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

Revision: 65432
Author:   jeroendedauw
Date:     2010-04-22 19:20:52 +0000 (Thu, 22 Apr 2010)

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

Added Paths:
-----------
    trunk/extensions/Maps/Features/
    trunk/extensions/Maps/Features/DisplayMap/
    trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php
    trunk/extensions/Maps/Features/DisplayMap/Maps_DisplayMap.php
    trunk/extensions/Maps/Features/DisplayPoint/
    trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php
    trunk/extensions/Maps/Features/DisplayPoint/Maps_DisplayPoint.php
    trunk/extensions/Maps/Features/Maps_ParserFunctions.php
    trunk/extensions/Maps/Features/Maps_iMapParserFunction.php

Added: trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php
===================================================================
--- trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php                  
        (rev 0)
+++ trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php  2010-04-22 
19:20:52 UTC (rev 65432)
@@ -0,0 +1,134 @@
+<?php
+
+/**
+ * File holding class MapsBaseMap.
+ *
+ * @file Maps_BaseMap.php
+ * @ingroup Maps
+ *
+ * @author Jeroen De Dauw
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+
+/**
+ * Abstract class MapsBaseMap provides the scafolding for classes handling 
display_map
+ * calls for a spesific mapping service. It inherits from MapsMapFeature and 
therefore
+ * forces inheriting classes to implement sereveral methods.
+ *
+ * @ingroup Maps
+ *
+ * @author Jeroen De Dauw
+ */
+abstract class MapsBaseMap implements iMapParserFunction {
+       
+       public $serviceName;
+       
+       protected $centreLat, $centreLon;
+
+       protected $output = '';
+
+       protected $spesificParameters = false;
+       protected $featureParameters = false;   
+       
+       /**
+        * Sets the map properties as class fields.
+        * 
+        * @param array $mapProperties
+        */
+       protected function setMapProperties( array $mapProperties ) {
+               foreach ( $mapProperties as $paramName => $paramValue ) {
+                       if ( !property_exists( __CLASS__, $paramName ) ) {
+                               $this-> { $paramName } = $paramValue;
+                       }
+                       else {
+                               // If this happens in any way, it could be a 
big vunerability, so throw an exception.
+                               throw new Exception( 'Attempt to override a 
class field during map property assignment. Field name: ' . $paramName );
+                       }
+               }
+       }       
+       
+       /**
+        * @return array
+        */
+       public function getSpecificParameterInfo() {
+               return array();
+       }       
+       
+       /**
+        * @return array
+        */     
+       public function getFeatureParameters() {
+               global $egMapsDefaultServices;
+               
+               return array(
+                       'service' => array(     
+                               'default' => 
$egMapsDefaultServices['display_map']
+                       ),
+                       'coordinates' => array(
+                               'required' => true,
+                               'aliases' => array( 'coords', 'location', 
'locations' ),
+                               'criteria' => array(
+                                       'is_location' => array()
+                               ),
+                               'output-type' => 'coordinateSet', 
+                       ),                                      
+               );
+       }
+       
+       /**
+        * Handles the request from the parser hook by doing the work that's 
common for all
+        * mapping services, calling the specific methods and finally returning 
the resulting output.
+        *
+        * @param unknown_type $parser
+        * @param array $params
+        * 
+        * @return html
+        */
+       public final function getMapHtml( Parser &$parser, array $params ) {
+               $this->featureParameters = MapsDisplayMap::$parameters;
+               
+               $this->doMapServiceLoad();
+
+               $this->setMapProperties( $params );
+               
+               $this->setCentre();
+               
+               if ( $this->zoom == 'null' ) {
+                       $htis->zoom = $this->getDefaultZoom();
+               }               
+               
+               $this->addSpecificMapHTML( $parser );
+               
+               return $this->output;
+       }
+       
+       /**
+        * Sets the $centre_lat and $centre_lon fields.
+        */
+       private function setCentre() {
+               if ( empty( $this->coordinates ) ) { // If centre is not set, 
use the default latitude and longitutde.
+                       global $egMapsMapLat, $egMapsMapLon;
+                       $this->centreLat = $egMapsMapLat;
+                       $this->centreLon = $egMapsMapLon;
+               }
+               else { // If a centre value is set, geocode when needed and use 
it.
+                       $this->coordinates = MapsGeocoder::attemptToGeocode( 
$this->coordinates, $this->geoservice, $this->serviceName );
+
+                       // If the centre is not false, it will be a valid 
coordinate, which can be used to set the  latitude and longitutde.
+                       if ( $this->coordinates ) {
+                               $this->centreLat = Xml::escapeJsString( 
$this->coordinates['lat'] );
+                               $this->centreLon = Xml::escapeJsString( 
$this->coordinates['lon'] );
+                       }
+                       else { // If it's false, the coordinate was invalid, or 
geocoding failed. Either way, the default's should be used.
+                               // TODO: Some warning this failed would be nice 
here. 
+                               global $egMapsMapLat, $egMapsMapLon;
+                               $this->centreLat = $egMapsMapLat;
+                               $this->centreLon = $egMapsMapLon;
+                       }
+               }
+       }
+       
+}

Added: trunk/extensions/Maps/Features/DisplayMap/Maps_DisplayMap.php
===================================================================
--- trunk/extensions/Maps/Features/DisplayMap/Maps_DisplayMap.php               
                (rev 0)
+++ trunk/extensions/Maps/Features/DisplayMap/Maps_DisplayMap.php       
2010-04-22 19:20:52 UTC (rev 65432)
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * File holding the registration and handling functions for the display_map 
parser function.
+ *
+ * @file Maps_DisplayMap.php
+ * @ingroup Maps
+ *
+ * @author Jeroen De Dauw
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+
+$wgAutoloadClasses['MapsDisplayMap']           = __FILE__;
+$wgAutoloadClasses['MapsBaseMap']                      = dirname( __FILE__ ) . 
'/Maps_BaseMap.php';
+
+if ( version_compare( $wgVersion, '1.16alpha', '<' ) ) {
+       $wgHooks['LanguageGetMagic'][] = 'efMapsDisplayMapMagic';
+}      
+$wgHooks['ParserFirstCallInit'][]                      = 
'efMapsRegisterDisplayMap';
+
+$egMapsFeatures['pf'][]        = 'MapsDisplayMap::initialize';
+
+/**
+ * Adds the magic words for the parser functions.
+ */
+function efMapsDisplayMapMagic( &$magicWords, $langCode ) {
+       $magicWords['display_map'] = array( 0,  'display_map' );
+       
+       return true; // Unless we return true, other parser functions won't get 
loaded.
+}
+
+/**
+ * Adds the parser function hooks
+ */
+function efMapsRegisterDisplayMap( &$wgParser ) {
+       // A hook to enable the '#display_map' parser function.
+       $wgParser->setFunctionHook( 'display_map', array( 'MapsDisplayMap', 
'displayMapRender' ) );
+       
+       return true;
+}
+
+/**
+ * Class containing the rendering functions for the display_map parser 
function.
+ * 
+ * @author Jeroen De Dauw
+ *
+ */
+final class MapsDisplayMap {
+       
+       public static $parameters = array();
+       
+       public static function initialize() {
+       }
+       
+       /**
+        * Returns the output for a display_map call.
+        *
+        * @param unknown_type $parser
+        * 
+        * @return array
+        */
+       public static function displayMapRender( &$parser ) {
+               $args = func_get_args();
+               return MapsParserFunctions::getMapHtml( $parser, $args, 
'display_map' );
+       }
+       
+}
\ No newline at end of file

Added: trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php
===================================================================
--- trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php           
                (rev 0)
+++ trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php   
2010-04-22 19:20:52 UTC (rev 65432)
@@ -0,0 +1,244 @@
+<?php
+
+/**
+ * File holding class MapsBasePointMap.
+ * 
+ * @file Maps_BasePointMap.php
+ * @ingroup Maps
+ * 
+ * @author Jeroen De Dauw
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+
+/**
+ * Abstract class MapsBasePointMap provides the scafolding for classes 
handling display_point(s)
+ * calls for a spesific mapping service. It inherits from MapsMapFeature and 
therefore forces
+ * inheriting classes to implement sereveral methods.
+ *
+ * @ingroup Maps
+ *
+ * @author Jeroen De Dauw
+ */
+abstract class MapsBasePointMap implements iMapParserFunction {        
+       
+       public $serviceName;
+       
+       protected $centreLat, $centreLon;
+
+       protected $output = '';
+
+       protected $spesificParameters = false;
+       protected $featureParameters = false;   
+       
+       private $markerData = array();
+       protected $markerString;
+       
+       /**
+        * Sets the map properties as class fields.
+        * 
+        * @param array $mapProperties
+        */
+       protected function setMapProperties( array $mapProperties ) {
+               foreach ( $mapProperties as $paramName => $paramValue ) {
+                       if ( !property_exists( __CLASS__, $paramName ) ) {
+                               $this-> { $paramName } = $paramValue;
+                       }
+                       else {
+                               // If this happens in any way, it could be a 
big vunerability, so throw an exception.
+                               throw new Exception( 'Attempt to override a 
class field during map property assignment. Field name: ' . $paramName );
+                       }
+               }
+       }       
+       
+       /**
+        * @return array
+        */
+       public function getSpecificParameterInfo() {
+               return array();
+       }       
+       
+       /**
+        * @return array
+        */     
+       public function getFeatureParameters() {
+               global $egMapsDefaultServices, $egMapsDefaultTitle, 
$egMapsDefaultLabel;
+               
+               return array(
+                       'service' => array(     
+                               'default' => 
$egMapsDefaultServices['display_point']
+                       ),
+                       'centre' => array(
+                               'aliases' => array( 'center' ),
+                       ),
+                       'title' => array(
+                               'default' => $egMapsDefaultTitle
+                       ),
+                       'label' => array(
+                               'default' => $egMapsDefaultLabel
+                       ),
+                       'icon' => array(
+                               'criteria' => array(
+                                       'not_empty' => array()
+                               )
+                       ),
+                       'coordinates' => array(
+                               'required' => true,
+                               'type' => array( 'string', 'list', ';' ),
+                               'aliases' => array( 'coords', 'location', 
'locations' ),
+                               'criteria' => array(
+                                       'are_locations' => array()
+                               ),
+                               'output-type' => 'coordinateSets', 
+                       ),                                      
+               );
+       }       
+       
+       /**
+        * Handles the request from the parser hook by doing the work that's 
common for all
+        * mapping services, calling the specific methods and finally returning 
the resulting output.
+        *
+        * @param Parser $parser
+        * @param array $params
+        * 
+        * @return html
+        */
+       public final function getMapHtml( Parser &$parser, array $params ) {    
        
+               $this->featureParameters = MapsDisplayPoint::$parameters;
+       
+               $this->doMapServiceLoad();
+
+               $this->setMapProperties( $params );
+               
+               $this->setMarkerData( $parser );
+
+               $this->createMarkerString();
+               
+               $this->setCentre();
+               
+               if ( count( $this->markerData ) <= 1 && $this->zoom == 'null' ) 
{
+                       $this->zoom = $this->getDefaultZoom();
+               }
+               
+               $this->addSpecificMapHTML( $parser );
+               
+               return $this->output;
+       }
+       
+       /**
+        * Fills the $markerData array with the locations and their meta data.
+        *
+        * @param unknown_type $parser
+        */
+       private function setMarkerData( $parser ) {
+               $this->title = Xml::escapeJsString( $parser->recursiveTagParse( 
$this->title ) );
+               $this->label = Xml::escapeJsString( $parser->recursiveTagParse( 
$this->label ) );
+               
+               foreach ( $this->coordinates as $coordinates ) {
+                       $args = explode( '~', $coordinates );
+                       
+                       $markerData = MapsCoordinateParser::parseCoordinates( 
$args[0] );
+                       
+                       if ( !$markerData ) continue;
+                       
+                       if ( count( $args ) > 1 ) {
+                               // Parse and add the point specific title if 
it's present.
+                               $markerData['title'] = 
$parser->recursiveTagParse( $args[1] );
+                               
+                               if ( count( $args ) > 2 ) {
+                                       // Parse and add the point specific 
label if it's present.
+                                       $markerData['label'] = 
$parser->recursiveTagParse( $args[2] );
+                                       
+                                       if ( count( $args ) > 3 ) {
+                                               // Add the point specific icon 
if it's present.
+                                               $markerData['icon'] = $args[3];
+                                       }
+                               }
+                       }
+                       
+                       // If there is no point specific icon, use the general 
icon parameter when available.
+                       if ( ! array_key_exists( 'icon', $markerData ) && 
strlen( $this->icon ) > 0 ) $markerData['icon'] = $this->icon;
+                       
+                       // Get the url for the icon when there is one, else set 
the icon to an empty string.
+                       if ( array_key_exists( 'icon', $markerData ) ) {
+                               $icon_image_page = new ImagePage( 
Title::newFromText( $markerData['icon'] ) );
+                               $markerData['icon'] = 
$icon_image_page->getDisplayedFile()->getURL();
+                       }
+                       else {
+                               $markerData['icon'] = '';
+                       }
+                       
+                       $this->markerData[] = $markerData;
+               }
+       }
+       
+       /**
+        * Creates a JS string with the marker data. Takes care of escaping the 
used values.
+        */
+       private function createMarkerString() {
+               $markerItems = array();
+               
+               foreach ( $this->markerData as $markerData ) {
+                       $title = array_key_exists( 'title', $markerData ) ? 
Xml::escapeJsString( $markerData['title'] ) : $this->title;
+                       $label = array_key_exists( 'label', $markerData ) ? 
Xml::escapeJsString( $markerData['label'] ) : $this->label;
+                       
+                       $markerData['lon'] = Xml::escapeJsString( 
$markerData['lon'] );
+                       $markerData['lat'] = Xml::escapeJsString( 
$markerData['lat'] );
+                       $markerData['icon'] = Xml::escapeJsString( 
$markerData['icon'] );
+                       
+                       $markerItems[] = str_replace(   array( 'lon', 'lat', 
'title', 'label', 'icon' ),
+                                                                               
        array( $markerData['lon'], $markerData['lat'], $title, $label, 
$markerData['icon'] ),
+                                                                               
        $this->markerStringFormat
+                                                                               
        );
+               }
+               
+               $this->markerString = implode( ',', $markerItems );
+       }
+
+       /**
+        * Sets the $centre_lat and $centre_lon fields.
+        * Note: this needs to be done AFTRE the maker coordinates are set.
+        */
+       private function setCentre() {
+               if ( empty( $this->centre ) ) {
+                       if ( count( $this->markerData ) == 1 ) {
+                               // If centre is not set and there is exactelly 
one marker, use it's coordinates.
+                               $this->centreLat = Xml::escapeJsString( 
$this->markerData[0]['lat'] );
+                               $this->centreLon = Xml::escapeJsString( 
$this->markerData[0]['lon'] );
+                       }
+                       elseif ( count( $this->markerData ) > 1 ) {
+                               // If centre is not set and there are multiple 
markers, set the values to null,
+                               // to be auto determined by the JS of the 
mapping API.
+                               $this->centreLat = 'null';
+                               $this->centreLon = 'null';
+                       }
+                       else {
+                               // If centre is not set and there are no 
markers, use the default latitude and longitutde.
+                               $this->setCentreDefaults();
+                       }
+               }
+               else { // If a centre value is set, geocode when needed and use 
it.
+                       $this->centre = MapsGeocoder::attemptToGeocode( 
$this->centre, $this->geoservice, $this->serviceName );
+                       
+                       // If the centre is not false, it will be a valid 
coordinate, which can be used to set the latitude and longitutde.
+                       if ( $this->centre ) {
+                               $this->centreLat = Xml::escapeJsString( 
$this->centre['lat'] );
+                               $this->centreLon = Xml::escapeJsString( 
$this->centre['lon'] );
+                       }
+                       else { // If it's false, the coordinate was invalid, or 
geocoding failed. Either way, the default's should be used.
+                               $this->setCentreDefaults();
+                       }
+               }
+       }
+       
+       /**
+        * Sets the centre latitude and longitutde to the defaults.
+        */
+       private function setCentreDefaults() {
+               global $egMapsMapLat, $egMapsMapLon;
+               $this->centreLat = $egMapsMapLat;
+               $this->centreLon = $egMapsMapLon;
+       }
+}

Added: trunk/extensions/Maps/Features/DisplayPoint/Maps_DisplayPoint.php
===================================================================
--- trunk/extensions/Maps/Features/DisplayPoint/Maps_DisplayPoint.php           
                (rev 0)
+++ trunk/extensions/Maps/Features/DisplayPoint/Maps_DisplayPoint.php   
2010-04-22 19:20:52 UTC (rev 65432)
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * File holding the registration and handling functions for the display_point 
parser function.
+ *
+ * @file Maps_DisplayPoint.php
+ * @ingroup Maps
+ *
+ * @author Jeroen De Dauw
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+
+$wgAutoloadClasses['MapsDisplayPoint'] = __FILE__;
+$wgAutoloadClasses['MapsBasePointMap'] = dirname( __FILE__ ) . 
'/Maps_BasePointMap.php';
+
+if ( version_compare( $wgVersion, '1.16alpha', '<' ) ) {
+       $wgHooks['LanguageGetMagic'][] = 'efMapsDisplayPointMagic';
+}      
+$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterDisplayPoint';
+
+$egMapsFeatures['pf'][]        = 'MapsDisplayPoint::initialize';
+
+/**
+ * Adds the magic words for the parser functions.
+ */
+function efMapsDisplayPointMagic( &$magicWords, $langCode ) {
+       // The display_address(es) aliases are for backward compatibility only, 
and will be removed eventually.
+       $magicWords['display_point'] = array( 0, 'display_point', 
'display_points' );
+       
+       return true; // Unless we return true, other parser functions won't get 
loaded.
+}
+
+/**
+ * Adds the parser function hooks
+ */
+function efMapsRegisterDisplayPoint( &$wgParser ) {
+       // Hooks to enable the '#display_point' and '#display_points' parser 
functions.
+       $wgParser->setFunctionHook( 'display_point', array( 'MapsDisplayPoint', 
'displayPointRender' ) );
+       
+       return true;
+}
+
+/**
+ * Class containing the rendering functions for the display_point parser 
function.
+ * 
+ * @author Jeroen De Dauw
+ *
+ */
+final class MapsDisplayPoint {
+       
+       public static $parameters = array();
+       
+       public static function initialize() {
+       }
+       
+       /**
+        * Returns the output for a display_point call.
+        *
+        * @param unknown_type $parser
+        * 
+        * @return array
+        */
+       public static function displayPointRender( &$parser ) {
+               $args = func_get_args();
+               return MapsParserFunctions::getMapHtml( $parser, $args, 
'display_point' );
+       }
+       
+}
\ No newline at end of file

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:20:52 UTC (rev 65432)
@@ -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:20:52 UTC (rev 65432)
@@ -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 );  
+}
+



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

Reply via email to