diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ee0248492e..61f86eba24 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -724,6 +724,7 @@ phutil_register_library_map(array( 'PhabricatorApplicationReleeph' => 'applications/releeph/application/PhabricatorApplicationReleeph.php', 'PhabricatorApplicationReleephConfigOptions' => 'applications/releeph/config/PhabricatorApplicationReleephConfigOptions.php', 'PhabricatorApplicationRepositories' => 'applications/repository/application/PhabricatorApplicationRepositories.php', + 'PhabricatorApplicationSearchEngine' => 'applications/search/engine/PhabricatorApplicationSearchEngine.php', 'PhabricatorApplicationSettings' => 'applications/settings/application/PhabricatorApplicationSettings.php', 'PhabricatorApplicationSlowvote' => 'applications/slowvote/application/PhabricatorApplicationSlowvote.php', 'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php', @@ -1193,6 +1194,7 @@ phutil_register_library_map(array( 'PhabricatorPasteListController' => 'applications/paste/controller/PhabricatorPasteListController.php', 'PhabricatorPasteQuery' => 'applications/paste/query/PhabricatorPasteQuery.php', 'PhabricatorPasteRemarkupRule' => 'applications/paste/remarkup/PhabricatorPasteRemarkupRule.php', + 'PhabricatorPasteSearchEngine' => 'applications/paste/query/PhabricatorPasteSearchEngine.php', 'PhabricatorPasteViewController' => 'applications/paste/controller/PhabricatorPasteViewController.php', 'PhabricatorPeopleController' => 'applications/people/controller/PhabricatorPeopleController.php', 'PhabricatorPeopleEditController' => 'applications/people/controller/PhabricatorPeopleEditController.php', @@ -1297,6 +1299,7 @@ phutil_register_library_map(array( 'PhabricatorS3FileStorageEngine' => 'applications/files/engine/PhabricatorS3FileStorageEngine.php', 'PhabricatorSQLPatchList' => 'infrastructure/storage/patch/PhabricatorSQLPatchList.php', 'PhabricatorSSHWorkflow' => 'infrastructure/ssh/PhabricatorSSHWorkflow.php', + 'PhabricatorSavedQuery' => 'applications/search/storage/PhabricatorSavedQuery.php', 'PhabricatorScopedEnv' => 'infrastructure/env/PhabricatorScopedEnv.php', 'PhabricatorSearchAbstractDocument' => 'applications/search/index/PhabricatorSearchAbstractDocument.php', 'PhabricatorSearchAttachController' => 'applications/search/controller/PhabricatorSearchAttachController.php', @@ -2873,6 +2876,7 @@ phutil_register_library_map(array( 'PhabricatorPasteListController' => 'PhabricatorPasteController', 'PhabricatorPasteQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorPasteRemarkupRule' => 'PhabricatorRemarkupRuleObject', + 'PhabricatorPasteSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorPasteViewController' => 'PhabricatorPasteController', 'PhabricatorPeopleController' => 'PhabricatorController', 'PhabricatorPeopleEditController' => 'PhabricatorPeopleController', diff --git a/src/applications/paste/controller/PhabricatorPasteListController.php b/src/applications/paste/controller/PhabricatorPasteListController.php index 03d44e6313..34524ed636 100644 --- a/src/applications/paste/controller/PhabricatorPasteListController.php +++ b/src/applications/paste/controller/PhabricatorPasteListController.php @@ -16,16 +16,14 @@ final class PhabricatorPasteListController extends PhabricatorPasteController { $request = $this->getRequest(); $user = $request->getUser(); - $query = id(new PhabricatorPasteQuery()) - ->setViewer($user) - ->needContent(true); + $saved_query = new PhabricatorSavedQuery(); $nav = $this->buildSideNavView($this->filter); $filter = $nav->getSelectedFilter(); switch ($filter) { case 'my': - $query->withAuthorPHIDs(array($user->getPHID())); + $saved_query->setParameter('authorPHIDs', array($user->getPHID())); $title = pht('My Pastes'); $nodata = pht("You haven't created any Pastes yet."); break; @@ -37,7 +35,11 @@ final class PhabricatorPasteListController extends PhabricatorPasteController { $pager = new AphrontCursorPagerView(); $pager->readFromRequest($request); - $pastes = $query->executeWithCursorPager($pager); + $engine = new PhabricatorPasteSearchEngine(); + $query = $engine->buildQueryFromSavedQuery($saved_query); + $pastes = $query->setViewer($request->getUser()) + ->needContent(true) + ->executeWithCursorPager($pager); $list = $this->buildPasteList($pastes); $list->setPager($pager); diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php new file mode 100644 index 0000000000..f7a88d7c38 --- /dev/null +++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php @@ -0,0 +1,48 @@ +withIDs($saved->getParameter('ids', array())) + ->withPHIDs($saved->getParameter('phids', array())) + ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())) + ->withParentPHIDs($saved->getParameter('parentPHIDs', array())); + + return $query; + } + + /** + * Builds the search form using the request. + * + * @param PhabricatorSavedQuery The query to populate the form with. + * @return void + */ + public function buildSearchForm(PhabricatorSavedQuery $saved_query) { + } + +} diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php new file mode 100644 index 0000000000..d1dedbb2de --- /dev/null +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -0,0 +1,37 @@ + array( + 'parameters' => self::SERIALIZATION_JSON), ) + + parent::getConfiguration(); + } + + public function setParameter($key, $value) { + $this->parameters[$key] = $value; + return $this; + } + + public function getParameter($key, $default = null) { + return idx($this->parameters, $key, $default); + } +}