* API: (bug 17355) Added auwitheditsonly parameter to list=allusers
[lhc/web/wiklou.git] / includes / OutputPage.php
index 25a7180..b1a0275 100644 (file)
@@ -408,7 +408,12 @@ class OutputPage {
                if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
                        $sk = $wgUser->getSkin();
                        foreach ( $categories as $category => $type ) {
+                               $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
+                               $wgContLang->findVariantLink( $category, $title, true );
+                               if ( $category != $origcategory )
+                                       if ( array_key_exists( $category, $categories ) )
+                                               continue;
                                $text = $wgContLang->convertHtml( $title->getText() );
                                $this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
                        }
@@ -531,11 +536,18 @@ class OutputPage {
                $this->mNoGallery = $parserOutput->getNoGallery();
                $this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems );
                // Versioning...
-               $this->mTemplateIds = wfArrayMerge( $this->mTemplateIds, (array)$parserOutput->mTemplateIds );
-
-               // Display title
+               foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) {
+                       if ( isset( $this->mTemplateIds[$ns] ) ) {
+                               $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
+                       } else {
+                               $this->mTemplateIds[$ns] = $dbks;
+                       }
+               }
+               // Page title
                if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
                        $this->setPageTitle( $dt );
+               else if ( ( $title = $parserOutput->getTitleText() ) != '' )
+                       $this->setPageTitle( $title );
 
                // Hooks registered in the object
                global $wgParserOutputHooks;
@@ -626,6 +638,9 @@ class OutputPage {
         */
        public function parse( $text, $linestart = true, $interface = false ) {
                global $wgParser, $wgTitle;
+               if( is_null( $wgTitle ) ) {
+                       throw new MWException( 'Empty $wgTitle in ' . __METHOD__ );
+               }
                $popts = $this->parserOptions();
                if ( $interface) { $popts->setInterfaceMessage(true); }
                $parserOutput = $wgParser->parse( $text, $wgTitle, $popts,
@@ -634,6 +649,18 @@ class OutputPage {
                return $parserOutput->getText();
        }
 
+       /** Parse wikitext, strip paragraphs, and return the HTML. */
+       public function parseInline( $text, $linestart = true, $interface = false ) {
+               $parsed = $this->parse( $text, $linestart, $interface );
+
+               $m = array();
+               if ( preg_match( '/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
+                       $parsed = $m[1];
+               }
+
+               return $parsed;
+       }
+
        /**
         * @param Article $article
         * @param User    $user
@@ -694,7 +721,7 @@ class OutputPage {
         * If it does, it's very important that we don't allow public caching
         */
        function haveCacheVaryCookies() {
-               global $wgRequest, $wgCookiePrefix;
+               global $wgRequest;
                $cookieHeader = $wgRequest->getHeader( 'cookie' );
                if ( $cookieHeader === false ) {
                        return false;
@@ -713,7 +740,6 @@ class OutputPage {
 
        /** Get a complete X-Vary-Options header */
        public function getXVO() {
-               global $wgCookiePrefix;
                $cvCookies = $this->getCacheVaryCookies();
                $xvo = 'X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;';
                $first = true;
@@ -794,7 +820,8 @@ class OutputPage {
                global $wgUser, $wgOutputEncoding, $wgRequest;
                global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
                global $wgJsMimeType, $wgUseAjax, $wgAjaxWatch;
-               global $wgEnableMWSuggest;
+               global $wgEnableMWSuggest, $wgUniversalEditButton;
+               global $wgArticle, $wgTitle;
 
                if( $this->mDoNothing ){
                        return;
@@ -901,6 +928,25 @@ class OutputPage {
                        $this->addScriptFile( 'rightclickedit.js' );
                }
 
+               if( $wgUniversalEditButton ) {
+                       if( isset( $wgArticle ) && isset( $wgTitle ) && $wgTitle->quickUserCan( 'edit' )
+                               && ( $wgTitle->exists() || $wgTitle->quickUserCan( 'create' ) ) ) {
+                               // Original UniversalEditButton
+                               $this->addLink( array(
+                                       'rel' => 'alternate',
+                                       'type' => 'application/x-wiki',
+                                       'title' => wfMsg( 'edit' ),
+                                       'href' => $wgTitle->getFullURL( 'action=edit' )
+                               ) );
+                               // Alternate edit link
+                               $this->addLink( array(
+                                       'rel' => 'edit',
+                                       'title' => wfMsg( 'edit' ),
+                                       'href' => $wgTitle->getFullURL( 'action=edit' )
+                               ) );
+                       }
+               }
+               
                # Buffer output; final headers may depend on later processing
                ob_start();
 
@@ -1050,7 +1096,7 @@ class OutputPage {
 
                array_unshift( $params, 'parse' );
                array_unshift( $params, $msg );
-               $this->addHtml( call_user_func_array( 'wfMsgExt', $params ) );
+               $this->addHTML( call_user_func_array( 'wfMsgExt', $params ) );
 
                $this->returnToMain();
        }
@@ -1161,8 +1207,8 @@ class OutputPage {
 
                $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
                $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() );
-               $this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
-               $this->addHtml( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
+               $this->addHTML( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
+               $this->addHTML( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
 
                # Don't return to the main page if the user can't read it
                # otherwise we'll end up in a pointless loop
@@ -1185,8 +1231,7 @@ class OutputPage {
                        $text = wfMsgNoTrans( 'permissionserrorstext', count($errors)). "\n\n";
                } else {
                        global $wgLang;
-                       $action_desc = wfMsg( "right-$action" );
-                       $action_desc = $wgLang->lcfirst( $action_desc ); // FIXME: TERRIBLE HACK
+                       $action_desc = wfMsg( "action-$action" );
                        $text = wfMsgNoTrans( 'permissionserrorstext-withaction', count($errors), $action_desc ) . "\n\n";
                }
 
@@ -1252,7 +1297,7 @@ class OutputPage {
                        // Wiki is read only
                        $this->setPageTitle( wfMsg( 'readonly' ) );
                        $reason = wfReadOnlyReason();
-                       $wgOut->wrapWikiMsg( '<div class="readonly-error">$1</div>', 'readonlytext' );
+                       $this->wrapWikiMsg( '<div class="mw-readonly-error">$1</div>', array( 'readonlytext', $reason ) );
                }
 
                // Show source, if supplied
@@ -1357,8 +1402,9 @@ class OutputPage {
         */
        public function addReturnTo( $title ) {
                global $wgUser;
+               $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullUrl() ) );
                $link = wfMsg( 'returnto', $wgUser->getSkin()->makeLinkObj( $title ) );
-               $this->addHtml( "<p>{$link}</p>\n" );
+               $this->addHTML( "<p>{$link}</p>\n" );
        }
 
        /**
@@ -1466,7 +1512,8 @@ class OutputPage {
        
        protected function addDefaultMeta() {
                global $wgVersion;
-               $this->addMeta( "generator", "MediaWiki $wgVersion" );
+               $this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835
+               $this->addMeta( 'generator', "MediaWiki $wgVersion" );
                
                $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
                if( $p !== 'index,follow' ) {
@@ -1533,7 +1580,7 @@ class OutputPage {
                        # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
                        # If so, use it instead.
                        
-                       global $wgOverrideSiteFeed, $wgSitename;
+                       global $wgOverrideSiteFeed, $wgSitename, $wgFeedClasses;
                        $rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
                        
                        if ( $wgOverrideSiteFeed ) {
@@ -1545,14 +1592,12 @@ class OutputPage {
                                }
                        }
                        else if ( $wgTitle->getPrefixedText() != $rctitle->getPrefixedText() ) {
-                               $tags[] = $this->feedLink(
-                                       'rss',
-                                       $rctitle->getFullURL( 'feed=rss' ),
-                                       wfMsg( 'site-rss-feed', $wgSitename ) );
-                               $tags[] = $this->feedLink(
-                                       'atom',
-                                       $rctitle->getFullURL( 'feed=atom' ),
-                                       wfMsg( 'site-atom-feed', $wgSitename ) );
+                               foreach( $wgFeedClasses as $format => $class ) {
+                                       $tags[] = $this->feedLink(
+                                               $format,
+                                               $rctitle->getFullURL( "feed={$format}" ),
+                                               wfMsg( "site-{$format}-feed", $wgSitename ) ); # For grep: 'site-rss-feed', 'site-atom-feed'.
+                               }
                        }
                }
 
@@ -1748,7 +1793,7 @@ class OutputPage {
                                ? 'lag-warn-normal'
                                : 'lag-warn-high';
                        $warning = wfMsgExt( $message, 'parse', $lag );
-                       $this->addHtml( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
+                       $this->addHTML( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
                }
        }
 
@@ -1817,7 +1862,7 @@ class OutputPage {
                                $args = array();
                                $name = $spec;
                        }
-                       $s = str_replace( '$' . ($n+1), wfMsgExt( $name, $options, $args ), $s );
+                       $s = str_replace( '$' . ( $n + 1 ), wfMsgExt( $name, $options, $args ), $s );
                }
                $this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
        }