From 8c5619f77804b78e5d28b43037bf889190ce2c56 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Fri, 5 Mar 2010 22:42:53 +0000 Subject: [PATCH] (bug 10183) allow users to add custom css/js for all skins via /common.css & /common.js user subpages --- RELEASE-NOTES | 2 ++ includes/OutputPage.php | 17 ++++++++++------- includes/Skin.php | 11 +++++++---- includes/Title.php | 4 +++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8f469d906f..d33bf3a489 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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:/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 diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 4543569b78..24e5c1caac 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 ); + } } } } diff --git a/includes/Skin.php b/includes/Skin.php index 49b375346b..8e231804b6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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' ) + ); + } } } diff --git a/includes/Title.php b/includes/Title.php index b6d8529ab3..06756d1061 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; } -- 2.20.1