From 8c71815028858e18e1a8a54591df7be7f89a23a3 Mon Sep 17 00:00:00 2001 From: vrana Date: Mon, 11 Feb 2013 14:55:35 -0800 Subject: [PATCH] Merge renderChildren() and renderHTMLChildren() Summary: `renderChildren()` now returns array which isn't ideal but I prefer it to having two methods. Test Plan: None. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4910 --- .../differential/view/DifferentialChangesetDetailView.php | 2 +- .../view/DifferentialInlineCommentEditView.php | 2 +- .../differential/view/DifferentialPrimaryPaneView.php | 2 +- src/applications/feed/view/PhabricatorFeedStoryView.php | 2 +- src/applications/ponder/view/PonderVotableView.php | 2 +- .../uiexample/examples/JavelinViewExampleServerView.php | 2 +- src/docs/developer/rendering_html.diviner | 8 -------- src/view/AphrontDialogView.php | 2 +- src/view/AphrontJavelinView.php | 2 +- src/view/AphrontNullView.php | 2 +- src/view/AphrontTagView.php | 2 +- src/view/AphrontView.php | 8 -------- src/view/form/AphrontErrorView.php | 2 +- src/view/form/AphrontFormInsetView.php | 2 +- src/view/form/AphrontFormLayoutView.php | 2 +- src/view/form/AphrontFormView.php | 2 +- src/view/layout/AphrontContextBarView.php | 2 +- src/view/layout/AphrontListFilterView.php | 2 +- src/view/layout/AphrontMiniPanelView.php | 2 +- src/view/layout/AphrontPanelView.php | 2 +- src/view/layout/AphrontSideNavFilterView.php | 2 +- src/view/layout/PhabricatorMenuItemView.php | 2 +- src/view/layout/PhabricatorObjectItemView.php | 2 +- src/view/layout/PhabricatorPinboardItemView.php | 2 +- src/view/layout/PhabricatorProfileHeaderView.php | 2 +- src/view/layout/PhabricatorTimelineEventView.php | 2 +- src/view/layout/PhabricatorTransactionView.php | 2 +- src/view/page/AphrontPageView.php | 2 +- src/view/page/AphrontRequestFailureView.php | 2 +- src/view/page/PhabricatorBarePageView.php | 2 +- src/view/page/menu/PhabricatorMainMenuGroupView.php | 2 +- 31 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/applications/differential/view/DifferentialChangesetDetailView.php b/src/applications/differential/view/DifferentialChangesetDetailView.php index 3810325ea2..e010d4e539 100644 --- a/src/applications/differential/view/DifferentialChangesetDetailView.php +++ b/src/applications/differential/view/DifferentialChangesetDetailView.php @@ -101,7 +101,7 @@ final class DifferentialChangesetDetailView extends AphrontView { $buttons, phutil_tag('h1', array(), $display_filename), phutil_tag('div', array('style' => 'clear: both'), ''), - $this->renderHTMLChildren(), + $this->renderChildren(), ))); } diff --git a/src/applications/differential/view/DifferentialInlineCommentEditView.php b/src/applications/differential/view/DifferentialInlineCommentEditView.php index 5bc2bbdb4a..193e3520ca 100644 --- a/src/applications/differential/view/DifferentialInlineCommentEditView.php +++ b/src/applications/differential/view/DifferentialInlineCommentEditView.php @@ -123,7 +123,7 @@ final class DifferentialInlineCommentEditView extends AphrontView { array( 'class' => 'differential-inline-comment-edit-body', ), - $this->renderHTMLChildren()); + $this->renderChildren()); $edit = phutil_tag( 'edit', diff --git a/src/applications/differential/view/DifferentialPrimaryPaneView.php b/src/applications/differential/view/DifferentialPrimaryPaneView.php index 8e1e8602ef..cfa4215fd5 100644 --- a/src/applications/differential/view/DifferentialPrimaryPaneView.php +++ b/src/applications/differential/view/DifferentialPrimaryPaneView.php @@ -17,7 +17,7 @@ final class DifferentialPrimaryPaneView extends AphrontView { 'class' => 'differential-primary-pane', 'id' => $this->id, ), - $this->renderHTMLChildren()); + $this->renderChildren()); } } diff --git a/src/applications/feed/view/PhabricatorFeedStoryView.php b/src/applications/feed/view/PhabricatorFeedStoryView.php index 468ce0c802..0ddca8df06 100644 --- a/src/applications/feed/view/PhabricatorFeedStoryView.php +++ b/src/applications/feed/view/PhabricatorFeedStoryView.php @@ -89,7 +89,7 @@ final class PhabricatorFeedStoryView extends PhabricatorFeedView { array( 'class' => 'phabricator-feed-story-body', ), - phutil_safe_html($this->renderChildren())); + phutil_safe_html(implode('', $this->renderChildren()))); if ($this->epoch) { $foot = phabricator_datetime($this->epoch, $this->user); diff --git a/src/applications/ponder/view/PonderVotableView.php b/src/applications/ponder/view/PonderVotableView.php index e94777ef91..11cbe6cde0 100644 --- a/src/applications/ponder/view/PonderVotableView.php +++ b/src/applications/ponder/view/PonderVotableView.php @@ -85,7 +85,7 @@ final class PonderVotableView extends AphrontView { array( 'class' => 'ponder-votebox-content', ), - $this->renderHTMLChildren()), + $this->renderChildren()), )); } diff --git a/src/applications/uiexample/examples/JavelinViewExampleServerView.php b/src/applications/uiexample/examples/JavelinViewExampleServerView.php index 0f996df1c3..2d59917a7c 100644 --- a/src/applications/uiexample/examples/JavelinViewExampleServerView.php +++ b/src/applications/uiexample/examples/JavelinViewExampleServerView.php @@ -8,7 +8,7 @@ final class JavelinViewExampleServerView extends AphrontView { array( 'class' => 'server-view', ), - $this->renderHTMLChildren()); + $this->renderChildren()); } } diff --git a/src/docs/developer/rendering_html.diviner b/src/docs/developer/rendering_html.diviner index 48f600f616..54b410a3af 100644 --- a/src/docs/developer/rendering_html.diviner +++ b/src/docs/developer/rendering_html.diviner @@ -124,14 +124,6 @@ return `phutil_tag()` or `javelin_tag()`: return phutil_tag('div', ...); -@{class:AphrontView} subclasses can use `renderHTMLChildren()` and -`renderSingleView()` to build @{class@libphutil:PhutilSafeHTML} objects from -children or arbitrary lists of components. - -@{class:AphrontView} subclasses should avoid `renderChildren()` and transition -callers to `renderHTMLChildren()`. This older method does not return -@{class@libphutil:PhutilSafeHTML} objects. - = Internationalization: pht() = The @{function:pht} function has some special rules. If any input to diff --git a/src/view/AphrontDialogView.php b/src/view/AphrontDialogView.php index 78e3a4170f..5b448678bb 100644 --- a/src/view/AphrontDialogView.php +++ b/src/view/AphrontDialogView.php @@ -158,7 +158,7 @@ final class AphrontDialogView extends AphrontView { } $buttons[] = phutil_tag('div', array('style' => 'clear: both;'), ''); - $children = $this->renderHTMLChildren(); + $children = $this->renderChildren(); $content = hsprintf( '%s%s%s', diff --git a/src/view/AphrontJavelinView.php b/src/view/AphrontJavelinView.php index 832d0c3178..a563c4aecb 100644 --- a/src/view/AphrontJavelinView.php +++ b/src/view/AphrontJavelinView.php @@ -32,7 +32,7 @@ final class AphrontJavelinView extends AphrontView { 'id' => $id, 'view' => $this->getName(), 'params' => $this->getParameters(), - 'children' => $this->renderChildren(), + 'children' => implode('', $this->renderChildren()), 'trigger_id' => $render_context, )); diff --git a/src/view/AphrontNullView.php b/src/view/AphrontNullView.php index df61ab81f3..2a218e700a 100644 --- a/src/view/AphrontNullView.php +++ b/src/view/AphrontNullView.php @@ -3,7 +3,7 @@ final class AphrontNullView extends AphrontView { public function render() { - return $this->renderHTMLChildren(); + return phutil_implode_html('', $this->renderChildren()); } } diff --git a/src/view/AphrontTagView.php b/src/view/AphrontTagView.php index 8e9595f0b6..514c8826f6 100644 --- a/src/view/AphrontTagView.php +++ b/src/view/AphrontTagView.php @@ -87,7 +87,7 @@ abstract class AphrontTagView extends AphrontView { } protected function getTagContent() { - return $this->renderHTMLChildren(); + return $this->renderChildren(); } protected function willRender() { diff --git a/src/view/AphrontView.php b/src/view/AphrontView.php index b5bf238f7d..59c7a2172a 100644 --- a/src/view/AphrontView.php +++ b/src/view/AphrontView.php @@ -29,14 +29,6 @@ abstract class AphrontView extends Phobject { } final protected function renderChildren() { - $out = array(); - foreach ($this->children as $child) { - $out[] = $this->renderSingleView($child); - } - return implode('', $out); - } - - final protected function renderHTMLChildren() { $out = array(); foreach ($this->children as $child) { $out[] = $this->renderSingleView($child); diff --git a/src/view/form/AphrontErrorView.php b/src/view/form/AphrontErrorView.php index cd97ff6a2f..938f0ae9ec 100644 --- a/src/view/form/AphrontErrorView.php +++ b/src/view/form/AphrontErrorView.php @@ -92,7 +92,7 @@ final class AphrontErrorView extends AphrontView { $classes[] = 'aphront-error-severity-'.$this->severity; $classes = implode(' ', $classes); - $children = $this->renderHTMLChildren(); + $children = $this->renderChildren(); $children[] = $list; return phutil_tag( diff --git a/src/view/form/AphrontFormInsetView.php b/src/view/form/AphrontFormInsetView.php index 014cdfffdd..1e504c4598 100644 --- a/src/view/form/AphrontFormInsetView.php +++ b/src/view/form/AphrontFormInsetView.php @@ -102,7 +102,7 @@ final class AphrontFormInsetView extends AphrontView { $content[] = $this->content; } - $content = array_merge($content, $this->renderHTMLChildren()); + $content = array_merge($content, $this->renderChildren()); return phutil_tag('div', $div_attributes, $content); } diff --git a/src/view/form/AphrontFormLayoutView.php b/src/view/form/AphrontFormLayoutView.php index 300c7370e0..83561491bb 100644 --- a/src/view/form/AphrontFormLayoutView.php +++ b/src/view/form/AphrontFormLayoutView.php @@ -38,6 +38,6 @@ final class AphrontFormLayoutView extends AphrontView { array( 'class' => $classes, ), - $this->renderHTMLChildren()); + $this->renderChildren()); } } diff --git a/src/view/form/AphrontFormView.php b/src/view/form/AphrontFormView.php index 76342830b8..5d5af2a430 100644 --- a/src/view/form/AphrontFormView.php +++ b/src/view/form/AphrontFormView.php @@ -68,7 +68,7 @@ final class AphrontFormView extends AphrontView { $layout ->appendChild($this->renderDataInputs()) - ->appendChild($this->renderHTMLChildren()); + ->appendChild($this->renderChildren()); if (!$this->user) { throw new Exception('You must pass the user to AphrontFormView.'); diff --git a/src/view/layout/AphrontContextBarView.php b/src/view/layout/AphrontContextBarView.php index 0b4d1e9499..07c640fbb5 100644 --- a/src/view/layout/AphrontContextBarView.php +++ b/src/view/layout/AphrontContextBarView.php @@ -24,7 +24,7 @@ final class AphrontContextBarView extends AphrontView { '
'. '', $view->render(), - $this->renderHTMLChildren()); + $this->renderChildren()); } } diff --git a/src/view/layout/AphrontListFilterView.php b/src/view/layout/AphrontListFilterView.php index 2f14ec83f0..cca43fa770 100644 --- a/src/view/layout/AphrontListFilterView.php +++ b/src/view/layout/AphrontListFilterView.php @@ -10,7 +10,7 @@ final class AphrontListFilterView extends AphrontView { '%s'. ''. '', - $this->renderHTMLChildren()); + $this->renderChildren()); } } diff --git a/src/view/layout/AphrontMiniPanelView.php b/src/view/layout/AphrontMiniPanelView.php index 02d29060db..a0df4af89e 100644 --- a/src/view/layout/AphrontMiniPanelView.php +++ b/src/view/layout/AphrontMiniPanelView.php @@ -5,7 +5,7 @@ final class AphrontMiniPanelView extends AphrontView { public function render() { return hsprintf( '
%s
', - $this->renderHTMLChildren()); + $this->renderChildren()); } } diff --git a/src/view/layout/AphrontPanelView.php b/src/view/layout/AphrontPanelView.php index 5c724eb8e5..861ad07416 100644 --- a/src/view/layout/AphrontPanelView.php +++ b/src/view/layout/AphrontPanelView.php @@ -88,7 +88,7 @@ final class AphrontPanelView extends AphrontView { '
'. $buttons.$header.$caption. '
'; - $table = $this->renderChildren(); + $table = implode('', $this->renderChildren()); require_celerity_resource('aphront-panel-view-css'); diff --git a/src/view/layout/AphrontSideNavFilterView.php b/src/view/layout/AphrontSideNavFilterView.php index f37222f919..d76e5d450a 100644 --- a/src/view/layout/AphrontSideNavFilterView.php +++ b/src/view/layout/AphrontSideNavFilterView.php @@ -294,7 +294,7 @@ final class AphrontSideNavFilterView extends AphrontView { ), array( $crumbs, - phutil_safe_html($this->renderChildren()), + phutil_safe_html(implode('', $this->renderChildren())), )) )); } diff --git a/src/view/layout/PhabricatorMenuItemView.php b/src/view/layout/PhabricatorMenuItemView.php index 28fa9584f0..6e021c8c97 100644 --- a/src/view/layout/PhabricatorMenuItemView.php +++ b/src/view/layout/PhabricatorMenuItemView.php @@ -119,7 +119,7 @@ final class PhabricatorMenuItemView extends AphrontTagView { return $this->renderSingleView( array( - $this->renderHTMLChildren(), + $this->renderChildren(), $name, )); } diff --git a/src/view/layout/PhabricatorObjectItemView.php b/src/view/layout/PhabricatorObjectItemView.php index c0ce3506ba..09b9c16f88 100644 --- a/src/view/layout/PhabricatorObjectItemView.php +++ b/src/view/layout/PhabricatorObjectItemView.php @@ -170,7 +170,7 @@ final class PhabricatorObjectItemView extends AphrontView { array( $header, $attrs, - $this->renderHTMLChildren(), + $this->renderChildren(), ))); return phutil_tag( diff --git a/src/view/layout/PhabricatorPinboardItemView.php b/src/view/layout/PhabricatorPinboardItemView.php index d83a1d0a6d..3154eadb10 100644 --- a/src/view/layout/PhabricatorPinboardItemView.php +++ b/src/view/layout/PhabricatorPinboardItemView.php @@ -55,7 +55,7 @@ final class PhabricatorPinboardItemView extends AphrontView { 'height' => $this->imageHeight, ))); - $content = $this->renderHTMLChildren(); + $content = $this->renderChildren(); if ($content) { $content = phutil_tag( 'div', diff --git a/src/view/layout/PhabricatorProfileHeaderView.php b/src/view/layout/PhabricatorProfileHeaderView.php index 338b0d0635..ad4fc0397d 100644 --- a/src/view/layout/PhabricatorProfileHeaderView.php +++ b/src/view/layout/PhabricatorProfileHeaderView.php @@ -70,6 +70,6 @@ final class PhabricatorProfileHeaderView extends AphrontView { self::renderSingleView($this->profileActions), $image, $description). - $this->renderHTMLChildren(); + $this->renderChildren(); } } diff --git a/src/view/layout/PhabricatorTimelineEventView.php b/src/view/layout/PhabricatorTimelineEventView.php index 8534b05076..fdc477340f 100644 --- a/src/view/layout/PhabricatorTimelineEventView.php +++ b/src/view/layout/PhabricatorTimelineEventView.php @@ -100,7 +100,7 @@ final class PhabricatorTimelineEventView extends AphrontView { } public function render() { - $content = $this->renderHTMLChildren(); + $content = $this->renderChildren(); $title = $this->title; if (($title === null) && $this->isEmptyContent($content)) { diff --git a/src/view/layout/PhabricatorTransactionView.php b/src/view/layout/PhabricatorTransactionView.php index 3c551d2176..b1c27ea7b8 100644 --- a/src/view/layout/PhabricatorTransactionView.php +++ b/src/view/layout/PhabricatorTransactionView.php @@ -142,7 +142,7 @@ final class PhabricatorTransactionView extends AphrontView { } return '
'. - $content. + implode('', $content). '
'; } diff --git a/src/view/page/AphrontPageView.php b/src/view/page/AphrontPageView.php index e2ddca7a0d..1db19ea260 100644 --- a/src/view/page/AphrontPageView.php +++ b/src/view/page/AphrontPageView.php @@ -22,7 +22,7 @@ abstract class AphrontPageView extends AphrontView { } protected function getBody() { - return $this->renderChildren(); + return implode('', $this->renderChildren()); } protected function getTail() { diff --git a/src/view/page/AphrontRequestFailureView.php b/src/view/page/AphrontRequestFailureView.php index 9ffce467d6..1965340dd5 100644 --- a/src/view/page/AphrontRequestFailureView.php +++ b/src/view/page/AphrontRequestFailureView.php @@ -21,7 +21,7 @@ final class AphrontRequestFailureView extends AphrontView { '
%s
'. '', $this->header, - $this->renderHTMLChildren()); + $this->renderChildren()); } } diff --git a/src/view/page/PhabricatorBarePageView.php b/src/view/page/PhabricatorBarePageView.php index d3d849b888..2ae201970f 100644 --- a/src/view/page/PhabricatorBarePageView.php +++ b/src/view/page/PhabricatorBarePageView.php @@ -55,7 +55,7 @@ class PhabricatorBarePageView extends AphrontPageView { protected function willRenderPage() { // We render this now to resolve static resources so they can appear in the // document head. - $this->bodyContent = $this->renderChildren(); + $this->bodyContent = implode('', $this->renderChildren()); } protected function getHead() { diff --git a/src/view/page/menu/PhabricatorMainMenuGroupView.php b/src/view/page/menu/PhabricatorMainMenuGroupView.php index 31473aed4d..1eca04c3c6 100644 --- a/src/view/page/menu/PhabricatorMainMenuGroupView.php +++ b/src/view/page/menu/PhabricatorMainMenuGroupView.php @@ -33,7 +33,7 @@ final class PhabricatorMainMenuGroupView extends AphrontView { array( 'class' => implode(' ', $classes), ), - $this->renderHTMLChildren()); + $this->renderChildren()); } }