(bug 13718) Return the proper continue parameter for cmsort=timestamp
[lhc/web/wiklou.git] / includes / Parser_OldPP.php
index f47dc00..92a7e18 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;
@@ -2139,7 +2146,7 @@ class Parser_OldPP
                                                $inBlockElem = true;
                                        }
                                } else if ( !$inBlockElem && !$this->mInPre ) {
-                                       if ( ' ' == $t{0} and ( $this->mLastSection == 'pre' or trim($t) != '' ) ) {
+                                       if ( '' != $t and ' ' == $t{0} and ( $this->mLastSection == 'pre' or trim($t) != '' ) ) {
                                                // pre
                                                if ($this->mLastSection != 'pre') {
                                                        $paragraphStack = false;
@@ -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 );
 
@@ -4074,7 +4081,7 @@ class Parser_OldPP
                $pdbks = array();
                $colours = array();
                $sk = $this->mOptions->getSkin();
-               $linkCache =& LinkCache::singleton();
+               $linkCache = LinkCache::singleton();
 
                if ( !empty( $this->mLinkHolders['namespaces'] ) ) {
                        wfProfileIn( $fname.'-check' );
@@ -4113,10 +4120,7 @@ class Parser_OldPP
                                        # Not in the link cache, add it to the query
                                        if ( !isset( $current ) ) {
                                                $current = $ns;
-                                               $query =  "SELECT page_id, page_namespace, page_title";
-                                               if ( $threshold > 0 ) {
-                                                       $query .= ', page_len, page_is_redirect';
-                                               }
+                                               $query =  "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect";
                                                $query .= " FROM $page WHERE (page_namespace=$ns AND page_title IN(";
                                        } elseif ( $current != $ns ) {
                                                $current = $ns;
@@ -4143,20 +4147,20 @@ class Parser_OldPP
                                while ( $s = $dbr->fetchObject($res) ) {
                                        $title = Title::makeTitle( $s->page_namespace, $s->page_title );
                                        $pdbk = $title->getPrefixedDBkey();
-                                       $linkCache->addGoodLinkObj( $s->page_id, $title );
+                                       $linkCache->addGoodLinkObj( $s->page_id, $title, $s->page_len, $s->page_is_redirect );
                                        $this->mOutput->addLink( $title, $s->page_id );
 
                                        $colours[$pdbk] = ( $threshold == 0 || (
                                                                $s->page_len >= $threshold || # always true if $threshold <= 0
                                                                $s->page_is_redirect ||
-                                                               !Namespace::isContent( $s->page_namespace ) )
+                                                               !MWNamespace::isContent( $s->page_namespace ) )
                                                            ? 1 : 2 );
                                }
                        }
                        wfProfileOut( $fname.'-check' );
 
                        # Do a second query for different language variants of links and categories
-                       if($wgContLang->hasVariants()){
+                       if( $wgContLang->hasVariants() ) {
                                $linkBatch = new LinkBatch();
                                $variantMap = array(); // maps $pdbkey_Variant => $keys (of link holders)
                                $categoryMap = array(); // maps $category_variant => $category (dbkeys)
@@ -4203,14 +4207,11 @@ class Parser_OldPP
                                }
 
 
-                               if(!$linkBatch->isEmpty()){
+                               if ( !$linkBatch->isEmpty() ){
                                        // construct query
                                        $titleClause = $linkBatch->constructSet('page', $dbr);
 
-                                       $variantQuery =  "SELECT page_id, page_namespace, page_title";
-                                       if ( $threshold > 0 ) {
-                                               $variantQuery .= ', page_len, page_is_redirect';
-                                       }
+                                       $variantQuery =  "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect";
 
                                        $variantQuery .= " FROM $page WHERE $titleClause";
                                        if ( $options & RLH_FOR_UPDATE ) {
@@ -4229,7 +4230,7 @@ class Parser_OldPP
                                                $holderKeys = array();
                                                if(isset($variantMap[$varPdbk])){
                                                        $holderKeys = $variantMap[$varPdbk];
-                                                       $linkCache->addGoodLinkObj( $s->page_id, $variantTitle );
+                                                       $linkCache->addGoodLinkObj( $s->page_id, $variantTitle, $s->page_len, $s->page_is_redirect );
                                                        $this->mOutput->addLink( $variantTitle, $s->page_id );
                                                }
 
@@ -4691,7 +4692,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 );