| 1 |
<?php |
| 2 |
|
| 3 |
namespace Cite\Hooks; |
| 4 |
|
| 5 |
use Cite\Cite; |
| 6 |
use MediaWiki\Config\Config; |
| 7 |
use MediaWiki\Hook\ParserAfterParseHook; |
| 8 |
use MediaWiki\Hook\ParserClearStateHook; |
| 9 |
use MediaWiki\Hook\ParserClonedHook; |
| 10 |
use MediaWiki\Hook\ParserFirstCallInitHook; |
| 11 |
use MediaWiki\Parser\Parser; |
| 12 |
use MediaWiki\Parser\StripState; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
class CiteParserHooks implements |
| 18 |
ParserFirstCallInitHook, |
| 19 |
ParserClearStateHook, |
| 20 |
ParserClonedHook, |
| 21 |
ParserAfterParseHook |
| 22 |
{ |
| 23 |
|
| 24 |
private CiteParserTagHooks $citeParserTagHooks; |
| 25 |
|
| 26 |
public function __construct( |
| 27 |
Config $config |
| 28 |
) { |
| 29 |
$this->citeParserTagHooks = new CiteParserTagHooks( $config ); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public function onParserFirstCallInit( $parser ) { |
| 38 |
$this->citeParserTagHooks->register( $parser ); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public function onParserClearState( $parser ) { |
| 47 |
$parser->extCite = null; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public function onParserCloned( $parser ) { |
| 56 |
$parser->extCite = null; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public function onParserAfterParse( $parser, &$text, $stripState ) { |
| 67 |
if ( isset( $parser->extCite ) ) { |
| 68 |
|
| 69 |
$cite = $parser->extCite; |
| 70 |
$text .= $cite->checkRefsNoReferences( $parser, $parser->getOptions()->getIsSectionPreview() ); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
} |