mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-28 00:40:12 +00:00
Followup of r82891 and r82894. Fixes hook for InlineEditor, which forces a page reparse when either a <ref> or <references> tag shows up. Doesn't affect normal behaviour when not using InlineEditor.
This commit is contained in:
parent
1aac56bb83
commit
68ea91084d
|
@ -72,6 +72,12 @@ class Cite {
|
||||||
*/
|
*/
|
||||||
var $mInCnt = 0;
|
var $mInCnt = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counter to track the total number of (useful) calls to either the
|
||||||
|
* ref or references tag hook
|
||||||
|
*/
|
||||||
|
var $mCallCnt = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The backlinks, in order, to pass as $3 to
|
* The backlinks, in order, to pass as $3 to
|
||||||
* 'cite_references_link_many_format', defined in
|
* 'cite_references_link_many_format', defined in
|
||||||
|
@ -151,6 +157,7 @@ class Cite {
|
||||||
if ( $this->mInCite ) {
|
if ( $this->mInCite ) {
|
||||||
return htmlspecialchars( "<ref>$str</ref>" );
|
return htmlspecialchars( "<ref>$str</ref>" );
|
||||||
} else {
|
} else {
|
||||||
|
$this->mCallCnt++;
|
||||||
$this->mInCite = true;
|
$this->mInCite = true;
|
||||||
$ret = $this->guardedRef( $str, $argv, $parser );
|
$ret = $this->guardedRef( $str, $argv, $parser );
|
||||||
$this->mInCite = false;
|
$this->mInCite = false;
|
||||||
|
@ -507,6 +514,7 @@ class Cite {
|
||||||
return htmlspecialchars( "<references>$str</references>" );
|
return htmlspecialchars( "<references>$str</references>" );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$this->mCallCnt++;
|
||||||
$this->mInReferences = true;
|
$this->mInReferences = true;
|
||||||
$ret = $this->guardedReferences( $str, $argv, $parser );
|
$ret = $this->guardedReferences( $str, $argv, $parser );
|
||||||
$this->mInReferences = false;
|
$this->mInReferences = false;
|
||||||
|
@ -984,6 +992,7 @@ class Cite {
|
||||||
$this->mGroupCnt = array();
|
$this->mGroupCnt = array();
|
||||||
$this->mOutCnt = - 1;
|
$this->mOutCnt = - 1;
|
||||||
$this->mInCnt = 0;
|
$this->mInCnt = 0;
|
||||||
|
$this->mCallCnt = 0;
|
||||||
$this->mRefs = array();
|
$this->mRefs = array();
|
||||||
$this->mReferencesErrors = array();
|
$this->mReferencesErrors = array();
|
||||||
$this->mRefCallStack = array();
|
$this->mRefCallStack = array();
|
||||||
|
@ -1015,11 +1024,11 @@ class Cite {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook for the InlineEditor extension. If any reference is in the text, the entire
|
* Hook for the InlineEditor extension. If any ref or reference reference tag is in the text, the entire
|
||||||
* page should be reparsed, so we return false in that case.
|
* page should be reparsed, so we return false in that case.
|
||||||
*/
|
*/
|
||||||
function checkAnyRefs( &$output ) {
|
function checkAnyCalls( &$output ) {
|
||||||
return ( count( $this->mRefs ) <= 0 );
|
return ( $this->mCallCnt <= 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1033,7 +1042,7 @@ class Cite {
|
||||||
|
|
||||||
$wgHooks['ParserClearState'][] = array( self::$instance, 'clearState' );
|
$wgHooks['ParserClearState'][] = array( self::$instance, 'clearState' );
|
||||||
$wgHooks['ParserBeforeTidy'][] = array( self::$instance, 'checkRefsNoReferences' );
|
$wgHooks['ParserBeforeTidy'][] = array( self::$instance, 'checkRefsNoReferences' );
|
||||||
$wgHooks['InlineEditorPartialAfterParse'][] = array( self::$instance, 'checkAnyRefs' );
|
$wgHooks['InlineEditorPartialAfterParse'][] = array( self::$instance, 'checkAnyCalls' );
|
||||||
}
|
}
|
||||||
$parser->setHook( 'ref' , array( self::$instance, 'ref' ) );
|
$parser->setHook( 'ref' , array( self::$instance, 'ref' ) );
|
||||||
$parser->setHook( 'references' , array( self::$instance, 'references' ) );
|
$parser->setHook( 'references' , array( self::$instance, 'references' ) );
|
||||||
|
|
Loading…
Reference in a new issue