Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/query/DivinerAtomSearchEngine.php
| <?php | <?php | ||||
| final class DivinerAtomSearchEngine extends PhabricatorApplicationSearchEngine { | final class DivinerAtomSearchEngine extends PhabricatorApplicationSearchEngine { | ||||
| public function getResultTypeDescription() { | public function getResultTypeDescription() { | ||||
| return pht('Documentation Atoms'); | return pht('Documentation Atoms'); | ||||
| } | } | ||||
| public function getApplicationClassName() { | public function getApplicationClassName() { | ||||
| return 'PhabricatorDivinerApplication'; | return 'PhabricatorDivinerApplication'; | ||||
| } | } | ||||
| public function buildSavedQueryFromRequest(AphrontRequest $request) { | public function buildSavedQueryFromRequest(AphrontRequest $request) { | ||||
| $saved = new PhabricatorSavedQuery(); | $saved = new PhabricatorSavedQuery(); | ||||
| $saved->setParameter( | $saved->setParameter( | ||||
| 'repositoryPHIDs', | |||||
| $this->readPHIDsFromRequest($request, 'repositoryPHIDs')); | |||||
| $saved->setParameter('name', $request->getStr('name')); | |||||
| $saved->setParameter( | |||||
| 'types', | 'types', | ||||
| $this->readListFromRequest($request, 'types')); | $this->readListFromRequest($request, 'types')); | ||||
| $saved->setParameter('name', $request->getStr('name')); | |||||
| return $saved; | return $saved; | ||||
| } | } | ||||
| public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | ||||
| $query = id(new DivinerAtomQuery()); | $query = id(new DivinerAtomQuery()); | ||||
| $types = $saved->getParameter('types'); | $repository_phids = $saved->getParameter('repositoryPHIDs'); | ||||
| if ($types) { | if ($repository_phids) { | ||||
| $query->withTypes($types); | $query->withRepositoryPHIDs($repository_phids); | ||||
| } | } | ||||
| $name = $saved->getParameter('name'); | $name = $saved->getParameter('name'); | ||||
| if ($name) { | if ($name) { | ||||
| $query->withNameContains($name); | $query->withNameContains($name); | ||||
| } | } | ||||
| $types = $saved->getParameter('types'); | |||||
| if ($types) { | |||||
| $query->withTypes($types); | |||||
| } | |||||
| return $query; | return $query; | ||||
| } | } | ||||
| public function buildSearchForm( | public function buildSearchForm( | ||||
| AphrontFormView $form, | AphrontFormView $form, | ||||
| PhabricatorSavedQuery $saved) { | PhabricatorSavedQuery $saved) { | ||||
| $form->appendChild( | |||||
| id(new AphrontFormTextControl()) | |||||
| ->setLabel(pht('Name Contains')) | |||||
| ->setName('name') | |||||
| ->setValue($saved->getParameter('name'))); | |||||
| $all_types = array(); | $all_types = array(); | ||||
| foreach (DivinerAtom::getAllTypes() as $type) { | foreach (DivinerAtom::getAllTypes() as $type) { | ||||
| $all_types[$type] = DivinerAtom::getAtomTypeNameString($type); | $all_types[$type] = DivinerAtom::getAtomTypeNameString($type); | ||||
| } | } | ||||
| asort($all_types); | asort($all_types); | ||||
| $types = $saved->getParameter('types', array()); | $types = $saved->getParameter('types', array()); | ||||
| $types = array_fuse($types); | $types = array_fuse($types); | ||||
| $type_control = id(new AphrontFormCheckboxControl()) | $type_control = id(new AphrontFormCheckboxControl()) | ||||
| ->setLabel(pht('Types')); | ->setLabel(pht('Types')); | ||||
| foreach ($all_types as $type => $name) { | foreach ($all_types as $type => $name) { | ||||
| $type_control->addCheckbox( | $type_control->addCheckbox( | ||||
| 'types[]', | 'types[]', | ||||
| $type, | $type, | ||||
| $name, | $name, | ||||
| isset($types[$type])); | isset($types[$type])); | ||||
| } | } | ||||
| $form->appendChild($type_control); | |||||
| $form | $form->appendControl( | ||||
| ->appendChild( | id(new AphrontFormTokenizerControl()) | ||||
| id(new AphrontFormTextControl()) | ->setLabel(pht('Repositories')) | ||||
| ->setLabel(pht('Name Contains')) | ->setName('repositoryPHIDs') | ||||
| ->setName('name') | ->setDatasource(new DiffusionRepositoryDatasource()) | ||||
| ->setValue($saved->getParameter('name'))) | ->setValue($saved->getParameter('repositoryPHIDs'))); | ||||
| ->appendChild($type_control); | |||||
| } | } | ||||
| protected function getURI($path) { | protected function getURI($path) { | ||||
| return '/diviner/'.$path; | return '/diviner/'.$path; | ||||
| } | } | ||||
| protected function getBuiltinQueryNames() { | protected function getBuiltinQueryNames() { | ||||
| return array( | return array( | ||||
| ▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines | |||||