2012-02-29 23:28:48 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialInlineCommentEditView extends AphrontView {
|
|
|
|
|
|
|
|
private $inputs = array();
|
|
|
|
private $uri;
|
|
|
|
private $title;
|
|
|
|
private $onRight;
|
2012-03-10 01:04:25 +01:00
|
|
|
private $number;
|
|
|
|
private $length;
|
2012-02-29 23:28:48 +01:00
|
|
|
|
|
|
|
public function addHiddenInput($key, $value) {
|
|
|
|
$this->inputs[] = array($key, $value);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSubmitURI($uri) {
|
|
|
|
$this->uri = $uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTitle($title) {
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOnRight($on_right) {
|
|
|
|
$this->onRight = $on_right;
|
|
|
|
$this->addHiddenInput('on_right', $on_right);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-03-10 01:04:25 +01:00
|
|
|
public function setNumber($number) {
|
|
|
|
$this->number = $number;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLength($length) {
|
|
|
|
$this->length = $length;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-02-29 23:28:48 +01:00
|
|
|
public function render() {
|
|
|
|
if (!$this->uri) {
|
|
|
|
throw new Exception("Call setSubmitURI() before render()!");
|
|
|
|
}
|
|
|
|
if (!$this->user) {
|
|
|
|
throw new Exception("Call setUser() before render()!");
|
|
|
|
}
|
|
|
|
|
2012-05-05 02:41:06 +02:00
|
|
|
$content = phabricator_render_form(
|
2012-02-29 23:28:48 +01:00
|
|
|
$this->user,
|
|
|
|
array(
|
|
|
|
'action' => $this->uri,
|
|
|
|
'method' => 'POST',
|
|
|
|
'sigil' => 'inline-edit-form',
|
|
|
|
),
|
|
|
|
$this->renderInputs().
|
2012-05-05 02:41:06 +02:00
|
|
|
$this->renderBody());
|
2012-02-29 23:28:48 +01:00
|
|
|
|
|
|
|
if ($this->onRight) {
|
2012-12-09 01:50:44 +01:00
|
|
|
$core =
|
|
|
|
'<th></th>'.
|
|
|
|
'<td class="left"></td>'.
|
|
|
|
'<th></th>'.
|
|
|
|
'<td colspan="3" class="right3">'.$content.'</td>';
|
2012-02-29 23:28:48 +01:00
|
|
|
} else {
|
2012-12-09 01:50:44 +01:00
|
|
|
$core =
|
|
|
|
'<th></th>'.
|
|
|
|
'<td class="left">'.$content.'</td>'.
|
|
|
|
'<th></th>'.
|
|
|
|
'<td colspan="3" class="right3"></td>';
|
2012-02-29 23:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return '<table><tr class="inline-comment-splint">'.$core.'</tr></table>';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderInputs() {
|
|
|
|
$out = array();
|
|
|
|
foreach ($this->inputs as $input) {
|
|
|
|
list($name, $value) = $input;
|
2013-01-18 03:39:02 +01:00
|
|
|
$out[] = phutil_tag(
|
2012-02-29 23:28:48 +01:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => $name,
|
|
|
|
'value' => $value,
|
2013-01-18 03:39:02 +01:00
|
|
|
));
|
2012-02-29 23:28:48 +01:00
|
|
|
}
|
|
|
|
return implode('', $out);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderBody() {
|
|
|
|
$buttons = array();
|
|
|
|
|
2012-03-06 20:48:01 +01:00
|
|
|
$buttons[] = '<button>Ready</button>';
|
2013-01-25 21:57:17 +01:00
|
|
|
$buttons[] = javelin_tag(
|
2012-02-29 23:28:48 +01:00
|
|
|
'button',
|
|
|
|
array(
|
|
|
|
'sigil' => 'inline-edit-cancel',
|
|
|
|
'class' => 'grey',
|
|
|
|
),
|
2013-01-24 22:18:44 +01:00
|
|
|
pht('Cancel'));
|
2012-02-29 23:28:48 +01:00
|
|
|
|
|
|
|
$buttons = implode('', $buttons);
|
2012-07-20 23:04:28 +02:00
|
|
|
|
2013-01-18 03:57:09 +01:00
|
|
|
$formatting = phutil_tag(
|
2012-07-20 23:04:28 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => PhabricatorEnv::getDoclink(
|
|
|
|
'article/Remarkup_Reference.html'),
|
|
|
|
'tabindex' => '-1',
|
|
|
|
'target' => '_blank',
|
|
|
|
),
|
2013-01-24 22:18:44 +01:00
|
|
|
pht('Formatting Reference'));
|
2012-07-20 23:04:28 +02:00
|
|
|
|
2012-03-10 01:04:25 +01:00
|
|
|
return javelin_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-inline-comment-edit',
|
|
|
|
'sigil' => 'differential-inline-comment',
|
|
|
|
'meta' => array(
|
|
|
|
'on_right' => $this->onRight,
|
|
|
|
'number' => $this->number,
|
|
|
|
'length' => $this->length,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'<div class="differential-inline-comment-edit-title">'.
|
|
|
|
phutil_escape_html($this->title).
|
|
|
|
'</div>'.
|
|
|
|
'<div class="differential-inline-comment-edit-body">'.
|
|
|
|
$this->renderChildren().
|
|
|
|
'</div>'.
|
|
|
|
'<div class="differential-inline-comment-edit-buttons">'.
|
2012-07-20 23:04:28 +02:00
|
|
|
$formatting.
|
2012-03-10 01:04:25 +01:00
|
|
|
$buttons.
|
|
|
|
'<div style="clear: both;"></div>'.
|
|
|
|
'</div>');
|
2012-02-29 23:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|