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


PHP Parser::incrementExpensiveFunctionCount方法代码示例

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


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

示例1: inCat

	/**
	 * check if $page belongs to $category
	 * @param $page Title current page
	 * @param $category String category to check (not a title object!)
	 * @param $parser Parser
	 * @return boolean If $page is a member of $category
	 */
	private static function inCat( Title $page, $category, Parser $parser ) {
		if ( $category === '' ) return false;
		$catTitle = Title::makeTitleSafe(
			NS_CATEGORY,
			$category
		);
		if ( !$catTitle ) return false;
		$catDBkey = $catTitle->getDBkey();

		if ( !isset( $parser->pageInCat_cache ) ) {
			$parser->pageInCat_cache = array();
		} else {
			if ( isset( $parser->pageInCat_cache[$catDBkey] ) ) {
				# been there done that, return cached value
				return $parser->pageInCat_cache[$catDBkey];
			} elseif( isset( $parser->pageInCat_onlyCache ) && $parser->pageInCat_onlyCache ) {
				# All categories have been preloaded into cache, so
				# we must have hit a cat not in page.
				# Mark it so can be checked for correctness later.
				$parser->PageInCat_cache[$catDBkey] = false;
				return false;
			}
		}

		$pageId = $page->getArticleId();
		if ( !$pageId ) {
			// page hasn't yet been saved (preview)
			// add to the cache list so the other hook
			// will warn about incorrect value.
			// Important to do this after checking cache
			// in case categories were pre-loaded during preview.
			$parser->pageInCat_cache[$catDBkey] = false;
			return false;
		}

		if ( !$parser->incrementExpensiveFunctionCount() ) {
			# expensive function limit reached.
			return false;
		}

		if ( self::inCatCheckDb( $pageId, $catDBkey ) ) {
			$parser->pageInCat_cache[$catDBkey] = true;
			return true;
		} /* else if false */

		$parser->pageInCat_cache[$catDBkey] = false;
		return false;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:55,代码来源:PageInCat_body.php

示例2: tryExecute

 /**
  * Execute the ParserFunction and throws exceptions if needed
  * 
  * @param array $arguments Array of strings
  * @return string output for parser
  * @throws \MWException Internal errors + user errors
  */
 public function tryExecute($arguments)
 {
     // if the limit has been exceeded, output is an error message
     // an additional warning message is displayed in page edit mode
     if (!$this->parser->incrementExpensiveFunctionCount()) {
         return 'Expensive function count error.';
     }
     // initializes
     $this->declareParameters();
     // tries to set parameters by name
     $arguments_without_name = $this->trySetParametersByName($arguments);
     // tries to set parameters by order
     $this->trySetParametersByOrder($arguments_without_name);
     // check all parameters (required, ...)
     $this->validate();
     // returns the output
     return $this->getOutputForParser();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:25,代码来源:ParserFunction.php

示例3: cascadingsources

 /**
  * Returns the sources of any cascading protection acting on a specified page.
  * Pages will not return their own title unless they transclude themselves.
  * This is an expensive parser function and can't be called too many times per page,
  * unless cascading protection sources for the page have already been loaded.
  *
  * @param Parser $parser
  * @param string $title
  *
  * @return string
  * @since 1.23
  */
 public static function cascadingsources($parser, $title = '')
 {
     $titleObject = Title::newFromText($title);
     if (!$titleObject instanceof Title) {
         $titleObject = $parser->mTitle;
     }
     if ($titleObject->areCascadeProtectionSourcesLoaded() || $parser->incrementExpensiveFunctionCount()) {
         $names = [];
         $sources = $titleObject->getCascadeProtectionSources();
         foreach ($sources[0] as $sourceTitle) {
             $names[] = $sourceTitle->getPrefixedText();
         }
         return implode($names, '|');
     }
     return '';
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:28,代码来源:CoreParserFunctions.php


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