1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 09:20:58 +01:00

Fixed Phriction status displays when browsing history

Summary: Refs T2686 - also did some pht()'s except one

Test Plan: browsed around in Phriction, including History. looked fine.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2686

Differential Revision: https://secure.phabricator.com/D5275
This commit is contained in:
Anh Nhan Nguyen 2013-03-07 08:28:46 -08:00 committed by epriestley
parent 76880916d0
commit 1797e51428

View file

@ -44,14 +44,23 @@ final class PhrictionDocumentController
} }
} }
$create_uri = '/phriction/edit/?slug='.$slug; $create_uri = '/phriction/edit/?slug='.$slug;
$page_content = hsprintf(
'<div class="phriction-content">'. $no_content_head = pht('No content here!');
'<em>No content here!</em><br />'. $no_content_body = pht(
'No document found at <tt>%s</tt>. '. 'No document found at %s. You can <strong>'.
'You can <strong><a href="%s">create a new document</a></strong>.'. '<a href="%s">create a new document here</a></strong>.',
'</div>', phutil_tag('tt', array(), $slug),
$slug,
$create_uri); $create_uri);
$no_content_text = hsprintf(
'<em>%s</em><br />%s',
$no_content_head,
$no_content_body);
$page_content = phutil_tag(
'div',
array('class' => 'phriction-content'),
$no_content_text);
$page_title = pht('Page Not Found'); $page_title = pht('Page Not Found');
} else { } else {
$version = $request->getInt('v'); $version = $request->getInt('v');
@ -99,19 +108,20 @@ final class PhrictionDocumentController
$age = floor($age / (60 * 60 * 24)); $age = floor($age / (60 * 60 * 24));
if ($age < 1) { if ($age < 1) {
$when = 'today'; $when = pht('today');
} else if ($age == 1) { } else if ($age == 1) {
$when = 'yesterday'; $when = pht('yesterday');
} else { } else {
$when = "{$age} days ago"; $when = pht("%d days ago", $age);
} }
$project_info = null; $project_info = null;
if ($project_phid) { if ($project_phid) {
$project_info = hsprintf( $project_info = hsprintf(
'<br />This document is about the project %s.', '<br />%s',
$handles[$project_phid]->renderLink()); pht('This document is about the project %s.',
$handles[$project_phid]->renderLink()));
} }
$index_link = phutil_tag( $index_link = phutil_tag(
@ -122,32 +132,36 @@ final class PhrictionDocumentController
pht('Document Index')); pht('Document Index'));
$byline = hsprintf( $byline = hsprintf(
'<div class="phriction-byline">Last updated %s by %s.%s</div>', '<div class="phriction-byline">%s.%s</div>',
pht('Last updated %s by %s.',
$when, $when,
$handles[$content->getAuthorPHID()]->renderLink(), $handles[$content->getAuthorPHID()]->renderLink()),
$project_info); $project_info);
$doc_status = $document->getStatus(); $doc_status = $document->getStatus();
if ($doc_status == PhrictionDocumentStatus::STATUS_EXISTS) { $current_status = $content->getChangeType();
if ($current_status == PhrictionChangeType::CHANGE_EDIT ||
$current_status == PhrictionChangeType::CHANGE_MOVE_HERE) {
$core_content = $content->renderContent($user); $core_content = $content->renderContent($user);
} else if ($doc_status == PhrictionDocumentStatus::STATUS_DELETED) { } else if ($current_status == PhrictionChangeType::CHANGE_DELETE) {
$notice = new AphrontErrorView(); $notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Document Deleted'); $notice->setTitle(pht('Document Deleted'));
$notice->appendChild( $notice->appendChild(
pht('This document has been deleted. You can edit it to put new '. pht('This document has been deleted. You can edit it to put new '.
'content here, or use history to revert to an earlier version.')); 'content here, or use history to revert to an earlier version.'));
$core_content = $notice->render(); $core_content = $notice->render();
} else if ($doc_status == PhrictionDocumentStatus::STATUS_STUB) { } else if ($current_status == PhrictionChangeType::CHANGE_STUB) {
$notice = new AphrontErrorView(); $notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Empty Document'); $notice->setTitle(pht('Empty Document'));
$notice->appendChild( $notice->appendChild(
pht('This document is empty. You can edit it to put some proper '. pht('This document is empty. You can edit it to put some proper '.
'content here.')); 'content here.'));
$core_content = $notice->render(); $core_content = $notice->render();
} else if ($doc_status == PhrictionDocumentStatus::STATUS_MOVED) { } else if ($current_status == PhrictionChangeType::CHANGE_MOVE_AWAY) {
$new_doc_id = $content->getChangeRef(); $new_doc_id = $content->getChangeRef();
$new_doc = new PhrictionDocument(); $new_doc = new PhrictionDocument();
$new_doc->load($new_doc_id); $new_doc->load($new_doc_id);
@ -167,7 +181,7 @@ final class PhrictionDocumentController
} }
$move_notice = null; $move_notice = null;
if ($content->getChangeType() == PhrictionChangeType::CHANGE_MOVE_HERE) { if ($current_status == PhrictionChangeType::CHANGE_MOVE_HERE) {
$from_doc_id = $content->getChangeRef(); $from_doc_id = $content->getChangeRef();
$from_doc = id(new PhrictionDocument())->load($from_doc_id); $from_doc = id(new PhrictionDocument())->load($from_doc_id);
$slug_uri = PhrictionDocument::getSlugURI($from_doc->getSlug()); $slug_uri = PhrictionDocument::getSlugURI($from_doc->getSlug());
@ -237,7 +251,7 @@ final class PhrictionDocumentController
if (!$document->getID()) { if (!$document->getID()) {
return $action_view->addAction( return $action_view->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setName(pht('Create this document')) ->setName(pht('Create This Document'))
->setIcon('create') ->setIcon('create')
->setHref('/phriction/edit/?slug='.$slug)); ->setHref('/phriction/edit/?slug='.$slug));
} }