Replace some hsprintf() with phutil_tag()

Summary:
I just want to make sure that this is the style we want.
It seems less readable to me in some cases.

Test Plan: Looked at DarkConsole with errors.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7533
This commit is contained in:
Jakub Vrana
2013-11-08 20:44:24 -08:00
parent 3eaac9eda9
commit aca621e21f
5 changed files with 76 additions and 70 deletions

View File

@@ -248,13 +248,13 @@ class AphrontDefaultApplicationConfiguration
$trace = null; $trace = null;
} }
$content = hsprintf( $content = phutil_tag(
'<div class="aphront-unhandled-exception">'. 'div',
'<div class="exception-message">%s</div>'. array('class' => 'aphront-unhandled-exception'),
'%s'. array(
'</div>', phutil_tag('div', array('class' => 'exception-message'), $message),
$message, $trace,
$trace); ));
$dialog = new AphrontDialogView(); $dialog = new AphrontDialogView();
$dialog $dialog
@@ -384,12 +384,16 @@ class AphrontDefaultApplicationConfiguration
'wide', 'wide',
)); ));
return hsprintf( return phutil_tag(
'<div class="exception-trace">'. 'div',
'<div class="exception-trace-header">Stack Trace</div>'. array('class' => 'exception-trace'),
'%s'. array(
'</div>', phutil_tag(
$table->render()); 'div',
array('class' => 'exception-trace-header'),
pht('Stack Trace')),
$table->render(),
));
} }
} }

View File

@@ -90,13 +90,13 @@ final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
$table->setHeaders(array('Error')); $table->setHeaders(array('Error'));
$table->setNoDataString('No errors.'); $table->setNoDataString('No errors.');
return hsprintf( return phutil_tag(
'<div>'. 'div',
'<div>%s</div>'. array(),
'<pre class="PhabricatorMonospaced">%s</pre>'. array(
'</div>', phutil_tag('div', array(), $table->render()),
$table->render(), phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $details),
phutil_implode_html('', $details)); ));
} }
} }

View File

@@ -42,10 +42,10 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin {
$out = array(); $out = array();
$out[] = hsprintf( $out[] = phutil_tag(
'<div class="dark-console-panel-header">'. 'div',
'<h1>Registered Event Listeners</h1>'. array('class' => 'dark-console-panel-header'),
'</div>'); phutil_tag('h1', array(), pht('Registered Event Listeners')));
$rows = array(); $rows = array();
foreach ($data['listeners'] as $listener) { foreach ($data['listeners'] as $listener) {
@@ -66,10 +66,10 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin {
$out[] = $table->render(); $out[] = $table->render();
$out[] = hsprintf( $out[] = phutil_tag(
'<div class="dark-console-panel-header">'. 'div',
'<h1>Event Log</h1>'. array('class' => 'dark-console-panel-header'),
'</div>'); phutil_tag('h1', array(), pht('Event Log')));
$rows = array(); $rows = array();
foreach ($data['events'] as $event) { foreach ($data['events'] as $event) {

View File

@@ -149,21 +149,20 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
$log = $data['log']; $log = $data['log'];
$results = array(); $results = array();
$results[] = hsprintf( $results[] = phutil_tag(
'<div class="dark-console-panel-header">'. 'div',
'%s'. array('class' => 'dark-console-panel-header'),
'<h1>Calls to External Services</h1>'. array(
'<div style="clear: both;"></div>'.
'</div>',
phutil_tag( phutil_tag(
'a', 'a',
array( array(
'href' => $data['analyzeURI'], 'href' => $data['analyzeURI'],
'class' => $data['didAnalyze'] 'class' => $data['didAnalyze'] ? 'disabled button' : 'green button',
? 'disabled button'
: 'green button',
), ),
'Analyze Query Plans')); pht('Analyze Query Plans')),
phutil_tag('h1', array(), pht('Calls to External Services')),
phutil_tag('div', array('style' => 'clear: both;')),
));
$page_total = $data['end'] - $data['start']; $page_total = $data['end'] - $data['start'];
$totals = array(); $totals = array();

View File

@@ -62,38 +62,41 @@ final class DarkConsoleXHProfPlugin extends DarkConsolePlugin {
$result = array(); $result = array();
$header = hsprintf( $header = phutil_tag(
'<div class="dark-console-panel-header">'. 'div',
'%s'. array('class' => 'dark-console-panel-header'),
'<h1>XHProf Profiler</h1>'. array(
'</div>',
phutil_tag( phutil_tag(
'a', 'a',
array( array(
'href' => $profile_uri, 'href' => $profile_uri,
'class' => $run 'class' => $run ? 'disabled button' : 'green button',
? 'disabled button'
: 'green button',
), ),
'Profile Page')); pht('Profile Page')),
phutil_tag('h1', array(), pht('XHProf Profiler')),
));
$result[] = $header; $result[] = $header;
if ($run) { if ($run) {
$result[] = hsprintf( $result[] = phutil_tag(
'<a href="/xhprof/profile/%s/" '. 'a',
'class="bright-link" '. array(
'style="float: right; margin: 1em 2em 0 0;'. 'href' => "/xhprof/profile/$run/",
'font-weight: bold;" '. 'class' => 'bright-link',
'target="_blank">Profile Permalink</a>'. 'style' => 'float: right; margin: 1em 2em 0 0; font-weight: bold;',
'<iframe src="/xhprof/profile/%s/?frame=true"></iframe>', 'target' => '_blank',
$run, ),
$run); pht('Profile Permalink'));
$result = phutil_tag(
'iframe',
array('src' => "/xhprof/profile/$run/?frame=true"));
} else { } else {
$result[] = hsprintf( $result[] = phutil_tag(
'<div class="dark-console-no-content">'. 'div',
array('class' => 'dark-console-no-content'),
pht(
'Profiling was not enabled for this page. Use the button above '. 'Profiling was not enabled for this page. Use the button above '.
'to enable it.'. 'to enable it.'));
'</div>');
} }
return phutil_implode_html("\n", $result); return phutil_implode_html("\n", $result);