mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
render_tag -> tag: phabricator_form, differential inline comment
Summary: Pretty straightforward. Test Plan: Viewed inline edit on left / right and new /edit. Reviewers: vrana Reviewed By: vrana CC: aran Maniphest Tasks: T2432 Differential Revision: https://secure.phabricator.com/D4724
This commit is contained in:
parent
0a9f378594
commit
74a90999d8
3 changed files with 82 additions and 46 deletions
|
@ -1483,6 +1483,7 @@ phutil_register_library_map(array(
|
||||||
'javelin_tag' => 'infrastructure/javelin/markup.php',
|
'javelin_tag' => 'infrastructure/javelin/markup.php',
|
||||||
'phabricator_date' => 'view/viewutils.php',
|
'phabricator_date' => 'view/viewutils.php',
|
||||||
'phabricator_datetime' => 'view/viewutils.php',
|
'phabricator_datetime' => 'view/viewutils.php',
|
||||||
|
'phabricator_form' => 'infrastructure/javelin/markup.php',
|
||||||
'phabricator_format_bytes' => 'view/viewutils.php',
|
'phabricator_format_bytes' => 'view/viewutils.php',
|
||||||
'phabricator_format_local_time' => 'view/viewutils.php',
|
'phabricator_format_local_time' => 'view/viewutils.php',
|
||||||
'phabricator_format_relative_time' => 'view/viewutils.php',
|
'phabricator_format_relative_time' => 'view/viewutils.php',
|
||||||
|
@ -1492,7 +1493,6 @@ phutil_register_library_map(array(
|
||||||
'phabricator_parse_bytes' => 'view/viewutils.php',
|
'phabricator_parse_bytes' => 'view/viewutils.php',
|
||||||
'phabricator_relative_date' => 'view/viewutils.php',
|
'phabricator_relative_date' => 'view/viewutils.php',
|
||||||
'phabricator_render_form' => 'infrastructure/javelin/markup.php',
|
'phabricator_render_form' => 'infrastructure/javelin/markup.php',
|
||||||
'phabricator_render_form_magic' => 'infrastructure/javelin/markup.php',
|
|
||||||
'phabricator_time' => 'view/viewutils.php',
|
'phabricator_time' => 'view/viewutils.php',
|
||||||
'phid_get_subtype' => 'applications/phid/utils.php',
|
'phid_get_subtype' => 'applications/phid/utils.php',
|
||||||
'phid_get_type' => 'applications/phid/utils.php',
|
'phid_get_type' => 'applications/phid/utils.php',
|
||||||
|
|
|
@ -48,31 +48,30 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
||||||
throw new Exception("Call setUser() before render()!");
|
throw new Exception("Call setUser() before render()!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = phabricator_render_form(
|
$content = phabricator_form(
|
||||||
$this->user,
|
$this->user,
|
||||||
array(
|
array(
|
||||||
'action' => $this->uri,
|
'action' => $this->uri,
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'sigil' => 'inline-edit-form',
|
'sigil' => 'inline-edit-form',
|
||||||
),
|
),
|
||||||
$this->renderInputs().
|
$this->renderHTMLView(
|
||||||
$this->renderBody());
|
array(
|
||||||
|
$this->renderInputs(),
|
||||||
|
$this->renderBody(),
|
||||||
|
)));
|
||||||
|
|
||||||
if ($this->onRight) {
|
return hsprintf(
|
||||||
$core =
|
'<table>'.
|
||||||
|
'<tr class="inline-comment-splint">'.
|
||||||
'<th></th>'.
|
'<th></th>'.
|
||||||
'<td class="left"></td>'.
|
'<td class="left">%s</td>'.
|
||||||
'<th></th>'.
|
'<th></th>'.
|
||||||
'<td colspan="3" class="right3">'.$content.'</td>';
|
'<td colspan="3" class="right3">%s</td>'.
|
||||||
} else {
|
'</tr>'.
|
||||||
$core =
|
'</table>',
|
||||||
'<th></th>'.
|
$this->onRight ? null : $content,
|
||||||
'<td class="left">'.$content.'</td>'.
|
$this->onRight ? $content : null);
|
||||||
'<th></th>'.
|
|
||||||
'<td colspan="3" class="right3"></td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<table><tr class="inline-comment-splint">'.$core.'</tr></table>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderInputs() {
|
private function renderInputs() {
|
||||||
|
@ -87,13 +86,13 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return implode('', $out);
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderBody() {
|
private function renderBody() {
|
||||||
$buttons = array();
|
$buttons = array();
|
||||||
|
|
||||||
$buttons[] = '<button>Ready</button>';
|
$buttons[] = phutil_tag('button', array(), 'Ready');
|
||||||
$buttons[] = javelin_tag(
|
$buttons[] = javelin_tag(
|
||||||
'button',
|
'button',
|
||||||
array(
|
array(
|
||||||
|
@ -102,8 +101,6 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
||||||
),
|
),
|
||||||
pht('Cancel'));
|
pht('Cancel'));
|
||||||
|
|
||||||
$buttons = implode('', $buttons);
|
|
||||||
|
|
||||||
$formatting = phutil_tag(
|
$formatting = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
@ -114,7 +111,33 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
||||||
),
|
),
|
||||||
pht('Formatting Reference'));
|
pht('Formatting Reference'));
|
||||||
|
|
||||||
return javelin_render_tag(
|
$title = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'differential-inline-comment-edit-title',
|
||||||
|
),
|
||||||
|
$this->title);
|
||||||
|
|
||||||
|
$body = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'differential-inline-comment-edit-body',
|
||||||
|
),
|
||||||
|
$this->renderHTMLChildren());
|
||||||
|
|
||||||
|
$edit = phutil_tag(
|
||||||
|
'edit',
|
||||||
|
array(
|
||||||
|
'class' => 'differential-inline-comment-edit-buttons',
|
||||||
|
),
|
||||||
|
$this->renderHTMLView(
|
||||||
|
array(
|
||||||
|
$formatting,
|
||||||
|
$buttons,
|
||||||
|
phutil_tag('div', array('style' => 'clear: both'), ''),
|
||||||
|
)));
|
||||||
|
|
||||||
|
return javelin_tag(
|
||||||
'div',
|
'div',
|
||||||
array(
|
array(
|
||||||
'class' => 'differential-inline-comment-edit',
|
'class' => 'differential-inline-comment-edit',
|
||||||
|
@ -125,17 +148,12 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
||||||
'length' => $this->length,
|
'length' => $this->length,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'<div class="differential-inline-comment-edit-title">'.
|
$this->renderHTMLView(
|
||||||
phutil_escape_html($this->title).
|
array(
|
||||||
'</div>'.
|
$title,
|
||||||
'<div class="differential-inline-comment-edit-body">'.
|
$body,
|
||||||
$this->renderChildren().
|
$edit,
|
||||||
'</div>'.
|
)));
|
||||||
'<div class="differential-inline-comment-edit-buttons">'.
|
|
||||||
$formatting.
|
|
||||||
$buttons.
|
|
||||||
'<div style="clear: both;"></div>'.
|
|
||||||
'</div>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,24 +48,20 @@ function javelin_tag(
|
||||||
return phutil_tag($tag, $attributes, $content);
|
return phutil_tag($tag, $attributes, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
function phabricator_render_form(PhabricatorUser $user, $attributes, $content) {
|
function phabricator_form(PhabricatorUser $user, $attributes, $content) {
|
||||||
|
$body = array();
|
||||||
|
|
||||||
if (strcasecmp(idx($attributes, 'method'), 'POST') == 0 &&
|
if (strcasecmp(idx($attributes, 'method'), 'POST') == 0 &&
|
||||||
!preg_match('#^(https?:|//)#', idx($attributes, 'action'))) {
|
!preg_match('#^(https?:|//)#', idx($attributes, 'action'))) {
|
||||||
$content = phabricator_render_form_magic($user).$content;
|
$body[] = phutil_tag(
|
||||||
}
|
|
||||||
return javelin_render_tag('form', $attributes, $content);
|
|
||||||
}
|
|
||||||
|
|
||||||
function phabricator_render_form_magic(PhabricatorUser $user) {
|
|
||||||
return
|
|
||||||
phutil_tag(
|
|
||||||
'input',
|
'input',
|
||||||
array(
|
array(
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
'name' => AphrontRequest::getCSRFTokenName(),
|
'name' => AphrontRequest::getCSRFTokenName(),
|
||||||
'value' => $user->getCSRFToken(),
|
'value' => $user->getCSRFToken(),
|
||||||
)).
|
));
|
||||||
phutil_tag(
|
|
||||||
|
$body[] = phutil_tag(
|
||||||
'input',
|
'input',
|
||||||
array(
|
array(
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
|
@ -74,3 +70,25 @@ function phabricator_render_form_magic(PhabricatorUser $user) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_array($content)) {
|
||||||
|
$body = array_merge($body, $content);
|
||||||
|
} else {
|
||||||
|
$body[] = $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
return javelin_tag('form', $attributes, $body);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function phabricator_render_form(PhabricatorUser $user, $attributes, $content) {
|
||||||
|
if (is_array($content)) {
|
||||||
|
$content = implode('', $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = phabricator_form($user, $attributes, phutil_safe_html($content));
|
||||||
|
return $html->getHTMLContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue