Capitalization fix in memcached setting
[lhc/web/wiklou.git] / includes / OutputPage.php
index 3f21307..6403576 100644 (file)
@@ -13,8 +13,6 @@ if( defined( 'MEDIAWIKI' ) ) {
 
 if($wgUseTeX) require_once( 'Math.php' );
 
-define( 'RLH_FOR_UPDATE', 1 );
-
 /**
  * @todo document
  * @package MediaWiki
@@ -161,7 +159,8 @@ class OutputPage {
        function setRobotpolicy( $str ) { $this->mRobotpolicy = $str; }
        function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; }
        function setPageTitle( $name ) {
-               global $action;
+               global $action, $wgContLang;
+               $name = $wgContLang->convert($name, true);
                $this->mPagetitle = $name;
                if(!empty($action)) {
                        $taction =  $this->getPageTitleActionText();
@@ -232,7 +231,7 @@ class OutputPage {
         * Convert wikitext to HTML and add it to the buffer
         */
        function addWikiText( $text, $linestart = true ) {
-               global $wgParser, $wgTitle;
+               global $wgParser, $wgTitle, $wgUseTidy;
 
                $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
                $this->mLanguageLinks += $parserOutput->getLanguageLinks();
@@ -245,14 +244,11 @@ class OutputPage {
         * Saves the text into the parser cache if possible
         */
        function addPrimaryWikiText( $text, $cacheArticle ) {
-               global $wgParser, $wgParserCache, $wgUser, $wgTitle;
+               global $wgParser, $wgParserCache, $wgUser, $wgTitle, $wgUseTidy;
 
                $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, true );
 
-               # Replace link holders
                $text = $parserOutput->getText();
-               $this->replaceLinkHolders( $text );
-               $parserOutput->setText( $text );
                
                if ( $cacheArticle ) {
                        $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
@@ -350,12 +346,12 @@ class OutputPage {
                global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
                global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
                global $wgDebugRedirects, $wgMimeType, $wgProfiler;
+
                if( $this->mDoNothing ){
                        return;
                }
                $fname = 'OutputPage::output';
                wfProfileIn( $fname );
-
                $sk = $wgUser->getSkin();
 
                if ( '' != $this->mRedirect ) {
@@ -386,10 +382,10 @@ class OutputPage {
                }
 
 
-               $this->sendCacheControl();
-               # Perform link colouring
+               # Buffer output; final headers may depend on later processing
+               ob_start();
+
                $this->transformBuffer();
-               $this->replaceLinkHolders( $this->mSubtitle );
                
                # Disable temporary placeholders, so that the skin produces HTML
                $sk->postParseLinkColour( false );
@@ -403,7 +399,9 @@ class OutputPage {
                }
 
                $sk->outputPage( $this );
-               # flush();
+               
+               $this->sendCacheControl();
+               ob_end_flush();
        }
 
        function out( $ins ) {
@@ -529,7 +527,7 @@ class OutputPage {
                $this->mBodytext = '';
 
                $sk = $wgUser->getSkin();
-               $ap = $sk->makeKnownLink( wfMsg( 'administrators' ), '' );
+               $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
                $this->addHTML( wfMsg( 'sysoptext', $ap ) );
                $this->returnToMain();
        }
@@ -544,7 +542,7 @@ class OutputPage {
                $this->mBodytext = '';
 
                $sk = $wgUser->getSkin();
-               $ap = $sk->makeKnownLink( wfMsg( 'administrators' ), '' );
+               $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
                $this->addHTML( wfMsg( 'developertext', $ap ) );
                $this->returnToMain();
        }
@@ -666,10 +664,11 @@ class OutputPage {
                if ( $returnto == NULL ) {
                        $returnto = $wgRequest->getText( 'returnto' );
                }
+               $returnto = htmlspecialchars( $returnto );
 
                $sk = $wgUser->getSkin();
                if ( '' == $returnto ) {
-                       $returnto = wfMsg( 'mainpage' );
+                       $returnto = wfMsgForContent( 'mainpage' );
                }
                $link = $sk->makeKnownLink( $returnto, '' );
 
@@ -797,154 +796,10 @@ class OutputPage {
         * Run any necessary pre-output transformations on the buffer text
         */
        function transformBuffer( $options = 0 ) {
-               $this->replaceLinkHolders( $this->mBodytext, $options );
        }
 
-       /**
-        * Replace <!--LINK--> link placeholders with actual links, in the buffer
-        * Placeholders created in Skin::makeLinkObj()
-        * Returns an array of links found, indexed by PDBK:
-        *  0 - broken
-        *  1 - normal link
-        *  2 - stub
-        * $options is a bit field, RLH_FOR_UPDATE to select for update
-        */
-       function replaceLinkHolders( &$text, $options = 0 ) {
-               global $wgUser, $wgLinkCache, $wgUseOldExistenceCheck, $wgLinkHolders;
-               
-               if ( $wgUseOldExistenceCheck ) {
-                       return array();
-               }
-
-               $fname = 'OutputPage::replaceLinkHolders';
-               wfProfileIn( $fname );
-
-               $pdbks = array();
-               $colours = array();
-               
-               #if ( !empty( $tmpLinks[0] ) ) { #TODO
-               if ( !empty( $wgLinkHolders['namespaces'] ) ) {
-                       wfProfileIn( $fname.'-check' );
-                       $dbr =& wfGetDB( DB_SLAVE );
-                       $cur = $dbr->tableName( 'cur' );
-                       $sk = $wgUser->getSkin();
-                       $threshold = $wgUser->getOption('stubthreshold');
-                       
-                       # Sort by namespace
-                       asort( $wgLinkHolders['namespaces'] );
-       
-                       # Generate query
-                       $query = false;
-                       foreach ( $wgLinkHolders['namespaces'] as $key => $val ) {
-                               # Make title object
-                               $title = $wgLinkHolders['titles'][$key];
-
-                               # Skip invalid entries.
-                               # Result will be ugly, but prevents crash.
-                               if ( is_null( $title ) ) {
-                                       continue;
-                               }
-                               $pdbk = $pdbks[$key] = $title->getPrefixedDBkey();
-
-                               # Check if it's in the link cache already
-                               if ( $wgLinkCache->getGoodLinkID( $pdbk ) ) {
-                                       $colours[$pdbk] = 1;
-                               } elseif ( $wgLinkCache->isBadLink( $pdbk ) ) {
-                                       $colours[$pdbk] = 0;
-                               } else {
-                                       # Not in the link cache, add it to the query
-                                       if ( !isset( $current ) ) {
-                                               $current = $val;
-                                               $query =  "SELECT cur_id, cur_namespace, cur_title";
-                                               if ( $threshold > 0 ) {
-                                                       $query .= ", LENGTH(cur_text) AS cur_len, cur_is_redirect";
-                                               } 
-                                               $query .= " FROM $cur WHERE (cur_namespace=$val AND cur_title IN(";
-                                       } elseif ( $current != $val ) {
-                                               $current = $val;
-                                               $query .= ")) OR (cur_namespace=$val AND cur_title IN(";
-                                       } else {
-                                               $query .= ', ';
-                                       }
-                               
-                                       $query .= $dbr->addQuotes( $wgLinkHolders['dbkeys'][$key] );
-                               }
-                       }
-                       if ( $query ) {
-                               $query .= '))';
-                               if ( $options & RLH_FOR_UPDATE ) {
-                                       $query .= ' FOR UPDATE';
-                               }
-                       
-                               $res = $dbr->query( $query, $fname );
-                               
-                               # Fetch data and form into an associative array
-                               # non-existent = broken
-                               # 1 = known
-                               # 2 = stub
-                               while ( $s = $dbr->fetchObject($res) ) {
-                                       $title = Title::makeTitle( $s->cur_namespace, $s->cur_title );
-                                       $pdbk = $title->getPrefixedDBkey();
-                                       $wgLinkCache->addGoodLink( $s->cur_id, $pdbk );
-                                       
-                                       if ( $threshold >  0 ) {
-                                               $size = $s->cur_len;
-                                               if ( $s->cur_is_redirect || $s->cur_namespace != 0 || $length < $threshold ) {
-                                                       $colours[$pdbk] = 1;
-                                               } else {
-                                                       $colours[$pdbk] = 2;
-                                               }
-                                       } else {
-                                               $colours[$pdbk] = 1;
-                                       }
-                               }
-                       }
-                       wfProfileOut( $fname.'-check' );
-                       
-                       # Construct search and replace arrays
-                       wfProfileIn( $fname.'-construct' );
-                       global $outputReplace;
-                       $outputReplace = array();
-                       foreach ( $wgLinkHolders['namespaces'] as $key => $ns ) {
-                               $pdbk = $pdbks[$key];
-                               $searchkey = '<!--LINK '.$key.'-->';
-                               $title = $wgLinkHolders['titles'][$key];
-                               if ( empty( $colours[$pdbk] ) ) {
-                                       $wgLinkCache->addBadLink( $pdbk );
-                                       $colours[$pdbk] = 0;
-                                       $outputReplace[$searchkey] = $sk->makeBrokenLinkObj( $title,
-                                                                       $wgLinkHolders['texts'][$key],
-                                                                       $wgLinkHolders['queries'][$key] );
-                               } elseif ( $colours[$pdbk] == 1 ) {
-                                       $outputReplace[$searchkey] = $sk->makeKnownLinkObj( $title,
-                                                                       $wgLinkHolders['texts'][$key],
-                                                                       $wgLinkHolders['queries'][$key] );
-                               } elseif ( $colours[$pdbk] == 2 ) {
-                                       $outputReplace[$searchkey] = $sk->makeStubLinkObj( $title,
-                                                                       $wgLinkHolders['texts'][$key],
-                                                                       $wgLinkHolders['queries'][$key] );
-                               }
-                       }
-                       wfProfileOut( $fname.'-construct' );
-
-                       # Do the thing
-                       wfProfileIn( $fname.'-replace' );
-                       
-                       $text = preg_replace_callback(
-                               '/(<!--LINK .*?-->)/',
-                               "outputReplaceMatches",
-                               $text);
-                       wfProfileOut( $fname.'-replace' );
-               }
-               wfProfileOut( $fname );
-               return $colours;
-       }
 }
 
-function &outputReplaceMatches($matches) {
-       global $outputReplace;
-       return $outputReplace[$matches[1]];
 }
 
-}
 ?>