mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-09-24 10:50:13 +00:00
* Wrote error messages for the internal errors
* Hook into Parser::clearState() and clear my state when it does
This commit is contained in:
parent
26e14facce
commit
837fb7cd49
24
Cite.php
24
Cite.php
|
@ -53,9 +53,18 @@ function wfCite() {
|
|||
/*
|
||||
Debug & errors
|
||||
*/
|
||||
|
||||
// Internal errors
|
||||
'cite_croak' => 'Cite croaked; $1: $2',
|
||||
|
||||
'cite_error_' . CITE_ERROR_STR_INVALID => 'Internal error; invalid $str',
|
||||
'cite_error_' . CITE_ERROR_KEY_INVALID_1 => 'Internal error; invalid key',
|
||||
'cite_error_' . CITE_ERROR_KEY_INVALID_2 => 'Internal error; invalid key',
|
||||
'cite_error_' . CITE_ERROR_STACK_INVALID_INPUT => 'Internal error; invalid stack key',
|
||||
|
||||
// User errors
|
||||
'cite_error' => 'Cite error $1; $2',
|
||||
|
||||
'cite_error_' . CITE_ERROR_REF_NUMERIC_KEY => 'Invalid call; expecting a non-integer key',
|
||||
'cite_error_' . CITE_ERROR_REF_NO_KEY => 'Invalid call; no key specified',
|
||||
'cite_error_' . CITE_ERROR_REF_TOO_MANY_KEYS => 'Invalid call; too many keys specified',
|
||||
|
@ -456,14 +465,27 @@ function wfCite() {
|
|||
$this->mParserOptions = new ParserOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets run when Parser::clearState() gets run, since we don't
|
||||
* want the counts to transcend pages and other instances
|
||||
*/
|
||||
function clearState() {
|
||||
$this->mOutCnt = $this->mInCnt = 0;
|
||||
$this->mRefs = array();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the parser hooks
|
||||
*/
|
||||
function setHooks() {
|
||||
global $wgParser;
|
||||
global $wgParser, $wgHooks;
|
||||
|
||||
$wgParser->setHook( 'ref' , array( &$this, 'ref' ) );
|
||||
$wgParser->setHook( 'references' , array( &$this, 'references' ) );
|
||||
|
||||
$wgHooks['ParserClearState'][] = array( &$this, 'clearState' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue