http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73025

Revision: 73025
Author:   tparscal
Date:     2010-09-14 21:48:23 +0000 (Tue, 14 Sep 2010)

Log Message:
-----------
* Added exporting of user preferences
* Renamed user.preferences to user.options
* Fixed bug that caused anonomous usernames (such as IP addresses) to be used 
in user style and script requests
* Fixed user options styles not loading for anon users

Modified Paths:
--------------
    trunk/phase3/resources/Resources.php
    trunk/phase3/resources/mediawiki/mediawiki.js

Modified: trunk/phase3/resources/Resources.php
===================================================================
--- trunk/phase3/resources/Resources.php        2010-09-14 21:47:59 UTC (rev 
73024)
+++ trunk/phase3/resources/Resources.php        2010-09-14 21:48:23 UTC (rev 
73025)
@@ -7,7 +7,7 @@
        'site' => new ResourceLoaderSiteModule,
        'startup' => new ResourceLoaderStartUpModule,
        'user' => new ResourceLoaderUserModule,
-       'user.preferences' => new ResourceLoaderUserPreferencesModule,
+       'user.options' => new ResourceLoaderUserOptionsModule,
        
        /* Skins */
        

Modified: trunk/phase3/resources/mediawiki/mediawiki.js
===================================================================
--- trunk/phase3/resources/mediawiki/mediawiki.js       2010-09-14 21:47:59 UTC 
(rev 73024)
+++ trunk/phase3/resources/mediawiki/mediawiki.js       2010-09-14 21:48:23 UTC 
(rev 73025)
@@ -44,10 +44,79 @@
        // This will not change until we are 100% ready to turn off legacy 
globals
        var LEGACY_GLOBALS = true;
        
-       /* Members */
+       /* Private Members */
        
-       this.legacy = LEGACY_GLOBALS ? window : {};
+       var that = this;
        
+       /* Prototypes */
+       
+       this.prototypes = {
+               /*
+                * An object which allows single and multiple get/set/exists 
functionality on a list of key / value pairs
+                * 
+                * @param {boolean} global whether to get/set/exists values on 
the window object or a private object
+                */
+               'configuration': function( global ) {
+                       
+                       /* Private Members */
+                       
+                       var that = this;
+                       var values = global === true ? window : {};
+                       
+                       /* Public Methods */
+                       
+                       /**
+                        * Gets one or multiple configuration values using a 
key and an optional fallback or an array of keys
+                        */
+                       this.get = function( keys, fallback ) {
+                               if ( typeof keys === 'object' ) {
+                                       var result = {};
+                                       for ( var k = 0; k < keys.length; k++ ) 
{
+                                               if ( typeof values[keys[k]] !== 
'undefined' ) {
+                                                       result[keys[k]] = 
values[keys[k]];
+                                               }
+                                       }
+                                       return result;
+                               } else if ( typeof keys === 'string' ) {
+                                       if ( typeof values[keys] === 
'undefined' ) {
+                                               return typeof fallback !== 
'undefined' ? fallback : null;
+                                       } else {
+                                               return values[keys];
+                                       }
+                               } else {
+                                       return values;
+                               }
+                       };
+                       /**
+                        * Sets one or multiple configuration values using a 
key and a value or an object of keys and values
+                        */
+                       this.set = function( keys, value ) {
+                               if ( typeof keys === 'object' ) {
+                                       for ( var k in keys ) {
+                                               values[k] = keys[k];
+                                       }
+                               } else if ( typeof keys === 'string' && typeof 
value !== 'undefined' ) {
+                                       values[keys] = value;
+                               }
+                       };
+                       /**
+                        * Checks if one or multiple configuration fields exist
+                        */
+                       this.exists = function( keys ) {
+                               if ( typeof keys === 'object' ) {
+                                       for ( var k = 0; k < keys.length; k++ ) 
{
+                                               if ( !( keys[k] in values ) ) {
+                                                       return false;
+                                               }
+                                       }
+                                       return true;
+                               } else {
+                                       return keys in values;
+                               }
+                       };
+               }
+       };
+       
        /* Methods */
        
        /*
@@ -55,67 +124,19 @@
         */
        this.log = function() { };
        /*
-        * An object which allows single and multiple existence, setting and 
getting on a list of key / value pairs
+        * List of configuration values
+        * 
+        * In legacy mode the values this object wraps will be in the global 
space
         */
-       this.config = new ( function() {
+       this.config = new this.prototypes.configuration( LEGACY_GLOBALS );
+       /*
+        * Information about the current user
+        */
+       this.user = new ( function() {
                
-               /* Private Members */
+               /* Public Members */
                
-               var that = this;
-               // List of configuration values - in legacy mode these 
configurations were ALL in the global space
-               var values = LEGACY_GLOBALS ? window : {};
-               
-               /* Public Methods */
-               
-               /**
-                * Sets one or multiple configuration values using a key and a 
value or an object of keys and values
-                */
-               this.set = function( keys, value ) {
-                       if ( typeof keys === 'object' ) {
-                               for ( var k in keys ) {
-                                       values[k] = keys[k];
-                               }
-                       } else if ( typeof keys === 'string' && typeof value 
!== 'undefined' ) {
-                               values[keys] = value;
-                       }
-               };
-               /**
-                * Gets one or multiple configuration values using a key and an 
optional fallback or an array of keys
-                */
-               this.get = function( keys, fallback ) {
-                       if ( typeof keys === 'object' ) {
-                               var result = {};
-                               for ( var k = 0; k < keys.length; k++ ) {
-                                       if ( typeof values[keys[k]] !== 
'undefined' ) {
-                                               result[keys[k]] = 
values[keys[k]];
-                                       }
-                               }
-                               return result;
-                       } else if ( typeof keys === 'string' ) {
-                               if ( typeof values[keys] === 'undefined' ) {
-                                       return typeof fallback !== 'undefined' 
? fallback : null;
-                               } else {
-                                       return values[keys];
-                               }
-                       } else {
-                               return values;
-                       }
-               };
-               /**
-                * Checks if one or multiple configuration fields exist
-                */
-               this.exists = function( keys ) {
-                       if ( typeof keys === 'object' ) {
-                               for ( var k = 0; k < keys.length; k++ ) {
-                                       if ( !( keys[k] in values ) ) {
-                                               return false;
-                                       }
-                               }
-                               return true;
-                       } else {
-                               return keys in values;
-                       }
-               };
+               this.options = new that.prototypes.configuration();
        } )();
        /*
         * Localization system



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to