mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Replace some hsprintf() with phutil_tag() and phutil_tag_div() Depends on D7545.
Test Plan: This is one of the rare moments where unit tests for views would be useful. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7547
This commit is contained in:
parent
56c65e33ef
commit
fd8d9ff0d6
18 changed files with 151 additions and 201 deletions
|
@ -42,18 +42,20 @@ class AphrontRedirectResponse extends AphrontResponse {
|
|||
$error->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
|
||||
$error->setTitle('Stopped on Redirect');
|
||||
|
||||
$error->appendChild(phutil_tag('p', array(), pht(
|
||||
'You were stopped here because %s is set in your configuration.',
|
||||
phutil_tag('tt', array(), 'debug.stop-on-redirect'))));
|
||||
|
||||
$link = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $this->getURI(),
|
||||
),
|
||||
'Continue to: '.$this->getURI());
|
||||
$this->getURI());
|
||||
|
||||
$error->appendChild(hsprintf(
|
||||
'<p>You were stopped here because <tt>debug.stop-on-redirect</tt> '.
|
||||
'is set in your configuration.</p>'.
|
||||
'<p>%s</p>',
|
||||
$link));
|
||||
$error->appendChild(phutil_tag('p', array(), pht(
|
||||
'Continue to: %s',
|
||||
$link)));
|
||||
|
||||
$view->appendChild($error);
|
||||
|
||||
|
|
|
@ -196,10 +196,11 @@ final class CelerityStaticResourceResponse {
|
|||
if (strpos($data, '<!') !== false) {
|
||||
throw new Exception('Literal <! is not allowed inside inline script.');
|
||||
}
|
||||
return hsprintf(
|
||||
// We don't use <![CDATA[ ]]> because it is ignored by HTML parsers. We
|
||||
// would need to send the document with XHTML content type.
|
||||
'<script type="text/javascript">%s</script>',
|
||||
// We don't use <![CDATA[ ]]> because it is ignored by HTML parsers. We
|
||||
// would need to send the document with XHTML content type.
|
||||
return phutil_tag(
|
||||
'script',
|
||||
array('type' => 'text/javascript'),
|
||||
phutil_safe_html($data));
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ abstract class PhabricatorInlineCommentController
|
|||
$dialog->setTitle('Really delete this comment?');
|
||||
$dialog->addHiddenInput('id', $this->getCommentID());
|
||||
$dialog->addHiddenInput('op', 'delete');
|
||||
$dialog->appendChild(hsprintf('<p>Delete this inline comment?</p>'));
|
||||
$dialog->appendChild(
|
||||
phutil_tag('p', array(), pht('Delete this inline comment?')));
|
||||
|
||||
$dialog->addCancelButton('#');
|
||||
$dialog->addSubmitButton('Delete');
|
||||
|
|
|
@ -19,12 +19,7 @@ final class PhabricatorInlineSummaryView extends AphrontView {
|
|||
}
|
||||
|
||||
private function renderHeader() {
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-inline-summary',
|
||||
),
|
||||
'Inline Comments');
|
||||
return phutil_tag_div('phabricator-inline-summary', pht('Inline Comments'));
|
||||
}
|
||||
|
||||
private function renderTable() {
|
||||
|
@ -39,7 +34,10 @@ final class PhabricatorInlineSummaryView extends AphrontView {
|
|||
}
|
||||
}
|
||||
|
||||
$rows[] = hsprintf('<tr><th colspan="3">%s</th></tr>', $group);
|
||||
$rows[] = phutil_tag(
|
||||
'tr',
|
||||
array(),
|
||||
phutil_tag('th', array('colspan' => 3), $group));
|
||||
|
||||
foreach ($items as $item) {
|
||||
|
||||
|
@ -80,25 +78,21 @@ final class PhabricatorInlineSummaryView extends AphrontView {
|
|||
$where = idx($item, 'where');
|
||||
|
||||
$colspan = ($has_where ? null : 2);
|
||||
$rows[] = hsprintf(
|
||||
'<tr>'.
|
||||
'<td class="inline-line-number">%s</td>'.
|
||||
'%s'.
|
||||
'%s'.
|
||||
'</tr>',
|
||||
$lines,
|
||||
($has_where
|
||||
? hsprintf('<td class="inline-which-diff">%s</td>', $where)
|
||||
: null),
|
||||
phutil_tag(
|
||||
'td',
|
||||
array(
|
||||
'class' => 'inline-summary-content',
|
||||
'colspan' => $colspan,
|
||||
),
|
||||
hsprintf(
|
||||
'<div class="phabricator-remarkup">%s</div>',
|
||||
$item['content'])));
|
||||
$rows[] = phutil_tag(
|
||||
'tr',
|
||||
array(),
|
||||
array(
|
||||
phutil_tag('td', array('class' => 'inline-line-number'), $lines),
|
||||
($has_where
|
||||
? phutil_tag('td', array('class' => 'inline-which-diff'), $where)
|
||||
: null),
|
||||
phutil_tag(
|
||||
'td',
|
||||
array(
|
||||
'class' => 'inline-summary-content',
|
||||
'colspan' => $colspan,
|
||||
),
|
||||
phutil_tag_div('phabricator-remarkup', $item['content']))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ final class PhabricatorRemarkupRuleYoutube
|
|||
}
|
||||
|
||||
$youtube_src = 'https://www.youtube.com/embed/'.$v;
|
||||
$iframe = hsprintf(
|
||||
'<div class="embedded-youtube-video">%s</div>',
|
||||
$iframe = phutil_tag_div(
|
||||
'embedded-youtube-video',
|
||||
phutil_tag(
|
||||
'iframe',
|
||||
array(
|
||||
|
|
|
@ -272,10 +272,13 @@ final class AphrontTableView extends AphrontView {
|
|||
}
|
||||
} else {
|
||||
$colspan = max(count(array_filter($visibility)), 1);
|
||||
$table[] = hsprintf(
|
||||
'<tr class="no-data"><td colspan="%s">%s</td></tr>',
|
||||
$colspan,
|
||||
coalesce($this->noDataString, pht('No data available.')));
|
||||
$table[] = phutil_tag(
|
||||
'tr',
|
||||
array('class' => 'no-data'),
|
||||
phutil_tag(
|
||||
'td',
|
||||
array('colspan' => $colspan),
|
||||
coalesce($this->noDataString, pht('No data available.'))));
|
||||
}
|
||||
|
||||
$table_class = 'aphront-table-view';
|
||||
|
@ -287,7 +290,7 @@ final class AphrontTableView extends AphrontView {
|
|||
}
|
||||
|
||||
$html = phutil_tag('table', array('class' => $table_class), $table);
|
||||
return hsprintf('<div class="aphront-table-wrap">%s</div>', $html);
|
||||
return phutil_tag_div('aphront-table-wrap', $html);
|
||||
}
|
||||
|
||||
public static function renderSingleDisplayLine($line) {
|
||||
|
|
|
@ -117,22 +117,19 @@ final class PhabricatorObjectSelectorDialog {
|
|||
'action' => $this->submitURI,
|
||||
'id' => $search_id,
|
||||
),
|
||||
hsprintf(
|
||||
'<table class="phabricator-object-selector-search">
|
||||
<tr>
|
||||
<td class="phabricator-object-selector-search-filter">%s</td>
|
||||
<td class="phabricator-object-selector-search-text">%s</td>
|
||||
</tr>
|
||||
</table>',
|
||||
phutil_tag(
|
||||
'select',
|
||||
array('id' => $filter_id),
|
||||
$options),
|
||||
phutil_tag(
|
||||
'input',
|
||||
array(
|
||||
'id' => $query_id,
|
||||
'type' => 'text'))));
|
||||
phutil_tag(
|
||||
'table',
|
||||
array('class' => 'phabricator-object-selector-search'),
|
||||
phutil_tag('tr', array(), array(
|
||||
phutil_tag(
|
||||
'td',
|
||||
array('class' => 'phabricator-object-selector-search-filter'),
|
||||
phutil_tag('select', array('id' => $filter_id), $options)),
|
||||
phutil_tag(
|
||||
'td',
|
||||
array('class' => 'phabricator-object-selector-search-text'),
|
||||
phutil_tag('input', array('id' => $query_id, 'type' => 'text'))),
|
||||
))));
|
||||
|
||||
$result_box = phutil_tag(
|
||||
'div',
|
||||
|
@ -142,17 +139,15 @@ final class PhabricatorObjectSelectorDialog {
|
|||
),
|
||||
'');
|
||||
|
||||
$attached_box = hsprintf(
|
||||
'<div class="phabricator-object-selector-current">'.
|
||||
'<div class="phabricator-object-selector-currently-attached">'.
|
||||
'<div class="phabricator-object-selector-header">%s</div>'.
|
||||
'<div id="%s"></div>'.
|
||||
'%s'.
|
||||
'</div>'.
|
||||
'</div>',
|
||||
$this->header,
|
||||
$current_id,
|
||||
$instructions);
|
||||
$attached_box = phutil_tag_div(
|
||||
'phabricator-object-selector-current',
|
||||
phutil_tag_div(
|
||||
'phabricator-object-selector-currently-attached',
|
||||
array(
|
||||
phutil_tag_div('phabricator-object-selector-header', $this->header),
|
||||
phutil_tag('div', array('id' => $current_id)),
|
||||
$instructions,
|
||||
)));
|
||||
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog
|
||||
|
|
|
@ -38,10 +38,10 @@ final class AphrontFormCheckboxControl extends AphrontFormControl {
|
|||
'for' => $id,
|
||||
),
|
||||
$box['label']);
|
||||
$rows[] = hsprintf(
|
||||
'<tr><td>%s</td><th>%s</th></tr>',
|
||||
$checkbox,
|
||||
$label);
|
||||
$rows[] = phutil_tag('tr', array(), array(
|
||||
phutil_tag('td', array(), $checkbox),
|
||||
phutil_tag('th', array(), $label)
|
||||
));
|
||||
}
|
||||
return phutil_tag(
|
||||
'table',
|
||||
|
|
|
@ -51,15 +51,15 @@ final class AphrontFormRadioButtonControl extends AphrontFormControl {
|
|||
$button['label']);
|
||||
|
||||
if ($button['caption']) {
|
||||
$label = hsprintf(
|
||||
'%s<div class="aphront-form-radio-caption">%s</div>',
|
||||
$label = array(
|
||||
$label,
|
||||
$button['caption']);
|
||||
phutil_tag_div('aphront-form-radio-caption', $button['caption']),
|
||||
);
|
||||
}
|
||||
$rows[] = hsprintf(
|
||||
'<tr><td>%s</td><th>%s</th></tr>',
|
||||
$radio,
|
||||
$label);
|
||||
$rows[] = phutil_tag('tr', array(), array(
|
||||
phutil_tag('td', array(), $radio),
|
||||
phutil_tag('th', array(), $label),
|
||||
));
|
||||
}
|
||||
|
||||
return phutil_tag(
|
||||
|
|
|
@ -15,16 +15,15 @@ final class AphrontContextBarView extends AphrontView {
|
|||
|
||||
require_celerity_resource('aphront-contextbar-view-css');
|
||||
|
||||
return hsprintf(
|
||||
'<div class="aphront-contextbar-view">'.
|
||||
'<div class="aphront-contextbar-core">'.
|
||||
'<div class="aphront-contextbar-buttons">%s</div>'.
|
||||
'<div class="aphront-contextbar-content">%s</div>'.
|
||||
'</div>'.
|
||||
'<div style="clear: both;"></div>'.
|
||||
'</div>',
|
||||
$view->render(),
|
||||
$this->renderChildren());
|
||||
return phutil_tag_div(
|
||||
'aphront-contextbar-view',
|
||||
array(
|
||||
phutil_tag_div('aphront-contextbar-core', array(
|
||||
phutil_tag_div('aphront-contextbar-buttons', $view->render()),
|
||||
phutil_tag_div('aphront-contextbar-content', $this->renderChildren()),
|
||||
)),
|
||||
phutil_tag('div', array('style' => 'clear: both;')),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,25 +69,20 @@ final class AphrontPanelView extends AphrontView {
|
|||
}
|
||||
|
||||
if ($this->caption !== null) {
|
||||
$caption = phutil_tag(
|
||||
'div',
|
||||
array('class' => 'aphront-panel-view-caption'),
|
||||
$this->caption);
|
||||
$caption = phutil_tag_div('aphront-panel-view-caption', $this->caption);
|
||||
} else {
|
||||
$caption = null;
|
||||
}
|
||||
|
||||
$buttons = null;
|
||||
if ($this->buttons) {
|
||||
$buttons = hsprintf(
|
||||
'<div class="aphront-panel-view-buttons">%s</div>',
|
||||
$buttons = phutil_tag_div(
|
||||
'aphront-panel-view-buttons',
|
||||
phutil_implode_html(" ", $this->buttons));
|
||||
}
|
||||
$header_elements = hsprintf(
|
||||
'<div class="aphront-panel-header">%s%s%s</div>',
|
||||
$buttons,
|
||||
$header,
|
||||
$caption);
|
||||
$header_elements = phutil_tag_div(
|
||||
'aphront-panel-header',
|
||||
array($buttons, $header, $caption));
|
||||
|
||||
$table = phutil_implode_html('', $this->renderChildren());
|
||||
|
||||
|
|
|
@ -116,11 +116,8 @@ final class PhabricatorSourceCodeView extends AphrontView {
|
|||
$classes[] = 'remarkup-code';
|
||||
$classes[] = 'PhabricatorMonospaced';
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-source-code-container',
|
||||
),
|
||||
return phutil_tag_div(
|
||||
'phabricator-source-code-container',
|
||||
javelin_tag(
|
||||
'table',
|
||||
array(
|
||||
|
|
|
@ -62,6 +62,10 @@ final class PhabricatorTransactionView extends AphrontView {
|
|||
|
||||
$transaction_id = $this->anchorName ? 'anchor-'.$this->anchorName : null;
|
||||
|
||||
$header = phutil_tag_div(
|
||||
'phabricator-transaction-header',
|
||||
array($info, $actions));
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
|
@ -69,15 +73,9 @@ final class PhabricatorTransactionView extends AphrontView {
|
|||
'id' => $transaction_id,
|
||||
'style' => $style,
|
||||
),
|
||||
hsprintf(
|
||||
'<div class="phabricator-transaction-detail %s">'.
|
||||
'<div class="phabricator-transaction-header">%s%s</div>'.
|
||||
'%s'.
|
||||
'</div>',
|
||||
$classes,
|
||||
$info,
|
||||
$actions,
|
||||
$content));
|
||||
phutil_tag_div(
|
||||
'phabricator-transaction-detail '.$classes,
|
||||
array($header, $content)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -118,8 +116,9 @@ final class PhabricatorTransactionView extends AphrontView {
|
|||
|
||||
$info = phutil_implode_html(" \xC2\xB7 ", $info);
|
||||
|
||||
return hsprintf(
|
||||
'<span class="phabricator-transaction-info">%s</span>',
|
||||
return phutil_tag(
|
||||
'span',
|
||||
array('class' => 'phabricator-transaction-info'),
|
||||
$info);
|
||||
}
|
||||
|
||||
|
@ -139,9 +138,8 @@ final class PhabricatorTransactionView extends AphrontView {
|
|||
if (!$this->hasChildren()) {
|
||||
return null;
|
||||
}
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array('class' => 'phabricator-transaction-content'),
|
||||
return phutil_tag_div(
|
||||
'phabricator-transaction-content',
|
||||
$this->renderChildren());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@ final class AphrontRequestFailureView extends AphrontView {
|
|||
final public function render() {
|
||||
require_celerity_resource('aphront-request-failure-view-css');
|
||||
|
||||
return hsprintf(
|
||||
'<div class="aphront-request-failure-view">'.
|
||||
'<div class="aphront-request-failure-head">'.
|
||||
'<h1>%s</h1>'.
|
||||
'</div>'.
|
||||
'<div class="aphront-request-failure-body">%s</div>'.
|
||||
'</div>',
|
||||
$this->header,
|
||||
$head = phutil_tag_div(
|
||||
'aphront-request-failure-head',
|
||||
phutil_tag('h1', array(), $this->header));
|
||||
|
||||
$body = phutil_tag_div(
|
||||
'aphront-request-failure-body',
|
||||
$this->renderChildren());
|
||||
|
||||
return phutil_tag_div('aphront-request-failure-view', array($head, $body));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -298,11 +298,8 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
|||
$developer_warning = null;
|
||||
if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode') &&
|
||||
DarkConsoleErrorLogPluginAPI::getErrors()) {
|
||||
$developer_warning = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'aphront-developer-error-callout',
|
||||
),
|
||||
$developer_warning = phutil_tag_div(
|
||||
'aphront-developer-error-callout',
|
||||
pht(
|
||||
'This page raised PHP errors. Find them in DarkConsole '.
|
||||
'or the error log.'));
|
||||
|
@ -313,11 +310,8 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
|||
if ($user && $user->getIsAdmin()) {
|
||||
$open = PhabricatorSetupCheck::getOpenSetupIssueCount();
|
||||
if ($open) {
|
||||
$setup_warning = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'setup-warning-callout',
|
||||
),
|
||||
$setup_warning = phutil_tag_div(
|
||||
'setup-warning-callout',
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
|
@ -334,16 +328,16 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
|||
'id' => 'base-page',
|
||||
'class' => 'phabricator-standard-page',
|
||||
),
|
||||
hsprintf(
|
||||
'%s%s%s'.
|
||||
'<div class="phabricator-standard-page-body">'.
|
||||
'%s%s<div style="clear: both;"></div>'.
|
||||
'</div>',
|
||||
$developer_warning,
|
||||
$setup_warning,
|
||||
$header_chrome,
|
||||
($console ? hsprintf('<darkconsole />') : null),
|
||||
parent::getBody()));
|
||||
array(
|
||||
$developer_warning,
|
||||
$setup_warning,
|
||||
$header_chrome,
|
||||
phutil_tag_div('phabricator-standard-page-body', array(
|
||||
($console ? hsprintf('<darkconsole />') : null),
|
||||
parent::getBody(),
|
||||
phutil_tag('div', array('style' => 'clear: both;')),
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
protected function getTail() {
|
||||
|
|
|
@ -66,13 +66,12 @@ final class PhabricatorMainMenuSearchView extends AphrontView {
|
|||
'action' => '/search/',
|
||||
'method' => 'POST',
|
||||
),
|
||||
hsprintf(
|
||||
'<div class="phabricator-main-menu-search-container">'.
|
||||
'%s<button>Search</button>%s%s'.
|
||||
'</div>',
|
||||
phutil_tag_div('phabricator-main-menu-search-container', array(
|
||||
$input,
|
||||
phutil_tag('button', array(), pht('Search')),
|
||||
$scope_input,
|
||||
$target));
|
||||
$target,
|
||||
)));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -38,18 +38,15 @@ final class AphrontProgressBarView extends AphrontBarView {
|
|||
|
||||
$color = $this->getColor();
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => "aphront-bar progress color-{$color}",
|
||||
),
|
||||
return phutil_tag_div(
|
||||
"aphront-bar progress color-{$color}",
|
||||
array(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array('title' => $this->alt),
|
||||
phutil_tag(
|
||||
'div',
|
||||
array('style' => hsprintf("width: %dpx;", $width)),
|
||||
array('style' => "width: {$width}px;"),
|
||||
'')),
|
||||
phutil_tag(
|
||||
'span',
|
||||
|
|
|
@ -92,22 +92,15 @@ final class PhabricatorHovercardView extends AphrontView {
|
|||
$body_title = $handle->getFullName();
|
||||
}
|
||||
|
||||
$body[] = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-hovercard-body-header'
|
||||
),
|
||||
$body_title);
|
||||
$body[] = phutil_tag_div('phabricator-hovercard-body-header', $body_title);
|
||||
|
||||
foreach ($this->fields as $field) {
|
||||
$item = hsprintf('<strong>%s:</strong> <span>%s</span>',
|
||||
$field['label'], $field['value']);
|
||||
$body[] = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-hovercard-body-item'
|
||||
),
|
||||
$item);
|
||||
$item = array(
|
||||
phutil_tag('strong', array(), $field['label']),
|
||||
' ',
|
||||
phutil_tag('span', array(), $field['value']),
|
||||
);
|
||||
$body[] = phutil_tag_div('phabricator-hovercard-body-item', $item);
|
||||
}
|
||||
|
||||
if ($handle->getImageURI()) {
|
||||
|
@ -147,40 +140,22 @@ final class PhabricatorHovercardView extends AphrontView {
|
|||
|
||||
$tail = null;
|
||||
if ($buttons) {
|
||||
$tail = phutil_tag('div',
|
||||
array('class' => 'phabricator-hovercard-tail'),
|
||||
$buttons);
|
||||
$tail = phutil_tag_div('phabricator-hovercard-tail', $buttons);
|
||||
}
|
||||
|
||||
// Assemble container
|
||||
// TODO: Add color support
|
||||
$content = hsprintf(
|
||||
'%s%s%s',
|
||||
phutil_tag('div',
|
||||
array(
|
||||
'class' => 'phabricator-hovercard-head'
|
||||
),
|
||||
$header),
|
||||
phutil_tag('div',
|
||||
array(
|
||||
'class' => 'phabricator-hovercard-body'
|
||||
),
|
||||
$body),
|
||||
$tail);
|
||||
|
||||
$hovercard = phutil_tag("div",
|
||||
$hovercard = phutil_tag_div(
|
||||
'phabricator-hovercard-container',
|
||||
array(
|
||||
"class" => "phabricator-hovercard-container",
|
||||
),
|
||||
$content);
|
||||
phutil_tag_div('phabricator-hovercard-head', $header),
|
||||
phutil_tag_div('phabricator-hovercard-body', $body),
|
||||
$tail,
|
||||
));
|
||||
|
||||
// Wrap for thick border
|
||||
// and later the tip at the bottom
|
||||
return phutil_tag('div',
|
||||
array(
|
||||
'class' => 'phabricator-hovercard-wrapper',
|
||||
),
|
||||
$hovercard);
|
||||
return phutil_tag_div('phabricator-hovercard-wrapper', $hovercard);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue