replace TYPE= with ENGINE=, (supported since 4.0, TYPE deprecated since 4.1)
[lhc/web/wiklou.git] / includes / Parser.php
index 3cc201d..3b5d119 100644 (file)
@@ -73,7 +73,7 @@ define( 'EXT_IMAGE_REGEX',
  *   performs brace substitution on MediaWiki messages
  *
  * Globals used:
- *    objects:   $wgLang
+ *    objects:   $wgLang, $wgContLang
  *
  * NOT $wgArticle, $wgUser or $wgTitle. Keep them away!
  *
@@ -236,17 +236,11 @@ class Parser
 
                $this->replaceLinkHolders( $text );
 
-               # the position of the convert() call should not be changed. it
+               # the position of the parserConvert() call should not be changed. it
                # assumes that the links are all replaced and the only thing left
                # is the <nowiki> mark.
-               $text = $wgContLang->convert($text);
-
-               # FIXME: Unexpected data flow
-               # Set the title text in mOutput to a converted version of the global 
-               # title. The title is stored in $wgContLang from a previous call to 
-               # OutputPage::setPageTitle(). If no call has been made, this will be 
-               # blank, a condition which Parser callers are expected to ignore.
-               $this->mOutput->setTitleText($wgContLang->getParsedTitle());
+               # Side-effects: this calls $this->mOutput->setTitleText()
+               $text = $wgContLang->parserConvert( $text, $this );
 
                $text = $this->unstripNoWiki( $text, $this->mStripState );
 
@@ -633,9 +627,9 @@ class Parser
                $process = proc_open("$wgTidyBin -config $wgTidyConf $wgTidyOpts$opts", $descriptorspec, $pipes);
                if (is_resource($process)) {
                        // Theoretically, this style of communication could cause a deadlock
-                       // here. If the stdout buffer fills up, then writes to stdin could 
+                       // here. If the stdout buffer fills up, then writes to stdin could
                        // block. This doesn't appear to happen with tidy, because tidy only
-                       // writes to stdout after it's finished reading from stdin. Search 
+                       // writes to stdout after it's finished reading from stdin. Search
                        // for tidyParseStdin and tidySaveStdout in console/tidy.c
                        fwrite($pipes[0], $text);
                        fclose($pipes[0]);
@@ -821,7 +815,6 @@ class Parser
         * @access private
         */
        function internalParse( $text ) {
-               global $wgContLang;
                $args = array();
                $isMain = true;
                $fname = 'Parser::internalParse';
@@ -1232,12 +1225,12 @@ class Parser
 
        /**
         * Replace unusual URL escape codes with their equivalent characters
-        * @param string 
+        * @param string
         * @return string
         * @static
         */
        function replaceUnusualEscapes( $url ) {
-               return preg_replace_callback( '/%[0-9A-Fa-f]{2}/', 
+               return preg_replace_callback( '/%[0-9A-Fa-f]{2}/',
                        array( 'Parser', 'replaceUnusualEscapesCallback' ), $url );
        }
 
@@ -2028,6 +2021,8 @@ class Parser
                                return $this->mTitle->getPrefixedText();
                        case MAG_FULLPAGENAMEE:
                                return $this->mTitle->getPrefixedURL();
+                       case MAG_SUBPAGENAME:
+                               return $this->mTitle->getSubpageText();
                        case MAG_REVISIONID:
                                return $this->mRevisionId;
                        case MAG_NAMESPACE:
@@ -2376,7 +2371,7 @@ class Parser
                $fname = 'Parser::braceSubstitution';
                wfProfileIn( $fname );
 
-               # Flags 
+               # Flags
                $found = false;             # $text has been filled
                $nowiki = false;            # wiki markup in $text should be escaped
                $noparse = false;           # Unsafe HTML tags should not be stripped, etc.
@@ -2743,7 +2738,7 @@ class Parser
        }
 
        /**
-        * Fetch the unparsed text of a template and register a reference to it. 
+        * Fetch the unparsed text of a template and register a reference to it.
         */
        function fetchTemplate( $title ) {
                $text = false;
@@ -3026,6 +3021,8 @@ class Parser
                        # strip out HTML
                        $canonized_headline = preg_replace( '/<.*?' . '>/','',$canonized_headline );
                        $tocline = trim( $canonized_headline );
+                       # Save headline for section edit hint before it's escaped
+                       $headline_hint = trim( $canonized_headline );
                        $canonized_headline = Sanitizer::escapeId( $tocline );
                        $refers[$headlineCount] = $canonized_headline;
 
@@ -3054,7 +3051,7 @@ class Parser
                                if( $istemplate )
                                        $head[$headlineCount] .= $sk->editSectionLinkForOther($templatetitle, $templatesection);
                                else
-                                       $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1);
+                                       $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
                        }
 
                        # give headline the correct <h#> tag
@@ -3281,7 +3278,7 @@ class Parser
                
                # Signatures
                $sigText = $this->getUserSig( $user );
-               $text = strtr( $text, array( 
+               $text = strtr( $text, array(
                        '~~~~~' => $d,
                        '~~~~' => "$sigText $d",
                        '~~~' => $sigText
@@ -3334,8 +3331,6 @@ class Parser
         * @access private
         */
        function getUserSig( &$user ) {
-               global $wgContLang;
-
                $username = $user->getName();
                $nickname = $user->getOption( 'nickname' );
                $nickname = $nickname === '' ? $username : $nickname;
@@ -3625,9 +3620,6 @@ class Parser
         * @return string
         */
        function replaceLinkHoldersText( $text ) {
-               global $wgUser;
-               global $wgOutputReplace;
-
                $fname = 'Parser::replaceLinkHoldersText';
                wfProfileIn( $fname );
 
@@ -3711,7 +3703,7 @@ class Parser
         * Parse image options text and use it to make an image
         */
        function makeImage( &$nt, $options ) {
-               global $wgContLang, $wgUseImageResize, $wgUser;
+               global $wgUseImageResize;
 
                $align = '';
 
@@ -3791,7 +3783,7 @@ class Parser
                $this->mOutput->mCacheTime = -1;
        }
 
-       /**#@+ 
+       /**#@+
         * Callback from the Sanitizer for expanding items found in HTML attribute
         * values, so they can be safely tested and escaped.
         * @param string $text
@@ -3993,8 +3985,8 @@ class ParserOptions
 
        /** Get user options */
        function initialiseFromUser( &$userInput ) {
-               global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages,
-                      $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion;
+               global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
+               global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion;
                $fname = 'ParserOptions::initialiseFromUser';
                wfProfileIn( $fname );
                if ( !$userInput ) {