当前位置: 首页>>代码示例>>PHP>>正文


PHP AphrontFormView::setViewer方法代码示例

本文整理汇总了PHP中AphrontFormView::setViewer方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontFormView::setViewer方法的具体用法?PHP AphrontFormView::setViewer怎么用?PHP AphrontFormView::setViewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AphrontFormView的用法示例。


在下文中一共展示了AphrontFormView::setViewer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render()
 {
     $question = $this->question;
     $viewer = $this->getViewer();
     $authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
     if (isset($authors[$viewer->getPHID()])) {
         $view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Already Answered'))->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.'));
         return phutil_tag_div('ponder-add-answer-view', $view);
     }
     $info_panel = null;
     if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
         $info_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This question has been marked as closed,
          but you can still leave a new answer.'));
     }
     $box_style = null;
     $header = id(new PHUIHeaderView())->setHeader(pht('New Answer'))->addClass('ponder-add-answer-header');
     $form = new AphrontFormView();
     $form->setViewer($viewer)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setViewer($viewer))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
     if (!$viewer->isLoggedIn()) {
         $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/Q' . $question->getID());
         $form = id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Answer'))->setHref((string) $login_href));
     }
     $box = id(new PHUIObjectBoxView())->appendChild($form)->setHeaderText('Answer')->addClass('ponder-add-answer-view');
     if ($info_panel) {
         $box->setInfoView($info_panel);
     }
     return array($header, $box);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:28,代码来源:PonderAddAnswerView.php


注:本文中的AphrontFormView::setViewer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。