Changeset View
Changeset View
Standalone View
Standalone View
src/applications/ponder/controller/PonderQuestionEditController.php
| Show All 26 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| } else { | } else { | ||||
| $is_new = true; | $is_new = true; | ||||
| $question = PonderQuestion::initializeNewQuestion($viewer); | $question = PonderQuestion::initializeNewQuestion($viewer); | ||||
| $v_projects = array(); | $v_projects = array(); | ||||
| } | } | ||||
| $v_title = $question->getTitle(); | $v_title = $question->getTitle(); | ||||
| $v_content = $question->getContent(); | $v_content = $question->getContent(); | ||||
| $v_wiki = $question->getAnswerWiki(); | |||||
| $v_view = $question->getViewPolicy(); | $v_view = $question->getViewPolicy(); | ||||
| $v_space = $question->getSpacePHID(); | $v_space = $question->getSpacePHID(); | ||||
| $v_status = $question->getStatus(); | $v_status = $question->getStatus(); | ||||
| $errors = array(); | $errors = array(); | ||||
| $e_title = true; | $e_title = true; | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $v_title = $request->getStr('title'); | $v_title = $request->getStr('title'); | ||||
| $v_content = $request->getStr('content'); | $v_content = $request->getStr('content'); | ||||
| $v_wiki = $request->getStr('answerWiki'); | |||||
| $v_projects = $request->getArr('projects'); | $v_projects = $request->getArr('projects'); | ||||
| $v_view = $request->getStr('viewPolicy'); | $v_view = $request->getStr('viewPolicy'); | ||||
| $v_space = $request->getStr('spacePHID'); | $v_space = $request->getStr('spacePHID'); | ||||
| $v_status = $request->getStr('status'); | $v_status = $request->getStr('status'); | ||||
| $len = phutil_utf8_strlen($v_title); | $len = phutil_utf8_strlen($v_title); | ||||
| if ($len < 1) { | if ($len < 1) { | ||||
| $errors[] = pht('Title must not be empty.'); | $errors[] = pht('Title must not be empty.'); | ||||
| Show All 10 Lines | if ($request->isFormPost()) { | ||||
| $xactions[] = id(clone $template) | $xactions[] = id(clone $template) | ||||
| ->setTransactionType(PonderQuestionTransaction::TYPE_TITLE) | ->setTransactionType(PonderQuestionTransaction::TYPE_TITLE) | ||||
| ->setNewValue($v_title); | ->setNewValue($v_title); | ||||
| $xactions[] = id(clone $template) | $xactions[] = id(clone $template) | ||||
| ->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) | ->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) | ||||
| ->setNewValue($v_content); | ->setNewValue($v_content); | ||||
| $xactions[] = id(clone $template) | |||||
| ->setTransactionType(PonderQuestionTransaction::TYPE_ANSWERWIKI) | |||||
| ->setNewValue($v_wiki); | |||||
| if (!$is_new) { | if (!$is_new) { | ||||
| $xactions[] = id(clone $template) | $xactions[] = id(clone $template) | ||||
| ->setTransactionType(PonderQuestionTransaction::TYPE_STATUS) | ->setTransactionType(PonderQuestionTransaction::TYPE_STATUS) | ||||
| ->setNewValue($v_status); | ->setNewValue($v_status); | ||||
| } | } | ||||
| $xactions[] = id(clone $template) | $xactions[] = id(clone $template) | ||||
| ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ||||
| Show All 35 Lines | $form = id(new AphrontFormView()) | ||||
| ->setValue($v_title) | ->setValue($v_title) | ||||
| ->setError($e_title)) | ->setError($e_title)) | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new PhabricatorRemarkupControl()) | id(new PhabricatorRemarkupControl()) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ->setName('content') | ->setName('content') | ||||
| ->setID('content') | ->setID('content') | ||||
| ->setValue($v_content) | ->setValue($v_content) | ||||
| ->setLabel(pht('Description')) | ->setLabel(pht('Question Details')) | ||||
| ->setUser($viewer)) | |||||
| ->appendChild( | |||||
| id(new PhabricatorRemarkupControl()) | |||||
| ->setUser($viewer) | |||||
| ->setName('answerWiki') | |||||
| ->setID('answerWiki') | |||||
| ->setValue($v_wiki) | |||||
| ->setLabel(pht('Answer Summary')) | |||||
| ->setUser($viewer)) | ->setUser($viewer)) | ||||
| ->appendControl( | ->appendControl( | ||||
| id(new AphrontFormPolicyControl()) | id(new AphrontFormPolicyControl()) | ||||
| ->setName('viewPolicy') | ->setName('viewPolicy') | ||||
| ->setPolicyObject($question) | ->setPolicyObject($question) | ||||
| ->setSpacePHID($v_space) | ->setSpacePHID($v_space) | ||||
| ->setPolicies($policies) | ->setPolicies($policies) | ||||
| ->setValue($v_view) | ->setValue($v_view) | ||||
| Show All 21 Lines | $form->appendChild( | ||||
| ->addCancelButton($this->getApplicationURI()) | ->addCancelButton($this->getApplicationURI()) | ||||
| ->setValue(pht('Submit'))); | ->setValue(pht('Submit'))); | ||||
| $preview = id(new PHUIRemarkupPreviewPanel()) | $preview = id(new PHUIRemarkupPreviewPanel()) | ||||
| ->setHeader(pht('Question Preview')) | ->setHeader(pht('Question Preview')) | ||||
| ->setControlID('content') | ->setControlID('content') | ||||
| ->setPreviewURI($this->getApplicationURI('preview/')); | ->setPreviewURI($this->getApplicationURI('preview/')); | ||||
| $answer_preview = id(new PHUIRemarkupPreviewPanel()) | |||||
| ->setHeader(pht('Answer Summary Preview')) | |||||
| ->setControlID('answerWiki') | |||||
| ->setPreviewURI($this->getApplicationURI('preview/')); | |||||
| $crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
| $id = $question->getID(); | $id = $question->getID(); | ||||
| if ($id) { | if ($id) { | ||||
| $crumbs->addTextCrumb("Q{$id}", "/Q{$id}"); | $crumbs->addTextCrumb("Q{$id}", "/Q{$id}"); | ||||
| $crumbs->addTextCrumb(pht('Edit')); | $crumbs->addTextCrumb(pht('Edit')); | ||||
| $title = pht('Edit Question'); | $title = pht('Edit Question'); | ||||
| } else { | } else { | ||||
| $crumbs->addTextCrumb(pht('Ask Question')); | $crumbs->addTextCrumb(pht('Ask Question')); | ||||
| $title = pht('Ask New Question'); | $title = pht('Ask New Question'); | ||||
| } | } | ||||
| $form_box = id(new PHUIObjectBoxView()) | $form_box = id(new PHUIObjectBoxView()) | ||||
| ->setHeaderText($title) | ->setHeaderText($title) | ||||
| ->setFormErrors($errors) | ->setFormErrors($errors) | ||||
| ->setForm($form); | ->setForm($form); | ||||
| return $this->buildApplicationPage( | return $this->buildApplicationPage( | ||||
| array( | array( | ||||
| $crumbs, | $crumbs, | ||||
| $form_box, | $form_box, | ||||
| $preview, | $preview, | ||||
| $answer_preview, | |||||
| ), | ), | ||||
| array( | array( | ||||
| 'title' => $title, | 'title' => $title, | ||||
| )); | )); | ||||
| } | } | ||||
| } | } | ||||