function sbParserInit(Parser $parser)
{
    // Register <scratchblocks> tag
    $parser->setHook('scratchblocks', 'sbRenderTag');
    $parser->setHook('sb', 'sbRenderInlineTag');
    return true;
}
Example #2
1
 static function onParserFirstCallSetup(Parser $parser)
 {
     if (!ExtensionRegistry::getInstance()->isLoaded('Math')) {
         die("The DMath extension requires the Math extension, please include it.");
     }
     $parser->setHook('dmath', 'DMathParse::dmathTagHook');
     $parser->setHook('math', 'DMathParse::mathTagHook');
 }
 /**
  * Set up our custom parser hooks when initializing parser.
  *
  * @param Parser $parser
  * @return boolean hook return value
  */
 public static function onParserFirstCallInit($parser)
 {
     $parser->setHook('pagelist', array(__CLASS__, 'renderPageList'));
     $parser->setHook('pages', array(__CLASS__, 'renderPages'));
     $parser->setHook('pagequality', array(__CLASS__, 'pageQuality'));
     return true;
 }
 /**
  *
  * @param Parser $parser
  * @return boolean
  */
 public function onParserFirstCallInit(&$parser)
 {
     $parser->setHook('bs:countarticles', array(&$this, 'onMagicWordBsCountArticles'));
     $parser->setHook('bs:countusers', array(&$this, 'onMagicWordBsCountUsers'));
     $parser->setHook('bs:countcharacters', array(&$this, 'onMagicWordBsCountCharacters'));
     return true;
 }
Example #5
0
 public static function parserInit(Parser $parser)
 {
     Hooks::register('ParserBeforeStrip', self::class . '::markBlockMathTags');
     $parser->setHook('math', self::class . '::mathTag');
     $parser->setHook('nomathjax', self::class . '::noMathJaxTag');
     Hooks::register('ParserAfterTidy', self::class . '::afterTidy');
     Hooks::register('BeforePageDisplay', self::class . '::Inject_JS');
     return true;
 }
Example #6
0
 /**
  * @param Parser $parser
  * @return void
  */
 public static function register($parser)
 {
     global $wgRawHtml;
     $parser->setHook('pre', array(__CLASS__, 'pre'));
     $parser->setHook('nowiki', array(__CLASS__, 'nowiki'));
     $parser->setHook('gallery', array(__CLASS__, 'gallery'));
     if ($wgRawHtml) {
         $parser->setHook('html', array(__CLASS__, 'html'));
     }
 }
Example #7
0
/**
 * @param Parser $parser
 * @return bool
 */
function wfEventCountdownExtension($parser)
{
    # register the extension with the WikiText parser
    # the first parameter is the name of the new tag.
    # In this case it defines the tag <example> ... </example>
    # the second parameter is the callback function for
    # processing the text between the tags
    $parser->setHook('daysuntil', 'runDaysUntil');
    $parser->setHook('eventcountdown', 'runShowEventCountdown');
    return true;
}
Example #8
0
 /**
  * @param Parser $parser
  * @return void
  */
 public static function register($parser)
 {
     global $wgRawHtml;
     $parser->setHook('pre', [__CLASS__, 'pre']);
     $parser->setHook('nowiki', [__CLASS__, 'nowiki']);
     $parser->setHook('gallery', [__CLASS__, 'gallery']);
     $parser->setHook('indicator', [__CLASS__, 'indicator']);
     if ($wgRawHtml) {
         $parser->setHook('html', [__CLASS__, 'html']);
     }
 }
function wfSampleParserInit(Parser &$parser)
{
    // This does <setprop>Some random text</setprop>
    // And then <getprop/> to retrieve a prop
    // Or <getprop page="somepage"> to retrieve for
    // something other than the current page.
    $parser->setHook('getprop', 'wfSampleGetProp');
    $parser->setHook('setprop', 'wfSampleSetProp');
    // Always return true from this function. The return value does not denote
    // success or otherwise have meaning - it just must always be true.
    return true;
}
 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;
 }
 public static function onParserFirstCallInit(Parser &$parser)
 {
     // Register the hook with the parser
     $parser->setHook('searchbox', array('SearchBoxesHooks', 'render'));
     // Continue
     return true;
 }
 /**
  * @brief This function set parseTag hook
  */
 public static function onParserFirstCallInit(Parser &$parser)
 {
     wfProfileIn(__METHOD__);
     $parser->setHook(CHAT_TAG, array(__CLASS__, "parseTag"));
     wfProfileOut(__METHOD__);
     return true;
 }
 /**
  * @brief This function set renderTag hook
  * @param Parser parser
  * @return true
  */
 public function onParserFirstCallInit(Parser $parser)
 {
     wfProfileIn(__METHOD__);
     $parser->setHook('hubspopularvideos', array($this, 'renderTag'));
     wfProfileOut(__METHOD__);
     return true;
 }
 /**
  * Sets up this extensions parser functions.
  *
  * @access	public
  * @param	object	Parser object passed as a reference.
  * @return	boolean	true
  */
 public static function onParserFirstCallInit(Parser &$parser)
 {
     foreach (self::$tags as $hook => $method) {
         $parser->setHook($hook, array(__CLASS__, $method));
     }
     return true;
 }
Example #15
0
/**
 * Setup parser hook
 *
 * @param Parser $parser
 * @return bool
 */
function efWidgetTagSetup(Parser $parser)
{
    global $wgHooks;
    $parser->setHook('widget', 'efWidgetTagRender');
    $wgHooks['ParserAfterTidy'][] = 'efWidgetTagReplaceMarkers';
    return true;
}
 public static function register(Parser &$parser)
 {
     // Register the hook with the parser
     $parser->setHook('inputbox', array('InputBoxHooks', 'render'));
     // Continue
     return true;
 }
function SmartsheetParserInit(Parser &$parser)
{
    global $wgSmartsheetTagName;
    // Register the desired tag
    $parser->setHook($wgSmartsheetTagName, 'SmartsheetRender');
    // Let the other hooks keep processing
    return TRUE;
}
 /**
  * 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;
 }
Example #19
0
 /**
  * @dataProvider provideBadNames
  * @expectedException MWException
  * @covers Parser::setHook
  */
 public function testBadTagHooks($tag)
 {
     global $wgParserConf, $wgContLang;
     $parser = new Parser($wgParserConf);
     $parser->setHook($tag, array($this, 'tagCallback'));
     $parser->parse("Foo<{$tag}>Bar</{$tag}>Baz", Title::newFromText('Test'), ParserOptions::newFromUserAndLang(new User(), $wgContLang));
     $this->fail('Exception not thrown.');
 }
 /**
  * Register the configured parser tags with default tag renderer.
  */
 public static function onParserFirstCallInit(Parser &$parser)
 {
     global $wgJsonDataDefaultTagHandlers;
     foreach ($wgJsonDataDefaultTagHandlers as $tag) {
         $parser->setHook($tag, __CLASS__ . '::jsonTagRender');
     }
     return true;
 }
Example #21
0
 /**
  * Register parser hooks for all supported Facebook XFBML tags
  *
  * @param Parser $parser
  *
  * @throws MWException
  */
 public static function registerHooks(Parser $parser)
 {
     foreach (self::$supportedTags as $tag) {
         $parser->setHook($tag, function ($text, $args, $parser) use($tag) {
             return FacebookClientXFBML::parserHook($tag, $text, $args, $parser);
         });
     }
 }
Example #22
0
 /**
  * @dataProvider provideBadNames
  * @expectedException MWException
  */
 function testBadTagHooks($tag)
 {
     global $wgParserConf;
     $parser = new Parser($wgParserConf);
     $parser->setHook($tag, array($this, 'tagCallback'));
     $parser->parse("Foo<{$tag}>Bar</{$tag}>Baz", Title::newFromText('Test'), new ParserOptions());
     $this->fail('Exception not thrown.');
 }
Example #23
0
/**
 * @param Parser $parser
 * @return bool
 */
function wfVerbatimExtension($parser)
{
    // register the extension with the WikiText parser
    // the first parameter is the name of the new tag. In this case it defines the tag <example> ... </example>
    // the second parameter is the callback function for processing the text between the tags
    $parser->setHook("verbatim", "renderVerbatim");
    return true;
}
Example #24
0
/**
 * @param Parser $parser
 * @return bool
 */
function wfSpoilerExtension($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("spoiler", "renderSpoiler");
    return true;
}
Example #25
0
function harmlessTags(Parser $parser)
{
    // When the parser sees the <sample> tag, it executes
    // the wfSampleRender function (see below)
    $parser->setHook('label', 'harmlessTagsRenderLabel');
    // Always return true from this function. The return value does not denote
    // success or otherwise have meaning - it just must always be true.
    return true;
}
Example #26
0
/**
 * Init routine.
 *
 * @param $parser Parser Mediawiki parser
 *
 * @return true if initialisation was successful, false otherwise.
 */
function efScoreExtension(Parser &$parser)
{
    global $wgUseImageMagick, $wgScoreTrim;
    if ($wgScoreTrim === null) {
        // Default to if we use Image Magick, since it requires Image Magick.
        $wgScoreTrim = $wgUseImageMagick;
    }
    $parser->setHook('score', 'Score::render');
    return true;
}
Example #27
0
/**
 * @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;
}
Example #28
0
 static function RunMathJax(Parser $parser)
 {
     $parser->setHook('nomathjax', 'MathJax_Parser::NoMathJax');
     global $wgHooks;
     $wgHooks['ParserBeforeStrip'][] = 'MathJax_Parser::RemoveMathTags';
     $wgHooks['InternalParseBeforeLinks'][] = 'MathJax_Parser::ReplaceByMarkers';
     $wgHooks['ParserAfterTidy'][] = 'MathJax_Parser::RemoveMarkers';
     $wgHooks['BeforePageDisplay'][] = 'MathJax_Parser::Inject_JS';
     return true;
 }
Example #29
0
function efHideTagsSetup(Parser $parser)
{
    $parser->setHook('vote', 'efHideTags');
    $parser->setHook('comments', 'efHideTags');
    $parser->setHook('rhtml', 'efHideTags');
    $parser->setHook('pageby', 'efHideTags');
    $parser->setHook('pageTools', 'efHideTags');
    /* copy above line and change tag name to hide additional tags */
    $parser->setHook('loggedin', 'efJustPrintTags');
    $parser->setHook('loggedout', 'efJustPrintTags');
    /* copy above line and change tag name to just print additional tags */
    return true;
}
Example #30
-1
/**
 * Set hooks for each of the three parser tags
 * @param Parser $parser reference to MediaWiki Parser object
 */
function wfMainPageTag(&$parser)
{
    $parser->setHook('mainpage-rightcolumn-start', 'wfMainPageTag_rcs');
    $parser->setHook('mainpage-leftcolumn-start', 'wfMainPageTag_lcs');
    $parser->setHook('mainpage-endcolumn', 'wfMainPageTag_ec');
    return true;
}