Add advanced search ability to paste.

Summary: Partially complete advanced search (building a form that might be right).

Test Plan: Check that form appears for advanced filter.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Differential Revision: https://secure.phabricator.com/D5807
This commit is contained in:
Bryan Cuccioli
2013-05-06 07:28:49 -07:00
committed by epriestley
parent c87ff2622b
commit e7904ed59d
5 changed files with 84 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ abstract class PhabricatorPasteController extends PhabricatorController {
if ($user->isLoggedIn()) {
$nav->addFilter('my', pht('My Pastes'));
}
$nav->addFilter('advanced', pht('Advanced Search'));
$nav->selectFilter($filter, 'all');

View File

@@ -7,24 +7,51 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
}
private $filter;
private $queryKey;
public function willProcessRequest(array $data) {
$this->filter = idx($data, 'filter');
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$saved_query = new PhabricatorSavedQuery();
if ($request->isFormPost()) {
$saved = id(new PhabricatorPasteSearchEngine())
->buildSavedQueryFromRequest($request);
if (count($saved->getParameter('authorPHIDs')) == 0) {
return id(new AphrontRedirectResponse())
->setURI('/paste/filter/advanced/');
}
return id(new AphrontRedirectResponse())
->setURI('/paste/query/'.$saved->getQueryKey().'/');
}
$nav = $this->buildSideNavView($this->filter);
$filter = $nav->getSelectedFilter();
$saved_query = new PhabricatorSavedQuery();
$engine = id(new PhabricatorPasteSearchEngine())
->setPasteSearchFilter($filter);
$saved_query = $engine->buildSavedQueryFromRequest($request);
$query = $engine->buildQueryFromSavedQuery($saved_query);
->setPasteSearchFilter($filter)
->setPasteSearchUser($request->getUser());
if ($this->queryKey !== null) {
$saved_query = id(new PhabricatorSavedQuery())->loadOneWhere(
'queryKey = %s',
$this->queryKey);
if (!$saved_query) {
return new Aphront404Response();
}
$query = id(new PhabricatorPasteSearchEngine())
->buildQueryFromSavedQuery($saved_query);
} else {
$saved_query = $engine->buildSavedQueryFromRequest($request);
$query = $engine->buildQueryFromSavedQuery($saved_query);
}
$pager = new AphrontCursorPagerView();
$pager->readFromRequest($request);
@@ -36,6 +63,14 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$list->setPager($pager);
$list->setNoDataString(pht("No results found for this query."));
if ($this->queryKey !== null || $filter == "advanced") {
$form = $engine->buildSearchForm($saved_query);
$nav->appendChild(
array(
$form
));
}
$nav->appendChild(
array(
$list,