Differential D21160 Diff 50381 src/applications/differential/view/DifferentialChangesetDetailView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/view/DifferentialChangesetDetailView.php
| <?php | <?php | ||||
| final class DifferentialChangesetDetailView extends AphrontView { | final class DifferentialChangesetDetailView extends AphrontView { | ||||
| private $changeset; | private $changeset; | ||||
| private $buttons = array(); | private $buttons = array(); | ||||
| private $editable; | private $editable; | ||||
| private $symbolIndex; | private $symbolIndex; | ||||
| private $id; | private $id; | ||||
| private $vsChangesetID; | private $vsChangesetID; | ||||
| private $renderURI; | private $renderURI; | ||||
| private $renderingRef; | private $renderingRef; | ||||
| private $autoload; | private $autoload; | ||||
| private $repository; | private $repository; | ||||
| private $diff; | private $diff; | ||||
| private $changesetResponse; | private $changesetResponse; | ||||
| private $branch; | |||||
| public function setAutoload($autoload) { | public function setAutoload($autoload) { | ||||
| $this->autoload = $autoload; | $this->autoload = $autoload; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getAutoload() { | public function getAutoload() { | ||||
| return $this->autoload; | return $this->autoload; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public function setEditable($editable) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setSymbolIndex($symbol_index) { | public function setSymbolIndex($symbol_index) { | ||||
| $this->symbolIndex = $symbol_index; | $this->symbolIndex = $symbol_index; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setBranch($branch) { | |||||
| $this->branch = $branch; | |||||
| return $this; | |||||
| } | |||||
| public function getBranch() { | |||||
| return $this->branch; | |||||
| } | |||||
| public function getID() { | public function getID() { | ||||
| if (!$this->id) { | if (!$this->id) { | ||||
| $this->id = celerity_generate_unique_node_id(); | $this->id = celerity_generate_unique_node_id(); | ||||
| } | } | ||||
| return $this->id; | return $this->id; | ||||
| } | } | ||||
| public function setID($id) { | public function setID($id) { | ||||
| $this->id = $id; | $this->id = $id; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setVsChangesetID($vs_changeset_id) { | public function setVsChangesetID($vs_changeset_id) { | ||||
| $this->vsChangesetID = $vs_changeset_id; | $this->vsChangesetID = $vs_changeset_id; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getVsChangesetID() { | public function getVsChangesetID() { | ||||
| return $this->vsChangesetID; | return $this->vsChangesetID; | ||||
| } | } | ||||
| public function render() { | public function render() { | ||||
| $viewer = $this->getViewer(); | |||||
| $this->requireResource('differential-changeset-view-css'); | $this->requireResource('differential-changeset-view-css'); | ||||
| $this->requireResource('syntax-highlighting-css'); | $this->requireResource('syntax-highlighting-css'); | ||||
| Javelin::initBehavior('phabricator-oncopy', array()); | Javelin::initBehavior('phabricator-oncopy', array()); | ||||
| $changeset = $this->changeset; | $changeset = $this->changeset; | ||||
| $class = 'differential-changeset'; | $class = 'differential-changeset'; | ||||
| if (!$this->editable) { | if (!$this->editable) { | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | if ($response) { | ||||
| $is_loaded = false; | $is_loaded = false; | ||||
| $changeset_markup = null; | $changeset_markup = null; | ||||
| $changeset_state = null; | $changeset_state = null; | ||||
| } | } | ||||
| $path_parts = trim($display_filename, '/'); | $path_parts = trim($display_filename, '/'); | ||||
| $path_parts = explode('/', $path_parts); | $path_parts = explode('/', $path_parts); | ||||
| $show_path_uri = null; | |||||
| $show_directory_uri = null; | |||||
| $repository = $this->getRepository(); | |||||
| if ($repository) { | |||||
| $diff = $this->getDiff(); | |||||
| if ($diff) { | |||||
| $repo_path = $changeset->getAbsoluteRepositoryPath($repository, $diff); | |||||
| $repo_dir = dirname($repo_path); | |||||
| if ($repo_dir === $repo_path) { | |||||
| $repo_dir = null; | |||||
| } | |||||
| $show_path_uri = $repository->getDiffusionBrowseURIForPath( | |||||
| $viewer, | |||||
| $repo_path, | |||||
| idx($changeset->getMetadata(), 'line:first'), | |||||
| $this->getBranch()); | |||||
| if ($repo_dir !== null) { | |||||
| $repo_dir = rtrim($repo_dir, '/').'/'; | |||||
| $show_directory_uri = $repository->getDiffusionBrowseURIForPath( | |||||
| $viewer, | |||||
| $repo_dir, | |||||
| null, | |||||
| $this->getBranch()); | |||||
| } | |||||
| } | |||||
| } | |||||
| if ($show_path_uri) { | |||||
| $show_path_uri = phutil_string_cast($show_path_uri); | |||||
| } | |||||
| if ($show_directory_uri) { | |||||
| $show_directory_uri = phutil_string_cast($show_directory_uri); | |||||
| } | |||||
| return javelin_tag( | return javelin_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'sigil' => 'differential-changeset', | 'sigil' => 'differential-changeset', | ||||
| 'meta' => array( | 'meta' => array( | ||||
| 'left' => $left_id, | 'left' => $left_id, | ||||
| 'right' => $right_id, | 'right' => $right_id, | ||||
| 'renderURI' => $this->getRenderURI(), | 'renderURI' => $this->getRenderURI(), | ||||
| 'ref' => $this->getRenderingRef(), | 'ref' => $this->getRenderingRef(), | ||||
| 'autoload' => $this->getAutoload(), | 'autoload' => $this->getAutoload(), | ||||
| 'displayPath' => hsprintf('%s', $display_parts), | 'displayPath' => hsprintf('%s', $display_parts), | ||||
| 'icon' => $display_icon, | 'icon' => $display_icon, | ||||
| 'pathParts' => $path_parts, | 'pathParts' => $path_parts, | ||||
| 'pathIconIcon' => $changeset->getPathIconIcon(), | 'pathIconIcon' => $changeset->getPathIconIcon(), | ||||
| 'pathIconColor' => $changeset->getPathIconColor(), | 'pathIconColor' => $changeset->getPathIconColor(), | ||||
| 'isLowImportance' => $changeset->getIsLowImportanceChangeset(), | 'isLowImportance' => $changeset->getIsLowImportanceChangeset(), | ||||
| 'isOwned' => $changeset->getIsOwnedChangeset(), | 'isOwned' => $changeset->getIsOwnedChangeset(), | ||||
| 'editorURI' => $this->getEditorURI(), | 'editorURI' => $this->getEditorURI(), | ||||
| 'editorConfigureURI' => $this->getEditorConfigureURI(), | 'editorConfigureURI' => $this->getEditorConfigureURI(), | ||||
| 'loaded' => $is_loaded, | 'loaded' => $is_loaded, | ||||
| 'changesetState' => $changeset_state, | 'changesetState' => $changeset_state, | ||||
| 'showPathURI' => $show_path_uri, | |||||
| 'showDirectoryURI' => $show_directory_uri, | |||||
| ), | ), | ||||
| 'class' => $class, | 'class' => $class, | ||||
| 'id' => $id, | 'id' => $id, | ||||
| ), | ), | ||||
| array( | array( | ||||
| id(new PhabricatorAnchorView()) | id(new PhabricatorAnchorView()) | ||||
| ->setAnchorName($changeset->getAnchorName()) | ->setAnchorName($changeset->getAnchorName()) | ||||
| ->setNavigationMarker(true) | ->setNavigationMarker(true) | ||||
| ▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines | |||||