mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Improve search result formatting slightly.
This commit is contained in:
parent
08fc13598d
commit
3c0a822d65
2 changed files with 25 additions and 2 deletions
|
@ -159,10 +159,18 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
|||
->loadHandles();
|
||||
$results = array();
|
||||
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 =
|
||||
'<div style="padding: 1em 2em 2em;">'.
|
||||
'<div style="padding: 1em 3em 2em;">'.
|
||||
implode("\n", $results).
|
||||
'</div>';
|
||||
} 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ phutil_require_module('phabricator', 'view/form/base');
|
|||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue