Fixes issues with complex background rules containing extra information after the...
[lhc/web/wiklou.git] / includes / ResourceLoaderModule.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @author Trevor Parscal
20 * @author Roan Kattouw
21 */
22
23 /**
24 * Interface for resource loader modules, with name registration and maxage functionality.
25 */
26 abstract class ResourceLoaderModule {
27 /* Protected Members */
28
29 protected $name = null;
30
31 /* Methods */
32
33 /**
34 * Get this module's name. This is set when the module is registered
35 * with ResourceLoader::register()
36 *
37 * @return Mixed: name (string) or null if no name was set
38 */
39 public function getName() {
40 return $this->name;
41 }
42
43 /**
44 * Set this module's name. This is called by ResourceLodaer::register()
45 * when registering the module. Other code should not call this.
46 *
47 * @param $name String: name
48 */
49 public function setName( $name ) {
50 $this->name = $name;
51 }
52
53 /**
54 * The maximum number of seconds to cache this module for in the
55 * client-side (browser) cache. Override this only if you have a good
56 * reason not to use $wgResourceLoaderClientMaxage.
57 *
58 * @return Integer: cache maxage in seconds
59 */
60 public function getClientMaxage() {
61 global $wgResourceLoaderClientMaxage;
62 return $wgResourceLoaderClientMaxage;
63 }
64
65 /**
66 * The maximum number of seconds to cache this module for in the
67 * server-side (Squid / proxy) cache. Override this only if you have a
68 * good reason not to use $wgResourceLoaderServerMaxage.
69 *
70 * @return Integer: cache maxage in seconds
71 */
72 public function getServerMaxage() {
73 global $wgResourceLoaderServerMaxage;
74 return $wgResourceLoaderServerMaxage;
75 }
76
77 /**
78 * Get whether CSS for this module should be flipped
79 */
80 public function getFlip( $context ) {
81 return $context->getDirection() === 'rtl';
82 }
83
84 /* Abstract Methods */
85
86 /**
87 * Get all JS for this module for a given language and skin.
88 * Includes all relevant JS except loader scripts.
89 *
90 * @param $context ResourceLoaderContext object
91 * @return String: JS
92 */
93 public abstract function getScript( ResourceLoaderContext $context );
94
95 /**
96 * Get all CSS for this module for a given skin.
97 *
98 * @param $context ResourceLoaderContext object
99 * @return String: CSS
100 */
101 public abstract function getStyle( ResourceLoaderContext $context );
102
103 /**
104 * Get the messages needed for this module.
105 *
106 * To get a JSON blob with messages, use MessageBlobStore::get()
107 *
108 * @return array of message keys. Keys may occur more than once
109 */
110 public abstract function getMessages();
111
112 /**
113 * Get the loader JS for this module, if set.
114 *
115 * @return Mixed: loader JS (string) or false if no custom loader set
116 */
117 public abstract function getLoaderScript();
118
119 /**
120 * Get a list of modules this module depends on.
121 *
122 * Dependency information is taken into account when loading a module
123 * on the client side. When adding a module on the server side,
124 * dependency information is NOT taken into account and YOU are
125 * responsible for adding dependent modules as well. If you don't do
126 * this, the client side loader will send a second request back to the
127 * server to fetch the missing modules, which kind of defeats the
128 * purpose of the resource loader.
129 *
130 * To add dependencies dynamically on the client side, use a custom
131 * loader script, see getLoaderScript()
132 * @return Array of module names (strings)
133 */
134 public abstract function getDependencies();
135
136 /**
137 * Get this module's last modification timestamp for a given
138 * combination of language, skin and debug mode flag. This is typically
139 * the highest of each of the relevant components' modification
140 * timestamps. Whenever anything happens that changes the module's
141 * contents for these parameters, the mtime should increase.
142 *
143 * @param $context ResourceLoaderContext object
144 * @return int UNIX timestamp
145 */
146 public abstract function getModifiedTime( ResourceLoaderContext $context );
147 }
148
149 /**
150 * Module based on local JS/CSS files. This is the most common type of module.
151 */
152 class ResourceLoaderFileModule extends ResourceLoaderModule {
153 /* Protected Members */
154
155 protected $scripts = array();
156 protected $styles = array();
157 protected $messages = array();
158 protected $dependencies = array();
159 protected $debugScripts = array();
160 protected $languageScripts = array();
161 protected $skinScripts = array();
162 protected $skinStyles = array();
163 protected $loaders = array();
164 protected $parameters = array();
165
166 // In-object cache for file dependencies
167 protected $fileDeps = array();
168 // In-object cache for mtime
169 protected $modifiedTime = array();
170
171 /* Methods */
172
173 /**
174 * Construct a new module from an options array.
175 *
176 * @param $options array Options array. If empty, an empty module will be constructed
177 *
178 * $options format:
179 * array(
180 * // Required module options (mutually exclusive)
181 * 'scripts' => 'dir/script.js' | array( 'dir/script1.js', 'dir/script2.js' ... ),
182 *
183 * // Optional module options
184 * 'languageScripts' => array(
185 * '[lang name]' => 'dir/lang.js' | '[lang name]' => array( 'dir/lang1.js', 'dir/lang2.js' ... )
186 * ...
187 * ),
188 * 'skinScripts' => 'dir/skin.js' | array( 'dir/skin1.js', 'dir/skin2.js' ... ),
189 * 'debugScripts' => 'dir/debug.js' | array( 'dir/debug1.js', 'dir/debug2.js' ... ),
190 *
191 * // Non-raw module options
192 * 'dependencies' => 'module' | array( 'module1', 'module2' ... )
193 * 'loaderScripts' => 'dir/loader.js' | array( 'dir/loader1.js', 'dir/loader2.js' ... ),
194 * 'styles' => 'dir/file.css' | array( 'dir/file1.css', 'dir/file2.css' ... ),
195 * 'skinStyles' => array(
196 * '[skin name]' => 'dir/skin.css' | '[skin name]' => array( 'dir/skin1.css', 'dir/skin2.css' ... )
197 * ...
198 * ),
199 * 'messages' => array( 'message1', 'message2' ... ),
200 * )
201 */
202 public function __construct( $options = array() ) {
203 foreach ( $options as $option => $value ) {
204 switch ( $option ) {
205 case 'scripts':
206 $this->scripts = (array)$value;
207 break;
208 case 'styles':
209 $this->styles = (array)$value;
210 break;
211 case 'messages':
212 $this->messages = (array)$value;
213 break;
214 case 'dependencies':
215 $this->dependencies = (array)$value;
216 break;
217 case 'debugScripts':
218 $this->debugScripts = (array)$value;
219 break;
220 case 'languageScripts':
221 $this->languageScripts = (array)$value;
222 break;
223 case 'skinScripts':
224 $this->skinScripts = (array)$value;
225 break;
226 case 'skinStyles':
227 $this->skinStyles = (array)$value;
228 break;
229 case 'loaders':
230 $this->loaders = (array)$value;
231 break;
232 }
233 }
234 }
235
236 /**
237 * Add script files to this module. In order to be valid, a module
238 * must contain at least one script file.
239 *
240 * @param $scripts Mixed: path to script file (string) or array of paths
241 */
242 public function addScripts( $scripts ) {
243 $this->scripts = array_merge( $this->scripts, (array)$scripts );
244 }
245
246 /**
247 * Add style (CSS) files to this module.
248 *
249 * @param $styles Mixed: path to CSS file (string) or array of paths
250 */
251 public function addStyles( $styles ) {
252 $this->styles = array_merge( $this->styles, (array)$styles );
253 }
254
255 /**
256 * Add messages to this module.
257 *
258 * @param $messages Mixed: message key (string) or array of message keys
259 */
260 public function addMessages( $messages ) {
261 $this->messages = array_merge( $this->messages, (array)$messages );
262 }
263
264 /**
265 * Add dependencies. Dependency information is taken into account when
266 * loading a module on the client side. When adding a module on the
267 * server side, dependency information is NOT taken into account and
268 * YOU are responsible for adding dependent modules as well. If you
269 * don't do this, the client side loader will send a second request
270 * back to the server to fetch the missing modules, which kind of
271 * defeats the point of using the resource loader in the first place.
272 *
273 * To add dependencies dynamically on the client side, use a custom
274 * loader (see addLoaders())
275 *
276 * @param $dependencies Mixed: module name (string) or array of module names
277 */
278 public function addDependencies( $dependencies ) {
279 $this->dependencies = array_merge( $this->dependencies, (array)$dependencies );
280 }
281
282 /**
283 * Add debug scripts to the module. These scripts are only included
284 * in debug mode.
285 *
286 * @param $scripts Mixed: path to script file (string) or array of paths
287 */
288 public function addDebugScripts( $scripts ) {
289 $this->debugScripts = array_merge( $this->debugScripts, (array)$scripts );
290 }
291
292 /**
293 * Add language-specific scripts. These scripts are only included for
294 * a given language.
295 *
296 * @param $lang String: language code
297 * @param $scripts Mixed: path to script file (string) or array of paths
298 */
299 public function addLanguageScripts( $lang, $scripts ) {
300 $this->languageScripts = array_merge_recursive(
301 $this->languageScripts,
302 array( $lang => $scripts )
303 );
304 }
305
306 /**
307 * Add skin-specific scripts. These scripts are only included for
308 * a given skin.
309 *
310 * @param $skin String: skin name, or 'default'
311 * @param $scripts Mixed: path to script file (string) or array of paths
312 */
313 public function addSkinScripts( $skin, $scripts ) {
314 $this->skinScripts = array_merge_recursive(
315 $this->skinScripts,
316 array( $skin => $scripts )
317 );
318 }
319
320 /**
321 * Add skin-specific CSS. These CSS files are only included for a
322 * given skin. If there are no skin-specific CSS files for a skin,
323 * the files defined for 'default' will be used, if any.
324 *
325 * @param $skin String: skin name, or 'default'
326 * @param $scripts Mixed: path to CSS file (string) or array of paths
327 */
328 public function addSkinStyles( $skin, $scripts ) {
329 $this->skinStyles = array_merge_recursive(
330 $this->skinStyles,
331 array( $skin => $scripts )
332 );
333 }
334
335 /**
336 * Add loader scripts. These scripts are loaded on every page and are
337 * responsible for registering this module using
338 * mediaWiki.loader.register(). If there are no loader scripts defined,
339 * the resource loader will register the module itself.
340 *
341 * Loader scripts are used to determine a module's dependencies
342 * dynamically on the client side (e.g. based on browser type/version).
343 * Note that loader scripts are included on every page, so they should
344 * be lightweight and use mediaWiki.loader.register()'s callback
345 * feature to defer dependency calculation.
346 *
347 * @param $scripts Mixed: path to script file (string) or array of paths
348 */
349 public function addLoaders( $scripts ) {
350 $this->loaders = array_merge( $this->loaders, (array)$scripts );
351 }
352
353 public function getScript( ResourceLoaderContext $context ) {
354 $retval = $this->getPrimaryScript() . "\n" .
355 $this->getLanguageScript( $context->getLanguage() ) . "\n" .
356 $this->getSkinScript( $context->getSkin() );
357
358 if ( $context->getDebug() ) {
359 $retval .= $this->getDebugScript();
360 }
361
362 return $retval;
363 }
364
365 public function getStyle( ResourceLoaderContext $context ) {
366 $style = $this->getPrimaryStyle() . "\n" . $this->getSkinStyle( $context->getSkin() );
367
368 // Extract and store the list of referenced files
369 $files = CSSMin::getLocalFileReferences( $style );
370
371 // Only store if modified
372 if ( $files !== $this->getFileDependencies( $context->getSkin() ) ) {
373 $encFiles = FormatJson::encode( $files );
374 $dbw = wfGetDb( DB_MASTER );
375 $dbw->replace( 'module_deps',
376 array( array( 'md_module', 'md_skin' ) ), array(
377 'md_module' => $this->getName(),
378 'md_skin' => $context->getSkin(),
379 'md_deps' => $encFiles,
380 )
381 );
382
383 // Save into memcached
384 global $wgMemc;
385
386 $key = wfMemcKey( 'resourceloader', 'module_deps', $this->getName(), $context->getSkin() );
387 $wgMemc->set( $key, $encFiles );
388 }
389
390 return $style;
391 }
392
393 public function getMessages() {
394 return $this->messages;
395 }
396
397 public function getDependencies() {
398 return $this->dependencies;
399 }
400
401 public function getLoaderScript() {
402 if ( count( $this->loaders ) == 0 ) {
403 return false;
404 }
405
406 return self::concatScripts( $this->loaders );
407 }
408
409 /**
410 * Get the last modified timestamp of this module, which is calculated
411 * as the highest last modified timestamp of its constituent files and
412 * the files it depends on (see getFileDependencies()). Only files
413 * relevant to the given language and skin are taken into account, and
414 * files only relevant in debug mode are not taken into account when
415 * debug mode is off.
416 *
417 * @param $context ResourceLoaderContext object
418 * @return Integer: UNIX timestamp
419 */
420 public function getModifiedTime( ResourceLoaderContext $context ) {
421 if ( isset( $this->modifiedTime[$context->getHash()] ) ) {
422 return $this->modifiedTime[$context->getHash()];
423 }
424
425 $files = array_merge(
426 $this->scripts,
427 $this->styles,
428 $context->getDebug() ? $this->debugScripts : array(),
429 isset( $this->languageScripts[$context->getLanguage()] ) ?
430 (array) $this->languageScripts[$context->getLanguage()] : array(),
431 (array) self::getSkinFiles( $context->getSkin(), $this->skinScripts ),
432 (array) self::getSkinFiles( $context->getSkin(), $this->skinStyles ),
433 $this->loaders,
434 $this->getFileDependencies( $context->getSkin() )
435 );
436
437 $filesMtime = max( array_map( 'filemtime', array_map( array( __CLASS__, 'remapFilename' ), $files ) ) );
438
439 // Get the mtime of the message blob
440 // TODO: This timestamp is queried a lot and queried separately for each module. Maybe it should be put in memcached?
441 $dbr = wfGetDb( DB_SLAVE );
442 $msgBlobMtime = $dbr->selectField( 'msg_resource', 'mr_timestamp', array(
443 'mr_resource' => $this->getName(),
444 'mr_lang' => $context->getLanguage()
445 ), __METHOD__
446 );
447 $msgBlobMtime = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0;
448
449 $this->modifiedTime[$context->getHash()] = max( $filesMtime, $msgBlobMtime );
450 return $this->modifiedTime[$context->getHash()];
451 }
452
453 /* Protected Members */
454
455 /**
456 * Get the primary JS for this module. This is pulled from the
457 * script files added through addScripts()
458 *
459 * @return String: JS
460 */
461 protected function getPrimaryScript() {
462 return self::concatScripts( $this->scripts );
463 }
464
465 /**
466 * Get the primary CSS for this module. This is pulled from the CSS
467 * files added through addStyles()
468 *
469 * @return String: JS
470 */
471 protected function getPrimaryStyle() {
472 return self::concatStyles( $this->styles );
473 }
474
475 /**
476 * Get the debug JS for this module. This is pulled from the script
477 * files added through addDebugScripts()
478 *
479 * @return String: JS
480 */
481 protected function getDebugScript() {
482 return self::concatScripts( $this->debugScripts );
483 }
484
485 /**
486 * Get the language-specific JS for a given language. This is pulled
487 * from the language-specific script files added through addLanguageScripts()
488 *
489 * @return String: JS
490 */
491 protected function getLanguageScript( $lang ) {
492 if ( !isset( $this->languageScripts[$lang] ) ) {
493 return '';
494 }
495 return self::concatScripts( $this->languageScripts[$lang] );
496 }
497
498 /**
499 * Get the skin-specific JS for a given skin. This is pulled from the
500 * skin-specific JS files added through addSkinScripts()
501 *
502 * @return String: JS
503 */
504 protected function getSkinScript( $skin ) {
505 return self::concatScripts( self::getSkinFiles( $skin, $this->skinScripts ) );
506 }
507
508 /**
509 * Get the skin-specific CSS for a given skin. This is pulled from the
510 * skin-specific CSS files added through addSkinStyles()
511 *
512 * @return String: CSS
513 */
514 protected function getSkinStyle( $skin ) {
515 return self::concatStyles( self::getSkinFiles( $skin, $this->skinStyles ) );
516 }
517
518 /**
519 * Helper function to get skin-specific data from an array.
520 *
521 * @param $skin String: skin name
522 * @param $map Array: map of skin names to arrays
523 * @return $map[$skin] if set and non-empty, or $map['default'] if set, or an empty array
524 */
525 protected static function getSkinFiles( $skin, $map ) {
526 $retval = array();
527
528 if ( isset( $map[$skin] ) && $map[$skin] ) {
529 $retval = $map[$skin];
530 } else if ( isset( $map['default'] ) ) {
531 $retval = $map['default'];
532 }
533
534 return $retval;
535 }
536
537 /**
538 * Get the files this module depends on indirectly for a given skin.
539 * Currently these are only image files referenced by the module's CSS.
540 *
541 * @param $skin String: skin name
542 * @return array of files
543 */
544 protected function getFileDependencies( $skin ) {
545 // Try in-object cache first
546 if ( isset( $this->fileDeps[$skin] ) ) {
547 return $this->fileDeps[$skin];
548 }
549
550 // Now try memcached
551 global $wgMemc;
552
553 $key = wfMemcKey( 'resourceloader', 'module_deps', $this->getName(), $skin );
554 $deps = $wgMemc->get( $key );
555
556 if ( !$deps ) {
557 $dbr = wfGetDb( DB_SLAVE );
558 $deps = $dbr->selectField( 'module_deps', 'md_deps', array(
559 'md_module' => $this->getName(),
560 'md_skin' => $skin,
561 ), __METHOD__
562 );
563 if ( !$deps ) {
564 $deps = '[]'; // Empty array so we can do negative caching
565 }
566 $wgMemc->set( $key, $deps );
567 }
568
569 $this->fileDeps = FormatJson::decode( $deps, true );
570
571 return $this->fileDeps;
572 }
573
574 /**
575 * Get the contents of a set of files and concatenate them, with
576 * newlines in between. Each file is used only once.
577 *
578 * @param $files Array of file names
579 * @return String: concatenated contents of $files
580 */
581 protected static function concatScripts( $files ) {
582 return implode( "\n", array_map( 'file_get_contents', array_map( array( __CLASS__, 'remapFilename' ), array_unique( (array) $files ) ) ) );
583 }
584
585 /**
586 * Get the contents of a set of CSS files, remap then and concatenate
587 * them, with newlines in between. Each file is used only once.
588 *
589 * @param $files Array of file names
590 * @return String: concatenated and remapped contents of $files
591 */
592 protected static function concatStyles( $files ) {
593 return implode( "\n", array_map( array( __CLASS__, 'remapStyle' ), array_unique( (array) $files ) ) );
594 }
595
596 /**
597 * Remap a relative to $IP. Used as a callback for array_map()
598 *
599 * @param $file String: file name
600 * @return string $IP/$file
601 */
602 protected static function remapFilename( $file ) {
603 global $IP;
604
605 return "$IP/$file";
606 }
607
608 /**
609 * Get the contents of a CSS file and run it through CSSMin::remap().
610 * This wrapper is needed so we can use array_map() in concatStyles()
611 *
612 * @param $file String: file name
613 * @return string Remapped CSS
614 */
615 protected static function remapStyle( $file ) {
616 global $wgUseDataURLs;
617 return CSSMin::remap( file_get_contents( self::remapFilename( $file ) ), dirname( $file ), $wgUseDataURLs );
618 }
619 }
620
621 /**
622 * Custom module for MediaWiki:Common.js and MediaWiki:Skinname.js
623 * TODO: Add Site CSS functionality too
624 */
625 class ResourceLoaderSiteModule extends ResourceLoaderModule {
626 /* Protected Members */
627
628 // In-object cache for modified time
629 protected $modifiedTime = null;
630
631 /* Methods */
632
633 public function getScript( ResourceLoaderContext $context ) {
634 return Skin::newFromKey( $context->getSkin() )->generateUserJs();
635 }
636
637 public function getModifiedTime( ResourceLoaderContext $context ) {
638 if ( isset( $this->modifiedTime[$context->getHash()] ) ) {
639 return $this->modifiedTime[$context->getHash()];
640 }
641
642 // HACK: We duplicate the message names from generateUserJs()
643 // here and weird things (i.e. mtime moving backwards) can happen
644 // when a MediaWiki:Something.js page is deleted
645 $jsPages = array( Title::makeTitle( NS_MEDIAWIKI, 'Common.js' ),
646 Title::makeTitle( NS_MEDIAWIKI, ucfirst( $context->getSkin() ) . '.js' )
647 );
648
649 // Do batch existence check
650 // TODO: This would work better if page_touched were loaded by this as well
651 $lb = new LinkBatch( $jsPages );
652 $lb->execute();
653
654 $this->modifiedTime = 1; // wfTimestamp() interprets 0 as "now"
655
656 foreach ( $jsPages as $jsPage ) {
657 if ( $jsPage->exists() ) {
658 $this->modifiedTime = max( $this->modifiedTime, wfTimestamp( TS_UNIX, $jsPage->getTouched() ) );
659 }
660 }
661
662 return $this->modifiedTime;
663 }
664
665 public function getStyle( ResourceLoaderContext $context ) { return ''; }
666 public function getMessages() { return array(); }
667 public function getLoaderScript() { return ''; }
668 public function getDependencies() { return array(); }
669 }
670
671
672 class ResourceLoaderStartUpModule extends ResourceLoaderModule {
673 /* Protected Members */
674
675 protected $modifiedTime = null;
676
677 /* Methods */
678
679 public function getScript( ResourceLoaderContext $context ) {
680 global $IP;
681
682 $scripts = file_get_contents( "$IP/resources/startup.js" );
683
684 if ( $context->getOnly() === 'scripts' ) {
685 // Get all module registrations
686 $registration = ResourceLoader::getModuleRegistrations( $context );
687 // Build configuration
688 $config = FormatJson::encode(
689 array( 'server' => $context->getServer(), 'debug' => $context->getDebug() )
690 );
691 // Add a well-known start-up function
692 $scripts .= "window.startUp = function() { $registration mediaWiki.config.set( $config ); };";
693 // Build load query for jquery and mediawiki modules
694 $query = wfArrayToCGI(
695 array(
696 'modules' => implode( '|', array( 'jquery', 'mediawiki' ) ),
697 'only' => 'scripts',
698 'lang' => $context->getLanguage(),
699 'dir' => $context->getDirection(),
700 'skin' => $context->getSkin(),
701 'debug' => $context->getDebug(),
702 'version' => wfTimestamp( TS_ISO_8601, round( max(
703 ResourceLoader::getModule( 'jquery' )->getModifiedTime( $context ),
704 ResourceLoader::getModule( 'mediawiki' )->getModifiedTime( $context )
705 ), -2 ) )
706 )
707 );
708
709 // Build HTML code for loading jquery and mediawiki modules
710 $loadScript = Html::linkedScript( $context->getServer() . "?$query" );
711 // Add code to add jquery and mediawiki loading code; only if the current client is compatible
712 $scripts .= "if ( isCompatible() ) { document.write( '$loadScript' ); }";
713 // Delete the compatible function - it's not needed anymore
714 $scripts .= "delete window['isCompatible'];";
715 }
716
717 return $scripts;
718 }
719
720 public function getModifiedTime( ResourceLoaderContext $context ) {
721 global $IP;
722
723 if ( !is_null( $this->modifiedTime ) ) {
724 return $this->modifiedTime;
725 }
726
727 // HACK getHighestModifiedTime() calls this function, so protect against infinite recursion
728 $this->modifiedTime = filemtime( "$IP/resources/startup.js" );
729 $this->modifiedTime = ResourceLoader::getHighestModifiedTime( $context );
730 return $this->modifiedTime;
731 }
732
733 public function getClientMaxage() {
734 return 300; // 5 minutes
735 }
736
737 public function getServerMaxage() {
738 return 300; // 5 minutes
739 }
740
741 public function getStyle( ResourceLoaderContext $context ) { return ''; }
742
743 public function getFlip( $context ) {
744 global $wgContLang;
745
746 return $wgContLang->getDir() !== $context->getDirection();
747 }
748 public function getMessages() { return array(); }
749 public function getLoaderScript() { return ''; }
750 public function getDependencies() { return array(); }
751 }