Fix flush-like commit in DeferredUpdates.
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index 377199d..6233228 100644 (file)
@@ -40,7 +40,7 @@ class MediaWiki_I18N {
                // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
                $value = preg_replace( '/^string:/', '', $value );
 
-               $value = wfMsg( $value );
+               $value = wfMessage( $value )->text();
                // interpolate variables
                $m = array();
                while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
@@ -135,7 +135,6 @@ class SkinTemplate extends Skin {
                global $wgDisableCounters, $wgSitename, $wgLogo, $wgHideInterlanguageLinks;
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
-               global $wgDebugComments;
                global $wgArticlePath, $wgScriptPath, $wgServer;
 
                wfProfileIn( __METHOD__ );
@@ -387,12 +386,6 @@ class SkinTemplate extends Skin {
                        }
                }
 
-               if ( $wgDebugComments ) {
-                       $tpl->setRef( 'debug', $out->mDebugtext );
-               } else {
-                       $tpl->set( 'debug', '' );
-               }
-
                $tpl->set( 'sitenotice', $this->getSiteNotice() );
                $tpl->set( 'bottomscripts', $this->bottomScripts() );
                $tpl->set( 'printfooter', $this->printSource() );
@@ -430,7 +423,7 @@ class SkinTemplate extends Skin {
                                        if ( strval( $ilLangName ) === '' ) {
                                                $ilLangName = $l;
                                        } else {
-                                               $ilLangName = $this->getLanguage()->ucfirst( $ilLangName );
+                                               $ilLangName = $this->formatLanguageName( $ilLangName );
                                        }
                                        $language_urls[] = array(
                                                'href' => $nt->getFullURL(),
@@ -468,6 +461,7 @@ class SkinTemplate extends Skin {
                        $tpl->set( 'headscripts', $out->getHeadScripts() . $out->getHeadItems() );
                }
 
+               $tpl->set( 'debug', '' );
                $tpl->set( 'debughtml', $this->generateDebugHTML() );
                $tpl->set( 'reporttime', wfReportTime() );
 
@@ -504,6 +498,18 @@ class SkinTemplate extends Skin {
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * Format language name for use in sidebar interlanguage links list.
+        * By default it is capitalized.
+        *
+        * @param $name string Language name, e.g. "English" or "espaƱol"
+        * @return string
+        * @private
+        */
+       function formatLanguageName( $name ) {
+               return $this->getLanguage()->ucfirst( $name );
+       }
+
        /**
         * Output the string, or print error message if it's
         * an error object of the appropriate type.
@@ -535,6 +541,8 @@ class SkinTemplate extends Skin {
         * @return array
         */
        protected function buildPersonalUrls() {
+               global $wgSecureLogin;
+
                $title = $this->getTitle();
                $request = $this->getRequest();
                $pageurl = $title->getLocalURL();
@@ -557,13 +565,19 @@ class SkinTemplate extends Skin {
                                $a['returntoquery'] = $query;
                        }
                }
+
+               if ( $wgSecureLogin && $request->detectProtocol() === 'https' ) {
+                       $a['wpStickHTTPS'] = true;
+               }
+
                $returnto = wfArrayToCGI( $a );
                if( $this->loggedin ) {
                        $personal_urls['userpage'] = array(
                                'text' => $this->username,
                                'href' => &$this->userpageUrlDetails['href'],
                                'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
-                               'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
+                               'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
+                               'dir' => 'auto'
                        );
                        $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
                        $personal_urls['mytalk'] = array(
@@ -625,37 +639,22 @@ class SkinTemplate extends Skin {
                        $is_signup = $request->getText( 'type' ) == 'signup';
 
                        # anonlogin & login are the same
+                       global $wgSecureLogin;
+                       $proto = $wgSecureLogin ? PROTO_HTTPS : null;
+
+                       $login_id = $this->showIPinHeader() ? 'anonlogin' : 'login';
                        $login_url = array(
                                'text' => $this->msg( $loginlink )->text(),
-                               'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
-                               'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup )
+                               'href' => self::makeSpecialUrl( 'Userlogin', $returnto, $proto ),
+                               'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
+                               'class' => $wgSecureLogin ? 'link-https' : ''
+                       );
+                       $createaccount_url = array(
+                               'text' => $this->msg( 'createaccount' )->text(),
+                               'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup", $proto ),
+                               'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
+                               'class' => $wgSecureLogin ? 'link-https' : ''
                        );
-                       if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
-                               $createaccount_url = array(
-                                       'text' => $this->msg( 'createaccount' )->text(),
-                                       'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
-                                       'active' => $title->isSpecial( 'Userlogin' ) && $is_signup
-                               );
-                       }
-                       global $wgServer, $wgSecureLogin;
-                       if( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) {
-                               $title = SpecialPage::getTitleFor( 'Userlogin' );
-                               $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
-                               $login_url['href']  = $https_url;
-                               # @todo FIXME: Class depends on skin
-                               $login_url['class'] = 'link-https';
-                               if ( isset( $createaccount_url ) ) {
-                                       $https_url = preg_replace( '/^http:/', 'https:',
-                                               $title->getFullURL( 'type=signup' ) );
-                                       $createaccount_url['href']  = $https_url;
-                                       # @todo FIXME: Class depends on skin
-                                       $createaccount_url['class'] = 'link-https';
-                               }
-                       }
-
-                       if ( isset( $createaccount_url ) ) {
-                               $personal_urls['createaccount'] = $createaccount_url;
-                       }
 
                        if( $this->showIPinHeader() ) {
                                $href = &$this->userpageUrlDetails['href'];
@@ -673,10 +672,13 @@ class SkinTemplate extends Skin {
                                        'class' => $usertalkUrlDetails['exists'] ? false : 'new',
                                        'active' => ( $pageurl == $href )
                                );
-                               $personal_urls['anonlogin'] = $login_url;
-                       } else {
-                               $personal_urls['login'] = $login_url;
                        }
+
+                       if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
+                               $personal_urls['createaccount'] = $createaccount_url;
+                       }
+
+                       $personal_urls[$login_id] = $login_url;
                }
 
                wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) );
@@ -1147,6 +1149,7 @@ class SkinTemplate extends Skin {
 
                $nav_urls['print'] = false;
                $nav_urls['permalink'] = false;
+               $nav_urls['info'] = false;
                $nav_urls['whatlinkshere'] = false;
                $nav_urls['recentchangeslinked'] = false;
                $nav_urls['contributions'] = false;
@@ -1170,10 +1173,15 @@ class SkinTemplate extends Skin {
                        if ( $revid ) {
                                $nav_urls['permalink'] = array(
                                        'text' => $this->msg( 'permalink' )->text(),
-                                       'href' => $out->getTitle()->getLocalURL( "oldid=$revid" )
+                                       'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
                                );
                        }
 
+                       $nav_urls['info'] = array(
+                               'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
+                               'href' => $out->getTitle()->getLocalURL( "action=info" )
+                       );
+
                        // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
                        wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
                                array( &$this, &$nav_urls, &$revid, &$revid ) );
@@ -1198,9 +1206,8 @@ class SkinTemplate extends Skin {
                                'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
                        );
 
-                       $logPage = SpecialPage::getTitleFor( 'Log' );
                        $nav_urls['log'] = array(
-                               'href' => $logPage->getLocalUrl( array( 'user' => $rootUser ) )
+                               'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
                        );
 
                        if ( $this->getUser()->isAllowed( 'block' ) ) {
@@ -1243,7 +1250,7 @@ abstract class QuickTemplate {
        /**
         * Constructor
         */
-       public function QuickTemplate() {
+       function __construct() {
                $this->data = array();
                $this->translator = new MediaWiki_I18N();
        }
@@ -1420,6 +1427,7 @@ abstract class BaseTemplate extends QuickTemplate {
                }
                if ( isset( $this->data['nav_urls']['print'] ) && $this->data['nav_urls']['print'] ) {
                        $toolbox['print'] = $this->data['nav_urls']['print'];
+                       $toolbox['print']['id'] = 't-print';
                        $toolbox['print']['rel'] = 'alternate';
                        $toolbox['print']['msg'] = 'printableversion';
                }
@@ -1434,6 +1442,10 @@ abstract class BaseTemplate extends QuickTemplate {
                                $toolbox['permalink']['id'] = 't-permalink';
                        }
                }
+               if ( isset( $this->data['nav_urls']['info'] ) && $this->data['nav_urls']['info'] ) {
+                       $toolbox['info'] = $this->data['nav_urls']['info'];
+               }
+
                wfRunHooks( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
                wfProfileOut( __METHOD__ );
                return $toolbox;
@@ -1800,11 +1812,15 @@ abstract class BaseTemplate extends QuickTemplate {
                                );
                                unset( $buttonAttrs['src'] );
                                unset( $buttonAttrs['alt'] );
+                               unset( $buttonAttrs['width'] );
+                               unset( $buttonAttrs['height'] );
                                $imgAttrs = array(
                                        'src' => $attrs['src'],
                                        'alt' => isset( $attrs['alt'] )
                                                ? $attrs['alt']
                                                : $this->translator->translate( 'searchbutton' ),
+                                       'width' => isset( $attrs['width'] ) ? $attrs['width'] : null,
+                                       'height' => isset( $attrs['height'] ) ? $attrs['height'] : null,
                                );
                                return Html::rawElement( 'button', $buttonAttrs, Html::element( 'img', $imgAttrs ) );
                        default:
@@ -1896,13 +1912,7 @@ abstract class BaseTemplate extends QuickTemplate {
        function printTrail() { ?>
 <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
 <?php $this->html( 'reporttime' ) ?>
-<?php if ( $this->data['debug'] ): ?>
-<!-- Debug output:
-<?php $this->text( 'debug' ); ?>
-
--->
-<?php endif;
+<?php echo MWDebug::getDebugHTML( $this->getSkin()->getContext() );
        }
 
 }
-