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


PHP ParserOptions::newFromUser方法代码示例

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


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

示例1: testLongNumericLinesDontKillTheParser

 /**
  * @see Bug 8689
  * @covers Parser::parse
  */
 public function testLongNumericLinesDontKillTheParser()
 {
     $longLine = '1.' . str_repeat('1234567890', 100000) . "\n";
     $title = Title::newFromText('Unit test');
     $options = ParserOptions::newFromUser(new User());
     $this->assertEquals("<p>{$longLine}</p>", $this->parser->parse($longLine, $title, $options)->getText());
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:11,代码来源:ExtraParserTest.php

示例2: getMessagesFormatted

 function getMessagesFormatted($severity = self::MESSAGE_WARNING, $header = null)
 {
     global $wgTitle, $wgUser;
     $ret = '';
     foreach ($this->mMessages as $message) {
         if ($message[1] <= $severity) {
             $ret .= '* ' . $message[0] . "\n";
         }
     }
     if ($ret != '') {
         if (!$this->mParser) {
             $parser = new Parser();
         }
         if ($header == null) {
             $header = '';
         } elseif ($header != '') {
             $header = Html::rawElement('div', array('class' => 'heading'), $header);
         }
         $ret = Html::rawElement('div', array('class' => 'messages'), $header . "\n" . $ret);
         $ret = $parser->parse($ret, $wgTitle, ParserOptions::newFromUser($wgUser));
     } else {
         $ret = null;
     }
     return $ret;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:LingoMessageLog.php

示例3: initialise

 function initialise(&$memCached, $useDB, $expiry, $memcPrefix)
 {
     $fname = 'MessageCache::initialise';
     wfProfileIn($fname);
     $this->mUseCache = !is_null($memCached);
     $this->mMemc =& $memCached;
     $this->mDisable = !$useDB;
     $this->mExpiry = $expiry;
     $this->mDisableTransform = false;
     $this->mMemcKey = $memcPrefix . ':messages';
     $this->mKeys = false;
     # initialised on demand
     $this->mInitialised = true;
     wfProfileIn($fname . '-parseropt');
     $this->mParserOptions = ParserOptions::newFromUser($u = NULL);
     wfProfileOut($fname . '-parseropt');
     wfProfileIn($fname . '-parser');
     $this->mParser = new Parser();
     wfProfileOut($fname . '-parser');
     # When we first get asked for a message,
     # then we'll fill up the cache. If we
     # can return a cache hit, this saves
     # some extra milliseconds
     $this->mDeferred = true;
     wfProfileOut($fname);
 }
开发者ID:BackupTheBerlios,项目名称:blahtex,代码行数:26,代码来源:MessageCache.php

示例4: genParserOptions

 function genParserOptions()
 {
     global $wgUser;
     $this->mParserOptions = ParserOptions::newFromUser($wgUser);
     $this->mParserOptions->setDateFormat(MW_DATE_DEFAULT);
     $this->mParserOptions->setEditSection(false);
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:7,代码来源:SpecialCite_body.php

示例5: sandboxParse

	function sandboxParse($wikiText){
		global $wgUser;
		$myParser = new Parser();
		$myParserOptions = ParserOptions::newFromUser( $wgUser );
		$result = $myParser->parse($wikiText, $this->getTitle(), $myParserOptions);
		return $result->getText();
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:TemplateLink.body.php

示例6: renderFlags

 /**
  * Parses the wrapped wikitext and returns an HTML block of code with rendered flags.
  * @param array $templateCalls
  * @param $pageId
  * @return ParserOutput
  */
 public function renderFlags(array $templateCalls, $pageId)
 {
     global $wgUser;
     $wikitext = $this->wrapAllFlags($templateCalls);
     $title = \Title::newFromID($pageId);
     return \ParserPool::parse($wikitext, $title, \ParserOptions::newFromUser($wgUser));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:FlagView.class.php

示例7: checkOptions

 public function checkOptions()
 {
     if ($this->hasOption('save-failed')) {
         $this->saveFailed = $this->getOption('save-failed');
     }
     $this->stripParametersEnabled = $this->hasOption('strip-parameters');
     $this->showParsedOutput = $this->hasOption('show-parsed-output');
     $this->showDiff = $this->hasOption('show-diff');
     if ($this->showDiff) {
         $bin = $this->getOption('diff-bin', getenv('DIFF'));
         if ($bin != '') {
             global $wgDiff;
             $wgDiff = $bin;
         }
     }
     $user = new User();
     $this->options = ParserOptions::newFromUser($user);
     if ($this->hasOption('tidy')) {
         global $wgUseTidy;
         if (!$wgUseTidy) {
             $this->error('Tidy was requested but $wgUseTidy is not set in LocalSettings.php', true);
         }
         $this->options->setTidy(true);
     }
     $this->failed = 0;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:26,代码来源:compareParsers.php

示例8: testBug8689

 function testBug8689()
 {
     global $wgUser;
     $longLine = '1.' . str_repeat('1234567890', 100000) . "\n";
     $t = Title::newFromText('Unit test');
     $options = ParserOptions::newFromUser($wgUser);
     $this->assertEquals("<p>{$longLine}</p>", $this->parser->parse($longLine, $t, $options)->getText());
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:8,代码来源:ExtraParserTest.php

示例9: getRevIncludes

 /**
  * Get template and image versions from parsing a revision
  * @param Page $article
  * @param Revision $rev
  * @param User $user
  * @param string $regen use 'regen' to force regeneration
  * @return array( templateIds, fileSHA1Keys )
  * templateIds like ParserOutput->mTemplateIds
  * fileSHA1Keys like ParserOutput->mImageTimeKeys
  */
 public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
 {
     global $wgParser, $wgMemc;
     wfProfileIn(__METHOD__);
     $versions = false;
     $key = self::getCacheKey($article->getTitle(), $rev->getId());
     if ($regen !== 'regen') {
         // check cache
         $versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
     }
     if (!is_array($versions)) {
         // cache miss
         $pOut = false;
         if ($rev->isCurrent()) {
             $parserCache = ParserCache::singleton();
             # Try current version parser cache (as anon)...
             $pOut = $parserCache->get($article, $article->makeParserOptions($user));
             if ($pOut == false && $rev->getUser()) {
                 // try the user who saved the change
                 $author = User::newFromId($rev->getUser());
                 $pOut = $parserCache->get($article, $article->makeParserOptions($author));
             }
         }
         // ParserOutput::mImageTimeKeys wasn't always there
         if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
             $title = $article->getTitle();
             $pOpts = ParserOptions::newFromUser($user);
             // Note: tidy off
             $pOut = $wgParser->parse($rev->getText(), $title, $pOpts, true, true, $rev->getId());
         }
         # Get the template/file versions used...
         $versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
         # Save to cache (check cache expiry for dynamic elements)...
         $data = FlaggedRevs::makeMemcObj($versions);
         $wgMemc->set($key, $data, $pOut->getCacheExpiry());
     } else {
         $tVersions =& $versions[0];
         // templates
         # Do a link batch query for page_latest...
         $lb = new LinkBatch();
         foreach ($tVersions as $ns => $tmps) {
             foreach ($tmps as $dbKey => $revIdDraft) {
                 $lb->add($ns, $dbKey);
             }
         }
         $lb->execute();
         # Update array with the current page_latest values.
         # This kludge is there since $newTemplates (thus $revIdDraft) is cached.
         foreach ($tVersions as $ns => &$tmps) {
             foreach ($tmps as $dbKey => &$revIdDraft) {
                 $title = Title::makeTitle($ns, $dbKey);
                 $revIdDraft = (int) $title->getLatestRevID();
             }
         }
     }
     wfProfileOut(__METHOD__);
     return $versions;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:68,代码来源:FRInclusionCache.php

示例10: getRevIncludes

 /**
  * Get template and image versions from parsing a revision
  * @param Page $article
  * @param Revision $rev
  * @param User $user
  * @param string $regen use 'regen' to force regeneration
  * @return array( templateIds, fileSHA1Keys )
  * templateIds like ParserOutput->mTemplateIds
  * fileSHA1Keys like ParserOutput->mImageTimeKeys
  */
 public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $key = self::getCacheKey($article->getTitle(), $rev->getId());
     if ($regen === 'regen') {
         $versions = false;
         // skip cache
     } elseif ($rev->isCurrent()) {
         // Check cache entry against page_touched
         $versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article);
     } else {
         // Old revs won't always be invalidated with template/file changes.
         // Also, we don't care if page_touched changed due to a direct edit.
         $versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
         if (is_array($versions)) {
             // entry exists
             // Sanity check that the cache is reasonably up to date
             list($templates, $files) = $versions;
             if (self::templatesStale($templates) || self::filesStale($files)) {
                 $versions = false;
                 // no good
             }
         }
     }
     if (!is_array($versions)) {
         // cache miss
         $pOut = false;
         if ($rev->isCurrent()) {
             $parserCache = ParserCache::singleton();
             # Try current version parser cache for this user...
             $pOut = $parserCache->get($article, $article->makeParserOptions($user));
             if ($pOut == false) {
                 # Try current version parser cache for the revision author...
                 $optsUser = $rev->getUser() ? User::newFromId($rev->getUser()) : 'canonical';
                 $pOut = $parserCache->get($article, $article->makeParserOptions($optsUser));
             }
         }
         // ParserOutput::mImageTimeKeys wasn't always there
         if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
             $content = $rev->getContent(Revision::RAW);
             if (!$content) {
                 // Just for extra sanity
                 $pOut = new ParserOutput();
             } else {
                 $pOut = $content->getParserOutput($article->getTitle(), $rev->getId(), ParserOptions::newFromUser($user));
             }
         }
         # Get the template/file versions used...
         $versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
         # Save to cache (check cache expiry for dynamic elements)...
         $data = FlaggedRevs::makeMemcObj($versions);
         $wgMemc->set($key, $data, $pOut->getCacheExpiry());
     }
     wfProfileOut(__METHOD__);
     return $versions;
 }
开发者ID:crippsy14,项目名称:orange-smorange,代码行数:67,代码来源:FRInclusionCache.php

示例11: parseText

 function parseText($text)
 {
     #still need to make it actually parse the input.
     global $wgOut, $wgUser, $wgTitle, $wgParser, $wgAllowDiffPreview, $wgEnableDiffPreviewPreference;
     $parserOptions = ParserOptions::newFromUser($wgUser);
     $parserOptions->setEditSection(false);
     $output = $wgParser->parse($text, $wgTitle, $parserOptions);
     $wgOut->setArticleBodyOnly(true);
     $wgOut->addHTML($output->mText);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:10,代码来源:EZParser.php

示例12: getPages

 function getPages($query)
 {
     global $wgTitle, $wgParser, $wgUser;
     $fname = 'NukeDPLForm::getNewPages';
     $query = trim($query) . "\nmode=userformat\nlistseparators=,\\n\$\$\$%PAGE%\$\$\$,,\n";
     $opt = ParserOptions::newFromUser($wgUser);
     $out = $wgParser->parse("<dpl>{$query}</dpl>", $wgTitle, $opt, false, true);
     preg_match_all('|\\${3}(.+?)\\${3}|m', $out->getText(), $matches);
     return str_replace(array('&nbsp;', '&amp;'), array(' ', '&'), $matches[1]);
 }
开发者ID:saper,项目名称:organic-extensions,代码行数:10,代码来源:NukeDPL.class.php

示例13: testPreSaveTransform

 /**
  * @dataProvider providePreSaveTransform
  * @covers Parser::preSaveTransform
  */
 public function testPreSaveTransform($text, $expected)
 {
     global $wgParser;
     $title = Title::newFromText(str_replace('::', '__', __METHOD__));
     $user = new User();
     $user->setName("127.0.0.1");
     $popts = ParserOptions::newFromUser($user);
     $text = $wgParser->preSaveTransform($text, $title, $user, $popts);
     $this->assertEquals($expected, $text);
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:14,代码来源:ParserMethodsTest.php

示例14: execute

 function execute($params)
 {
     global $wgRequest, $wgOut, $wgTitle, $wgUser;
     global $wgContLang, $wgProxyKey, $wgParser;
     $article = $wgRequest->getText('article', $params);
     $map = $wgRequest->getText('map', $params);
     $wgOut->disable();
     header("Cache-Control: no-cache, must-revalidate");
     header("Content-type: application/vnd.google-earth.kml+xml");
     header('Content-Disposition: attachment; filename="' . $article . '.kml"');
     $title = Title::newFromText($article);
     /* Wikia change begin - @author: Sebastian Marzjan */
     /* fogbugz BugID #18043 */
     if ($title instanceof Title) {
         /* Wikia change end */
         $revision = Revision::newFromTitle($title);
         /* Wikia change begin - @author: Sebastian Marzjan */
         /* fogbugz BugID #18043 */
         if (!$revision instanceof Revision) {
             $errorMessage = 'SpecialGoogleMapsKML.php ' . __LINE__ . ' - no revision for ' . $article . ' / ' . $title->getArticleID();
             Wikia::log(__METHOD__, false, $errorMessage);
             echo "No article revisions found by the name of {$article}";
             return false;
         }
         /* Wikia change end */
         $mapOptions = GoogleMaps::getMapSettings($title, array('icons' => 'http://maps.google.com/mapfiles/kml/pal4/{label}.png', 'icon' => 'icon57'));
         $exporter = new GoogleMapsKmlExporter($wgContLang, str_replace('{label}', $mapOptions['icon'], $mapOptions['icons']));
         $wgParser->mOptions = ParserOptions::newFromUser($wgUser);
         $wgParser->mOptions->setEditSection(false);
         $wgParser->mTitle = $wgTitle;
         $wgParser->clearState();
         $localParser = new Parser();
         $localParser->mTitle = $title;
         $localParser->mOptions = $wgParser->mOptions;
         if (preg_match_all("/<googlemap( .*?|)>(.*?)<\\/googlemap>/s", $revision->getText(), $matches)) {
             $exporter->addFileHeader();
             for ($i = 0; $i < count($matches[2]); $i++) {
                 $attrs = Sanitizer::decodeTagAttributes($matches[1][$i]);
                 $mapOptions['version'] = isset($attrs['version']) ? $attrs['version'] : "0";
                 $exporter->addHeader(isset($attrs['title']) ? $attrs['title'] : "Map #" . ($i + 1));
                 GoogleMaps::renderContent($matches[2][$i], $wgParser, $localParser, $exporter, $mapOptions);
                 $exporter->addTrailer();
             }
             $exporter->addFileTrailer();
             echo $exporter->render();
         } else {
             echo "No maps in {$article}!";
         }
     } else {
         echo "No article found by the name of {$article}";
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:52,代码来源:SpecialGoogleMapsKML.php

示例15: getPages

 function getPages($query)
 {
     global $wgParser;
     $user = $this->getUser();
     $title = $this->getTitle();
     $query = trim($query) . PHP_EOL . "format=,\$\$\$%PAGE%\$\$\$,,";
     //Enclose each title with $$$
     $parserOptions = ParserOptions::newFromUser($user);
     $parserOutput = $wgParser->parse('<dpl>' . $query . '</dpl>', $title, $parserOptions, false, true);
     preg_match_all('|\\$\\$\\$(.+)\\$\\$\\$|U', $parserOutput->getText(), $matches);
     //Extract the titles from the output
     return $matches[1];
     //Return an array of titles
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:14,代码来源:SpecialNukeDPL.php


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