1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Standardize rendering of atom type names like "Article" and "Class"

Summary: Ref T988. This was sort of hard-coded in one place and not done properly in another. Do it consistently.

Test Plan: Looked at atom list; looked at atom view. Saw "Article", "Class" rendered correctly.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T988

Differential Revision: https://secure.phabricator.com/D6821
This commit is contained in:
epriestley 2013-08-28 09:55:05 -07:00
parent a799a05b6c
commit a96582c788
3 changed files with 35 additions and 10 deletions

View file

@ -5,6 +5,9 @@ final class DivinerAtom {
const TYPE_FILE = 'file';
const TYPE_ARTICLE = 'article';
const TYPE_METHOD = 'method';
const TYPE_CLASS = 'class';
const TYPE_FUNCTION = 'function';
const TYPE_INTERFACE = 'interface';
private $type;
private $name;
@ -357,18 +360,42 @@ final class DivinerAtom {
public static function getThisAtomIsNotDocumentedString($type) {
switch ($type) {
case 'function':
case self::TYPE_FILE:
return pht('This file is not documented.');
case self::TYPE_FUNCTION:
return pht('This function is not documented.');
case 'class':
case self::TYPE_CLASS:
return pht('This class is not documented.');
case 'article':
case self::TYPE_ARTICLE:
return pht('This article is not documented.');
case 'method':
case self::TYPE_METHOD:
return pht('This method is not documented.');
case self::TYPE_INTERFACE:
return pht('This interface is not documented.');
default:
phlog("Need translation for '{$type}'.");
return pht('This %s is not documented.', $type);
}
}
public static function getAtomTypeNameString($type) {
switch ($type) {
case self::TYPE_FILE:
return pht('File');
case self::TYPE_FUNCTION:
return pht('Function');
case self::TYPE_CLASS:
return pht('Class');
case self::TYPE_ARTICLE:
return pht('Article');
case self::TYPE_METHOD:
return pht('Method');
case self::TYPE_INTERFACE:
return pht('Interface');
default:
phlog("Need translation for '{$type}'.");
return ucwords($type);
}
}
}

View file

@ -89,7 +89,7 @@ final class DivinerAtomController extends DivinerController {
id(new PhabricatorTagView())
->setType(PhabricatorTagView::TYPE_STATE)
->setBackgroundColor(PhabricatorTagView::COLOR_BLUE)
->setName($this->renderAtomTypeName($atom->getType())));
->setName(DivinerAtom::getAtomTypeNameString($atom->getType())));
$properties = id(new PhabricatorPropertyListView());
@ -208,10 +208,6 @@ final class DivinerAtomController extends DivinerController {
));
}
private function renderAtomTypeName($name) {
return phutil_utf8_ucwords($name);
}
private function buildExtendsAndImplements(
PhabricatorPropertyListView $view,
DivinerLiveSymbol $symbol) {

View file

@ -34,7 +34,9 @@ abstract class DivinerController extends PhabricatorController {
$item = id(new PhabricatorObjectItemView())
->setHeader($symbol->getTitle())
->setHref($symbol->getURI())
->addIcon('none', $symbol->getType());
->addIcon('none',
DivinerAtom::getAtomTypeNameString(
$symbol->getType()));
$item->addAttribute(phutil_safe_html($symbol->getSummary()));