mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 23:05:31 +00:00
ae8360f84a
I was particularly suprised by the conditions that checked if `$parser->extCite !== $this`. This can never happen. Maybe it was possible in a very old version of this code, but it is not any more. Change-Id: I049ff4109a747eb9dbf325c24cf20f65753827dd
60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
|
|
class CiteParserHooks {
|
|
|
|
/**
|
|
* @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;
|
|
// Clear the state, making sure it will actually work.
|
|
$cite->mInCite = false;
|
|
$cite->mInReferences = false;
|
|
$cite->clearState();
|
|
|
|
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(), $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(), $text );
|
|
}
|
|
|
|
}
|