2011-02-14 15:34:20 -08:00
|
|
|
<?php
|
|
|
|
|
2012-03-09 15:46:25 -08:00
|
|
|
final class PhabricatorSearchController
|
2014-05-09 12:28:02 -07:00
|
|
|
extends PhabricatorSearchBaseController {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Replace "search scope" with selectable default behavior
Summary:
Fixes T4365. See discussion in D8123.
This implements the most conservative solution of approaches discussed in D8123. Basically:
- When you search in primary search, we overwrite "query" in your default (topmost) search filter, and execute that.
This doesn't implement any of the other "sticky" stuff, where the query sticks around. Maybe we'll do that eventually, but it gets messy and could be confusing. Practically, this addresses the major use case in the wild, which is to make the menu bar search mean "Open Tasks" by default.
This also removes the old, obsolete "search scope" stuff. A long time ago, searching from within Maniphest would search tasks, etc., but this was pretty weird and confusing and is no longer used, and no one complained when we got rid of it.
Test Plan: Dragged "Open Tasks" to my top search, searched for "asdf", got "asdf in open tasks" results.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: bigo, aran
Maniphest Tasks: T4365
Differential Revision: https://secure.phabricator.com/D8135
2014-02-03 14:29:49 -08:00
|
|
|
$engine = new PhabricatorSearchApplicationSearchEngine();
|
|
|
|
$engine->setViewer($viewer);
|
|
|
|
|
|
|
|
// NOTE: This is a little weird. If we're coming from primary search, we
|
|
|
|
// load the user's first search filter and overwrite the "query" part of
|
|
|
|
// it, then send them to that result page. This is sort of odd, but lets
|
|
|
|
// users choose a default query like "Open Tasks" in a reasonable way,
|
|
|
|
// with only this piece of somewhat-sketchy code. See discussion in T4365.
|
|
|
|
|
|
|
|
if ($request->getBool('search:primary')) {
|
|
|
|
$named_queries = $engine->loadEnabledNamedQueries();
|
|
|
|
if ($named_queries) {
|
|
|
|
$named = head($named_queries);
|
|
|
|
|
|
|
|
$query_key = $named->getQueryKey();
|
|
|
|
$saved = null;
|
|
|
|
if ($engine->isBuiltinQuery($query_key)) {
|
|
|
|
$saved = $engine->buildSavedQueryFromBuiltin($query_key);
|
|
|
|
} else {
|
|
|
|
$saved = id(new PhabricatorSavedQueryQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withQueryKeys(array($query_key))
|
|
|
|
->executeOne();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($saved) {
|
|
|
|
$saved->setParameter('query', $request->getStr('query'));
|
|
|
|
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
|
|
|
try {
|
|
|
|
$saved->setID(null)->save();
|
|
|
|
} catch (AphrontQueryDuplicateKeyException $ex) {
|
|
|
|
// Ignore, this is just a repeated search.
|
|
|
|
}
|
|
|
|
unset($unguarded);
|
|
|
|
|
|
|
|
$results_uri = $engine->getQueryResultsPageURI(
|
|
|
|
$saved->getQueryKey()).'#R';
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($results_uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-03 12:52:47 -08:00
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
->setQueryKey($this->queryKey)
|
Replace "search scope" with selectable default behavior
Summary:
Fixes T4365. See discussion in D8123.
This implements the most conservative solution of approaches discussed in D8123. Basically:
- When you search in primary search, we overwrite "query" in your default (topmost) search filter, and execute that.
This doesn't implement any of the other "sticky" stuff, where the query sticks around. Maybe we'll do that eventually, but it gets messy and could be confusing. Practically, this addresses the major use case in the wild, which is to make the menu bar search mean "Open Tasks" by default.
This also removes the old, obsolete "search scope" stuff. A long time ago, searching from within Maniphest would search tasks, etc., but this was pretty weird and confusing and is no longer used, and no one complained when we got rid of it.
Test Plan: Dragged "Open Tasks" to my top search, searched for "asdf", got "asdf in open tasks" results.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: bigo, aran
Maniphest Tasks: T4365
Differential Revision: https://secure.phabricator.com/D8135
2014-02-03 14:29:49 -08:00
|
|
|
->setSearchEngine($engine)
|
2014-02-03 12:52:47 -08:00
|
|
|
->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
|
|
|
|
2011-02-14 15:34:20 -08:00
|
|
|
}
|