Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionHistoryController.php
<?php | <?php | ||||
final class PhrictionHistoryController | final class PhrictionHistoryController | ||||
extends PhrictionController { | extends PhrictionController { | ||||
private $slug; | |||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
$this->slug = $request->getURIData('slug'); | $slug = $request->getURIData('slug'); | ||||
$document = id(new PhrictionDocumentQuery()) | $document = id(new PhrictionDocumentQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withSlugs(array(PhabricatorSlug::normalize($this->slug))) | ->withSlugs(array(PhabricatorSlug::normalize($slug))) | ||||
->needContent(true) | ->needContent(true) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$document) { | if (!$document) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$current = $document->getContent(); | $current = $document->getContent(); | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumb_views = $this->renderBreadcrumbs($document->getSlug()); | $crumb_views = $this->renderBreadcrumbs($document->getSlug()); | ||||
foreach ($crumb_views as $view) { | foreach ($crumb_views as $view) { | ||||
$crumbs->addCrumb($view); | $crumbs->addCrumb($view); | ||||
} | } | ||||
$crumbs->addTextCrumb( | $crumbs->addTextCrumb( | ||||
pht('History'), | pht('History'), | ||||
PhrictionDocument::getSlugURI($document->getSlug(), 'history')); | PhrictionDocument::getSlugURI($document->getSlug(), 'history')); | ||||
$crumbs->setBorder(true); | |||||
$header = new PHUIHeaderView(); | $header = new PHUIHeaderView(); | ||||
$header->setHeader(phutil_tag( | $header->setHeader(phutil_tag( | ||||
'a', | 'a', | ||||
array('href' => PhrictionDocument::getSlugURI($document->getSlug())), | array('href' => PhrictionDocument::getSlugURI($document->getSlug())), | ||||
head($history)->getTitle())); | head($history)->getTitle())); | ||||
$header->setSubheader(pht('Document History')); | $header->setSubheader(pht('Document History')); | ||||
$obj_box = id(new PHUIObjectBoxView()) | $obj_box = id(new PHUIObjectBoxView()) | ||||
->setHeader($header) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
->setObjectList($list); | ->setObjectList($list); | ||||
$pager = id(new PHUIBoxView()) | $pager = id(new PHUIBoxView()) | ||||
->addClass('ml') | ->addClass('ml') | ||||
->appendChild($pager); | ->appendChild($pager); | ||||
return $this->buildApplicationPage( | $header = id(new PHUIHeaderView()) | ||||
array( | ->setHeader(pht('Document History: %s', head($history)->getTitle())) | ||||
$crumbs, | ->setHeaderIcon('fa-history'); | ||||
$view = id(new PHUITwoColumnView()) | |||||
->setHeader($header) | |||||
->setFooter(array( | |||||
$obj_box, | $obj_box, | ||||
$pager, | $pager, | ||||
), | |||||
array( | |||||
'title' => pht('Document History'), | |||||
)); | )); | ||||
$title = pht('Document History'); | |||||
return $this->newPage() | |||||
->setTitle($title) | |||||
->setCrumbs($crumbs) | |||||
->appendChild($view); | |||||
} | } | ||||
} | } |