mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-09 06:11:01 +01:00
368657a570
Summary: Okay, just a forewarning, this is horrible right now. But I think it's an okay enough start that it's worth sending what I've done. This rips out the old Phriction breadcrumb UI and replaces it with the new one that other apps have been starting to use. Test Plan: Looked at a bunch of Phriction pages. Reviewers: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4183
151 lines
3.7 KiB
PHP
151 lines
3.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group phriction
|
|
*/
|
|
final class PhrictionHistoryController
|
|
extends PhrictionController {
|
|
|
|
private $slug;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->slug = $data['slug'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$document = id(new PhrictionDocument())->loadOneWhere(
|
|
'slug = %s',
|
|
PhabricatorSlug::normalize($this->slug));
|
|
|
|
if (!$document) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$current = id(new PhrictionContent())->load($document->getContentID());
|
|
|
|
$pager = new AphrontPagerView();
|
|
$pager->setOffset($request->getInt('page'));
|
|
$pager->setURI($request->getRequestURI(), 'page');
|
|
|
|
$history = id(new PhrictionContent())->loadAllWhere(
|
|
'documentID = %d ORDER BY version DESC LIMIT %d, %d',
|
|
$document->getID(),
|
|
$pager->getOffset(),
|
|
$pager->getPageSize() + 1);
|
|
$history = $pager->sliceResults($history);
|
|
|
|
$author_phids = mpull($history, 'getAuthorPHID');
|
|
$handles = $this->loadViewerHandles($author_phids);
|
|
|
|
$rows = array();
|
|
foreach ($history as $content) {
|
|
|
|
$slug_uri = PhrictionDocument::getSlugURI($document->getSlug());
|
|
$version = $content->getVersion();
|
|
|
|
$diff_uri = new PhutilURI('/phriction/diff/'.$document->getID().'/');
|
|
|
|
$vs_previous = '<em>Created</em>';
|
|
if ($content->getVersion() != 1) {
|
|
$uri = $diff_uri
|
|
->alter('l', $content->getVersion() - 1)
|
|
->alter('r', $content->getVersion());
|
|
$vs_previous = phutil_render_tag(
|
|
'a',
|
|
array(
|
|
'href' => $uri,
|
|
),
|
|
'Show Change');
|
|
}
|
|
|
|
$vs_head = '<em>Current</em>';
|
|
if ($content->getID() != $document->getContentID()) {
|
|
$uri = $diff_uri
|
|
->alter('l', $content->getVersion())
|
|
->alter('r', $current->getVersion());
|
|
|
|
$vs_head = phutil_render_tag(
|
|
'a',
|
|
array(
|
|
'href' => $uri,
|
|
),
|
|
'Show Later Changes');
|
|
}
|
|
|
|
$change_type = PhrictionChangeType::getChangeTypeLabel(
|
|
$content->getChangeType());
|
|
|
|
$rows[] = array(
|
|
phabricator_date($content->getDateCreated(), $user),
|
|
phabricator_time($content->getDateCreated(), $user),
|
|
phutil_render_tag(
|
|
'a',
|
|
array(
|
|
'href' => $slug_uri.'?v='.$version,
|
|
),
|
|
'Version '.$version),
|
|
$handles[$content->getAuthorPHID()]->renderLink(),
|
|
$change_type,
|
|
phutil_escape_html($content->getDescription()),
|
|
$vs_previous,
|
|
$vs_head,
|
|
);
|
|
}
|
|
|
|
$table = new AphrontTableView($rows);
|
|
$table->setHeaders(
|
|
array(
|
|
'Date',
|
|
'Time',
|
|
'Version',
|
|
'Author',
|
|
'Type',
|
|
'Description',
|
|
'Against Previous',
|
|
'Against Current',
|
|
));
|
|
$table->setColumnClasses(
|
|
array(
|
|
'',
|
|
'right',
|
|
'pri',
|
|
'',
|
|
'',
|
|
'wide',
|
|
'',
|
|
'',
|
|
));
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
$crumb_views = $this->renderBreadcrumbs($document->getSlug());
|
|
foreach ($crumb_views as $view) {
|
|
$crumbs->addCrumb($view);
|
|
}
|
|
$crumbs->addCrumb(
|
|
id(new PhabricatorCrumbView())
|
|
->setName(pht('History'))
|
|
->setHref(
|
|
PhrictionDocument::getSlugURI($document->getSlug(), 'history')));
|
|
|
|
$panel = new AphrontPanelView();
|
|
$panel->setHeader('Document History');
|
|
$panel->appendChild($table);
|
|
$panel->appendChild($pager);
|
|
|
|
return $this->buildApplicationPage(
|
|
array(
|
|
$crumbs,
|
|
$panel,
|
|
),
|
|
array(
|
|
'title' => 'Document History',
|
|
'device' => true,
|
|
));
|
|
|
|
}
|
|
|
|
}
|