Revert "Remove unsupported and mostly non-functional Mssql support"
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index ccfb3db..77ea307 100644 (file)
@@ -131,6 +131,7 @@ class SkinTemplate extends Skin {
        public function getLanguages() {
                global $wgHideInterlanguageLinks;
                $out = $this->getOutput();
+               $userLang = $this->getLanguage();
 
                # Language links
                $language_urls = array();
@@ -151,10 +152,14 @@ class SkinTemplate extends Skin {
                                                $ilLangName = $this->formatLanguageName( $ilLangName );
                                        }
 
+                                       // CLDR extension or similar is required to localize the language name;
+                                       // otherwise we'll end up with the autonym again.
+                                       $ilLangLocalName = Language::fetchLanguageName( $ilInterwikiCode, $userLang->getCode() );
+
                                        $language_urls[] = array(
                                                'href' => $languageLinkTitle->getFullURL(),
                                                'text' => $ilLangName,
-                                               'title' => $languageLinkTitle->getText(),
+                                               'title' => wfMessage( 'interlanguage-link-title', $languageLinkTitle->getText(), $ilLangLocalName )->text(),
                                                'class' => $class,
                                                'lang' => wfBCP47( $ilInterwikiCode ),
                                                'hreflang' => wfBCP47( $ilInterwikiCode ),
@@ -212,15 +217,6 @@ class SkinTemplate extends Skin {
         * @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 );
 
@@ -232,14 +228,45 @@ class SkinTemplate extends Skin {
                }
 
                $out = $this->getOutput();
-               $request = $this->getRequest();
                $user = $this->getUser();
-               $title = $this->getTitle();
 
                wfProfileIn( __METHOD__ . '-init' );
                $this->initPage( $out );
                wfProfileOut( __METHOD__ . '-init' );
+               $tpl = $this->prepareQuickTemplate( $out );
+               // execute template
+               wfProfileIn( __METHOD__ . '-execute' );
+               $res = $tpl->execute();
+               wfProfileOut( __METHOD__ . '-execute' );
+
+               // result may be an error
+               $this->printOrError( $res );
+
+               if ( $oldContext ) {
+                       $this->setContext( $oldContext );
+               }
+
+               wfProfileOut( __METHOD__ );
+       }
+
+       /**
+        * initialize various variables and generate the template
+        *
+        * @since 1.23
+        * @param $out OutputPage
+        * @return QuickTemplate the template to be executed by outputPage
+        */
+       protected function prepareQuickTemplate( OutputPage $out = null ) {
+               global $wgContLang, $wgScript, $wgStylePath,
+                       $wgMimeType, $wgJsMimeType, $wgXhtmlNamespaces, $wgHtml5Version,
+                       $wgDisableCounters, $wgSitename, $wgLogo, $wgMaxCredits,
+                       $wgShowCreditsIfMax, $wgPageShowWatchingUsers, $wgArticlePath,
+                       $wgScriptPath, $wgServer;
+
+               wfProfileIn( __METHOD__ );
 
+               $title = $this->getTitle();
+               $request = $this->getRequest();
                $tpl = $this->setupTemplateForOutput();
 
                wfProfileIn( __METHOD__ . '-stuff-head' );
@@ -518,18 +545,8 @@ class SkinTemplate extends Skin {
                $tpl->set( 'dataAfterContent', $this->afterContentHook() );
                wfProfileOut( __METHOD__ . '-stuff5' );
 
-               // execute template
-               wfProfileIn( __METHOD__ . '-execute' );
-               $res = $tpl->execute();
-               wfProfileOut( __METHOD__ . '-execute' );
-
-               // result may be an error
-               $this->printOrError( $res );
-
-               if ( $oldContext ) {
-                       $this->setContext( $oldContext );
-               }
                wfProfileOut( __METHOD__ );
+               return $tpl;
        }
 
        /**
@@ -1275,12 +1292,14 @@ class SkinTemplate extends Skin {
                                );
                        }
 
-                       $sur = new UserrightsPage;
-                       $sur->setContext( $this->getContext() );
-                       if ( $sur->userCanExecute( $this->getUser() ) ) {
-                               $nav_urls['userrights'] = array(
-                                       'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
-                               );
+                       if ( !$user->isAnon() ) {
+                               $sur = new UserrightsPage;
+                               $sur->setContext( $this->getContext() );
+                               if ( $sur->userCanExecute( $this->getUser() ) ) {
+                                       $nav_urls['userrights'] = array(
+                                               'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
+                                       );
+                               }
                        }
                }
 
@@ -1710,6 +1729,10 @@ abstract class BaseTemplate extends QuickTemplate {
         * on the link) is present it will be used to generate a tooltip and
         * accesskey for the link.
         *
+        * The keys "context" and "primary" are ignored; these keys are used
+        * internally by skins and are not supposed to be included in the HTML
+        * output.
+        *
         * If you don't want an accesskey, set $item['tooltiponly'] = true;
         *
         * @param array $options can be used to affect the output of a link.
@@ -1750,7 +1773,7 @@ abstract class BaseTemplate extends QuickTemplate {
 
                if ( isset( $item['href'] ) || isset( $options['link-fallback'] ) ) {
                        $attrs = $item;
-                       foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly' ) as $k ) {
+                       foreach ( array( 'single-id', 'text', 'msg', 'tooltiponly', 'context', 'primary' ) as $k ) {
                                unset( $attrs[$k] );
                        }
 
@@ -1987,9 +2010,10 @@ abstract class BaseTemplate extends QuickTemplate {
         * body and html tags.
         */
        function printTrail() { ?>
+<?php echo MWDebug::getDebugHTML( $this->getSkin()->getContext() ); ?>
 <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
 <?php $this->html( 'reporttime' ) ?>
-<?php echo MWDebug::getDebugHTML( $this->getSkin()->getContext() );
+<?php
        }
 
 }