mediawiki-extensions-Cite/includes/CiteParserHooks.php
2019-11-19 14:54:11 +00:00

70 lines
1.6 KiB
PHP

<?php
/**
* @license GPL-2.0-or-later
*/
class CiteParserHooks {
/**
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit
*
* @param Parser $parser
*/
public static function onParserFirstCallInit( Parser $parser ) {
$parser->extCite = new Cite();
CiteParserTagHooks::initialize( $parser );
}
/**
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserClearState
*
* @param Parser $parser
*/
public static function onParserClearState( Parser $parser ) {
/** @var Cite $cite */
$cite = $parser->extCite;
$cite->clearState();
}
/**
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserCloned
*
* @param Parser $parser
*/
public static function onParserCloned( Parser $parser ) {
$parser->extCite = clone $parser->extCite;
/** @var Cite $cite */
$cite = $parser->extCite;
$cite->clearState( 'force' );
CiteParserTagHooks::initialize( $parser );
}
/**
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterParse
*
* @param Parser $parser
* @param string &$text
* @param StripState $stripState
*/
public static function onParserAfterParse( Parser $parser, &$text, $stripState ) {
/** @var Cite $cite */
$cite = $parser->extCite;
$cite->checkRefsNoReferences( true, $parser->getOptions(), $parser->getOutput(), $text );
}
/**
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserBeforeTidy
*
* @param Parser $parser
* @param string &$text
*/
public static function onParserBeforeTidy( Parser $parser, &$text ) {
/** @var Cite $cite */
$cite = $parser->extCite;
$cite->checkRefsNoReferences( false, $parser->getOptions(), $parser->getOutput(), $text );
}
}