2011-03-22 20:41:02 -07:00
|
|
|
<?php
|
|
|
|
|
2012-03-13 16:21:04 -07:00
|
|
|
final class AphrontTokenizerTemplateView extends AphrontView {
|
2011-03-22 20:41:02 -07:00
|
|
|
|
|
|
|
private $value;
|
|
|
|
private $name;
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function setID($id) {
|
|
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setValue(array $value) {
|
|
|
|
$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();
|
|
|
|
$values = nonempty($this->getValue(), array());
|
|
|
|
|
|
|
|
$tokens = array();
|
|
|
|
foreach ($values as $key => $value) {
|
|
|
|
$tokens[] = $this->renderToken($key, $value);
|
|
|
|
}
|
|
|
|
|
2013-01-25 12:57:17 -08:00
|
|
|
$input = javelin_tag(
|
2011-03-22 20:41:02 -07:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'mustcapture' => true,
|
|
|
|
'name' => $name,
|
|
|
|
'class' => 'jx-tokenizer-input',
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-03 15:11:55 -07:00
|
|
|
'sigil' => 'tokenizer-input',
|
2011-03-22 20:41:02 -07:00
|
|
|
'style' => 'width: 0px;',
|
|
|
|
'disabled' => 'disabled',
|
|
|
|
'type' => 'text',
|
|
|
|
));
|
|
|
|
|
2013-01-18 00:32:58 -08:00
|
|
|
$content = $tokens;
|
|
|
|
$content[] = $input;
|
|
|
|
$content[] = phutil_tag('div', array('style' => 'clear: both;'), '');
|
|
|
|
|
|
|
|
return phutil_tag(
|
2011-03-22 20:41:02 -07:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $id,
|
|
|
|
'class' => 'jx-tokenizer-container',
|
|
|
|
),
|
2013-01-18 00:32:58 -08:00
|
|
|
$content);
|
2011-03-22 20:41:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private function renderToken($key, $value) {
|
|
|
|
$input_name = $this->getName();
|
|
|
|
if ($input_name) {
|
|
|
|
$input_name .= '[]';
|
|
|
|
}
|
2013-01-18 00:32:58 -08:00
|
|
|
return phutil_tag(
|
2011-03-22 20:41:02 -07:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => 'jx-tokenizer-token',
|
|
|
|
),
|
2013-01-18 00:32:58 -08:00
|
|
|
array(
|
|
|
|
$value,
|
|
|
|
phutil_tag(
|
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => $input_name,
|
|
|
|
'value' => $key,
|
2013-02-06 14:49:34 -08:00
|
|
|
)),
|
2013-01-18 00:32:58 -08:00
|
|
|
phutil_tag('span', array('class' => 'jx-tokenizer-x-placeholder'), ''),
|
|
|
|
));
|
2011-03-22 20:41:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|