Include MediaWiki:Noscript.css in <noscript></noscript> tags in the header, to allow...
authorHappy-melon <happy-melon@users.mediawiki.org>
Sat, 5 Mar 2011 16:01:25 +0000 (16:01 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sat, 5 Mar 2011 16:01:25 +0000 (16:01 +0000)
RELEASE-NOTES
includes/AutoLoader.php
includes/OutputPage.php
includes/Skin.php
includes/resourceloader/ResourceLoaderNoscriptModule.php [new file with mode: 0644]
languages/messages/MessagesEn.php
resources/Resources.php

index 9b13ff7..d1ba8b5 100644 (file)
@@ -87,6 +87,8 @@ PHP if you have not done so prior to upgrading MediaWiki.
   specifically, rather than all ZIP files being blocked.
 * (bug 2429) Allow selection of associated namespace in recent changes
 * (bug 26995) File size is now checked before uploading in HTML5 browsers
+* CSS stylesheet MediaWiki:Noscript.css is now loaded for users with JavaScript
+  disabled (enclosed in the head in a <noscript> tag)
 
 === Bug fixes in 1.18 ===
 * (bug 23119) WikiError class and subclasses are now marked as deprecated
index 1fe21fd..e1820b1 100644 (file)
@@ -201,6 +201,7 @@ $wgAutoloadLocalClasses = array(
        'ResourceLoaderWikiModule' => 'includes/resourceloader/ResourceLoaderWikiModule.php',
        'ResourceLoaderFileModule' => 'includes/resourceloader/ResourceLoaderFileModule.php',
        'ResourceLoaderSiteModule' => 'includes/resourceloader/ResourceLoaderSiteModule.php',
+       'ResourceLoaderNoscriptModule' => 'includes/resourceloader/ResourceLoaderNoscriptModule.php',
        'ResourceLoaderUserModule' => 'includes/resourceloader/ResourceLoaderUserModule.php',
        'ResourceLoaderUserGroupsModule' => 'includes/resourceloader/ResourceLoaderUserGroupsModule.php',
        'ResourceLoaderUserOptionsModule' => 'includes/resourceloader/ResourceLoaderUserOptionsModule.php',
index fc90f2f..b953728 100644 (file)
@@ -2524,18 +2524,24 @@ class OutputPage {
                        if ( $useESI && $wgResourceLoaderUseESI ) {
                                $esi = Xml::element( 'esi:include', array( 'src' => $url ) );
                                if ( $only == ResourceLoaderModule::TYPE_STYLES ) {
-                                       $links .= Html::inlineStyle( $esi );
+                                       $link = Html::inlineStyle( $esi );
                                } else {
-                                       $links .= Html::inlineScript( $esi );
+                                       $link = Html::inlineScript( $esi );
                                }
                        } else {
                                // Automatically select style/script elements
                                if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
-                                       $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+                                       $link = Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) );
                                } else {
-                                       $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+                                       $link = Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) );
                                }
                        }
+
+                       if( $group == 'noscript' ){
+                               $links .= Html::rawElement( 'noscript', array(), $link ) . "\n";
+                       } else {
+                               $links .= $link . "\n";
+                       }
                }
                return $links;
        }
@@ -2829,7 +2835,7 @@ class OutputPage {
                $ret = '';
                // Add ResourceLoader styles
                // Split the styles into four groups
-               $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array() );
+               $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array(), 'noscript' => array() );
                $resourceLoader = $this->getResourceLoader();
                foreach ( $this->getModuleStyles() as $name ) {
                        $group = $resourceLoader->getModule( $name )->getGroup();
@@ -2847,12 +2853,12 @@ class OutputPage {
                $ret .= implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles;
                // Add marker tag to mark the place where the client-side loader should inject dynamic styles
                // We use a <meta> tag with a made-up name for this because that's valid HTML
-               $ret .= Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) );
+               $ret .= Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) ) . "\n";
                
                // Add site, private and user styles
                // 'private' at present only contains user.options, so put that before 'user'
                // Any future private modules will likely have a similar user-specific character
-               foreach ( array( 'site', 'private', 'user' ) as $group ) {
+               foreach ( array( 'site', 'noscript', 'private', 'user' ) as $group ) {
                        $ret .= $this->makeResourceLoaderLink( $sk, $styles[$group],
                                        ResourceLoaderModule::TYPE_STYLES
                        );
index e8a53c2..34c90cf 100644 (file)
@@ -565,7 +565,7 @@ abstract class Skin extends Linker {
 
                // Per-site custom styles
                if ( $wgUseSiteCss ) {
-                       $out->addModuleStyles( 'site' );
+                       $out->addModuleStyles( array( 'site', 'noscript' ) );
                        if( $wgUser->isLoggedIn() ){
                                $out->addModuleStyles( 'user.groups' );
                        }
diff --git a/includes/resourceloader/ResourceLoaderNoscriptModule.php b/includes/resourceloader/ResourceLoaderNoscriptModule.php
new file mode 100644 (file)
index 0000000..49ea6f1
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author Trevor Parscal
+ * @author Roan Kattouw
+ */
+
+/**
+ * Module for site customizations
+ */
+class ResourceLoaderNoscriptModule extends ResourceLoaderWikiModule {
+
+       /* Protected Methods */
+
+       /**
+        * Gets list of pages used by this module.  Obviously, it makes absolutely no
+        * sense to include JavaScript files here... :D
+        * 
+        * @return Array: List of pages
+        */
+       protected function getPages( ResourceLoaderContext $context ) {
+               return array( 'MediaWiki:Noscript.css' => array( 'type' => 'style' ) );
+       }
+
+       /* Methods */
+
+       /**
+        * Gets group name
+        * 
+        * @return String: Name of group
+        */
+       public function getGroup() {
+               return 'noscript';
+       }
+}
index 3d91e13..c4ee837 100644 (file)
@@ -3508,6 +3508,7 @@ You can view its source',
 'vector.css'        => '/* CSS placed here will affect users of the Vector skin */', # only translate this message to other languages if you have to change it
 'print.css'         => '/* CSS placed here will affect the print output */', # only translate this message to other languages if you have to change it
 'handheld.css'      => '/* CSS placed here will affect handheld devices based on the skin configured in $wgHandheldStyle */', # only translate this message to other languages if you have to change it
+'noscript.css'      => '/* CSS placed here will affect users with JavaScript disabled */', # only translate this message to other languages if you have to change it
 'autoconfirmed.css' => '/* CSS placed here will affect autoconfirmed users only */', # only translate this message to other languages if you have to change it
 'bot.css'           => '/* CSS placed here will affect bots only */', # only translate this message to other languages if you have to change it
 'sysop.css'         => '/* CSS placed here will affect sysops only */', # only translate this message to other languages if you have to change it
index 6e558e6..13065c8 100644 (file)
@@ -5,6 +5,7 @@ return array(
        /* Special resources who have their own classes */
 
        'site' => array( 'class' => 'ResourceLoaderSiteModule' ),
+       'noscript' => array( 'class' => 'ResourceLoaderNoscriptModule' ),
        'startup' => array( 'class' => 'ResourceLoaderStartUpModule' ),
        'user' => array( 'class' => 'ResourceLoaderUserModule' ),
        'user.options' => array( 'class' => 'ResourceLoaderUserOptionsModule' ),