Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMaps.php |
— | — | @@ -20,5 +20,8 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
24 | | -$egMapsServices['yahoomaps']['qp'] = array( 'class' => 'SMYahooMapsQP', 'file' => 'YahooMaps/SM_YahooMapsQP.php', 'local' => true ); |
25 | | -$egMapsServices['yahoomaps']['fi'] = array( 'class' => 'SMYahooMapsFormInput', 'file' => 'YahooMaps/SM_YahooMapsFormInput.php', 'local' => true ); |
\ No newline at end of file |
| 24 | +$wgAutoloadClasses['SMYahooMapsQP'] = dirname( __FILE__ ) . '/SM_YahooMapsQP.php'; |
| 25 | +$wgAutoloadClasses['SMYahooMapsFormInput'] = dirname( __FILE__ ) . '/SM_YahooMapsFormInput.php'; |
| 26 | + |
| 27 | +$egMapsServices['yahoomaps']['features']['qp'] = 'SMYahooMapsQP'; |
| 28 | +$egMapsServices['yahoomaps']['features']['fi'] = 'SMYahooMapsFormInput'; |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayers.php |
— | — | @@ -20,5 +20,8 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
24 | | -$egMapsServices['openlayers']['qp'] = array( 'class' => 'SMOpenLayersQP', 'file' => 'OpenLayers/SM_OpenLayersQP.php', 'local' => true ); |
25 | | -$egMapsServices['openlayers']['fi'] = array( 'class' => 'SMOpenLayersFormInput', 'file' => 'OpenLayers/SM_OpenLayersFormInput.php', 'local' => true ); |
\ No newline at end of file |
| 24 | +$wgAutoloadClasses['SMOpenLayersQP'] = dirname( __FILE__ ) . '/SM_OpenLayersQP.php'; |
| 25 | +$wgAutoloadClasses['SMOpenLayersFormInput'] = dirname( __FILE__ ) . '/SM_OpenLayersFormInput.php'; |
| 26 | + |
| 27 | +$egMapsServices['openlayers']['features']['qp'] = 'SMOpenLayersQP'; |
| 28 | +$egMapsServices['openlayers']['features']['fi'] = 'SMOpenLayersFormInput'; |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/SM_Settings.php |
— | — | @@ -25,22 +25,13 @@ |
26 | 26 | # (named) Array of String. This array contains the available features for Maps. |
27 | 27 | # The array element name contains an abbriviation, used for code references, |
28 | 28 | # and in the service data arrays, the value is the human readible version for displaying purpouses. |
29 | | -$egMapsAvailableFeatures['qp'] = array( |
30 | | - 'name' => 'Query Printer', |
31 | | - 'class' => 'SMQueryPrinters', |
32 | | - 'file' => 'SemanticMaps/QueryPrinters/SM_QueryPrinters.php' |
33 | | - ); |
| 29 | +include_once $smgDir . 'QueryPrinters/SM_QueryPrinters.php'; // Query printers |
| 30 | +include_once $smgDir . 'FormInputs/SM_FormInputs.php'; // Form imputs |
34 | 31 | |
35 | | -$egMapsAvailableFeatures['fi'] = array( |
36 | | - 'name' => 'Form input', |
37 | | - 'class' => 'SMFormInputs', |
38 | | - 'file' => 'SemanticMaps/FormInputs/SM_FormInputs.php' |
39 | | - ); |
40 | 32 | |
41 | 33 | |
42 | 34 | |
43 | 35 | |
44 | | - |
45 | 36 | # Mapping services configuration |
46 | 37 | |
47 | 38 | # Include the mapping services that should be loaded into Semantic Maps. |
Index: trunk/extensions/SemanticMaps/FormInputs/SM_FormInputs.php |
— | — | @@ -13,6 +13,10 @@ |
14 | 14 | die( 'Not an entry point.' ); |
15 | 15 | } |
16 | 16 | |
| 17 | +$wgAutoloadClasses['SMFormInputs'] = __FILE__; |
| 18 | + |
| 19 | +$wgHooks['MappingFeatureLoad'][] = 'SMFormInputs::initialize'; |
| 20 | + |
17 | 21 | final class SMFormInputs { |
18 | 22 | |
19 | 23 | public static $parameters = array(); |
— | — | @@ -24,13 +28,13 @@ |
25 | 29 | if ( isset( $sfgFormPrinter ) ) { |
26 | 30 | $hasFormInputs = false; |
27 | 31 | |
28 | | - $wgAutoloadClasses['SMFormInput'] = $smgDir . 'FormInputs/SM_FormInput.php'; |
| 32 | + $wgAutoloadClasses['SMFormInput'] = dirname( __FILE__ ) . '/SM_FormInput.php'; |
29 | 33 | |
30 | 34 | self::initializeParams(); |
31 | 35 | |
32 | 36 | foreach ( $egMapsServices as $serviceName => $serviceData ) { |
33 | 37 | // Check if the service has a form input |
34 | | - $hasFI = array_key_exists( 'fi', $serviceData ); |
| 38 | + $hasFI = array_key_exists( 'fi', $serviceData['features'] ); |
35 | 39 | |
36 | 40 | // If the service has no FI, skipt it and continue with the next one. |
37 | 41 | if ( !$hasFI ) continue; |
— | — | @@ -39,15 +43,17 @@ |
40 | 44 | $hasFormInputs = true; |
41 | 45 | |
42 | 46 | // Add the result form input type for the service name. |
43 | | - self::initFormHook( $serviceName, $serviceData['fi'], $serviceName ); |
| 47 | + self::initFormHook( $serviceName, $serviceName ); |
44 | 48 | |
45 | 49 | // Loop through the service alliases, and add them as form input types. |
46 | | - foreach ( $serviceData['aliases'] as $alias ) self::initFormHook( $alias, $serviceData['fi'], $serviceName ); |
| 50 | + foreach ( $serviceData['aliases'] as $alias ) self::initFormHook( $alias, $serviceName ); |
47 | 51 | } |
48 | 52 | |
49 | 53 | // Add the 'map' form input type if there are mapping services that have FI's loaded. |
50 | 54 | if ( $hasFormInputs ) self::initFormHook( 'map' ); |
51 | 55 | } |
| 56 | + |
| 57 | + return true; |
52 | 58 | } |
53 | 59 | |
54 | 60 | private static function initializeParams() { |
— | — | @@ -82,17 +88,10 @@ |
83 | 89 | * @param array $fi |
84 | 90 | * @param strig $mainName |
85 | 91 | */ |
86 | | - private static function initFormHook( $inputName, array $fi = null, $mainName = '' ) { |
| 92 | + private static function initFormHook( $inputName, $mainName = '' ) { |
87 | 93 | global $wgAutoloadClasses, $sfgFormPrinter, $smgDir; |
88 | | - |
89 | | - if ( isset( $fi ) ) { |
90 | | - if ( ! array_key_exists( $fi['class'], $wgAutoloadClasses ) ) { |
91 | | - $file = array_key_exists( 'local', $fi ) && $fi['local'] ? $smgDir . $fi['file'] : $fi['file']; |
92 | | - $wgAutoloadClasses[$fi['class']] = $file; |
93 | | - } |
94 | | - } |
95 | 94 | |
96 | | - // Add the form input hook for the service |
| 95 | + // Add the form input hook for the service. |
97 | 96 | $field_args = array(); |
98 | 97 | if ( strlen( $mainName ) > 0 ) $field_args['service_name'] = $mainName; |
99 | 98 | $sfgFormPrinter->setInputTypeHook( $inputName, 'smfSelectFormInputHTML', $field_args ); |
— | — | @@ -124,7 +123,7 @@ |
125 | 124 | |
126 | 125 | // Ensure the service is valid and create a new instance of the handling form input class. |
127 | 126 | $service_name = MapsMapper::getValidService( $service_name, 'fi' ); |
128 | | - $formInput = new $egMapsServices[$service_name]['fi']['class'](); |
| 127 | + $formInput = new $egMapsServices[$service_name]['features']['fi'](); |
129 | 128 | |
130 | 129 | // Get and return the form input HTML from the hook corresponding with the provided service. |
131 | 130 | return $formInput->formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ); |
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSM.php |
— | — | @@ -20,5 +20,7 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
24 | | -$egMapsServices['osm']['qp'] = array( 'class' => 'SMOSMQP', 'file' => 'OpenStreetMap/SM_OSMQP.php', 'local' => true ); |
25 | | -// $egMapsServices['osm']['fi'] = array('class' => 'SMOSMFormInput', 'file' => 'extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php', 'local' => false); |
\ No newline at end of file |
| 24 | +$wgAutoloadClasses['SMOSMQP'] = dirname( __FILE__ ) . '/SM_SMOSMQP.php'; |
| 25 | + |
| 26 | +$egMapsServices['osm']['features']['qp'] = 'SMOSMQP'; |
| 27 | +// $egMapsServices['osm']['features']['fi'] = 'SMOSMFormInput'; |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | // Only initialize the extension when all dependencies are present. |
38 | 38 | if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) { |
39 | | - define( 'SM_VERSION', '0.6 a7' ); |
| 39 | + define( 'SM_VERSION', '0.6 a8' ); |
40 | 40 | |
41 | 41 | $smgScriptPath = ( isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps'; |
42 | 42 | $smgDir = dirname( __FILE__ ) . '/'; |
— | — | @@ -74,7 +74,11 @@ |
75 | 75 | 'path' => __FILE__, |
76 | 76 | 'name' => wfMsg( 'semanticmaps_name' ), |
77 | 77 | 'version' => SM_VERSION, |
78 | | - 'author' => array( '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]', '[http://www.mediawiki.org/wiki/User:Yaron_Koren Yaron Koren]', 'others' ), |
| 78 | + 'author' => array( |
| 79 | + '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]', |
| 80 | + '[http://www.mediawiki.org/wiki/User:Yaron_Koren Yaron Koren]', |
| 81 | + '[http://www.ohloh.net/p/semanticmaps/contributors others]' |
| 82 | + ), |
79 | 83 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Maps', |
80 | 84 | 'description' => wfMsgExt( 'semanticmaps_desc', 'parsemag', $services_list ), |
81 | 85 | ); |
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php |
— | — | @@ -13,6 +13,10 @@ |
14 | 14 | die( 'Not an entry point.' ); |
15 | 15 | } |
16 | 16 | |
| 17 | +$wgAutoloadClasses['SMQueryPrinters'] = __FILE__; |
| 18 | + |
| 19 | +$wgHooks['MappingFeatureLoad'][] = 'SMQueryPrinters::initialize'; |
| 20 | + |
17 | 21 | final class SMQueryPrinters { |
18 | 22 | |
19 | 23 | public static $parameters = array(); |
— | — | @@ -22,15 +26,17 @@ |
23 | 27 | */ |
24 | 28 | public static function initialize() { |
25 | 29 | global $smgDir, $wgAutoloadClasses, $egMapsServices; |
26 | | - $wgAutoloadClasses['SMMapPrinter'] = $smgDir . 'QueryPrinters/SM_MapPrinter.php'; |
27 | 30 | |
| 31 | + $wgAutoloadClasses['SMMapper'] = dirname( __FILE__ ) . '/SM_Mapper.php'; |
| 32 | + $wgAutoloadClasses['SMMapPrinter'] = dirname( __FILE__ ) . '/SM_MapPrinter.php'; |
| 33 | + |
28 | 34 | self::initializeParams(); |
29 | 35 | |
30 | 36 | $hasQueryPrinters = false; |
31 | | - |
| 37 | + |
32 | 38 | foreach ( $egMapsServices as $serviceName => $serviceData ) { |
33 | | - // Check if the service has a query printer |
34 | | - $hasQP = array_key_exists( 'qp', $serviceData ); |
| 39 | + // Check if the service has a query printer. |
| 40 | + $hasQP = array_key_exists( 'qp', $serviceData['features'] ); |
35 | 41 | |
36 | 42 | // If the service has no QP, skipt it and continue with the next one. |
37 | 43 | if ( !$hasQP ) continue; |
— | — | @@ -39,11 +45,13 @@ |
40 | 46 | $hasQueryPrinters = true; |
41 | 47 | |
42 | 48 | // Initiate the format. |
43 | | - self::initFormat( $serviceName, $serviceData['qp'], $serviceData['aliases'] ); |
| 49 | + self::initFormat( $serviceName, $serviceData['features']['qp'], $serviceData['aliases'] ); |
44 | 50 | } |
45 | 51 | |
46 | 52 | // Add the 'map' result format if there are mapping services that have QP's loaded. |
47 | | - if ( $hasQueryPrinters ) self::initFormat( 'map', array( 'class' => 'SMMapper', 'file' => 'QueryPrinters/SM_Mapper.php', 'local' => true ), array() ); |
| 53 | + if ( $hasQueryPrinters ) self::initFormat( 'map', 'SMMapper' ); |
| 54 | + |
| 55 | + return true; |
48 | 56 | } |
49 | 57 | |
50 | 58 | private static function initializeParams() { |
— | — | @@ -127,27 +135,21 @@ |
128 | 136 | * Add the result format for a mapping service or alias. |
129 | 137 | * |
130 | 138 | * @param string $format |
131 | | - * @param array $qp |
| 139 | + * @param string $formatClass |
132 | 140 | * @param array $aliases |
133 | 141 | */ |
134 | | - private static function initFormat( $format, array $qp, array $aliases ) { |
| 142 | + private static function initFormat( $format, $formatClass, array $aliases = array() ) { |
135 | 143 | global $wgAutoloadClasses, $smgDir, $smwgResultAliases; |
136 | 144 | |
137 | | - // Load the QP class when it's not loaded yet. |
138 | | - if ( ! array_key_exists( $qp['class'], $wgAutoloadClasses ) ) { |
139 | | - $file = array_key_exists( 'local', $qp ) && $qp['local'] ? $smgDir . $qp['file'] : $qp['file']; |
140 | | - $wgAutoloadClasses[$qp['class']] = $file; |
141 | | - } |
142 | | - |
143 | 145 | // Add the QP to SMW. |
144 | | - self::addFormatQP( $format, $qp['class'] ); |
| 146 | + self::addFormatQP( $format, $formatClass ); |
145 | 147 | |
146 | 148 | // If SMW supports aliasing, add the aliases to $smwgResultAliases. |
147 | 149 | if ( isset( $smwgResultAliases ) ) { |
148 | 150 | $smwgResultAliases[$format] = $aliases; |
149 | 151 | } |
150 | 152 | else { // If SMW does not support aliasing, add every alias as a format. |
151 | | - foreach ( $aliases as $alias ) self::addFormatQP( $alias, $qp['class'] ); |
| 153 | + foreach ( $aliases as $alias ) self::addFormatQP( $alias, $formatClass ); |
152 | 154 | } |
153 | 155 | } |
154 | 156 | |
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_Mapper.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | |
28 | 28 | $service = MapsMapper::getValidService( $format, 'qp' ); |
29 | 29 | |
30 | | - $this->queryPrinter = new $egMapsServices[$service]['qp']['class']( $format, $inline ); |
| 30 | + $this->queryPrinter = new $egMapsServices[$service]['features']['qp']( $format, $inline ); |
31 | 31 | } |
32 | 32 | |
33 | 33 | public static function getAliases() { |
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMaps.php |
— | — | @@ -20,5 +20,8 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
24 | | -$egMapsServices['googlemaps2']['qp'] = array( 'class' => 'SMGoogleMapsQP', 'file' => 'GoogleMaps/SM_GoogleMapsQP.php', 'local' => true ); |
25 | | -$egMapsServices['googlemaps2']['fi'] = array( 'class' => 'SMGoogleMapsFormInput', 'file' => 'GoogleMaps/SM_GoogleMapsFormInput.php', 'local' => true ); |
\ No newline at end of file |
| 24 | +$wgAutoloadClasses['SMGoogleMapsQP'] = dirname( __FILE__ ) . '/SM_GoogleMapsQP.php'; |
| 25 | +$wgAutoloadClasses['SMGoogleMapsFormInput'] = dirname( __FILE__ ) . '/SM_GoogleMapsFormInput.php'; |
| 26 | + |
| 27 | +$egMapsServices['googlemaps2']['features']['qp'] = 'SMGoogleMapsQP'; |
| 28 | +$egMapsServices['googlemaps2']['features']['fi'] = 'SMGoogleMapsFormInput'; |
\ No newline at end of file |