* @return Array: List of pages
*/
protected function getPages( ResourceLoaderContext $context ) {
- global $wgHandheldStyle;
+ global $wgUseSiteJs, $wgUseSiteCss, $wgHandheldStyle;
- $pages = array(
- 'MediaWiki:Common.js' => array( 'type' => 'script' ),
- 'MediaWiki:Common.css' => array( 'type' => 'style' ),
- 'MediaWiki:' . ucfirst( $context->getSkin() ) . '.js' => array( 'type' => 'script' ),
- 'MediaWiki:' . ucfirst( $context->getSkin() ) . '.css' => array( 'type' => 'style' ),
- 'MediaWiki:Print.css' => array( 'type' => 'style', 'media' => 'print' ),
- );
+ $pages = array();
+ if ( $wgUseSiteJs ) {
+ $pages['MediaWiki:Common.js'] = array( 'type' => 'script' );
+ $pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.js'] = array( 'type' => 'script' );
+ }
+ if ( $wgUseSiteCss ) {
+ $pages['MediaWiki:Common.css'] = array( 'type' => 'style' );
+ $pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.css'] = array( 'type' => 'style' );
+
+ }
+ $pages['MediaWiki:Print.css'] = array( 'type' => 'style', 'media' => 'print' );
if ( $wgHandheldStyle ) {
$pages['MediaWiki:Handheld.css'] = array(
'type' => 'style',
public function getStyles( ResourceLoaderContext $context ) {
global $wgAllowUserCssPrefs, $wgUser;
- if ( $wgAllowUserCssPrefs ) {
- $options = $wgUser->getOptions();
+ if ( !$wgAllowUserCssPrefs ) {
+ return array();
+ }
- // Build CSS rules
- $rules = array();
+ $options = $wgUser->getOptions();
- // Underline: 2 = browser default, 1 = always, 0 = never
- if ( $options['underline'] < 2 ) {
- $rules[] = "a { text-decoration: " .
- ( $options['underline'] ? 'underline' : 'none' ) . "; }";
- } else {
- # The scripts of these languages are very hard to read with underlines
- $rules[] = 'a:lang(ar), a:lang(ckb), a:lang(fa),a:lang(kk-arab), ' .
- 'a:lang(mzn), a:lang(ps), a:lang(ur) { text-decoration: none; }';
- }
- if ( $options['justify'] ) {
- $rules[] = "#article, #bodyContent, #mw_content { text-align: justify; }\n";
- }
- if ( !$options['showtoc'] ) {
- $rules[] = "#toc { display: none; }\n";
- }
- if ( !$options['editsection'] ) {
- $rules[] = ".editsection { display: none; }\n";
- }
- if ( $options['editfont'] !== 'default' ) {
- // Double-check that $options['editfont'] consists of safe characters only
- if ( preg_match( '/^[a-zA-Z0-9_, -]+$/', $options['editfont'] ) ) {
- $rules[] = "textarea { font-family: {$options['editfont']}; }\n";
- }
- }
- $style = implode( "\n", $rules );
- if ( $this->getFlip( $context ) ) {
- $style = CSSJanus::transform( $style, true, false );
+ // Build CSS rules
+ $rules = array();
+
+ // Underline: 2 = browser default, 1 = always, 0 = never
+ if ( $options['underline'] < 2 ) {
+ $rules[] = "a { text-decoration: " .
+ ( $options['underline'] ? 'underline' : 'none' ) . "; }";
+ } else {
+ # The scripts of these languages are very hard to read with underlines
+ $rules[] = 'a:lang(ar), a:lang(ckb), a:lang(fa),a:lang(kk-arab), ' .
+ 'a:lang(mzn), a:lang(ps), a:lang(ur) { text-decoration: none; }';
+ }
+ if ( $options['justify'] ) {
+ $rules[] = "#article, #bodyContent, #mw_content { text-align: justify; }\n";
+ }
+ if ( !$options['showtoc'] ) {
+ $rules[] = "#toc { display: none; }\n";
+ }
+ if ( !$options['editsection'] ) {
+ $rules[] = ".editsection { display: none; }\n";
+ }
+ if ( $options['editfont'] !== 'default' ) {
+ // Double-check that $options['editfont'] consists of safe characters only
+ if ( preg_match( '/^[a-zA-Z0-9_, -]+$/', $options['editfont'] ) ) {
+ $rules[] = "textarea { font-family: {$options['editfont']}; }\n";
}
- return array( 'all' => $style );
}
- return array();
+ $style = implode( "\n", $rules );
+ if ( $this->getFlip( $context ) ) {
+ $style = CSSJanus::transform( $style, true, false );
+ }
+ return array( 'all' => $style );
}
/**
* @return array
*/
protected function getPages( ResourceLoaderContext $context ) {
- global $wgUser;
+ global $wgUser, $wgUseSiteJs, $wgUseSiteCss;
$userName = $context->getUser();
if ( $userName === null ) {
return array();
}
+ if ( !$wgUseSiteJs && !$wgUseSiteCss ) {
+ return array();
+ }
// Use $wgUser is possible; allows to skip a lot of code
if ( is_object( $wgUser ) && $wgUser->getName() == $userName ) {
if ( in_array( $group, array( '*', 'user' ) ) ) {
continue;
}
- $pages["MediaWiki:Group-$group.js"] = array( 'type' => 'script' );
- $pages["MediaWiki:Group-$group.css"] = array( 'type' => 'style' );
+ if ( $wgUseSiteJs ) {
+ $pages["MediaWiki:Group-$group.js"] = array( 'type' => 'script' );
+ }
+ if ( $wgUseSiteCss ) {
+ $pages["MediaWiki:Group-$group.css"] = array( 'type' => 'style' );
+ }
}
return $pages;
}
* @return array
*/
protected function getPages( ResourceLoaderContext $context ) {
+ global $wgAllowUserJs, $wgAllowUserCss;
$username = $context->getUser();
if ( $username === null ) {
return array();
}
+ if ( !$wgAllowUserJs && !$wgAllowUserCss ) {
+ return array();
+ }
// Get the normalized title of the user's user page
$userpageTitle = Title::makeTitleSafe( NS_USER, $username );
$userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works
- $pages = array(
- "$userpage/common.js" => array( 'type' => 'script' ),
- "$userpage/" . $context->getSkin() . '.js' =>
- array( 'type' => 'script' ),
- "$userpage/common.css" => array( 'type' => 'style' ),
- "$userpage/" . $context->getSkin() . '.css' =>
- array( 'type' => 'style' ),
- );
+ $pages = array();
+ if ( $wgAllowUserJs ) {
+ $pages["$userpage/common.js"] = array( 'type' => 'script' );
+ $pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' );
+ }
+ if ( $wgAllowUserCss ) {
+ $pages["$userpage/common.css"] = array( 'type' => 'style' );
+ $pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' );
+ }
// Hack for bug 26283: if we're on a preview page for a CSS/JS page,
// we need to exclude that page from this module. In that case, the excludepage