[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DivinerAtomSearchEngine extends PhabricatorApplicationSearchEngine { 4 5 public function getResultTypeDescription() { 6 return pht('Documentation Atoms'); 7 } 8 9 public function getApplicationClassName() { 10 return 'PhabricatorDivinerApplication'; 11 } 12 13 public function buildSavedQueryFromRequest(AphrontRequest $request) { 14 $saved = new PhabricatorSavedQuery(); 15 16 $saved->setParameter( 17 'types', 18 $this->readListFromRequest($request, 'types')); 19 20 $saved->setParameter('name', $request->getStr('name')); 21 22 return $saved; 23 } 24 25 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 26 $query = id(new DivinerAtomQuery()); 27 28 $types = $saved->getParameter('types'); 29 if ($types) { 30 $query->withTypes($types); 31 } 32 33 $name = $saved->getParameter('name'); 34 if ($name) { 35 $query->withNameContains($name); 36 } 37 38 return $query; 39 } 40 41 public function buildSearchForm( 42 AphrontFormView $form, 43 PhabricatorSavedQuery $saved) { 44 45 $all_types = array(); 46 foreach (DivinerAtom::getAllTypes() as $type) { 47 $all_types[$type] = DivinerAtom::getAtomTypeNameString($type); 48 } 49 asort($all_types); 50 51 $types = $saved->getParameter('types', array()); 52 $types = array_fuse($types); 53 $type_control = id(new AphrontFormCheckboxControl()) 54 ->setLabel(pht('Types')); 55 foreach ($all_types as $type => $name) { 56 $type_control->addCheckbox( 57 'types[]', 58 $type, 59 $name, 60 isset($types[$type])); 61 } 62 63 $form 64 ->appendChild( 65 id(new AphrontFormTextControl()) 66 ->setLabel(pht('Name Contains')) 67 ->setName('name') 68 ->setValue($saved->getParameter('name'))) 69 ->appendChild($type_control); 70 } 71 72 protected function getURI($path) { 73 return '/diviner/'.$path; 74 } 75 76 public function getBuiltinQueryNames() { 77 return array( 78 'all' => pht('All'), 79 ); 80 } 81 82 public function buildSavedQueryFromBuiltin($query_key) { 83 $query = $this->newSavedQuery(); 84 $query->setQueryKey($query_key); 85 86 switch ($query_key) { 87 case 'all': 88 return $query; 89 } 90 91 return parent::buildSavedQueryFromBuiltin($query_key); 92 } 93 94 protected function renderResultList( 95 array $symbols, 96 PhabricatorSavedQuery $query, 97 array $handles) { 98 99 assert_instances_of($symbols, 'DivinerLiveSymbol'); 100 101 $viewer = $this->requireViewer(); 102 103 $list = id(new PHUIObjectItemListView()) 104 ->setUser($viewer); 105 106 foreach ($symbols as $symbol) { 107 $type = $symbol->getType(); 108 $type_name = DivinerAtom::getAtomTypeNameString($type); 109 110 $item = id(new PHUIObjectItemView()) 111 ->setHeader($symbol->getTitle()) 112 ->setHref($symbol->getURI()) 113 ->addAttribute($symbol->getSummary()) 114 ->addIcon('none', $type_name); 115 116 $list->addItem($item); 117 } 118 119 return $list; 120 } 121 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |