[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class AphrontFormToggleButtonsControl extends AphrontFormControl { 4 5 private $baseURI; 6 private $param; 7 8 private $buttons; 9 10 public function setBaseURI(PhutilURI $uri, $param) { 11 $this->baseURI = $uri; 12 $this->param = $param; 13 return $this; 14 } 15 16 public function setButtons(array $buttons) { 17 $this->buttons = $buttons; 18 return $this; 19 } 20 21 protected function getCustomControlClass() { 22 return 'aphront-form-control-togglebuttons'; 23 } 24 25 protected function renderInput() { 26 if (!$this->baseURI) { 27 throw new Exception('Call setBaseURI() before render()!'); 28 } 29 30 $selected = $this->getValue(); 31 32 $out = array(); 33 foreach ($this->buttons as $value => $label) { 34 if ($value == $selected) { 35 $more = ' toggle-selected toggle-fixed'; 36 } else { 37 $more = null; 38 } 39 40 $out[] = phutil_tag( 41 'a', 42 array( 43 'class' => 'toggle'.$more, 44 'href' => $this->baseURI->alter($this->param, $value), 45 ), 46 $label); 47 } 48 49 return $out; 50 } 51 52 }
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 |