From aca621e21f9c5ddfabe3f27c15ac6217d1c8ce41 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 8 Nov 2013 20:44:24 -0800 Subject: [PATCH] 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 --- ...AphrontDefaultApplicationConfiguration.php | 30 +++++----- .../plugin/DarkConsoleErrorLogPlugin.php | 14 ++--- .../console/plugin/DarkConsoleEventPlugin.php | 16 +++--- .../plugin/DarkConsoleServicesPlugin.php | 29 +++++----- .../plugin/DarkConsoleXHProfPlugin.php | 57 ++++++++++--------- 5 files changed, 76 insertions(+), 70 deletions(-) diff --git a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php index 0b296962f7..e114f8d663 100644 --- a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php @@ -248,13 +248,13 @@ class AphrontDefaultApplicationConfiguration $trace = null; } - $content = hsprintf( - '
'. - '
%s
'. - '%s'. - '
', - $message, - $trace); + $content = phutil_tag( + 'div', + array('class' => 'aphront-unhandled-exception'), + array( + phutil_tag('div', array('class' => 'exception-message'), $message), + $trace, + )); $dialog = new AphrontDialogView(); $dialog @@ -384,12 +384,16 @@ class AphrontDefaultApplicationConfiguration 'wide', )); - return hsprintf( - '
'. - '
Stack Trace
'. - '%s'. - '
', - $table->render()); + return phutil_tag( + 'div', + array('class' => 'exception-trace'), + array( + phutil_tag( + 'div', + array('class' => 'exception-trace-header'), + pht('Stack Trace')), + $table->render(), + )); } } diff --git a/src/aphront/console/plugin/DarkConsoleErrorLogPlugin.php b/src/aphront/console/plugin/DarkConsoleErrorLogPlugin.php index e0d3cd5f8e..7c96cafe6f 100644 --- a/src/aphront/console/plugin/DarkConsoleErrorLogPlugin.php +++ b/src/aphront/console/plugin/DarkConsoleErrorLogPlugin.php @@ -90,13 +90,13 @@ final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin { $table->setHeaders(array('Error')); $table->setNoDataString('No errors.'); - return hsprintf( - '
'. - '
%s
'. - '
%s
'. - '
', - $table->render(), - phutil_implode_html('', $details)); + return phutil_tag( + 'div', + array(), + array( + phutil_tag('div', array(), $table->render()), + phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $details), + )); } } diff --git a/src/aphront/console/plugin/DarkConsoleEventPlugin.php b/src/aphront/console/plugin/DarkConsoleEventPlugin.php index 3b9236b4a2..bc191e00ea 100644 --- a/src/aphront/console/plugin/DarkConsoleEventPlugin.php +++ b/src/aphront/console/plugin/DarkConsoleEventPlugin.php @@ -42,10 +42,10 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin { $out = array(); - $out[] = hsprintf( - '
'. - '

Registered Event Listeners

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

Event Log

'. - '
'); + $out[] = phutil_tag( + 'div', + array('class' => 'dark-console-panel-header'), + phutil_tag('h1', array(), pht('Event Log'))); $rows = array(); foreach ($data['events'] as $event) { diff --git a/src/aphront/console/plugin/DarkConsoleServicesPlugin.php b/src/aphront/console/plugin/DarkConsoleServicesPlugin.php index a43a83c785..3005c94b0d 100644 --- a/src/aphront/console/plugin/DarkConsoleServicesPlugin.php +++ b/src/aphront/console/plugin/DarkConsoleServicesPlugin.php @@ -149,21 +149,20 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin { $log = $data['log']; $results = array(); - $results[] = hsprintf( - '
'. - '%s'. - '

Calls to External Services

'. - '
'. - '
', - phutil_tag( - 'a', - array( - 'href' => $data['analyzeURI'], - 'class' => $data['didAnalyze'] - ? 'disabled button' - : 'green button', - ), - 'Analyze Query Plans')); + $results[] = phutil_tag( + 'div', + array('class' => 'dark-console-panel-header'), + array( + phutil_tag( + 'a', + array( + 'href' => $data['analyzeURI'], + 'class' => $data['didAnalyze'] ? 'disabled button' : 'green button', + ), + 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']; $totals = array(); diff --git a/src/aphront/console/plugin/DarkConsoleXHProfPlugin.php b/src/aphront/console/plugin/DarkConsoleXHProfPlugin.php index db40e92e9d..0ffc280edf 100644 --- a/src/aphront/console/plugin/DarkConsoleXHProfPlugin.php +++ b/src/aphront/console/plugin/DarkConsoleXHProfPlugin.php @@ -62,38 +62,41 @@ final class DarkConsoleXHProfPlugin extends DarkConsolePlugin { $result = array(); - $header = hsprintf( - '
'. - '%s'. - '

XHProf Profiler

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