[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorDashboardPanelSearchQueryCustomField 4 extends PhabricatorStandardCustomField { 5 6 public function getFieldType() { 7 return 'search.query'; 8 } 9 10 public function shouldAppearInApplicationSearch() { 11 return false; 12 } 13 14 public function renderEditControl(array $handles) { 15 16 $engines = id(new PhutilSymbolLoader()) 17 ->setAncestorClass('PhabricatorApplicationSearchEngine') 18 ->loadObjects(); 19 20 $value = $this->getFieldValue(); 21 22 $queries = array(); 23 $seen = false; 24 foreach ($engines as $engine_class => $engine) { 25 $engine->setViewer($this->getViewer()); 26 $engine_queries = $engine->loadEnabledNamedQueries(); 27 $query_map = mpull($engine_queries, 'getQueryName', 'getQueryKey'); 28 asort($query_map); 29 30 foreach ($query_map as $key => $name) { 31 $queries[$engine_class][] = array('key' => $key, 'name' => $name); 32 if ($key == $value) { 33 $seen = true; 34 } 35 } 36 } 37 38 if (strlen($value) && !$seen) { 39 $name = pht('Custom Query ("%s")', $value); 40 } else { 41 $name = pht('(None)'); 42 } 43 44 $options = array($value => $name); 45 46 $app_control_key = $this->getFieldConfigValue('control.application'); 47 Javelin::initBehavior( 48 'dashboard-query-panel-select', 49 array( 50 'applicationID' => $this->getFieldControlID($app_control_key), 51 'queryID' => $this->getFieldControlID(), 52 'options' => $queries, 53 'value' => array( 54 'key' => strlen($value) ? $value : null, 55 'name' => $name, 56 ), 57 )); 58 59 return id(new AphrontFormSelectControl()) 60 ->setID($this->getFieldControlID()) 61 ->setLabel($this->getFieldName()) 62 ->setCaption($this->getCaption()) 63 ->setName($this->getFieldKey()) 64 ->setValue($this->getFieldValue()) 65 ->setOptions($options); 66 } 67 68 }
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 |