Commit ef7f1618 authored by epriestley's avatar epriestley
Browse files

Restore merge of phutil_tag.

parent 73cce6e1
......@@ -9,7 +9,7 @@
final class AphrontRequest {
// NOTE: These magic request-type parameters are automatically included in
// certain requests (e.g., by phabricator_render_form(), JX.Request,
// certain requests (e.g., by phabricator_form(), JX.Request,
// JX.Workflow, and ConduitClient) and help us figure out what sort of
// response the client expects.
......
......@@ -210,7 +210,7 @@ class AphrontDefaultApplicationConfiguration
if ($ex instanceof AphrontUsageException) {
$error = new AphrontErrorView();
$error->setTitle(phutil_escape_html($ex->getTitle()));
$error->setTitle($ex->getTitle());
$error->appendChild($ex->getMessage());
$view = new PhabricatorStandardPageView();
......@@ -227,8 +227,8 @@ class AphrontDefaultApplicationConfiguration
// Always log the unhandled exception.
phlog($ex);
$class = phutil_escape_html(get_class($ex));
$message = phutil_escape_html($ex->getMessage());
$class = get_class($ex);
$message = $ex->getMessage();
if ($ex instanceof AphrontQuerySchemaException) {
$message .=
......@@ -244,11 +244,13 @@ class AphrontDefaultApplicationConfiguration
$trace = null;
}
$content =
$content = hsprintf(
'<div class="aphront-unhandled-exception">'.
'<div class="exception-message">'.$message.'</div>'.
$trace.
'</div>';
'<div class="exception-message">%s</div>'.
'%s'.
'</div>',
$message,
$trace);
$dialog = new AphrontDialogView();
$dialog
......@@ -348,17 +350,17 @@ class AphrontDefaultApplicationConfiguration
),
$relative);
}
$file_name = $file_name.' : '.(int)$part['line'];
$file_name = hsprintf('%s : %d', $file_name, $part['line']);
} else {
$file_name = '<em>(Internal)</em>';
$file_name = phutil_tag('em', array(), '(Internal)');
}
$rows[] = array(
$depth--,
phutil_escape_html($lib),
$lib,
$file_name,
phutil_escape_html($where),
$where,
);
}
$table = new AphrontTableView($rows);
......@@ -377,11 +379,12 @@ class AphrontDefaultApplicationConfiguration
'wide',
));
return
return hsprintf(
'<div class="exception-trace">'.
'<div class="exception-trace-header">Stack Trace</div>'.
$table->render().
'</div>';
'%s',
'</div>',
$table->render());
}
}
......@@ -36,7 +36,7 @@ final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
$data = $this->getData();
$rows = array();
$details = '';
$details = array();
foreach ($data as $index => $row) {
$file = $row['file'];
......@@ -50,11 +50,11 @@ final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
$row['str'].' at ['.basename($file).':'.$line.']');
$rows[] = array($tag);
$details .=
'<div class="dark-console-panel-error-details" id="row-details-'.
$index.'">'.
phutil_escape_html($row['details'])."\n".
'Stack trace:'."\n";
$details[] = hsprintf(
'<div class="dark-console-panel-error-details" id="row-details-%s">'.
"%s\nStack trace:\n",
$index,
$row['details']);
foreach ($row['trace'] as $key => $entry) {
$line = '';
......@@ -73,16 +73,16 @@ final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
}
}
$details .= phutil_tag(
$details[] = phutil_tag(
'a',
array(
'href' => $href,
),
$line);
$details .= "\n";
$details[] = "\n";
}
$details .= '</div>';
$details[] = hsprintf('</div>');
}
$table = new AphrontTableView($rows);
......@@ -90,11 +90,13 @@ final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
$table->setHeaders(array('Error'));
$table->setNoDataString('No errors.');
return '<div>'.
'<div>'.$table->render().'</div>'.
'<pre class="PhabricatorMonospaced">'.
$details.'</pre>'.
'</div>';
return hsprintf(
'<div>'.
'<div>%s</div>'.
'<pre class="PhabricatorMonospaced">%s</pre>'.
'</div>',
$table->render(),
phutil_implode_html('', $details));
}
}
......
......@@ -42,17 +42,14 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin {
$out = array();
$out[] =
$out[] = hsprintf(
'<div class="dark-console-panel-header">'.
'<h1>Registered Event Listeners</h1>'.
'</div>';
'</div>');
$rows = array();
foreach ($data['listeners'] as $listener) {
$rows[] = array(
phutil_escape_html($listener['id']),
phutil_escape_html($listener['class']),
);
$rows[] = array($listener['id'], $listener['class']);
}
$table = new AphrontTableView($rows);
......@@ -69,15 +66,15 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin {
$out[] = $table->render();
$out[] =
$out[] = hsprintf(
'<div class="dark-console-panel-header">'.
'<h1>Event Log</h1>'.
'</div>';
'</div>');
$rows = array();
foreach ($data['events'] as $event) {
$rows[] = array(
phutil_escape_html($event['type']),
$event['type'],
$event['stopped'] ? 'STOPPED' : null,
);
}
......@@ -96,6 +93,6 @@ final class DarkConsoleEventPlugin extends DarkConsolePlugin {
$out[] = $table->render();
return implode("\n", $out);
return phutil_implode_html("\n", $out);
}
}
......@@ -43,8 +43,8 @@ final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
$rows = array();
foreach ($map as $key => $value) {
$rows[] = array(
phutil_escape_html($key),
phutil_escape_html(is_array($value) ? json_encode($value) : $value),
$key,
(is_array($value) ? json_encode($value) : $value),
);
}
......@@ -62,6 +62,6 @@ final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
$out[] = $table->render();
}
return implode("\n", $out);
return phutil_implode_html("\n", $out);
}
}
......@@ -149,20 +149,21 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
$log = $data['log'];
$results = array();
$results[] =
$results[] = hsprintf(
'<div class="dark-console-panel-header">'.
phutil_tag(
'a',
array(
'href' => $data['analyzeURI'],
'class' => $data['didAnalyze']
? 'disabled button'
: 'green button',
),
'Analyze Query Plans').
'%s'.
'<h1>Calls to External Services</h1>'.
'<div style="clear: both;"></div>'.
'</div>';
'</div>',
phutil_tag(
'a',
array(
'href' => $data['analyzeURI'],
'class' => $data['didAnalyze']
? 'disabled button'
: 'green button',
),
'Analyze Query Plans'));
$page_total = $data['end'] - $data['start'];
$totals = array();
......@@ -224,23 +225,18 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
$row['explain']['reason']);
}
$info = phutil_escape_html($info);
break;
case 'connect':
$info = $row['host'].':'.$row['database'];
$info = phutil_escape_html($info);
break;
case 'exec':
$info = $row['command'];
$info = phutil_escape_html($info);
break;
case 'conduit':
$info = $row['method'];
$info = phutil_escape_html($info);
break;
case 'http':
$info = $row['uri'];
$info = phutil_escape_html($info);
break;
default:
$info = '-';
......@@ -248,7 +244,7 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
}
$rows[] = array(
phutil_escape_html($row['type']),
$row['type'],
'+'.number_format(1000 * ($row['begin'] - $data['start'])).' ms',
number_format(1000000 * $row['duration']).' us',
$info,
......@@ -276,7 +272,7 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
$results[] = $table->render();
return implode("\n", $results);
return phutil_implode_html("\n", $results);
}
}
......@@ -51,48 +51,52 @@ final class DarkConsoleXHProfPlugin extends DarkConsolePlugin {
'class' => 'bright-link',
),
'Installation Guide');
return
return hsprintf(
'<div class="dark-console-no-content">'.
'The "xhprof" PHP extension is not available. Install xhprof '.
'to enable the XHProf console plugin. You can find instructions in '.
'the '.$install_guide.'.'.
'</div>';
'the %s.'.
'</div>',
$install_guide);
}
$result = array();
$header =
$header = hsprintf(
'<div class="dark-console-panel-header">'.
phutil_tag(
'a',
array(
'href' => $profile_uri,
'class' => $run
? 'disabled button'
: 'green button',
),
'Profile Page').
'%s'.
'<h1>XHProf Profiler</h1>'.
'</div>';
'</div>',
phutil_tag(
'a',
array(
'href' => $profile_uri,
'class' => $run
? 'disabled button'
: 'green button',
),
'Profile Page'));
$result[] = $header;
if ($run) {
$result[] =
'<a href="/xhprof/profile/'.$run.'/" '.
$result[] = hsprintf(
'<a href="/xhprof/profile/%s/" '.
'class="bright-link" '.
'style="float: right; margin: 1em 2em 0 0;'.
'font-weight: bold;" '.
'target="_blank">Profile Permalink</a>'.
'<iframe src="/xhprof/profile/'.$run.'/?frame=true"></iframe>';
'<iframe src="/xhprof/profile/%s/?frame=true"></iframe>',
$run,
$run);
} else {
$result[] =
$result[] = hsprintf(
'<div class="dark-console-no-content">'.
'Profiling was not enabled for this page. Use the button above '.
'to enable it.'.
'</div>';
'</div>');
}
return implode("\n", $result);
return phutil_implode_html("\n", $result);
}
......
......@@ -26,7 +26,7 @@ final class Aphront403Response extends AphrontHTMLResponse {
}
$failure = new AphrontRequestFailureView();
$failure->setHeader('403 Forbidden');
$failure->appendChild('<p>'.$forbidden_text.'</p>');
$failure->appendChild(phutil_tag('p', array(), $forbidden_text));
$view = new PhabricatorStandardPageView();
$view->setTitle('403 Forbidden');
......
......@@ -12,7 +12,8 @@ final class Aphront404Response extends AphrontHTMLResponse {
public function buildResponseString() {
$failure = new AphrontRequestFailureView();
$failure->setHeader('404 Not Found');
$failure->appendChild('<p>The page you requested was not found.</p>');
$failure->appendChild(phutil_tag('p', array(), pht(
'The page you requested was not found.')));
$view = new PhabricatorStandardPageView();
$view->setTitle('404 Not Found');
......
......@@ -13,7 +13,7 @@ final class AphrontWebpageResponse extends AphrontHTMLResponse {
}
public function buildResponseString() {
return $this->content;
return hsprintf('%s', $this->content);
}
}
......@@ -335,7 +335,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
}
if ($handle) {
$handle_name = phutil_escape_html($handle->getName());
$handle_name = $handle->getName();
} else {
$handle_name = null;
}
......@@ -435,7 +435,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
}
if ($handle) {
$handle_name = phutil_escape_html($handle->getName());
$handle_name = $handle->getName();
} else {
$handle_name = null;
}
......
......@@ -70,10 +70,10 @@ final class PhabricatorAuditCommitListView extends AphrontView {
$rows[] = array(
$commit_name,
$author_name,
phutil_escape_html($commit->getCommitData()->getSummary()),
$commit->getCommitData()->getSummary(),
PhabricatorAuditCommitStatusConstants::getStatusName(
$commit->getAuditStatus()),
implode(', ', $auditors),
phutil_implode_html(', ', $auditors),
phabricator_datetime($commit->getEpoch(), $this->user),
);
}
......
......@@ -129,10 +129,7 @@ final class PhabricatorAuditListView extends AphrontView {
}
$reasons = $audit->getAuditReasons();
foreach ($reasons as $key => $reason) {
$reasons[$key] = phutil_escape_html($reason);
}
$reasons = implode('<br />', $reasons);
$reasons = phutil_implode_html(phutil_tag('br'), $reasons);
$status_code = $audit->getAuditStatus();
$status = PhabricatorAuditStatusConstants::getStatusName($status_code);
......@@ -140,10 +137,10 @@ final class PhabricatorAuditListView extends AphrontView {
$auditor_handle = $this->getHandle($audit->getAuditorPHID());
$rows[] = array(
$commit_name,
phutil_escape_html($commit_desc),
$commit_desc,
$committed,
$auditor_handle->renderLink(),
phutil_escape_html($status),
$status,
$reasons,
);
......
......@@ -16,8 +16,8 @@ final class PhabricatorDisabledUserController
$failure_view = new AphrontRequestFailureView();
$failure_view->setHeader(pht('Account Disabled'));
$failure_view->appendChild(
'<p>'.pht('Your account has been disabled.').'</p>');
$failure_view->appendChild(phutil_tag('p', array(), pht(
'Your account has been disabled.')));
return $this->buildStandardPageResponse(
$failure_view,
......
......@@ -98,10 +98,8 @@ EOBODY;
$view = new AphrontRequestFailureView();
$view->setHeader(pht('Check Your Email'));
$view->appendChild(
'<p>'.pht(
'An email has been sent with a link you can use to login.'
).'</p>');
$view->appendChild(phutil_tag('p', array(), pht(
'An email has been sent with a link you can use to login.')));
return $this->buildStandardPageResponse(
$view,
array(
......@@ -140,8 +138,8 @@ EOBODY;
$panel = new AphrontPanelView();
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild('
<h1>'.pht('Forgot Password / Email Login').'</h1>');
$panel->appendChild(phutil_tag('h1', array(), pht(
'Forgot Password / Email Login')));
$panel->appendChild($email_auth);
$panel->setNoBackground();
......
......@@ -50,17 +50,16 @@ final class PhabricatorEmailTokenController
$view = new AphrontRequestFailureView();
$view->setHeader(pht('Unable to Login'));
$view->appendChild(
'<p>'.pht('The authentication information in the link you clicked is '.
$view->appendChild(phutil_tag('p', array(), pht(
'The authentication information in the link you clicked is '.
'invalid or out of date. Make sure you are copy-and-pasting the '.
'entire link into your browser. You can try again, or request '.
'a new email.').'</p>');
$view->appendChild(
'a new email.')));
$view->appendChild(hsprintf(
'<div class="aphront-failure-continue">'.
'<a class="button" href="/login/email/">'.
pht('Send Another Email').
'</a>'.
'</div>');
'<a class="button" href="/login/email/">%s</a>'.
'</div>',
pht('Send Another Email')));
return $this->buildStandardPageResponse(
$view,
......
......@@ -43,12 +43,11 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController {
$dialog = new AphrontDialogView();
$dialog->setUser($current_user);
$dialog->setTitle(pht('Already Linked to Another Account'));
$dialog->appendChild(
'<p>'.pht('The LDAP account you just authorized is already '.
$dialog->appendChild(phutil_tag('p', array(), pht(
'The LDAP account you just authorized is already '.
'linked toanother Phabricator account. Before you can link it '.
'to a different LDAP account, you must unlink the old '.
'account.').'</p>'
);
'account.')));
$dialog->addCancelButton('/settings/panel/ldap/');
return id(new AphrontDialogResponse())->setDialog($dialog);
......@@ -62,10 +61,8 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController {
$dialog = new AphrontDialogView();
$dialog->setUser($current_user);
$dialog->setTitle(pht('Link LDAP Account'));
$dialog->appendChild(
'<p>'.
pht('Link your LDAP account to your Phabricator account?').
'</p>');
$dialog->appendChild(phutil_tag('p', array(), pht(
'Link your LDAP account to your Phabricator account?')));
$dialog->addHiddenInput('username', $request->getStr('username'));
$dialog->addHiddenInput('password', $request->getStr('password'));
$dialog->addSubmitButton(pht('Link Accounts'));
......@@ -134,9 +131,10 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController {
$panel = new AphrontPanelView();
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild('<h1>'.pht('LDAP login').'</h1>');
$panel->appendChild(phutil_tag('h1', array(), pht('LDAP login')));
$panel->appendChild($ldap_form);
$error_view = null;
if (isset($errors) && count($errors) > 0) {
$error_view = new AphrontErrorView();
$error_view->setTitle(pht('Login Failed'));
......@@ -145,7 +143,7 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController {
return $this->buildStandardPageResponse(
array(
isset($error_view) ? $error_view : null,
$error_view,
$panel,
),
array(
......
......@@ -18,9 +18,9 @@ final class PhabricatorLDAPUnlinkController extends PhabricatorAuthController {
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle(pht('Really unlink account?'));
$dialog->appendChild(
'<p>'.pht('You will not be able to login using this account '.
'once you unlink it. Continue?').'</p>');
$dialog->appendChild(phutil_tag('p', array(), pht(
'You will not be able to login using this account '.
'once you unlink it. Continue?')));
$dialog->addSubmitButton(pht('Unlink Account'));
$dialog->addCancelButton('/settings/panel/ldap/');
......
......@@ -29,7 +29,8 @@ final class PhabricatorLoginController
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle(pht('Login Required'));
$dialog->appendChild('<p>'.pht('You must login to continue.').'</p>');
$dialog->appendChild(phutil_tag('p', array(), pht(
'You must login to continue.')));
$dialog->addSubmitButton(pht('Login'));
$dialog->addCancelButton('/', pht('Cancel'));
......@@ -246,8 +247,7 @@ final class PhabricatorLoginController
$title = pht("Login or Register with %s", $provider_name);
$body = pht('Login or register for Phabricator using your %s account.',
$provider_name);
$button = pht("Login or Register with %s",
phutil_escape_html($provider_name));
$button = pht("Login or Register with %s", $provider_name);
} else {