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


PHP PhabricatorMarkupEngine::newDifferentialMarkupEngine方法代码示例

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


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

示例1: renderValueForRevisionView

 public function renderValueForRevisionView()
 {
     $diff = $this->getDiff();
     $ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff);
     $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
     $postponed_count = 0;
     $udata = $this->getDiffProperty('arc:unit');
     $utail = null;
     if ($udata) {
         $unit_messages = array();
         foreach ($udata as $test) {
             $name = idx($test, 'name');
             $result = idx($test, 'result');
             if ($result != DifferentialUnitTestResult::RESULT_POSTPONED && $result != DifferentialUnitTestResult::RESULT_PASS) {
                 $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
                 $userdata = phutil_utf8_shorten(idx($test, 'userdata'), 512);
                 $userdata = $engine->markupText($userdata);
                 $unit_messages[] = '<li>' . '<span class="unit-result-' . phutil_escape_html($result) . '">' . phutil_escape_html(ucwords($result)) . '</span>' . ' ' . phutil_escape_html($name) . '<p>' . $userdata . '</p>' . '</li>';
             } else {
                 if ($result == DifferentialUnitTestResult::RESULT_POSTPONED) {
                     $postponed_count++;
                 }
             }
         }
         $uexcuse = $this->getUnitExcuse();
         if ($unit_messages) {
             $utail = '<div class="differential-unit-block">' . $uexcuse . '<ul>' . implode("\n", $unit_messages) . '</ul>' . '</div>';
         }
     }
     if ($postponed_count > 0 && $diff->getUnitStatus() == DifferentialUnitStatus::UNIT_POSTPONED) {
         $umsg = $postponed_count . ' ' . $umsg;
     }
     return $ustar . ' ' . $umsg . $utail;
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:34,代码来源:DifferentialUnitFieldSpecification.php

示例2: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $author_phid = $request->getUser()->getPHID();
     $action = $request->getStr('action');
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $comment = new DifferentialComment();
     $comment->setContent($request->getStr('content'));
     $comment->setAction($action);
     $comment->setAuthorPHID($author_phid);
     $handles = array($author_phid);
     $reviewers = $request->getStr('reviewers');
     if (($action == DifferentialAction::ACTION_ADDREVIEWERS || $action == DifferentialAction::ACTION_REQUEST) && $reviewers) {
         $reviewers = explode(',', $reviewers);
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_REVIEWERS => $reviewers));
         $handles = array_merge($handles, $reviewers);
     }
     $ccs = $request->getStr('ccs');
     if ($action == DifferentialAction::ACTION_ADDCCS && $ccs) {
         $ccs = explode(',', $ccs);
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_CCS => $ccs));
         $handles = array_merge($handles, $ccs);
     }
     $handles = id(new PhabricatorObjectHandleData($handles))->loadHandles();
     $view = new DifferentialRevisionCommentView();
     $view->setUser($request->getUser());
     $view->setComment($comment);
     $view->setHandles($handles);
     $view->setMarkupEngine($engine);
     $view->setPreview(true);
     $view->setTargetDiff(null);
     $draft = new PhabricatorDraft();
     $draft->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->replace();
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:35,代码来源:DifferentialCommentPreviewController.php

示例3: renderValueForRevisionView

 public function renderValueForRevisionView()
 {
     if (!$this->value) {
         return null;
     }
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     return $engine->markupText($this->value);
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:8,代码来源:DifferentialBlameRevisionFieldSpecification.php

示例4: renderValueForRevisionView

 public function renderValueForRevisionView()
 {
     $diff = $this->getDiff();
     $ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff);
     $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
     $rows = array();
     $rows[] = array('style' => 'star', 'name' => $ustar, 'value' => $umsg, 'show' => true);
     $excuse = $this->getUnitExcuse();
     if ($excuse) {
         $rows[] = array('style' => 'excuse', 'name' => 'Excuse', 'value' => nl2br(phutil_escape_html($excuse)), 'show' => true);
     }
     $show_limit = 10;
     $hidden = array();
     $udata = $this->getDiffProperty('arc:unit');
     if ($udata) {
         $sort_map = array(ArcanistUnitTestResult::RESULT_BROKEN => 0, ArcanistUnitTestResult::RESULT_FAIL => 1, ArcanistUnitTestResult::RESULT_UNSOUND => 2, ArcanistUnitTestResult::RESULT_SKIP => 3, ArcanistUnitTestResult::RESULT_POSTPONED => 4, ArcanistUnitTestResult::RESULT_PASS => 5);
         foreach ($udata as $key => $test) {
             $udata[$key]['sort'] = idx($sort_map, idx($test, 'result'));
         }
         $udata = isort($udata, 'sort');
         foreach ($udata as $test) {
             $result = idx($test, 'result');
             $default_hide = false;
             switch ($result) {
                 case ArcanistUnitTestResult::RESULT_POSTPONED:
                 case ArcanistUnitTestResult::RESULT_PASS:
                     $default_hide = true;
                     break;
             }
             if ($show_limit && !$default_hide) {
                 --$show_limit;
                 $show = true;
             } else {
                 $show = false;
                 if (empty($hidden[$result])) {
                     $hidden[$result] = 0;
                 }
                 $hidden[$result]++;
             }
             $rows[] = array('style' => $this->getResultStyle($result), 'name' => phutil_escape_html(ucwords($result)), 'value' => phutil_escape_html(idx($test, 'name')), 'show' => $show);
             $userdata = idx($test, 'userdata');
             if ($userdata) {
                 $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
                 $userdata = $engine->markupText($userdata);
                 $rows[] = array('style' => 'details', 'value' => $userdata, 'show' => false);
                 if (empty($hidden['details'])) {
                     $hidden['details'] = 0;
                 }
                 $hidden['details']++;
             }
         }
     }
     $show_string = $this->renderShowString($hidden);
     $view = new DifferentialResultsTableView();
     $view->setRows($rows);
     $view->setShowMoreString($show_string);
     return $view->render();
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:58,代码来源:DifferentialUnitFieldSpecification.php

示例5: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $author_phid = $request->getUser()->getPHID();
     $handles = id(new PhabricatorObjectHandleData(array($author_phid)))->loadHandles();
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $comment = new DifferentialComment();
     $comment->setContent($request->getStr('content'));
     $comment->setAction($request->getStr('action'));
     $comment->setAuthorPHID($author_phid);
     $view = new DifferentialRevisionCommentView();
     $view->setUser($request->getUser());
     $view->setComment($comment);
     $view->setHandles($handles);
     $view->setMarkupEngine($engine);
     $view->setPreview(true);
     $view->setTargetDiff(null);
     $draft = new PhabricatorDraft();
     $draft->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->replace();
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:21,代码来源:DifferentialCommentPreviewController.php

示例6: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $inlines = $this->loadInlineComments();
     assert_instances_of($inlines, 'PhabricatorInlineCommentInterface');
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $phids = array($user->getPHID());
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $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 = implode("\n", $views);
     return id(new AphrontAjaxResponse())->setContent($views);
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:22,代码来源:PhabricatorInlineCommentPreviewController.php

示例7: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     // TODO: This is a reasonable approximation of the feature as it exists
     // in Facebook trunk but we should probably pull filename data, sort these,
     // figure out next/prev/edit/delete, deal with out-of-date inlines, etc.
     $inlines = id(new DifferentialInlineComment())->loadAllWhere('authorPHID = %s AND revisionID = %d AND commentID IS NULL', $user->getPHID(), $this->revisionID);
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $phids = array($user->getPHID());
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $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 = implode("\n", $views);
     return id(new AphrontAjaxResponse())->setContent($views);
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:24,代码来源:DifferentialInlineCommentPreviewController.php

示例8: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $author_phid = $request->getUser()->getPHID();
     $action = $request->getStr('action');
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $comment = new DifferentialComment();
     $comment->setContent($request->getStr('content'));
     $comment->setAction($action);
     $comment->setAuthorPHID($author_phid);
     $handles = array($author_phid);
     $reviewers = $request->getStrList('reviewers');
     if (DifferentialAction::allowReviewers($action) && $reviewers) {
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_REVIEWERS => $reviewers));
         $handles = array_merge($handles, $reviewers);
     }
     $ccs = $request->getStrList('ccs');
     if ($action == DifferentialAction::ACTION_ADDCCS && $ccs) {
         $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_CCS => $ccs));
         $handles = array_merge($handles, $ccs);
     }
     $handles = $this->loadViewerHandles($handles);
     $view = new DifferentialRevisionCommentView();
     $view->setUser($request->getUser());
     $view->setComment($comment);
     $view->setHandles($handles);
     $view->setMarkupEngine($engine);
     $view->setPreview(true);
     $view->setTargetDiff(null);
     $metadata = array('reviewers' => $reviewers, 'ccs' => $ccs);
     if ($action != DifferentialAction::ACTION_COMMENT) {
         $metadata['action'] = $action;
     }
     id(new PhabricatorDraft())->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->setMetadata($metadata)->replaceOrDelete();
     return id(new AphrontAjaxResponse())->setContent($view->render());
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:36,代码来源:DifferentialCommentPreviewController.php

示例9: newMarkupEngine

 public function newMarkupEngine($field)
 {
     return PhabricatorMarkupEngine::newDifferentialMarkupEngine();
 }
开发者ID:denghp,项目名称:phabricator,代码行数:4,代码来源:PhabricatorAuditInlineComment.php

示例10: processRequest

 public function processRequest()
 {
     $drequest = $this->getDiffusionRequest();
     $request = $this->getRequest();
     $user = $request->getUser();
     $callsign = $drequest->getRepository()->getCallsign();
     $content = array();
     $content[] = $this->buildCrumbs(array('commit' => true));
     $detail_panel = new AphrontPanelView();
     $repository = $drequest->getRepository();
     $commit = $drequest->loadCommit();
     if (!$commit) {
         // TODO: Make more user-friendly.
         throw new Exception('This commit has not parsed yet.');
     }
     $commit_data = $drequest->loadCommitData();
     $is_foreign = $commit_data->getCommitDetail('foreign-svn-stub');
     if ($is_foreign) {
         $subpath = $commit_data->getCommitDetail('svn-subpath');
         $error_panel = new AphrontErrorView();
         $error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
         $error_panel->setTitle('Commit Not Tracked');
         $error_panel->setSeverity(AphrontErrorView::SEVERITY_WARNING);
         $error_panel->appendChild("This Diffusion repository is configured to track only one " . "subdirectory of the entire Subversion repository, and this commit " . "didn't affect the tracked subdirectory ('" . phutil_escape_html($subpath) . "'), so no information is available.");
         $content[] = $error_panel;
     } else {
         $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
         require_celerity_resource('diffusion-commit-view-css');
         require_celerity_resource('phabricator-remarkup-css');
         $property_table = $this->renderPropertyTable($commit, $commit_data);
         $detail_panel->appendChild('<div class="diffusion-commit-view">' . '<div class="diffusion-commit-dateline">' . 'r' . $callsign . $commit->getCommitIdentifier() . ' &middot; ' . phabricator_datetime($commit->getEpoch(), $user) . '</div>' . '<h1>Revision Detail</h1>' . '<div class="diffusion-commit-details">' . $property_table . '<hr />' . '<div class="diffusion-commit-message phabricator-remarkup">' . $engine->markupText($commit_data->getCommitMessage()) . '</div>' . '</div>' . '</div>');
         $content[] = $detail_panel;
     }
     $change_query = DiffusionPathChangeQuery::newFromDiffusionRequest($drequest);
     $changes = $change_query->loadChanges();
     $original_changes_count = count($changes);
     if ($request->getStr('show_all') !== 'true' && $original_changes_count > self::CHANGES_LIMIT) {
         $changes = array_slice($changes, 0, self::CHANGES_LIMIT);
     }
     $change_table = new DiffusionCommitChangeTableView();
     $change_table->setDiffusionRequest($drequest);
     $change_table->setPathChanges($changes);
     $count = count($changes);
     $bad_commit = null;
     if ($count == 0) {
         $bad_commit = queryfx_one(id(new PhabricatorRepository())->establishConnection('r'), 'SELECT * FROM %T WHERE fullCommitName = %s', PhabricatorRepository::TABLE_BADCOMMIT, 'r' . $callsign . $commit->getCommitIdentifier());
     }
     if ($bad_commit) {
         $error_panel = new AphrontErrorView();
         $error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
         $error_panel->setTitle('Bad Commit');
         $error_panel->appendChild(phutil_escape_html($bad_commit['description']));
         $content[] = $error_panel;
     } else {
         if ($is_foreign) {
             // Don't render anything else.
         } else {
             if (!count($changes)) {
                 $no_changes = new AphrontErrorView();
                 $no_changes->setWidth(AphrontErrorView::WIDTH_WIDE);
                 $no_changes->setSeverity(AphrontErrorView::SEVERITY_WARNING);
                 $no_changes->setTitle('Not Yet Parsed');
                 // TODO: This can also happen with weird SVN changes that don't do
                 // anything (or only alter properties?), although the real no-changes case
                 // is extremely rare and might be impossible to produce organically. We
                 // should probably write some kind of "Nothing Happened!" change into the
                 // DB once we parse these changes so we can distinguish between
                 // "not parsed yet" and "no changes".
                 $no_changes->appendChild("This commit hasn't been fully parsed yet (or doesn't affect any " . "paths).");
                 $content[] = $no_changes;
             } else {
                 $change_panel = new AphrontPanelView();
                 $change_panel->setHeader("Changes (" . number_format($count) . ")");
                 if ($count !== $original_changes_count) {
                     $show_all_button = phutil_render_tag('a', array('class' => 'button green', 'href' => '?show_all=true'), phutil_escape_html('Show All Changes'));
                     $warning_view = id(new AphrontErrorView())->setSeverity(AphrontErrorView::SEVERITY_WARNING)->setTitle(sprintf("Showing only the first %d changes out of %s!", self::CHANGES_LIMIT, number_format($original_changes_count)));
                     $change_panel->appendChild($warning_view);
                     $change_panel->addButton($show_all_button);
                 }
                 $change_panel->appendChild($change_table);
                 $content[] = $change_panel;
                 $changesets = DiffusionPathChange::convertToDifferentialChangesets($changes);
                 $vcs = $repository->getVersionControlSystem();
                 switch ($vcs) {
                     case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                         $vcs_supports_directory_changes = true;
                         break;
                     case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                         $vcs_supports_directory_changes = false;
                         break;
                     default:
                         throw new Exception("Unknown VCS.");
                 }
                 $references = array();
                 foreach ($changesets as $key => $changeset) {
                     $file_type = $changeset->getFileType();
                     if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
                         if (!$vcs_supports_directory_changes) {
                             unset($changesets[$key]);
                             continue;
//.........这里部分代码省略.........
开发者ID:hwang36,项目名称:phabricator,代码行数:101,代码来源:DiffusionCommitController.php

示例11: processRequest


//.........这里部分代码省略.........
             default:
                 return new Aphront400Response();
         }
     }
     if ($vs && $vs != -1) {
         $vs_changeset = id(new DifferentialChangeset())->load($vs);
         if (!$vs_changeset) {
             return new Aphront404Response();
         }
     }
     if (!$vs) {
         $right = $changeset;
         $left = null;
         $right_source = $right->getID();
         $right_new = true;
         $left_source = $right->getID();
         $left_new = false;
         $render_cache_key = $right->getID();
     } else {
         if ($vs == -1) {
             $right = null;
             $left = $changeset;
             $right_source = $left->getID();
             $right_new = false;
             $left_source = $left->getID();
             $left_new = true;
             $render_cache_key = null;
         } else {
             $right = $changeset;
             $left = $vs_changeset;
             $right_source = $right->getID();
             $right_new = true;
             $left_source = $left->getID();
             $left_new = true;
             $render_cache_key = null;
         }
     }
     if ($left) {
         $left->attachHunks($left->loadHunks());
     }
     if ($right) {
         $right->attachHunks($right->loadHunks());
     }
     if ($left) {
         $left_data = $left->makeNewFile();
         if ($right) {
             $right_data = $right->makeNewFile();
         } else {
             $right_data = $left->makeOldFile();
         }
         $engine = new PhabricatorDifferenceEngine();
         $synthetic = $engine->generateChangesetFromFileContent($left_data, $right_data);
         $choice = nonempty($left, $right);
         $choice->attachHunks($synthetic->getHunks());
         $changeset = $choice;
         $changeset->setID(null);
     }
     $spec = $request->getStr('range');
     list($range_s, $range_e, $mask) = DifferentialChangesetParser::parseRangeSpecification($spec);
     $parser = new DifferentialChangesetParser();
     $parser->setChangeset($changeset);
     $parser->setRenderingReference($rendering_reference);
     $parser->setRenderCacheKey($render_cache_key);
     $parser->setRightSideCommentMapping($right_source, $right_new);
     $parser->setLeftSideCommentMapping($left_source, $left_new);
     $parser->setWhitespaceMode($request->getStr('whitespace'));
     // Load both left-side and right-side inline comments.
     $inlines = $this->loadInlineComments(array($left_source, $right_source), $author_phid);
     $phids = array();
     foreach ($inlines as $inline) {
         $parser->parseInlineComment($inline);
         $phids[$inline->getAuthorPHID()] = true;
     }
     $phids = array_keys($phids);
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $parser->setHandles($handles);
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $parser->setMarkupEngine($engine);
     if ($request->isAjax()) {
         // TODO: This is sort of lazy, the effect is just to not render "Edit"
         // links on the "standalone view".
         $parser->setUser($request->getUser());
     }
     $output = $parser->render($range_s, $range_e, $mask);
     if ($request->isAjax()) {
         return id(new AphrontAjaxResponse())->setContent($output);
     }
     Javelin::initBehavior('differential-show-more', array('uri' => '/differential/changeset/', 'whitespace' => $request->getStr('whitespace')));
     Javelin::initBehavior('differential-comment-jump', array());
     $detail = new DifferentialChangesetDetailView();
     $detail->setChangeset($changeset);
     $detail->appendChild($output);
     if (!$vs) {
         $detail->addButton(phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('view', 'old'), 'class' => 'grey button small'), 'View Raw File (Old Version)'));
         $detail->addButton(phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('view', 'new'), 'class' => 'grey button small'), 'View Raw File (New Version)'));
     }
     $detail->setRevisionID($request->getInt('revision_id'));
     $output = id(new DifferentialPrimaryPaneView())->setLineWidthFromChangesets(array($changeset))->appendChild('<div class="differential-review-stage" ' . 'id="differential-review-stage">' . $detail->render() . '</div>');
     return $this->buildStandardPageResponse(array($output), array('title' => 'Changeset View'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:101,代码来源:DifferentialChangesetViewController.php

示例12: processRequest


//.........这里部分代码省略.........
             $right = $changeset;
             $left = $vs_changeset;
             $right_source = $right->getID();
             $right_new = true;
             $left_source = $left->getID();
             $left_new = true;
             $render_cache_key = null;
         }
     }
     if ($left) {
         $left->attachHunks($left->loadHunks());
     }
     if ($right) {
         $right->attachHunks($right->loadHunks());
     }
     if ($left) {
         $left_data = $left->makeNewFile();
         if ($right) {
             $right_data = $right->makeNewFile();
         } else {
             $right_data = $left->makeOldFile();
         }
         $engine = new PhabricatorDifferenceEngine();
         $synthetic = $engine->generateChangesetFromFileContent($left_data, $right_data);
         $choice = clone nonempty($left, $right);
         $choice->attachHunks($synthetic->getHunks());
         $changeset = $choice;
     }
     $coverage = null;
     if ($right && $right->getDiffID()) {
         $unit = id(new DifferentialDiffProperty())->loadOneWhere('diffID = %d AND name = %s', $right->getDiffID(), 'arc:unit');
         if ($unit) {
             $coverage = array();
             foreach ($unit->getData() as $result) {
                 $result_coverage = idx($result, 'coverage');
                 if (!$result_coverage) {
                     continue;
                 }
                 $file_coverage = idx($result_coverage, $right->getFileName());
                 if (!$file_coverage) {
                     continue;
                 }
                 $coverage[] = $file_coverage;
             }
             $coverage = ArcanistUnitTestResult::mergeCoverage($coverage);
         }
     }
     $spec = $request->getStr('range');
     list($range_s, $range_e, $mask) = DifferentialChangesetParser::parseRangeSpecification($spec);
     $parser = new DifferentialChangesetParser();
     $parser->setCoverage($coverage);
     $parser->setChangeset($changeset);
     $parser->setRenderingReference($rendering_reference);
     $parser->setRenderCacheKey($render_cache_key);
     $parser->setRightSideCommentMapping($right_source, $right_new);
     $parser->setLeftSideCommentMapping($left_source, $left_new);
     $parser->setWhitespaceMode($request->getStr('whitespace'));
     if ($left && $right) {
         $parser->setOriginals($left, $right);
     }
     // Load both left-side and right-side inline comments.
     $inlines = $this->loadInlineComments(array($left_source, $right_source), $author_phid);
     if ($left_new) {
         $inlines = array_merge($inlines, $this->buildLintInlineComments($left));
     }
     if ($right_new) {
         $inlines = array_merge($inlines, $this->buildLintInlineComments($right));
     }
     $phids = array();
     foreach ($inlines as $inline) {
         $parser->parseInlineComment($inline);
         if ($inline->getAuthorPHID()) {
             $phids[$inline->getAuthorPHID()] = true;
         }
     }
     $phids = array_keys($phids);
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $parser->setHandles($handles);
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $parser->setMarkupEngine($engine);
     if ($request->isAjax()) {
         // TODO: This is sort of lazy, the effect is just to not render "Edit"
         // and "Reply" links on the "standalone view".
         $parser->setUser($request->getUser());
     }
     $output = $parser->render($range_s, $range_e, $mask);
     $mcov = $parser->renderModifiedCoverage();
     if ($request->isAjax()) {
         $coverage = array('differential-mcoverage-' . md5($changeset->getFilename()) => $mcov);
         return id(new PhabricatorChangesetResponse())->setRenderedChangeset($output)->setCoverage($coverage);
     }
     Javelin::initBehavior('differential-show-more', array('uri' => '/differential/changeset/', 'whitespace' => $request->getStr('whitespace')));
     Javelin::initBehavior('differential-comment-jump', array());
     $detail = new DifferentialChangesetDetailView();
     $detail->setChangeset($changeset);
     $detail->appendChild($output);
     $detail->setVsChangesetID($left_source);
     $output = id(new DifferentialPrimaryPaneView())->setLineWidthFromChangesets(array($changeset))->appendChild('<div class="differential-review-stage" ' . 'id="differential-review-stage">' . $detail->render() . '</div>');
     return $this->buildStandardPageResponse(array($output), array('title' => 'Changeset View'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:101,代码来源:DifferentialChangesetViewController.php

示例13: processRequest

 public function processRequest()
 {
     $drequest = $this->getDiffusionRequest();
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($request->getStr('diff')) {
         return $this->buildRawDiffResponse($drequest);
     }
     $callsign = $drequest->getRepository()->getCallsign();
     $content = array();
     $content[] = $this->buildCrumbs(array('commit' => true));
     $repository = $drequest->getRepository();
     $commit = $drequest->loadCommit();
     if (!$commit) {
         // TODO: Make more user-friendly.
         throw new Exception('This commit has not parsed yet.');
     }
     $commit_data = $drequest->loadCommitData();
     $commit->attachCommitData($commit_data);
     $is_foreign = $commit_data->getCommitDetail('foreign-svn-stub');
     if ($is_foreign) {
         $subpath = $commit_data->getCommitDetail('svn-subpath');
         $error_panel = new AphrontErrorView();
         $error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
         $error_panel->setTitle('Commit Not Tracked');
         $error_panel->setSeverity(AphrontErrorView::SEVERITY_WARNING);
         $error_panel->appendChild("This Diffusion repository is configured to track only one " . "subdirectory of the entire Subversion repository, and this commit " . "didn't affect the tracked subdirectory ('" . phutil_escape_html($subpath) . "'), so no information is available.");
         $content[] = $error_panel;
     } else {
         $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
         require_celerity_resource('diffusion-commit-view-css');
         require_celerity_resource('phabricator-remarkup-css');
         $parent_query = DiffusionCommitParentsQuery::newFromDiffusionRequest($drequest);
         $headsup_panel = new AphrontHeadsupView();
         $headsup_panel->setHeader('Commit Detail');
         $headsup_panel->setActionList($this->renderHeadsupActionList($commit));
         $headsup_panel->setProperties($this->getCommitProperties($commit, $commit_data, $parent_query->loadParents()));
         $headsup_panel->appendChild('<div class="diffusion-commit-message phabricator-remarkup">' . $engine->markupText($commit_data->getCommitMessage()) . '</div>');
         $content[] = $headsup_panel;
     }
     $query = new PhabricatorAuditQuery();
     $query->withCommitPHIDs(array($commit->getPHID()));
     $audit_requests = $query->execute();
     $this->auditAuthorityPHIDs = PhabricatorAuditCommentEditor::loadAuditPHIDsForUser($user);
     $content[] = $this->buildAuditTable($commit, $audit_requests);
     $content[] = $this->buildComments($commit);
     $change_query = DiffusionPathChangeQuery::newFromDiffusionRequest($drequest);
     $changes = $change_query->loadChanges();
     $content[] = $this->buildMergesTable($commit);
     $original_changes_count = count($changes);
     if ($request->getStr('show_all') !== 'true' && $original_changes_count > self::CHANGES_LIMIT) {
         $changes = array_slice($changes, 0, self::CHANGES_LIMIT);
     }
     $owners_paths = array();
     if ($this->highlightedAudits) {
         $packages = id(new PhabricatorOwnersPackage())->loadAllWhere('phid IN (%Ls)', mpull($this->highlightedAudits, 'getAuditorPHID'));
         if ($packages) {
             $owners_paths = id(new PhabricatorOwnersPath())->loadAllWhere('repositoryPHID = %s AND packageID IN (%Ld)', $repository->getPHID(), mpull($packages, 'getID'));
         }
     }
     $change_table = new DiffusionCommitChangeTableView();
     $change_table->setDiffusionRequest($drequest);
     $change_table->setPathChanges($changes);
     $change_table->setOwnersPaths($owners_paths);
     $count = count($changes);
     $bad_commit = null;
     if ($count == 0) {
         $bad_commit = queryfx_one(id(new PhabricatorRepository())->establishConnection('r'), 'SELECT * FROM %T WHERE fullCommitName = %s', PhabricatorRepository::TABLE_BADCOMMIT, 'r' . $callsign . $commit->getCommitIdentifier());
     }
     $pane_id = null;
     if ($bad_commit) {
         $error_panel = new AphrontErrorView();
         $error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
         $error_panel->setTitle('Bad Commit');
         $error_panel->appendChild(phutil_escape_html($bad_commit['description']));
         $content[] = $error_panel;
     } else {
         if ($is_foreign) {
             // Don't render anything else.
         } else {
             if (!count($changes)) {
                 $no_changes = new AphrontErrorView();
                 $no_changes->setWidth(AphrontErrorView::WIDTH_WIDE);
                 $no_changes->setSeverity(AphrontErrorView::SEVERITY_WARNING);
                 $no_changes->setTitle('Not Yet Parsed');
                 // TODO: This can also happen with weird SVN changes that don't do
                 // anything (or only alter properties?), although the real no-changes case
                 // is extremely rare and might be impossible to produce organically. We
                 // should probably write some kind of "Nothing Happened!" change into the
                 // DB once we parse these changes so we can distinguish between
                 // "not parsed yet" and "no changes".
                 $no_changes->appendChild("This commit hasn't been fully parsed yet (or doesn't affect any " . "paths).");
                 $content[] = $no_changes;
             } else {
                 $change_panel = new AphrontPanelView();
                 $change_panel->setHeader("Changes (" . number_format($count) . ")");
                 $change_panel->setID('differential-review-toc');
                 if ($count !== $original_changes_count) {
                     $show_all_button = phutil_render_tag('a', array('class' => 'button green', 'href' => '?show_all=true'), phutil_escape_html('Show All Changes'));
                     $warning_view = id(new AphrontErrorView())->setSeverity(AphrontErrorView::SEVERITY_WARNING)->setTitle(sprintf("Showing only the first %d changes out of %s!", self::CHANGES_LIMIT, number_format($original_changes_count)));
//.........这里部分代码省略.........
开发者ID:relrod,项目名称:phabricator,代码行数:101,代码来源:DiffusionCommitController.php

示例14: buildRenderedCommentResponse

 private function buildRenderedCommentResponse(PhabricatorInlineCommentInterface $inline, $on_right)
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     $phids = array($user->getPHID());
     $handles = $this->loadViewerHandles($phids);
     $view = new DifferentialInlineCommentView();
     $view->setInlineComment($inline);
     $view->setOnRight($on_right);
     $view->setBuildScaffolding(true);
     $view->setMarkupEngine($engine);
     $view->setHandles($handles);
     $view->setEditable(true);
     return id(new AphrontAjaxResponse())->setContent(array('inlineCommentID' => $inline->getID(), 'markup' => $view->render()));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:16,代码来源:PhabricatorInlineCommentController.php

示例15: processRequest

 public function processRequest()
 {
     $drequest = $this->getDiffusionRequest();
     $request = $this->getRequest();
     $user = $request->getUser();
     $callsign = $drequest->getRepository()->getCallsign();
     $content = array();
     $content[] = $this->buildCrumbs(array('commit' => true));
     $detail_panel = new AphrontPanelView();
     $repository = $drequest->getRepository();
     $commit = $drequest->loadCommit();
     if (!$commit) {
         // TODO: Make more user-friendly.
         throw new Exception('This commit has not parsed yet.');
     }
     $commit_data = $drequest->loadCommitData();
     $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
     require_celerity_resource('diffusion-commit-view-css');
     require_celerity_resource('phabricator-remarkup-css');
     $property_table = $this->renderPropertyTable($commit, $commit_data);
     $detail_panel->appendChild('<div class="diffusion-commit-view">' . '<div class="diffusion-commit-dateline">' . 'r' . $callsign . $commit->getCommitIdentifier() . ' &middot; ' . phabricator_datetime($commit->getEpoch(), $user) . '</div>' . '<h1>Revision Detail</h1>' . '<div class="diffusion-commit-details">' . $property_table . '<hr />' . '<div class="diffusion-commit-message phabricator-remarkup">' . $engine->markupText($commit_data->getCommitMessage()) . '</div>' . '</div>' . '</div>');
     $content[] = $detail_panel;
     $change_query = DiffusionPathChangeQuery::newFromDiffusionRequest($drequest);
     $changes = $change_query->loadChanges();
     $original_changes_count = count($changes);
     if ($request->getStr('show_all') !== 'true' && $original_changes_count > self::CHANGES_LIMIT) {
         $changes = array_slice($changes, 0, self::CHANGES_LIMIT);
     }
     $change_table = new DiffusionCommitChangeTableView();
     $change_table->setDiffusionRequest($drequest);
     $change_table->setPathChanges($changes);
     $count = count($changes);
     $bad_commit = null;
     if ($count == 0) {
         $bad_commit = queryfx_one(id(new PhabricatorRepository())->establishConnection('r'), 'SELECT * FROM %T WHERE fullCommitName = %s', PhabricatorRepository::TABLE_BADCOMMIT, 'r' . $callsign . $commit->getCommitIdentifier());
     }
     if ($bad_commit) {
         $error_panel = new AphrontErrorView();
         $error_panel->setWidth(AphrontErrorView::WIDTH_WIDE);
         $error_panel->setTitle('Bad Commit');
         $error_panel->appendChild(phutil_escape_html($bad_commit['description']));
         $content[] = $error_panel;
     } else {
         $change_panel = new AphrontPanelView();
         $change_panel->setHeader("Changes (" . number_format($count) . ")");
         if ($count !== $original_changes_count) {
             $show_all_button = phutil_render_tag('a', array('class' => 'button green', 'href' => '?show_all=true'), phutil_escape_html('Show All Changes'));
             $warning_view = id(new AphrontErrorView())->setSeverity(AphrontErrorView::SEVERITY_WARNING)->setTitle(sprintf("Showing only the first %d changes out of %s!", self::CHANGES_LIMIT, number_format($original_changes_count)));
             $change_panel->appendChild($warning_view);
             $change_panel->addButton($show_all_button);
         }
         $change_panel->appendChild($change_table);
         $content[] = $change_panel;
         if ($changes) {
             $changesets = DiffusionPathChange::convertToDifferentialChangesets($changes);
             $vcs = $repository->getVersionControlSystem();
             switch ($vcs) {
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                     $vcs_supports_directory_changes = true;
                     break;
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                     $vcs_supports_directory_changes = false;
                     break;
                 default:
                     throw new Exception("Unknown VCS.");
             }
             $references = array();
             foreach ($changesets as $key => $changeset) {
                 $file_type = $changeset->getFileType();
                 if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
                     if (!$vcs_supports_directory_changes) {
                         unset($changesets[$key]);
                         continue;
                     }
                 }
                 $branch = $drequest->getBranchURIComponent($drequest->getBranch());
                 $filename = $changeset->getFilename();
                 $commit = $drequest->getCommit();
                 $reference = "{$branch}{$filename};{$commit}";
                 $references[$key] = $reference;
             }
             $change_list = new DifferentialChangesetListView();
             $change_list->setChangesets($changesets);
             $change_list->setRenderingReferences($references);
             $change_list->setRenderURI('/diffusion/' . $callsign . '/diff/');
             // TODO: This is pretty awkward, unify the CSS between Diffusion and
             // Differential better.
             require_celerity_resource('differential-core-view-css');
             $change_list = '<div class="differential-primary-pane">' . $change_list->render() . '</div>';
         } else {
             $change_list = '<div style="margin: 2em; color: #666; padding: 1em;
         background: #eee;">' . '(no changes blah blah)' . '</div>';
         }
         $content[] = $change_list;
     }
     return $this->buildStandardPageResponse($content, array('title' => 'Diffusion'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:97,代码来源:DiffusionCommitController.php


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