Code style tweaks per brion's suggestions on Wikitech-l
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index 0503684..95bd876 100644 (file)
@@ -518,7 +518,7 @@ class SkinTemplate extends Skin {
                        $personal_urls['logout'] = array(
                                'text' => wfMsg( 'userlogout' ),
                                'href' => self::makeSpecialUrl( 'Userlogout',
-                                       $wgTitle->getNamespace() === NS_SPECIAL && $wgTitle->getText() === 'Preferences' ? '' : "returnto={$this->thisurl}"
+                                       $wgTitle->isSpecial( 'Preferences' ) ? '' : "returnto={$this->thisurl}"
                                )
                        );
                } else {
@@ -541,14 +541,14 @@ class SkinTemplate extends Skin {
                                $personal_urls['anonlogin'] = array(
                                        'text' => wfMsg('userlogin'),
                                        'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ),
-                                       'active' => ( NS_SPECIAL == $wgTitle->getNamespace() && 'Userlogin' == $wgTitle->getDBkey() )
+                                       'active' => $wgTitle->isSpecial( 'Userlogin' ) 
                                );
                        } else {
 
                                $personal_urls['login'] = array(
                                        'text' => wfMsg('userlogin'),
                                        'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ),
-                                       'active' => ( NS_SPECIAL == $wgTitle->getNamespace() && 'Userlogin' == $wgTitle->getDBkey() )
+                                       'active' => $wgTitle->isSpecial( 'Userlogin' )
                                );
                        }
                }
@@ -703,18 +703,18 @@ class SkinTemplate extends Skin {
                                        );
                                }
                                if ( $this->mTitle->userCanMove()) {
-                                       $moveTitle = Title::makeTitle( NS_SPECIAL, 'Movepage' );
+                                       $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage );
                                        $content_actions['move'] = array(
-                                               'class' => ($this->mTitle->getDbKey() == 'Movepage' and $this->mTitle->getNamespace == NS_SPECIAL) ? 'selected' : false,
+                                               'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
                                                'text' => wfMsg('move'),
-                                               'href' => $moveTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
+                                               'href' => $moveTitle->getLocalUrl()
                                        );
                                }
                        } else {
                                //article doesn't exist or is deleted
                                if( $wgUser->isAllowed( 'delete' ) ) {
                                        if( $n = $this->mTitle->isDeleted() ) {
-                                               $undelTitle = Title::makeTitle( NS_SPECIAL, 'Undelete' );
+                                               $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
                                                $content_actions['undelete'] = array(
                                                        'class' => false,
                                                        'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $n ),
@@ -849,14 +849,14 @@ class SkinTemplate extends Skin {
                }
 
                if( $this->mTitle->getNamespace() != NS_SPECIAL ) {
-                       $wlhTitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' );
+                       $wlhTitle = SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage );
                        $nav_urls['whatlinkshere'] = array(
-                               'href' => $wlhTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
+                               'href' => $wlhTitle->getLocalUrl()
                        );
                        if( $this->mTitle->getArticleId() ) {
-                               $rclTitle = Title::makeTitle( NS_SPECIAL, 'Recentchangeslinked' );
+                               $rclTitle = SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage );
                                $nav_urls['recentchangeslinked'] = array(
-                                       'href' => $rclTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
+                                       'href' => $rclTitle->getLocalUrl()
                                );
                        }
                        if ($wgUseTrackbacks)
@@ -1013,16 +1013,23 @@ class SkinTemplate extends Skin {
        }
 
        /**
-        * @public
+        * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
+        * nated together.  For some bizarre reason, it does *not* return any
+        * custom user JS from subpages.  Huh?
+        *
+        * There's absolutely no reason to have separate Monobook/Common JSes.
+        * Any JS that cares can just check the skin variable generated at the
+        * top.  For now Monobook.js will be maintained, but it should be consi-
+        * dered deprecated.
+        *
+        * @return string
         */
-       function getUserJs() {
+       public function getUserJs() {
                $fname = 'SkinTemplate::getUserJs';
                wfProfileIn( $fname );
 
-               global $wgStylePath;
-               $s = '/* generated javascript */';
-               $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
-               $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n";
+               $s = parent::getUserJs();
+               $s .= "\n\n/* MediaWiki:".ucfirst($this->skinname).".js (deprecated; migrate to Common.js!) */\n";
 
                // avoid inclusion of non defined user JavaScript (with custom skins only)
                // by checking for default message content