Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionDiffController.php
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | $comparison_table = $this->renderComparisonTable( | ||||
array( | array( | ||||
$content_r, | $content_r, | ||||
$content_l, | $content_l, | ||||
)); | )); | ||||
$navigation_table = null; | $navigation_table = null; | ||||
if ($l + 1 == $r) { | if ($l + 1 == $r) { | ||||
$nav_l = ($l > 1); | $nav_l = ($l > 1); | ||||
$nav_r = ($r != $current->getVersion()); | $nav_r = ($r != $document->getMaxVersion()); | ||||
$uri = $request->getRequestURI(); | $uri = $request->getRequestURI(); | ||||
if ($nav_l) { | if ($nav_l) { | ||||
$link_l = phutil_tag( | $link_l = phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $uri->alter('l', $l - 1)->alter('r', $r - 1), | 'href' => $uri->alter('l', $l - 1)->alter('r', $r - 1), | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | private function renderRevertButton( | ||||
$document_id = $document->getID(); | $document_id = $document->getID(); | ||||
$version = $content->getVersion(); | $version = $content->getVersion(); | ||||
$hidden_statuses = array( | $hidden_statuses = array( | ||||
PhrictionChangeType::CHANGE_DELETE => true, // Silly | PhrictionChangeType::CHANGE_DELETE => true, // Silly | ||||
PhrictionChangeType::CHANGE_MOVE_AWAY => true, // Plain silly | PhrictionChangeType::CHANGE_MOVE_AWAY => true, // Plain silly | ||||
PhrictionChangeType::CHANGE_STUB => true, // Utterly silly | PhrictionChangeType::CHANGE_STUB => true, // Utterly silly | ||||
); | ); | ||||
if (isset($hidden_statuses[$content->getChangeType()])) { | if (isset($hidden_statuses[$content->getChangeType()])) { | ||||
// Don't show an edit/revert button for changes which deleted, moved or | // Don't show an edit/revert button for changes which deleted, moved or | ||||
// stubbed the content since it's silly. | // stubbed the content since it's silly. | ||||
return null; | return null; | ||||
} | } | ||||
if ($content->getID() == $current->getID()) { | if ($version == $current->getVersion()) { | ||||
return phutil_tag( | $label = pht('Edit Current Version %s...', new PhutilNumber($version)); | ||||
'a', | } else if ($version < $current->getVersion()) { | ||||
array( | $label = pht('Edit Older Version %s...', new PhutilNumber($version)); | ||||
'href' => '/phriction/edit/'.$document_id.'/', | } else { | ||||
'class' => 'button button-grey', | $label = pht('Edit Draft Version %s...', new PhutilNumber($version)); | ||||
), | |||||
pht('Edit Current Version')); | |||||
} | } | ||||
return phutil_tag( | return phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => '/phriction/edit/'.$document_id.'/?revert='.$version, | 'href' => '/phriction/edit/'.$document_id.'/?revert='.$version, | ||||
'class' => 'button button-grey', | 'class' => 'button button-grey', | ||||
), | ), | ||||
pht('Revert to Version %s...', $version)); | $label); | ||||
} | } | ||||
private function renderComparisonTable(array $content) { | private function renderComparisonTable(array $content) { | ||||
assert_instances_of($content, 'PhrictionContent'); | assert_instances_of($content, 'PhrictionContent'); | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$phids = mpull($content, 'getAuthorPHID'); | $phids = mpull($content, 'getAuthorPHID'); | ||||
Show All 34 Lines |