Fix for bug 12726: make the internal OT_xxx constants class constants.
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 22 Jan 2008 10:47:44 +0000 (10:47 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 22 Jan 2008 10:47:44 +0000 (10:47 +0000)
includes/Parser.php
includes/Parser_OldPP.php

index c3b398d..209b712 100644 (file)
@@ -75,6 +75,13 @@ class Parser
 
        // Flags for preprocessToDom
        const PTD_FOR_INCLUSION = 1;
+
+       // Allowed values for $this->mOutputType
+       // Parameter to startExternalParse().
+       const OT_HTML = 1;
+       const OT_WIKI = 2;
+       const OT_PREPROCESS = 3;
+       const OT_MSG = 3;
        
        /**#@+
         * @private
@@ -253,9 +260,9 @@ class Parser
                $this->mOutputType = $ot;
                // Shortcut alias
                $this->ot = array(
-                       'html' => $ot == OT_HTML,
-                       'wiki' => $ot == OT_WIKI,
-                       'pre' => $ot == OT_PREPROCESS,
+                       'html' => $ot == self::OT_HTML,
+                       'wiki' => $ot == self::OT_WIKI,
+                       'pre' => $ot == self::OT_PREPROCESS,
                );
        }
 
@@ -328,7 +335,7 @@ class Parser
                        $this->mRevisionId = $revid;
                        $this->mRevisionTimestamp = null;
                }
-               $this->setOutputType( OT_HTML );
+               $this->setOutputType( self::OT_HTML );
                wfRunHooks( 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState ) );
                # No more strip!
                wfRunHooks( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) );
@@ -454,7 +461,7 @@ class Parser
        function preprocess( $text, $title, $options, $revid = null ) {
                wfProfileIn( __METHOD__ );
                $this->clearState();
-               $this->setOutputType( OT_PREPROCESS );
+               $this->setOutputType( self::OT_PREPROCESS );
                $this->mOptions = $options;
                $this->setTitle( $title );
                if( $revid !== null ) {
@@ -948,7 +955,7 @@ class Parser
 
        /**
         * Helper function for parse() that transforms wiki markup into
-        * HTML. Only called for $mOutputType == OT_HTML.
+        * HTML. Only called for $mOutputType == self::OT_HTML.
         *
         * @private
         */
@@ -2639,9 +2646,9 @@ class Parser
         * taking care to avoid infinite loops.
         *
         * Note that the substitution depends on value of $mOutputType:
-        *  OT_WIKI: only {{subst:}} templates
-        *  OT_PREPROCESS: templates but not extension tags
-        *  OT_HTML: all templates and extension tags
+        *  self::OT_WIKI: only {{subst:}} templates
+        *  self::OT_PREPROCESS: templates but not extension tags
+        *  self::OT_HTML: all templates and extension tags
         *
         * @param string $tex The text to transform
         * @param PPFrame $frame Object describing the arguments passed to the template
@@ -3597,7 +3604,7 @@ class Parser
        function preSaveTransform( $text, &$title, $user, $options, $clearState = true ) {
                $this->mOptions = $options;
                $this->setTitle( $title );
-               $this->setOutputType( OT_WIKI );
+               $this->setOutputType( self::OT_WIKI );
 
                if ( $clearState ) {
                        $this->clearState();
@@ -3749,7 +3756,7 @@ class Parser
                        $this->clearState();
                        $this->setTitle( $wgTitle );
                        $this->mOptions = new ParserOptions;
-                       $this->setOutputType = OT_PREPROCESS;
+                       $this->setOutputType = self::OT_PREPROCESS;
                }
 
                # FIXME: regex doesn't respect extension tags or nowiki
@@ -4540,7 +4547,7 @@ class Parser
                $this->clearState();
                $this->setTitle( $wgTitle ); // not generally used but removes an ugly failure mode
                $this->mOptions = new ParserOptions;
-               $this->setOutputType( OT_WIKI );
+               $this->setOutputType( self::OT_WIKI );
                $curIndex = 0;
                $outText = '';
                $frame = $this->getPreprocessor()->newFrame();
@@ -4767,7 +4774,7 @@ class Parser
        /**
         * strip/replaceVariables/unstrip for preprocessor regression testing
         */
-       function testSrvus( $text, $title, $options, $outputType = OT_HTML ) {
+       function testSrvus( $text, $title, $options, $outputType = self::OT_HTML ) {
                $this->clearState();
                $this->mTitle = $title;
                $this->mOptions = $options;
@@ -4784,7 +4791,7 @@ class Parser
        }
 
        function testPreprocess( $text, $title, $options ) {
-               return $this->testSrvus( $text, $title, $options, OT_PREPROCESS );
+               return $this->testSrvus( $text, $title, $options, self::OT_PREPROCESS );
        }
 }
 
index f47dc00..c10de25 100644 (file)
@@ -30,6 +30,13 @@ class Parser_OldPP
        const COLON_STATE_COMMENTDASH = 6;
        const COLON_STATE_COMMENTDASHDASH = 7;
 
+       // Allowed values for $this->mOutputType
+       // Parameter to startExternalParse().
+       const OT_HTML = 1;
+       const OT_WIKI = 2;
+       const OT_PREPROCESS = 3;
+       const OT_MSG = 4;
+
        /**#@+
         * @private
         */
@@ -195,10 +202,10 @@ class Parser_OldPP
                $this->mOutputType = $ot;
                // Shortcut alias
                $this->ot = array(
-                       'html' => $ot == OT_HTML,
-                       'wiki' => $ot == OT_WIKI,
-                       'msg' => $ot == OT_MSG,
-                       'pre' => $ot == OT_PREPROCESS,
+                       'html' => $ot == self::OT_HTML,
+                       'wiki' => $ot == self::OT_WIKI,
+                       'msg' => $ot == self::OT_MSG,
+                       'pre' => $ot == self::OT_PREPROCESS,
                );
        }
 
@@ -246,7 +253,7 @@ class Parser_OldPP
                        $this->mRevisionId = $revid;
                        $this->mRevisionTimestamp = null;
                }
-               $this->setOutputType( OT_HTML );
+               $this->setOutputType( self::OT_HTML );
                wfRunHooks( 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState ) );
                $text = $this->strip( $text, $this->mStripState );
                wfRunHooks( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) );
@@ -372,7 +379,7 @@ class Parser_OldPP
        function preprocess( $text, $title, $options, $revid = null ) {
                wfProfileIn( __METHOD__ );
                $this->clearState();
-               $this->setOutputType( OT_PREPROCESS );
+               $this->setOutputType( self::OT_PREPROCESS );
                $this->mOptions = $options;
                $this->mTitle = $title;
                if( $revid !== null ) {
@@ -508,7 +515,7 @@ class Parser_OldPP
        function strip( $text, $state, $stripcomments = false , $dontstrip = array () ) {
                global $wgContLang;
                wfProfileIn( __METHOD__ );
-               $render = ($this->mOutputType == OT_HTML);
+               $render = ($this->mOutputType == self::OT_HTML);
 
                $uniq_prefix = $this->mUniqPrefix;
                $commentState = new ReplacementArray;
@@ -2758,9 +2765,9 @@ class Parser_OldPP
         * taking care to avoid infinite loops.
         *
         * Note that the substitution depends on value of $mOutputType:
-        *  OT_WIKI: only {{subst:}} templates
-        *  OT_MSG: only magic variables
-        *  OT_HTML: all templates and magic variables
+        *  self::OT_WIKI: only {{subst:}} templates
+        *  self::OT_MSG: only magic variables
+        *  self::OT_HTML: all templates and magic variables
         *
         * @param string $tex The text to transform
         * @param array $args Key-value pairs representing template parameters to substitute
@@ -2783,7 +2790,7 @@ class Parser_OldPP
                if ( !$argsOnly ) {
                        $braceCallbacks[2] = array( &$this, 'braceSubstitution' );
                }
-               if ( $this->mOutputType != OT_MSG ) {
+               if ( $this->mOutputType != self::OT_MSG ) {
                        $braceCallbacks[3] = array( &$this, 'argSubstitution' );
                }
                if ( $braceCallbacks ) {
@@ -2819,7 +2826,7 @@ class Parser_OldPP
                $varname = $wgContLang->lc($matches[1]);
                wfProfileIn( $fname );
                $skip = false;
-               if ( $this->mOutputType == OT_WIKI ) {
+               if ( $this->mOutputType == self::OT_WIKI ) {
                        # Do only magic variables prefixed by SUBST
                        $mwSubst =& MagicWord::get( 'subst' );
                        if (!$mwSubst->matchStartAndRemove( $varname ))
@@ -3380,7 +3387,7 @@ class Parser_OldPP
 
                if ( array_key_exists( $arg, $inputArgs ) ) {
                        $text = $inputArgs[$arg];
-               } else if (($this->mOutputType == OT_HTML || $this->mOutputType == OT_PREPROCESS ) &&
+               } else if (($this->mOutputType == self::OT_HTML || $this->mOutputType == self::OT_PREPROCESS ) &&
                null != $matches['parts'] && count($matches['parts']) > 0) {
                        $text = $matches['parts'][0];
                }
@@ -3736,7 +3743,7 @@ class Parser_OldPP
        function preSaveTransform( $text, &$title, $user, $options, $clearState = true ) {
                $this->mOptions = $options;
                $this->mTitle =& $title;
-               $this->setOutputType( OT_WIKI );
+               $this->setOutputType( self::OT_WIKI );
 
                if ( $clearState ) {
                        $this->clearState();
@@ -3886,7 +3893,7 @@ class Parser_OldPP
         */
        function cleanSig( $text, $parsing = false ) {
                global $wgTitle;
-               $this->startExternalParse( $this->mTitle, new ParserOptions(), $parsing ? OT_WIKI : OT_MSG );
+               $this->startExternalParse( $this->mTitle, new ParserOptions(), $parsing ? self::OT_WIKI : self::OT_MSG );
 
                $substWord = MagicWord::get( 'subst' );
                $substRegex = '/\{\{(?!(?:' . $substWord->getBaseRegex() . '))/x' . $substWord->getRegexCase();
@@ -3952,7 +3959,7 @@ class Parser_OldPP
                        $this->mTitle = Title::newFromText('msg');
                }
                $this->mOptions = $options;
-               $this->setOutputType( OT_MSG );
+               $this->setOutputType( self::OT_MSG );
                $this->clearState();
                $text = $this->replaceVariables( $text );
 
@@ -4691,7 +4698,7 @@ class Parser_OldPP
                $oldOutputType = $this->mOutputType;
                $oldOptions = $this->mOptions;
                $this->mOptions = new ParserOptions();
-               $this->setOutputType( OT_WIKI );
+               $this->setOutputType( self::OT_WIKI );
 
                $striptext = $this->strip( $text, $stripState, true );