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


PHP Parser::getOptions方法代码示例

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


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

示例1: getMapHTML

 /**
  * @see MapsBaseMap::getMapHTML()
  */
 public function getMapHTML(array $params, Parser $parser, $mapName)
 {
     $thumbs = $params['thumbs'] ? 'yes' : 'no';
     $photos = $params['photos'] ? 'yes' : 'no';
     $lang = $parser->getOptions()->getTargetLanguage();
     $langCode = $lang->getCode();
     // https://secure.wikimedia.org/wikipedia/de/wiki/Wikipedia:WikiProjekt_Georeferenzierung/Wikipedia-World/en#Expert_mode
     return Html::element('iframe', array('id' => $mapName, 'style' => "width: {$params['width']}; height: {$params['height']}; clear: both;", 'src' => "http://toolserver.org/~kolossos/openlayers/kml-on-ol.php?zoom={$params['zoom']}&lat={$params['centre']['lat']}&lon={$params['centre']['lon']}&lang={$langCode}&thumbs={$thumbs}&photo={$photos}"), wfMessage('maps-loading-map')->inLanguage($lang)->escaped());
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:Maps_OSMDispMap.php

示例2: formatDate

 /**
  * @param Parser $parser
  * @param string $date
  * @param string $defaultPref
  *
  * @return string
  */
 static function formatDate($parser, $date, $defaultPref = null)
 {
     $lang = $parser->getFunctionLang();
     $df = DateFormatter::getInstance($lang);
     $date = trim($date);
     $pref = $parser->getOptions()->getDateFormat();
     // Specify a different default date format other than the the normal default
     // if the user has 'default' for their setting
     if ($pref == 'default' && $defaultPref) {
         $pref = $defaultPref;
     }
     $date = $df->reformat($pref, $date, array('match-whole'));
     return $date;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:21,代码来源:CoreParserFunctions.php

示例3: gender

 /**
  * @param Parser $parser
  * @param string $username
  * @return string
  */
 public static function gender($parser, $username)
 {
     $forms = array_slice(func_get_args(), 2);
     // Some shortcuts to avoid loading user data unnecessarily
     if (count($forms) === 0) {
         return '';
     } elseif (count($forms) === 1) {
         return $forms[0];
     }
     $username = trim($username);
     // default
     $gender = User::getDefaultOption('gender');
     // allow prefix.
     $title = Title::newFromText($username);
     if ($title && $title->getNamespace() == NS_USER) {
         $username = $title->getText();
     }
     // check parameter, or use the ParserOptions if in interface message
     $user = User::newFromName($username);
     if ($user) {
         $gender = GenderCache::singleton()->getGenderOf($user, __METHOD__);
     } elseif ($username === '' && $parser->getOptions()->getInterfaceMessage()) {
         $gender = GenderCache::singleton()->getGenderOf($parser->getOptions()->getUser(), __METHOD__);
     }
     $ret = $parser->getFunctionLang()->gender($gender, $forms);
     return $ret;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:32,代码来源:CoreParserFunctions.php

示例4: doVariants

 /**
  * Modify $this->internals and $colours according to language variant linking rules
  * @param array $colours
  */
 protected function doVariants(&$colours)
 {
     global $wgContLang, $wgContentHandlerUseDB;
     $linkBatch = new LinkBatch();
     $variantMap = array();
     // maps $pdbkey_Variant => $keys (of link holders)
     $output = $this->parent->getOutput();
     $linkCache = LinkCache::singleton();
     $threshold = $this->parent->getOptions()->getStubThreshold();
     $titlesToBeConverted = '';
     $titlesAttrs = array();
     // Concatenate titles to a single string, thus we only need auto convert the
     // single string to all variants. This would improve parser's performance
     // significantly.
     foreach ($this->internals as $ns => $entries) {
         if ($ns == NS_SPECIAL) {
             continue;
         }
         foreach ($entries as $index => $entry) {
             $pdbk = $entry['pdbk'];
             // we only deal with new links (in its first query)
             if (!isset($colours[$pdbk]) || $colours[$pdbk] === 'new') {
                 $titlesAttrs[] = array($index, $entry['title']);
                 // separate titles with \0 because it would never appears
                 // in a valid title
                 $titlesToBeConverted .= $entry['title']->getText() . "";
             }
         }
     }
     // Now do the conversion and explode string to text of titles
     $titlesAllVariants = $wgContLang->autoConvertToAllVariants(rtrim($titlesToBeConverted, ""));
     $allVariantsName = array_keys($titlesAllVariants);
     foreach ($titlesAllVariants as &$titlesVariant) {
         $titlesVariant = explode("", $titlesVariant);
     }
     // Then add variants of links to link batch
     $parentTitle = $this->parent->getTitle();
     foreach ($titlesAttrs as $i => $attrs) {
         /** @var Title $title */
         list($index, $title) = $attrs;
         $ns = $title->getNamespace();
         $text = $title->getText();
         foreach ($allVariantsName as $variantName) {
             $textVariant = $titlesAllVariants[$variantName][$i];
             if ($textVariant === $text) {
                 continue;
             }
             $variantTitle = Title::makeTitle($ns, $textVariant);
             if (is_null($variantTitle)) {
                 continue;
             }
             // Self-link checking for mixed/different variant titles. At this point, we
             // already know the exact title does not exist, so the link cannot be to a
             // variant of the current title that exists as a separate page.
             if ($variantTitle->equals($parentTitle) && !$title->hasFragment()) {
                 $this->internals[$ns][$index]['selflink'] = true;
                 continue 2;
             }
             $linkBatch->addObj($variantTitle);
             $variantMap[$variantTitle->getPrefixedDBkey()][] = "{$ns}:{$index}";
         }
     }
     // process categories, check if a category exists in some variant
     $categoryMap = array();
     // maps $category_variant => $category (dbkeys)
     $varCategories = array();
     // category replacements oldDBkey => newDBkey
     foreach ($output->getCategoryLinks() as $category) {
         $categoryTitle = Title::makeTitleSafe(NS_CATEGORY, $category);
         $linkBatch->addObj($categoryTitle);
         $variants = $wgContLang->autoConvertToAllVariants($category);
         foreach ($variants as $variant) {
             if ($variant !== $category) {
                 $variantTitle = Title::makeTitleSafe(NS_CATEGORY, $variant);
                 if (is_null($variantTitle)) {
                     continue;
                 }
                 $linkBatch->addObj($variantTitle);
                 $categoryMap[$variant] = array($category, $categoryTitle);
             }
         }
     }
     if (!$linkBatch->isEmpty()) {
         // construct query
         $dbr = wfGetDB(DB_SLAVE);
         $fields = array('page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest');
         if ($wgContentHandlerUseDB) {
             $fields[] = 'page_content_model';
         }
         $varRes = $dbr->select('page', $fields, $linkBatch->constructSet('page', $dbr), __METHOD__);
         $linkcolour_ids = array();
         // for each found variants, figure out link holders and replace
         foreach ($varRes as $s) {
             $variantTitle = Title::makeTitle($s->page_namespace, $s->page_title);
             $varPdbk = $variantTitle->getPrefixedDBkey();
             $vardbk = $variantTitle->getDBkey();
//.........这里部分代码省略.........
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:101,代码来源:LinkHolderArray.php

示例5: parse

 protected function parse($wikitext, $params, $newline = false)
 {
     $withVars = $this->parser->replaceVariables($wikitext, $this->parser->getPreprocessor()->newCustomFrame($params));
     $parserOutput = $this->parser->parse($withVars, $this->parser->getTitle(), $this->parser->getOptions(), $newline);
     return preg_replace('|{{{.*}}}|Us', '', preg_replace('|[\\n\\r]|Us', '', $parserOutput->getText()));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:6,代码来源:MediaWikiParserTest.php

示例6: renderCompaTables

 /**
  * Render CompaTable HTML code
  *
  * Reads from JSON file, triggers generation if required
  * and optionally adds ESI tags.
  *
  * @param string $input
  * @param array  $args
  * @param Parser $parser
  */
 public static function renderCompaTables($input, array $args, Parser $parser)
 {
     global $wgCompatablesUseESI, $wgUseTidy, $wgAlwaysUseTidy;
     $out = '';
     $args['topic'] = isset($args['topic']) ? $args['topic'] : '';
     $args['feature'] = isset($args['feature']) ? $args['feature'] : '';
     $args['format'] = isset($args['format']) ? $args['format'] : '';
     $args['cacheKey'] = wfMemcKey('compatables', $args['format'], $args['topic'], $args['feature']);
     /**   *****************************   **/
     $data = self::getData();
     if ($data !== null) {
         $cached = self::memcacheRead($args['cacheKey'], $data['hash']);
         if ($cached !== false) {
             $table = $cached['output'];
         } else {
             $generated = self::generateCompaTable($data, $args);
             if ($wgUseTidy && $parser->getOptions()->getTidy() || $wgAlwaysUseTidy) {
                 $generated['output'] = MWTidy::tidy($generated['output']);
             }
             self::memcacheSave($args['cacheKey'], $generated);
             $table = $generated['output'];
         }
         /**   *****************************   * */
         // We are ignoring <compatibility>input would be here</compatibility>
         // because its useless for now.
         //if ( $input != '' ) {
         //  $out .= '<p>' . $input . '</p>';
         //}
         if ($wgCompatablesUseESI === true) {
             $urlArgs['topic'] = $args['topic'];
             $urlArgs['feature'] = $args['feature'];
             $urlArgs['format'] = $args['format'];
             $urlArgs['foresi'] = 1;
             // @TODO: this breaks in ESI level if $url ends up http for https views
             $urlHelper = SpecialPage::getTitleFor('Compatables')->getFullUrl($urlArgs);
             $out .= self::applyEsiTags($table, wfExpandUrl($urlHelper, PROTO_INTERNAL));
         } else {
             $out .= $table;
             $parser->getOutput()->updateCacheExpiry(6 * 3600);
             // worse cache hit rate
         }
     } else {
         wfDebugLog('CompaTables', 'Could not generate table, data is either empty or had problems.');
         $out = '<!-- Compatables: Could not generate table, data might be empty or had problems with caching -->';
     }
     return $out;
 }
开发者ID:renoirb,项目名称:mediawiki-1,代码行数:57,代码来源:Compatables.class.php

示例7: onParserBeforeInternalParse

	/**
	 * Insert categories from previous pre-preview parse into parser.
	 *
	 * See onEditPageGetPreviewText. This is rather fragile/scary.
	 * If anyone has a suggestion for how to do this better, please let me know.
	 *
	 * @param $parser Parser
	 * @param $pstText String text to parse, all pst'd. In theory untouched but
	 *    various hooks could have touched it, which would make this all fail.
	 * @param $stripState StripState $parser->mStripState - I really don't need this
	 * @return boolean true
	 */
	public static function onParserBeforeInternalParse( Parser $parser, $pstText, $stripState ) {
		global $wgPageInCatUseAccuratePreview;
		if ( !$wgPageInCatUseAccuratePreview ) {
			// Disabled
			return true;
		}

		if ( !$parser->getOptions()->getIsPreview() ) {
			// We only do stuff on preview
			return true;
		}

		$hash = md5( $pstText, true );

		if ( !isset( self::$categoriesForPreview[$hash] ) ) {
			# This probably shouldn't happen
			wfDebug( __METHOD__ . ' Could not find relevant cat list.' );
			return true;
		}

		if ( !isset( $parser->pageInCat_cache ) ) {
			$parser->pageInCat_cache = array();
		} elseif ( count( $parser->pageInCat_cache ) !== 0 ) {
			# being paranoid
			wfDebug( __METHOD__ . ' $parser->pageInCat_cache not empty!' );
			$parser->pageInCat_cache = array();
		}

		foreach( self::$categoriesForPreview[$hash] as $catName ) {
			$parser->pageInCat_cache[$catName] = true;
		}
		// Assume anything not in the cache is false.
		$parser->pageInCat_onlyCache = true;
		unset( self::$categoriesForPreview[$hash] );

		return true;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:49,代码来源:PageInCat_body.php


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