Differential D18969 Diff 45496 src/applications/search/controller/PhabricatorApplicationSearchController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/controller/PhabricatorApplicationSearchController.php
| <?php | <?php | ||||
| final class PhabricatorApplicationSearchController | final class PhabricatorApplicationSearchController | ||||
| extends PhabricatorSearchBaseController { | extends PhabricatorSearchBaseController { | ||||
| private $searchEngine; | private $searchEngine; | ||||
| private $navigation; | private $navigation; | ||||
| private $queryKey; | private $queryKey; | ||||
| private $preface; | private $preface; | ||||
| private $activeQuery; | |||||
| public function setPreface($preface) { | public function setPreface($preface) { | ||||
| $this->preface = $preface; | $this->preface = $preface; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getPreface() { | public function getPreface() { | ||||
| return $this->preface; | return $this->preface; | ||||
| Show All 22 Lines | public function setSearchEngine( | ||||
| $this->searchEngine = $search_engine; | $this->searchEngine = $search_engine; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getSearchEngine() { | protected function getSearchEngine() { | ||||
| return $this->searchEngine; | return $this->searchEngine; | ||||
| } | } | ||||
| protected function getActiveQuery() { | |||||
| if (!$this->activeQuery) { | |||||
| throw new Exception(pht('There is no active query yet.')); | |||||
| } | |||||
| return $this->activeQuery; | |||||
| } | |||||
| protected function validateDelegatingController() { | protected function validateDelegatingController() { | ||||
| $parent = $this->getDelegatingController(); | $parent = $this->getDelegatingController(); | ||||
| if (!$parent) { | if (!$parent) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht('You must delegate to this controller, not invoke it directly.')); | pht('You must delegate to this controller, not invoke it directly.')); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | private function processSearchRequest() { | ||||
| } else { | } else { | ||||
| $saved_query = $engine->buildSavedQueryFromRequest($request); | $saved_query = $engine->buildSavedQueryFromRequest($request); | ||||
| // Save the query to generate a query key, so "Save Custom Query..." and | // Save the query to generate a query key, so "Save Custom Query..." and | ||||
| // other features like "Bulk Edit" and "Export Data" work correctly. | // other features like "Bulk Edit" and "Export Data" work correctly. | ||||
| $engine->saveQuery($saved_query); | $engine->saveQuery($saved_query); | ||||
| } | } | ||||
| $this->activeQuery = $saved_query; | |||||
| $nav->selectFilter( | $nav->selectFilter( | ||||
| 'query/'.$saved_query->getQueryKey(), | 'query/'.$saved_query->getQueryKey(), | ||||
| 'query/advanced'); | 'query/advanced'); | ||||
| $form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
| ->setUser($user) | ->setUser($user) | ||||
| ->setAction($request->getPath()); | ->setAction($request->getPath()); | ||||
| ▲ Show 20 Lines • Show All 693 Lines • ▼ Show 20 Lines | private function newBuiltinUseActions() { | ||||
| $actions = array(); | $actions = array(); | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
| $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); | $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); | ||||
| $engine = $this->getSearchEngine(); | $engine = $this->getSearchEngine(); | ||||
| $engine_class = get_class($engine); | $engine_class = get_class($engine); | ||||
| $query_key = $this->getQueryKey(); | |||||
| if (!$query_key) { | $query_key = $this->getActiveQuery()->getQueryKey(); | ||||
| $query_key = $engine->getDefaultQueryKey(); | |||||
| } | |||||
| $can_use = $engine->canUseInPanelContext(); | $can_use = $engine->canUseInPanelContext(); | ||||
| $is_installed = PhabricatorApplication::isClassInstalledForViewer( | $is_installed = PhabricatorApplication::isClassInstalledForViewer( | ||||
| 'PhabricatorDashboardApplication', | 'PhabricatorDashboardApplication', | ||||
| $viewer); | $viewer); | ||||
| if ($can_use && $is_installed) { | if ($can_use && $is_installed) { | ||||
| $actions[] = id(new PhabricatorActionView()) | $actions[] = id(new PhabricatorActionView()) | ||||
| ▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines | |||||