Folowup r77763, add documentation for $wgFooterIcons.
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 7bf14bf..a768585 100644 (file)
@@ -354,7 +354,7 @@ class Parser {
                $uniq_prefix = $this->mUniqPrefix;
                $matches = array();
                $elements = array_keys( $this->mTransparentTagHooks );
-               $text = self::extractTagsAndParams( $elements, $text, $matches, $uniq_prefix );
+               $text = $this->extractTagsAndParams( $elements, $text, $matches, $uniq_prefix );
 
                foreach ( $matches as $marker => $data ) {
                        list( $element, $content, $params, $tag ) = $data;
@@ -494,7 +494,7 @@ class Parser {
         * @private
         * @static
         */
-       static function getRandomString() {
+       static private function getRandomString() {
                return dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) );
        }
 
@@ -538,7 +538,7 @@ class Parser {
         *
         * @return Title object
         */
-       function &getTitle() {
+       function getTitle() {
                return $this->mTitle;
        }
 
@@ -647,7 +647,7 @@ class Parser {
         *
         * @param $elements list of element names. Comments are always extracted.
         * @param $text Source text string.
-        * @param $matches Out parameter, Array: extarcted tags
+        * @param $matches Out parameter, Array: extracted tags
         * @param $uniq_prefix
         * @return String: stripped text
         *
@@ -789,7 +789,6 @@ class Parser {
                wfProfileIn( __METHOD__ );
                
                $lines = StringUtils::explode( "\n", $text );
-               $text = null;
                $out = '';
                $td_history = array(); # Is currently a td tag open?
                $last_tag_history = array(); # Save history of last lag activated (td, th or caption)
@@ -1129,7 +1128,6 @@ class Parser {
                        return $this->makeFreeExternalLink( $m[0] );
                } elseif ( isset( $m[4] ) && $m[4] !== '' ) {
                        # RFC or PMID
-                       $CssClass = '';
                        if ( substr( $m[0], 0, 3 ) === 'RFC' ) {
                                $keyword = 'RFC';
                                $urlmsg = 'rfcurl';
@@ -1261,10 +1259,9 @@ class Parser {
                        # First, do some preliminary work. This may shift some apostrophes from
                        # being mark-up to being text. It also counts the number of occurrences
                        # of bold and italics mark-ups.
-                       $i = 0;
                        $numbold = 0;
                        $numitalics = 0;
-                       foreach ( $arr as $r ) {
+                       for ( $i = 0; $i < count( $arr ); $i++ ) {
                                if ( ( $i % 2 ) == 1 ) {
                                        # If there are ever four apostrophes, assume the first is supposed to
                                        # be text, and the remaining three constitute mark-up for bold text.
@@ -1288,7 +1285,6 @@ class Parser {
                                                $numbold++;
                                        }
                                }
-                               $i++;
                        }
 
                        # If there is an odd number of both bold and italics, it is likely
@@ -1617,7 +1613,7 @@ class Parser {
 
        /**
         * Process [[ ]] wikilinks
-        * @return processed text
+        * @return String: processed text
         *
         * @private
         */
@@ -2495,7 +2491,7 @@ class Parser {
         * @private
         */
        function getVariableValue( $index, $frame=false ) {
-               global $wgContLang, $wgSitename, $wgServer, $wgServerName;
+               global $wgContLang, $wgSitename, $wgServer;
                global $wgArticlePath, $wgScriptPath, $wgStylePath;
 
                /**
@@ -2777,7 +2773,10 @@ class Parser {
                        case 'server':
                                return $wgServer;
                        case 'servername':
-                               return $wgServerName;
+                               wfSuppressWarnings(); # May give an E_WARNING in PHP < 5.3.3
+                               $serverName = parse_url( $wgServer, PHP_URL_HOST );
+                               wfRestoreWarnings();
+                               return $serverName ? $serverName : $wgServer;
                        case 'scriptpath':
                                return $wgScriptPath;
                        case 'stylepath':
@@ -2785,8 +2784,8 @@ class Parser {
                        case 'directionmark':
                                return $wgContLang->getDirMark();
                        case 'contentlanguage':
-                               global $wgContLanguageCode;
-                               return $wgContLanguageCode;
+                               global $wgLanguageCode;
+                               return $wgLanguageCode;
                        default:
                                $ret = null;
                                if ( wfRunHooks( 'ParserGetVariableValueSwitch', array( &$this, &$this->mVarCache, &$index, &$ret, &$frame ) ) ) {
@@ -3307,7 +3306,7 @@ class Parser {
 
                if ( !$title->equals( $cacheTitle ) ) {
                        $this->mTplRedirCache[$cacheTitle->getPrefixedDBkey()] =
-                               array( $title->getNamespace(),$cdb = $title->getDBkey() );
+                               array( $title->getNamespace(), $cdb = $title->getDBkey() );
                }
 
                return array( $dom, $title );
@@ -3752,7 +3751,6 @@ class Parser {
                $head = array();
                $sublevelCount = array();
                $levelCount = array();
-               $toclevel = 0;
                $level = 0;
                $prevlevel = 0;
                $toclevel = 0;
@@ -3766,6 +3764,7 @@ class Parser {
                $node = $root->getFirstChild();
                $byteOffset = 0;
                $tocraw = array();
+               $refers = array();
 
                foreach ( $matches[3] as $headline ) {
                        $isTemplate = false;
@@ -3782,7 +3781,6 @@ class Parser {
 
                        if ( $toclevel ) {
                                $prevlevel = $level;
-                               $prevtoclevel = $toclevel;
                        }
                        $level = $matches[1][$headlineCount];
 
@@ -3893,9 +3891,10 @@ class Parser {
                                        'noninitial' );
                        }
 
-                       # HTML names must be case-insensitively unique (bug 10721).  FIXME:
-                       # Does this apply to Unicode characters?  Because we aren't
-                       # handling those here.
+                       # HTML names must be case-insensitively unique (bug 10721). 
+                       # This does not apply to Unicode characters per 
+                       # http://dev.w3.org/html5/spec/infrastructure.html#case-sensitivity-and-string-comparison
+                       # FIXME: We may be changing them depending on the current locale.
                        $arrayKey = strtolower( $safeHeadline );
                        if ( $legacyHeadline === false ) {
                                $legacyArrayKey = false;
@@ -3940,8 +3939,9 @@ class Parser {
                        while ( $node && !$isTemplate ) {
                                if ( $node->getName() === 'h' ) {
                                        $bits = $node->splitHeading();
-                                       if ( $bits['i'] == $sectionIndex )
+                                       if ( $bits['i'] == $sectionIndex ) {
                                                break;
+                                       }
                                }
                                $byteOffset += mb_strlen( $this->mStripState->unstripBoth(
                                        $frame->expand( $node, PPFrame::RECOVER_ORIG ) ) );
@@ -4033,7 +4033,7 @@ class Parser {
         * conversion, substitting signatures, {{subst:}} templates, etc.
         *
         * @param $text String: the text to transform
-        * @param &$title Title: the Title object for the current article
+        * @param $title Title: the Title object for the current article
         * @param $user User: the User object describing the current user
         * @param $options ParserOptions: parsing options
         * @param $clearState Boolean: whether to clear the parser state first
@@ -4691,6 +4691,9 @@ class Parser {
                                                                if ( preg_match( "/^($prots)$chars+$/", $value, $m ) ) {
                                                                        $paramName = 'link-url';
                                                                        $this->mOutput->addExternalLink( $value );
+                                                                       if ( $this->mOptions->getExternalLinkTarget() ) {
+                                                                               $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
+                                                                       }
                                                                        $validated = true;
                                                                }
                                                        } else {
@@ -5255,7 +5258,7 @@ class Parser {
         */
        function unserialiseHalfParsedText( $data, $intPrefix = null ) {
                if ( !$intPrefix ) {
-                       $intPrefix = $this->getRandomString();
+                       $intPrefix = self::getRandomString();
                }
 
                # First, extract the strip state.