user = $user; return $this; } public function setSubmitURI($uri) { $this->submitURI = $uri; return $this; } public function setTitle($title) { $this->title = $title; return $this; } public function getTitle() { return $this->title; } public function addSubmitButton($text = 'Okay') { $this->submitButton = $text; return $this; } public function addCancelButton($uri) { $this->cancelURI = $uri; return $this; } public function addHiddenInput($key, $value) { $this->hidden[$key] = $value; return $this; } public function setClass($class) { $this->class = $class; return $this; } final public function render() { require_celerity_resource('aphront-dialog-view-css'); $buttons = array(); if ($this->submitButton) { $buttons[] = phutil_render_tag( 'button', array( 'name' => '__submit__', 'sigil' => '__default__', ), phutil_escape_html($this->submitButton)); } if ($this->cancelURI) { $buttons[] = javelin_render_tag( 'a', array( 'href' => $this->cancelURI, 'class' => 'button grey', 'name' => '__cancel__', 'sigil' => 'jx-workflow-button', ), 'Cancel'); } if (!$this->user) { throw new Exception( "You must call setUser() when rendering an AphrontDialogView."); } $csrf = $this->user->getCSRFToken(); $hidden_inputs = array(); foreach ($this->hidden as $key => $value) { $hidden_inputs[] = phutil_render_tag( 'input', array( 'type' => 'hidden', 'name' => $key, 'value' => $value, )); } $hidden_inputs = implode("\n", $hidden_inputs); $more = $this->class; return javelin_render_tag( 'form', array( 'class' => 'aphront-dialog-view '.$more, 'action' => $this->submitURI, 'method' => 'post', 'sigil' => 'jx-dialog', ), ''. ''. ''. $hidden_inputs. '
'. phutil_escape_html($this->title). '
'. '
'. $this->renderChildren(). '
'. '
'. implode('', $buttons). '
'. '
'); } }