Remove some more unused variables
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 4d16393..ca949ed 100644 (file)
@@ -266,6 +266,7 @@ class Parser {
                        $this->clearState();
                }
 
+               $options->resetUsage();
                $this->mOptions = $options;
                $this->setTitle( $title ); # Page title has to be set for the pre-processor
 
@@ -369,7 +370,7 @@ class Parser {
 
                $text = Sanitizer::normalizeCharReferences( $text );
 
-               if ( ( $wgUseTidy && $this->mOptions->mTidy ) || $wgAlwaysUseTidy ) {
+               if ( ( $wgUseTidy && $this->mOptions->getTidy() ) || $wgAlwaysUseTidy ) {
                        $text = MWTidy::tidy( $text );
                } else {
                        # attempt to sanitize at least some nesting problems
@@ -411,7 +412,7 @@ class Parser {
                        $PFreport = "Expensive parser function count: {$this->mExpensiveFunctionCount}/$wgExpensiveParserFunctionLimit\n";
                        $limitReport =
                                "NewPP limit report\n" .
-                               "Preprocessor node count: {$this->mPPNodeCount}/{$this->mOptions->mMaxPPNodeCount}\n" .
+                               "Preprocessor node count: {$this->mPPNodeCount}/{$this->mOptions->getMaxPPNodeCount()}\n" .
                                "Post-expand include size: {$this->mIncludeSizes['post-expand']}/$max bytes\n" .
                                "Template argument size: {$this->mIncludeSizes['arg']}/$max bytes\n".
                                $PFreport;
@@ -454,6 +455,7 @@ class Parser {
                wfProfileIn( __METHOD__ );
                $this->clearState();
                $this->setOutputType( self::OT_PREPROCESS );
+               $options->resetUsage();
                $this->mOptions = $options;
                $this->setTitle( $title );
                if ( $revid !== null ) {
@@ -477,6 +479,7 @@ class Parser {
                # Parser (re)initialisation
                $this->clearState();
                $this->setOutputType( self::OT_PLAIN );
+               $options->resetUsage();
                $this->mOptions = $options;
                $this->setTitle( $title );
 
@@ -945,7 +948,7 @@ class Parser {
                                        $last_tag = array_pop( $last_tag_history );
 
                                        if ( array_pop( $td_history ) ) {
-                                               $previous = "</{$last_tag}>{$previous}";
+                                               $previous = "</{$last_tag}>\n{$previous}";
                                        }
 
                                        if ( $first_character === '|' ) {
@@ -1141,8 +1144,8 @@ class Parser {
                                throw new MWException( __METHOD__.': unrecognised match type "' .
                                        substr( $m[0], 0, 20 ) . '"' );
                        }
-                       $url = wfMsg( $urlmsg, $id);
-                       $sk = $this->mOptions->getSkin();
+                       $url = wfMsgForContent( $urlmsg, $id);
+                       $sk = $this->mOptions->getSkin( $this->mTitle );
                        $la = $sk->getExternalLinkAttributes( "external $CssClass" );
                        return "<a href=\"{$url}\"{$la}>{$keyword} {$id}</a>";
                } elseif ( isset( $m[5] ) && $m[5] !== '' ) {
@@ -1171,7 +1174,7 @@ class Parser {
                global $wgContLang;
                wfProfileIn( __METHOD__ );
 
-               $sk = $this->mOptions->getSkin();
+               $sk = $this->mOptions->getSkin( $this->mTitle );
                $trail = '';
 
                # The characters '<' and '>' (which were escaped by
@@ -1420,7 +1423,7 @@ class Parser {
                global $wgContLang;
                wfProfileIn( __METHOD__ );
 
-               $sk = $this->mOptions->getSkin();
+               $sk = $this->mOptions->getSkin( $this->mTitle );
 
                $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
                $s = array_shift( $bits );
@@ -1569,7 +1572,7 @@ class Parser {
         * @private
         */
        function maybeMakeExternalImage( $url ) {
-               $sk = $this->mOptions->getSkin();
+               $sk = $this->mOptions->getSkin( $this->mTitle );
                $imagesfrom = $this->mOptions->getAllowExternalImagesFrom();
                $imagesexception = !empty( $imagesfrom );
                $text = false;
@@ -1645,7 +1648,7 @@ class Parser {
                        $e1_img = "/^([{$tc}]+)\\|(.*)\$/sD";
                }
 
-               $sk = $this->mOptions->getSkin();
+               $sk = $this->mOptions->getSkin( $this->mTitle );
                $holders = new LinkHolderArray( $this );
 
                # split the entire text string on occurences of [[
@@ -1988,7 +1991,7 @@ class Parser {
         */
        function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                list( $inside, $trail ) = Linker::splitTrail( $trail );
-               $sk = $this->mOptions->getSkin();
+               $sk = $this->mOptions->getSkin( $this->mTitle );
                # FIXME: use link() instead of deprecated makeKnownLinkObj()
                $link = $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix );
                return $this->armorLinks( $link ) . $trail;
@@ -2497,7 +2500,7 @@ class Parser {
         */
        function getVariableValue( $index, $frame=false ) {
                global $wgContLang, $wgSitename, $wgServer, $wgServerName;
-               global $wgScriptPath, $wgStylePath;
+               global $wgArticlePath, $wgScriptPath, $wgStylePath;
 
                /**
                 * Some of these require message or data lookups and can be
@@ -2771,6 +2774,8 @@ class Parser {
                        case 'currentversion':
                                $value = SpecialVersion::getVersion();
                                break;
+                       case 'articlepath':
+                               return $wgArticlePath;
                        case 'sitename':
                                return $wgSitename;
                        case 'server':
@@ -3402,13 +3407,13 @@ class Parser {
                global $wgEnableScaryTranscluding;
 
                if ( !$wgEnableScaryTranscluding ) {
-                       return wfMsg('scarytranscludedisabled');
+                       return wfMsgForContent('scarytranscludedisabled');
                }
 
                $url = $title->getFullUrl( "action=$action" );
 
                if ( strlen( $url ) > 255 ) {
-                       return wfMsg( 'scarytranscludetoolong' );
+                       return wfMsgForContent( 'scarytranscludetoolong' );
                }
                return $this->fetchScaryTemplateMaybeFromCache( $url );
        }
@@ -3425,7 +3430,7 @@ class Parser {
 
                $text = Http::get( $url );
                if ( !$text ) {
-                       return wfMsg( 'scarytranscludefailed', $url );
+                       return wfMsgForContent( 'scarytranscludefailed', $url );
                }
 
                $dbw = wfGetDB( DB_MASTER );
@@ -3700,16 +3705,12 @@ class Parser {
                global $wgMaxTocLevel, $wgContLang, $wgHtml5, $wgExperimentalHtmlIds;
 
                $doNumberHeadings = $this->mOptions->getNumberHeadings();
-               $showEditLink = $this->mOptions->getEditSection();
-
-               # Do not call quickUserCan unless necessary
-               if ( $showEditLink && !$this->mTitle->quickUserCan( 'edit' ) ) {
-                       $showEditLink = 0;
-               }
-
+               
                # Inhibit editsection links if requested in the page
-               if ( isset( $this->mDoubleUnderscores['noeditsection'] )  || $this->mOptions->getIsPrintable() ) {
+               if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
                        $showEditLink = 0;
+               } else {
+                       $showEditLink = $this->mOptions->getEditSection();
                }
 
                # Get all headlines for numbering them and adding funky stuff like [edit]
@@ -3742,7 +3743,7 @@ class Parser {
                }
 
                # We need this to perform operations on the HTML
-               $sk = $this->mOptions->getSkin();
+               $sk = $this->mOptions->getSkin( $this->mTitle );
 
                # headline counter
                $headlineCount = 0;
@@ -3966,9 +3967,9 @@ class Parser {
                                if ( $isTemplate ) {
                                        # Put a T flag in the section identifier, to indicate to extractSections()
                                        # that sections inside <includeonly> should be counted.
-                                       $editlink = $sk->doEditSectionLink( Title::newFromText( $titleText ), "T-$sectionIndex" );
+                                       $editlink = $sk->doEditSectionLink( Title::newFromText( $titleText ), "T-$sectionIndex", null, $this->mOptions->getUserLang() );
                                } else {
-                                       $editlink = $sk->doEditSectionLink( $this->mTitle, $sectionIndex, $headlineHint );
+                                       $editlink = $sk->doEditSectionLink( $this->mTitle, $sectionIndex, $headlineHint, $this->mOptions->getUserLang() );
                                }
                        } else {
                                $editlink = '';
@@ -4043,6 +4044,7 @@ class Parser {
         * @return String: the altered wiki markup
         */
        public function preSaveTransform( $text, Title $title, $user, $options, $clearState = true ) {
+               $options->resetUsage();
                $this->mOptions = $options;
                $this->setTitle( $title );
                $this->setOutputType( self::OT_WIKI );
@@ -4267,6 +4269,7 @@ class Parser {
         */
        public function startExternalParse( &$title, $options, $outputType, $clearState = true ) {
                $this->setTitle( $title );
+               $options->resetUsage();
                $this->mOptions = $options;
                $this->setOutputType( $outputType );
                if ( $clearState ) {
@@ -4477,7 +4480,7 @@ class Parser {
                $ig->setParser( $this );
                $ig->setHideBadImages();
                $ig->setAttributes( Sanitizer::validateTagAttributes( $params, 'table' ) );
-               $ig->useSkin( $this->mOptions->getSkin() );
+               $ig->useSkin( $this->mOptions->getSkin( $this->mTitle ) );
                $ig->mRevisionId = $this->mRevisionId;
 
                if ( isset( $params['showfilename'] ) ) {
@@ -4615,7 +4618,7 @@ class Parser {
                #  * text-bottom
 
                $parts = StringUtils::explode( "|", $options );
-               $sk = $this->mOptions->getSkin();
+               $sk = $this->mOptions->getSkin( $this->mTitle );
 
                # Give extensions a chance to select the file revision for us
                $skip = $time = $descQuery = false;
@@ -4626,7 +4629,6 @@ class Parser {
                }
 
                # Get the file
-               $imagename = $title->getDBkey();
                $file = wfFindFile( $title, array( 'time' => $time ) );
                # Get parameter map
                $handler = $file ? $file->getHandler() : false;
@@ -4779,7 +4781,7 @@ class Parser {
                wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) );
 
                # Linker does the rest
-               $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery );
+               $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery, $this->mOptions->getThumbSize() );
 
                # Give the handler a chance to modify the parser object
                if ( $handler ) {
@@ -5053,7 +5055,6 @@ class Parser {
         * @return string
         */
        public function getDefaultSort() {
-               global $wgCategoryPrefixedDefaultSortkey;
                if ( $this->mDefaultSort !== false ) {
                        return $this->mDefaultSort;
                } else {
@@ -5083,6 +5084,21 @@ class Parser {
                return '#' . Sanitizer::escapeId( $text, 'noninitial' );
        }
 
+       /**
+        * Same as guessSectionNameFromWikiText(), but produces legacy anchors
+        * instead.  For use in redirects, since IE6 interprets Redirect: headers
+        * as something other than UTF-8 (apparently?), resulting in breakage.
+        *
+        * @param $text String: The section name
+        * @return string An anchor
+        */
+       public function guessLegacySectionNameFromWikiText( $text ) {
+               # Strip out wikitext links(they break the anchor)
+               $text = $this->stripSectionName( $text );
+               $text = Sanitizer::normalizeSectionNameWhitespace( $text );
+               return '#' . Sanitizer::escapeId( $text, array( 'noninitial', 'legacy' ) );
+       }
+
        /**
         * Strips a text string of wikitext for use in a section anchor
         *
@@ -5115,10 +5131,6 @@ class Parser {
                return $text;
        }
 
-       function srvus( $text ) {
-               return $this->testSrvus( $text, $this->mOutputType );
-       }
-
        /**
         * strip/replaceVariables/unstrip for preprocessor regression testing
         */
@@ -5128,6 +5140,7 @@ class Parser {
                        $title = Title::newFromText( $title );
                }
                $this->mTitle = $title;
+               $options->resetUsage();
                $this->mOptions = $options;
                $this->setOutputType( $outputType );
                $text = $this->replaceVariables( $text );