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

Merge renderSingleView() and renderHTMLView()

Summary: They are same because render() returns safe HTML and raw strings are automatically escaped.

Test Plan: None.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4909
This commit is contained in:
vrana 2013-02-11 14:43:25 -08:00
parent c9ab1fe505
commit ae4e5807d6
27 changed files with 41 additions and 57 deletions

View file

@ -114,7 +114,7 @@ final class PhabricatorSetupIssueView extends AphrontView {
array( array(
'class' => 'setup-issue', 'class' => 'setup-issue',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$name, $name,
$description, $description,
@ -187,7 +187,7 @@ final class PhabricatorSetupIssueView extends AphrontView {
array( array(
'class' => 'setup-issue-config', 'class' => 'setup-issue-config',
), ),
self::renderHTMLView( self::renderSingleView(
array( array(
$table_info, $table_info,
$table, $table,
@ -293,7 +293,7 @@ final class PhabricatorSetupIssueView extends AphrontView {
array( array(
'class' => 'setup-issue-config', 'class' => 'setup-issue-config',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$table_info, $table_info,
$table, $table,

View file

@ -139,7 +139,7 @@ final class ConpherenceMenuItemView extends AphrontTagView {
(int)$this->unreadCount); (int)$this->unreadCount);
} }
return $this->renderHTMLView( return $this->renderSingleView(
array( array(
$image, $image,
$title, $title,

View file

@ -91,7 +91,7 @@ final class ConpherenceTransactionView extends AphrontView {
array( array(
'class' => $content_class 'class' => $content_class
), ),
$this->renderHTMLView($content)) $this->renderSingleView($content))
); );
return $transaction_view->render(); return $transaction_view->render();

View file

@ -92,7 +92,7 @@ final class DifferentialChangesetDetailView extends AphrontView {
'class' => $class, 'class' => $class,
'id' => $id, 'id' => $id,
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
id(new PhabricatorAnchorView()) id(new PhabricatorAnchorView())
->setAnchorName($changeset->getAnchorName()) ->setAnchorName($changeset->getAnchorName())

View file

@ -187,7 +187,7 @@ final class DifferentialChangesetListView extends AphrontView {
)); ));
} }
return $this->renderHTMLView( return $this->renderSingleView(
array( array(
id(new PhabricatorHeaderView()) id(new PhabricatorHeaderView())
->setHeader($this->getTitle()) ->setHeader($this->getTitle())

View file

@ -55,7 +55,7 @@ final class DifferentialInlineCommentEditView extends AphrontView {
'method' => 'POST', 'method' => 'POST',
'sigil' => 'inline-edit-form', 'sigil' => 'inline-edit-form',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$this->renderInputs(), $this->renderInputs(),
$this->renderBody(), $this->renderBody(),
@ -130,7 +130,7 @@ final class DifferentialInlineCommentEditView extends AphrontView {
array( array(
'class' => 'differential-inline-comment-edit-buttons', 'class' => 'differential-inline-comment-edit-buttons',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$formatting, $formatting,
$buttons, $buttons,
@ -148,7 +148,7 @@ final class DifferentialInlineCommentEditView extends AphrontView {
'length' => $this->length, 'length' => $this->length,
), ),
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$title, $title,
$body, $body,

View file

@ -45,7 +45,7 @@ final class ManiphestTaskListView extends ManiphestView {
$views[] = $view->render(); $views[] = $view->render();
} }
return $this->renderHTMLView($views); return $this->renderSingleView($views);
} }
} }

View file

@ -52,7 +52,7 @@ final class ManiphestTaskProjectsView extends ManiphestView {
"\xE2\x80\xA6"); "\xE2\x80\xA6");
} }
return $this->renderHTMLView($tags); return $this->renderSingleView($tags);
} }
} }

View file

@ -128,13 +128,13 @@ final class PhabricatorApplicationLaunchView extends AphrontView {
'href' => $application ? $application->getBaseURI() : null, 'href' => $application ? $application->getBaseURI() : null,
'title' => $application ? $application->getShortDescription() : null, 'title' => $application ? $application->getShortDescription() : null,
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$icon, $icon,
$content, $content,
))); )));
return $this->renderHTMLView( return $this->renderSingleView(
array( array(
$app_button, $app_button,
$create_button, $create_button,

View file

@ -81,6 +81,6 @@ final class PholioMockImagesView extends AphrontView {
$thumbnails); $thumbnails);
} }
return $this->renderHTMLView($mockview); return $this->renderSingleView($mockview);
} }
} }

View file

@ -128,7 +128,7 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
'id' => $this->getPreviewPanelID(), 'id' => $this->getPreviewPanelID(),
'style' => 'display: none', 'style' => 'display: none',
), ),
self::renderHTMLView( self::renderSingleView(
array( array(
$header, $header,
$preview, $preview,

View file

@ -125,12 +125,12 @@ return `phutil_tag()` or `javelin_tag()`:
return phutil_tag('div', ...); return phutil_tag('div', ...);
@{class:AphrontView} subclasses can use `renderHTMLChildren()` and @{class:AphrontView} subclasses can use `renderHTMLChildren()` and
`renderHTMLView()` to build @{class@libphutil:PhutilSafeHTML} objects from `renderSingleView()` to build @{class@libphutil:PhutilSafeHTML} objects from
children or arbitrary lists of components. children or arbitrary lists of components.
@{class:AphrontView} subclasses should avoid `renderChildren()` and @{class:AphrontView} subclasses should avoid `renderChildren()` and transition
`renderSingleView()` and transition callers to the `HTML` varieties. These older callers to `renderHTMLChildren()`. This older method does not return
methods do not return @{class@libphutil:PhutilSafeHTML} objects. @{class@libphutil:PhutilSafeHTML} objects.
= Internationalization: pht() = = Internationalization: pht() =

View file

@ -39,7 +39,7 @@ abstract class AphrontView extends Phobject {
final protected function renderHTMLChildren() { final protected function renderHTMLChildren() {
$out = array(); $out = array();
foreach ($this->children as $child) { foreach ($this->children as $child) {
$out[] = $this->renderHTMLView($child); $out[] = $this->renderSingleView($child);
} }
return $out; return $out;
} }
@ -58,22 +58,6 @@ abstract class AphrontView extends Phobject {
} }
} }
final protected function renderHTMLView($child) {
if ($child instanceof AphrontView) {
return $child->render();
} else if ($child instanceof PhutilSafeHTML) {
return $child;
} else if (is_array($child)) {
$out = array();
foreach ($child as $element) {
$out[] = $this->renderHTMLView($element);
}
return phutil_implode_html('', $out);
} else {
return hsprintf('%s', $child);
}
}
final protected function isEmptyContent($content) { final protected function isEmptyContent($content) {
if (is_array($content)) { if (is_array($content)) {
foreach ($content as $element) { foreach ($content as $element) {

View file

@ -154,7 +154,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
array( array(
'sigil' => 'remarkup-assist-control', 'sigil' => 'remarkup-assist-control',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$buttons, $buttons,
parent::renderInput(), parent::renderInput(),

View file

@ -231,7 +231,7 @@ final class AphrontSideNavFilterView extends AphrontView {
), ),
''); '');
$local_menu = $this->renderHTMLView( $local_menu = $this->renderSingleView(
array( array(
$menu_background, $menu_background,
phutil_tag( phutil_tag(

View file

@ -42,7 +42,7 @@ final class PhabricatorActionListView extends AphrontView {
array( array(
'class' => 'phabricator-action-list-view', 'class' => 'phabricator-action-list-view',
), ),
$this->renderHTMLView($actions)); $this->renderSingleView($actions));
} }

View file

@ -39,7 +39,7 @@ final class PhabricatorAnchorView extends AphrontView {
), ),
''); '');
return $this->renderHTMLView(array($marker, $anchor)); return $this->renderSingleView(array($marker, $anchor));
} }
} }

View file

@ -55,7 +55,7 @@ final class PhabricatorCrumbsView extends AphrontView {
array( array(
'class' => 'phabricator-crumbs-actions', 'class' => 'phabricator-crumbs-actions',
), ),
$this->renderHTMLView($actions)); $this->renderSingleView($actions));
} }
if ($this->crumbs) { if ($this->crumbs) {
@ -68,7 +68,7 @@ final class PhabricatorCrumbsView extends AphrontView {
'class' => 'phabricator-crumbs-view '. 'class' => 'phabricator-crumbs-view '.
'sprite-gradient gradient-breadcrumbs', 'sprite-gradient gradient-breadcrumbs',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$action_view, $action_view,
$this->crumbs, $this->crumbs,

View file

@ -44,7 +44,7 @@ final class PhabricatorHeaderView extends AphrontView {
array( array(
'class' => 'phabricator-header-tags', 'class' => 'phabricator-header-tags',
), ),
$this->renderHTMLView($this->tags)); $this->renderSingleView($this->tags));
} }
return phutil_tag( return phutil_tag(

View file

@ -117,7 +117,7 @@ final class PhabricatorMenuItemView extends AphrontTagView {
$this->name.$external); $this->name.$external);
} }
return $this->renderHTMLView( return $this->renderSingleView(
array( array(
$this->renderHTMLChildren(), $this->renderHTMLChildren(),
$name, $name,

View file

@ -167,6 +167,6 @@ final class PhabricatorMenuView extends AphrontTagView {
} }
protected function getTagContent() { protected function getTagContent() {
return $this->renderHTMLView($this->items); return $this->renderSingleView($this->items);
} }
} }

View file

@ -48,7 +48,7 @@ final class PhabricatorObjectItemListView extends AphrontView {
} }
if ($this->items) { if ($this->items) {
$items = $this->renderHTMLView($this->items); $items = $this->renderSingleView($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())
@ -58,7 +58,7 @@ final class PhabricatorObjectItemListView extends AphrontView {
$pager = null; $pager = null;
if ($this->pager) { if ($this->pager) {
$pager = $this->renderHTMLView($this->pager); $pager = $this->renderSingleView($this->pager);
} }
$classes[] = 'phabricator-object-item-list-view'; $classes[] = 'phabricator-object-item-list-view';
@ -71,7 +71,7 @@ final class PhabricatorObjectItemListView extends AphrontView {
array( array(
'class' => implode(' ', $classes), 'class' => implode(' ', $classes),
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$header, $header,
$items, $items,

View file

@ -166,7 +166,7 @@ final class PhabricatorObjectItemView extends AphrontView {
array( array(
'class' => 'phabricator-object-item-content', 'class' => 'phabricator-object-item-content',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$header, $header,
$attrs, $attrs,

View file

@ -70,7 +70,7 @@ final class PhabricatorPinboardItemView extends AphrontView {
array( array(
'class' => 'phabricator-pinboard-item-view', 'class' => 'phabricator-pinboard-item-view',
), ),
$this->renderHTMLView( $this->renderSingleView(
array( array(
$header, $header,
$image, $image,

View file

@ -31,7 +31,7 @@ final class PhabricatorPinboardView extends AphrontView {
array( array(
'class' => 'phabricator-pinboard-view', 'class' => 'phabricator-pinboard-view',
), ),
$this->renderHTMLView($this->items)); $this->renderSingleView($this->items));
} }
} }

View file

@ -78,7 +78,7 @@ final class PhabricatorPropertyListView extends AphrontView {
array( array(
'class' => 'phabricator-property-list-view', 'class' => 'phabricator-property-list-view',
), ),
$this->renderHTMLView($items)); $this->renderSingleView($items));
} }
private function renderPropertyPart(array $part) { private function renderPropertyPart(array $part) {
@ -99,7 +99,7 @@ final class PhabricatorPropertyListView extends AphrontView {
array( array(
'class' => 'phabricator-property-list-value', 'class' => 'phabricator-property-list-value',
), ),
$this->renderHTMLView($value)); $this->renderSingleView($value));
} }
$list = phutil_tag( $list = phutil_tag(
@ -107,7 +107,7 @@ final class PhabricatorPropertyListView extends AphrontView {
array( array(
'class' => 'phabricator-property-list-properties', 'class' => 'phabricator-property-list-properties',
), ),
$this->renderHTMLView($items)); $this->renderSingleView($items));
$shortcuts = null; $shortcuts = null;
if ($this->hasKeyboardShortcuts) { if ($this->hasKeyboardShortcuts) {

View file

@ -138,7 +138,7 @@ final class PhabricatorTimelineEventView extends AphrontView {
), ),
array($title, $extra)); array($title, $extra));
$title = $this->renderHTMLView(array($icon, $title)); $title = $this->renderSingleView(array($icon, $title));
} }
$wedge = phutil_tag( $wedge = phutil_tag(
@ -275,7 +275,7 @@ final class PhabricatorTimelineEventView extends AphrontView {
->setAnchorName($this->anchor) ->setAnchorName($this->anchor)
->render(); ->render();
$date = $this->renderHTMLView( $date = $this->renderSingleView(
array( array(
$anchor, $anchor,
phutil_tag( phutil_tag(