@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use phutil_tag in Setup issue stuff

Summary: These are pretty straightforward, they just have a fair amount of instructional text with inline markup.

Test Plan: Added and viewed a UIExample.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2432

Differential Revision: https://secure.phabricator.com/D4686

+125 -86
+2
src/__phutil_library_map__.php
··· 1254 1254 'PhabricatorSetupCheckStorage' => 'applications/config/check/PhabricatorSetupCheckStorage.php', 1255 1255 'PhabricatorSetupCheckTimezone' => 'applications/config/check/PhabricatorSetupCheckTimezone.php', 1256 1256 'PhabricatorSetupIssue' => 'applications/config/issue/PhabricatorSetupIssue.php', 1257 + 'PhabricatorSetupIssueExample' => 'applications/uiexample/examples/PhabricatorSetupIssueExample.php', 1257 1258 'PhabricatorSetupIssueView' => 'applications/config/view/PhabricatorSetupIssueView.php', 1258 1259 'PhabricatorSlowvoteChoice' => 'applications/slowvote/storage/PhabricatorSlowvoteChoice.php', 1259 1260 'PhabricatorSlowvoteComment' => 'applications/slowvote/storage/PhabricatorSlowvoteComment.php', ··· 2652 2653 'PhabricatorSetupCheckPath' => 'PhabricatorSetupCheck', 2653 2654 'PhabricatorSetupCheckStorage' => 'PhabricatorSetupCheck', 2654 2655 'PhabricatorSetupCheckTimezone' => 'PhabricatorSetupCheck', 2656 + 'PhabricatorSetupIssueExample' => 'PhabricatorUIExample', 2655 2657 'PhabricatorSetupIssueView' => 'AphrontView', 2656 2658 'PhabricatorSlowvoteChoice' => 'PhabricatorSlowvoteDAO', 2657 2659 'PhabricatorSlowvoteComment' => 'PhabricatorSlowvoteDAO',
+5 -4
src/applications/config/check/PhabricatorSetupCheckBaseURI.php
··· 59 59 ->setSummary($summary) 60 60 ->setMessage($message) 61 61 ->addCommand( 62 - csprintf( 63 - '<tt>phabricator/ $</tt> '. 64 - './bin/config set phabricator.base-uri %s', 65 - $base_uri_guess)); 62 + hsprintf( 63 + '<tt>phabricator/ $</tt> %s', 64 + csprintf( 65 + './bin/config set phabricator.base-uri %s', 66 + $base_uri_guess))); 66 67 } 67 68 }
+1 -1
src/applications/config/check/PhabricatorSetupCheckDatabase.php
··· 79 79 ->setName(pht('Setup MySQL Schema')) 80 80 ->setMessage($message) 81 81 ->setIsFatal(true) 82 - ->addCommand('<tt>phabricator/ $</tt> ./bin/storage upgrade'); 82 + ->addCommand(hsprintf('<tt>phabricator/ $</tt> ./bin/storage upgrade')); 83 83 } 84 84 } 85 85 }
+79 -81
src/applications/config/view/PhabricatorSetupIssueView.php
··· 16 16 public function render() { 17 17 $issue = $this->getIssue(); 18 18 19 - $description = phutil_tag( 19 + $description = array(); 20 + $description[] = phutil_tag( 20 21 'div', 21 22 array( 22 23 'class' => 'setup-issue-instructions', ··· 25 26 26 27 $configs = $issue->getPHPConfig(); 27 28 if ($configs) { 28 - $description .= $this->renderPHPConfig($configs); 29 + $description[] = $this->renderPHPConfig($configs); 29 30 } 30 31 31 32 $configs = $issue->getPhabricatorConfig(); 32 33 if ($configs) { 33 - $description .= $this->renderPhabricatorConfig($configs); 34 + $description[] = $this->renderPhabricatorConfig($configs); 34 35 } 35 36 36 37 $commands = $issue->getCommands(); 37 38 if ($commands) { 38 39 $run_these = pht("Run these %d command(s):", count($commands)); 39 - $description .= phutil_tag( 40 + $description[] = phutil_tag( 40 41 'div', 41 42 array( 42 43 'class' => 'setup-issue-config', 43 44 ), 44 45 array( 45 - phutil_render_tag('p', array(), $run_these), 46 - phutil_render_tag('pre', array(), implode("\n", $commands)), 46 + phutil_tag('p', array(), $run_these), 47 + phutil_tag('pre', array(), array_interleave("\n", $commands)), 47 48 )); 48 49 } 49 50 ··· 52 53 $install_these = pht( 53 54 "Install these %d PHP extension(s):", count($extensions)); 54 55 55 - $install_info = pht( 56 + $install_info = phutil_safe_html(pht( 56 57 "You can usually install a PHP extension using <tt>apt-get</tt> or ". 57 58 "<tt>yum</tt>. Common package names are ". 58 59 "<tt>php-<em>extname</em></tt> or <tt>php5-<em>extname</em></tt>. ". 59 - "Try commands like these:"); 60 + "Try commands like these:")); 60 61 61 62 // TODO: We should do a better job of detecting how to install extensions 62 63 // on the current system. ··· 65 66 "$ sudo yum install php-<em>extname</em> # Red Hat / Derivatives", 66 67 ); 67 68 $install_commands = implode("\n", $install_commands); 69 + $install_commands = phutil_safe_html($install_commands); 68 70 69 71 $fallback_info = pht( 70 72 "If those commands don't work, try Google. The process of installing ". ··· 75 77 $restart_info = pht( 76 78 "After installing new PHP extensions, <strong>restart your webserver ". 77 79 "for the changes to take effect</strong>."); 80 + $restart_info = phutil_safe_html($restart_info); 78 81 79 - $description .= phutil_tag( 82 + $description[] = phutil_tag( 80 83 'div', 81 84 array( 82 85 'class' => 'setup-issue-config', 83 86 ), 84 87 array( 85 - phutil_render_tag('p', array(), $install_these), 86 - phutil_render_tag('pre', array(), implode("\n", $extensions)), 87 - phutil_render_tag('p', array(), $install_info), 88 - phutil_render_tag('pre', array(), $install_commands), 89 - phutil_render_tag('p', array(), $fallback_info), 90 - phutil_render_tag('p', array(), $restart_info), 88 + phutil_tag('p', array(), $install_these), 89 + phutil_tag('pre', array(), implode("\n", $extensions)), 90 + phutil_tag('p', array(), $install_info), 91 + phutil_tag('pre', array(), $install_commands), 92 + phutil_tag('p', array(), $fallback_info), 93 + phutil_tag('p', array(), $restart_info), 91 94 )); 92 95 93 96 } ··· 111 114 array( 112 115 'class' => 'setup-issue', 113 116 ), 114 - array($name, $description, $next)); 117 + $this->renderHTMLView( 118 + array( 119 + $name, 120 + $description, 121 + $next, 122 + ))); 115 123 } 116 124 117 125 private function renderPhabricatorConfig(array $configs) { ··· 124 132 "The current Phabricator configuration has these %d value(s):", 125 133 count($configs))); 126 134 127 - $table = array(); 135 + $dict = array(); 128 136 foreach ($configs as $key) { 129 - $table[] = '<tr>'; 130 - $table[] = '<th>'.phutil_escape_html($key).'</th>'; 131 - 132 - $value = PhabricatorEnv::getUnrepairedEnvConfig($key); 133 - if ($value === null) { 134 - $value = '<em>null</em>'; 135 - } else if ($value === false) { 136 - $value = '<em>false</em>'; 137 - } else if ($value === true) { 138 - $value = '<em>true</em>'; 139 - } else { 140 - $value = phutil_escape_html( 141 - PhabricatorConfigJSON::prettyPrintJSON($value)); 142 - } 143 - 144 - $table[] = '<td>'.$value.'</td>'; 145 - $table[] = '</tr>'; 137 + $dict[$key] = PhabricatorEnv::getUnrepairedEnvConfig($key); 146 138 } 147 - 148 - $table = phutil_tag( 149 - 'table', 150 - array( 151 - ), 152 - new PhutilSafeHTML(implode("\n", $table))); 139 + $table = $this->renderValueTable($dict); 153 140 154 141 $options = PhabricatorApplicationConfigOptions::loadAllOptions(); 155 142 ··· 164 151 165 152 $update = array(); 166 153 foreach ($configs as $key) { 167 - $cmd = '<tt>phabricator/ $</tt> ./bin/config set '. 168 - phutil_escape_html($key).' '. 169 - '<em>value</em>'; 170 - $update[] = $cmd; 154 + $update[] = hsprintf( 155 + '<tt>phabricator/ $</tt> ./bin/config set %s <em>value</em>', 156 + $key); 171 157 } 172 - $update = phutil_render_tag('pre', array(), implode("\n", $update)); 158 + $update = phutil_tag('pre', array(), array_interleave("\n", $update)); 173 159 } else { 174 160 $update = array(); 175 161 foreach ($configs as $config) { ··· 182 168 'href' => '/config/edit/'.$config.'/?issue='.$issue->getIssueKey(), 183 169 ), 184 170 pht('Edit %s', $config)); 185 - $update[] = '<li>'.$link.'</li>'; 171 + $update[] = phutil_tag('li', array(), $link); 186 172 } 187 173 if ($update) { 188 - $update = '<ul>'.implode("\n", $update).'</ul>'; 189 - $update_info = phutil_render_tag( 174 + $update = phutil_tag('ul', array(), $update); 175 + $update_info = phutil_tag( 190 176 'p', 191 177 array(), 192 178 pht("You can update these %d value(s) here:", count($configs))); ··· 196 182 } 197 183 } 198 184 199 - return phutil_render_tag( 185 + return phutil_tag( 200 186 'div', 201 187 array( 202 188 'class' => 'setup-issue-config', 203 189 ), 204 - self::renderSingleView( 190 + self::renderHTMLView( 205 191 array( 206 192 $table_info, 207 193 $table, ··· 218 204 "The current PHP configuration has these %d value(s):", 219 205 count($configs))); 220 206 221 - $table = array(); 207 + $dict = array(); 222 208 foreach ($configs as $key) { 223 - $table[] = '<tr>'; 224 - $table[] = '<th>'.phutil_escape_html($key).'</th>'; 225 - 226 - $value = ini_get($key); 227 - if ($value === null) { 228 - $value = '<em>null</em>'; 229 - } else if ($value === false) { 230 - $value = '<em>false</em>'; 231 - } else if ($value === true) { 232 - $value = '<em>true</em>'; 233 - } else if ($value === '') { 234 - $value = '<em>(empty string)</em>'; 235 - } else { 236 - $value = phutil_escape_html($value); 237 - } 238 - 239 - $table[] = '<td>'.$value.'</td>'; 240 - $table[] = '</tr>'; 209 + $dict[$key] = ini_get($key); 241 210 } 242 211 243 - $table = phutil_tag( 244 - 'table', 245 - array(), 246 - new PhutilSafeHTML(implode("\n", $table))); 212 + $table = $this->renderValueTable($dict); 247 213 248 214 ob_start(); 249 215 phpinfo(); ··· 270 236 } 271 237 } 272 238 239 + $info = array(); 273 240 if (!$ini_loc) { 274 - $info = phutil_tag( 241 + $info[] = phutil_tag( 275 242 'p', 276 243 array(), 277 244 pht( 278 245 "To update these %d value(s), edit your PHP configuration file.", 279 246 count($configs))); 280 247 } else { 281 - $info = phutil_tag( 248 + $info[] = phutil_tag( 282 249 'p', 283 250 array(), 284 251 pht( 285 252 "To update these %d value(s), edit your PHP configuration file, ". 286 253 "located here:", 287 254 count($configs))); 288 - $info .= phutil_tag( 255 + $info[] = phutil_tag( 289 256 'pre', 290 257 array(), 291 258 $ini_loc); 292 259 } 293 260 294 261 if ($more_loc) { 295 - $info .= phutil_tag( 262 + $info[] = phutil_tag( 296 263 'p', 297 264 array(), 298 265 pht( 299 266 "PHP also loaded these configuration file(s):", 300 267 count($more_loc))); 301 - $info .= phutil_tag( 268 + $info[] = phutil_tag( 302 269 'pre', 303 270 array(), 304 271 implode("\n", $more_loc)); 305 272 } 306 273 307 - $info .= phutil_tag( 274 + $info[] = phutil_tag( 308 275 'p', 309 276 array(), 310 277 phutil_safe_html(pht( ··· 312 279 '<a href="%s">PHP Documentation</a>.', 313 280 'http://php.net/manual/ini.list.php'))); 314 281 315 - $info .= phutil_tag( 282 + $info[] = phutil_tag( 316 283 'p', 317 284 array(), 318 285 phutil_safe_html(pht( ··· 324 291 array( 325 292 'class' => 'setup-issue-config', 326 293 ), 327 - array($table_info, $table, $info)); 294 + $this->renderHTMLView( 295 + array( 296 + $table_info, 297 + $table, 298 + $info, 299 + ))); 300 + } 301 + 302 + private function renderValueTable(array $dict) { 303 + $rows = array(); 304 + foreach ($dict as $key => $value) { 305 + $cols = array( 306 + phutil_tag('th', array(), $key), 307 + phutil_tag('td', array(), $this->renderValueForDisplay($value)), 308 + ); 309 + $rows[] = phutil_tag('tr', array(), $cols); 310 + } 311 + return phutil_tag('table', array(), $rows); 312 + } 313 + 314 + private function renderValueForDisplay($value) { 315 + if ($value === null) { 316 + return phutil_tag('em', array(), 'null'); 317 + } else if ($value === false) { 318 + return phutil_tag('em', array(), 'false'); 319 + } else if ($value === true) { 320 + return phutil_tag('em', array(), 'true'); 321 + } else if ($value === '') { 322 + return phutil_tag('em', array(), 'empty string'); 323 + } else { 324 + return PhabricatorConfigJSON::prettyPrintJSON($value); 325 + } 328 326 } 329 327 330 328 }
+38
src/applications/uiexample/examples/PhabricatorSetupIssueExample.php
··· 1 + <?php 2 + 3 + final class PhabricatorSetupIssueExample extends PhabricatorUIExample { 4 + 5 + public function getName() { 6 + return 'Setup Issue'; 7 + } 8 + 9 + public function getDescription() { 10 + return 'Setup errors and warnings.'; 11 + } 12 + 13 + public function renderExample() { 14 + $request = $this->getRequest(); 15 + $user = $request->getUser(); 16 + 17 + $issue = id(new PhabricatorSetupIssue()) 18 + ->setShortName(pht('Short Name')) 19 + ->setName(pht('Name')) 20 + ->setSummary(pht('Summary')) 21 + ->setMessage(pht('Message')) 22 + ->setIssueKey('example.key') 23 + ->addCommand('$ # Add Command') 24 + ->addCommand(hsprintf('<tt>$</tt> %s', '$ ls -1 > /dev/null')) 25 + ->addPHPConfig('php.config.example') 26 + ->addPhabricatorConfig('test.value') 27 + ->addPHPExtension('libexample'); 28 + 29 + // NOTE: Since setup issues may be rendered before we can build the page 30 + // chrome, they don't explicitly include resources. 31 + require_celerity_resource('setup-issue-css'); 32 + 33 + $view = id(new PhabricatorSetupIssueView()) 34 + ->setIssue($issue); 35 + 36 + return $view; 37 + } 38 + }