1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Improve search result formatting slightly.

This commit is contained in:
epriestley 2011-03-22 17:41:55 -07:00
parent 08fc13598d
commit 3c0a822d65
2 changed files with 25 additions and 2 deletions

View file

@ -159,10 +159,18 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
->loadHandles(); ->loadHandles();
$results = array(); $results = array();
foreach ($handles as $handle) { foreach ($handles as $handle) {
$results[] = '<h1>'.$handle->renderLink().'</h1>'; $results[] =
'<h1 style="font-size: 14px; font-weight: normal; margin: 4px 0 8px;">'.
phutil_render_tag(
'a',
array(
'href' => $handle->getURI(),
),
$this->emboldenQuery($handle->getName(), $query->getQuery())).
'</h1>';
} }
$results = $results =
'<div style="padding: 1em 2em 2em;">'. '<div style="padding: 1em 3em 2em;">'.
implode("\n", $results). implode("\n", $results).
'</div>'; '</div>';
} else { } else {
@ -181,4 +189,18 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
)); ));
} }
private function emboldenQuery($str, $query) {
$query = preg_split("/\s+/", $query);
$query = array_filter($query);
$str = phutil_escape_html($str);
foreach ($query as $word) {
$word = phutil_escape_html($word);
$str = preg_replace(
'/('.preg_quote($word, '/').')/i',
'<strong>\1</strong>',
$str);
}
return $str;
}
} }

View file

@ -18,6 +18,7 @@ phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit'); phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');