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


PHP DifferenceEngine::getDiffBody方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $rev1 = $this->revisionOrTitleOrId($params['fromrev'], $params['fromtitle'], $params['fromid']);
     $rev2 = $this->revisionOrTitleOrId($params['torev'], $params['totitle'], $params['toid']);
     $de = new DifferenceEngine($this->getContext(), $rev1, $rev2, null, true, false);
     $vals = array();
     if (isset($params['fromtitle'])) {
         $vals['fromtitle'] = $params['fromtitle'];
     }
     if (isset($params['fromid'])) {
         $vals['fromid'] = $params['fromid'];
     }
     $vals['fromrevid'] = $rev1;
     if (isset($params['totitle'])) {
         $vals['totitle'] = $params['totitle'];
     }
     if (isset($params['toid'])) {
         $vals['toid'] = $params['toid'];
     }
     $vals['torevid'] = $rev2;
     $difftext = $de->getDiffBody();
     if ($difftext === false) {
         $this->dieUsage('The diff cannot be retrieved. ' . 'Maybe one or both revisions do not exist or you do not have permission to view them.', 'baddiff');
     } else {
         ApiResult::setContent($vals, $difftext);
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $vals);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:29,代码来源:ApiComparePages.php

示例2: formatApi

 /**
  * Diff would format against two revisions
  */
 public function formatApi(FormatterRow $newRow, FormatterRow $oldRow, IContextSource $ctx)
 {
     $oldRes = $this->revisionViewFormatter->formatApi($oldRow, $ctx);
     $newRes = $this->revisionViewFormatter->formatApi($newRow, $ctx);
     $oldContent = $oldRow->revision->getContent('wikitext');
     $newContent = $newRow->revision->getContent('wikitext');
     $differenceEngine = new \DifferenceEngine();
     $differenceEngine->setContent(new \TextContent($oldContent), new \TextContent($newContent));
     if ($oldRow->revision->isFirstRevision()) {
         $prevLink = null;
     } else {
         $prevLink = $this->urlGenerator->diffLink($oldRow->revision, $ctx->getTitle(), UUID::create($oldRes['workflowId']))->getLocalURL();
     }
     // this is probably a network request which typically goes in the query
     // half, but we don't have to worry about batching because we only show
     // one diff at a time so just do it.
     $nextRevision = $newRow->revision->getCollection()->getNextRevision($newRow->revision);
     if ($nextRevision === null) {
         $nextLink = null;
     } else {
         $nextLink = $this->urlGenerator->diffLink($nextRevision, $ctx->getTitle(), UUID::create($newRes['workflowId']))->getLocalURL();
     }
     return array('new' => $newRes, 'old' => $oldRes, 'diff_content' => $differenceEngine->getDiffBody(), 'links' => array('previous' => $prevLink, 'next' => $nextLink));
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:27,代码来源:RevisionDiffViewFormatter.php

示例3: getTopDiffToggle

 /**
  * Get collapsible diff-to-stable html to add to the review notice as needed
  * @param FlaggedRevision $srev, stable version
  * @param bool $quality, revision is quality
  * @return string, the html line (either "" or "<diff toggle><diff div>")
  */
 protected function getTopDiffToggle(FlaggedRevision $srev, $quality)
 {
     $reqUser = $this->getUser();
     $this->load();
     if (!$reqUser->getBoolOption('flaggedrevsviewdiffs')) {
         return false;
         // nothing to do here
     }
     # Diff should only show for the draft
     $oldid = $this->getOldIDFromRequest();
     $latest = $this->article->getLatest();
     if ($oldid && $oldid != $latest) {
         return false;
         // not viewing the draft
     }
     $revsSince = $this->article->getPendingRevCount();
     if (!$revsSince) {
         return false;
         // no pending changes
     }
     $title = $this->article->getTitle();
     // convenience
     # Review status of left diff revision...
     $leftNote = $quality ? 'revreview-hist-quality' : 'revreview-hist-basic';
     $lClass = FlaggedRevsXML::getQualityColor((int) $quality);
     $leftNote = "<span class='{$lClass}'>[" . wfMsgHtml($leftNote) . "]</span>";
     # Review status of right diff revision...
     $rClass = FlaggedRevsXML::getQualityColor(false);
     $rightNote = "<span class='{$rClass}'>[" . wfMsgHtml('revreview-hist-pending') . "]</span>";
     # Get the actual body of the diff...
     $diffEngine = new DifferenceEngine($title, $srev->getRevId(), $latest);
     $diffBody = $diffEngine->getDiffBody();
     if (strlen($diffBody) > 0) {
         $nEdits = $revsSince - 1;
         // full diff-to-stable, no need for query
         if ($nEdits) {
             $limit = 100;
             $nUsers = $title->countAuthorsBetween($srev->getRevId(), $latest, $limit);
             $multiNotice = DifferenceEngine::intermediateEditsMsg($nEdits, $nUsers, $limit);
         } else {
             $multiNotice = '';
         }
         $diffEngine->showDiffStyle();
         // add CSS
         $this->isDiffFromStable = true;
         // alter default review form tags
         return FlaggedRevsXML::diffToggle() . "<div id='mw-fr-stablediff'>\n" . self::getFormattedDiff($diffBody, $multiNotice, $leftNote, $rightNote) . "</div>\n";
     }
     return '';
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:56,代码来源:FlaggablePageView.php

示例4: extractRowInfo


//.........这里部分代码省略.........
             $vals['sha1'] = wfBaseConvert($revision->getSha1(), 36, 16, 40);
         } else {
             $vals['sha1'] = '';
         }
     }
     if ($this->fld_comment || $this->fld_parsedcomment) {
         if ($revision->isDeleted(Revision::DELETED_COMMENT)) {
             $vals['commenthidden'] = '';
         } else {
             $comment = $revision->getComment();
             if ($this->fld_comment) {
                 $vals['comment'] = $comment;
             }
             if ($this->fld_parsedcomment) {
                 $vals['parsedcomment'] = Linker::formatComment($comment, $title);
             }
         }
     }
     if ($this->fld_tags) {
         if ($row->ts_tags) {
             $tags = explode(',', $row->ts_tags);
             $this->getResult()->setIndexedTagName($tags, 'tag');
             $vals['tags'] = $tags;
         } else {
             $vals['tags'] = array();
         }
     }
     if (!is_null($this->token)) {
         $tokenFunctions = $this->getTokenFunctions();
         foreach ($this->token as $t) {
             $val = call_user_func($tokenFunctions[$t], $title->getArticleID(), $title, $revision);
             if ($val === false) {
                 $this->setWarning("Action '{$t}' is not allowed for the current user");
             } else {
                 $vals[$t . 'token'] = $val;
             }
         }
     }
     $text = null;
     global $wgParser;
     if ($this->fld_content || !is_null($this->difftotext)) {
         $text = $revision->getText();
         // Expand templates after getting section content because
         // template-added sections don't count and Parser::preprocess()
         // will have less input
         if ($this->section !== false) {
             $text = $wgParser->getSection($text, $this->section, false);
             if ($text === false) {
                 $this->dieUsage("There is no section {$this->section} in r" . $revision->getId(), 'nosuchsection');
             }
         }
     }
     if ($this->fld_content && !$revision->isDeleted(Revision::DELETED_TEXT)) {
         if ($this->generateXML) {
             $wgParser->startExternalParse($title, ParserOptions::newFromContext($this->getContext()), OT_PREPROCESS);
             $dom = $wgParser->preprocessToDom($text);
             if (is_callable(array($dom, 'saveXML'))) {
                 $xml = $dom->saveXML();
             } else {
                 $xml = $dom->__toString();
             }
             $vals['parsetree'] = $xml;
         }
         if ($this->expandTemplates && !$this->parseContent) {
             $text = $wgParser->preprocess($text, $title, ParserOptions::newFromContext($this->getContext()));
         }
         if ($this->parseContent) {
             $text = $wgParser->parse($text, $title, ParserOptions::newFromContext($this->getContext()))->getText();
         }
         ApiResult::setContent($vals, $text);
     } elseif ($this->fld_content) {
         $vals['texthidden'] = '';
     }
     if (!is_null($this->diffto) || !is_null($this->difftotext)) {
         global $wgAPIMaxUncachedDiffs;
         static $n = 0;
         // Number of uncached diffs we've had
         if ($n < $wgAPIMaxUncachedDiffs) {
             $vals['diff'] = array();
             $context = new DerivativeContext($this->getContext());
             $context->setTitle($title);
             if (!is_null($this->difftotext)) {
                 $engine = new DifferenceEngine($context);
                 $engine->setText($text, $this->difftotext);
             } else {
                 $engine = new DifferenceEngine($context, $revision->getID(), $this->diffto);
                 $vals['diff']['from'] = $engine->getOldid();
                 $vals['diff']['to'] = $engine->getNewid();
             }
             $difftext = $engine->getDiffBody();
             ApiResult::setContent($vals['diff'], $difftext);
             if (!$engine->wasCacheHit()) {
                 $n++;
             }
         } else {
             $vals['diff']['notcached'] = '';
         }
     }
     return $vals;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:ApiQueryRevisions.php

示例5: getNotificationDiffHtml

    public static function getNotificationDiffHtml($oldRevId, $revId)
    {
        $oldRevisionObj = Revision::newFromId($oldRevId);
        $newRevisionObj = Revision::newFromId($revId);
        if ($oldRevisionObj->getTitle() != $newRevisionObj->getTitle()) {
            return '<span class="error">' . htmlspecialchars(wfMsg('notificator-revs-not-from-same-title')) . '</span>';
        }
        $titleObj = $oldRevisionObj->getTitle();
        $differenceEngineObj = new DifferenceEngine($titleObj, $oldRevId, $revId);
        $notificationDiffHtml = '<style media="screen" type="text/css">' . file_get_contents(dirname(__FILE__) . '/diff-in-mail.css') . '</style><table class="diff">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
' . $differenceEngineObj->getDiffBody() . '
</table>';
        return $notificationDiffHtml;
    }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:18,代码来源:Notificator.body.php


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