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


PHP Revision::getContentHandler方法代码示例

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


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

示例1: showDiff

 /**
  * Render the inline difference between two revisions
  * using InlineDiffEngine
  */
 function showDiff()
 {
     $ctx = MobileContext::singleton();
     $prevId = $this->prevRev ? $this->prevRev->getId() : 0;
     $unhide = (bool) $this->getRequest()->getVal('unhide');
     $contentHandler = $this->rev->getContentHandler();
     $de = $contentHandler->createDifferenceEngine($this->getContext(), $prevId, $this->revId);
     // HACK:
     if (get_class($de) == 'DifferenceEngine') {
         $de = new $this->diffClass($this->getContext(), $prevId, $this->revId, 0, false, $unhide);
     } else {
         $de->showDiffPage();
         return;
     }
     $this->mDiffEngine = $de;
     $diff = $de->getDiffBody();
     if (!$prevId) {
         $audience = $unhide ? Revision::FOR_THIS_USER : Revision::FOR_PUBLIC;
         $diff = '<ins>' . nl2br(htmlspecialchars($this->rev->getText($audience))) . '</ins>';
     }
     $warnings = $de->getWarningMessageText();
     if ($warnings) {
         $warnings = MobileUI::warningBox($warnings);
     }
     $this->getOutput()->addHtml($warnings . '<div id="mw-mf-minidiff">' . $diff . '</div>');
     $prev = $this->rev->getPrevious();
     $next = $this->rev->getNext();
     if ($prev || $next) {
         $history = Html::openElement('ul', array('class' => 'hlist revision-history-links'));
         if ($prev) {
             $history .= Html::openElement('li') . Html::element('a', array('href' => SpecialPage::getTitleFor('MobileDiff', $prev->getId())->getLocalUrl()), $this->msg('previousdiff')) . Html::closeElement('li');
         }
         if ($next) {
             $history .= Html::openElement('li') . Html::element('a', array('href' => SpecialPage::getTitleFor('MobileDiff', $next->getId())->getLocalUrl()), $this->msg('nextdiff')) . Html::closeElement('li');
         }
         $history .= Html::closeElement('ul');
         $this->getOutput()->addHtml($history);
     }
 }
开发者ID:felixonmars,项目名称:mediawiki-extensions-MobileFrontend,代码行数:43,代码来源:SpecialMobileDiff.php

示例2: getUndoContent

	/**
	 * Get the content that needs to be saved in order to undo all revisions
	 * between $undo and $undoafter. Revisions must belong to the same page,
	 * must exist and must not be deleted
	 * @param $undo Revision
	 * @param $undoafter Revision Must be an earlier revision than $undo
	 * @return mixed string on success, false on failure
	 * @since 1.21
	 * Before we had the Content object, this was done in getUndoText
	 */
	public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
		$handler = $undo->getContentHandler();
		return $handler->getUndoContent( $this->getRevision(), $undo, $undoafter );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:14,代码来源:WikiPage.php

示例3: showDiff

 /**
  * Build a diff display between this and the previous either deleted
  * or non-deleted edit.
  *
  * @param Revision $previousRev
  * @param Revision $currentRev
  * @return string HTML
  */
 function showDiff($previousRev, $currentRev)
 {
     $diffContext = clone $this->getContext();
     $diffContext->setTitle($currentRev->getTitle());
     $diffContext->setWikiPage(WikiPage::factory($currentRev->getTitle()));
     $diffEngine = $currentRev->getContentHandler()->createDifferenceEngine($diffContext);
     $diffEngine->showDiffStyle();
     $formattedDiff = $diffEngine->generateContentDiffBody($previousRev->getContent(Revision::FOR_THIS_USER, $this->getUser()), $currentRev->getContent(Revision::FOR_THIS_USER, $this->getUser()));
     $formattedDiff = $diffEngine->addHeader($formattedDiff, $this->diffHeader($previousRev, 'o'), $this->diffHeader($currentRev, 'n'));
     $this->getOutput()->addHTML("<div>{$formattedDiff}</div>\n");
 }
开发者ID:raymondzhangl,项目名称:mediawiki,代码行数:19,代码来源:SpecialUndelete.php

示例4: runForTitleInternal

 /**
  * @param $title Title
  * @param $revision Revision
  * @param $fname string
  * @return void
  */
 public static function runForTitleInternal(Title $title, Revision $revision, $fname)
 {
     wfProfileIn($fname);
     $content = $revision->getContent(Revision::RAW);
     if (!$content) {
         // if there is no content, pretend the content is empty
         $content = $revision->getContentHandler()->makeEmptyContent();
     }
     // Revision ID must be passed to the parser output to get revision variables correct
     $parserOutput = $content->getParserOutput($title, $revision->getId(), null, false);
     $updates = $content->getSecondaryDataUpdates($title, null, false, $parserOutput);
     DataUpdate::runUpdates($updates);
     InfoAction::invalidateCache($title);
     wfProfileOut($fname);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:21,代码来源:RefreshLinksJob.php

示例5: extractRevisionInfo


//.........这里部分代码省略.........
             $anyHidden = true;
         } elseif (!$content) {
             $vals['textmissing'] = true;
         }
     }
     if ($this->fld_content && $content) {
         $text = null;
         if ($this->generateXML) {
             if ($content->getModel() === CONTENT_MODEL_WIKITEXT) {
                 $t = $content->getNativeData();
                 # note: don't set $text
                 $wgParser->startExternalParse($title, ParserOptions::newFromContext($this->getContext()), Parser::OT_PREPROCESS);
                 $dom = $wgParser->preprocessToDom($t);
                 if (is_callable(array($dom, 'saveXML'))) {
                     $xml = $dom->saveXML();
                 } else {
                     $xml = $dom->__toString();
                 }
                 $vals['parsetree'] = $xml;
             } else {
                 $vals['badcontentformatforparsetree'] = true;
                 $this->setWarning("Conversion to XML is supported for wikitext only, " . $title->getPrefixedDBkey() . " uses content model " . $content->getModel());
             }
         }
         if ($this->expandTemplates && !$this->parseContent) {
             #XXX: implement template expansion for all content types in ContentHandler?
             if ($content->getModel() === CONTENT_MODEL_WIKITEXT) {
                 $text = $content->getNativeData();
                 $text = $wgParser->preprocess($text, $title, ParserOptions::newFromContext($this->getContext()));
             } else {
                 $this->setWarning("Template expansion is supported for wikitext only, " . $title->getPrefixedDBkey() . " uses content model " . $content->getModel());
                 $vals['badcontentformat'] = true;
                 $text = false;
             }
         }
         if ($this->parseContent) {
             $po = $content->getParserOutput($title, $revision->getId(), ParserOptions::newFromContext($this->getContext()));
             $text = $po->getText();
         }
         if ($text === null) {
             $format = $this->contentFormat ? $this->contentFormat : $content->getDefaultFormat();
             $model = $content->getModel();
             if (!$content->isSupportedFormat($format)) {
                 $name = $title->getPrefixedDBkey();
                 $this->setWarning("The requested format {$this->contentFormat} is not " . "supported for content model {$model} used by {$name}");
                 $vals['badcontentformat'] = true;
                 $text = false;
             } else {
                 $text = $content->serialize($format);
                 // always include format and model.
                 // Format is needed to deserialize, model is needed to interpret.
                 $vals['contentformat'] = $format;
                 $vals['contentmodel'] = $model;
             }
         }
         if ($text !== false) {
             ApiResult::setContentValue($vals, 'content', $text);
         }
     }
     if ($content && (!is_null($this->diffto) || !is_null($this->difftotext))) {
         static $n = 0;
         // Number of uncached diffs we've had
         if ($n < $this->getConfig()->get('APIMaxUncachedDiffs')) {
             $vals['diff'] = array();
             $context = new DerivativeContext($this->getContext());
             $context->setTitle($title);
             $handler = $revision->getContentHandler();
             if (!is_null($this->difftotext)) {
                 $model = $title->getContentModel();
                 if ($this->contentFormat && !ContentHandler::getForModelID($model)->isSupportedFormat($this->contentFormat)) {
                     $name = $title->getPrefixedDBkey();
                     $this->setWarning("The requested format {$this->contentFormat} is not " . "supported for content model {$model} used by {$name}");
                     $vals['diff']['badcontentformat'] = true;
                     $engine = null;
                 } else {
                     $difftocontent = ContentHandler::makeContent($this->difftotext, $title, $model, $this->contentFormat);
                     $engine = $handler->createDifferenceEngine($context);
                     $engine->setContent($content, $difftocontent);
                 }
             } else {
                 $engine = $handler->createDifferenceEngine($context, $revision->getID(), $this->diffto);
                 $vals['diff']['from'] = $engine->getOldid();
                 $vals['diff']['to'] = $engine->getNewid();
             }
             if ($engine) {
                 $difftext = $engine->getDiffBody();
                 ApiResult::setContentValue($vals['diff'], 'body', $difftext);
                 if (!$engine->wasCacheHit()) {
                     $n++;
                 }
             }
         } else {
             $vals['diff']['notcached'] = true;
         }
     }
     if ($anyHidden && $revision->isDeleted(Revision::DELETED_RESTRICTED)) {
         $vals['suppressed'] = true;
     }
     return $vals;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:101,代码来源:ApiQueryRevisionsBase.php

示例6: showDiff

 /**
  * Build a diff display between this and the previous either deleted
  * or non-deleted edit.
  *
  * @param Revision $previousRev
  * @param Revision $currentRev
  * @return string HTML
  */
 function showDiff($previousRev, $currentRev)
 {
     $diffContext = clone $this->getContext();
     $diffContext->setTitle($currentRev->getTitle());
     $diffContext->setWikiPage(WikiPage::factory($currentRev->getTitle()));
     $diffEngine = $currentRev->getContentHandler()->createDifferenceEngine($diffContext);
     $diffEngine->showDiffStyle();
     $this->getOutput()->addHTML("<div>" . "<table style='width: 98%;' cellpadding='0' cellspacing='4' class='diff'>" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<col class='diff-marker' />" . "<col class='diff-content' />" . "<tr>" . "<td colspan='2' style='width: 50%; text-align: center' class='diff-otitle'>" . $this->diffHeader($previousRev, 'o') . "</td>\n" . "<td colspan='2' style='width: 50%;  text-align: center' class='diff-ntitle'>" . $this->diffHeader($currentRev, 'n') . "</td>\n" . "</tr>" . $diffEngine->generateContentDiffBody($previousRev->getContent(Revision::FOR_THIS_USER, $this->getUser()), $currentRev->getContent(Revision::FOR_THIS_USER, $this->getUser())) . "</table>" . "</div>\n");
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:17,代码来源:SpecialUndelete.php


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