r72425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72424‎ | r72425 | r72426 >
Date:13:31, 5 September 2010
Author:ialex
Status:ok
Tags:
Comment:
Fixed some doxygen warnings
Modified paths:
  • /trunk/phase3/includes/ResourceLoader.php (modified) (history)
  • /trunk/phase3/includes/ResourceLoaderModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ResourceLoader.php
@@ -15,11 +15,12 @@
1616 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717 * http://www.gnu.org/copyleft/gpl.html
1818 *
 19+ * @file
1920 * @author Roan Kattouw
2021 * @author Trevor Parscal
2122 */
2223
23 -/*
 24+/**
2425 * Dynamic JavaScript and CSS resource loading system
2526 *
2627 * @example
@@ -27,10 +28,10 @@
2829 * ResourceLoader::register( 'foo', array(
2930 * // Script or list of scripts to include when implementating the module (required)
3031 * 'script' => 'resources/foo/foo.js',
31 - * // List of scripts or lists of scripts to include based on the current language
32 - * 'locales' => array(
33 - * 'en-gb' => 'resources/foo/locales/en-gb.js',
34 - * ),
 32+ * // List of scripts or lists of scripts to include based on the current language
 33+ * 'locales' => array(
 34+ * 'en-gb' => 'resources/foo/locales/en-gb.js',
 35+ * ),
3536 * // Script or list of scripts to include only when in debug mode
3637 * 'debug' => 'resources/foo/debug.js',
3738 * // If this module is going to be loaded before the mediawiki module is ready such as jquery or the mediawiki
@@ -45,16 +46,16 @@
4647 * 'loader' => 'resources/foo/loader.js',
4748 * // Style-sheets or list of style-sheets to include
4849 * 'style' => 'resources/foo/foo.css',
49 - * // List of style-sheets or lists of style-sheets to include based on the skin - if no match is found for current
50 - * // skin, 'default' is used - if default doesn't exist nothing is added
51 - * 'themes' => array(
52 - * 'default' => 'resources/foo/themes/default/foo.css',
53 - * 'vector' => 'resources/foo/themes/vector.foo.css',
54 - * ),
 50+ * // List of style-sheets or lists of style-sheets to include based on the skin - if no match is found for current
 51+ * // skin, 'default' is used - if default doesn't exist nothing is added
 52+ * 'themes' => array(
 53+ * 'default' => 'resources/foo/themes/default/foo.css',
 54+ * 'vector' => 'resources/foo/themes/vector.foo.css',
 55+ * ),
5556 * // List of keys of messages to include
5657 * 'messages' => array( 'foo-hello', 'foo-goodbye' ),
5758 * // Subclass of ResourceLoaderModule to use for custom modules
58 - * 'class' => 'ResourceLoaderSiteJSModule',
 59+ * 'class' => 'ResourceLoaderSiteJSModule',
5960 * ) );
6061 * @example
6162 * // Responds to a resource loading request
@@ -71,10 +72,10 @@
7273 /**
7374 * Runs text through a filter, caching the filtered result for future calls
7475 *
75 - * @param {string} $filter name of filter to run
76 - * @param {string} $data text to filter, such as JavaScript or CSS text
77 - * @param {string} $file path to file being filtered, (optional: only required for CSS to resolve paths)
78 - * @return {string} filtered data
 76+ * @param $filter String: name of filter to run
 77+ * @param $data String: text to filter, such as JavaScript or CSS text
 78+ * @param $file String: path to file being filtered, (optional: only required for CSS to resolve paths)
 79+ * @return String: filtered data
7980 */
8081 protected static function filter( $filter, $data ) {
8182 global $wgMemc;
@@ -126,9 +127,9 @@
127128 * Note that registering the same object under multiple names is not supported and may silently fail in all
128129 * kinds of interesting ways.
129130 *
130 - * @param {mixed} $name string of name of module or array of name/object pairs
131 - * @param {ResourceLoaderModule} $object module object (optional when using multiple-registration calling style)
132 - * @return {boolean} false if there were any errors, in which case one or more modules were not registered
 131+ * @param $name Mixed: string of name of module or array of name/object pairs
 132+ * @param $object ResourceLoaderModule: module object (optional when using multiple-registration calling style)
 133+ * @return Boolean: false if there were any errors, in which case one or more modules were not registered
133134 *
134135 * @todo We need much more clever error reporting, not just in detailing what happened, but in bringing errors to
135136 * the client in a way that they can easily see them if they want to, such as by using FireBug
@@ -156,7 +157,7 @@
157158 /**
158159 * Gets a map of all modules and their options
159160 *
160 - * @return {array} array( modulename => ResourceLoaderModule )
 161+ * @return Array: array( modulename => ResourceLoaderModule )
161162 */
162163 public static function getModules() {
163164 return self::$modules;
@@ -164,7 +165,8 @@
165166
166167 /**
167168 * Get the ResourceLoaderModule object for a given module name
168 - * @param $name string Module name
 169+ *
 170+ * @param $name String: module name
169171 * @return mixed ResourceLoaderModule or null if not registered
170172 */
171173 public static function getModule( $name ) {
@@ -174,12 +176,8 @@
175177 /**
176178 * Gets registration code for all modules, except pre-registered ones listed in self::$preRegisteredModules
177179 *
178 - * The $lang, $skin and $debug parameters are used to calculate the last modified timestamps for each
179 - * module.
180 - * @param $lang string Language code
181 - * @param $skin string Skin name
182 - * @param $debug bool Debug mode flag
183 - * @return {string} JavaScript code for registering all modules with the client loader
 180+ * @param $context ResourceLoaderContext object
 181+ * @return String: JavaScript code for registering all modules with the client loader
184182 */
185183 public static function getModuleRegistrations( ResourceLoaderContext $context ) {
186184 $scripts = '';
@@ -208,10 +206,9 @@
209207 /**
210208 * Get the highest modification time of all modules, based on a given combination of language code,
211209 * skin name and debug mode flag.
212 - * @param $lang string Language code
213 - * @param $skin string Skin name
214 - * @param $debug bool Debug mode flag
215 - * @return int UNIX timestamp
 210+ *
 211+ * @param $context ResourceLoaderContext object
 212+ * @return Integer: UNIX timestamp
216213 */
217214 public static function getHighestModifiedTime( ResourceLoaderContext $context ) {
218215 $time = 1; // wfTimestamp() treats 0 as 'now', so that's not a suitable choice
@@ -223,22 +220,10 @@
224221 return $time;
225222 }
226223
227 - /* Methods */
228 -
229 - /*
 224+ /**
230225 * Outputs a response to a resource load-request, including a content-type header
231226 *
232 - * @param {WebRequest} $request web request object to respond to
233 - * @param {string} $server web-accessible path to script server
234 - *
235 - * $options format:
236 - * array(
237 - * 'lang' => [string: language code, optional, code of default language by default],
238 - * 'skin' => [string: name of skin, optional, name of default skin by default],
239 - * 'dir' => [string: 'ltr' or 'rtl', optional, direction of lang by default],
240 - * 'debug' => [boolean: true to include debug-only scripts, optional, false by default],
241 - * 'only' => [string: 'scripts', 'styles' or 'messages', optional, if set only get part of the requested module]
242 - * )
 227+ * @param $context ResourceLoaderContext object
243228 */
244229 public static function respond( ResourceLoaderContext $context ) {
245230 // Split requested modules into two groups, modules and missing
Index: trunk/phase3/includes/ResourceLoaderModule.php
@@ -15,6 +15,7 @@
1616 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717 * http://www.gnu.org/copyleft/gpl.html
1818 *
 19+ * @file
1920 * @author Trevor Parscal
2021 * @author Roan Kattouw
2122 */
@@ -32,7 +33,8 @@
3334 /**
3435 * Get this module's name. This is set when the module is registered
3536 * with ResourceLoader::register()
36 - * @return mixed Name (string) or null if no name was set
 37+ *
 38+ * @return Mixed: name (string) or null if no name was set
3739 */
3840 public function getName() {
3941 return $this->name;
@@ -41,7 +43,8 @@
4244 /**
4345 * Set this module's name. This is called by ResourceLodaer::register()
4446 * when registering the module. Other code should not call this.
45 - * @param $name string Name
 47+ *
 48+ * @param $name String: name
4649 */
4750 public function setName( $name ) {
4851 $this->name = $name;
@@ -51,7 +54,8 @@
5255 * The maximum number of seconds to cache this module for in the
5356 * client-side (browser) cache. Override this only if you have a good
5457 * reason not to use $wgResourceLoaderClientMaxage.
55 - * @return int Cache maxage in seconds
 58+ *
 59+ * @return Integer: cache maxage in seconds
5660 */
5761 public function getClientMaxage() {
5862 global $wgResourceLoaderClientMaxage;
@@ -62,7 +66,8 @@
6367 * The maximum number of seconds to cache this module for in the
6468 * server-side (Squid / proxy) cache. Override this only if you have a
6569 * good reason not to use $wgResourceLoaderServerMaxage.
66 - * @return int Cache maxage in seconds
 70+ *
 71+ * @return Integer: cache maxage in seconds
6772 */
6873 public function getServerMaxage() {
6974 global $wgResourceLoaderServerMaxage;
@@ -81,17 +86,17 @@
8287 /**
8388 * Get all JS for this module for a given language and skin.
8489 * Includes all relevant JS except loader scripts.
85 - * @param $lang string Language code
86 - * @param $skin string Skin name
87 - * @param $debug bool Whether to include debug scripts
88 - * @return string JS
 90+ *
 91+ * @param $context ResourceLoaderContext object
 92+ * @return String: JS
8993 */
9094 public abstract function getScript( ResourceLoaderContext $context );
9195
9296 /**
9397 * Get all CSS for this module for a given skin.
94 - * @param $skin string Skin name
95 - * @return string CSS
 98+ *
 99+ * @param $context ResourceLoaderContext object
 100+ * @return String: CSS
96101 */
97102 public abstract function getStyle( ResourceLoaderContext $context );
98103
@@ -99,13 +104,15 @@
100105 * Get the messages needed for this module.
101106 *
102107 * To get a JSON blob with messages, use MessageBlobStore::get()
 108+ *
103109 * @return array of message keys. Keys may occur more than once
104110 */
105111 public abstract function getMessages();
106112
107113 /**
108114 * Get the loader JS for this module, if set.
109 - * @return mixed Loader JS (string) or false if no custom loader set
 115+ *
 116+ * @return Mixed: loader JS (string) or false if no custom loader set
110117 */
111118 public abstract function getLoaderScript();
112119
@@ -122,7 +129,7 @@
123130 *
124131 * To add dependencies dynamically on the client side, use a custom
125132 * loader script, see getLoaderScript()
126 - * @return array Array of module names (strings)
 133+ * @return Array of module names (strings)
127134 */
128135 public abstract function getDependencies();
129136
@@ -132,9 +139,8 @@
133140 * the highest of each of the relevant components' modification
134141 * timestamps. Whenever anything happens that changes the module's
135142 * contents for these parameters, the mtime should increase.
136 - * @param $lang string Language code
137 - * @param $skin string Skin name
138 - * @param $debug bool Debug mode flag
 143+ *
 144+ * @param $context ResourceLoaderContext object
139145 * @return int UNIX timestamp
140146 */
141147 public abstract function getModifiedTime( ResourceLoaderContext $context );
@@ -230,7 +236,8 @@
231237 /**
232238 * Add script files to this module. In order to be valid, a module
233239 * must contain at least one script file.
234 - * @param $scripts mixed Path to script file (string) or array of paths
 240+ *
 241+ * @param $scripts Mixed: path to script file (string) or array of paths
235242 */
236243 public function addScripts( $scripts ) {
237244 $this->scripts = array_merge( $this->scripts, (array)$scripts );
@@ -238,7 +245,8 @@
239246
240247 /**
241248 * Add style (CSS) files to this module.
242 - * @param $styles mixed Path to CSS file (string) or array of paths
 249+ *
 250+ * @param $styles Mixed: path to CSS file (string) or array of paths
243251 */
244252 public function addStyles( $styles ) {
245253 $this->styles = array_merge( $this->styles, (array)$styles );
@@ -246,7 +254,8 @@
247255
248256 /**
249257 * Add messages to this module.
250 - * @param $messages mixed Message key (string) or array of message keys
 258+ *
 259+ * @param $messages Mixed: message key (string) or array of message keys
251260 */
252261 public function addMessages( $messages ) {
253262 $this->messages = array_merge( $this->messages, (array)$messages );
@@ -264,7 +273,7 @@
265274 * To add dependencies dynamically on the client side, use a custom
266275 * loader (see addLoaders())
267276 *
268 - * @param $dependencies mixed Module name (string) or array of module names
 277+ * @param $dependencies Mixed: module name (string) or array of module names
269278 */
270279 public function addDependencies( $dependencies ) {
271280 $this->dependencies = array_merge( $this->dependencies, (array)$dependencies );
@@ -273,7 +282,8 @@
274283 /**
275284 * Add debug scripts to the module. These scripts are only included
276285 * in debug mode.
277 - * @param $scripts mixed Path to script file (string) or array of paths
 286+ *
 287+ * @param $scripts Mixed: path to script file (string) or array of paths
278288 */
279289 public function addDebugScripts( $scripts ) {
280290 $this->debugScripts = array_merge( $this->debugScripts, (array)$scripts );
@@ -282,8 +292,9 @@
283293 /**
284294 * Add language-specific scripts. These scripts are only included for
285295 * a given language.
286 - * @param $lang string Language code
287 - * @param $scripts mixed Path to script file (string) or array of paths
 296+ *
 297+ * @param $lang String: language code
 298+ * @param $scripts Mixed: path to script file (string) or array of paths
288299 */
289300 public function addLanguageScripts( $lang, $scripts ) {
290301 $this->languageScripts = array_merge_recursive(
@@ -295,8 +306,9 @@
296307 /**
297308 * Add skin-specific scripts. These scripts are only included for
298309 * a given skin.
299 - * @param $skin string Skin name, or 'default'
300 - * @param $scripts mixed Path to script file (string) or array of paths
 310+ *
 311+ * @param $skin String: skin name, or 'default'
 312+ * @param $scripts Mixed: path to script file (string) or array of paths
301313 */
302314 public function addSkinScripts( $skin, $scripts ) {
303315 $this->skinScripts = array_merge_recursive(
@@ -309,8 +321,9 @@
310322 * Add skin-specific CSS. These CSS files are only included for a
311323 * given skin. If there are no skin-specific CSS files for a skin,
312324 * the files defined for 'default' will be used, if any.
313 - * @param $skin string Skin name, or 'default'
314 - * @param $scripts mixed Path to CSS file (string) or array of paths
 325+ *
 326+ * @param $skin String: skin name, or 'default'
 327+ * @param $scripts Mixed: path to CSS file (string) or array of paths
315328 */
316329 public function addSkinStyles( $skin, $scripts ) {
317330 $this->skinStyles = array_merge_recursive(
@@ -330,7 +343,8 @@
331344 * Note that loader scripts are included on every page, so they should
332345 * be lightweight and use mediaWiki.loader.register()'s callback
333346 * feature to defer dependency calculation.
334 - * @param $scripts mixed Path to script file (string) or array of paths
 347+ *
 348+ * @param $scripts Mixed: path to script file (string) or array of paths
335349 */
336350 public function addLoaders( $scripts ) {
337351 $this->loaders = array_merge( $this->loaders, (array)$scripts );
@@ -399,10 +413,9 @@
400414 * relevant to the given language and skin are taken into account, and
401415 * files only relevant in debug mode are not taken into account when
402416 * debug mode is off.
403 - * @param $lang string Language code
404 - * @param $skin string Skin name
405 - * @param $debug bool Debug mode flag
406 - * @return int UNIX timestamp
 417+ *
 418+ * @param $context ResourceLoaderContext object
 419+ * @return Integer: UNIX timestamp
407420 */
408421 public function getModifiedTime( ResourceLoaderContext $context ) {
409422 if ( isset( $this->modifiedTime[$context->getHash()] ) ) {
@@ -442,7 +455,8 @@
443456 /**
444457 * Get the primary JS for this module. This is pulled from the
445458 * script files added through addScripts()
446 - * @return string JS
 459+ *
 460+ * @return String: JS
447461 */
448462 protected function getPrimaryScript() {
449463 return self::concatScripts( $this->scripts );
@@ -451,7 +465,8 @@
452466 /**
453467 * Get the primary CSS for this module. This is pulled from the CSS
454468 * files added through addStyles()
455 - * @return string JS
 469+ *
 470+ * @return String: JS
456471 */
457472 protected function getPrimaryStyle() {
458473 return self::concatStyles( $this->styles );
@@ -460,7 +475,8 @@
461476 /**
462477 * Get the debug JS for this module. This is pulled from the script
463478 * files added through addDebugScripts()
464 - * @return string JS
 479+ *
 480+ * @return String: JS
465481 */
466482 protected function getDebugScript() {
467483 return self::concatScripts( $this->debugScripts );
@@ -469,7 +485,8 @@
470486 /**
471487 * Get the language-specific JS for a given language. This is pulled
472488 * from the language-specific script files added through addLanguageScripts()
473 - * @return string JS
 489+ *
 490+ * @return String: JS
474491 */
475492 protected function getLanguageScript( $lang ) {
476493 if ( !isset( $this->languageScripts[$lang] ) ) {
@@ -481,7 +498,8 @@
482499 /**
483500 * Get the skin-specific JS for a given skin. This is pulled from the
484501 * skin-specific JS files added through addSkinScripts()
485 - * @return string JS
 502+ *
 503+ * @return String: JS
486504 */
487505 protected function getSkinScript( $skin ) {
488506 return self::concatScripts( self::getSkinFiles( $skin, $this->skinScripts ) );
@@ -490,7 +508,8 @@
491509 /**
492510 * Get the skin-specific CSS for a given skin. This is pulled from the
493511 * skin-specific CSS files added through addSkinStyles()
494 - * @return string CSS
 512+ *
 513+ * @return String: CSS
495514 */
496515 protected function getSkinStyle( $skin ) {
497516 return self::concatStyles( self::getSkinFiles( $skin, $this->skinStyles ) );
@@ -498,8 +517,9 @@
499518
500519 /**
501520 * Helper function to get skin-specific data from an array.
502 - * @param $skin string Skin name
503 - * @param $map array Map of skin names to arrays
 521+ *
 522+ * @param $skin String: skin name
 523+ * @param $map Array: map of skin names to arrays
504524 * @return $map[$skin] if set and non-empty, or $map['default'] if set, or an empty array
505525 */
506526 protected static function getSkinFiles( $skin, $map ) {
@@ -517,7 +537,8 @@
518538 /**
519539 * Get the files this module depends on indirectly for a given skin.
520540 * Currently these are only image files referenced by the module's CSS.
521 - * @param $skin string Skin name
 541+ *
 542+ * @param $skin String: skin name
522543 * @return array of files
523544 */
524545 protected function getFileDependencies( $skin ) {
@@ -553,8 +574,9 @@
554575 /**
555576 * Get the contents of a set of files and concatenate them, with
556577 * newlines in between. Each file is used only once.
557 - * @param $files array Array of file names
558 - * @return string Concatenated contents of $files
 578+ *
 579+ * @param $files Array of file names
 580+ * @return String: concatenated contents of $files
559581 */
560582 protected static function concatScripts( $files ) {
561583 return implode( "\n", array_map( 'file_get_contents', array_map( array( __CLASS__, 'remapFilename' ), array_unique( (array) $files ) ) ) );
@@ -563,8 +585,9 @@
564586 /**
565587 * Get the contents of a set of CSS files, remap then and concatenate
566588 * them, with newlines in between. Each file is used only once.
567 - * @param $files array Array of file names
568 - * @return string Concatenated and remapped contents of $files
 589+ *
 590+ * @param $files Array of file names
 591+ * @return String: concatenated and remapped contents of $files
569592 */
570593 protected static function concatStyles( $files ) {
571594 return implode( "\n", array_map( array( __CLASS__, 'remapStyle' ), array_unique( (array) $files ) ) );
@@ -572,7 +595,8 @@
573596
574597 /**
575598 * Remap a relative to $IP. Used as a callback for array_map()
576 - * @param $file string File name
 599+ *
 600+ * @param $file String: file name
577601 * @return string $IP/$file
578602 */
579603 protected static function remapFilename( $file ) {
@@ -584,7 +608,8 @@
585609 /**
586610 * Get the contents of a CSS file and run it through CSSMin::remap().
587611 * This wrapper is needed so we can use array_map() in concatStyles()
588 - * @param $file string File name
 612+ *
 613+ * @param $file String: file name
589614 * @return string Remapped CSS
590615 */
591616 protected static function remapStyle( $file ) {

Status & tagging log