mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +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',
|
||||
'phabricator_date' => 'view/viewutils.php',
|
||||
'phabricator_datetime' => 'view/viewutils.php',
|
||||
'phabricator_form' => 'infrastructure/javelin/markup.php',
|
||||
'phabricator_format_bytes' => 'view/viewutils.php',
|
||||
'phabricator_format_local_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_relative_date' => 'view/viewutils.php',
|
||||
'phabricator_render_form' => 'infrastructure/javelin/markup.php',
|
||||
'phabricator_render_form_magic' => 'infrastructure/javelin/markup.php',
|
||||
'phabricator_time' => 'view/viewutils.php',
|
||||
'phid_get_subtype' => '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()!");
|
||||
}
|
||||
|
||||
$content = phabricator_render_form(
|
||||
$content = phabricator_form(
|
||||
$this->user,
|
||||
array(
|
||||
'action' => $this->uri,
|
||||
'method' => 'POST',
|
||||
'sigil' => 'inline-edit-form',
|
||||
),
|
||||
$this->renderInputs().
|
||||
$this->renderBody());
|
||||
$this->renderHTMLView(
|
||||
array(
|
||||
$this->renderInputs(),
|
||||
$this->renderBody(),
|
||||
)));
|
||||
|
||||
if ($this->onRight) {
|
||||
$core =
|
||||
'<th></th>'.
|
||||
'<td class="left"></td>'.
|
||||
'<th></th>'.
|
||||
'<td colspan="3" class="right3">'.$content.'</td>';
|
||||
} else {
|
||||
$core =
|
||||
'<th></th>'.
|
||||
'<td class="left">'.$content.'</td>'.
|
||||
'<th></th>'.
|
||||
'<td colspan="3" class="right3"></td>';
|
||||
}
|
||||
|
||||
return '<table><tr class="inline-comment-splint">'.$core.'</tr></table>';
|
||||
return hsprintf(
|
||||
'<table>'.
|
||||
'<tr class="inline-comment-splint">'.
|
||||
'<th></th>'.
|
||||
'<td class="left">%s</td>'.
|
||||
'<th></th>'.
|
||||
'<td colspan="3" class="right3">%s</td>'.
|
||||
'</tr>'.
|
||||
'</table>',
|
||||
$this->onRight ? null : $content,
|
||||
$this->onRight ? $content : null);
|
||||
}
|
||||
|
||||
private function renderInputs() {
|
||||
|
@ -87,13 +86,13 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
|||
'value' => $value,
|
||||
));
|
||||
}
|
||||
return implode('', $out);
|
||||
return $out;
|
||||
}
|
||||
|
||||
private function renderBody() {
|
||||
$buttons = array();
|
||||
|
||||
$buttons[] = '<button>Ready</button>';
|
||||
$buttons[] = phutil_tag('button', array(), 'Ready');
|
||||
$buttons[] = javelin_tag(
|
||||
'button',
|
||||
array(
|
||||
|
@ -102,8 +101,6 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
|||
),
|
||||
pht('Cancel'));
|
||||
|
||||
$buttons = implode('', $buttons);
|
||||
|
||||
$formatting = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
|
@ -114,7 +111,33 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
|||
),
|
||||
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',
|
||||
array(
|
||||
'class' => 'differential-inline-comment-edit',
|
||||
|
@ -125,17 +148,12 @@ final class DifferentialInlineCommentEditView extends AphrontView {
|
|||
'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">'.
|
||||
$formatting.
|
||||
$buttons.
|
||||
'<div style="clear: both;"></div>'.
|
||||
'</div>');
|
||||
$this->renderHTMLView(
|
||||
array(
|
||||
$title,
|
||||
$body,
|
||||
$edit,
|
||||
)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,29 +48,47 @@ function javelin_tag(
|
|||
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 &&
|
||||
!preg_match('#^(https?:|//)#', idx($attributes, 'action'))) {
|
||||
$content = phabricator_render_form_magic($user).$content;
|
||||
}
|
||||
return javelin_render_tag('form', $attributes, $content);
|
||||
}
|
||||
|
||||
function phabricator_render_form_magic(PhabricatorUser $user) {
|
||||
return
|
||||
phutil_tag(
|
||||
$body[] = phutil_tag(
|
||||
'input',
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => AphrontRequest::getCSRFTokenName(),
|
||||
'value' => $user->getCSRFToken(),
|
||||
)).
|
||||
phutil_tag(
|
||||
));
|
||||
|
||||
$body[] = phutil_tag(
|
||||
'input',
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => '__form__',
|
||||
'value' => true,
|
||||
));
|
||||
}
|
||||
|
||||
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