r88185 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88184‎ | r88185 | r88186 >
Date:14:26, 15 May 2011
Author:mah
Status:ok
Tags:
Comment:
Fix Bug #28995: “public interface for getting state of a module” from
Bergi

Sometimes userscripts need to know about the registrated modules,
mostly about their state.

My patch also resolves inconsistencies in the naming conventions
of getters and setters; I think there should be a clear
difference.
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -1298,13 +1298,31 @@
12991299 *
13001300 * @param module string name of module to get version for
13011301 */
1302 - this.version = function( module ) {
 1302+ this.getVersion = function( module ) {
13031303 if ( module in registry && 'version' in registry[module] ) {
13041304 return formatVersionNumber( registry[module].version );
13051305 }
13061306 return null;
13071307 };
 1308+ /**
 1309+ * @deprecated use mw.loader.getVersion() instead
 1310+ */
 1311+ this.version = function() {
 1312+ return mediaWiki.loader.getVersion.apply( mediaWiki.loader, arguments );
 1313+ }
13081314
 1315+ /**
 1316+ * Gets the state of a module
 1317+ *
 1318+ * @param module string name of module to get state for
 1319+ */
 1320+ this.getState = function( module ) {
 1321+ if ( module in registry && 'state' in registry[module] ) {
 1322+ return registry[module].state;
 1323+ }
 1324+ return null;
 1325+ };
 1326+
13091327 /* Cache document ready status */
13101328
13111329 $(document).ready( function() { ready = true; } );

Status & tagging log