[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorDashboardPanelTabsCustomField 4 extends PhabricatorStandardCustomField { 5 6 public function getFieldType() { 7 return 'dashboard.tabs'; 8 } 9 10 public function shouldAppearInApplicationSearch() { 11 return false; 12 } 13 14 public function readValueFromRequest(AphrontRequest $request) { 15 $value = array(); 16 17 $names = $request->getArr($this->getFieldKey().'_name'); 18 $panels = $request->getArr($this->getFieldKey().'_panelID'); 19 foreach ($names as $idx => $name) { 20 $panel_id = idx($panels, $idx); 21 if (strlen($name) && $panel_id) { 22 $value[] = array( 23 'name' => $name, 24 'panelID' => $panel_id, 25 ); 26 } 27 } 28 29 $this->setFieldValue($value); 30 } 31 32 public function renderEditControl(array $handles) { 33 // NOTE: This includes archived panels so we don't mutate the tabs 34 // when saving a tab panel that includes archied panels. This whole UI is 35 // hopefully temporary anyway. 36 37 $panels = id(new PhabricatorDashboardPanelQuery()) 38 ->setViewer($this->getViewer()) 39 ->execute(); 40 41 $panel_map = array(); 42 foreach ($panels as $panel) { 43 $panel_map[$panel->getID()] = pht( 44 '%s %s', 45 $panel->getMonogram(), 46 $panel->getName()); 47 } 48 $panel_map = array( 49 '' => pht('(None)'), 50 ) + $panel_map; 51 52 $value = $this->getFieldValue(); 53 if (!is_array($value)) { 54 $value = array(); 55 } 56 57 $out = array(); 58 for ($ii = 1; $ii <= 6; $ii++) { 59 $tab = idx($value, ($ii - 1), array()); 60 $out[] = id(new AphrontFormTextControl()) 61 ->setName($this->getFieldKey().'_name[]') 62 ->setValue(idx($tab, 'name')) 63 ->setLabel(pht('Tab %d Name', $ii)); 64 65 $out[] = id(new AphrontFormSelectControl()) 66 ->setName($this->getFieldKey().'_panelID[]') 67 ->setValue(idx($tab, 'panelID')) 68 ->setOptions($panel_map) 69 ->setLabel(pht('Tab %d Panel', $ii)); 70 } 71 72 return $out; 73 } 74 75 }
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 |