http://www.mediawiki.org/wiki/Special:Code/MediaWiki/65430

Revision: 65430
Author:   jeroendedauw
Date:     2010-04-22 19:02:05 +0000 (Thu, 22 Apr 2010)

Log Message:
-----------
Changes for 0.6 - moved a bunch of directories to get a more logic structure

Modified Paths:
--------------
    trunk/extensions/Maps/Maps.php
    trunk/extensions/Maps/Maps_Settings.php

Added Paths:
-----------
    trunk/extensions/Maps/Features/
    trunk/extensions/Maps/Features/Maps_ParserFunctions.php
    trunk/extensions/Maps/Features/Maps_iMapParserFunction.php
    trunk/extensions/Maps/Services/

Removed Paths:
-------------
    trunk/extensions/Maps/GoogleMaps/
    trunk/extensions/Maps/GoogleMaps3/
    trunk/extensions/Maps/OpenLayers/
    trunk/extensions/Maps/OpenStreetMap/
    trunk/extensions/Maps/ParserFunctions/DisplayMap/
    trunk/extensions/Maps/ParserFunctions/DisplayPoint/
    trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
    trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php
    trunk/extensions/Maps/YahooMaps/

Added: trunk/extensions/Maps/Features/Maps_ParserFunctions.php
===================================================================
--- trunk/extensions/Maps/Features/Maps_ParserFunctions.php                     
        (rev 0)
+++ trunk/extensions/Maps/Features/Maps_ParserFunctions.php     2010-04-22 
19:02:05 UTC (rev 65430)
@@ -0,0 +1,136 @@
+<?php
+
+/**
+ * Initialization file for parser function functionality in the Maps extension
+ *
+ * @file Maps_ParserFunctions.php
+ * @ingroup Maps
+ *
+ * @author Jeroen De Dauw
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+
+$wgAutoloadClasses['MapsParserFunctions'] = __FILE__;
+
+$wgHooks['MappingFeatureLoad'][] = 'MapsParserFunctions::initialize';
+
+/**
+ * A class that holds handlers for the mapping parser functions.
+ * 
+ * @author Jeroen De Dauw
+ */
+final class MapsParserFunctions {
+       
+       /**
+        * Initialize the parser functions feature. This function handles the 
parser function hook,
+        * and will load the required classes.
+        */
+       public static function initialize() {
+               global $egMapsDir, $egMapsFeatures;
+               
+               include_once dirname( __FILE__ ) . 
'/Maps_iMapParserFunction.php';
+               
+               // This runs a small hook that enables parser functions to run 
initialization code.
+               foreach ( $egMapsFeatures['pf'] as $hook ) {
+                       call_user_func( $hook );
+               }
+               
+               return true;
+       }
+       
+       /**
+        * Returns the output for the call to the specified parser function.
+        * 
+        * @param Parser $parser
+        * @param array $params
+        * @param string $parserFunction
+        * 
+        * @return array
+        */
+       public static function getMapHtml( Parser &$parser, array $args, 
$parserFunction ) {
+        global $wgLang, $egValidatorErrorLevel, $egValidatorFatalLevel, 
$egMapsServices;
+        
+        array_shift( $args ); // We already know the $parser.
+        
+        $parameters = array();
+        $setService = false; 
+        
+               foreach( $args as $arg ) {
+                       $split = explode( '=', $arg );
+                       $name = strtolower( trim( array_shift( $split ) ) );
+                       if ( count( $split ) > 1 && self::inParamAliases( 
$name, 'service', MapsMapper::getCommonParameters() ) ) {
+                               if ( !$setService ) {
+                                       $service = implode( '=', $split );
+                                       $parameters = 'service=' . $service;
+                                       $setService = true;                     
                
+                               }
+                       } else {
+                               $parameters[] = $arg;
+                       }
+               }
+               
+               $service = MapsMapper::getValidService( $setService ? $service 
: '', $parserFunction );
+               
+               $mapClass = new 
$egMapsServices[$service]['features'][$parserFunction]();
+               
+               $manager = new ValidatorManager();
+               
+               /*
+                * Assembliy of the allowed parameters and their information. 
+                * The main parameters (the ones that are shared by everything) 
are overidden
+                * by the feature parameters (the ones spesific to a feature). 
The result is then
+                * again overidden by the service parameters (the ones spesific 
to the service),
+                * and finally by the spesific parameters (the ones spesific to 
a service-feature combination).
+                */
+               $parameterInfo = array_merge_recursive( 
MapsMapper::getCommonParameters(), $mapClass->getFeatureParameters() );
+               $parameterInfo = array_merge_recursive( $parameterInfo, 
$egMapsServices[$service]['parameters'] );
+               $parameterInfo = array_merge_recursive( $parameterInfo, 
$mapClass->getSpecificParameterInfo() ); 
+               
+               $parameters = $manager->manageParameters(
+                       $parameters,
+                       $parameterInfo,
+                       array( 'coordinates' )
+               );        
+        
+               $displayMap = $parameters !== false;
+               
+        if ( $displayMap ) {
+            // Call the function according to the map service to get the HTML 
output.
+            $output = $mapClass->getMapHtml( $parser, $parameters ) . 
$manager->getErrorList();
+        } else {
+               // TODO: Get failiures
+               if ( $egValidatorFatalLevel == Validator_ERRORS_WARN ) {
+                       $output .= htmlspecialchars( wfMsg( '' ) );
+               } elseif ( $egValidatorFatalLevel > Validator_ERRORS_WARN ) {
+                       $output .= htmlspecialchars( wfMsg( '' ) );
+               }
+        }
+        
+        // Return the result.
+        return array( $output, 'noparse' => true, 'isHTML' => true );
+       }
+       
+       /**
+        * Gets if a provided name is present in the aliases array of a 
parameter
+        * name in the $mainParams array.
+        *
+        * @param string $name The name you want to check for.
+        * @param string $mainParamName The main parameter name.
+        * @param array $paramInfo Contains meta data, including aliases, of 
the possible parameters.
+        * @param boolean $compareMainName Boolean indicating wether the main 
name should also be compared.
+        * 
+        * @return boolean
+        */
+       public static function inParamAliases( $name, $mainParamName, array 
$paramInfo = array(), $compareMainName = true ) {
+               $equals = $compareMainName && $mainParamName == $name;
+
+               if ( !$equals && array_key_exists( $mainParamName, $paramInfo ) 
) {
+                       $equals = in_array( $name, $paramInfo[$mainParamName] );
+               }
+
+               return $equals;
+       }
+}
\ No newline at end of file

Added: trunk/extensions/Maps/Features/Maps_iMapParserFunction.php
===================================================================
--- trunk/extensions/Maps/Features/Maps_iMapParserFunction.php                  
        (rev 0)
+++ trunk/extensions/Maps/Features/Maps_iMapParserFunction.php  2010-04-22 
19:02:05 UTC (rev 65430)
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * File holding interface iMapParserFunction.
+ * 
+ * @file Maps_iMapParserFunction.php
+ * @ingroup Maps
+ * 
+ * @author Jeroen De Dauw
+ * 
+ * TODO: revise this interface
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+
+/**
+ * Interface that should be implemented by all mapping feature classes.
+ * 
+ * @author Jeroen De Dauw
+ */
+interface iMapParserFunction {
+       function getMapHtml( Parser &$parser, array $params );
+       
+       /**
+        * Map service specific map count and loading of dependencies.
+        */
+       function doMapServiceLoad();
+       
+       /**
+        * Adds the HTML specific to the mapping service to the output.
+        */
+       function addSpecificMapHTML( Parser $parser );  
+}
+

Modified: trunk/extensions/Maps/Maps.php
===================================================================
--- trunk/extensions/Maps/Maps.php      2010-04-22 18:45:04 UTC (rev 65429)
+++ trunk/extensions/Maps/Maps.php      2010-04-22 19:02:05 UTC (rev 65430)
@@ -33,7 +33,7 @@
        echo '<b>Warning:</b> You need to have <a 
href="http://www.mediawiki.org/wiki/Extension:Validator";>Validator</a> 
installed in order to use <a 
href="http://www.mediawiki.org/wiki/Extension:Maps";>Maps</a>.';
 }
 else {
-       define( 'Maps_VERSION', '0.6 a16' );
+       define( 'Maps_VERSION', '0.6 a17' );
        
        // The different coordinate notations.
        define( 'Maps_COORDS_FLOAT', 'float' );

Modified: trunk/extensions/Maps/Maps_Settings.php
===================================================================
--- trunk/extensions/Maps/Maps_Settings.php     2010-04-22 18:45:04 UTC (rev 
65429)
+++ trunk/extensions/Maps/Maps_Settings.php     2010-04-22 19:02:05 UTC (rev 
65430)
@@ -29,34 +29,15 @@
 # The array element name contains an abbriviation, used for code references,
 # and in the service data arrays, the value is the human readible version for 
displaying purpouses.
 
-include_once $egMapsDir . 'Geocoders/Maps_Geocoders.php';                      
        // Geocoders
-include_once $egMapsDir . 'ParserFunctions/Maps_ParserFunctions.php';  // 
Parser functions
+include_once $egMapsDir . 'Features/Maps_ParserFunctions.php';         // 
Parser functions
+include_once $egMapsDir . 'Features/DisplayMap/Maps_DisplayMap.php';           
// #display_map 
+include_once $egMapsDir . 'Features/DisplayPoint/Maps_DisplayPoint.php';       
// #display_point(s)
 
 
 
-
-# Geocoding services configuration
-
-# Array of String. Array containing all the geocoding services that will be 
made available to the user.
-# Currently Maps provides the following services: geonames, google, yahoo
-$egMapsAvailableGeoServices = array(
-       'geonames',
-       'google',
-       'yahoo'
-);
-
-# String. The default geocoding service, which will be used when no service is 
provided by the user.
-# This service needs to be enabled, if not, the first one from the available 
services will be taken.
-$egMapsDefaultGeoService = 'geonames';
-
-$egMapsUserGeoOverrides = true;
-
-
-
 # Include the parser functions that should be loaded into Maps.
 # Commenting or removing a parser functions will cause Maps to completely 
ignore it, and so improve performance.
-include_once $egMapsDir . 'ParserFunctions/DisplayMap/Maps_DisplayMap.php';    
        // #display_map 
-include_once $egMapsDir . 
'ParserFunctions/DisplayPoint/Maps_DisplayPoint.php';        // 
#display_point(s)
+include_once $egMapsDir . 'Geocoders/Maps_Geocoders.php';                      
        // Geocoders
 include_once $egMapsDir . 'ParserFunctions/Geocode/Maps_GeocodeFunctions.php'; 
// #geocode, #geocodelat, #geocodelon
 include_once $egMapsDir . 'ParserFunctions/Coordinates/Maps_Coordinates.php';  
// #coordinates
 include_once $egMapsDir . 
'ParserFunctions/GeoFunctions/Maps_GeoFunctions.php';        // #geodistance
@@ -64,16 +45,17 @@
 
 
 
+
 # Mapping services configuration
 # Note: You can not use aliases in the settings. Use the main service names.
 
 # Include the mapping services that should be loaded into Maps. 
 # Commenting or removing a mapping service will cause Maps to completely 
ignore it, and so improve performance.
-include_once $egMapsDir . 'GoogleMaps/Maps_GoogleMaps.php';    // Google Maps
-include_once $egMapsDir . 'GoogleMaps3/Maps_GoogleMaps3.php';  // Google Maps 
v3
-include_once $egMapsDir . 'OpenLayers/Maps_OpenLayers.php';    // OpenLayers
-include_once $egMapsDir . 'YahooMaps/Maps_YahooMaps.php';              // 
Yahoo! Maps
-// include_once $egMapsDir . 'OpenStreetMap/Maps_OSM.php';             // 
OpenLayers optimized for OSM
+include_once $egMapsDir . 'Services/GoogleMaps/Maps_GoogleMaps.php';   // 
Google Maps
+include_once $egMapsDir . 'Services/GoogleMaps3/Maps_GoogleMaps3.php';         
// Google Maps v3
+include_once $egMapsDir . 'Services/OpenLayers/Maps_OpenLayers.php';   // 
OpenLayers
+include_once $egMapsDir . 'Services/YahooMaps/Maps_YahooMaps.php';             
// Yahoo! Maps
+// include_once $egMapsDir . 'Services/OpenStreetMap/Maps_OSM.php';            
// OpenLayers optimized for OSM
 
 # Array of String. Array containing all the mapping services that will be made 
available to the user.
 # Currently Maps provides the following services: googlemaps, yahoomaps, 
openlayers
@@ -100,7 +82,24 @@
 
 
 
+# Geocoding services configuration
 
+# Array of String. Array containing all the geocoding services that will be 
made available to the user.
+# Currently Maps provides the following services: geonames, google, yahoo
+$egMapsAvailableGeoServices = array(
+       'geonames',
+       'google',
+       'yahoo'
+);
+
+# String. The default geocoding service, which will be used when no service is 
provided by the user.
+# This service needs to be enabled, if not, the first one from the available 
services will be taken.
+$egMapsDefaultGeoService = 'geonames';
+
+$egMapsUserGeoOverrides = true;
+
+
+
 # General configuration
 
 # Boolean. Indicates if minified js files should be used where available.

Deleted: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php      
2010-04-22 18:45:04 UTC (rev 65429)
+++ trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php      
2010-04-22 19:02:05 UTC (rev 65430)
@@ -1,136 +0,0 @@
-<?php
-
-/**
- * Initialization file for parser function functionality in the Maps extension
- *
- * @file Maps_ParserFunctions.php
- * @ingroup Maps
- *
- * @author Jeroen De Dauw
- */
-
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 'Not an entry point.' );
-}
-
-$wgAutoloadClasses['MapsParserFunctions'] = __FILE__;
-
-$wgHooks['MappingFeatureLoad'][] = 'MapsParserFunctions::initialize';
-
-/**
- * A class that holds handlers for the mapping parser functions.
- * 
- * @author Jeroen De Dauw
- */
-final class MapsParserFunctions {
-       
-       /**
-        * Initialize the parser functions feature. This function handles the 
parser function hook,
-        * and will load the required classes.
-        */
-       public static function initialize() {
-               global $egMapsDir, $egMapsFeatures;
-               
-               include_once $egMapsDir . 
'ParserFunctions/Maps_iMapFeature.php';
-               
-               // This runs a small hook that enables parser functions to run 
initialization code.
-               foreach ( $egMapsFeatures['pf'] as $hook ) {
-                       call_user_func( $hook );
-               }
-               
-               return true;
-       }
-       
-       /**
-        * Returns the output for the call to the specified parser function.
-        * 
-        * @param Parser $parser
-        * @param array $params
-        * @param string $parserFunction
-        * 
-        * @return array
-        */
-       public static function getMapHtml( Parser &$parser, array $args, 
$parserFunction ) {
-        global $wgLang, $egValidatorErrorLevel, $egValidatorFatalLevel, 
$egMapsServices;
-        
-        array_shift( $args ); // We already know the $parser.
-        
-        $parameters = array();
-        $setService = false; 
-        
-               foreach( $args as $arg ) {
-                       $split = explode( '=', $arg );
-                       $name = strtolower( trim( array_shift( $split ) ) );
-                       if ( count( $split ) > 1 && self::inParamAliases( 
$name, 'service', MapsMapper::getCommonParameters() ) ) {
-                               if ( !$setService ) {
-                                       $service = implode( '=', $split );
-                                       $parameters = 'service=' . $service;
-                                       $setService = true;                     
                
-                               }
-                       } else {
-                               $parameters[] = $arg;
-                       }
-               }
-               
-               $service = MapsMapper::getValidService( $setService ? $service 
: '', $parserFunction );
-               
-               $mapClass = new 
$egMapsServices[$service]['features'][$parserFunction]();
-               
-               $manager = new ValidatorManager();
-               
-               /*
-                * Assembliy of the allowed parameters and their information. 
-                * The main parameters (the ones that are shared by everything) 
are overidden
-                * by the feature parameters (the ones spesific to a feature). 
The result is then
-                * again overidden by the service parameters (the ones spesific 
to the service),
-                * and finally by the spesific parameters (the ones spesific to 
a service-feature combination).
-                */
-               $parameterInfo = array_merge_recursive( 
MapsMapper::getCommonParameters(), $mapClass->getFeatureParameters() );
-               $parameterInfo = array_merge_recursive( $parameterInfo, 
$egMapsServices[$service]['parameters'] );
-               $parameterInfo = array_merge_recursive( $parameterInfo, 
$mapClass->getSpecificParameterInfo() ); 
-               
-               $parameters = $manager->manageParameters(
-                       $parameters,
-                       $parameterInfo,
-                       array( 'coordinates' )
-               );        
-        
-               $displayMap = $parameters !== false;
-               
-        if ( $displayMap ) {
-            // Call the function according to the map service to get the HTML 
output.
-            $output = $mapClass->displayMap( $parser, $parameters ) . 
$manager->getErrorList();
-        } else {
-               // TODO: Get failiures
-               if ( $egValidatorFatalLevel == Validator_ERRORS_WARN ) {
-                       $output .= htmlspecialchars( wfMsg( '' ) );
-               } elseif ( $egValidatorFatalLevel > Validator_ERRORS_WARN ) {
-                       $output .= htmlspecialchars( wfMsg( '' ) );
-               }
-        }
-        
-        // Return the result.
-        return array( $output, 'noparse' => true, 'isHTML' => true );
-       }
-       
-       /**
-        * Gets if a provided name is present in the aliases array of a 
parameter
-        * name in the $mainParams array.
-        *
-        * @param string $name The name you want to check for.
-        * @param string $mainParamName The main parameter name.
-        * @param array $paramInfo Contains meta data, including aliases, of 
the possible parameters.
-        * @param boolean $compareMainName Boolean indicating wether the main 
name should also be compared.
-        * 
-        * @return boolean
-        */
-       public static function inParamAliases( $name, $mainParamName, array 
$paramInfo = array(), $compareMainName = true ) {
-               $equals = $compareMainName && $mainParamName == $name;
-
-               if ( !$equals && array_key_exists( $mainParamName, $paramInfo ) 
) {
-                       $equals = in_array( $name, $paramInfo[$mainParamName] );
-               }
-
-               return $equals;
-       }
-}
\ No newline at end of file

Deleted: trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php  2010-04-22 
18:45:04 UTC (rev 65429)
+++ trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php  2010-04-22 
19:02:05 UTC (rev 65430)
@@ -1,36 +0,0 @@
-<?php
-
-/**
- * File holding interface iMapFeature.
- * 
- * @file Maps_iMapFeature.php
- * @ingroup Maps
- * 
- * @author Jeroen De Dauw
- * 
- * TODO: revise this interface
- */
-
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 'Not an entry point.' );
-}
-
-/**
- * Interface that should be implemented by all mapping feature classes.
- * 
- * @author Jeroen De Dauw
- */
-interface iMapFeature {
-       function displayMap( Parser &$parser, array $params );
-       
-       /**
-        * Map service specific map count and loading of dependencies.
-        */
-       function doMapServiceLoad();
-       
-       /**
-        * Adds the HTML specific to the mapping service to the output.
-        */
-       function addSpecificMapHTML( Parser $parser );  
-}
-



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to