/** * 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; }
/** * @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'); }
/** * @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); } }
/** * @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; }
/** * 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; } }
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; }
/** * 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; }
/** * @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; }
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); } }
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; }
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; }
/** * @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; }
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; }
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); }
/** * @param Parser $parser */ public static function onParserFirstCallInit($parser) { $parser->setFunctionHook('customwatchlist', 'customWatchlist::render'); }
function parserHook(Parser $parser) { $parser->setHook('summary', 'ArticleSummary::summaryTag'); $parser->setFunctionHook('summary', 'ArticleSummary::summaryFunction'); return true; }
/** * Register parser-functions */ public static function onParserFirstCallInit(Parser $parser) { $parser->setFunctionHook('tags', __CLASS__ . '::expandTags'); $parser->setFunctionHook('nextpost', __CLASS__ . '::expandNext'); $parser->setFunctionHook('prevpost', __CLASS__ . '::expandPrev'); return true; }
function wfLyricWikiParserFunctions(Parser $parser) { $parser->setFunctionHook('sterilizeTitle', 'wfLyricWikiSterilizeTitle'); return true; }
/** * Register parser-functions */ public static function onParserFirstCallInit(Parser $parser) { $parser->setFunctionHook('odmap', __CLASS__ . '::expandOdMap'); return true; }
/** * Function to hook up the coordinate rendering functions to the parser. * * @since 0.4 * * @param Parser $wgParser * * @return true */ public function init(Parser &$wgParser) { $className = get_class($this); $first = true; foreach ($this->getNames() as $name) { if ($first) { self::$registeredHooks[$name] = $className; $first = false; } if ($this->forTagExtensions) { $wgParser->setHook($name, array(new ParserHookCaller($className, 'renderTag'), 'runHook')); } if ($this->forParserFunctions) { $wgParser->setFunctionHook($name, array(new ParserHookCaller($className, 'renderFunction'), 'runHook')); } } return true; }
public static function init(Parser $wgParser) { $wgParser->setHook('seo', 'WikiSEO::parserTag'); $wgParser->setFunctionHook('seo', 'WikiSEO::parserFunction'); return true; }
/** * @param Parser $parser */ public static function onParserFirstCallInit($parser) { $parser->setFunctionHook('authorrating', 'authorRating::render'); }
private static function initFunction(Parser &$parser, $name) { global $egLoopsEnabledFunctions; // don't register parser function if disabled by configuration: if (!in_array($name, $egLoopsEnabledFunctions)) { return; } $functionCallback = array(__CLASS__, 'pfObj_' . $name); $parser->setFunctionHook($name, $functionCallback, SFH_OBJECT_ARGS); }
function efOpeningHoursInit(Parser $parser) { $parser->setHook('openinghours', array('OpeningHours', 'ParserHook')); $parser->setFunctionHook('openinghours', array('OpeningHours', 'ParserFunction')); return true; }
/** * Hooks parserFunctionHook() to ParserFirstCallInit * @param Parser $parser Parser object * @return bool Always true to continue loading other hooks. */ public static function setupParserHook(\Parser $parser) { $parser->setFunctionHook('infoboxbuilder', '\\InfoboxBuilder\\InfoboxBuilderHooks::parserFunctionHook', SFH_OBJECT_ARGS); return true; }
function efOpenGraphMetaParserInit(Parser $parser) { $parser->setFunctionHook('setmainimage', 'efSetMainImagePF'); return true; }
function wfExampleParserASvideo_Setup(Parser $parser) { # Set a function hook associating the "example" magic word with our function $parser->setFunctionHook('watch', 'wfExampleParserASvideo_Render'); return true; }
public static function parserFirstCallInit(Parser &$parser) { $parser->setFunctionHook('imgw', array('ExtImageSizeInfoFunctionsHooks', 'imageWidth')); $parser->setFunctionHook('imgh', array('ExtImageSizeInfoFunctionsHooks', 'imageHeight')); return true; }
/** * Hook to setup parser function {{NUMBEROFVOTESPAGE:<page>}} * * @param Parser $parser * @return bool */ static function setupNumberOfVotesPageParser(&$parser) { $parser->setFunctionHook('NUMBEROFVOTESPAGE', 'VoteHooks::getNumberOfVotesPageParser', Parser::SFH_NO_HASH); return true; }
private static function initFunction(Parser &$parser, $name, $functionCallback = null, $flags = 0) { if ($functionCallback === null) { // prefix parser functions with 'pf_' $functionCallback = array(__CLASS__, 'pf_' . $name); } global $egVariablesDisabledFunctions; // register function only if not disabled by configuration: if (!in_array($name, $egVariablesDisabledFunctions)) { $parser->setFunctionHook($name, $functionCallback, $flags); } }