1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-10 19:34:51 +01:00
phorge-phorge/src/view/control/AphrontTokenizerTemplateView.php

103 lines
2.1 KiB
PHP
Raw Normal View History

2011-03-22 20:41:02 -07:00
<?php
final class AphrontTokenizerTemplateView extends AphrontView {
2011-03-22 20:41:02 -07:00
private $value;
private $name;
private $id;
private $browseURI;
public function setBrowseURI($browse_uri) {
$this->browseURI = $browse_uri;
return $this;
}
2011-03-22 20:41:02 -07:00
public function setID($id) {
$this->id = $id;
return $this;
}
public function setValue(array $value) {
assert_instances_of($value, 'PhabricatorTypeaheadTokenView');
2011-03-22 20:41:02 -07:00
$this->value = $value;
return $this;
}
public function getValue() {
return $this->value;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function getName() {
return $this->name;
}
public function render() {
require_celerity_resource('aphront-tokenizer-control-css');
$id = $this->id;
$name = $this->getName();
$tokens = nonempty($this->getValue(), array());
2011-03-22 20:41:02 -07:00
$input = javelin_tag(
2011-03-22 20:41:02 -07:00
'input',
array(
'mustcapture' => true,
'name' => $name,
'class' => 'jx-tokenizer-input',
'sigil' => 'tokenizer-input',
2011-03-22 20:41:02 -07:00
'style' => 'width: 0px;',
'disabled' => 'disabled',
'type' => 'text',
));
$content = $tokens;
$content[] = $input;
$content[] = phutil_tag('div', array('style' => 'clear: both;'), '');
$container = javelin_tag(
2011-03-22 20:41:02 -07:00
'div',
array(
'id' => $id,
'class' => 'jx-tokenizer-container',
'sigil' => 'tokenizer-container',
2011-03-22 20:41:02 -07:00
),
$content);
$icon = id(new PHUIIconView())
->setIconFont('fa-search');
$browse = id(new PHUIButtonView())
->setTag('a')
->setIcon($icon)
->addClass('tokenizer-browse-button')
->setColor(PHUIButtonView::GREY)
->addSigil('tokenizer-browse');
$classes = array();
$classes[] = 'jx-tokenizer-frame';
if ($this->browseURI) {
$classes[] = 'has-browse';
}
$frame = javelin_tag(
'div',
array(
'class' => implode(' ', $classes),
'sigil' => 'tokenizer-frame',
),
array(
$container,
$browse,
));
return $frame;
2011-03-22 20:41:02 -07:00
}
}