Merge "Correctly use $wgFeedLimit in page history feed"
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index fa90954..94978d4 100644 (file)
@@ -156,8 +156,8 @@ class SkinTemplate extends Skin {
                                                'text' => $ilLangName,
                                                'title' => $languageLinkTitle->getText(),
                                                'class' => $class,
-                                               'lang' => $ilInterwikiCode,
-                                               'hreflang' => $ilInterwikiCode
+                                               'lang' => wfBCP47( $ilInterwikiCode ),
+                                               'hreflang' => wfBCP47( $ilInterwikiCode ),
                                        );
                                }
                        }
@@ -165,39 +165,14 @@ class SkinTemplate extends Skin {
                return $language_urls;
        }
 
-       /**
-        * initialize various variables and generate the template
-        *
-        * @param $out OutputPage
-        */
-       function outputPage( OutputPage $out = null ) {
-               global $wgContLang;
-               global $wgScript, $wgStylePath;
-               global $wgMimeType, $wgJsMimeType;
-               global $wgXhtmlNamespaces, $wgHtml5Version;
-               global $wgDisableCounters, $wgSitename, $wgLogo;
-               global $wgMaxCredits, $wgShowCreditsIfMax;
-               global $wgPageShowWatchingUsers;
-               global $wgArticlePath, $wgScriptPath, $wgServer;
-
+       protected function setupTemplateForOutput() {
                wfProfileIn( __METHOD__ );
-               Profiler::instance()->setTemplated( true );
 
-               $oldContext = null;
-               if ( $out !== null ) {
-                       // @todo Add wfDeprecated in 1.20
-                       $oldContext = $this->getContext();
-                       $this->setContext( $out->getContext() );
-               }
-
-               $out = $this->getOutput();
                $request = $this->getRequest();
                $user = $this->getUser();
                $title = $this->getTitle();
 
                wfProfileIn( __METHOD__ . '-init' );
-               $this->initPage( $out );
-
                $tpl = $this->setupTemplate( $this->template, 'skins' );
                wfProfileOut( __METHOD__ . '-init' );
 
@@ -226,6 +201,47 @@ class SkinTemplate extends Skin {
 
                wfProfileOut( __METHOD__ . '-stuff' );
 
+               wfProfileOut( __METHOD__ );
+
+               return $tpl;
+       }
+
+       /**
+        * initialize various variables and generate the template
+        *
+        * @param $out OutputPage
+        */
+       function outputPage( OutputPage $out = null ) {
+               global $wgContLang;
+               global $wgScript, $wgStylePath;
+               global $wgMimeType, $wgJsMimeType;
+               global $wgXhtmlNamespaces, $wgHtml5Version;
+               global $wgDisableCounters, $wgSitename, $wgLogo;
+               global $wgMaxCredits, $wgShowCreditsIfMax;
+               global $wgPageShowWatchingUsers;
+               global $wgArticlePath, $wgScriptPath, $wgServer;
+
+               wfProfileIn( __METHOD__ );
+               Profiler::instance()->setTemplated( true );
+
+               $oldContext = null;
+               if ( $out !== null ) {
+                       // @todo Add wfDeprecated in 1.20
+                       $oldContext = $this->getContext();
+                       $this->setContext( $out->getContext() );
+               }
+
+               $out = $this->getOutput();
+               $request = $this->getRequest();
+               $user = $this->getUser();
+               $title = $this->getTitle();
+
+               wfProfileIn( __METHOD__ . '-init' );
+               $this->initPage( $out );
+               wfProfileOut( __METHOD__ . '-init' );
+
+               $tpl = $this->setupTemplateForOutput();
+
                wfProfileIn( __METHOD__ . '-stuff-head' );
                if ( !$this->useHeadElement ) {
                        $tpl->set( 'pagecss', false );
@@ -515,6 +531,20 @@ class SkinTemplate extends Skin {
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * Get the HTML for the p-personal list
+        * @return string
+        */
+       public function getPersonalToolsList() {
+               $tpl = $this->setupTemplateForOutput();
+               $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
+               $html = '';
+               foreach ( $tpl->getPersonalTools() as $key => $item ) {
+                       $html .= $tpl->makeListItem( $key, $item );
+               }
+               return $html;
+       }
+
        /**
         * Format language name for use in sidebar interlanguage links list.
         * By default it is capitalized.
@@ -613,12 +643,15 @@ class SkinTemplate extends Skin {
                                'href' => $href,
                                'active' => ( $href == $pageurl )
                        );
-                       $href = self::makeSpecialUrl( 'Watchlist' );
-                       $personal_urls['watchlist'] = array(
-                               'text' => $this->msg( 'mywatchlist' )->text(),
-                               'href' => $href,
-                               'active' => ( $href == $pageurl )
-                       );
+
+                       if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
+                               $href = self::makeSpecialUrl( 'Watchlist' );
+                               $personal_urls['watchlist'] = array(
+                                       'text' => $this->msg( 'mywatchlist' )->text(),
+                                       'href' => $href,
+                                       'active' => ( $href == $pageurl )
+                               );
+                       }
 
                        # We need to do an explicit check for Special:Contributions, as we
                        # have to match both the title, and the target, which could come
@@ -992,7 +1025,7 @@ class SkinTemplate extends Skin {
                                wfProfileOut( __METHOD__ . '-live' );
 
                                // Checks if the user is logged in
-                               if ( $this->loggedin ) {
+                               if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
                                        /**
                                         * The following actions use messages which, if made particular to
                                         * the any specific skins, would break the Ajax code which makes this
@@ -1040,8 +1073,8 @@ class SkinTemplate extends Skin {
                                                        'class' => ( $code == $preferred ) ? 'selected' : false,
                                                        'text' => $varname,
                                                        'href' => $title->getLocalURL( array( 'variant' => $code ) + $params ),
-                                                       'lang' => $code,
-                                                       'hreflang' => $code
+                                                       'lang' => wfBCP47( $code ),
+                                                       'hreflang' => wfBCP47( $code ),
                                                );
                                        }
                                }
@@ -1187,15 +1220,15 @@ class SkinTemplate extends Skin {
 
                // A print stylesheet is attached to all pages, but nobody ever
                // figures that out. :)  Add a link...
-               if ( $out->isArticle() ) {
-                       if ( !$out->isPrintable() ) {
-                               $nav_urls['print'] = array(
-                                       'text' => $this->msg( 'printableversion' )->text(),
-                                       'href' => $this->getTitle()->getLocalURL(
-                                               $request->appendQueryValue( 'printable', 'yes', true ) )
-                               );
-                       }
+               if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
+                       $nav_urls['print'] = array(
+                               'text' => $this->msg( 'printableversion' )->text(),
+                               'href' => $this->getTitle()->getLocalURL(
+                                       $request->appendQueryValue( 'printable', 'yes', true ) )
+                       );
+               }
 
+               if ( $out->isArticle() ) {
                        // Also add a "permalink" while we're at it
                        $revid = $this->getRevisionId();
                        if ( $revid ) {