2019-11-04 15:33:07 +00:00
|
|
|
<?php
|
|
|
|
|
2019-11-19 10:31:08 +00:00
|
|
|
/**
|
|
|
|
* @license GPL-2.0-or-later
|
|
|
|
*/
|
2019-11-04 15:33:07 +00:00
|
|
|
class CiteParserHooks {
|
|
|
|
|
2019-11-04 16:23:29 +00:00
|
|
|
/**
|
|
|
|
* @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 );
|
|
|
|
}
|
|
|
|
|
2019-11-04 15:33:07 +00:00
|
|
|
/**
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserClearState
|
|
|
|
*
|
|
|
|
* @param Parser $parser
|
|
|
|
*/
|
|
|
|
public static function onParserClearState( Parser $parser ) {
|
|
|
|
/** @var Cite $cite */
|
|
|
|
$cite = $parser->extCite;
|
2019-11-04 16:00:49 +00:00
|
|
|
$cite->clearState();
|
2019-11-04 15:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserCloned
|
|
|
|
*
|
|
|
|
* @param Parser $parser
|
|
|
|
*/
|
|
|
|
public static function onParserCloned( Parser $parser ) {
|
2019-11-04 16:00:49 +00:00
|
|
|
$parser->extCite = clone $parser->extCite;
|
|
|
|
|
2019-11-04 15:33:07 +00:00
|
|
|
/** @var Cite $cite */
|
|
|
|
$cite = $parser->extCite;
|
2019-11-19 11:01:10 +00:00
|
|
|
$cite->clearState( 'force' );
|
2019-11-04 16:00:49 +00:00
|
|
|
|
|
|
|
CiteParserTagHooks::initialize( $parser );
|
2019-11-04 15:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
2019-11-12 11:52:55 +00:00
|
|
|
$cite->checkRefsNoReferences( true, $parser->getOptions(), $parser->getOutput(), $text );
|
2019-11-04 15:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;
|
2019-11-12 11:52:55 +00:00
|
|
|
$cite->checkRefsNoReferences( false, $parser->getOptions(), $parser->getOutput(), $text );
|
2019-11-04 15:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|