[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DifferentialInlineCommentEditView extends AphrontView { 4 5 private $inputs = array(); 6 private $uri; 7 private $title; 8 private $onRight; 9 private $number; 10 private $length; 11 12 public function addHiddenInput($key, $value) { 13 $this->inputs[] = array($key, $value); 14 return $this; 15 } 16 17 public function setSubmitURI($uri) { 18 $this->uri = $uri; 19 return $this; 20 } 21 22 public function setTitle($title) { 23 $this->title = $title; 24 return $this; 25 } 26 27 public function setOnRight($on_right) { 28 $this->onRight = $on_right; 29 $this->addHiddenInput('on_right', $on_right); 30 return $this; 31 } 32 33 public function setNumber($number) { 34 $this->number = $number; 35 return $this; 36 } 37 38 public function setLength($length) { 39 $this->length = $length; 40 return $this; 41 } 42 43 public function render() { 44 if (!$this->uri) { 45 throw new Exception('Call setSubmitURI() before render()!'); 46 } 47 if (!$this->user) { 48 throw new Exception('Call setUser() before render()!'); 49 } 50 51 $content = phabricator_form( 52 $this->user, 53 array( 54 'action' => $this->uri, 55 'method' => 'POST', 56 'sigil' => 'inline-edit-form', 57 ), 58 array( 59 $this->renderInputs(), 60 $this->renderBody(), 61 )); 62 63 return phutil_tag('table', array(), phutil_tag( 64 'tr', 65 array('class' => 'inline-comment-splint'), 66 array( 67 phutil_tag('th', array()), 68 phutil_tag( 69 'td', 70 array('class' => 'left'), 71 $this->onRight ? null : $content), 72 phutil_tag('th', array()), 73 phutil_tag( 74 'td', 75 array('colspan' => 3, 'class' => 'right3'), 76 $this->onRight ? $content : null), 77 ))); 78 } 79 80 private function renderInputs() { 81 $out = array(); 82 foreach ($this->inputs as $input) { 83 list($name, $value) = $input; 84 $out[] = phutil_tag( 85 'input', 86 array( 87 'type' => 'hidden', 88 'name' => $name, 89 'value' => $value, 90 )); 91 } 92 return $out; 93 } 94 95 private function renderBody() { 96 $buttons = array(); 97 98 $buttons[] = phutil_tag('button', array(), pht('Ready')); 99 $buttons[] = javelin_tag( 100 'button', 101 array( 102 'sigil' => 'inline-edit-cancel', 103 'class' => 'grey', 104 ), 105 pht('Cancel')); 106 107 $title = phutil_tag( 108 'div', 109 array( 110 'class' => 'differential-inline-comment-edit-title', 111 ), 112 $this->title); 113 114 $body = phutil_tag( 115 'div', 116 array( 117 'class' => 'differential-inline-comment-edit-body', 118 ), 119 $this->renderChildren()); 120 121 $edit = phutil_tag( 122 'div', 123 array( 124 'class' => 'differential-inline-comment-edit-buttons', 125 ), 126 array( 127 $buttons, 128 phutil_tag('div', array('style' => 'clear: both'), ''), 129 )); 130 131 return javelin_tag( 132 'div', 133 array( 134 'class' => 'differential-inline-comment-edit', 135 'sigil' => 'differential-inline-comment', 136 'meta' => array( 137 'on_right' => $this->onRight, 138 'number' => $this->number, 139 'length' => $this->length, 140 ), 141 ), 142 array( 143 $title, 144 $body, 145 $edit, 146 )); 147 } 148 149 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |