r75538 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75537‎ | r75538 | r75539 >
Date:13:48, 27 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed resource path issue, found by RoanKattouw
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/SMW.hooks.php (added) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Outputs.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Outputs.php
@@ -47,6 +47,7 @@
4848
4949 if ( is_numeric( $id ) ) {
5050 global $wgOut;
 51+
5152 switch ( $id ) {
5253 case SMW_HEADER_TOOLTIP:
5354 $wgOut->addModules( 'ext.smw.tooltips' );
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php
@@ -60,6 +60,8 @@
6161 $wgExtensionAliasesFiles['SemanticMediaWiki'] = $smwgIP . 'languages/SMW_Aliases.php';
6262
6363 // Set up autoloading; essentially all classes should be autoloaded!
 64+ $wgAutoloadClasses['SMWHooks'] = $smwgIP . 'SMW.hooks.php';
 65+
6466 $wgAutoloadClasses['SMWParserExtensions'] = $smwgIP . 'includes/SMW_ParserExtensions.php';
6567 $wgAutoloadClasses['SMWInfolink'] = $smwgIP . 'includes/SMW_Infolink.php';
6668 // $wgAutoloadClasses['SMWFactbox'] = $smwgIP . 'includes/SMW_Factbox.php';
@@ -229,7 +231,7 @@
230232 $wgHooks['ArticleFromTitle'][] = 'smwfOnArticleFromTitle'; // special implementations for property/type articles
231233 $wgHooks['ParserFirstCallInit'][] = 'smwfRegisterParserFunctions';
232234
233 - $wgHooks['ResourceLoaderRegisterModules'][] = 'smwfRegisterResourceLoaderModules';
 235+ $wgHooks['ResourceLoaderRegisterModules'][] = 'SMWHooks::registerResourceLoaderModules';
234236
235237 $smwgMW_1_14 = true; // assume latest 1.14 API
236238
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -55,7 +55,7 @@
5656 $wgHooks['ParserTestTables'][] = 'smwfOnParserTestTables';
5757 $wgHooks['AdminLinks'][] = 'smwfAddToAdminLinks';
5858
59 - $wgHooks['ResourceLoaderRegisterModules'][] = 'smwfRegisterResourceLoaderModules';
 59+ $wgHooks['ResourceLoaderRegisterModules'][] = 'SMWHooks::registerResourceLoaderModules';
6060
6161 if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) {
6262 // For MediaWiki 1.17 alpha and later.
@@ -69,6 +69,8 @@
7070 $wgExtensionAliasesFiles['SemanticMediaWiki'] = $smwgIP . 'languages/SMW_Aliases.php';
7171
7272 // Set up autoloading; essentially all classes should be autoloaded!
 73+ $wgAutoloadClasses['SMWHooks'] = $smwgIP . 'SMW.hooks.php';
 74+
7375 $wgAutoloadClasses['SMWParserExtensions'] = $smwgIP . 'includes/SMW_ParserExtensions.php';
7476 $wgAutoloadClasses['SMWInfolink'] = $smwgIP . 'includes/SMW_Infolink.php';
7577 $wgAutoloadClasses['SMWFactbox'] = $smwgIP . 'includes/SMW_Factbox.php';
@@ -512,44 +514,6 @@
513515 }
514516
515517 /**
516 - * Register the resource modules for the resource loader.
517 - *
518 - * @since 1.5.3
519 - *
520 - * @param ResourceLoader $resourceLoader
521 - *
522 - * @return true
523 - */
524 -function smwfRegisterResourceLoaderModules( ResourceLoader &$resourceLoader ) {
525 - global $smwgScriptPath, $wgContLang;
526 -
527 - $modules = array(
528 - 'ext.smw.style' => array(
529 - 'styles' => $smwgScriptPath . ( $wgContLang->isRTL() ? '/skins/SMW_custom_rtl.css' : '/skins/SMW_custom.css' )
530 - ),
531 - 'ext.smw.tooltips' => array(
532 - 'scripts' => $smwgScriptPath . '/skins/SMW_tooltip.js',
533 - 'dependencies' => array(
534 - 'mediawiki.legacy.wikibits',
535 - 'ext.smw.style'
536 - )
537 - ),
538 - 'ext.smw.sorttable' => array(
539 - 'scripts' => $smwgScriptPath . '/skins/SMW_sorttable.js',
540 - 'dependencies' => 'ext.smw.style'
541 - )
542 - );
543 -
544 - foreach ( $modules as $name => $resources ) {
545 - $resourceLoader->register( $name, new ResourceLoaderFileModule(
546 - array_merge_recursive( $resources, array( 'group' => 'ext.smw' ) )
547 - ) );
548 - }
549 -
550 - return true;
551 -}
552 -
553 -/**
554518 * This hook registers parser functions and hooks to the given parser. It is
555519 * called during SMW initialisation. Note that parser hooks are something different
556520 * than MW hooks in general, which explains the two-level registration.
Index: trunk/extensions/SemanticMediaWiki/SMW.hooks.php
@@ -0,0 +1,60 @@
 2+<?php
 3+
 4+/**
 5+ * Static class for hooks handled by the SMW extension.
 6+ *
 7+ * This class is an attempt to clean up SMW initialization, as it's rather messy at the moment,
 8+ * and the split between SMW and SMW light is not very clean.
 9+ *
 10+ * @since 1.5.3
 11+ *
 12+ * @file SMW.hooks.php
 13+ * @ingroup SMW
 14+ *
 15+ * @author Jeroen De Dauw
 16+ */
 17+final class SMWHooks {
 18+
 19+ /**
 20+ * Register the resource modules for the resource loader.
 21+ *
 22+ * @since 1.5.3
 23+ *
 24+ * @param ResourceLoader $resourceLoader
 25+ *
 26+ * @return true
 27+ */
 28+ public static function registerResourceLoaderModules( ResourceLoader &$resourceLoader ) {
 29+ global $wgContLang;
 30+
 31+ $modules = array(
 32+ 'ext.smw.style' => array(
 33+ 'styles' => ( $wgContLang->isRTL() ? 'SMW_custom_rtl.css' : 'SMW_custom.css' )
 34+ ),
 35+ 'ext.smw.tooltips' => array(
 36+ 'scripts' => 'SMW_tooltip.js',
 37+ 'dependencies' => array(
 38+ 'mediawiki.legacy.wikibits',
 39+ 'ext.smw.style'
 40+ )
 41+ ),
 42+ 'ext.smw.sorttable' => array(
 43+ 'scripts' => dirname( __FILE__ ) . 'SMW_sorttable.js',
 44+ 'dependencies' => 'ext.smw.style'
 45+ )
 46+ );
 47+
 48+ foreach ( $modules as $name => $resources ) {
 49+ $resourceLoader->register(
 50+ $name,
 51+ new ResourceLoaderFileModule(
 52+ array_merge_recursive( $resources, array( 'group' => 'ext.smw' ) ),
 53+ 'extensions/SemanticMediaWiki/skins/'
 54+ )
 55+ );
 56+ }
 57+
 58+ return true;
 59+ }
 60+
 61+}
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMediaWiki/SMW.hooks.php
___________________________________________________________________
Added: svn:eol-style
162 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r75539Follow up to r75538 - forgot to remove this functionjeroendedauw13:50, 27 October 2010

Status & tagging log