http://www.mediawiki.org/wiki/Special:Code/MediaWiki/83213

Revision: 83213
Author:   janpaul123
Date:     2011-03-04 11:45:22 +0000 (Fri, 04 Mar 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/extensions/Cite/Cite_body.php

Modified: trunk/extensions/Cite/Cite_body.php
===================================================================
--- trunk/extensions/Cite/Cite_body.php 2011-03-04 11:36:47 UTC (rev 83212)
+++ trunk/extensions/Cite/Cite_body.php 2011-03-04 11:45:22 UTC (rev 83213)
@@ -71,6 +71,12 @@
         * @var int
         */
        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
@@ -151,6 +157,7 @@
                if ( $this->mInCite ) {
                        return htmlspecialchars( "<ref>$str</ref>" );
                } else {
+                       $this->mCallCnt++;
                        $this->mInCite = true;
                        $ret = $this->guardedRef( $str, $argv, $parser );
                        $this->mInCite = false;
@@ -507,6 +514,7 @@
                                return htmlspecialchars( 
"<references>$str</references>" );
                        }
                } else {
+                       $this->mCallCnt++;
                        $this->mInReferences = true;
                        $ret = $this->guardedReferences( $str, $argv, $parser );
                        $this->mInReferences = false;
@@ -984,6 +992,7 @@
                $this->mGroupCnt = array();
                $this->mOutCnt = - 1;
                $this->mInCnt = 0;
+               $this->mCallCnt = 0;
                $this->mRefs = array();
                $this->mReferencesErrors = array();
                $this->mRefCallStack = array();
@@ -1015,11 +1024,11 @@
        }
        
        /**
-        * 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.
         */
-       function checkAnyRefs( &$output ) {
-               return ( count( $this->mRefs ) <= 0 );
+       function checkAnyCalls( &$output ) {
+               return ( $this->mCallCnt <= 0 );
        }
 
        /**
@@ -1033,7 +1042,7 @@
 
                        $wgHooks['ParserClearState'][] = array( 
self::$instance, 'clearState' );
                        $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( 'references' , array( self::$instance, 
'references' ) );


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to