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


PHP PhabricatorMarkupEngine类代码示例

本文整理汇总了PHP中PhabricatorMarkupEngine的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorMarkupEngine类的具体用法?PHP PhabricatorMarkupEngine怎么用?PHP PhabricatorMarkupEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $inlines = $this->loadInlineComments();
     assert_instances_of($inlines, 'PhabricatorInlineCommentInterface');
     $engine = new PhabricatorMarkupEngine();
     $engine->setViewer($user);
     foreach ($inlines as $inline) {
         $engine->addObject($inline, PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
     }
     $engine->process();
     $phids = array($user->getPHID());
     $handles = $this->loadViewerHandles($phids);
     $views = array();
     foreach ($inlines as $inline) {
         $view = new DifferentialInlineCommentView();
         $view->setInlineComment($inline);
         $view->setMarkupEngine($engine);
         $view->setHandles($handles);
         $view->setEditable(false);
         $view->setPreview(true);
         $views[] = $view->render();
     }
     $views = phutil_implode_html("\n", $views);
     return id(new AphrontAjaxResponse())->setContent($views);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:27,代码来源:PhabricatorInlineCommentPreviewController.php

示例2: buildChangesetParser

 private function buildChangesetParser($type, $data, $file)
 {
     $parser = new ArcanistDiffParser();
     $changes = $parser->parseDiff($data);
     $diff = DifferentialDiff::newFromRawChanges($changes);
     if (count($diff->getChangesets()) !== 1) {
         throw new Exception("Expected one changeset: {$file}");
     }
     $changeset = head($diff->getChangesets());
     $engine = new PhabricatorMarkupEngine();
     $engine->setViewer(new PhabricatorUser());
     $cparser = new DifferentialChangesetParser();
     $cparser->setDisableCache(true);
     $cparser->setChangeset($changeset);
     $cparser->setMarkupEngine($engine);
     if ($type == 'one') {
         $cparser->setRenderer(new DifferentialChangesetOneUpTestRenderer());
     } else {
         if ($type == 'two') {
             $cparser->setRenderer(new DifferentialChangesetTwoUpTestRenderer());
         } else {
             throw new Exception("Unknown renderer type '{$type}'!");
         }
     }
     return $cparser;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:26,代码来源:DifferentialParseRenderTestCase.php

示例3: render

 public function render()
 {
     $old = $this->oldText;
     $new = $this->newText;
     // TODO: On mobile, or perhaps by default, we should switch to 1-up once
     // that is built.
     if (strlen($old)) {
         $old = phutil_utf8_hard_wrap($old, 80);
         $old = implode("\n", $old) . "\n";
     }
     if (strlen($new)) {
         $new = phutil_utf8_hard_wrap($new, 80);
         $new = implode("\n", $new) . "\n";
     }
     try {
         $engine = new PhabricatorDifferenceEngine();
         $changeset = $engine->generateChangesetFromFileContent($old, $new);
         $whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
         $markup_engine = new PhabricatorMarkupEngine();
         $markup_engine->setViewer($this->getUser());
         $parser = new DifferentialChangesetParser();
         $parser->setUser($this->getUser());
         $parser->setChangeset($changeset);
         $parser->setMarkupEngine($markup_engine);
         $parser->setWhitespaceMode($whitespace_mode);
         return $parser->render(0, PHP_INT_MAX, array());
     } catch (Exception $ex) {
         return $ex->getMessage();
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:30,代码来源:PhabricatorApplicationTransactionTextDiffDetailView.php

示例4: buildChangesetParsers

 private function buildChangesetParsers($type, $data, $file)
 {
     $parser = new ArcanistDiffParser();
     $changes = $parser->parseDiff($data);
     $diff = DifferentialDiff::newFromRawChanges(PhabricatorUser::getOmnipotentUser(), $changes);
     $changesets = $diff->getChangesets();
     $engine = new PhabricatorMarkupEngine();
     $engine->setViewer(new PhabricatorUser());
     $parsers = array();
     foreach ($changesets as $changeset) {
         $cparser = new DifferentialChangesetParser();
         $cparser->setUser(new PhabricatorUser());
         $cparser->setDisableCache(true);
         $cparser->setChangeset($changeset);
         $cparser->setMarkupEngine($engine);
         if ($type == 'one') {
             $cparser->setRenderer(new DifferentialChangesetOneUpTestRenderer());
         } else {
             if ($type == 'two') {
                 $cparser->setRenderer(new DifferentialChangesetTwoUpTestRenderer());
             } else {
                 throw new Exception(pht('Unknown renderer type "%s"!', $type));
             }
         }
         $parsers[] = $cparser;
     }
     return $parsers;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:28,代码来源:DifferentialParseRenderTestCase.php

示例5: buildDocument

 private function buildDocument(PhabricatorMarkupEngine $engine, LegalpadDocumentBody $body)
 {
     $view = new PHUIPropertyListView();
     $view->addClass('legalpad');
     $view->addSectionHeader(pht('Document'));
     $view->addTextContent($engine->getOutput($body, LegalpadDocumentBody::MARKUP_FIELD_TEXT));
     return $view;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:8,代码来源:LegalpadDocumentManageController.php

示例6: buildPropertyView

 private function buildPropertyView(PholioMock $mock, PhabricatorMarkupEngine $engine, PhabricatorActionListView $actions)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($mock)->setActionList($actions);
     $properties->addProperty(pht('Author'), $viewer->renderHandle($mock->getAuthorPHID()));
     $properties->addProperty(pht('Created'), phabricator_datetime($mock->getDateCreated(), $viewer));
     if ($this->getManiphestTaskPHIDs()) {
         $properties->addProperty(pht('Maniphest Tasks'), $viewer->renderHandleList($this->getManiphestTaskPHIDs()));
     }
     $properties->invokeWillRenderEvent();
     $properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
     $properties->addImageContent($engine->getOutput($mock, PholioMock::MARKUP_FIELD_DESCRIPTION));
     return $properties;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:14,代码来源:PholioMockViewController.php

示例7: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     // this means we're using "show more" on a diff of a description and
     // should thus use the rendering reference to identify the transaction
     $ref = $request->getStr('ref');
     if ($ref) {
         $this->setTransactionID($ref);
     }
     $transaction_id = $this->getTransactionID();
     $transaction = id(new ManiphestTransaction())->load($transaction_id);
     if (!$transaction) {
         return new Aphront404Response();
     }
     $transactions = array($transaction);
     $phids = array();
     foreach ($transactions as $transaction) {
         foreach ($transaction->extractPHIDs() as $phid) {
             $phids[$phid] = $phid;
         }
     }
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $engine = PhabricatorMarkupEngine::newManiphestMarkupEngine();
     $view = new ManiphestTransactionDetailView();
     $view->setTransactionGroup($transactions);
     $view->setHandles($handles);
     $view->setUser($user);
     $view->setMarkupEngine($engine);
     $view->setRenderSummaryOnly(true);
     $view->setRenderFullSummary(true);
     $view->setRangeSpecification($request->getStr('range'));
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:34,代码来源:ManiphestTaskDescriptionChangeController.php

示例8: renderPropertyViewValue

 public function renderPropertyViewValue(array $handles)
 {
     if (!strlen($this->getValue())) {
         return null;
     }
     return PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setPreserveLinebreaks(true)->setContent($this->getValue()), 'default', $this->getViewer());
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:DifferentialRevertPlanField.php

示例9: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $transaction = id(new ManiphestTransaction())->load($this->transactionID);
     if (!$transaction) {
         return new Aphront404Response();
     }
     $transactions = array($transaction);
     $phids = array();
     foreach ($transactions as $transaction) {
         foreach ($transaction->extractPHIDs() as $phid) {
             $phids[$phid] = $phid;
         }
     }
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $engine = PhabricatorMarkupEngine::newManiphestMarkupEngine();
     $view = new ManiphestTransactionDetailView();
     $view->setTransactionGroup($transactions);
     $view->setHandles($handles);
     $view->setUser($user);
     $view->setMarkupEngine($engine);
     $view->setRenderSummaryOnly(true);
     $view->setRenderFullSummary(true);
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:26,代码来源:ManiphestTaskDescriptionChangeController.php

示例10: save

 public function save()
 {
     if (!$this->viewer) {
         throw new Exception("Must set user before saving question");
     }
     if (!$this->question) {
         throw new Exception("Must set question before saving it");
     }
     $viewer = $this->viewer;
     $question = $this->question;
     $question->save();
     // search index
     $question->attachRelated();
     PhabricatorSearchPonderIndexer::indexQuestion($question);
     // subscribe author and @mentions
     $subeditor = id(new PhabricatorSubscriptionsEditor())->setObject($question)->setUser($viewer);
     $subeditor->subscribeExplicit(array($question->getAuthorPHID()));
     $content = $question->getContent();
     $at_mention_phids = PhabricatorMarkupEngine::extractPHIDsFromMentions(array($content));
     $subeditor->subscribeImplicit($at_mention_phids);
     $subeditor->save();
     if ($this->shouldEmail && $at_mention_phids) {
         id(new PonderMentionMail($question, $question, $viewer))->setToPHIDs($at_mention_phids)->send();
     }
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:25,代码来源:PonderQuestionEditor.php

示例11: buildPropertyView

 private function buildPropertyView(PhabricatorApplication $application, PhabricatorActionListView $actions)
 {
     $viewer = $this->getRequest()->getUser();
     $properties = id(new PHUIPropertyListView());
     $properties->setActionList($actions);
     $properties->addProperty(pht('Description'), $application->getShortDescription());
     if ($application->getFlavorText()) {
         $properties->addProperty(null, phutil_tag('em', array(), $application->getFlavorText()));
     }
     if ($application->isPrototype()) {
         $proto_href = PhabricatorEnv::getDoclink('User Guide: Prototype Applications');
         $learn_more = phutil_tag('a', array('href' => $proto_href, 'target' => '_blank'), pht('Learn More'));
         $properties->addProperty(pht('Prototype'), pht('This application is a prototype. %s', $learn_more));
     }
     $overview = $application->getOverview();
     if ($overview) {
         $properties->addSectionHeader(pht('Overview'), PHUIPropertyListView::ICON_SUMMARY);
         $properties->addTextContent(PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($overview), 'default', $viewer));
     }
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $application);
     $properties->addSectionHeader(pht('Policies'), 'fa-lock');
     foreach ($application->getCapabilities() as $capability) {
         $properties->addProperty($application->getCapabilityLabel($capability), idx($descriptions, $capability));
     }
     return $properties;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:26,代码来源:PhabricatorApplicationDetailViewController.php

示例12: addRemarkupSection

 public function addRemarkupSection($header, $text)
 {
     try {
         $engine = PhabricatorMarkupEngine::newMarkupEngine(array());
         $engine->setConfig('viewer', $this->getViewer());
         $engine->setMode(PhutilRemarkupEngine::MODE_TEXT);
         $styled_text = $engine->markupText($text);
         $this->addPlaintextSection($header, $styled_text);
     } catch (Exception $ex) {
         phlog($ex);
         $this->addTextSection($header, $text);
     }
     try {
         $mail_engine = PhabricatorMarkupEngine::newMarkupEngine(array());
         $mail_engine->setConfig('viewer', $this->getViewer());
         $mail_engine->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL);
         $mail_engine->setConfig('uri.base', PhabricatorEnv::getProductionURI('/'));
         $html = $mail_engine->markupText($text);
         $this->addHTMLSection($header, $html);
     } catch (Exception $ex) {
         phlog($ex);
         $this->addHTMLSection($header, $text);
     }
     return $this;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:25,代码来源:PhabricatorMetaMTAMailBody.php

示例13: appendRemarkupInstructions

 public function appendRemarkupInstructions($remarkup)
 {
     if ($this->getUser() === null) {
         throw new Exception('Call `setUser` before appending Remarkup to PHUIFormLayoutView.');
     }
     return $this->appendInstructions(PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($remarkup), 'default', $this->getUser()));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:7,代码来源:PHUIFormLayoutView.php

示例14: appendRemarkupInstructions

 public function appendRemarkupInstructions($remarkup)
 {
     if ($this->getUser() === null) {
         throw new PhutilInvalidStateException('setUser');
     }
     return $this->appendInstructions(PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($remarkup), 'default', $this->getUser()));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PHUIFormLayoutView.php

示例15: getTagContent

 protected function getTagContent()
 {
     require_celerity_resource('ponder-view-css');
     $answer = $this->answer;
     $viewer = $this->getUser();
     $author_phid = $answer->getAuthorPHID();
     $actions = $this->buildAnswerActions();
     $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIconFont('fa-bars')->setDropdownMenu($actions);
     $header = id(new PHUIHeaderView())->setUser($viewer)->setEpoch($answer->getDateCreated())->setHeader($viewer->renderHandle($author_phid))->addActionLink($action_button);
     $content = phutil_tag('div', array('class' => 'phabricator-remarkup mlt mlb msr msl'), PhabricatorMarkupEngine::renderOneObject($answer, $answer->getMarkupField(), $viewer));
     $id = $answer->getID();
     $anchor = id(new PhabricatorAnchorView())->setAnchorName("A{$id}");
     $content_id = celerity_generate_unique_node_id();
     $footer = id(new PonderFooterView())->setContentID($content_id)->setCount(count($this->transactions));
     $votes = $answer->getVoteCount();
     if ($votes) {
         $icon = id(new PHUIIconView())->setIconFont('fa-thumbs-up');
         $helpful = phutil_tag('span', array('class' => 'ponder-footer-action'), array($votes, $icon));
         $footer->addAction($helpful);
     }
     $answer_view = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($anchor)->appendChild($content)->appendChild($footer);
     $transaction_view = id(new PhabricatorApplicationTransactionView())->setUser($viewer)->setObjectPHID($answer->getPHID())->setTransactions($this->transactions)->setMarkupEngine($this->engine);
     $comment_view = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($answer->getPHID())->setShowPreview(false)->setHeaderText(pht('Answer Comment'))->setAction("/ponder/answer/comment/{$id}/")->setSubmitButtonName(pht('Comment'));
     $hidden_view = phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), array($transaction_view, $comment_view));
     return array($answer_view, $hidden_view);
 }
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:26,代码来源:PonderAnswerView.php


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