mediawiki-extensions-Cite/includes/CiteParserTagHooks.php
Thiemo Kreuz ae8360f84a Move some glue code from Cite to the Cite…Hooks classes
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
2019-11-07 09:48:08 +01:00

50 lines
1.3 KiB
PHP

<?php
class CiteParserTagHooks {
/**
* Enables the two <ref> and <references> tags.
*
* @param Parser $parser
*/
public static function initialize( Parser $parser ) {
$parser->setHook( 'ref', 'CiteParserTagHooks::ref' );
$parser->setHook( 'references', 'CiteParserTagHooks::references' );
}
/**
* Parser hook for the <ref> tag.
*
* @param string|null $content Raw wikitext content of the <ref> tag.
* @param string[] $attributes
* @param Parser $parser
* @param PPFrame $frame
*
* @return string
*/
public static function ref( $content, array $attributes, Parser $parser, PPFrame $frame ) {
/** @var Cite $cite */
$cite = $parser->extCite;
// @phan-suppress-next-line SecurityCheck-XSS False positive
return $cite->ref( $content, $attributes, $parser, $frame );
}
/**
* Parser hook for the <references> tag.
*
* @param string|null $content Raw wikitext content of the <references> tag.
* @param string[] $attributes
* @param Parser $parser
* @param PPFrame $frame
*
* @return string
*/
public static function references( $content, array $attributes, Parser $parser, PPFrame $frame ) {
/** @var Cite $cite */
$cite = $parser->extCite;
// @phan-suppress-next-line SecurityCheck-XSS False positive
return $cite->references( $content, $attributes, $parser, $frame );
}
}