mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-12-11 15:26:24 +00:00
Make Cite properly register to any parser instead of just $wgParser.
Makes CiteParserTests work with r82867 code.
This commit is contained in:
parent
90a8629d1d
commit
286a80efc1
10
Cite.php
10
Cite.php
|
@ -43,9 +43,13 @@ $wgAllowCiteGroups = true;
|
|||
*/
|
||||
$wgCiteCacheReferences = false;
|
||||
|
||||
function wfCite() {
|
||||
new Cite;
|
||||
return true;
|
||||
/**
|
||||
* Performs the hook registration.
|
||||
* Note that several extensions (and even core!) try to detect if Cite is
|
||||
* installed by looking for wfCite().
|
||||
*/
|
||||
function wfCite( $parser ) {
|
||||
return Cite::setHooks( $parser );
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
|
|
@ -45,7 +45,7 @@ class Cite {
|
|||
* </code>
|
||||
*
|
||||
* This works because:
|
||||
* * PHP's datastructures are guarenteed to be returned in the
|
||||
* * PHP's datastructures are guaranteed to be returned in the
|
||||
* order that things are inserted into them (unless you mess
|
||||
* with that)
|
||||
* * User supplied keys can't be integers, therefore avoiding
|
||||
|
@ -133,14 +133,10 @@ class Cite {
|
|||
*/
|
||||
var $mRefCallStack = array();
|
||||
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Variable holding the singleton.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->setHooks();
|
||||
}
|
||||
static protected $instance = null;
|
||||
|
||||
/**#@+ @access private */
|
||||
|
||||
|
@ -1021,14 +1017,19 @@ class Cite {
|
|||
/**
|
||||
* Initialize the parser hooks
|
||||
*/
|
||||
function setHooks() {
|
||||
global $wgParser, $wgHooks;
|
||||
static function setHooks( $parser ) {
|
||||
global $wgHooks;
|
||||
|
||||
$wgParser->setHook( 'ref' , array( &$this, 'ref' ) );
|
||||
$wgParser->setHook( 'references' , array( &$this, 'references' ) );
|
||||
if ( !self::$instance ) {
|
||||
self::$instance = new self();
|
||||
|
||||
$wgHooks['ParserClearState'][] = array( &$this, 'clearState' );
|
||||
$wgHooks['ParserBeforeTidy'][] = array( &$this, 'checkRefsNoReferences' );
|
||||
$wgHooks['ParserClearState'][] = array( self::$instance, 'clearState' );
|
||||
$wgHooks['ParserBeforeTidy'][] = array( self::$instance, 'checkRefsNoReferences' );
|
||||
}
|
||||
$parser->setHook( 'ref' , array( self::$instance, 'ref' ) );
|
||||
$parser->setHook( 'references' , array( self::$instance, 'references' ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue