Index: trunk/phase3/includes/resourceloader/ResourceLoaderSiteModule.php |
— | — | @@ -29,7 +29,9 @@ |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Gets list of pages used by this module |
33 | | - * |
| 33 | + * |
| 34 | + * @param $context ResourceLoaderContext |
| 35 | + * |
34 | 36 | * @return Array: List of pages |
35 | 37 | */ |
36 | 38 | protected function getPages( ResourceLoaderContext $context ) { |
Index: trunk/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -569,6 +569,8 @@ |
570 | 570 | * @param $messages Mixed: List of messages associated with this module. May either be an |
571 | 571 | * associative array mapping message key to value, or a JSON-encoded message blob containing |
572 | 572 | * the same data, wrapped in an XmlJsCode object. |
| 573 | + * |
| 574 | + * @return string |
573 | 575 | */ |
574 | 576 | public static function makeLoaderImplementScript( $name, $scripts, $styles, $messages ) { |
575 | 577 | if ( is_string( $scripts ) ) { |
— | — | @@ -591,6 +593,8 @@ |
592 | 594 | * |
593 | 595 | * @param $messages Mixed: Either an associative array mapping message key to value, or a |
594 | 596 | * JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object. |
| 597 | + * |
| 598 | + * @return string |
595 | 599 | */ |
596 | 600 | public static function makeMessageSetScript( $messages ) { |
597 | 601 | return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) ); |
— | — | @@ -601,6 +605,8 @@ |
602 | 606 | * single stylesheet with @media blocks. |
603 | 607 | * |
604 | 608 | * @param $styles Array: List of CSS strings keyed by media type |
| 609 | + * |
| 610 | + * @return string |
605 | 611 | */ |
606 | 612 | public static function makeCombinedStyles( array $styles ) { |
607 | 613 | $out = ''; |
— | — | @@ -630,6 +636,11 @@ |
631 | 637 | * |
632 | 638 | * - ResourceLoader::makeLoaderStateScript( array( $name => $state, ... ) ): |
633 | 639 | * Set the state of modules with the given names to the given states |
| 640 | + * |
| 641 | + * @param $name string |
| 642 | + * @param $state |
| 643 | + * |
| 644 | + * @return string |
634 | 645 | */ |
635 | 646 | public static function makeLoaderStateScript( $name, $state = null ) { |
636 | 647 | if ( is_array( $name ) ) { |
— | — | @@ -650,6 +661,8 @@ |
651 | 662 | * @param $dependencies Array: List of module names on which this module depends |
652 | 663 | * @param $group String: Group which the module is in. |
653 | 664 | * @param $script String: JavaScript code |
| 665 | + * |
| 666 | + * @return string |
654 | 667 | */ |
655 | 668 | public static function makeCustomLoaderScript( $name, $version, $dependencies, $group, $script ) { |
656 | 669 | $script = str_replace( "\n", "\n\t", trim( $script ) ); |
— | — | @@ -679,6 +692,8 @@ |
680 | 693 | * @param $version Integer: Module version number as a timestamp |
681 | 694 | * @param $dependencies Array: List of module names on which this module depends |
682 | 695 | * @param $group String: group which the module is in. |
| 696 | + * |
| 697 | + * @return string |
683 | 698 | */ |
684 | 699 | public static function makeLoaderRegisterScript( $name, $version = null, |
685 | 700 | $dependencies = null, $group = null ) |
— | — | @@ -697,6 +712,8 @@ |
698 | 713 | * present. |
699 | 714 | * |
700 | 715 | * @param $script String: JavaScript code |
| 716 | + * |
| 717 | + * @return string |
701 | 718 | */ |
702 | 719 | public static function makeLoaderConditionalScript( $script ) { |
703 | 720 | $script = str_replace( "\n", "\n\t", trim( $script ) ); |
— | — | @@ -708,11 +725,13 @@ |
709 | 726 | * the given value. |
710 | 727 | * |
711 | 728 | * @param $configuration Array: List of configuration values keyed by variable name |
| 729 | + * |
| 730 | + * @return string |
712 | 731 | */ |
713 | 732 | public static function makeConfigSetScript( array $configuration ) { |
714 | 733 | return Xml::encodeJsCall( 'mw.config.set', array( $configuration ) ); |
715 | 734 | } |
716 | | - |
| 735 | + |
717 | 736 | /** |
718 | 737 | * Convert an array of module names to a packed query string. |
719 | 738 | * |
— | — | @@ -730,7 +749,7 @@ |
731 | 750 | $suffix = $pos === false ? $module : substr( $module, $pos + 1 ); |
732 | 751 | $groups[$prefix][] = $suffix; |
733 | 752 | } |
734 | | - |
| 753 | + |
735 | 754 | $arr = array(); |
736 | 755 | foreach ( $groups as $prefix => $suffixes ) { |
737 | 756 | $p = $prefix === '' ? '' : $prefix . '.'; |
— | — | @@ -739,7 +758,7 @@ |
740 | 759 | $str = implode( '|', $arr ); |
741 | 760 | return str_replace( ".", "!", $str ); # bug 28840 |
742 | 761 | } |
743 | | - |
| 762 | + |
744 | 763 | /** |
745 | 764 | * Determine whether debug mode was requested |
746 | 765 | * Order of priority is 1) request param, 2) cookie, 3) $wg setting |
— | — | @@ -748,8 +767,9 @@ |
749 | 768 | public static function inDebugMode() { |
750 | 769 | global $wgRequest, $wgResourceLoaderDebug; |
751 | 770 | static $retval = null; |
752 | | - if ( !is_null( $retval ) ) |
| 771 | + if ( !is_null( $retval ) ) { |
753 | 772 | return $retval; |
| 773 | + } |
754 | 774 | return $retval = $wgRequest->getFuzzyBool( 'debug', |
755 | 775 | $wgRequest->getCookie( 'resourceLoaderDebug', '', $wgResourceLoaderDebug ) ); |
756 | 776 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php |
— | — | @@ -33,6 +33,10 @@ |
34 | 34 | |
35 | 35 | /* Methods */ |
36 | 36 | |
| 37 | + /** |
| 38 | + * @param $context ResourceLoaderContext |
| 39 | + * @return array|int|Mixed |
| 40 | + */ |
37 | 41 | public function getModifiedTime( ResourceLoaderContext $context ) { |
38 | 42 | $hash = $context->getHash(); |
39 | 43 | if ( isset( $this->modifiedTime[$hash] ) ) { |
— | — | @@ -66,11 +70,19 @@ |
67 | 71 | } |
68 | 72 | } |
69 | 73 | |
| 74 | + /** |
| 75 | + * @param $context ResourceLoaderContext |
| 76 | + * @return string |
| 77 | + */ |
70 | 78 | public function getScript( ResourceLoaderContext $context ) { |
71 | 79 | return Xml::encodeJsCall( 'mw.user.options.set', |
72 | 80 | array( $this->contextUserOptions( $context ) ) ); |
73 | 81 | } |
74 | 82 | |
| 83 | + /** |
| 84 | + * @param $context ResourceLoaderContext |
| 85 | + * @return array |
| 86 | + */ |
75 | 87 | public function getStyles( ResourceLoaderContext $context ) { |
76 | 88 | global $wgAllowUserCssPrefs; |
77 | 89 | |
— | — | @@ -111,6 +123,9 @@ |
112 | 124 | return array(); |
113 | 125 | } |
114 | 126 | |
| 127 | + /** |
| 128 | + * @return string |
| 129 | + */ |
115 | 130 | public function getGroup() { |
116 | 131 | return 'private'; |
117 | 132 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderContext.php |
— | — | @@ -99,18 +99,30 @@ |
100 | 100 | return $retval; |
101 | 101 | } |
102 | 102 | |
| 103 | + /** |
| 104 | + * @return ResourceLoader |
| 105 | + */ |
103 | 106 | public function getResourceLoader() { |
104 | 107 | return $this->resourceLoader; |
105 | 108 | } |
106 | | - |
| 109 | + |
| 110 | + /** |
| 111 | + * @return WebRequest |
| 112 | + */ |
107 | 113 | public function getRequest() { |
108 | 114 | return $this->request; |
109 | 115 | } |
110 | 116 | |
| 117 | + /** |
| 118 | + * @return array |
| 119 | + */ |
111 | 120 | public function getModules() { |
112 | 121 | return $this->modules; |
113 | 122 | } |
114 | 123 | |
| 124 | + /** |
| 125 | + * @return string |
| 126 | + */ |
115 | 127 | public function getLanguage() { |
116 | 128 | if ( $this->language === null ) { |
117 | 129 | global $wgLang; |
— | — | @@ -122,6 +134,9 @@ |
123 | 135 | return $this->language; |
124 | 136 | } |
125 | 137 | |
| 138 | + /** |
| 139 | + * @return string |
| 140 | + */ |
126 | 141 | public function getDirection() { |
127 | 142 | if ( $this->direction === null ) { |
128 | 143 | $this->direction = $this->request->getVal( 'dir' ); |
— | — | @@ -133,38 +148,65 @@ |
134 | 149 | return $this->direction; |
135 | 150 | } |
136 | 151 | |
| 152 | + /** |
| 153 | + * @return string |
| 154 | + */ |
137 | 155 | public function getSkin() { |
138 | 156 | return $this->skin; |
139 | 157 | } |
140 | 158 | |
| 159 | + /** |
| 160 | + * @return string |
| 161 | + */ |
141 | 162 | public function getUser() { |
142 | 163 | return $this->user; |
143 | 164 | } |
144 | 165 | |
| 166 | + /** |
| 167 | + * @return bool |
| 168 | + */ |
145 | 169 | public function getDebug() { |
146 | 170 | return $this->debug; |
147 | 171 | } |
148 | 172 | |
| 173 | + /** |
| 174 | + * @return String |
| 175 | + */ |
149 | 176 | public function getOnly() { |
150 | 177 | return $this->only; |
151 | 178 | } |
152 | 179 | |
| 180 | + /** |
| 181 | + * @return String |
| 182 | + */ |
153 | 183 | public function getVersion() { |
154 | 184 | return $this->version; |
155 | 185 | } |
156 | 186 | |
| 187 | + /** |
| 188 | + * @return bool |
| 189 | + */ |
157 | 190 | public function shouldIncludeScripts() { |
158 | 191 | return is_null( $this->only ) || $this->only === 'scripts'; |
159 | 192 | } |
160 | 193 | |
| 194 | + /** |
| 195 | + * @return bool |
| 196 | + */ |
161 | 197 | public function shouldIncludeStyles() { |
162 | 198 | return is_null( $this->only ) || $this->only === 'styles'; |
163 | 199 | } |
164 | 200 | |
| 201 | + /** |
| 202 | + * @return bool |
| 203 | + */ |
165 | 204 | public function shouldIncludeMessages() { |
166 | 205 | return is_null( $this->only ) || $this->only === 'messages'; |
167 | 206 | } |
168 | 207 | |
| 208 | + /** |
| 209 | + * @return string |
| 210 | + */ |
169 | 211 | public function getHash() { |
170 | 212 | if ( !isset( $this->hash ) ) { |
171 | 213 | $this->hash = implode( '|', array( |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserGroupsModule.php |
— | — | @@ -26,6 +26,10 @@ |
27 | 27 | /* Protected Methods */ |
28 | 28 | protected $origin = self::ORIGIN_USER_SITEWIDE; |
29 | 29 | |
| 30 | + /** |
| 31 | + * @param $context ResourceLoaderContext |
| 32 | + * @return array |
| 33 | + */ |
30 | 34 | protected function getPages( ResourceLoaderContext $context ) { |
31 | 35 | if ( $context->getUser() ) { |
32 | 36 | $user = User::newFromName( $context->getUser() ); |
— | — | @@ -44,9 +48,12 @@ |
45 | 49 | } |
46 | 50 | return array(); |
47 | 51 | } |
48 | | - |
| 52 | + |
49 | 53 | /* Methods */ |
50 | | - |
| 54 | + |
| 55 | + /** |
| 56 | + * @return string |
| 57 | + */ |
51 | 58 | public function getGroup() { |
52 | 59 | return 'user'; |
53 | 60 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php |
— | — | @@ -28,6 +28,10 @@ |
29 | 29 | /* Protected Methods */ |
30 | 30 | protected $origin = self::ORIGIN_USER_INDIVIDUAL; |
31 | 31 | |
| 32 | + /** |
| 33 | + * @param $context ResourceLoaderContext |
| 34 | + * @return array |
| 35 | + */ |
32 | 36 | protected function getPages( ResourceLoaderContext $context ) { |
33 | 37 | if ( $context->getUser() ) { |
34 | 38 | $username = $context->getUser(); |
— | — | @@ -42,9 +46,12 @@ |
43 | 47 | } |
44 | 48 | return array(); |
45 | 49 | } |
46 | | - |
| 50 | + |
47 | 51 | /* Methods */ |
48 | | - |
| 52 | + |
| 53 | + /** |
| 54 | + * @return string |
| 55 | + */ |
49 | 56 | public function getGroup() { |
50 | 57 | return 'user'; |
51 | 58 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php |
— | — | @@ -292,7 +292,10 @@ |
293 | 293 | public function getGroup() { |
294 | 294 | return $this->group; |
295 | 295 | } |
296 | | - |
| 296 | + |
| 297 | + /** |
| 298 | + * @return string |
| 299 | + */ |
297 | 300 | public function getPosition() { |
298 | 301 | return $this->position; |
299 | 302 | } |
— | — | @@ -375,10 +378,18 @@ |
376 | 379 | |
377 | 380 | /* Protected Methods */ |
378 | 381 | |
| 382 | + /** |
| 383 | + * @param $path string |
| 384 | + * @return string |
| 385 | + */ |
379 | 386 | protected function getLocalPath( $path ) { |
380 | 387 | return "{$this->localBasePath}/$path"; |
381 | 388 | } |
382 | | - |
| 389 | + |
| 390 | + /** |
| 391 | + * @param $path string |
| 392 | + * @return string |
| 393 | + */ |
383 | 394 | protected function getRemotePath( $path ) { |
384 | 395 | return "{$this->remoteBasePath}/$path"; |
385 | 396 | } |
— | — | @@ -494,6 +505,9 @@ |
495 | 506 | * |
496 | 507 | * @param $styles Array: List of media type/list of file paths pairs, to read, remap and |
497 | 508 | * concetenate |
| 509 | + * |
| 510 | + * @param $flip bool |
| 511 | + * |
498 | 512 | * @return Array: List of concatenated and remapped CSS data from $styles, |
499 | 513 | * keyed by media type |
500 | 514 | */ |
— | — | @@ -521,6 +535,8 @@ |
522 | 536 | * This method can be used as a callback for array_map() |
523 | 537 | * |
524 | 538 | * @param $path String: File path of script file to read |
| 539 | + * @param $flip bool |
| 540 | + * |
525 | 541 | * @return String: CSS data in script file |
526 | 542 | */ |
527 | 543 | protected function readStyleFile( $path, $flip ) { |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderModule.php |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | * Set this module's origin. This is called by ResourceLodaer::register() |
101 | 101 | * when registering the module. Other code should not call this. |
102 | 102 | * |
103 | | - * @param $name Int origin |
| 103 | + * @param $origin Int origin |
104 | 104 | */ |
105 | 105 | public function setOrigin( $origin ) { |
106 | 106 | $this->origin = $origin; |
— | — | @@ -164,6 +164,8 @@ |
165 | 165 | * Where on the HTML page should this module's JS be loaded? |
166 | 166 | * 'top': in the <head> |
167 | 167 | * 'bottom': at the bottom of the <body> |
| 168 | + * |
| 169 | + * @return string |
168 | 170 | */ |
169 | 171 | public function getPosition() { |
170 | 172 | return 'bottom'; |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderNoscriptModule.php |
— | — | @@ -30,7 +30,9 @@ |
31 | 31 | /** |
32 | 32 | * Gets list of pages used by this module. Obviously, it makes absolutely no |
33 | 33 | * sense to include JavaScript files here... :D |
34 | | - * |
| 34 | + * |
| 35 | + * @param $context ResourceLoaderContext |
| 36 | + * |
35 | 37 | * @return Array: List of pages |
36 | 38 | */ |
37 | 39 | protected function getPages( ResourceLoaderContext $context ) { |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php |
— | — | @@ -162,6 +162,10 @@ |
163 | 163 | |
164 | 164 | /* Methods */ |
165 | 165 | |
| 166 | + /** |
| 167 | + * @param $context ResourceLoaderContext |
| 168 | + * @return string |
| 169 | + */ |
166 | 170 | public function getScript( ResourceLoaderContext $context ) { |
167 | 171 | global $IP, $wgLoadScript, $wgLegacyJavaScriptGlobals; |
168 | 172 | |
— | — | @@ -211,6 +215,10 @@ |
212 | 216 | return $out; |
213 | 217 | } |
214 | 218 | |
| 219 | + /** |
| 220 | + * @param $context ResourceLoaderContext |
| 221 | + * @return array|mixed |
| 222 | + */ |
215 | 223 | public function getModifiedTime( ResourceLoaderContext $context ) { |
216 | 224 | global $IP, $wgCacheEpoch; |
217 | 225 | |
— | — | @@ -235,9 +243,12 @@ |
236 | 244 | } |
237 | 245 | return $this->modifiedTime[$hash] = $time; |
238 | 246 | } |
239 | | - |
| 247 | + |
240 | 248 | /* Methods */ |
241 | | - |
| 249 | + |
| 250 | + /** |
| 251 | + * @return string |
| 252 | + */ |
242 | 253 | public function getGroup() { |
243 | 254 | return 'startup'; |
244 | 255 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php |
— | — | @@ -66,6 +66,10 @@ |
67 | 67 | |
68 | 68 | /* Methods */ |
69 | 69 | |
| 70 | + /** |
| 71 | + * @param $context ResourceLoaderContext |
| 72 | + * @return string |
| 73 | + */ |
70 | 74 | public function getScript( ResourceLoaderContext $context ) { |
71 | 75 | $scripts = ''; |
72 | 76 | foreach ( $this->getPages( $context ) as $titleText => $options ) { |
— | — | @@ -87,6 +91,10 @@ |
88 | 92 | return $scripts; |
89 | 93 | } |
90 | 94 | |
| 95 | + /** |
| 96 | + * @param $context ResourceLoaderContext |
| 97 | + * @return array |
| 98 | + */ |
91 | 99 | public function getStyles( ResourceLoaderContext $context ) { |
92 | 100 | global $wgScriptPath; |
93 | 101 | |
— | — | @@ -119,6 +127,10 @@ |
120 | 128 | return $styles; |
121 | 129 | } |
122 | 130 | |
| 131 | + /** |
| 132 | + * @param $context ResourceLoaderContext |
| 133 | + * @return int|mixed |
| 134 | + */ |
123 | 135 | public function getModifiedTime( ResourceLoaderContext $context ) { |
124 | 136 | $modifiedTime = 1; // wfTimestamp() interprets 0 as "now" |
125 | 137 | $mtimes = $this->getTitleMtimes( $context ); |
— | — | @@ -127,7 +139,11 @@ |
128 | 140 | } |
129 | 141 | return $modifiedTime; |
130 | 142 | } |
131 | | - |
| 143 | + |
| 144 | + /** |
| 145 | + * @param $context ResourceLoaderContext |
| 146 | + * @return bool |
| 147 | + */ |
132 | 148 | public function isKnownEmpty( ResourceLoaderContext $context ) { |
133 | 149 | return count( $this->getTitleMtimes( $context ) ) == 0; |
134 | 150 | } |