Update the Chinese conversion tables.
[lhc/web/wiklou.git] / includes / parser / Parser.php
index f60ed17..bfff371 100644 (file)
@@ -886,7 +886,7 @@ class Parser
 
                $text = $this->doDoubleUnderscore( $text );
                $text = $this->doHeadings( $text );
-               if($this->mOptions->getUseDynamicDates()) {
+               if( $this->mOptions->getUseDynamicDates() ) {
                        $df = DateFormatter::getInstance();
                        $text = $df->reformat( $this->mOptions->getDateFormat(), $text );
                }
@@ -896,7 +896,7 @@ class Parser
 
                # replaceInternalLinks may sometimes leave behind
                # absolute URLs, which have to be masked to hide them from replaceExternalLinks
-               $text = str_replace($this->mUniqPrefix."NOPARSE", "", $text);
+               $text = str_replace($this->mUniqPrefix.'NOPARSE', '', $text);
 
                $text = $this->doMagicLinks( $text );
                $text = $this->formatHeadings( $text, $isMain );
@@ -933,16 +933,16 @@ class Parser
        }
 
        function magicLinkCallback( $m ) {
-               if ( isset( $m[1] ) && strval( $m[1] ) !== '' ) {
+               if ( isset( $m[1] ) && $m[1] !== '' ) {
                        # Skip anchor
                        return $m[0];
-               } elseif ( isset( $m[2] ) && strval( $m[2] ) !== '' ) {
+               } elseif ( isset( $m[2] ) && $m[2] !== '' ) {
                        # Skip HTML element
                        return $m[0];
-               } elseif ( isset( $m[3] ) && strval( $m[3] ) !== '' ) {
+               } elseif ( isset( $m[3] ) && $m[3] !== '' ) {
                        # Free external link
                        return $this->makeFreeExternalLink( $m[0] );
-               } elseif ( isset( $m[4] ) && strval( $m[4] ) !== '' ) {
+               } elseif ( isset( $m[4] ) && $m[4] !== '' ) {
                        # RFC or PMID
                        if ( substr( $m[0], 0, 3 ) === 'RFC' ) {
                                $keyword = 'RFC';
@@ -960,7 +960,7 @@ class Parser
                        $sk = $this->mOptions->getSkin();
                        $la = $sk->getExternalLinkAttributes( $url, $keyword.$id );
                        return "<a href=\"{$url}\"{$la}>{$keyword} {$id}</a>";
-               } elseif ( isset( $m[5] ) && strval( $m[5] ) !== '' ) {
+               } elseif ( isset( $m[5] ) && $m[5] !== '' ) {
                        # ISBN
                        $isbn = $m[5];
                        $num = strtr( $isbn, array(
@@ -1603,7 +1603,7 @@ class Parser
                        wfProfileOut( __METHOD__."-misc" );
                        wfProfileIn( __METHOD__."-title" );
                        $nt = Title::newFromText( $this->mStripState->unstripNoWiki($link) );
-                       if( !$nt ) {
+                       if( $nt === NULL ) {
                                $s .= $prefix . '[[' . $line;
                                wfProfileOut( __METHOD__."-title" );
                                continue;
@@ -1729,6 +1729,7 @@ class Parser
                        # NS_MEDIA is a pseudo-namespace for linking directly to a file
                        # FIXME: Should do batch file existence checks, see comment below
                        if( $ns == NS_MEDIA ) {
+                               wfProfileIn( __METHOD__."-media" );
                                # Give extensions a chance to select the file revision for us
                                $skip = $time = false;
                                wfRunHooks( 'BeforeParserMakeImageLinkObj', array( &$this, &$nt, &$skip, &$time ) );
@@ -1740,9 +1741,11 @@ class Parser
                                # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
                                $s .= $prefix . $this->armorLinks( $link ) . $trail;
                                $this->mOutput->addImage( $nt->getDBkey() );
+                               wfProfileOut( __METHOD__."-media" );
                                continue;
                        }
 
+                       wfProfileIn( __METHOD__."-always_known" );
                        # Some titles, such as valid special pages or files in foreign repos, should
                        # be shown as bluelinks even though they're not included in the page table
                        #
@@ -1755,6 +1758,7 @@ class Parser
                                # Links will be added to the output link list after checking
                                $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
                        }
+                       wfProfileOut( __METHOD__."-always_known" );
                }
                wfProfileOut( __METHOD__ );
                return $holders;
@@ -2084,7 +2088,7 @@ class Parser
                                                $inBlockElem = true;
                                        }
                                } else if ( !$inBlockElem && !$this->mInPre ) {
-                                       if ( ' ' == $t{0} and ( $this->mLastSection === 'pre' or trim($t) != '' ) ) {
+                                       if ( ' ' == substr( $t, 0, 1 ) and ( $this->mLastSection === 'pre' or trim($t) != '' ) ) {
                                                // pre
                                                if ($this->mLastSection !== 'pre') {
                                                        $paragraphStack = false;
@@ -2446,6 +2450,12 @@ class Parser
                                $this->mOutput->setFlag( 'vary-revision' );
                                wfDebug( __METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n" );
                                return $this->getRevisionTimestamp();
+                       case 'revisionuser':
+                                // Let the edit saving system know we should parse the page
+                                // *after* a revision ID has been assigned. This is for null edits.
+                               $this->mOutput->setFlag( 'vary-revision' );
+                               wfDebug( __METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n" );
+                               return $this->getRevisionUser();
                        case 'namespace':
                                return str_replace('_',' ',$wgContLang->getNsText( $this->mTitle->getNamespace() ) );
                        case 'namespacee':
@@ -2604,11 +2614,10 @@ class Parser
         * @private
         */
        function replaceVariables( $text, $frame = false, $argsOnly = false ) {
-               # Prevent too big inclusions
-               if( strlen( $text ) > $this->mOptions->getMaxIncludeSize() ) {
+               # Is there any text? Also, Prevent too big inclusions!
+               if ( strlen( $text ) < 1 || strlen( $text ) > $this->mOptions->getMaxIncludeSize() ) {
                        return $text;
                }
-
                wfProfileIn( __METHOD__ );
 
                if ( $frame === false ) {
@@ -2684,7 +2693,7 @@ class Parser
         * @private
         */
        function braceSubstitution( $piece, $frame ) {
-               global $wgContLang, $wgAllowDisplayTitle, $wgNonincludableNamespaces;
+               global $wgContLang, $wgNonincludableNamespaces;
                wfProfileIn( __METHOD__ );
                wfProfileIn( __METHOD__.'-setup' );
 
@@ -3296,6 +3305,7 @@ class Parser
         * Fills $this->mDoubleUnderscores, returns the modified text
         */
        function doDoubleUnderscore( $text ) {
+               wfProfileIn( __METHOD__ );
                // The position of __TOC__ needs to be recorded
                $mw = MagicWord::get( 'toc' );
                if( $mw->match( $text ) ) {
@@ -3338,7 +3348,7 @@ class Parser
                } elseif( isset( $this->mDoubleUnderscores['index'] ) ) {
                        $this->mOutput->setIndexPolicy( 'index' );
                }
-
+               wfProfileOut( __METHOD__ );
                return $text;
        }
 
@@ -3368,7 +3378,7 @@ class Parser
                }
 
                # Inhibit editsection links if requested in the page
-               if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
+               if ( isset( $this->mDoubleUnderscores['noeditsection'] )  || $this->mOptions->getIsPrintable() ) {
                        $showEditLink = 0;
                }
 
@@ -4621,6 +4631,22 @@ class Parser
                return $this->mRevisionTimestamp;
        }
 
+       /**
+        * Get the name of the user that edited the last revision
+        */
+       function getRevisionUser() {
+               // if this template is subst: the revision id will be blank,
+               // so just use the current user's name
+               if( $this->mRevisionId ) {
+                       $revision = Revision::newFromId( $this->mRevisionId );
+                       $revuser = $revision->getUserText();
+               } else {
+                       global $wgUser;
+                       $revuser = $wgUser->getName();
+               }
+               return $revuser;
+       }
+
        /**
         * Mutator for $mDefaultSort
         *