Kill off $wg{Request,User,Lang,Output} usage within skins/ and redundant $this->skin...
authorDaniel Friesen <dantman@users.mediawiki.org>
Fri, 9 Sep 2011 15:41:30 +0000 (15:41 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Fri, 9 Sep 2011 15:41:30 +0000 (15:41 +0000)
skins/CologneBlue.php
skins/Modern.php
skins/Nostalgia.php
skins/Simple.php
skins/Standard.php
skins/Vector.php

index 66255ad..925ffd4 100644 (file)
@@ -101,8 +101,6 @@ class CologneBlueTemplate extends LegacyTemplate {
         * @return string
         */
        function doAfterContent(){
-               global $wgLang;
-
                $s = "\n</div><br clear='all' />\n";
 
                $s .= "\n<div id='footer'>";
@@ -115,7 +113,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                $s .= '<td class="bottom">';
 
                $s .= $this->bottomLinks();
-               $s .= $wgLang->pipeList( array(
+               $s .= $this->getSkin()->getLang()->pipeList( array(
                        "\n<br />" . Linker::link(
                                Title::newMainPage(),
                                null,
@@ -145,7 +143,6 @@ class CologneBlueTemplate extends LegacyTemplate {
         * @return string
         */
        function sysLinks() {
-               global $wgUser, $wgLang;
                $li = SpecialPage::getTitleFor( 'Userlogin' );
                $lo = SpecialPage::getTitleFor( 'Userlogout' );
 
@@ -180,7 +177,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                if( $this->extensionTabLinks() ) {
                        $s[] = $this->extensionTabLinks();
                }
-               if ( $wgUser->isLoggedIn() ) {
+               if ( $this->data['loggedin'] ) {
                        $s[] = Linker::linkKnown(
                                $lo,
                                wfMsg( 'logout' ),
@@ -196,7 +193,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                        );
                }
 
-               return $wgLang->pipeList( $s );
+               return $this->getSkin()->getLang()->pipeList( $s );
        }
 
        /**
@@ -206,8 +203,6 @@ class CologneBlueTemplate extends LegacyTemplate {
         * @return string
         */
        function quickBar(){
-               global $wgOut, $wgUser;
-
                $tns = $this->getSkin()->getTitle()->getNamespace();
 
                $s = "\n<div id='quickbar'>";
@@ -246,7 +241,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                        $barnumber++;
                }
 
-               if ( $wgOut->isArticle() ) {
+               if ( $this->data['isarticle'] ) {
                        $s .= $this->menuHead( 'qbedit' );
                        $s .= '<strong>' . $this->editThisPage() . '</strong>';
 
@@ -255,16 +250,16 @@ class CologneBlueTemplate extends LegacyTemplate {
                                wfMsg( 'edithelp' )
                        );
 
-                       if( $wgUser->isLoggedIn() ) {
+                       if( $this->data['loggedin'] ) {
                                $s .= $sep . $this->moveThisPage();
                        }
-                       if ( $wgUser->isAllowed( 'delete' ) ) {
+                       if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
                                $dtp = $this->deleteThisPage();
                                if ( $dtp != '' ) {
                                        $s .= $sep . $dtp;
                                }
                        }
-                       if ( $wgUser->isAllowed( 'protect' ) ) {
+                       if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
                                $ptp = $this->protectThisPage();
                                if ( $ptp != '' ) {
                                        $s .= $sep . $ptp;
@@ -276,7 +271,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                        $s .= $this->talkLink()
                                        . $sep . $this->commentLink()
                                        . $sep . $this->printableLink();
-                       if ( $wgUser->isLoggedIn() ) {
+                       if ( $this->data['loggedin'] ) {
                                $s .= $sep . $this->watchThisPage();
                        }
 
@@ -300,20 +295,20 @@ class CologneBlueTemplate extends LegacyTemplate {
                }
 
                $s .= $this->menuHead( 'qbmyoptions' );
-               if ( $wgUser->isLoggedIn() ) {
+               if ( $this->data['loggedin'] ) {
                        $tl = Linker::link(
-                               $wgUser->getTalkPage(),
+                               $this->getSkin()->getUser()->getTalkPage(),
                                wfMsg( 'mytalk' ),
                                array(),
                                array(),
                                array( 'known', 'noclasses' )
                        );
-                       if ( $wgUser->getNewtalk() ) {
+                       if ( $this->getSkin()->getUser()->getNewtalk() ) {
                                $tl .= ' *';
                        }
 
                        $s .= Linker::link(
-                                       $wgUser->getUserPage(),
+                                       $this->getSkin()->getUser()->getUserPage(),
                                        wfMsg( 'mypage' ),
                                        array(),
                                        array(),
@@ -321,7 +316,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                                ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' )
                                        . $sep .
                                Linker::link(
-                                       SpecialPage::getSafeTitleFor( 'Contributions', $wgUser->getName() ),
+                                       SpecialPage::getSafeTitleFor( 'Contributions', $this->getSkin()->getUser()->getName() ),
                                        wfMsg( 'mycontris' ),
                                        array(),
                                        array(),
@@ -336,7 +331,7 @@ class CologneBlueTemplate extends LegacyTemplate {
                        . Linker::specialLink( 'Newpages' )
                        . $sep . Linker::specialLink( 'Listfiles' )
                        . $sep . Linker::specialLink( 'Statistics' );
-               if( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
+               if( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getSkin()->getUser() ) === true ) {
                        $s .= $sep . $this->getUploadLink();
                }
 
@@ -373,9 +368,9 @@ class CologneBlueTemplate extends LegacyTemplate {
         * @return string
         */
        function searchForm( $label = '' ) {
-               global $wgRequest, $wgUseTwoButtonsSearchForm;
+               global $wgUseTwoButtonsSearchForm;
 
-               $search = $wgRequest->getText( 'search' );
+               $search = $this->getSkin()->getRequest()->getText( 'search' );
                $action = $this->data['searchaction'];
                $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
                if( $label != '' ) {
index 151fece..74f9b30 100644 (file)
@@ -36,10 +36,6 @@ class SkinModern extends SkinTemplate {
  */
 class ModernTemplate extends MonoBookTemplate {
 
-       /**
-        * @var Skin
-        */
-       var $skin;
        /**
         * Template filter callback for Modern skin.
         * Takes an associative array of data set from a SkinTemplate-based
@@ -49,8 +45,6 @@ class ModernTemplate extends MonoBookTemplate {
         * @access private
         */
        function execute() {
-               $this->skin = $skin = $this->data['skin'];
-
                // Suppress warnings to prevent notices about missing indexes in $this->data
                wfSuppressWarnings();
 
@@ -137,7 +131,7 @@ class ModernTemplate extends MonoBookTemplate {
                        <div id="mw_<?php echo htmlspecialchars($blockName); ?>">
 <?php
                        foreach ( $footerIcons as $icon ) { ?>
-                               <?php echo $this->skin->makeFooterIcon( $icon, 'withoutImage' ); ?>
+                               <?php echo $this->getSkin()->makeFooterIcon( $icon, 'withoutImage' ); ?>
 
 <?php
                        } ?>
index c23e289..6e8febc 100644 (file)
@@ -69,13 +69,12 @@ class NostalgiaTemplate extends LegacyTemplate {
         * @return string
         */
        function topLinks() {
-               global $wgOut, $wgUser;
                $sep = " |\n";
 
                $s = $this->getSkin()->mainPageLink() . $sep
                  . Linker::specialLink( 'Recentchanges' );
 
-               if ( $wgOut->isArticle() ) {
+               if ( $this->data['isarticle'] ) {
                        $s .= $sep . '<strong>' . $this->editThisPage() . '</strong>' . $sep . $this->talkLink() .
                                        $sep . $this->historyLink();
                }
@@ -83,25 +82,25 @@ class NostalgiaTemplate extends LegacyTemplate {
                /* show links to different language variants */
                $s .= $this->variantLinks();
                $s .= $this->extensionTabLinks();
-               if ( $wgUser->isAnon() ) {
+               if ( !$this->data['loggedin'] ) {
                        $s .= $sep . Linker::specialLink( 'Userlogin' );
                } else {
                        /* show user page and user talk links */
-                       $s .= $sep . Linker::link( $wgUser->getUserPage(), wfMsgHtml( 'mypage' ) );
-                       $s .= $sep . Linker::link( $wgUser->getTalkPage(), wfMsgHtml( 'mytalk' ) );
-                       if ( $wgUser->getNewtalk() ) {
+                       $s .= $sep . Linker::link( $this->getSkin()->getUser()->getUserPage(), wfMsgHtml( 'mypage' ) );
+                       $s .= $sep . Linker::link( $this->getSkin()->getUser()->getTalkPage(), wfMsgHtml( 'mytalk' ) );
+                       if ( $this->getSkin()->getUser()->getNewtalk() ) {
                                $s .= ' *';
                        }
                        /* show watchlist link */
                        $s .= $sep . Linker::specialLink( 'Watchlist' );
                        /* show my contributions link */
                        $s .= $sep . Linker::link(
-                               SpecialPage::getSafeTitleFor( 'Contributions', $wgUser->getName() ),
+                               SpecialPage::getSafeTitleFor( 'Contributions', $this->data['username'] ),
                                wfMsgHtml( 'mycontris' ) );
                        /* show my preferences link */
                        $s .= $sep . Linker::specialLink( 'Preferences' );
                        /* show upload file link */
-                       if( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
+                       if( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getSkin()->getUser() ) === true ) {
                                $s .= $sep . $this->getUploadLink();
                        }
 
index ad1df57..c0777d4 100644 (file)
@@ -30,16 +30,15 @@ class SkinSimple extends SkinTemplate {
                $out->addModuleStyles( 'skins.simple' );
 
                /* Add some userprefs specific CSS styling */
-               global $wgUser;
                $rules = array();
                $underline = "";
 
-               if ( $wgUser->getOption( 'underline' ) < 2 ) {
-                       $underline = "text-decoration: " . $wgUser->getOption( 'underline' ) ? 'underline !important' : 'none' . ";";
+               if ( $this->getSkin()->getUser()->getOption( 'underline' ) < 2 ) {
+                       $underline = "text-decoration: " . $this->getSkin()->getUser()->getOption( 'underline' ) ? 'underline !important' : 'none' . ";";
                }
 
                /* Also inherits from resourceloader */
-               if( !$wgUser->getOption( 'highlightbroken' ) ) {
+               if( !$this->getSkin()->getUser()->getOption( 'highlightbroken' ) ) {
                        $rules[] = "a.new, a.stub { color: inherit; text-decoration: inherit;}";
                        $rules[] = "a.new:after { color: #CC2200; $underline;}";
                        $rules[] = "a.stub:after { $underline; }";
index 53b1d63..b29748e 100644 (file)
@@ -54,7 +54,7 @@ class StandardTemplate extends LegacyTemplate {
         * @return string
         */
        function doAfterContent() {
-               global $wgContLang, $wgLang;
+               global $wgContLang;
                wfProfileIn( __METHOD__ );
                wfProfileIn( __METHOD__ . '-1' );
 
@@ -78,7 +78,7 @@ class StandardTemplate extends LegacyTemplate {
                $s .= "<td class='bottom' align='$l' valign='top'>";
 
                $s .= $this->bottomLinks();
-               $s .= "\n<br />" . $wgLang->pipeList( array(
+               $s .= "\n<br />" . $this->getSkin()->getLang()->pipeList( array(
                        $this->getSkin()->mainPageLink(),
                        $this->getSkin()->aboutLink(),
                        Linker::specialLink( 'Recentchanges' ),
@@ -105,12 +105,12 @@ class StandardTemplate extends LegacyTemplate {
         * @return string
         */
        function quickBar() {
-               global $wgOut, $wgUser, $wgRequest, $wgContLang;
+               global $wgContLang;
 
                wfProfileIn( __METHOD__ );
 
-               $action = $wgRequest->getText( 'action' );
-               $wpPreview = $wgRequest->getBool( 'wpPreview' );
+               $action = $this->getSkin()->getRequest()->getText( 'action' );
+               $wpPreview = $this->getSkin()->getRequest()->getBool( 'wpPreview' );
                $title = $this->getSkin()->getTitle();
                $tns = $title->getNamespace();
 
@@ -138,13 +138,13 @@ class StandardTemplate extends LegacyTemplate {
                        }
                        if ( $barnumber == 1 ) {
                                // only show watchlist link if logged in
-                               if( $wgUser->isLoggedIn() ) {
+                               if( $this->data['loggedin'] ) {
                                        $s.= Linker::specialLink( 'Watchlist' ) ;
                                        $s .= $sep . Linker::linkKnown(
                                                SpecialPage::getTitleFor( 'Contributions' ),
                                                wfMsg( 'mycontris' ),
                                                array(),
-                                               array( 'target' => $wgUser->getName() )
+                                               array( 'target' => $this->data['username'] )
                                        );
                                }
                        }
@@ -153,8 +153,8 @@ class StandardTemplate extends LegacyTemplate {
 
                $s .= "\n<hr class='sep' />";
                $articleExists = $title->getArticleId();
-               if ( $wgOut->isArticle() || $action == 'edit' || $action == 'history' || $wpPreview ) {
-                       if( $wgOut->isArticle() ) {
+               if ( $this->data['isarticle'] || $action == 'edit' || $action == 'history' || $wpPreview ) {
+                       if( $this->data['isarticle'] ) {
                                $s .= '<strong>' . $this->editThisPage() . '</strong>';
                        } else { # backlink to the article in edit or history mode
                                if( $articleExists ){ # no backlink if no article
@@ -212,7 +212,7 @@ class StandardTemplate extends LegacyTemplate {
                        }
 
                        # "Post a comment" link
-                       if( ( $title->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
+                       if( ( $title->isTalkPage() || $this->getSkin()->getOutput()->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
                                $s .= '<br />' . Linker::link(
                                        $title,
                                        wfMsg( 'postcomment' ),
@@ -229,14 +229,14 @@ class StandardTemplate extends LegacyTemplate {
                        article with "Watch this article" checkbox disabled, the article is transparently
                        unwatched. Therefore we do not show the "Watch this page" link in edit mode
                        */
-                       if ( $wgUser->isLoggedIn() && $articleExists ) {
+                       if ( $this->data['loggedin'] && $articleExists ) {
                                if( $action != 'edit' && $action != 'submit' ) {
                                        $s .= $sep . $this->watchThisPage();
                                }
                                if ( $title->userCan( 'edit' ) )
                                        $s .= $sep . $this->moveThisPage();
                        }
-                       if ( $wgUser->isAllowed( 'delete' ) && $articleExists ) {
+                       if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) && $articleExists ) {
                                $s .= $sep . $this->deleteThisPage() .
                                $sep . $this->protectThisPage();
                        }
@@ -246,7 +246,7 @@ class StandardTemplate extends LegacyTemplate {
                        }
                        $s .= $sep . $this->whatLinksHere();
 
-                       if( $wgOut->isArticleRelated() ) {
+                       if( $this->getSkin()->getOutput()->isArticleRelated() ) {
                                $s .= $sep . $this->watchPageLinksLink();
                        }
 
@@ -268,7 +268,7 @@ class StandardTemplate extends LegacyTemplate {
                        $s .= "\n<br /><hr class='sep' />";
                }
 
-               if( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
+               if( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getSkin()->getUser() ) === true ) {
                        $s .= $this->getUploadLink() . $sep;
                }
 
index a57d2cd..be1404f 100644 (file)
@@ -26,14 +26,14 @@ class SkinVector extends SkinTemplate {
         * @param $out OutputPage object to initialize
         */
        public function initPage( OutputPage $out ) {
-               global $wgLocalStylePath, $wgRequest;
+               global $wgLocalStylePath;
 
                parent::initPage( $out );
 
                // Append CSS which includes IE only behavior fixes for hover support -
                // this is better than including this in a CSS fille since it doesn't
                // wait for the CSS file to load before fetching the HTC file.
-               $min = $wgRequest->getFuzzyBool( 'debug' ) ? '' : '.min';
+               $min = $this->getRequest()->getFuzzyBool( 'debug' ) ? '' : '.min';
                $out->addHeadItem( 'csshover',
                        '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
                                htmlspecialchars( $wgLocalStylePath ) .
@@ -60,29 +60,19 @@ class SkinVector extends SkinTemplate {
  */
 class VectorTemplate extends BaseTemplate {
 
-       /* Members */
-
-       /**
-        * @var Skin Cached skin object
-        */
-       var $skin;
-
        /* Functions */
 
        /**
         * Outputs the entire contents of the (X)HTML page
         */
        public function execute() {
-               global $wgLang, $wgVectorUseIconWatch;
-
-               $this->skin = $this->data['skin'];
+               global $wgVectorUseIconWatch;
 
                // Build additional attributes for navigation urls
-               //$nav = $this->skin->buildNavigationUrls();
                $nav = $this->data['content_navigation'];
 
                if ( $wgVectorUseIconWatch ) {
-                       $mode = $this->skin->getTitle()->userIsWatching() ? 'unwatch' : 'watch';
+                       $mode = $this->getSkin()->getTitle()->userIsWatching() ? 'unwatch' : 'watch';
                        if ( isset( $nav['actions'][$mode] ) ) {
                                $nav['views'][$mode] = $nav['actions'][$mode];
                                $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
@@ -121,7 +111,7 @@ class VectorTemplate extends BaseTemplate {
                $this->data['variant_urls'] = $nav['variants'];
 
                // Reverse horizontally rendered navigation elements
-               if ( $wgLang->isRTL() ) {
+               if ( $this->data['rtl'] ) {
                        $this->data['view_urls'] =
                                array_reverse( $this->data['view_urls'] );
                        $this->data['namespace_urls'] =
@@ -236,7 +226,7 @@ class VectorTemplate extends BaseTemplate {
 <?php                  foreach ( $footericons as $blockName => $footerIcons ): ?>
                                        <li id="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
 <?php                          foreach ( $footerIcons as $icon ): ?>
-                                               <?php echo $this->skin->makeFooterIcon( $icon ); ?>
+                                               <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
 
 <?php                          endforeach; ?>
                                        </li>
@@ -336,14 +326,14 @@ class VectorTemplate extends BaseTemplate {
         * @param $elements array
         */
        private function renderNavigation( $elements ) {
-               global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser, $wgLang;
+               global $wgVectorUseSimpleSearch, $wgVectorShowVariantName;
 
                // If only one element was given, wrap it in an array, allowing more
                // flexible arguments
                if ( !is_array( $elements ) ) {
                        $elements = array( $elements );
                // If there's a series of elements, reverse them when in RTL mode
-               } elseif ( $wgLang->isRTL() ) {
+               } elseif ( $this->data['rtl'] ) {
                        $elements = array_reverse( $elements );
                }
                // Render elements
@@ -435,14 +425,14 @@ class VectorTemplate extends BaseTemplate {
        <h5<?php $this->html( 'userlangattributes' ) ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
        <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
                <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
-               <?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
+               <?php if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?>
                <div id="simpleSearch">
                        <?php if ( $this->data['rtl'] ): ?>
-                       <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin->getSkinStylePath( 'images/search-rtl.png' ) ) ); ?>
+                       <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ) ) ); ?>
                        <?php endif; ?>
                        <?php echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?>
                        <?php if ( !$this->data['rtl'] ): ?>
-                       <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin->getSkinStylePath( 'images/search-ltr.png' ) ) ); ?>
+                       <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ) ) ); ?>
                        <?php endif; ?>
                </div>
                <?php else: ?>