Index: trunk/extensions/Cite/Cite.php |
— | — | @@ -43,9 +43,13 @@ |
44 | 44 | */ |
45 | 45 | $wgCiteCacheReferences = false; |
46 | 46 | |
47 | | -function wfCite() { |
48 | | - new Cite; |
49 | | - return true; |
| 47 | +/** |
| 48 | + * Performs the hook registration. |
| 49 | + * Note that several extensions (and even core!) try to detect if Cite is |
| 50 | + * installed by looking for wfCite(). |
| 51 | + */ |
| 52 | +function wfCite( $parser ) { |
| 53 | + return Cite::setHooks( $parser ); |
50 | 54 | } |
51 | 55 | |
52 | 56 | /**#@-*/ |
Index: trunk/extensions/Cite/Cite_body.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | * </code> |
47 | 47 | * |
48 | 48 | * This works because: |
49 | | - * * PHP's datastructures are guarenteed to be returned in the |
| 49 | + * * PHP's datastructures are guaranteed to be returned in the |
50 | 50 | * order that things are inserted into them (unless you mess |
51 | 51 | * with that) |
52 | 52 | * * User supplied keys can't be integers, therefore avoiding |
— | — | @@ -133,14 +133,10 @@ |
134 | 134 | */ |
135 | 135 | var $mRefCallStack = array(); |
136 | 136 | |
137 | | - /**#@-*/ |
138 | | - |
139 | 137 | /** |
140 | | - * Constructor |
| 138 | + * Variable holding the singleton. |
141 | 139 | */ |
142 | | - function __construct() { |
143 | | - $this->setHooks(); |
144 | | - } |
| 140 | + static protected $instance = null; |
145 | 141 | |
146 | 142 | /**#@+ @access private */ |
147 | 143 | |
— | — | @@ -1021,14 +1017,19 @@ |
1022 | 1018 | /** |
1023 | 1019 | * Initialize the parser hooks |
1024 | 1020 | */ |
1025 | | - function setHooks() { |
1026 | | - global $wgParser, $wgHooks; |
| 1021 | + static function setHooks( $parser ) { |
| 1022 | + global $wgHooks; |
1027 | 1023 | |
1028 | | - $wgParser->setHook( 'ref' , array( &$this, 'ref' ) ); |
1029 | | - $wgParser->setHook( 'references' , array( &$this, 'references' ) ); |
| 1024 | + if ( !self::$instance ) { |
| 1025 | + self::$instance = new self(); |
1030 | 1026 | |
1031 | | - $wgHooks['ParserClearState'][] = array( &$this, 'clearState' ); |
1032 | | - $wgHooks['ParserBeforeTidy'][] = array( &$this, 'checkRefsNoReferences' ); |
| 1027 | + $wgHooks['ParserClearState'][] = array( self::$instance, 'clearState' ); |
| 1028 | + $wgHooks['ParserBeforeTidy'][] = array( self::$instance, 'checkRefsNoReferences' ); |
| 1029 | + } |
| 1030 | + $parser->setHook( 'ref' , array( self::$instance, 'ref' ) ); |
| 1031 | + $parser->setHook( 'references' , array( self::$instance, 'references' ) ); |
| 1032 | + |
| 1033 | + return true; |
1033 | 1034 | } |
1034 | 1035 | |
1035 | 1036 | /** |