1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Fix object ObjectItemListView attributes

Summary: This works after pht() + html got sorted out.

Test Plan: Looked at some object attribute lists.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2432

Differential Revision: https://secure.phabricator.com/D4645
This commit is contained in:
epriestley 2013-01-28 18:09:00 -08:00
parent f9030885c4
commit d83257c29a
9 changed files with 36 additions and 16 deletions

View file

@ -79,8 +79,7 @@ final class PhabricatorCalendarViewStatusController
->setBarColor($color) ->setBarColor($color)
->addAttribute(pht('From %s to %s', $from, $to)) ->addAttribute(pht('From %s to %s', $from, $to))
->addAttribute( ->addAttribute(
phutil_escape_html( phutil_utf8_shorten($status->getDescription(), 64));
phutil_utf8_shorten($status->getDescription(), 64)));
$list->addItem($item); $list->addItem($item);
} }

View file

@ -52,7 +52,7 @@ final class PhabricatorConfigListController
$item = id(new PhabricatorObjectItemView()) $item = id(new PhabricatorObjectItemView())
->setHeader($group->getName()) ->setHeader($group->getName())
->setHref('/config/group/'.$group->getKey().'/') ->setHref('/config/group/'.$group->getKey().'/')
->addAttribute(phutil_escape_html($group->getDescription())); ->addAttribute($group->getDescription());
$list->addItem($item); $list->addItem($item);
} }

View file

@ -105,7 +105,7 @@ abstract class DrydockController extends PhabricatorController {
} }
$status = DrydockLeaseStatus::getNameForStatus($lease->getStatus()); $status = DrydockLeaseStatus::getNameForStatus($lease->getStatus());
$item->addAttribute(phutil_escape_html($status)); $item->addAttribute($status);
$date_created = phabricator_date($lease->getDateCreated(), $user); $date_created = phabricator_date($lease->getDateCreated(), $user);
$item->addAttribute(pht('Created on %s', $date_created)); $item->addAttribute(pht('Created on %s', $date_created));

View file

@ -51,8 +51,7 @@ final class PhabricatorApplicationsListController
$item = id(new PhabricatorObjectItemView()) $item = id(new PhabricatorObjectItemView())
->setHeader($application->getName()) ->setHeader($application->getName())
->setHref('/applications/view/'.get_class($application).'/') ->setHref('/applications/view/'.get_class($application).'/')
->addAttribute( ->addAttribute($application->getShortDescription());
phutil_escape_html($application->getShortDescription()));
$list->addItem($item); $list->addItem($item);
} }
return $list; return $list;

View file

@ -85,7 +85,8 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$created = phabricator_date($paste->getDateCreated(), $user); $created = phabricator_date($paste->getDateCreated(), $user);
$author = $this->getHandle($paste->getAuthorPHID())->renderLink(); $author = $this->getHandle($paste->getAuthorPHID())->renderLink();
$source_code = $this->buildSourceCodeView($paste, 5)->render(); $source_code = $this->buildSourceCodeView($paste, 5)->render();
$source_code = phutil_render_tag(
$source_code = phutil_tag(
'div', 'div',
array( array(
'class' => 'phabricator-source-code-summary', 'class' => 'phabricator-source-code-summary',

View file

@ -84,7 +84,7 @@ final class PonderUserProfileView extends AphrontView {
array( array(
'href' => '/Q'.$question->getID(), 'href' => '/Q'.$question->getID(),
), ),
phutil_escape_html(self::abbreviate($question->getTitle()))))); self::abbreviate($question->getTitle()))));
$view->addItem($item); $view->addItem($item);
} }

View file

@ -36,6 +36,14 @@ abstract class AphrontView extends Phobject {
return implode('', $out); return implode('', $out);
} }
final protected function renderHTMLChildren() {
$out = array();
foreach ($this->children as $child) {
$out[] = $this->renderHTMLView($child);
}
return $out;
}
final protected function renderSingleView($child) { final protected function renderSingleView($child) {
if ($child instanceof AphrontView) { if ($child instanceof AphrontView) {
return $child->render(); return $child->render();

View file

@ -48,7 +48,7 @@ final class PhabricatorObjectItemListView extends AphrontView {
} }
if ($this->items) { if ($this->items) {
$items = $this->renderSingleView($this->items); $items = $this->renderHTMLView($this->items);
} else { } else {
$string = nonempty($this->noDataString, pht('No data.')); $string = nonempty($this->noDataString, pht('No data.'));
$items = id(new AphrontErrorView()) $items = id(new AphrontErrorView())
@ -59,7 +59,7 @@ final class PhabricatorObjectItemListView extends AphrontView {
$pager = null; $pager = null;
if ($this->pager) { if ($this->pager) {
$pager = $this->renderSingleView($this->pager); $pager = $this->renderHTMLView($this->pager);
} }
$classes[] = 'phabricator-object-item-list-view'; $classes[] = 'phabricator-object-item-list-view';
@ -67,12 +67,17 @@ final class PhabricatorObjectItemListView extends AphrontView {
$classes[] = 'phabricator-object-list-stackable'; $classes[] = 'phabricator-object-list-stackable';
} }
return phutil_render_tag( return phutil_tag(
'ul', 'ul',
array( array(
'class' => implode(' ', $classes), 'class' => implode(' ', $classes),
), ),
$header.$items.$pager); $this->renderHTMLView(
array(
$header,
$items,
$pager,
)));
} }
} }

View file

@ -127,12 +127,15 @@ final class PhabricatorObjectItemView extends AphrontView {
"\xC2\xB7"); "\xC2\xB7");
$first = true; $first = true;
foreach ($this->attributes as $attribute) { foreach ($this->attributes as $attribute) {
$attrs[] = phutil_render_tag( $attrs[] = phutil_tag(
'li', 'li',
array( array(
'class' => 'phabricator-object-item-attribute', 'class' => 'phabricator-object-item-attribute',
), ),
($first ? null : $spacer).$attribute); array(
($first ? null : $spacer),
$attribute,
));
$first = false; $first = false;
} }
$attrs = phutil_tag( $attrs = phutil_tag(
@ -158,12 +161,17 @@ final class PhabricatorObjectItemView extends AphrontView {
throw new Exception("Invalid effect!"); throw new Exception("Invalid effect!");
} }
$content = phutil_render_tag( $content = phutil_tag(
'div', 'div',
array( array(
'class' => 'phabricator-object-item-content', 'class' => 'phabricator-object-item-content',
), ),
$header.$attrs.$this->renderChildren()); $this->renderHTMLView(
array(
$header,
$attrs,
$this->renderHTMLChildren(),
)));
return phutil_tag( return phutil_tag(
'li', 'li',