2011-02-14 15:34:20 -08:00
|
|
|
<?php
|
|
|
|
|
2012-03-09 15:46:25 -08:00
|
|
|
final class PhabricatorSearchController
|
2014-02-03 12:52:47 -08:00
|
|
|
extends PhabricatorSearchBaseController
|
|
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
2012-03-09 15:46:25 -08:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
private $queryKey;
|
2011-02-14 15:34:20 -08:00
|
|
|
|
2013-09-27 10:49:59 -07:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-02-14 15:34:20 -08:00
|
|
|
public function willProcessRequest(array $data) {
|
2014-02-03 12:52:47 -08:00
|
|
|
$this->queryKey = idx($data, 'queryKey');
|
2011-02-14 15:34:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
2014-02-03 12:52:47 -08:00
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
|
|
|
if ($request->getStr('jump') != 'no') {
|
|
|
|
$pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP;
|
|
|
|
if ($viewer->loadPreferences($pref_jump, 1)) {
|
|
|
|
$response = PhabricatorJumpNavHandler::getJumpResponse(
|
|
|
|
$viewer,
|
|
|
|
$request->getStr('query'));
|
2012-03-05 19:51:16 -08:00
|
|
|
if ($response) {
|
|
|
|
return $response;
|
2011-02-20 20:37:50 -08:00
|
|
|
}
|
2011-02-14 15:34:20 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
->setQueryKey($this->queryKey)
|
|
|
|
->setSearchEngine(new PhabricatorSearchApplicationSearchEngine())
|
|
|
|
->setUseOffsetPaging(true)
|
|
|
|
->setNavigation($this->buildSideNavView());
|
2011-02-18 17:16:00 -08:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
return $this->delegateToController($controller);
|
|
|
|
}
|
Improve search result listing
Summary:
Make it prettier, paginate, add user pictures, show document types, clean some
stuff up a little. Plenty of room for improvement but this should make it a lot
more useful.
Test Plan:
Here's what the new one looks like:
https://secure.phabricator.com/file/view/PHID-FILE-edce2b83c2e3a121c2b7/
Reviewed By: jungejason
Reviewers: tomo, jungejason, aran, tuomaspelkonen, mroch
Commenters: tomo
CC: aran, tomo, jungejason, epriestley
Differential Revision: 545
2011-06-28 14:35:02 -07:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
public function buildSideNavView($for_app = false) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
Improve search result listing
Summary:
Make it prettier, paginate, add user pictures, show document types, clean some
stuff up a little. Plenty of room for improvement but this should make it a lot
more useful.
Test Plan:
Here's what the new one looks like:
https://secure.phabricator.com/file/view/PHID-FILE-edce2b83c2e3a121c2b7/
Reviewed By: jungejason
Reviewers: tomo, jungejason, aran, tuomaspelkonen, mroch
Commenters: tomo
CC: aran, tomo, jungejason, epriestley
Differential Revision: 545
2011-06-28 14:35:02 -07:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
Improve search result listing
Summary:
Make it prettier, paginate, add user pictures, show document types, clean some
stuff up a little. Plenty of room for improvement but this should make it a lot
more useful.
Test Plan:
Here's what the new one looks like:
https://secure.phabricator.com/file/view/PHID-FILE-edce2b83c2e3a121c2b7/
Reviewed By: jungejason
Reviewers: tomo, jungejason, aran, tuomaspelkonen, mroch
Commenters: tomo
CC: aran, tomo, jungejason, epriestley
Differential Revision: 545
2011-06-28 14:35:02 -07:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
id(new PhabricatorSearchApplicationSearchEngine())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->addNavigationItems($nav->getMenu());
|
Improve search result listing
Summary:
Make it prettier, paginate, add user pictures, show document types, clean some
stuff up a little. Plenty of room for improvement but this should make it a lot
more useful.
Test Plan:
Here's what the new one looks like:
https://secure.phabricator.com/file/view/PHID-FILE-edce2b83c2e3a121c2b7/
Reviewed By: jungejason
Reviewers: tomo, jungejason, aran, tuomaspelkonen, mroch
Commenters: tomo
CC: aran, tomo, jungejason, epriestley
Differential Revision: 545
2011-06-28 14:35:02 -07:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
$nav->selectFilter(null);
|
Improve search result listing
Summary:
Make it prettier, paginate, add user pictures, show document types, clean some
stuff up a little. Plenty of room for improvement but this should make it a lot
more useful.
Test Plan:
Here's what the new one looks like:
https://secure.phabricator.com/file/view/PHID-FILE-edce2b83c2e3a121c2b7/
Reviewed By: jungejason
Reviewers: tomo, jungejason, aran, tuomaspelkonen, mroch
Commenters: tomo
CC: aran, tomo, jungejason, epriestley
Differential Revision: 545
2011-06-28 14:35:02 -07:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
return $nav;
|
|
|
|
}
|
Improve search result listing
Summary:
Make it prettier, paginate, add user pictures, show document types, clean some
stuff up a little. Plenty of room for improvement but this should make it a lot
more useful.
Test Plan:
Here's what the new one looks like:
https://secure.phabricator.com/file/view/PHID-FILE-edce2b83c2e3a121c2b7/
Reviewed By: jungejason
Reviewers: tomo, jungejason, aran, tuomaspelkonen, mroch
Commenters: tomo
CC: aran, tomo, jungejason, epriestley
Differential Revision: 545
2011-06-28 14:35:02 -07:00
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
public function renderResultsList(
|
|
|
|
array $results,
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
if ($results) {
|
|
|
|
$objects = id(new PhabricatorObjectQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs(mpull($results, 'getPHID'))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$output = array();
|
|
|
|
foreach ($results as $phid => $handle) {
|
|
|
|
$view = id(new PhabricatorSearchResultView())
|
|
|
|
->setHandle($handle)
|
|
|
|
->setQuery($query)
|
|
|
|
->setObject(idx($objects, $phid));
|
|
|
|
$output[] = $view->render();
|
2012-04-02 17:29:52 -07:00
|
|
|
}
|
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
$results = phutil_tag_div(
|
|
|
|
'phabricator-search-result-list',
|
|
|
|
$output);
|
2011-02-14 15:34:20 -08:00
|
|
|
} else {
|
2014-02-03 12:52:47 -08:00
|
|
|
$results = phutil_tag_div(
|
|
|
|
'phabricator-search-result-list',
|
|
|
|
phutil_tag(
|
|
|
|
'p',
|
|
|
|
array('class' => 'phabricator-search-no-results'),
|
|
|
|
pht('No search results.')));
|
2011-02-14 15:34:20 -08:00
|
|
|
}
|
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
return id(new PHUIBoxView())
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE)
|
|
|
|
->addPadding(PHUI::PADDING_LARGE)
|
|
|
|
->setShadow(true)
|
|
|
|
->appendChild($results)
|
|
|
|
->addClass('phabricator-search-result-box');
|
2011-02-14 15:34:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|