Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/audit/application/PhabricatorApplicationAudit.php b/src/applications/audit/application/PhabricatorApplicationAudit.php
index 8e050e380d..d24e3a71a0 100644
--- a/src/applications/audit/application/PhabricatorApplicationAudit.php
+++ b/src/applications/audit/application/PhabricatorApplicationAudit.php
@@ -1,80 +1,80 @@
<?php
final class PhabricatorApplicationAudit extends PhabricatorApplication {
public function getShortDescription() {
- return 'Audit Code';
+ return pht('Audit Code');
}
public function getBaseURI() {
return '/audit/';
}
public function getIconName() {
return 'audit';
}
public function getHelpURI() {
return PhabricatorEnv::getDoclink('article/Audit_User_Guide.html');
}
public function getRoutes() {
return array(
'/audit/' => array(
'' => 'PhabricatorAuditListController',
'view/(?P<filter>[^/]+)/(?:(?P<name>[^/]+)/)?'
=> 'PhabricatorAuditListController',
'addcomment/' => 'PhabricatorAuditAddCommentController',
'preview/(?P<id>[1-9]\d*)/' => 'PhabricatorAuditPreviewController',
),
);
}
public function getApplicationGroup() {
return self::GROUP_CORE;
}
public function getApplicationOrder() {
return 0.130;
}
public function loadStatus(PhabricatorUser $user) {
$status = array();
$phids = PhabricatorAuditCommentEditor::loadAuditPHIDsForUser($user);
$audits = id(new PhabricatorAuditQuery())
->withAuditorPHIDs($phids)
->withStatus(PhabricatorAuditQuery::STATUS_OPEN)
->withAwaitingUser($user)
->execute();
$count = count($audits);
$type = $count
? PhabricatorApplicationStatusView::TYPE_INFO
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView())
->setType($type)
->setText(pht('%d Commit(s) Awaiting Audit', $count))
->setCount($count);
$commits = id(new PhabricatorAuditCommitQuery())
->withAuthorPHIDs($phids)
->withStatus(PhabricatorAuditQuery::STATUS_OPEN)
->execute();
$count = count($commits);
$type = $count
? PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION
: PhabricatorApplicationStatusView::TYPE_EMPTY;
$status[] = id(new PhabricatorApplicationStatusView())
->setType($type)
->setText(pht('%d Problem Commit(s)', $count))
->setCount($count);
return $status;
}
}
diff --git a/src/applications/audit/controller/PhabricatorAuditController.php b/src/applications/audit/controller/PhabricatorAuditController.php
index 52bcdb7e26..0c9f4ef318 100644
--- a/src/applications/audit/controller/PhabricatorAuditController.php
+++ b/src/applications/audit/controller/PhabricatorAuditController.php
@@ -1,19 +1,19 @@
<?php
abstract class PhabricatorAuditController extends PhabricatorController {
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
- $page->setApplicationName('Audit');
+ $page->setApplicationName(pht('Audit'));
$page->setBaseURI('/audit/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9C\x8D");
$page->appendChild($view);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
}
diff --git a/src/applications/audit/controller/PhabricatorAuditListController.php b/src/applications/audit/controller/PhabricatorAuditListController.php
index 5019a95225..d858dec6bf 100644
--- a/src/applications/audit/controller/PhabricatorAuditListController.php
+++ b/src/applications/audit/controller/PhabricatorAuditListController.php
@@ -1,489 +1,489 @@
<?php
final class PhabricatorAuditListController extends PhabricatorAuditController {
private $filter;
private $name;
private $filterStatus;
public function willProcessRequest(array $data) {
$this->filter = idx($data, 'filter');
$this->name = idx($data, 'name');
}
public function processRequest() {
$request = $this->getRequest();
$nav = $this->buildNavAndSelectFilter();
if ($request->isFormPost()) {
// If the list filter is POST'ed, redirect to GET so the page can be
// bookmarked.
$uri = $request->getRequestURI();
$phid = head($request->getArr('set_phid'));
$user = id(new PhabricatorUser())->loadOneWhere(
'phid = %s',
$phid);
$uri = $request->getRequestURI();
if ($user) {
$username = phutil_escape_uri($user->getUsername());
$uri = '/audit/view/'.$this->filter.'/'.$username.'/';
} else if ($phid) {
$uri = $request->getRequestURI();
$uri = $uri->alter('phid', $phid);
}
return id(new AphrontRedirectResponse())->setURI($uri);
}
$this->filterStatus = $request->getStr('status', 'all');
$handle = $this->loadHandle();
$nav->appendChild($this->buildListFilters($handle));
$title = null;
$message = null;
if (!$handle) {
switch ($this->filter) {
case 'project':
- $title = 'Choose A Project';
- $message = 'Choose a project to view audits for.';
+ $title = pht('Choose A Project');
+ $message = pht('Choose a project to view audits for.');
break;
case 'package':
case 'packagecommits':
- $title = 'Choose a Package';
- $message = 'Choose a package to view audits for.';
+ $title = pht('Choose a Package');
+ $message = pht('Choose a package to view audits for.');
break;
}
}
if (!$message) {
$nav->appendChild($this->buildViews($handle));
} else {
$panel = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NODATA)
->setTitle($title)
->appendChild($message);
$nav->appendChild($panel);
}
return $this->buildStandardPageResponse(
$nav,
array(
- 'title' => 'Audits',
+ 'title' => pht('Audits'),
));
}
private function buildNavAndSelectFilter() {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/audit/view/'));
- $nav->addLabel('Active');
- $nav->addFilter('active', 'Need Attention');
+ $nav->addLabel(pht('Active'));
+ $nav->addFilter('active', pht('Need Attention'));
- $nav->addLabel('Audits');
- $nav->addFilter('audits', 'All');
- $nav->addFilter('user', 'By User');
- $nav->addFilter('project', 'By Project');
- $nav->addFilter('package', 'By Package');
+ $nav->addLabel(pht('Audits'));
+ $nav->addFilter('audits', pht('All'));
+ $nav->addFilter('user', pht('By User'));
+ $nav->addFilter('project', pht('By Project'));
+ $nav->addFilter('package', pht('By Package'));
- $nav->addLabel('Commits');
- $nav->addFilter('commits', 'All');
- $nav->addFilter('author', 'By Author');
- $nav->addFilter('packagecommits', 'By Package');
+ $nav->addLabel(pht('Commits'));
+ $nav->addFilter('commits', pht('All'));
+ $nav->addFilter('author', pht('By Author'));
+ $nav->addFilter('packagecommits', pht('By Package'));
$this->filter = $nav->selectFilter($this->filter, 'active');
return $nav;
}
private function buildListFilters(PhabricatorObjectHandle $handle = null) {
$request = $this->getRequest();
$user = $request->getUser();
$form = new AphrontFormView();
$form->setUser($user);
$show_status = false;
$show_user = false;
$show_project = false;
$show_package = false;
switch ($this->filter) {
case 'audits':
case 'commits':
$show_status = true;
break;
case 'active':
$show_user = true;
break;
case 'author':
case 'user':
$show_user = true;
$show_status = true;
break;
case 'project':
$show_project = true;
$show_status = true;
break;
case 'package':
case 'packagecommits':
$show_package = true;
$show_status = true;
break;
}
if ($show_user || $show_project || $show_package) {
if ($show_user) {
$uri = '/typeahead/common/users/';
- $label = 'User';
+ $label = pht('User');
} else if ($show_project) {
$uri = '/typeahead/common/projects/';
- $label = 'Project';
+ $label = pht('Project');
} else if ($show_package) {
$uri = '/typeahead/common/packages/';
- $label = 'Package';
+ $label = pht('Package');
}
$tok_value = null;
if ($handle) {
$tok_value = array(
$handle->getPHID() => $handle->getFullName(),
);
}
$form->appendChild(
id(new AphrontFormTokenizerControl())
->setName('set_phid')
->setLabel($label)
->setLimit(1)
->setDatasource($uri)
->setValue($tok_value));
}
if ($show_status) {
$form->appendChild(
id(new AphrontFormToggleButtonsControl())
->setName('status')
- ->setLabel('Status')
+ ->setLabel(pht('Status'))
->setBaseURI($request->getRequestURI(), 'status')
->setValue($this->filterStatus)
->setButtons(
array(
- 'all' => 'All',
- 'open' => 'Open',
+ 'all' => pht('All'),
+ 'open' => pht('Open'),
)));
}
$form->appendChild(
id(new AphrontFormSubmitControl())
- ->setValue('Filter Audits'));
+ ->setValue(pht('Filter Audits')));
$view = new AphrontListFilterView();
$view->appendChild($form);
return $view;
}
private function loadHandle() {
$request = $this->getRequest();
$default = null;
switch ($this->filter) {
case 'user':
case 'active':
case 'author':
$default = $request->getUser()->getPHID();
if ($this->name) {
$user = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
$this->name);
if ($user) {
$default = $user->getPHID();
}
}
break;
}
$phid = $request->getStr('phid', $default);
if (!$phid) {
return null;
}
$phids = array($phid);
$handles = $this->loadViewerHandles($phids);
$handle = $handles[$phid];
$this->validateHandle($handle);
return $handle;
}
private function validateHandle(PhabricatorObjectHandle $handle) {
switch ($this->filter) {
case 'active':
case 'user':
case 'author':
if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_USER) {
throw new Exception("PHID must be a user PHID!");
}
break;
case 'package':
case 'packagecommits':
if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_OPKG) {
throw new Exception("PHID must be a package PHID!");
}
break;
case 'project':
if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_PROJ) {
throw new Exception("PHID must be a project PHID!");
}
break;
case 'audits':
case 'commits':
break;
default:
throw new Exception("Unknown filter '{$this->filter}'!");
}
}
private function buildViews(PhabricatorObjectHandle $handle = null) {
$views = array();
switch ($this->filter) {
case 'active':
$views[] = $this->buildAuditView($handle);
$views[] = $this->buildCommitView($handle);
break;
case 'audits':
case 'user':
case 'package':
case 'project':
$views[] = $this->buildAuditView($handle);
break;
case 'commits':
case 'packagecommits':
case 'author':
$views[] = $this->buildCommitView($handle);
break;
}
return $views;
}
private function buildAuditView(PhabricatorObjectHandle $handle = null) {
$request = $this->getRequest();
$query = new PhabricatorAuditQuery();
$use_pager = ($this->filter != 'active');
if ($use_pager) {
$pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
$query->setOffset($pager->getOffset());
$query->setLimit($pager->getPageSize() + 1);
}
$awaiting = null;
$phids = null;
switch ($this->filter) {
case 'user':
case 'active':
$obj = id(new PhabricatorUser())->loadOneWhere(
'phid = %s',
$handle->getPHID());
if (!$obj) {
throw new Exception("Invalid user!");
}
$phids = PhabricatorAuditCommentEditor::loadAuditPHIDsForUser($obj);
$awaiting = $obj;
break;
case 'project':
case 'package':
$phids = array($handle->getPHID());
break;
case 'audits';
break;
default:
throw new Exception("Unknown filter!");
}
if ($phids) {
$query->withAuditorPHIDs($phids);
}
if ($awaiting) {
$query->withAwaitingUser($awaiting);
}
switch ($this->filter) {
case 'audits':
case 'user':
case 'project':
case 'package':
switch ($this->filterStatus) {
case 'open':
$query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
break;
}
break;
case 'active':
$query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
break;
}
if ($handle) {
$handle_name = phutil_escape_html($handle->getName());
} else {
$handle_name = null;
}
switch ($this->filter) {
case 'active':
- $header = 'Required Audits';
- $nodata = 'No commits require your audit.';
+ $header = pht('Required Audits');
+ $nodata = pht('No commits require your audit.');
break;
case 'user':
- $header = "Audits for {$handle_name}";
- $nodata = "No matching audits by {$handle_name}.";
+ $header = pht("Audits for %s", $handle_name);
+ $nodata = pht("No matching audits by %s.", $handle_name);
break;
case 'audits':
- $header = "Audits";
- $nodata = "No matching audits.";
+ $header = pht('Audits');
+ $nodata = pht('No matching audits.');
break;
case 'project':
- $header = "Audits in Project '{$handle_name}'";
- $nodata = "No matching audits in project '{$handle_name}'.";
+ $header = pht("Audits in Project %s", $handle_name);
+ $nodata = pht("No matching audits in project %s.", $handle_name);
break;
case 'package':
- $header = "Audits for Package '{$handle_name}'";
- $nodata = "No matching audits in package '{$handle_name}'.";
+ $header = pht("Audits for Package %s", $handle_name);
+ $nodata = pht("No matching audits in package %s.", $handle_name);
break;
}
$query->needCommitData(true);
$audits = $query->execute();
if ($use_pager) {
$audits = $pager->sliceResults($audits);
}
$view = new PhabricatorAuditListView();
$view->setAudits($audits);
$view->setCommits($query->getCommits());
$view->setUser($request->getUser());
$view->setNoDataString($nodata);
$phids = $view->getRequiredHandlePHIDs();
$handles = $this->loadViewerHandles($phids);
$view->setHandles($handles);
$panel = new AphrontPanelView();
$panel->setHeader($header);
$panel->appendChild($view);
$panel->setNoBackground();
if ($use_pager) {
$panel->appendChild($pager);
}
return $panel;
}
private function buildCommitView(PhabricatorObjectHandle $handle = null) {
$request = $this->getRequest();
$query = new PhabricatorAuditCommitQuery();
$query->needCommitData(true);
$query->needAudits(true);
$use_pager = ($this->filter != 'active');
if ($use_pager) {
$pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
$query->setOffset($pager->getOffset());
$query->setLimit($pager->getPageSize() + 1);
}
switch ($this->filter) {
case 'active':
case 'author':
$query->withAuthorPHIDs(array($handle->getPHID()));
break;
case 'packagecommits':
$query->withPackagePHIDs(array($handle->getPHID()));
break;
}
switch ($this->filter) {
case 'active':
$query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
break;
case 'author':
case 'packagecommits':
switch ($this->filterStatus) {
case 'open':
$query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
break;
}
break;
}
if ($handle) {
$handle_name = phutil_escape_html($handle->getName());
} else {
$handle_name = null;
}
switch ($this->filter) {
case 'active':
- $header = 'Problem Commits';
- $nodata = 'None of your commits have open concerns.';
+ $header = pht('Problem Commits');
+ $nodata = pht('None of your commits have open concerns.');
break;
case 'author':
- $header = "Commits by {$handle_name}";
- $nodata = "No matching commits by {$handle_name}.";
+ $header = pht("Commits by %s", $handle_name);
+ $nodata = pht("No matching commits by %s.", $handle_name);
break;
case 'commits':
- $header = "Commits";
- $nodata = "No matching commits.";
+ $header = pht("Commits");
+ $nodata = pht("No matching commits.");
break;
case 'packagecommits':
- $header = "Commits in Package '{$handle_name}'";
- $nodata = "No matching commits in package '{$handle_name}'.";
+ $header = pht("Commits in Package %s", $handle_name);
+ $nodata = pht("No matching commits in package %s.", $handle_name);
break;
}
$commits = $query->execute();
if ($use_pager) {
$commits = $pager->sliceResults($commits);
}
$view = new PhabricatorAuditCommitListView();
$view->setUser($request->getUser());
$view->setCommits($commits);
$view->setNoDataString($nodata);
$phids = $view->getRequiredHandlePHIDs();
$handles = $this->loadViewerHandles($phids);
$view->setHandles($handles);
$panel = new AphrontPanelView();
$panel->setHeader($header);
$panel->appendChild($view);
$panel->setNoBackground();
if ($use_pager) {
$panel->appendChild($pager);
}
return $panel;
}
}
diff --git a/src/applications/macro/application/PhabricatorApplicationMacro.php b/src/applications/macro/application/PhabricatorApplicationMacro.php
index fea4d3a75d..1dc24aae8a 100644
--- a/src/applications/macro/application/PhabricatorApplicationMacro.php
+++ b/src/applications/macro/application/PhabricatorApplicationMacro.php
@@ -1,40 +1,40 @@
<?php
final class PhabricatorApplicationMacro extends PhabricatorApplication {
public function getBaseURI() {
return '/macro/';
}
public function getShortDescription() {
- return 'Image Macros and Memes';
+ return pht('Image Macros and Memes');
}
public function getIconName() {
return 'macro';
}
public function getTitleGlyph() {
return "\xE2\x9A\x98";
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/macro/' => array(
'' => 'PhabricatorMacroListController',
'create/' => 'PhabricatorMacroEditController',
'view/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroViewController',
'comment/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroCommentController',
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroEditController',
'disable/(?P<id>[1-9]\d*)/' => 'PhabricatorMacroDisableController',
'meme/' => 'PhabricatorMacroMemeController',
'meme/create/' => 'PhabricatorMacroMemeDialogController',
),
);
}
}
diff --git a/src/applications/macro/controller/PhabricatorMacroController.php b/src/applications/macro/controller/PhabricatorMacroController.php
index 8ae3e7f1bc..7df1e98b4d 100644
--- a/src/applications/macro/controller/PhabricatorMacroController.php
+++ b/src/applications/macro/controller/PhabricatorMacroController.php
@@ -1,41 +1,45 @@
<?php
abstract class PhabricatorMacroController
extends PhabricatorController {
protected function buildSideNavView($for_app = false, $has_search = false) {
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
- $nav->addLabel('Create');
- $nav->addFilter('', 'Create Macro', $this->getApplicationURI('/create/'));
+ $nav->addLabel(pht('Create'));
+ $nav->addFilter('',
+ pht('Create Macro'),
+ $this->getApplicationURI('/create/'));
}
- $nav->addLabel('Macros');
- $nav->addFilter('/', 'All Macros');
+ $nav->addLabel(pht('Macros'));
+ $nav->addFilter('/', pht('All Macros'));
if ($has_search) {
- $nav->addFilter('search', 'Search', $this->getRequest()->getRequestURI());
+ $nav->addFilter('search',
+ pht('Search'),
+ $this->getRequest()->getRequestURI());
}
return $nav;
}
public function buildApplicationMenu() {
return $this->buildSideNavView($for_app = true)->getMenu();
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addAction(
id(new PhabricatorMenuItemView())
->setName(pht('Create Macro'))
->setHref($this->getApplicationURI('/create/'))
->setIcon('create'));
return $crumbs;
}
}
diff --git a/src/applications/macro/controller/PhabricatorMacroDisableController.php b/src/applications/macro/controller/PhabricatorMacroDisableController.php
index 8be2409068..3e9e44aa9e 100644
--- a/src/applications/macro/controller/PhabricatorMacroDisableController.php
+++ b/src/applications/macro/controller/PhabricatorMacroDisableController.php
@@ -1,56 +1,56 @@
<?php
final class PhabricatorMacroDisableController
extends PhabricatorMacroController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
if (!$macro) {
return new Aphront404Response();
}
$view_uri = $this->getApplicationURI('/view/'.$this->id.'/');
if ($request->isDialogFormPost() || $macro->getIsDisabled()) {
$xaction = id(new PhabricatorMacroTransaction())
->setTransactionType(PhabricatorMacroTransactionType::TYPE_DISABLED)
->setNewValue($macro->getIsDisabled() ? 0 : 1);
$editor = id(new PhabricatorMacroEditor())
->setActor($user)
->setContentSource(
PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_WEB,
array(
'ip' => $request->getRemoteAddr(),
)));
$xactions = $editor->applyTransactions($macro, array($xaction));
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
$dialog = new AphrontDialogView();
$dialog
->setUser($request->getUser())
- ->setTitle('Really disable macro?')
+ ->setTitle(pht('Really disable macro?'))
->appendChild(
- '<p>Really disable the much-beloved image macro "'.
- phutil_escape_html($macro->getName()).'"? It will be sorely missed.'.
+ '<p>'.pht('Really disable the much-beloved image macro %s? '.
+ 'It will be sorely missed.', phutil_escape_html($macro->getName())).
'</p>')
->setSubmitURI($this->getApplicationURI('/disable/'.$this->id.'/'))
- ->addSubmitButton('Disable')
+ ->addSubmitButton(pht('Disable'))
->addCancelButton($view_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
diff --git a/src/applications/macro/controller/PhabricatorMacroEditController.php b/src/applications/macro/controller/PhabricatorMacroEditController.php
index 129dd26b7e..1d4e1e0d57 100644
--- a/src/applications/macro/controller/PhabricatorMacroEditController.php
+++ b/src/applications/macro/controller/PhabricatorMacroEditController.php
@@ -1,247 +1,248 @@
<?php
final class PhabricatorMacroEditController
extends PhabricatorMacroController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
if ($this->id) {
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
if (!$macro) {
return new Aphront404Response();
}
} else {
$macro = new PhabricatorFileImageMacro();
}
$errors = array();
$e_name = true;
$e_file = true;
$file = null;
$request = $this->getRequest();
$user = $request->getUser();
if ($request->isFormPost()) {
$original = clone $macro;
$new_name = null;
if ($request->getBool('name_form') || !$macro->getID()) {
$new_name = $request->getStr('name');
$macro->setName($new_name);
if (!strlen($macro->getName())) {
- $errors[] = 'Macro name is required.';
- $e_name = 'Required';
+ $errors[] = pht('Macro name is required.');
+ $e_name = pht('Required');
} else if (!preg_match('/^[a-z0-9_-]{3,}$/', $macro->getName())) {
- $errors[] = 'Macro must be at least three characters long and '.
+ $errors[] = pht('Macro must be at least three characters long and '.
'contain only lowercase letters, digits, hyphen and '.
- 'underscore.';
- $e_name = 'Invalid';
+ 'underscore.');
+ $e_name = pht('Invalid');
} else {
$e_name = null;
}
}
$file = null;
if ($request->getFileExists('file')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['file'],
array(
'name' => $request->getStr('name'),
'authorPHID' => $user->getPHID(),
));
} else if ($request->getStr('phid')) {
$file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$request->getStr('phid'));
}
if ($file) {
if (!$file->isViewableInBrowser()) {
$errors[] = pht('You must upload an image.');
$e_file = pht('Invalid');
} else {
$macro->setFilePHID($file->getPHID());
$e_file = null;
}
}
if (!$macro->getID() && !$file) {
- $errors[] = 'You must upload an image to create a macro.';
+ $errors[] = pht('You must upload an image to create a macro.');
$e_file = pht('Required');
}
if (!$errors) {
try {
$xactions = array();
if ($new_name !== null) {
$xactions[] = id(new PhabricatorMacroTransaction())
->setTransactionType(PhabricatorMacroTransactionType::TYPE_NAME)
->setNewValue($new_name);
}
if ($file) {
$xactions[] = id(new PhabricatorMacroTransaction())
->setTransactionType(PhabricatorMacroTransactionType::TYPE_FILE)
->setNewValue($file->getPHID());
}
$editor = id(new PhabricatorMacroEditor())
->setActor($user)
->setContinueOnNoEffect(true)
->setContentSource(
PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_WEB,
array(
'ip' => $request->getRemoteAddr(),
)));
$xactions = $editor->applyTransactions($original, $xactions);
$view_uri = $this->getApplicationURI('/view/'.$original->getID().'/');
return id(new AphrontRedirectResponse())->setURI($view_uri);
} catch (AphrontQueryDuplicateKeyException $ex) {
throw $ex;
- $errors[] = 'Macro name is not unique!';
- $e_name = 'Duplicate';
+ $errors[] = pht('Macro name is not unique!');
+ $e_name = pht('Duplicate');
}
}
}
if ($errors) {
$error_view = new AphrontErrorView();
- $error_view->setTitle('Form Errors');
+ $error_view->setTitle(pht('Form Errors'));
$error_view->setErrors($errors);
} else {
$error_view = null;
}
$current_file = null;
if ($macro->getFilePHID()) {
$current_file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$macro->getFilePHID());
}
$form = new AphrontFormView();
$form->setFlexible(true);
$form->addHiddenInput('name_form', 1);
$form->setUser($request->getUser());
$form
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormTextControl())
- ->setLabel('Name')
+ ->setLabel(pht('Name'))
->setName('name')
->setValue($macro->getName())
- ->setCaption('This word or phrase will be replaced with the image.')
+ ->setCaption(
+ pht('This word or phrase will be replaced with the image.'))
->setError($e_name));
if (!$macro->getID()) {
if ($current_file) {
$current_file_view = id(new PhabricatorFileLinkView())
->setFilePHID($current_file->getPHID())
->setFileName($current_file->getName())
->setFileViewable(true)
->setFileViewURI($current_file->getBestURI())
->render();
$form->addHiddenInput('phid', $current_file->getPHID());
$form->appendChild(
id(new AphrontFormMarkupControl())
- ->setLabel('Selected File')
+ ->setLabel(pht('Selected File'))
->setValue($current_file_view));
$other_label = pht('Change File');
} else {
$other_label = pht('File');
}
$form->appendChild(
id(new AphrontFormFileControl())
->setLabel($other_label)
->setName('file')
->setError($e_file));
}
$view_uri = $this->getApplicationURI('/view/'.$macro->getID().'/');
if ($macro->getID()) {
$cancel_uri = $view_uri;
} else {
$cancel_uri = $this->getApplicationURI();
}
$form
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save Image Macro'))
->addCancelButton($cancel_uri));
$crumbs = $this->buildApplicationCrumbs();
if ($macro->getID()) {
$title = pht('Edit Image Macro');
$crumb = pht('Edit');
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setHref($view_uri)
->setName(pht('Macro "%s"', $macro->getName())));
} else {
$title = pht('Create Image Macro');
$crumb = pht('Create');
}
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setHref($request->getRequestURI())
->setName($crumb));
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$upload = null;
if ($macro->getID()) {
$upload_header = id(new PhabricatorHeaderView())
->setHeader(pht('Upload New File'));
$upload_form = id(new AphrontFormView())
->setFlexible(true)
->setEncType('multipart/form-data')
->setUser($request->getUser())
->appendChild(
id(new AphrontFormFileControl())
- ->setLabel('File')
+ ->setLabel(pht('File'))
->setName('file'))
->appendChild(
id(new AphrontFormSubmitControl())
- ->setValue('Upload File'));
+ ->setValue(pht('Upload File')));
$upload = array($upload_header, $upload_form);
}
return $this->buildApplicationPage(
array(
$crumbs,
$header,
$error_view,
$form,
$upload,
),
array(
'title' => $title,
));
}
}
diff --git a/src/applications/macro/controller/PhabricatorMacroListController.php b/src/applications/macro/controller/PhabricatorMacroListController.php
index d52f52327f..3756d346a0 100644
--- a/src/applications/macro/controller/PhabricatorMacroListController.php
+++ b/src/applications/macro/controller/PhabricatorMacroListController.php
@@ -1,165 +1,165 @@
<?php
final class PhabricatorMacroListController
extends PhabricatorMacroController {
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$macro_table = new PhabricatorFileImageMacro();
$file_table = new PhabricatorFile();
$conn = $macro_table->establishConnection('r');
$where = array();
$join = array();
$join[] = qsprintf($conn, '%T m', $macro_table->getTableName());
$filter = $request->getStr('name');
if (strlen($filter)) {
$where[] = qsprintf($conn, 'm.name LIKE %~', $filter);
}
$authors = $request->getArr('authors');
if ($authors) {
$join[] = qsprintf(
$conn,
'%T f ON m.filePHID = f.phid',
$file_table->getTableName());
$where[] = qsprintf($conn, 'f.authorPHID IN (%Ls)', $authors);
}
$has_search = $where;
if ($has_search) {
$macros = queryfx_all(
$conn,
'SELECT m.*
FROM '.implode(' JOIN ', $join).'
WHERE '.implode(' AND ', $where));
$macros = $macro_table->loadAllFromArray($macros);
$nodata = pht('There are no macros matching the filter.');
} else {
$pager = new AphrontPagerView();
$pager->setOffset($request->getInt('page'));
$macros = $macro_table->loadAllWhere(
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
$pager->getOffset(),
$pager->getPageSize());
// Get an exact count since the size here is reasonably going to be a few
// thousand at most in any reasonable case.
$count = queryfx_one(
$conn,
'SELECT COUNT(*) N FROM %T',
$macro_table->getTableName());
$count = $count['N'];
$pager->setCount($count);
$pager->setURI($request->getRequestURI(), 'page');
$nodata = pht('There are no image macros yet.');
}
if ($authors) {
$author_phids = array_combine($authors, $authors);
} else {
$author_phids = array();
}
$file_phids = mpull($macros, 'getFilePHID');
$files = array();
if ($file_phids) {
$files = $file_table->loadAllWhere(
"phid IN (%Ls)",
$file_phids);
$author_phids += mpull($files, 'getAuthorPHID', 'getAuthorPHID');
}
$files_map = mpull($files, null, 'getPHID');
$this->loadHandles($author_phids);
$author_handles = array_select_keys($this->getLoadedHandles(), $authors);
$filter_form = id(new AphrontFormView())
->setMethod('GET')
->setUser($request->getUser())
->appendChild(
id(new AphrontFormTextControl())
->setName('name')
- ->setLabel('Name')
+ ->setLabel(pht('Name'))
->setValue($filter))
->appendChild(
id(new AphrontFormTokenizerControl())
->setName('authors')
->setLabel(pht('Authors'))
->setDatasource('/typeahead/common/users/')
->setValue(mpull($author_handles, 'getFullName')))
->appendChild(
id(new AphrontFormSubmitControl())
- ->setValue('Filter Image Macros'));
+ ->setValue(pht('Filter Image Macros')));
$filter_view = new AphrontListFilterView();
$filter_view->appendChild($filter_form);
$nav = $this->buildSideNavView(
$for_app = false,
$has_search);
$nav->selectFilter($has_search ? 'search' : '/');
$nav->appendChild($filter_view);
$pinboard = new PhabricatorPinboardView();
$pinboard->setNoDataString($nodata);
foreach ($macros as $macro) {
$file_phid = $macro->getFilePHID();
$file = idx($files_map, $file_phid);
$item = new PhabricatorPinboardItemView();
if ($file) {
$item->setImageURI($file->getThumb220x165URI());
$item->setImageSize(220, 165);
if ($file->getAuthorPHID()) {
$author_handle = $this->getHandle($file->getAuthorPHID());
$item->appendChild(
'Created by '.$author_handle->renderLink());
}
$datetime = phabricator_date($file->getDateCreated(), $viewer);
$item->appendChild(
phutil_render_tag(
'div',
array(),
- 'Created on '.$datetime));
+ pht('Created on %s', $datetime)));
}
$item->setURI($this->getApplicationURI('/view/'.$macro->getID().'/'));
$item->setHeader($macro->getName());
$pinboard->addItem($item);
}
$nav->appendChild($pinboard);
if (!$has_search) {
$nav->appendChild($pager);
$name = pht('All Macros');
} else {
$name = pht('Search');
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($name)
->setHref($request->getRequestURI()));
$nav->setCrumbs($crumbs);
return $this->buildApplicationPage(
$nav,
array(
'device' => true,
- 'title' => 'Image Macros',
+ 'title' => pht('Image Macros'),
));
}
}
diff --git a/src/applications/macro/controller/PhabricatorMacroViewController.php b/src/applications/macro/controller/PhabricatorMacroViewController.php
index 970d6e48da..3a0ad35e42 100644
--- a/src/applications/macro/controller/PhabricatorMacroViewController.php
+++ b/src/applications/macro/controller/PhabricatorMacroViewController.php
@@ -1,172 +1,172 @@
<?php
final class PhabricatorMacroViewController
extends PhabricatorMacroController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$macro = id(new PhabricatorFileImageMacro())->load($this->id);
if (!$macro) {
return new Aphront404Response();
}
$file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$macro->getFilePHID());
$title_short = pht('Macro "%s"', $macro->getName());
$title_long = pht('Image Macro "%s"', $macro->getName());
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$macro->getPHID());
$this->loadHandles($subscribers);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setHref($this->getApplicationURI('/view/'.$macro->getID().'/'))
->setName($title_short));
$actions = $this->buildActionView($macro);
$properties = $this->buildPropertyView($macro, $file, $subscribers);
$xactions = id(new PhabricatorMacroTransactionQuery())
->setViewer($request->getUser())
->withObjectPHIDs(array($macro->getPHID()))
->execute();
$engine = id(new PhabricatorMarkupEngine())
->setViewer($user);
foreach ($xactions as $xaction) {
if ($xaction->getComment()) {
$engine->addObject(
$xaction->getComment(),
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
}
}
$engine->process();
$timeline = id(new PhabricatorApplicationTransactionView())
->setUser($user)
->setTransactions($xactions)
->setMarkupEngine($engine);
$header = id(new PhabricatorHeaderView())
->setHeader($title_long);
if ($macro->getIsDisabled()) {
$header->addTag(
id(new PhabricatorTagView())
->setType(PhabricatorTagView::TYPE_STATE)
->setName(pht('Macro Disabled'))
->setBackgroundColor(PhabricatorTagView::COLOR_BLACK));
}
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = id(new PhabricatorHeaderView())
->setHeader(
$is_serious
? pht('Add Comment')
: pht('Grovel in Awe'));
$submit_button_name = $is_serious
? pht('Add Comment')
: pht('Lavish Praise');
$draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID());
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($user)
->setDraft($draft)
->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/'))
->setSubmitButtonName($submit_button_name);
return $this->buildApplicationPage(
array(
$crumbs,
$header,
$actions,
$properties,
$timeline,
$add_comment_header,
$add_comment_form,
),
array(
'title' => $title_short,
));
}
private function buildActionView(PhabricatorFileImageMacro $macro) {
$view = new PhabricatorActionListView();
$view->setUser($this->getRequest()->getUser());
$view->setObject($macro);
$view->addAction(
id(new PhabricatorActionView())
- ->setName('Edit Macro')
+ ->setName(pht('Edit Macro'))
->setHref($this->getApplicationURI('/edit/'.$macro->getID().'/'))
->setIcon('edit'));
if ($macro->getIsDisabled()) {
$view->addAction(
id(new PhabricatorActionView())
- ->setName('Restore Macro')
+ ->setName(pht('Restore Macro'))
->setHref($this->getApplicationURI('/disable/'.$macro->getID().'/'))
->setWorkflow(true)
->setIcon('undo'));
} else {
$view->addAction(
id(new PhabricatorActionView())
- ->setName('Disable Macro')
+ ->setName(pht('Disable Macro'))
->setHref($this->getApplicationURI('/disable/'.$macro->getID().'/'))
->setWorkflow(true)
->setIcon('delete'));
}
return $view;
}
private function buildPropertyView(
PhabricatorFileImageMacro $macro,
PhabricatorFile $file = null,
array $subscribers) {
$view = new PhabricatorPropertyListView();
if ($subscribers) {
$sub_view = array();
foreach ($subscribers as $subscriber) {
$sub_view[] = $this->getHandle($subscriber)->renderLink();
}
$sub_view = implode(', ', $sub_view);
} else {
$sub_view = '<em>'.pht('None').'</em>';
}
$view->addProperty(
pht('Subscribers'),
$sub_view);
if ($file) {
$view->addTextContent(
phutil_render_tag(
'img',
array(
'src' => $file->getViewURI(),
'class' => 'phabricator-image-macro-hero',
)));
}
return $view;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Dec 1, 7:41 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
425155
Default Alt Text
(43 KB)

Event Timeline