Skip to content

Commit a29b5b0

Browse files
committed
Replace some hsprintf() by phutil_tag()
Test Plan: Looked at a diff with inline comment. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7549
1 parent 7ec42db commit a29b5b0

File tree

62 files changed

+518
-520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+518
-520
lines changed

src/applications/auth/controller/PhabricatorEmailTokenController.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ public function processRequest() {
5151
'invalid or out of date. Make sure you are copy-and-pasting the '.
5252
'entire link into your browser. You can try again, or request '.
5353
'a new email.')));
54-
$view->appendChild(hsprintf(
55-
'<div class="aphront-failure-continue">'.
56-
'<a class="button" href="/login/email/">%s</a>'.
57-
'</div>',
58-
pht('Send Another Email')));
54+
$view->appendChild(phutil_tag_div(
55+
'aphront-failure-continue',
56+
phutil_tag(
57+
'a',
58+
array('class' => 'button', 'href' => '/login/email/'),
59+
pht('Send Another Email'))));
5960

6061
return $this->buildStandardPageResponse(
6162
$view,

src/applications/auth/controller/PhabricatorMustVerifyEmailController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function processRequest() {
4848
$error_view->appendChild(phutil_tag('p', array(), pht(
4949
'If you did not receive an email, you can click the button below '.
5050
'to try sending another one.')));
51-
$error_view->appendChild(hsprintf(
52-
'<div class="aphront-failure-continue">%s</div>',
51+
$error_view->appendChild(phutil_tag_div(
52+
'aphront-failure-continue',
5353
phabricator_form(
5454
$user,
5555
array(

src/applications/auth/provider/PhabricatorAuthProviderLDAP.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,18 @@ public function extendEditForm(
254254
$captions = array(
255255
self::KEY_HOSTNAME =>
256256
pht('Example: %s',
257-
hsprintf('<tt>%s</tt>', pht('ldap.example.com'))),
257+
phutil_tag('tt', array(), pht('ldap.example.com'))),
258258
self::KEY_DISTINGUISHED_NAME =>
259259
pht('Example: %s',
260-
hsprintf('<tt>%s</tt>', pht('ou=People, dc=example, dc=com'))),
260+
phutil_tag('tt', array(), pht('ou=People, dc=example, dc=com'))),
261261
self::KEY_SEARCH_ATTRIBUTE =>
262262
pht('Example: %s',
263-
hsprintf('<tt>%s</tt>', pht('sn'))),
263+
phutil_tag('tt', array(), pht('sn'))),
264264
self::KEY_USERNAME_ATTRIBUTE =>
265265
pht('Optional, if different from search attribute.'),
266266
self::KEY_REALNAME_ATTRIBUTES =>
267267
pht('Optional. Example: %s',
268-
hsprintf('<tt>%s</tt>', pht('firstname, lastname'))),
268+
phutil_tag('tt', array(), pht('firstname, lastname'))),
269269
self::KEY_REFERRALS =>
270270
pht('Follow referrals. Disable this for Windows AD 2003.'),
271271
self::KEY_START_TLS =>

src/applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ public function extendEditForm(
8484
"improves security by preventing an attacker from capturing ".
8585
"an insecure Facebook session and escalating it into a ".
8686
"Phabricator session. Enabling it is recommended.",
87-
hsprintf(
88-
'<strong>%s</strong>',
89-
pht('Require Secure Browsing:')))));
87+
phutil_tag('strong', array(), pht('Require Secure Browsing:')))));
9088
}
9189

9290
public function renderConfigPropertyTransactionTitle(

src/applications/base/controller/PhabricatorController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ public function didProcessRequest($response) {
246246
$view = new PhabricatorStandardPageView();
247247
$view->setRequest($request);
248248
$view->setController($this);
249-
$view->appendChild(hsprintf(
250-
'<div style="padding: 2em 0;">%s</div>',
249+
$view->appendChild(phutil_tag(
250+
'div',
251+
array('style' => 'padding: 2em 0;'),
251252
$response->buildResponseString()));
252253
$page_response = new AphrontWebpageResponse();
253254
$page_response->setContent($view->render());

src/applications/calendar/controller/PhabricatorCalendarBrowseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function processRequest() {
6161
$nav->appendChild(
6262
array(
6363
$this->getNoticeView(),
64-
hsprintf('<div style="padding: 20px;">%s</div>', $month_view),
64+
phutil_tag('div', array('style' => 'padding: 20px;'), $month_view),
6565
));
6666

6767
return $this->buildApplicationPage(

src/applications/calendar/view/AphrontCalendarMonthView.php

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ public function render() {
8787
} else {
8888
$show_events = array_fill_keys(
8989
array_keys($show_events),
90-
hsprintf(
91-
'<div class="aphront-calendar-event aphront-calendar-event-empty">'.
92-
'&nbsp;'.
93-
'</div>'));
90+
phutil_tag_div(
91+
'aphront-calendar-event aphront-calendar-event-empty',
92+
"\xC2\xA0")); // &nbsp;
9493
}
9594

9695
foreach ($events as $event) {
@@ -119,45 +118,49 @@ public function render() {
119118
$name);
120119
}
121120

122-
$markup[] = hsprintf(
123-
'<div class="%s">'.
124-
'<div class="aphront-calendar-date-number">%s</div>'.
125-
'%s%s'.
126-
'</div>',
121+
$markup[] = phutil_tag_div(
127122
$class,
128-
$day_number,
129-
$holiday_markup,
130-
phutil_implode_html("\n", $show_events));
123+
array(
124+
phutil_tag_div('aphront-calendar-date-number', $day_number),
125+
$holiday_markup,
126+
phutil_implode_html("\n", $show_events),
127+
));
131128
}
132129

133130
$table = array();
134131
$rows = array_chunk($markup, 7);
135132
foreach ($rows as $row) {
136-
$table[] = hsprintf('<tr>');
133+
$cells = array();
137134
while (count($row) < 7) {
138135
$row[] = $empty_box;
139136
}
140137
foreach ($row as $cell) {
141-
$table[] = phutil_tag('td', array(), $cell);
138+
$cells[] = phutil_tag('td', array(), $cell);
142139
}
143-
$table[] = hsprintf('</tr>');
140+
$table[] = phutil_tag('tr', array(), $cells);
144141
}
145-
$table = hsprintf(
146-
'<table class="aphront-calendar-view">'.
147-
'%s'.
148-
'<tr class="aphront-calendar-day-of-week-header">'.
149-
'<th>Sun</th>'.
150-
'<th>Mon</th>'.
151-
'<th>Tue</th>'.
152-
'<th>Wed</th>'.
153-
'<th>Thu</th>'.
154-
'<th>Fri</th>'.
155-
'<th>Sat</th>'.
156-
'</tr>'.
157-
'%s'.
158-
'</table>',
159-
$this->renderCalendarHeader($first),
160-
phutil_implode_html("\n", $table));
142+
143+
$header = phutil_tag(
144+
'tr',
145+
array('class' => 'aphront-calendar-day-of-week-header'),
146+
array(
147+
phutil_tag('th', array(), pht('Sun')),
148+
phutil_tag('th', array(), pht('Mon')),
149+
phutil_tag('th', array(), pht('Tue')),
150+
phutil_tag('th', array(), pht('Wed')),
151+
phutil_tag('th', array(), pht('Thu')),
152+
phutil_tag('th', array(), pht('Fri')),
153+
phutil_tag('th', array(), pht('Sat')),
154+
));
155+
156+
$table = phutil_tag(
157+
'table',
158+
array('class' => 'aphront-calendar-view'),
159+
array(
160+
$this->renderCalendarHeader($first),
161+
$header,
162+
phutil_implode_html("\n", $table),
163+
));
161164

162165
return $table;
163166
}
@@ -190,11 +193,14 @@ private function renderCalendarHeader(DateTime $date) {
190193
$right_th = phutil_tag('th', array(), $next_link);
191194
}
192195

193-
return hsprintf(
194-
'<tr class="aphront-calendar-month-year-header">%s%s%s</tr>',
195-
$left_th,
196-
phutil_tag('th', array('colspan' => $colspan), $date->format('F Y')),
197-
$right_th);
196+
return phutil_tag(
197+
'tr',
198+
array('class' => 'aphront-calendar-month-year-header'),
199+
array(
200+
$left_th,
201+
phutil_tag('th', array('colspan' => $colspan), $date->format('F Y')),
202+
$right_th,
203+
));
198204
}
199205

200206
private function getNextYearAndMonth() {

src/applications/conduit/controller/PhabricatorConduitAPIController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,10 @@ private function renderAPIValue($value) {
423423
$value = $json->encodeFormatted($value);
424424
}
425425

426-
$value = hsprintf('<pre style="white-space: pre-wrap;">%s</pre>', $value);
426+
$value = phutil_tag(
427+
'pre',
428+
array('style' => 'white-space: pre-wrap;'),
429+
$value);
427430

428431
return $value;
429432
}

src/applications/conduit/query/PhabricatorConduitSearchEngine.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ public function buildSearchForm(
6161
->setLabel('Applications')
6262
->setName('applicationNames')
6363
->setValue(implode(', ', $names))
64-
->setCaption(
65-
pht('Example: %s', hsprintf('<tt>differential, paste</tt>'))));
64+
->setCaption(pht(
65+
'Example: %s',
66+
phutil_tag('tt', array(), 'differential, paste'))));
6667

6768
$is_stable = $saved->getParameter('isStable');
6869
$is_unstable = $saved->getParameter('isUnstable');

src/applications/config/controller/PhabricatorConfigEditController.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,10 @@ private function renderExamples(PhabricatorConfigOption $option) {
473473
}
474474

475475
$table = array();
476-
$table[] = hsprintf(
477-
'<tr class="column-labels"><th>%s</th><th>%s</th></tr>',
478-
pht('Example'),
479-
pht('Value'));
476+
$table[] = phutil_tag('tr', array('class' => 'column-labels'), array(
477+
phutil_tag('th', array(), pht('Example')),
478+
phutil_tag('th', array(), pht('Value')),
479+
));
480480
foreach ($examples as $example) {
481481
list($value, $description) = $example;
482482

@@ -488,10 +488,10 @@ private function renderExamples(PhabricatorConfigOption $option) {
488488
}
489489
}
490490

491-
$table[] = hsprintf(
492-
'<tr><th>%s</th><td>%s</td></tr>',
493-
$description,
494-
$value);
491+
$table[] = phutil_tag('tr', array(), array(
492+
phutil_tag('th', array(), $description),
493+
phutil_tag('th', array(), $value),
494+
));
495495
}
496496

497497
require_celerity_resource('config-options-css');
@@ -509,10 +509,10 @@ private function renderDefaults(PhabricatorConfigOption $option) {
509509
$stack = $stack->getStack();
510510

511511
$table = array();
512-
$table[] = hsprintf(
513-
'<tr class="column-labels"><th>%s</th><th>%s</th></tr>',
514-
pht('Source'),
515-
pht('Value'));
512+
$table[] = phutil_tag('tr', array('class' => 'column-labels'), array(
513+
phutil_tag('th', array(), pht('Source')),
514+
phutil_tag('th', array(), pht('Value')),
515+
));
516516
foreach ($stack as $key => $source) {
517517
$value = $source->getKeys(
518518
array(
@@ -526,10 +526,10 @@ private function renderDefaults(PhabricatorConfigOption $option) {
526526
$value[$option->getKey()]);
527527
}
528528

529-
$table[] = hsprintf(
530-
'<tr><th>%s</th><td>%s</td></tr>',
531-
$source->getName(),
532-
$value);
529+
$table[] = phutil_tag('tr', array('class' => 'column-labels'), array(
530+
phutil_tag('th', array(), $source->getName()),
531+
phutil_tag('td', array(), $value),
532+
));
533533
}
534534

535535
require_celerity_resource('config-options-css');

src/applications/conpherence/controller/ConpherenceNotificationPanelController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function processRequest() {
7272
}
7373
$content = $view->render();
7474
} else {
75-
$content = hsprintf(
76-
'<div class="phabricator-notification no-notifications">%s</div>',
75+
$content = phutil_tag_div(
76+
'phabricator-notification no-notifications',
7777
pht('You have no messages.'));
7878
}
7979

src/applications/countdown/controller/PhabricatorCountdownDeleteController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function processRequest() {
4343
$dialog = new AphrontDialogView();
4444
$dialog->setUser($request->getUser());
4545
$dialog->setTitle(pht('Really delete this countdown?'));
46-
$dialog->appendChild(hsprintf('<p>%s</p>', $inst));
46+
$dialog->appendChild(phutil_tag('p', array(), $inst));
4747
$dialog->addSubmitButton(pht('Delete'));
4848
$dialog->addCancelButton('/countdown/');
4949
$dialog->setSubmitURI($request->getPath());

src/applications/countdown/view/PhabricatorCountdownView.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,31 @@ public function getTagContent() {
4242
}
4343

4444

45-
$container = celerity_generate_unique_node_id();
46-
$content = hsprintf(
47-
'<div class="phabricator-timer" id="%s">
48-
%s
49-
<table class="phabricator-timer-table">
50-
<tr>
51-
<th>%s</th>
52-
<th>%s</th>
53-
<th>%s</th>
54-
<th>%s</th>
55-
</tr>
56-
<tr>%s%s%s%s</tr>
57-
</table>
58-
</div>',
59-
$container,
60-
$header,
61-
pht('Days'),
62-
pht('Hours'),
63-
pht('Minutes'),
64-
pht('Seconds'),
45+
$ths = array(
46+
phutil_tag('th', array(), pht('Days')),
47+
phutil_tag('th', array(), pht('Hours')),
48+
phutil_tag('th', array(), pht('Minutes')),
49+
phutil_tag('th', array(), pht('Seconds')),
50+
);
51+
52+
$dashes = array(
6553
javelin_tag('td', array('sigil' => 'phabricator-timer-days'), '-'),
6654
javelin_tag('td', array('sigil' => 'phabricator-timer-hours'), '-'),
6755
javelin_tag('td', array('sigil' => 'phabricator-timer-minutes'), '-'),
68-
javelin_tag('td', array('sigil' => 'phabricator-timer-seconds'), '-'));
56+
javelin_tag('td', array('sigil' => 'phabricator-timer-seconds'), '-'),
57+
);
58+
59+
$container = celerity_generate_unique_node_id();
60+
$content = phutil_tag(
61+
'div',
62+
array('class' => 'phabricator-timer', 'id' => $container),
63+
array(
64+
$header,
65+
phutil_tag('table', array('class' => 'phabricator-timer-table'), array(
66+
phutil_tag('tr', array(), $ths),
67+
phutil_tag('tr', array(), $dashes),
68+
)),
69+
));
6970

7071
Javelin::initBehavior('countdown-timer', array(
7172
'timestamp' => $countdown->getEpoch(),

src/applications/differential/controller/DifferentialDiffViewController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ public function processRequest() {
3636
// TODO: implement optgroup support in AphrontFormSelectControl?
3737
$select = array();
3838
$select[] = hsprintf('<optgroup label="%s">', pht('Create New Revision'));
39-
$select[] = hsprintf(
40-
'<option value="">%s</option>',
39+
$select[] = phutil_tag(
40+
'option',
41+
array('value' => ''),
4142
pht('Create a new Revision...'));
4243
$select[] = hsprintf('</optgroup>');
4344

src/applications/differential/controller/DifferentialRevisionLandController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function processRequest() {
4949
$ex->getMessage(),
5050
$ex->getPreviousException()->getMessage());
5151
} else {
52-
$text = hsprintf('<pre>%s</pre>', $ex->getMessage());
52+
$text = phutil_tag('pre', array(), $ex->getMessage());
5353
}
5454
$text = id(new AphrontErrorView())
5555
->appendChild($text);

0 commit comments

Comments
 (0)