Index: trunk/extensions/LocalJQuery/LocalJQuery.php |
— | — | @@ -0,0 +1,56 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Local jQuery - An extension to load jQuery from the wiki |
| 5 | + * |
| 6 | + * |
| 7 | + * For more info see http://mediawiki.org/wiki/Extension:Local_jQuery |
| 8 | + * |
| 9 | + * @file |
| 10 | + * @ingroup Extensions |
| 11 | + * @author Timo Tijhof, timotijhof@gmail.com |
| 12 | + * @copyright © 2011 Timo Tijhof |
| 13 | + * @license Creative Commons 1.0 Universal (CC0 1.0) Public Domain Dedication |
| 14 | + */ |
| 15 | + |
| 16 | +if( !defined( 'MEDIAWIKI' ) ) { |
| 17 | + echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
| 18 | + die( 1 ); |
| 19 | +} |
| 20 | + |
| 21 | +if ( version_compare( $wgVersion, '1.18', '<' ) ) { |
| 22 | + die( "LocalJQuery extension requires MediaWiki 1.18+\n" ); |
| 23 | +} |
| 24 | + |
| 25 | +$wgExtensionCredits['other'][] = array( |
| 26 | + 'path' => __FILE__, |
| 27 | + 'name' => 'Local jQuery', |
| 28 | + 'author' => array( 'Timo Tijhof' ), |
| 29 | + 'url' => 'http://mediawiki.org/wiki/Extension:Local_jQuery', |
| 30 | + 'descriptionmsg' => 'Load jQuery from [[MediaWiki:JQuery.js]] (with ResourceLoader)', |
| 31 | +); |
| 32 | + |
| 33 | +// Create a wiki module for MediaWiki:JQuery.js |
| 34 | +class JQueryWikiModule extends ResourceLoaderWikiModule { |
| 35 | + protected function getPages( ResourceLoaderContext $context ) { |
| 36 | + return array( |
| 37 | + 'MediaWiki:JQuery.js' => array( 'type' => 'script' ), |
| 38 | + ); |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +// Register it |
| 43 | +$wgResourceModules['jquery-wiki'] = array( |
| 44 | + 'class' => 'JQueryWikiModule', |
| 45 | +); |
| 46 | + |
| 47 | +// Load it during startup instead of the default jquery |
| 48 | +$wgHooks['ResourceLoaderGetStartupModules'][] = 'efLoadJQueryFromWiki'; |
| 49 | +function efLoadJQueryFromWiki( &$modules ) { |
| 50 | + $key = array_search( 'jquery', $modules ); |
| 51 | + if ( $key !== false ) { |
| 52 | + $modules[$key] = 'jquery-wiki'; |
| 53 | + } else { |
| 54 | + $modules[] = 'jquery-wiki'; |
| 55 | + } |
| 56 | + return true; |
| 57 | +} |
Property changes on: trunk/extensions/LocalJQuery/LocalJQuery.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 58 | + native |