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


PHP ParserOutput类代码示例

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


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

示例1: getParserOutput

 /**
  * Override getParserOutput, since we require $title to generate our output
  */
 function getParserOutput(Title $title, $revId = null, ParserOptions $otpions = null, $generateHtml = true)
 {
     $po = new ParserOutput();
     if ($generateHtml) {
         $po->setText($this->generateHtml($title));
     }
     return $po;
 }
开发者ID:robksawyer,项目名称:lathe.tools,代码行数:11,代码来源:CampaignContent.php

示例2: testGetTemplates

 public function testGetTemplates()
 {
     $title = Title::makeTitle(NS_TEMPLATE, 'Cite_news');
     $parserOutput = new ParserOutput();
     $parserOutput->addTemplate($title, 10, 100);
     $searchDataExtractor = new ParserOutputSearchDataExtractor();
     $this->assertEquals(['Template:Cite news'], $searchDataExtractor->getTemplates($parserOutput));
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:8,代码来源:ParserOutputSearchDataExtractorTest.php

示例3: wfWikiAnswersPageTitle

/**
 * @param OutputPage $out
 * @param ParserOutput $parserOutput
 * @return bool
 */
function wfWikiAnswersPageTitle(&$out, $parserOutput)
{
    $answerObj = Answer::newFromTitle($out->getTitle());
    if ($answerObj->isQuestion()) {
        $parserOutput->setTitleText($parserOutput->getTitleText() . wfMsg('?'));
    }
    return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:WikiAnswers.php

示例4: fillParserOutput

 /**
  * Set the HTML and add the appropriate styles
  *
  *
  * @param Title $title
  * @param int $revId
  * @param ParserOptions $options
  * @param bool $generateHtml
  * @param ParserOutput $output
  */
 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     if ($generateHtml) {
         $output->setText($this->objectTable($this->getJsonData()));
         $output->addModuleStyles('mediawiki.content.json');
     } else {
         $output->setText('');
     }
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:19,代码来源:JSONContent.php

示例5: __construct

 public function __construct(Title $title, ParserOutput $stableOutput)
 {
     $this->title = $title;
     # Stable version links
     $this->sLinks = $stableOutput->getLinks();
     $this->sTemplates = $stableOutput->getTemplates();
     $this->sImages = $stableOutput->getImages();
     $this->sCategories = $stableOutput->getCategories();
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:9,代码来源:FRDependencyUpdate.php

示例6: fillParserOutput

 /**
  * Set the HTML and add the appropriate styles
  *
  *
  * @param Title $title
  * @param int $revId
  * @param ParserOptions $options
  * @param bool $generateHtml
  * @param ParserOutput $output
  */
 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     if ($generateHtml) {
         $html = Html::element('pre', array('class' => 'mw-code mw-yaml', 'dir' => 'ltr'), $this->getNativeData());
         $output->setText($html);
     } else {
         $output->setText('');
     }
 }
开发者ID:valhallasw,项目名称:mediawiki-extensions-OpenStackManager,代码行数:19,代码来源:YamlContent.php

示例7: fillParserOutput

 protected function fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 {
     // FIXME: WikiPage::doEditContent generates parser output before validation.
     // As such, native data may be invalid (though output is discarded later in that case).
     if ($generateHtml && $this->isValid()) {
         $output->setText($this->renderNotebook($this->getNativeData()));
     } else {
         $output->setText('error');
     }
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-NotebookViewer,代码行数:10,代码来源:NotebookContent.php

示例8: outputPageParserOutput

 /**
  * OutputPageParserOutput hook handler
  * @param OutputPage $out
  * @param ParserOutput $parserOutput
  * @return type 
  */
 public static function outputPageParserOutput(OutputPage &$out, ParserOutput $parserOutput)
 {
     $out->addModuleStyles('ext.articleEmblems');
     if (isset($parserOutput->articleEmblems)) {
         $emblems = array();
         foreach ($parserOutput->articleEmblems as $emblem) {
             $emblems[] = '<li class="articleEmblem">' . $emblem . '</li>';
         }
         $parserOutput->setText('<ul id="articleEmblems" class="noprint">' . implode($emblems) . '</ul>' . $parserOutput->getText());
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:18,代码来源:ArticleEmblems.hooks.php

示例9: testExtensionData

 /**
  * @covers ParserOutput::setExtensionData
  * @covers ParserOutput::getExtensionData
  */
 public function testExtensionData()
 {
     $po = new ParserOutput();
     $po->setExtensionData("one", "Foo");
     $this->assertEquals("Foo", $po->getExtensionData("one"));
     $this->assertNull($po->getExtensionData("spam"));
     $po->setExtensionData("two", "Bar");
     $this->assertEquals("Foo", $po->getExtensionData("one"));
     $this->assertEquals("Bar", $po->getExtensionData("two"));
     $po->setExtensionData("one", null);
     $this->assertNull($po->getExtensionData("one"));
     $this->assertEquals("Bar", $po->getExtensionData("two"));
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:17,代码来源:ParserOutputTest.php

示例10: testMergeExternalParserOutputVars

 /**
  * @dataProvider getParserOutputVars
  */
 public function testMergeExternalParserOutputVars($sourceVars, $externalVars, $expectedVars)
 {
     $parserOutputSource = new ParserOutput();
     $parserOutputExternal = new ParserOutput();
     foreach ($parserOutputSource::$varsToMerge as $var) {
         $parserOutputSource->{$var} = $sourceVars[$var];
         $parserOutputExternal->{$var} = $externalVars[$var];
     }
     $parserOutputSource->mergeExternalParserOutputVars($parserOutputExternal);
     foreach ($parserOutputSource::$varsToMerge as $var) {
         $this->assertSame($expectedVars[$var], $parserOutputSource->{$var});
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:ParserOutputTest.php

示例11: LinksUpdate

 /**
  * Constructor
  *
  * @param Title $title Title of the page we're updating
  * @param ParserOutput $parserOutput Output from a full parse of this page
  * @param bool $recursive Queue jobs for recursive updates?
  */
 function LinksUpdate($title, $parserOutput, $recursive = true)
 {
     global $wgAntiLockFlags;
     if ($wgAntiLockFlags & ALF_NO_LINK_LOCK) {
         $this->mOptions = array();
     } else {
         $this->mOptions = array('FOR UPDATE');
     }
     $this->mDb = wfGetDB(DB_MASTER);
     if (!is_object($title)) {
         throw new MWException("The calling convention to LinksUpdate::LinksUpdate() has changed. " . "Please see Article::editUpdates() for an invocation example.\n");
     }
     $this->mTitle = $title;
     $this->mId = $title->getArticleID();
     $this->mParserOutput = $parserOutput;
     $this->mLinks = $parserOutput->getLinks();
     $this->mImages = $parserOutput->getImages();
     $this->mTemplates = $parserOutput->getTemplates();
     $this->mExternals = $parserOutput->getExternalLinks();
     $this->mCategories = $parserOutput->getCategories();
     $this->mProperties = $parserOutput->getProperties();
     # Convert the format of the interlanguage links
     # I didn't want to change it in the ParserOutput, because that array is passed all
     # the way back to the skin, so either a skin API break would be required, or an
     # inefficient back-conversion.
     $ill = $parserOutput->getLanguageLinks();
     $this->mInterlangs = array();
     foreach ($ill as $link) {
         list($key, $title) = explode(':', $link, 2);
         $this->mInterlangs[$key] = $title;
     }
     $this->mRecursive = $recursive;
     $this->mTouchTmplLinks = false;
     wfRunHooks('LinksUpdateConstructed', array(&$this));
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:42,代码来源:LinksUpdate.php

示例12: testProperties

 /**
  * @covers ParserOutput::setProperty
  * @covers ParserOutput::getProperty
  * @covers ParserOutput::unsetProperty
  * @covers ParserOutput::getProperties
  */
 public function testProperties()
 {
     $po = new ParserOutput();
     $po->setProperty('foo', 'val');
     $properties = $po->getProperties();
     $this->assertEquals($po->getProperty('foo'), 'val');
     $this->assertEquals($properties['foo'], 'val');
     $po->setProperty('foo', 'second val');
     $properties = $po->getProperties();
     $this->assertEquals($po->getProperty('foo'), 'second val');
     $this->assertEquals($properties['foo'], 'second val');
     $po->unsetProperty('foo');
     $properties = $po->getProperties();
     $this->assertEquals($po->getProperty('foo'), false);
     $this->assertArrayNotHasKey('foo', $properties);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:22,代码来源:ParserOutputTest.php

示例13: getOutputFromWikitext

 /**
  * This does all the heavy lifting for outputWikitext, except it returns the parser
  * output instead of sending it straight to $wgOut. Makes things nice and simple for,
  * say, embedding thread pages within a discussion system (LiquidThreads)
  *
  * @param $text string
  * @param $cache boolean
  * @param $parserOptions parsing options, defaults to false
  * @return ParserOutput
  */
 public function getOutputFromWikitext($text, $cache = true, $parserOptions = false)
 {
     global $wgParser, $wgEnableParserCache, $wgUseFileCache;
     if (!$parserOptions) {
         $parserOptions = $this->mPage->getParserOptions();
     }
     $time = -wfTime();
     $this->mParserOutput = $wgParser->parse($text, $this->getTitle(), $parserOptions, true, true, $this->getRevIdFetched());
     $time += wfTime();
     # Timing hack
     if ($time > 3) {
         wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->getTitle()->getPrefixedDBkey()));
     }
     if ($wgEnableParserCache && $cache && $this->mParserOutput->isCacheable()) {
         $parserCache = ParserCache::singleton();
         $parserCache->save($this->mParserOutput, $this, $parserOptions);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->mParserOutput->isCacheable() || $this->mParserOutput->containsOldMagic()) {
         $wgUseFileCache = false;
     }
     if ($this->isCurrent()) {
         $this->mPage->doCascadeProtectionUpdates($this->mParserOutput);
     }
     return $this->mParserOutput;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:38,代码来源:Article.php

示例14: testUpdate_pagelinks

 public function testUpdate_pagelinks()
 {
     list($t, $po) = $this->makeTitleAndParserOutput("Testing", 111);
     $po->addLink(Title::newFromText("Foo"));
     $po->addLink(Title::newFromText("Special:Foo"));
     // special namespace should be ignored
     $po->addLink(Title::newFromText("linksupdatetest:Foo"));
     // interwiki link should be ignored
     $po->addLink(Title::newFromText("#Foo"));
     // hash link should be ignored
     $this->assertLinksUpdate($t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(array(NS_MAIN, 'Foo')));
     $po = new ParserOutput();
     $po->setTitleText($t->getPrefixedText());
     $po->addLink(Title::newFromText("Bar"));
     $this->assertLinksUpdate($t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(array(NS_MAIN, 'Bar')));
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:16,代码来源:LinksUpdateTest.php

示例15: updateLinksTimestamp

 /**
  * Update links table freshness
  */
 protected function updateLinksTimestamp()
 {
     if ($this->mId) {
         // The link updates made here only reflect the freshness of the parser output
         $timestamp = $this->mParserOutput->getCacheTime();
         $this->mDb->update('page', array('page_links_updated' => $this->mDb->timestamp($timestamp)), array('page_id' => $this->mId), __METHOD__);
     }
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:11,代码来源:LinksUpdate.php


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