Changeset View
Changeset View
Standalone View
Standalone View
src/view/control/AphrontTokenizerTemplateView.php
| <?php | <?php | ||||
| final class AphrontTokenizerTemplateView extends AphrontView { | final class AphrontTokenizerTemplateView extends AphrontView { | ||||
| private $value; | private $value; | ||||
| private $name; | private $name; | ||||
| private $id; | private $id; | ||||
| private $browseURI; | private $browseURI; | ||||
| private $originalValue; | |||||
| public function setBrowseURI($browse_uri) { | public function setBrowseURI($browse_uri) { | ||||
| $this->browseURI = $browse_uri; | $this->browseURI = $browse_uri; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setID($id) { | public function setID($id) { | ||||
| $this->id = $id; | $this->id = $id; | ||||
| Show All 14 Lines | public function setName($name) { | ||||
| $this->name = $name; | $this->name = $name; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getName() { | public function getName() { | ||||
| return $this->name; | return $this->name; | ||||
| } | } | ||||
| public function setOriginalValue(array $original_value) { | |||||
| $this->originalValue = $original_value; | |||||
| return $this; | |||||
| } | |||||
| public function getOriginalValue() { | |||||
| return $this->originalValue; | |||||
| } | |||||
| public function render() { | public function render() { | ||||
| require_celerity_resource('aphront-tokenizer-control-css'); | require_celerity_resource('aphront-tokenizer-control-css'); | ||||
| $id = $this->id; | $id = $this->id; | ||||
| $name = $this->getName(); | $name = $this->getName(); | ||||
| $tokens = nonempty($this->getValue(), array()); | $tokens = nonempty($this->getValue(), array()); | ||||
| $input = javelin_tag( | $input = javelin_tag( | ||||
| Show All 33 Lines | public function render() { | ||||
| $classes = array(); | $classes = array(); | ||||
| $classes[] = 'jx-tokenizer-frame'; | $classes[] = 'jx-tokenizer-frame'; | ||||
| if ($this->browseURI) { | if ($this->browseURI) { | ||||
| $classes[] = 'has-browse'; | $classes[] = 'has-browse'; | ||||
| } | } | ||||
| $original = array(); | |||||
| $original_value = $this->getOriginalValue(); | |||||
| if ($original_value) { | |||||
| foreach ($this->getOriginalValue() as $value) { | |||||
| $original[] = phutil_tag( | |||||
| 'input', | |||||
| array( | |||||
| 'type' => 'hidden', | |||||
| 'name' => $name.'.original[]', | |||||
| 'value' => $value, | |||||
| )); | |||||
| } | |||||
| } | |||||
| $frame = javelin_tag( | $frame = javelin_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => implode(' ', $classes), | 'class' => implode(' ', $classes), | ||||
| 'sigil' => 'tokenizer-frame', | 'sigil' => 'tokenizer-frame', | ||||
| ), | ), | ||||
| array( | array( | ||||
| $container, | $container, | ||||
| $browse, | $browse, | ||||
| $original, | |||||
| )); | )); | ||||
| return $frame; | return $frame; | ||||
| } | } | ||||
| } | } | ||||