當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。