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


PHP Parser::setFunctionHook方法代码示例

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


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

示例1: onParserFirstCallInit

 /**
  * Sets up this extension's parser functions.
  *
  * @access	public
  * @param	object	Parser object passed as a reference.
  * @return	boolean	true
  */
 public static function onParserFirstCallInit(Parser &$parser)
 {
     $parser->setFunctionHook("ev", "EmbedVideoHooks::parseEV");
     $parser->setFunctionHook("evt", "EmbedVideoHooks::parseEVT");
     $parser->setFunctionHook("evp", "EmbedVideoHooks::parseEVP");
     $parser->setHook("embedvideo", "EmbedVideoHooks::parseEVTag");
     return true;
 }
开发者ID:ghm5,项目名称:mediawiki-embedvideo,代码行数:15,代码来源:EmbedVideo.hooks.php

示例2: onParserFirstCallInit

 /**
  * @param Parser $parser
  */
 public static function onParserFirstCallInit($parser)
 {
     $parser->setFunctionHook('stoolsformlink', 'stools::formlink');
     $parser->setFunctionHook('stoolsmoddate', 'stools::moddate');
     $parser->setFunctionHook('stoolseditorlist', 'stools::editorlist');
     $parser->setFunctionHook('stoolsprintbtn', 'stools::sprintbtn');
     $parser->setFunctionHook('stoolsmakebtn', 'stools::makebtn');
 }
开发者ID:vedmaka,项目名称:SettleInSkin,代码行数:11,代码来源:stools.hooks.php

示例3: register

 /**
  * @param Parser $parser
  * @return void
  */
 public static function register($parser)
 {
     global $wgAllowDisplayTitle, $wgAllowSlowParserFunctions;
     # Syntax for arguments (see Parser::setFunctionHook):
     #  "name for lookup in localized magic words array",
     #  function callback,
     #  optional Parser::SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}}
     #    instead of {{#int:...}})
     $noHashFunctions = ['ns', 'nse', 'urlencode', 'lcfirst', 'ucfirst', 'lc', 'uc', 'localurl', 'localurle', 'fullurl', 'fullurle', 'canonicalurl', 'canonicalurle', 'formatnum', 'grammar', 'gender', 'plural', 'bidi', 'numberofpages', 'numberofusers', 'numberofactiveusers', 'numberofarticles', 'numberoffiles', 'numberofadmins', 'numberingroup', 'numberofedits', 'language', 'padleft', 'padright', 'anchorencode', 'defaultsort', 'filepath', 'pagesincategory', 'pagesize', 'protectionlevel', 'protectionexpiry', 'namespacee', 'namespacenumber', 'talkspace', 'talkspacee', 'subjectspace', 'subjectspacee', 'pagename', 'pagenamee', 'fullpagename', 'fullpagenamee', 'rootpagename', 'rootpagenamee', 'basepagename', 'basepagenamee', 'subpagename', 'subpagenamee', 'talkpagename', 'talkpagenamee', 'subjectpagename', 'subjectpagenamee', 'pageid', 'revisionid', 'revisionday', 'revisionday2', 'revisionmonth', 'revisionmonth1', 'revisionyear', 'revisiontimestamp', 'revisionuser', 'cascadingsources'];
     foreach ($noHashFunctions as $func) {
         $parser->setFunctionHook($func, [__CLASS__, $func], Parser::SFH_NO_HASH);
     }
     $parser->setFunctionHook('namespace', [__CLASS__, 'mwnamespace'], Parser::SFH_NO_HASH);
     $parser->setFunctionHook('int', [__CLASS__, 'intFunction'], Parser::SFH_NO_HASH);
     $parser->setFunctionHook('special', [__CLASS__, 'special']);
     $parser->setFunctionHook('speciale', [__CLASS__, 'speciale']);
     $parser->setFunctionHook('tag', [__CLASS__, 'tagObj'], Parser::SFH_OBJECT_ARGS);
     $parser->setFunctionHook('formatdate', [__CLASS__, 'formatDate']);
     if ($wgAllowDisplayTitle) {
         $parser->setFunctionHook('displaytitle', [__CLASS__, 'displaytitle'], Parser::SFH_NO_HASH);
     }
     if ($wgAllowSlowParserFunctions) {
         $parser->setFunctionHook('pagesinnamespace', [__CLASS__, 'pagesinnamespace'], Parser::SFH_NO_HASH);
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:29,代码来源:CoreParserFunctions.php

示例4: wfDynamicFunctions

/**
 * @param Parser $parser
 * @return bool
 */
function wfDynamicFunctions($parser)
{
    global $wgExtDynamicFunctions;
    if (empty($wgExtDynamicFunctions)) {
        $wgExtDynamicFunctions = new ExtDynamicFunctions();
    }
    $parser->setFunctionHook('arg', array(&$wgExtDynamicFunctions, 'arg'));
    $parser->setFunctionHook('ip', array(&$wgExtDynamicFunctions, 'ip'));
    $parser->setFunctionHook('rand', array(&$wgExtDynamicFunctions, 'rand'));
    $parser->setFunctionHook('skin', array(&$wgExtDynamicFunctions, 'skin'));
    return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:DynamicFunctions.php

示例5: loadTable

 /**
  * Loads the mapping table.
  */
 private function loadTable()
 {
     // no need to load multiple times.
     if ($this->loaded) {
         return;
     }
     $this->loaded = true;
     $title = Title::newFromText(self::$tablePageName);
     if (!$title->exists()) {
         return;
     }
     $tablePageRev = Revision::newFromTitle($title);
     if (is_object($tablePageRev)) {
         $tablePage = $tablePageRev->getText();
         global $wgUser;
         $parser = new Parser();
         $parser->setFunctionHook('tag_to_template', array($this, 'mg_tag_to_template'));
         // this will populate the 'map' variable
         // assuming of course that the page was edited with
         // {{#tag_to_template| ... }} instructions.
         $this->initPhase = true;
         $parser->parse($tablePage, $title, new ParserOptions($wgUser));
         $this->initPhase = false;
     }
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:28,代码来源:TagToTemplate.body.php

示例6: init

 static function init(Parser &$parser)
 {
     if (self::isEnabledFunction('this')) {
         // only register function if not disabled by configuration
         $parser->setFunctionHook('this', array('ParserFunThis', 'pfObj_this'), SFH_NO_HASH | SFH_OBJECT_ARGS);
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:8,代码来源:ParserFun.php

示例7: initParserFunction

 /**
  * Initialize the parser functions of the extension.
  * 
  * Currently only #serieslink
  * 
  * @param Parser $parser
  * @return bool 
  */
 public static function initParserFunction(&$parser)
 {
     // Create a function hook associating the "example" magic word with the
     // efExampleParserFunction_Render() function.
     $parser->setFunctionHook('serieslink', array('SPSUtils', 'renderSeriesLink'));
     // Return true so that MediaWiki continues to load extensions.
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:16,代码来源:SPSUtils.php

示例8: wfRespawnMapExtension_InstallParser

/**
 * @param Parser $parser
 * @return bool
 */
function wfRespawnMapExtension_InstallParser($parser)
{
    # register the extension with the WikiText parser
    # the first parameter is the name of the new tag.
    # the second parameter is the callback function for
    # processing the text between the tags
    $parser->setHook("respawnmap", "renderRespawnMap");
    $parser->setFunctionHook("imageurl", "imageURL");
    return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:RespawnMap.php

示例9: initFunction

 private static function initFunction(Parser &$parser, $name, $flags = 0)
 {
     global $egRegexFunDisabledFunctions;
     // only register function if not disabled by configuration
     if (!in_array($name, $egRegexFunDisabledFunctions)) {
         // all parser functions with prefix:
         $prefix = $flags & SFH_OBJECT_ARGS ? 'pfObj_' : 'pf_';
         $functionCallback = array(__CLASS__, $prefix . $name);
         $parser->setFunctionHook($name, $functionCallback, $flags);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:RegexFun.php

示例10: onParserFirstCallInit

 public static function onParserFirstCallInit(Parser &$parser)
 {
     // When the parser sees the <sample> tag, it executes
     // the wfSampleRender function (see below)
     $parser->setHook('in', 'NumerAlpha::renderNumeralTag');
     $parser->setHook('ia', 'NumerAlpha::renderAlphaTag');
     $parser->setHook('ir', 'NumerAlpha::renderRomanTag');
     // Always return true from this function. The return value does not denote
     // success or otherwise have meaning - it just must always be true.
     self::$listTypes = array(wfMessage('ext-numeralpha-list-type-numeral')->text() => "numeral", wfMessage('ext-numeralpha-list-type-alpha')->text() => "alpha", wfMessage('ext-numeralpha-list-type-roman')->text() => "roman");
     $parser->setFunctionHook('counter', array('NumerAlpha', 'renderCounter'), SFH_OBJECT_ARGS);
     return true;
 }
开发者ID:emanspeaks,项目名称:mediawiki-extensions-NumerAlpha,代码行数:13,代码来源:NumerAlpha.class.php

示例11: init

	static function init( Parser &$parser ) {
		// optional SFH_NO_HASH to omit the hash '#' from function names
		$parser->setFunctionHook( self::MAG_SUBPAGETITLE,     array( __CLASS__, 'pf_subpagetitle' ),     SFH_NO_HASH );
		$parser->setFunctionHook( self::MAG_SUBPAGES,         array( __CLASS__, 'pf_subpages' ),         SFH_NO_HASH );
		$parser->setFunctionHook( self::MAG_PARENTPAGES,      array( __CLASS__, 'pf_parentpages' ),      SFH_NO_HASH );
		$parser->setFunctionHook( self::MAG_SIBLINGPAGES,     array( __CLASS__, 'pf_siblingpages' ),     SFH_NO_HASH );
		$parser->setFunctionHook( self::MAG_SUBPAGELEVEL,     array( __CLASS__, 'pf_subpagelevel' ),     SFH_NO_HASH );
		$parser->setFunctionHook( self::MAG_NUMBEROFSUBPAGES, array( __CLASS__, 'pf_numberofsubpages' ), SFH_NO_HASH );
		$parser->setFunctionHook( self::MAG_TOPLEVELPAGE,     array( __CLASS__, 'pf_toplevelpage' ),     SFH_NO_HASH );
		
		return true;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:12,代码来源:SubpageFun.php

示例12: wfYouTube

/**
 * @param Parser $parser
 * @return bool
 */
function wfYouTube($parser)
{
    $parser->setHook('youtube', 'embedYouTube');
    $parser->setHook('gvideo', 'embedGoogleVideo');
    $parser->setHook('aovideo', 'embedArchiveOrgVideo');
    $parser->setHook('aoaudio', 'embedArchiveOrgAudio');
    $parser->setHook('wegame', 'embedWeGame');
    $parser->setHook('tangler', 'embedTangler');
    $parser->setHook('gtrailer', 'embedGametrailers');
    $parser->setHook('nicovideo', 'embedNicovideo');
    $parser->setHook('ggtube', 'embedGoGreenTube');
    $parser->setHook('cgamer', 'embedCrispyGamer');
    $parser->setHook('longtail', 'embedLongtailVideo');
    $parser->setFunctionHook('youtube', 'wfParserFunction_youTube');
    return true;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:20,代码来源:YouTube.php

示例13: setup

 public static function setup(\Parser &$parser)
 {
     if (!array_key_exists('SemanticRating_DefaultMax', $GLOBALS)) {
         $GLOBALS['SemanticRating_DefaultMax'] = 5;
     }
     if (!array_key_exists('SemanticRating_CSSSelector', $GLOBALS)) {
         $GLOBALS['SemanticRating_CSSSelector'] = "#firstHeading";
     }
     $imagepath = $GLOBALS['wgServer'] . $GLOBALS['wgScriptPath'] . "/extensions/SemanticRating/images/";
     $renderer = new SemanticRatingHtmlRenderer($imagepath);
     $parser->setFunctionHook('rating', function ($parser) use($renderer) {
         return $renderer->renderInline($parser, func_get_args());
     });
     $parser->setFunctionHook('ratingBeforeTitle', function ($parser) use($renderer) {
         return $renderer->renderBeforeTitle($parser, func_get_args());
     });
     $parser->setFunctionHook('ratingAfterTitle', function ($parser) use($renderer) {
         return $renderer->renderAfterTitle($parser, func_get_args());
     });
     SemanticRatingFormInput::setImagePath($imagepath);
     $GLOBALS['sfgFormPrinter']->registerInputType('SemanticRatingFormInput');
     return true;
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:23,代码来源:SemanticRating.class.php

示例14: initFunction

 private static function initFunction(Parser &$parser, $name, $flags = 0)
 {
     // all parser functions with prefix:
     $prefix = $flags & SFH_OBJECT_ARGS ? 'pfObj_' : 'pf_';
     $functionCallback = array(__CLASS__, $prefix . $name);
     $parser->setFunctionHook($name, $functionCallback, $flags);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:Arrays.php

示例15: onParserFirstCallInit

 /**
  * @param Parser $parser
  */
 public static function onParserFirstCallInit($parser)
 {
     $parser->setFunctionHook('customwatchlist', 'customWatchlist::render');
 }
开发者ID:vedmaka,项目名称:SettleIn_customWatchlist,代码行数:7,代码来源:customWatchlist.hooks.php


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