mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 09:12:41 +01:00
Allow Phriction document history to be viewed
Summary: Simple access to document history. Test Plan: Looked at document history. Reviewed By: codeblock Reviewers: hsb, codeblock, jungejason, tuomaspelkonen, aran Commenters: hsb CC: aran, codeblock, hsb Differential Revision: 658
This commit is contained in:
parent
87436ff8a3
commit
0c49b39658
4 changed files with 40 additions and 2 deletions
|
@ -28,6 +28,7 @@ class PhrictionDocumentController
|
|||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$slug = PhrictionDocument::normalizeSlug($this->slug);
|
||||
if ($slug != $this->slug) {
|
||||
|
@ -43,6 +44,7 @@ class PhrictionDocumentController
|
|||
$slug);
|
||||
|
||||
$breadcrumbs = $this->renderBreadcrumbs($slug);
|
||||
$version_note = null;
|
||||
|
||||
if (!$document) {
|
||||
$create_uri = '/phriction/edit/?slug='.$slug;
|
||||
|
@ -68,7 +70,28 @@ class PhrictionDocumentController
|
|||
),
|
||||
'Create Page');
|
||||
} else {
|
||||
$content = id(new PhrictionContent())->load($document->getContentID());
|
||||
$version = $request->getInt('v');
|
||||
if ($version) {
|
||||
$content = id(new PhrictionContent())->loadOneWhere(
|
||||
'documentID = %d AND version = %d',
|
||||
$document->getID(),
|
||||
$version);
|
||||
if (!$content) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
if ($content->getID() != $document->getContentID()) {
|
||||
$version_note = new AphrontErrorView();
|
||||
$version_note->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
|
||||
$version_note->setTitle('Older Version');
|
||||
$version_note->appendChild(
|
||||
'You are viewing an older version of this document, as it '.
|
||||
'appeared on '.
|
||||
phabricator_datetime($content->getDateCreated(), $user).'.');
|
||||
}
|
||||
} else {
|
||||
$content = id(new PhrictionContent())->load($document->getContentID());
|
||||
}
|
||||
$page_title = $content->getTitle();
|
||||
|
||||
$phids = array($content->getAuthorPHID());
|
||||
|
@ -110,12 +133,17 @@ class PhrictionDocumentController
|
|||
'Edit Page');
|
||||
}
|
||||
|
||||
if ($version_note) {
|
||||
$version_note = $version_note->render();
|
||||
}
|
||||
|
||||
$page =
|
||||
'<div class="phriction-header">'.
|
||||
$button.
|
||||
'<h1>'.phutil_escape_html($page_title).'</h1>'.
|
||||
$breadcrumbs.
|
||||
'</div>'.
|
||||
$version_note.
|
||||
$page_content;
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/markup/engine');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle');
|
||||
|
@ -14,6 +15,8 @@ phutil_require_module('phabricator', 'applications/phriction/controller/base');
|
|||
phutil_require_module('phabricator', 'applications/phriction/storage/content');
|
||||
phutil_require_module('phabricator', 'applications/phriction/storage/document');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
|
|
@ -57,11 +57,17 @@ class PhrictionHistoryController
|
|||
foreach ($history as $content) {
|
||||
|
||||
$uri = PhrictionDocument::getSlugURI($document->getSlug());
|
||||
$version = $content->getVersion();
|
||||
|
||||
$rows[] = array(
|
||||
phabricator_date($content->getDateCreated(), $user),
|
||||
phabricator_time($content->getDateCreated(), $user),
|
||||
(int)$content->getVersion(),
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $uri.'?v='.$version,
|
||||
),
|
||||
'Version '.$version),
|
||||
$handles[$content->getAuthorPHID()]->renderLink(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ phutil_require_module('phabricator', 'view/control/table');
|
|||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue