Changeset View
Changeset View
Standalone View
Standalone View
src/view/form/control/AphrontFormTokenizerControl.php
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | protected function renderInput() { | ||||
if ($this->getID()) { | if ($this->getID()) { | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
} else { | } else { | ||||
$id = celerity_generate_unique_node_id(); | $id = celerity_generate_unique_node_id(); | ||||
} | } | ||||
$datasource = $this->datasource; | $datasource = $this->datasource; | ||||
if ($datasource) { | |||||
$datasource->setViewer($this->getUser()); | $datasource->setViewer($this->getUser()); | ||||
} | |||||
$placeholder = null; | $placeholder = null; | ||||
if (!strlen($this->placeholder)) { | if (!strlen($this->placeholder)) { | ||||
if ($datasource) { | if ($datasource) { | ||||
$placeholder = $datasource->getPlaceholderText(); | $placeholder = $datasource->getPlaceholderText(); | ||||
} | } | ||||
} else { | } else { | ||||
$placeholder = $this->placeholder; | $placeholder = $this->placeholder; | ||||
Show All 16 Lines | foreach ($values as $value) { | ||||
} | } | ||||
} | } | ||||
if (!$token) { | if (!$token) { | ||||
$name = pht('Invalid Function: %s', $value); | $name = pht('Invalid Function: %s', $value); | ||||
$token = $datasource->newInvalidToken($name); | $token = $datasource->newInvalidToken($name); | ||||
} | } | ||||
if ($token->getKey() == PhabricatorTypeaheadTokenView::KEY_INVALID) { | $type = $token->getTokenType(); | ||||
if ($type == PhabricatorTypeaheadTokenView::TYPE_INVALID) { | |||||
$token->setKey($value); | $token->setKey($value); | ||||
} | } | ||||
} | } | ||||
$token->setInputName($this->getName()); | $token->setInputName($this->getName()); | ||||
$tokens[] = $token; | $tokens[] = $token; | ||||
} | } | ||||
$template = new AphrontTokenizerTemplateView(); | $template = new AphrontTokenizerTemplateView(); | ||||
Show All 16 Lines | if ($datasource) { | ||||
$browse_uri = $datasource->getBrowseURI(); | $browse_uri = $datasource->getBrowseURI(); | ||||
if ($browse_uri) { | if ($browse_uri) { | ||||
$template->setBrowseURI($browse_uri); | $template->setBrowseURI($browse_uri); | ||||
} | } | ||||
} | } | ||||
if (!$this->disableBehavior) { | if (!$this->disableBehavior) { | ||||
Javelin::initBehavior('aphront-basic-tokenizer', array( | Javelin::initBehavior('aphront-basic-tokenizer', array( | ||||
'id' => $id, | 'id' => $id, | ||||
'src' => $datasource_uri, | 'src' => $datasource_uri, | ||||
'value' => mpull($tokens, 'getValue', 'getKey'), | 'value' => mpull($tokens, 'getValue', 'getKey'), | ||||
'icons' => mpull($tokens, 'getIcon', 'getKey'), | 'icons' => mpull($tokens, 'getIcon', 'getKey'), | ||||
'types' => mpull($tokens, 'getTokenType', 'getKey'), | |||||
'limit' => $this->limit, | 'limit' => $this->limit, | ||||
'username' => $username, | 'username' => $username, | ||||
'placeholder' => $placeholder, | 'placeholder' => $placeholder, | ||||
'browseURI' => $browse_uri, | 'browseURI' => $browse_uri, | ||||
)); | )); | ||||
} | } | ||||
return $template->render(); | return $template->render(); | ||||
} | } | ||||
Show All 26 Lines |