r74249 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74248‎ | r74249 | r74250 >
Date:10:09, 4 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7 - Moved hooks to a new hooks class
Modified paths:
  • /trunk/extensions/Maps/Maps.hooks.php (added) (history)
  • /trunk/extensions/Maps/Maps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Maps.php
@@ -71,11 +71,16 @@
7272 // Register the initialization function of Maps.
7373 $wgExtensionFunctions[] = 'efMapsSetup';
7474
75 - $wgHooks['AdminLinks'][] = 'efMapsAddToAdminLinks';
 75+ $wgAutoloadClasses['MapsHooks'] = dirname( __FILE__ ) . '/Maps.hooks.php';
7676
77 - $wgHooks['UnitTestsList'][] = 'efMapsUnitTests';
 77+ // Since 0.2
 78+ $wgHooks['AdminLinks'][] = 'MapsHooks::addToAdminLinks';
7879
79 - $wgHooks['SkinAfterBottomScripts'][] = 'efMapsAddOnloadFunction';
 80+ // Since 0.6.5
 81+ $wgHooks['UnitTestsList'][] = 'MapsHooks::registerUnitTests';
 82+
 83+ // Since 0.7
 84+ $wgHooks['SkinAfterBottomScripts'][] = 'MapsHooks::addOnloadFunction';
8085 }
8186
8287 /**
@@ -88,10 +93,8 @@
8994 function efMapsSetup() {
9095 global $wgExtensionCredits, $wgLang, $wgAutoloadClasses;
9196 global $egMapsDefaultService, $egMapsAvailableServices;
92 - global $egMapsDir, $egMapsUseMinJs, $egMapsEvilJS;
 97+ global $egMapsDir, $egMapsUseMinJs;
9398
94 - $egMapsEvilJS = '';
95 -
9699 // Autoload the "includes/" classes and interfaces.
97100 $incDir = dirname( __FILE__ ) . '/includes/';
98101 $wgAutoloadClasses['MapsMapper'] = $incDir . 'Maps_Mapper.php';
@@ -170,50 +173,4 @@
171174 );
172175
173176 return true;
174 -}
175 -
176 -/**
177 - * Adds a link to Admin Links page.
178 - *
179 - * @since 0.2
180 - *
181 - * @return true
182 - */
183 -function efMapsAddToAdminLinks( &$admin_links_tree ) {
184 - $displaying_data_section = $admin_links_tree->getSection( wfMsg( 'smw_adminlinks_displayingdata' ) );
185 -
186 - // Escape if SMW hasn't added links.
187 - if ( is_null( $displaying_data_section ) ) return true;
188 - $smw_docu_row = $displaying_data_section->getRow( 'smw' );
189 -
190 - $maps_docu_label = wfMsg( 'adminlinks_documentation', wfMsg( 'maps_name' ) );
191 - $smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://mapping.referata.com/wiki/Maps', $maps_docu_label ) );
192 -
193 - return true;
194 -}
195 -
196 -/**
197 - * Hook to add PHPUnit test cases.
198 - *
199 - * @since 0.6.5
200 - *
201 - * @param array $files
202 - */
203 -function efMapsUnitTests( array &$files ) {
204 - $testDir = dirname( __FILE__ ) . '/test/';
205 - //$files[] = $testDir . 'MapsCoordinateParserTest.php';
206 - return true;
207 -}
208 -
209 -/**
210 - * Adds the map JS to the bottom of the page. This is a hack to get
211 - * around the lack of inline script support in the MW 1.17 resource loader.
212 - *
213 - * @since 0.7
214 - */
215 -function efMapsAddOnloadFunction( $skin, &$text ) {
216 - if ( method_exists( 'ParserOutput', 'addModules' ) ) {
217 - $text .= Html::inlineScript( 'if (window.runMapsOnloadHook) runMapsOnloadHook();' );
218 - }
219 - return true;
220177 }
\ No newline at end of file
Index: trunk/extensions/Maps/Maps.hooks.php
@@ -0,0 +1,62 @@
 2+<?php
 3+
 4+/**
 5+ * Static class for hooks handled by the Maps extension.
 6+ *
 7+ * @since 0.7
 8+ *
 9+ * @file Maps.hooks.php
 10+ * @ingroup Maps
 11+ *
 12+ * @author Jeroen De Dauw
 13+ */
 14+final class MapsHooks {
 15+
 16+ /**
 17+ * Adds a link to Admin Links page.
 18+ *
 19+ * @since 0.7
 20+ *
 21+ * @return true
 22+ */
 23+ public static function addToAdminLinks( &$admin_links_tree ) {
 24+ $displaying_data_section = $admin_links_tree->getSection( wfMsg( 'smw_adminlinks_displayingdata' ) );
 25+
 26+ // Escape if SMW hasn't added links.
 27+ if ( is_null( $displaying_data_section ) ) return true;
 28+ $smw_docu_row = $displaying_data_section->getRow( 'smw' );
 29+
 30+ $maps_docu_label = wfMsg( 'adminlinks_documentation', wfMsg( 'maps_name' ) );
 31+ $smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://mapping.referata.com/wiki/Maps', $maps_docu_label ) );
 32+
 33+ return true;
 34+ }
 35+
 36+ /**
 37+ * Hook to add PHPUnit test cases.
 38+ *
 39+ * @since 0.7
 40+ *
 41+ * @param array $files
 42+ */
 43+ public static function registerUnitTests( array &$files ) {
 44+ $testDir = dirname( __FILE__ ) . '/test/';
 45+ //$files[] = $testDir . 'MapsCoordinateParserTest.php';
 46+ return true;
 47+ }
 48+
 49+ /**
 50+ * Adds the map JS to the bottom of the page. This is a hack to get
 51+ * around the lack of inline script support in the MW 1.17 resource loader.
 52+ *
 53+ * @since 0.7
 54+ */
 55+ public static function addOnloadFunction( $skin, &$text ) {
 56+ if ( method_exists( 'ParserOutput', 'addModules' ) ) {
 57+ $text .= Html::inlineScript( 'if (window.runMapsOnloadHook) runMapsOnloadHook();' );
 58+ }
 59+
 60+ return true;
 61+ }
 62+
 63+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/Maps.hooks.php
___________________________________________________________________
Added: svn:eol-style
164 + native

Status & tagging log