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()!");
|
|
|
|
}
|
|
|
|
|
2013-01-30 20:24:30 +01:00
|
|
|
$content = phabricator_form(
|
2012-02-29 23:28:48 +01:00
|
|
|
$this->user,
|
|
|
|
array(
|
|
|
|
'action' => $this->uri,
|
|
|
|
'method' => 'POST',
|
|
|
|
'sigil' => 'inline-edit-form',
|
|
|
|
),
|
2013-03-09 22:52:21 +01:00
|
|
|
array(
|
|
|
|
$this->renderInputs(),
|
|
|
|
$this->renderBody(),
|
|
|
|
));
|
2013-01-30 20:24:30 +01:00
|
|
|
|
2013-11-11 18:23:23 +01:00
|
|
|
return phutil_tag('table', array(), phutil_tag(
|
|
|
|
'tr',
|
|
|
|
array('class' => 'inline-comment-splint'),
|
|
|
|
array(
|
|
|
|
phutil_tag('th', array()),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array('class' => 'left'),
|
|
|
|
$this->onRight ? null : $content),
|
|
|
|
phutil_tag('th', array()),
|
|
|
|
phutil_tag(
|
|
|
|
'td',
|
|
|
|
array('colspan' => 3, 'class' => 'right3'),
|
|
|
|
$this->onRight ? $content : null),
|
|
|
|
)));
|
2012-02-29 23:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2013-01-30 20:24:30 +01:00
|
|
|
return $out;
|
2012-02-29 23:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function renderBody() {
|
|
|
|
$buttons = array();
|
|
|
|
|
2013-01-30 20:24:30 +01:00
|
|
|
$buttons[] = phutil_tag('button', array(), 'Ready');
|
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
|
|
|
|
2013-01-30 20:24:30 +01:00
|
|
|
$title = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-inline-comment-edit-title',
|
|
|
|
),
|
|
|
|
$this->title);
|
|
|
|
|
|
|
|
$body = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-inline-comment-edit-body',
|
|
|
|
),
|
2013-02-13 23:50:15 +01:00
|
|
|
$this->renderChildren());
|
2013-01-30 20:24:30 +01:00
|
|
|
|
|
|
|
$edit = phutil_tag(
|
2013-05-10 01:09:29 +02:00
|
|
|
'div',
|
2013-01-30 20:24:30 +01:00
|
|
|
array(
|
|
|
|
'class' => 'differential-inline-comment-edit-buttons',
|
|
|
|
),
|
2013-03-09 22:52:21 +01:00
|
|
|
array(
|
|
|
|
$buttons,
|
|
|
|
phutil_tag('div', array('style' => 'clear: both'), ''),
|
|
|
|
));
|
2013-01-30 20:24:30 +01:00
|
|
|
|
|
|
|
return javelin_tag(
|
2012-03-10 01:04:25 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'differential-inline-comment-edit',
|
|
|
|
'sigil' => 'differential-inline-comment',
|
|
|
|
'meta' => array(
|
|
|
|
'on_right' => $this->onRight,
|
|
|
|
'number' => $this->number,
|
|
|
|
'length' => $this->length,
|
|
|
|
),
|
|
|
|
),
|
2013-03-09 22:52:21 +01:00
|
|
|
array(
|
|
|
|
$title,
|
|
|
|
$body,
|
|
|
|
$edit,
|
|
|
|
));
|
2012-02-29 23:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|