Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2892589
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
47 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/phriction/application/PhabricatorApplicationPhriction.php b/src/applications/phriction/application/PhabricatorApplicationPhriction.php
index f6119bff57..212b984ca5 100644
--- a/src/applications/phriction/application/PhabricatorApplicationPhriction.php
+++ b/src/applications/phriction/application/PhabricatorApplicationPhriction.php
@@ -1,62 +1,62 @@
<?php
final class PhabricatorApplicationPhriction extends PhabricatorApplication {
public function getShortDescription() {
- return 'Wiki';
+ return pht('Wiki');
}
public function getBaseURI() {
return '/w/';
}
public function getIconName() {
return 'phriction';
}
public function getHelpURI() {
return PhabricatorEnv::getDoclink('article/Phriction_User_Guide.html');
}
public function isEnabled() {
return PhabricatorEnv::getEnvConfig('phriction.enabled');
}
public function getTitleGlyph() {
return "\xE2\x9A\xA1";
}
public function getRoutes() {
return array(
// Match "/w/" with slug "/".
'/w(?P<slug>/)' => 'PhrictionDocumentController',
// Match "/w/x/y/z/" with slug "x/y/z/".
'/w/(?P<slug>.+/)' => 'PhrictionDocumentController',
'/phriction/' => array(
'' => 'PhrictionListController',
'list/(?P<view>[^/]+)/' => 'PhrictionListController',
'history(?P<slug>/)' => 'PhrictionHistoryController',
'history/(?P<slug>.+/)' => 'PhrictionHistoryController',
'edit/(?:(?P<id>[1-9]\d*)/)?' => 'PhrictionEditController',
'delete/(?P<id>[1-9]\d*)/' => 'PhrictionDeleteController',
'new/' => 'PhrictionNewController',
'preview/' => 'PhrictionDocumentPreviewController',
'diff/(?P<id>[1-9]\d*)/' => 'PhrictionDiffController',
),
);
}
public function getApplicationGroup() {
return self::GROUP_COMMUNICATION;
}
public function getApplicationOrder() {
return 0.140;
}
}
diff --git a/src/applications/phriction/controller/PhrictionController.php b/src/applications/phriction/controller/PhrictionController.php
index 0b7fa32ede..c242c4f64f 100644
--- a/src/applications/phriction/controller/PhrictionController.php
+++ b/src/applications/phriction/controller/PhrictionController.php
@@ -1,101 +1,101 @@
<?php
/**
* @group phriction
*/
abstract class PhrictionController extends PhabricatorController {
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
- $page->setApplicationName('Phriction');
+ $page->setApplicationName(pht('Phriction'));
$page->setBaseURI('/w/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9A\xA1");
$page->appendChild($view);
$page->setSearchDefaultScope(PhabricatorSearchScope::SCOPE_WIKI);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
public function buildSideNavView($filter = null, $for_app = false) {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/phriction/list/'));
if ($for_app) {
$nav->addFilter('', pht('Root Document'), '/w/');
$nav->addFilter('', pht('Create Document'), '/phriction/new');
}
- $nav->addLabel('Filters');
+ $nav->addLabel(pht('Filters'));
$nav->addFilter('active', pht('Active Documents'));
$nav->addFilter('all', pht('All Documents'));
$nav->addFilter('updates', pht('Recently Updated'));
$nav->selectFilter($filter, 'active');
return $nav;
}
public function buildApplicationMenu() {
return $this->buildSideNavView(null, true)->getMenu();
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addAction(
id(new PhabricatorMenuItemView())
->setName(pht('Create Document'))
->setHref('/phriction/new/')
->setWorkflow(true)
->setIcon('create'));
return $crumbs;
}
public function renderBreadcrumbs($slug) {
$ancestor_handles = array();
$ancestral_slugs = PhabricatorSlug::getAncestry($slug);
$ancestral_slugs[] = $slug;
if ($ancestral_slugs) {
$empty_slugs = array_fill_keys($ancestral_slugs, null);
$ancestors = id(new PhrictionDocument())->loadAllWhere(
'slug IN (%Ls)',
$ancestral_slugs);
$ancestors = mpull($ancestors, null, 'getSlug');
$ancestor_phids = mpull($ancestors, 'getPHID');
$handles = array();
if ($ancestor_phids) {
$handles = $this->loadViewerHandles($ancestor_phids);
}
$ancestor_handles = array();
foreach ($ancestral_slugs as $slug) {
if (isset($ancestors[$slug])) {
$ancestor_handles[] = $handles[$ancestors[$slug]->getPHID()];
} else {
$handle = new PhabricatorObjectHandle();
$handle->setName(PhabricatorSlug::getDefaultTitle($slug));
$handle->setURI(PhrictionDocument::getSlugURI($slug));
$ancestor_handles[] = $handle;
}
}
}
$breadcrumbs = array();
foreach ($ancestor_handles as $ancestor_handle) {
$breadcrumbs[] = id(new PhabricatorCrumbView())
->setName($ancestor_handle->getName())
->setHref($ancestor_handle->getUri());
}
return $breadcrumbs;
}
}
diff --git a/src/applications/phriction/controller/PhrictionDeleteController.php b/src/applications/phriction/controller/PhrictionDeleteController.php
index 13d43d25b8..16cb4a9edc 100644
--- a/src/applications/phriction/controller/PhrictionDeleteController.php
+++ b/src/applications/phriction/controller/PhrictionDeleteController.php
@@ -1,45 +1,45 @@
<?php
/**
* @group phriction
*/
final class PhrictionDeleteController extends PhrictionController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$document = id(new PhrictionDocument())->load($this->id);
if (!$document) {
return new Aphront404Response();
}
$document_uri = PhrictionDocument::getSlugURI($document->getSlug());
if ($request->isFormPost()) {
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
->setActor($user)
->delete();
return id(new AphrontRedirectResponse())->setURI($document_uri);
}
$dialog = id(new AphrontDialogView())
->setUser($user)
- ->setTitle('Delete document?')
+ ->setTitle(pht('Delete document?'))
->appendChild(
- 'Really delete this document? You can recover it later by reverting '.
- 'to a previous version.')
- ->addSubmitButton('Delete')
+ pht('Really delete this document? You can recover it later by '.
+ 'reverting to a previous version.'))
+ ->addSubmitButton(pht('Delete'))
->addCancelButton($document_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
diff --git a/src/applications/phriction/controller/PhrictionDiffController.php b/src/applications/phriction/controller/PhrictionDiffController.php
index ee03806fac..3701b7810f 100644
--- a/src/applications/phriction/controller/PhrictionDiffController.php
+++ b/src/applications/phriction/controller/PhrictionDiffController.php
@@ -1,265 +1,265 @@
<?php
/**
* @group phriction
*/
final class PhrictionDiffController
extends PhrictionController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$document = id(new PhrictionDocument())->load($this->id);
if (!$document) {
return new Aphront404Response();
}
$current = id(new PhrictionContent())->load($document->getContentID());
$l = $request->getInt('l');
$r = $request->getInt('r');
$ref = $request->getStr('ref');
if ($ref) {
list($l, $r) = explode(',', $ref);
}
$content = id(new PhrictionContent())->loadAllWhere(
'documentID = %d AND version IN (%Ld)',
$document->getID(),
array($l, $r));
$content = mpull($content, null, 'getVersion');
$content_l = idx($content, $l, null);
$content_r = idx($content, $r, null);
if (!$content_l || !$content_r) {
return new Aphront404Response();
}
$text_l = $content_l->getContent();
$text_r = $content_r->getContent();
$text_l = wordwrap($text_l, 80);
$text_r = wordwrap($text_r, 80);
$engine = new PhabricatorDifferenceEngine();
$changeset = $engine->generateChangesetFromFileContent($text_l, $text_r);
$changeset->setOldProperties(
array(
'Title' => $content_l->getTitle(),
));
$changeset->setNewProperties(
array(
'Title' => $content_r->getTitle(),
));
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
$parser = new DifferentialChangesetParser();
$parser->setChangeset($changeset);
$parser->setRenderingReference("{$l},{$r}");
$parser->setWhitespaceMode($whitespace_mode);
$engine = new PhabricatorMarkupEngine();
$engine->setViewer($user);
$engine->process();
$parser->setMarkupEngine($engine);
$spec = $request->getStr('range');
list($range_s, $range_e, $mask) =
DifferentialChangesetParser::parseRangeSpecification($spec);
$output = $parser->render($range_s, $range_e, $mask);
if ($request->isAjax()) {
return id(new PhabricatorChangesetResponse())
->setRenderedChangeset($output);
}
require_celerity_resource('differential-changeset-view-css');
require_celerity_resource('syntax-highlighting-css');
require_celerity_resource('phriction-document-css');
Javelin::initBehavior('differential-show-more', array(
'uri' => '/phriction/diff/'.$document->getID().'/',
'whitespace' => $whitespace_mode,
));
$slug = $document->getSlug();
$revert_l = $this->renderRevertButton($content_l, $current);
$revert_r = $this->renderRevertButton($content_r, $current);
$crumbs = new AphrontCrumbsView();
$crumbs->setCrumbs(
array(
'Phriction',
phutil_render_tag(
'a',
array(
'href' => PhrictionDocument::getSlugURI($slug),
),
phutil_escape_html($current->getTitle())),
phutil_render_tag(
'a',
array(
'href' => '/phriction/history/'.$document->getSlug().'/',
),
'History'),
phutil_escape_html("Changes Between Version {$l} and Version {$r}"),
));
$comparison_table = $this->renderComparisonTable(
array(
$content_r,
$content_l,
));
$navigation_table = null;
if ($l + 1 == $r) {
$nav_l = ($l > 1);
$nav_r = ($r != $current->getVersion());
$uri = $request->getRequestURI();
if ($nav_l) {
$link_l = phutil_render_tag(
'a',
array(
'href' => $uri->alter('l', $l - 1)->alter('r', $r - 1),
),
- "\xC2\xAB Previous Change");
+ pht("\xC2\xAB Previous Change"));
} else {
- $link_l = 'Original Change';
+ $link_l = pht('Original Change');
}
$link_r = null;
if ($nav_r) {
$link_r = phutil_render_tag(
'a',
array(
'href' => $uri->alter('l', $l + 1)->alter('r', $r + 1),
),
- "Next Change \xC2\xBB");
+ pht("Next Change \xC2\xBB"));
} else {
- $link_r = 'Most Recent Change';
+ $link_r = pht('Most Recent Change');
}
$navigation_table =
'<table class="phriction-history-nav-table">
<tr>
<td class="nav-prev">'.$link_l.'</td>
<td class="nav-next">'.$link_r.'</td>
</tr>
</table>';
}
$output =
'<div class="phriction-document-history-diff">'.
$comparison_table->render().
'<br />'.
'<br />'.
$navigation_table.
'<table class="phriction-revert-table">'.
'<tr><td>'.$revert_l.'</td><td>'.$revert_r.'</td>'.
'</table>'.
$output.
'</div>';
return $this->buildStandardPageResponse(
array(
$crumbs,
$output,
),
array(
- 'title' => 'Document History',
+ 'title' => pht('Document History'),
));
}
private function renderRevertButton(
PhrictionContent $content,
PhrictionContent $current) {
$document_id = $content->getDocumentID();
$version = $content->getVersion();
if ($content->getChangeType() == PhrictionChangeType::CHANGE_DELETE) {
// Don't show an edit/revert button for changes which deleted the content
// since it's silly.
return null;
}
if ($content->getID() == $current->getID()) {
return phutil_render_tag(
'a',
array(
'href' => '/phriction/edit/'.$document_id.'/',
'class' => 'button',
),
- 'Edit Current Version');
+ pht('Edit Current Version'));
}
return phutil_render_tag(
'a',
array(
'href' => '/phriction/edit/'.$document_id.'/?revert='.$version,
'class' => 'button',
),
- 'Revert to Version '.phutil_escape_html($version).'...');
+ pht('Revert to Version %s...', phutil_escape_html($version)));
}
private function renderComparisonTable(array $content) {
assert_instances_of($content, 'PhrictionContent');
$user = $this->getRequest()->getUser();
$phids = mpull($content, 'getAuthorPHID');
$handles = $this->loadViewerHandles($phids);
$rows = array();
foreach ($content as $c) {
$rows[] = array(
phabricator_date($c->getDateCreated(), $user),
phabricator_time($c->getDateCreated(), $user),
phutil_escape_html('Version '.$c->getVersion()),
$handles[$c->getAuthorPHID()]->renderLink(),
phutil_escape_html($c->getDescription()),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
- 'Date',
- 'Time',
- 'Version',
- 'Author',
- 'Description',
+ pht('Date'),
+ pht('Time'),
+ pht('Version'),
+ pht('Author'),
+ pht('Description'),
));
$table->setColumnClasses(
array(
'',
'right',
'pri',
'',
'wide',
));
return $table;
}
}
diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php
index 97b328bd67..64f51f9845 100644
--- a/src/applications/phriction/controller/PhrictionDocumentController.php
+++ b/src/applications/phriction/controller/PhrictionDocumentController.php
@@ -1,369 +1,371 @@
<?php
/**
* @group phriction
*/
final class PhrictionDocumentController
extends PhrictionController {
private $slug;
public function willProcessRequest(array $data) {
$this->slug = $data['slug'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$slug = PhabricatorSlug::normalize($this->slug);
if ($slug != $this->slug) {
$uri = PhrictionDocument::getSlugURI($slug);
// Canonicalize pages to their one true URI.
return id(new AphrontRedirectResponse())->setURI($uri);
}
require_celerity_resource('phriction-document-css');
$document = id(new PhrictionDocument())->loadOneWhere(
'slug = %s',
$slug);
$version_note = null;
if (!$document) {
$document = new PhrictionDocument();
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProject())->loadOneWhere(
'phrictionSlug = %s',
PhrictionDocument::getProjectSlugIdentifier($slug));
if (!$project) {
return new Aphront404Response();
}
}
$create_uri = '/phriction/edit/?slug='.$slug;
$create_sentence =
'You can <strong>'.
phutil_render_tag(
'a',
array(
'href' => $create_uri,
),
'create a new document').
'</strong>.';
$button = phutil_render_tag(
'a',
array(
'href' => $create_uri,
'class' => 'green button',
),
- 'Create Page');
+ pht('Create Page'));
$page_content =
'<div class="phriction-content">'.
- '<em>No content here!</em><br />'.
- 'No document found at <tt>'.phutil_escape_html($slug).'</tt>. '.
- $create_sentence.
+ '<em>'.pht('No content here!').'</em><br />'.
+ pht('No document found at <tt>%s</tt>.', phutil_escape_html($slug)).
+ ' '.$create_sentence.
'</div>';
- $page_title = 'Page Not Found';
+ $page_title = pht('Page Not Found');
$buttons = $button;
} else {
$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()) {
+ $vdate = phabricator_datetime($content->getDateCreated(), $user);
$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).'.');
+ pht('You are viewing an older version of this document, as it '.
+ 'appeared on %s.', $vdate));
}
} else {
$content = id(new PhrictionContent())->load($document->getContentID());
}
$page_title = $content->getTitle();
$project_phid = null;
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProject())->loadOneWhere(
'phrictionSlug = %s',
PhrictionDocument::getProjectSlugIdentifier($slug));
if ($project) {
$project_phid = $project->getPHID();
}
}
$phids = array_filter(
array(
$content->getAuthorPHID(),
$project_phid,
));
$handles = $this->loadViewerHandles($phids);
$age = time() - $content->getDateCreated();
$age = floor($age / (60 * 60 * 24));
if ($age < 1) {
$when = 'today';
} else if ($age == 1) {
$when = 'yesterday';
} else {
$when = "{$age} days ago";
}
$project_info = null;
if ($project_phid) {
$project_info =
'<br />This document is about the project '.
$handles[$project_phid]->renderLink().'.';
}
$index_link = phutil_render_tag(
'a',
array(
'href' => '/phriction/',
),
pht('Document Index'));
$byline =
'<div class="phriction-byline">'.
"Last updated {$when} by ".
$handles[$content->getAuthorPHID()]->renderLink().'.'.
$project_info.
'</div>';
$doc_status = $document->getStatus();
if ($doc_status == PhrictionDocumentStatus::STATUS_EXISTS) {
$core_content = $content->renderContent($user);
} else if ($doc_status == PhrictionDocumentStatus::STATUS_DELETED) {
$notice = new AphrontErrorView();
$notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice->setTitle('Document Deleted');
$notice->appendChild(
- 'This document has been deleted. You can edit it to put new content '.
- 'here, or use history to revert to an earlier version.');
+ pht('This document has been deleted. You can edit it to put new '.
+ 'content here, or use history to revert to an earlier version.'));
$core_content = $notice->render();
} else {
throw new Exception("Unknown document status '{$doc_status}'!");
}
$page_content =
'<div class="phriction-content">'.
$index_link.
$byline.
$core_content.
'</div>';
}
if ($version_note) {
$version_note = $version_note->render();
}
$children = $this->renderChildren($slug);
$crumbs = $this->buildApplicationCrumbs();
$crumb_views = $this->renderBreadcrumbs($slug);
foreach ($crumb_views as $view) {
$crumbs->addCrumb($view);
}
$actions = $this->buildActionView($user, $document);
$header = id(new PhabricatorHeaderView())
->setHeader($page_title);
$page =
$crumbs->render().
$header->render().
$actions->render().
$version_note.
$page_content.
$children;
return $this->buildApplicationPage(
array(
$page,
),
array(
'title' => $page_title,
'device' => true,
));
}
private function buildActionView(
PhabricatorUser $user,
PhrictionDocument $document) {
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$document,
PhabricatorPolicyCapability::CAN_EDIT);
$slug = PhabricatorSlug::normalize($this->slug);
$action_view = id(new PhabricatorActionListView())
->setUser($user)
->setObject($document)
->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Document'))
->setIcon('edit')
->setHref('/phriction/edit/'.$document->getID().'/'));
if ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS) {
$action_view->addAction(
id(new PhabricatorActionView())
->setName(pht('Delete Document'))
->setIcon('delete')
->setHref('/phriction/delete/'.$document->getID().'/')
->setWorkflow(true));
}
return
$action_view->addAction(
id(new PhabricatorActionView())
->setName(pht('View History'))
->setIcon('history')
->setHref(PhrictionDocument::getSlugURI($slug, 'history')));
}
private function renderChildren($slug) {
$document_dao = new PhrictionDocument();
$content_dao = new PhrictionContent();
$conn = $document_dao->establishConnection('r');
$limit = 50;
$d_child = PhabricatorSlug::getDepth($slug) + 1;
$d_grandchild = PhabricatorSlug::getDepth($slug) + 2;
// Select children and grandchildren.
$children = queryfx_all(
$conn,
'SELECT d.slug, d.depth, c.title FROM %T d JOIN %T c
ON d.contentID = c.id
WHERE d.slug LIKE %> AND d.depth IN (%d, %d)
AND d.status = %d
ORDER BY d.depth, c.title LIMIT %d',
$document_dao->getTableName(),
$content_dao->getTableName(),
($slug == '/' ? '' : $slug),
$d_child,
$d_grandchild,
PhrictionDocumentStatus::STATUS_EXISTS,
$limit);
if (!$children) {
return;
}
// We're going to render in one of three modes to try to accommodate
// different information scales:
//
// - If we found fewer than $limit rows, we know we have all the children
// and grandchildren and there aren't all that many. We can just render
// everything.
// - If we found $limit rows but the results included some grandchildren,
// we just throw them out and render only the children, as we know we
// have them all.
// - If we found $limit rows and the results have no grandchildren, we
// have a ton of children. Render them and then let the user know that
// this is not an exhaustive list.
if (count($children) == $limit) {
$more_children = true;
foreach ($children as $child) {
if ($child['depth'] == $d_grandchild) {
$more_children = false;
}
}
$show_grandchildren = false;
} else {
$show_grandchildren = true;
$more_children = false;
}
$grandchildren = array();
foreach ($children as $key => $child) {
if ($child['depth'] == $d_child) {
continue;
} else {
unset($children[$key]);
if ($show_grandchildren) {
$ancestors = PhabricatorSlug::getAncestry($child['slug']);
$grandchildren[end($ancestors)][] = $child;
}
}
}
// Fill in any missing children.
$known_slugs = ipull($children, null, 'slug');
foreach ($grandchildren as $slug => $ignored) {
if (empty($known_slugs[$slug])) {
$children[] = array(
'slug' => $slug,
'depth' => $d_child,
'title' => PhabricatorSlug::getDefaultTitle($slug),
'empty' => true,
);
}
}
$children = isort($children, 'title');
$list = array();
$list[] = '<ul>';
foreach ($children as $child) {
$list[] = $this->renderChildDocumentLink($child);
$grand = idx($grandchildren, $child['slug'], array());
if ($grand) {
$list[] = '<ul>';
foreach ($grand as $grandchild) {
$list[] = $this->renderChildDocumentLink($grandchild);
}
$list[] = '</ul>';
}
}
if ($more_children) {
- $list[] = '<li>More...</li>';
+ $list[] = '<li>'.pht('More...').'</li>';
}
$list[] = '</ul>';
$list = implode("\n", $list);
return
'<div class="phriction-children">'.
- '<div class="phriction-children-header">Document Hierarchy</div>'.
+ '<div class="phriction-children-header">'.
+ pht('Document Hierarchy').
+ '</div>'.
$list.
'</div>';
}
private function renderChildDocumentLink(array $info) {
- $title = nonempty($info['title'], '(Untitled Document)');
+ $title = nonempty($info['title'], pht('(Untitled Document)'));
$item = phutil_render_tag(
'a',
array(
'href' => PhrictionDocument::getSlugURI($info['slug']),
),
phutil_escape_html($title));
if (isset($info['empty'])) {
$item = '<em>'.$item.'</em>';
}
return '<li>'.$item.'</li>';
}
}
diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php
index f701839262..08243f4f7a 100644
--- a/src/applications/phriction/controller/PhrictionEditController.php
+++ b/src/applications/phriction/controller/PhrictionEditController.php
@@ -1,265 +1,266 @@
<?php
/**
* @group phriction
*/
final class PhrictionEditController
extends PhrictionController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
if ($this->id) {
$document = id(new PhrictionDocument())->load($this->id);
if (!$document) {
return new Aphront404Response();
}
$revert = $request->getInt('revert');
if ($revert) {
$content = id(new PhrictionContent())->loadOneWhere(
'documentID = %d AND version = %d',
$document->getID(),
$revert);
if (!$content) {
return new Aphront404Response();
}
} else {
$content = id(new PhrictionContent())->load($document->getContentID());
}
} else {
$slug = $request->getStr('slug');
$slug = PhabricatorSlug::normalize($slug);
if (!$slug) {
return new Aphront404Response();
}
$document = id(new PhrictionDocument())->loadOneWhere(
'slug = %s',
$slug);
if ($document) {
$content = id(new PhrictionContent())->load($document->getContentID());
} else {
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProject())->loadOneWhere(
'phrictionSlug = %s',
PhrictionDocument::getProjectSlugIdentifier($slug));
if (!$project) {
return new Aphront404Response();
}
}
$document = new PhrictionDocument();
$document->setSlug($slug);
$content = new PhrictionContent();
$content->setSlug($slug);
$default_title = PhabricatorSlug::getDefaultTitle($slug);
$content->setTitle($default_title);
}
}
if ($request->getBool('nodraft')) {
$draft = null;
$draft_key = null;
} else {
if ($document->getPHID()) {
$draft_key = $document->getPHID().':'.$content->getVersion();
} else {
$draft_key = 'phriction:'.$content->getSlug();
}
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$draft_key);
}
require_celerity_resource('phriction-document-css');
$e_title = true;
$notes = null;
$errors = array();
if ($request->isFormPost()) {
$title = $request->getStr('title');
$notes = $request->getStr('description');
if (!strlen($title)) {
- $e_title = 'Required';
- $errors[] = 'Document title is required.';
+ $e_title = pht('Required');
+ $errors[] = pht('Document title is required.');
} else {
$e_title = null;
}
if ($document->getID()) {
if ($content->getTitle() == $title &&
$content->getContent() == $request->getStr('content')) {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
- $dialog->setTitle('No Edits');
+ $dialog->setTitle(pht('No Edits'));
$dialog->appendChild(
- '<p>You did not make any changes to the document.</p>');
+ '<p>'.pht('You did not make any changes to the document.').'</p>');
$dialog->addCancelButton($request->getRequestURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
} else if (!strlen($request->getStr('content'))) {
// We trigger this only for new pages. For existing pages, deleting
// all the content counts as deleting the page.
$dialog = new AphrontDialogView();
$dialog->setUser($user);
- $dialog->setTitle('Empty Page');
+ $dialog->setTitle(pht('Empty Page'));
$dialog->appendChild(
- '<p>You can not create an empty document.</p>');
+ '<p>'.pht('You can not create an empty document.').'</p>');
$dialog->addCancelButton($request->getRequestURI());
return id(new AphrontDialogResponse())->setDialog($dialog);
}
if (!count($errors)) {
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
->setActor($user)
->setTitle($title)
->setContent($request->getStr('content'))
->setDescription($notes);
$editor->save();
if ($draft) {
$draft->delete();
}
$uri = PhrictionDocument::getSlugURI($document->getSlug());
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$error_view = null;
if ($errors) {
$error_view = id(new AphrontErrorView())
- ->setTitle('Form Errors')
+ ->setTitle(pht('Form Errors'))
->setErrors($errors);
}
if ($document->getID()) {
- $panel_header = 'Edit Phriction Document';
- $submit_button = 'Save Changes';
+ $panel_header = pht('Edit Phriction Document');
+ $submit_button = pht('Save Changes');
} else {
- $panel_header = 'Create New Phriction Document';
- $submit_button = 'Create Document';
+ $panel_header = pht('Create New Phriction Document');
+ $submit_button = pht('Create Document');
}
$uri = $document->getSlug();
$uri = PhrictionDocument::getSlugURI($uri);
$uri = PhabricatorEnv::getProductionURI($uri);
$cancel_uri = PhrictionDocument::getSlugURI($document->getSlug());
if ($draft &&
strlen($draft->getDraft()) &&
($draft->getDraft() != $content->getContent())) {
$content_text = $draft->getDraft();
$discard = phutil_render_tag(
'a',
array(
'href' => $request->getRequestURI()->alter('nodraft', true),
),
- 'discard this draft');
+ pht('discard this draft'));
$draft_note = new AphrontErrorView();
$draft_note->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$draft_note->setTitle('Recovered Draft');
$draft_note->appendChild(
- '<p>Showing a saved draft of your edits, you can '.$discard.'.</p>');
+ '<p>'.pht('Showing a saved draft of your edits, you can %s.',
+ $discard).'</p>');
} else {
$content_text = $content->getContent();
$draft_note = null;
}
$form = id(new AphrontFormView())
->setUser($user)
->setWorkflow(true)
->setAction($request->getRequestURI()->getPath())
->addHiddenInput('slug', $document->getSlug())
->addHiddenInput('nodraft', $request->getBool('nodraft'))
->appendChild(
id(new AphrontFormTextControl())
- ->setLabel('Title')
+ ->setLabel(pht('Title'))
->setValue($content->getTitle())
->setError($e_title)
->setName('title'))
->appendChild(
id(new AphrontFormStaticControl())
- ->setLabel('URI')
+ ->setLabel(pht('URI'))
->setValue($uri))
->appendChild(
id(new PhabricatorRemarkupControl())
- ->setLabel('Content')
+ ->setLabel(pht('Content'))
->setValue($content_text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('content')
->setID('document-textarea')
->setUser($user))
->appendChild(
id(new AphrontFormTextControl())
- ->setLabel('Edit Notes')
+ ->setLabel(pht('Edit Notes'))
->setValue($notes)
->setError(null)
->setName('description'))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($cancel_uri)
->setValue($submit_button));
$panel = id(new AphrontPanelView())
->setNoBackground()
->setHeader($panel_header)
->appendChild($form);
$preview_panel =
'<div class="aphront-panel-preview aphront-panel-preview-wide">
<div class="phriction-document-preview-header">
- Document Preview
+ '.pht('Document Preview').'
</div>
<div id="document-preview">
<div class="aphront-panel-preview-loading-text">
- Loading preview...
+ '.pht('Loading preview...').'
</div>
</div>
</div>';
Javelin::initBehavior(
'phriction-document-preview',
array(
'preview' => 'document-preview',
'textarea' => 'document-textarea',
'uri' => '/phriction/preview/?draftkey='.$draft_key,
));
return $this->buildStandardPageResponse(
array(
$draft_note,
$error_view,
$panel,
$preview_panel,
),
array(
- 'title' => 'Edit Document',
+ 'title' => pht('Edit Document'),
));
}
}
diff --git a/src/applications/phriction/controller/PhrictionHistoryController.php b/src/applications/phriction/controller/PhrictionHistoryController.php
index e6bb0a9aa1..c822c5e120 100644
--- a/src/applications/phriction/controller/PhrictionHistoryController.php
+++ b/src/applications/phriction/controller/PhrictionHistoryController.php
@@ -1,152 +1,152 @@
<?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>';
+ $vs_previous = '<em>'.pht('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');
+ pht('Show Change'));
}
- $vs_head = '<em>Current</em>';
+ $vs_head = '<em>'.pht('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');
+ pht('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),
+ pht('Version %s', $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',
+ pht('Date'),
+ pht('Time'),
+ pht('Version'),
+ pht('Author'),
+ pht('Type'),
+ pht('Description'),
+ pht('Against Previous'),
+ pht('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->setHeader(pht('Document History'));
$panel->setNoBackground();
$panel->appendChild($table);
$panel->appendChild($pager);
return $this->buildApplicationPage(
array(
$crumbs,
$panel,
),
array(
- 'title' => 'Document History',
+ 'title' => pht('Document History'),
'device' => true,
));
}
}
diff --git a/src/applications/phriction/controller/PhrictionListController.php b/src/applications/phriction/controller/PhrictionListController.php
index 269a70288c..c4b8968609 100644
--- a/src/applications/phriction/controller/PhrictionListController.php
+++ b/src/applications/phriction/controller/PhrictionListController.php
@@ -1,161 +1,161 @@
<?php
/**
* @group phriction
*/
final class PhrictionListController
extends PhrictionController {
private $view;
public function willProcessRequest(array $data) {
$this->view = idx($data, 'view');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$views = array(
'active' => pht('Active Documents'),
'all' => pht('All Documents'),
'updates' => pht('Recently Updated'),
);
if (empty($views[$this->view])) {
$this->view = 'active';
}
$nav = $this->buildSideNavView($this->view);
$header = id(new PhabricatorHeaderView())
->setHeader($views[$this->view]);
$nav->appendChild(
array(
$header,
));
$pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'page');
$pager->setOffset($request->getInt('page'));
$documents = $this->loadDocuments($pager);
$content = mpull($documents, 'getContent');
$phids = mpull($content, 'getAuthorPHID');
$handles = $this->loadViewerHandles($phids);
$rows = array();
foreach ($documents as $document) {
$content = $document->getContent();
$rows[] = array(
$handles[$content->getAuthorPHID()]->renderLink(),
phutil_render_tag(
'a',
array(
'href' => PhrictionDocument::getSlugURI($document->getSlug()),
),
phutil_escape_html($content->getTitle())),
phabricator_date($content->getDateCreated(), $user),
phabricator_time($content->getDateCreated(), $user),
);
}
$document_table = new AphrontTableView($rows);
$document_table->setHeaders(
array(
- 'Last Editor',
- 'Title',
- 'Last Update',
- 'Time',
+ pht('Last Editor'),
+ pht('Title'),
+ pht('Last Update'),
+ pht('Time'),
));
$document_table->setColumnClasses(
array(
'',
'wide pri',
'right',
'right',
));
$view_header = $views[$this->view];
$panel = new AphrontPanelView();
$panel->setNoBackground();
$panel->appendChild($document_table);
$panel->appendChild($pager);
$nav->appendChild($panel);
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Phriction Main'),
));
}
private function loadDocuments(AphrontPagerView $pager) {
// TODO: Do we want/need a query object for this?
$document_dao = new PhrictionDocument();
$content_dao = new PhrictionContent();
$conn = $document_dao->establishConnection('r');
switch ($this->view) {
case 'active':
$data = queryfx_all(
$conn,
'SELECT * FROM %T WHERE status != %d ORDER BY id DESC LIMIT %d, %d',
$document_dao->getTableName(),
PhrictionDocumentStatus::STATUS_DELETED,
$pager->getOffset(),
$pager->getPageSize() + 1);
break;
case 'all':
$data = queryfx_all(
$conn,
'SELECT * FROM %T ORDER BY id DESC LIMIT %d, %d',
$document_dao->getTableName(),
$pager->getOffset(),
$pager->getPageSize() + 1);
break;
case 'updates':
// TODO: This query is a little suspicious, verify we don't need to key
// or change it once we get more data.
$data = queryfx_all(
$conn,
'SELECT d.* FROM %T d JOIN %T c ON c.documentID = d.id
GROUP BY c.documentID
ORDER BY MAX(c.id) DESC LIMIT %d, %d',
$document_dao->getTableName(),
$content_dao->getTableName(),
$pager->getOffset(),
$pager->getPageSize() + 1);
break;
default:
throw new Exception("Unknown view '{$this->view}'!");
}
$data = $pager->sliceResults($data);
$documents = $document_dao->loadAllFromArray($data);
if ($documents) {
$content = $content_dao->loadAllWhere(
'documentID IN (%Ld)',
mpull($documents, 'getID'));
$content = mpull($content, null, 'getDocumentID');
foreach ($documents as $document) {
$document->attachContent($content[$document->getID()]);
}
}
return $documents;
}
}
diff --git a/src/applications/phriction/storage/PhrictionContent.php b/src/applications/phriction/storage/PhrictionContent.php
index 0307455b7f..6c13c55fb7 100644
--- a/src/applications/phriction/storage/PhrictionContent.php
+++ b/src/applications/phriction/storage/PhrictionContent.php
@@ -1,103 +1,103 @@
<?php
/**
* @task markup Markup Interface
*
* @group phriction
*/
final class PhrictionContent extends PhrictionDAO
implements PhabricatorMarkupInterface {
const MARKUP_FIELD_BODY = 'markup:body';
protected $id;
protected $documentID;
protected $version;
protected $authorPHID;
protected $title;
protected $slug;
protected $content;
protected $description;
protected $changeType;
protected $changeRef;
public function renderContent(PhabricatorUser $viewer) {
return PhabricatorMarkupEngine::renderOneObject(
$this,
self::MARKUP_FIELD_BODY,
$viewer);
}
/* -( Markup Interface )--------------------------------------------------- */
/**
* @task markup
*/
public function getMarkupFieldKey($field) {
if ($this->shouldUseMarkupCache($field)) {
$id = $this->getID();
} else {
$id = PhabricatorHash::digest($this->getMarkupText($field));
}
return "phriction:{$field}:{$id}";
}
/**
* @task markup
*/
public function getMarkupText($field) {
return $this->getContent();
}
/**
* @task markup
*/
public function newMarkupEngine($field) {
return PhabricatorMarkupEngine::newPhrictionMarkupEngine();
}
/**
* @task markup
*/
public function didMarkupText(
$field,
$output,
PhutilMarkupEngine $engine) {
$toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::renderTableOfContents(
$engine);
if ($toc) {
$toc =
'<div class="phabricator-remarkup-toc">'.
'<div class="phabricator-remarkup-toc-header">'.
- 'Table of Contents'.
+ pht('Table of Contents').
'</div>'.
$toc.
'</div>';
}
return
'<div class="phabricator-remarkup">'.
$toc.
$output.
'</div>';
}
/**
* @task markup
*/
public function shouldUseMarkupCache($field) {
return (bool)$this->getID();
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 17:02 (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126758
Default Alt Text
(47 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment