Dear extension developers, this is an important notice for developers of extensions that load JavaScript or CSS. Updates are required in order to stay compatible with recent changes in MediaWiki (1.17). Luckily, SMW helps you to achieve this easily. Below is a quick walkthrough.
So far, SMW supports the loading of Javascript and CSS resources with the function "SMWOutputs::requireHeadItem". It takes two parameters: an ID (to avoid loading something twice) and an HTML snippet for the thing that is loaded. Example from SRF's timeline code: SMWOutputs::requireHeadItem( 'smw_tlhelper', '<script type="text/javascript" src="' . $wgScriptPath . '/extensions/SemanticResultFormats/Timeline/SRF_timeline.js"></script>' ); From 1.17 on, MediaWiki has its own support for efficiently loading and compressing resources that also reduces server load. To use this facility, it is necessary to declare so-called "resource modules". SMW has examples on how to do this in its file "./SMW.hooks.php". Essentially, you just need to specify the location of the file to be loaded, and the other resource modules that it requires to run. Each module also has an ID (e.g. "ext.smw.tooltips"). Now you need to do the following to make your extension MW 1.17 compatible while keeping downwards compatible with older MW version: (1) Define resource modules for the files that you need, just like done for SMW in SMW.hooks.php. Please use hierarchical names and a suitable group name for your extension (SMW uses "ext.smw" as a prefix, Semantic Result Formats might use "ext.srf" etc.). (2) Change all calls to SMWOutputs::requireHeadItem in your code to use the ID of the according resource module when loading a script. For example, the above ID 'smw_tlhelper' would probably not be used for resource modules. Rather, you could use something hierarchical like 'ext.srf.tlhelper'. The above should allow you to update your code in no time while keeping fully compatible with old versions of SMW and MW. If you use a lot of Javascript, then you could check out the capabilities of Resource Loader for your application. In particular, SMW also allows you to directly register a module for loading by using the function "SMWOutputs::requireModule". Thus, if preferred, you can do the MW version check in your own code and only call either this function or the old function directly. The above method only works in the current development version of SMW. SMW 1.5.3 uses the Resource Loader but it does not yet interpret the IDs used for scripts by extensions as resource loader IDs. So if you need to be compatible with SMW 1.5.3, you will have to call SMWOutputs::requireModule manually in such cases. Calling it in addition to RequireHeadItem would not do much harm, though. Cheers, Markus ------------------------------------------------------------------------------ The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now! http://p.sf.net/sfu/SAP-dev2dev _______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel