(bug 10183) allow users to add custom css/js for all skins via /common.css & /common...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Fri, 5 Mar 2010 22:42:53 +0000 (22:42 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Fri, 5 Mar 2010 22:42:53 +0000 (22:42 +0000)
RELEASE-NOTES
includes/OutputPage.php
includes/Skin.php
includes/Title.php

index 8f469d9..d33bf3a 100644 (file)
@@ -23,6 +23,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   has been removed.
   
 === New features in 1.17 ===
+* (bug 10183) Users can now add personal styles and scripts to all skins via
+  User:<name>/common.css and /common.js (if user css/js is enabled)
   
 === Bug fixes in 1.17 ===
 * (bug 17560) Half-broken deletion moved image files to deletion archive without
index 4543569..24e5c1c 100644 (file)
@@ -2199,13 +2199,16 @@ class OutputPage {
                                $this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) );
                        } else {
                                $userpage = $wgUser->getUserPage();
-                               $scriptpage = Title::makeTitleSafe(
-                                       NS_USER,
-                                       $userpage->getDBkey() . '/' . $sk->getSkinName() . '.js'
-                               );
-                               if ( $scriptpage && $scriptpage->exists() ) {
-                                       $userjs = Skin::makeUrl( $scriptpage->getPrefixedText(), 'action=raw&ctype=' . $wgJsMimeType );
-                                       $this->addScriptFile( $userjs );
+                               $names = array( 'common', $sk->getSkinName() );
+                               foreach( $names as $name ) {
+                                       $scriptpage = Title::makeTitleSafe(
+                                               NS_USER,
+                                               $userpage->getDBkey() . '/' . $name . '.js'
+                                       );
+                                       if ( $scriptpage && $scriptpage->exists() ) {
+                                               $userjs = $scriptpage->getLocalURL( 'action=raw&ctype=' . $wgJsMimeType );
+                                               $this->addScriptFile( $userjs );
+                                       }
                                }
                        }
                }
index 49b3753..8e23180 100644 (file)
@@ -650,10 +650,13 @@ CSS;
                                // @FIXME: properly escape the cdata!
                                $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
                        } else {
-                               $out->addStyle( self::makeUrl(
-                                       $this->userpage . '/' . $this->getSkinName() . '.css',
-                                       'action=raw&ctype=text/css' )
-                               );
+                               $names = array( 'common', $this->getSkinName() );
+                               foreach( $names as $name ) {
+                                       $out->addStyle( self::makeUrl(
+                                               $this->userpage . '/' . $name . '.css',
+                                               'action=raw&ctype=text/css' )
+                                       );
+                               }
                        }
                }
 
index b6d8529..06756d1 100644 (file)
@@ -1709,8 +1709,10 @@ class Title {
         */
        public function isValidCssJsSubpage() {
                if ( $this->isCssJsSubpage() ) {
+                       $name = $this->getSkinFromCssJsSubpage();
+                       if ( $name == 'common' ) return true;
                        $skinNames = Skin::getSkinNames();
-                       return array_key_exists( $this->getSkinFromCssJsSubpage(), $skinNames );
+                       return array_key_exists( $name, $skinNames );
                } else {
                        return false;
                }