[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class AphrontFormTokenizerControl extends AphrontFormControl { 4 5 private $datasource; 6 private $disableBehavior; 7 private $limit; 8 private $placeholder; 9 10 public function setDatasource(PhabricatorTypeaheadDatasource $datasource) { 11 $this->datasource = $datasource; 12 return $this; 13 } 14 15 public function setDisableBehavior($disable) { 16 $this->disableBehavior = $disable; 17 return $this; 18 } 19 20 protected function getCustomControlClass() { 21 return 'aphront-form-control-tokenizer'; 22 } 23 24 public function setLimit($limit) { 25 $this->limit = $limit; 26 return $this; 27 } 28 29 public function setPlaceholder($placeholder) { 30 $this->placeholder = $placeholder; 31 return $this; 32 } 33 34 protected function renderInput() { 35 $name = $this->getName(); 36 $values = nonempty($this->getValue(), array()); 37 38 assert_instances_of($values, 'PhabricatorObjectHandle'); 39 40 if ($this->getID()) { 41 $id = $this->getID(); 42 } else { 43 $id = celerity_generate_unique_node_id(); 44 } 45 46 $placeholder = null; 47 if (!strlen($this->placeholder)) { 48 if ($this->datasource) { 49 $placeholder = $this->datasource->getPlaceholderText(); 50 } 51 } else { 52 $placeholder = $this->placeholder; 53 } 54 55 $template = new AphrontTokenizerTemplateView(); 56 $template->setName($name); 57 $template->setID($id); 58 $template->setValue($values); 59 60 $username = null; 61 if ($this->user) { 62 $username = $this->user->getUsername(); 63 } 64 65 $datasource_uri = null; 66 if ($this->datasource) { 67 $datasource_uri = $this->datasource->getDatasourceURI(); 68 } 69 70 if (!$this->disableBehavior) { 71 Javelin::initBehavior('aphront-basic-tokenizer', array( 72 'id' => $id, 73 'src' => $datasource_uri, 74 'value' => mpull($values, 'getFullName', 'getPHID'), 75 'icons' => mpull($values, 'getIcon', 'getPHID'), 76 'limit' => $this->limit, 77 'username' => $username, 78 'placeholder' => $placeholder, 79 )); 80 } 81 82 return $template->render(); 83 } 84 85 }
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 |