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

Revision: 60381
Author:   jeroendedauw
Date:     2009-12-25 00:21:57 +0000 (Fri, 25 Dec 2009)

Log Message:
-----------
Changes for 0.5.1. Modified parameter definitions to work Validator 0.2.

Modified Paths:
--------------
    trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
    trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php
    trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
    trunk/extensions/Maps/Maps.php

Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php        2009-12-24 
23:30:30 UTC (rev 60380)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php        2009-12-25 
00:21:57 UTC (rev 60381)
@@ -46,6 +46,7 @@
                self::initializeParams();
                Validator::addOutputFormat('gmaptype', array('MapsGoogleMaps', 
'setGMapType'));
                Validator::addOutputFormat('gmaptypes', array('MapsGoogleMaps', 
'setGMapTypes'));
+               Validator::addValidationFunction('is_google_overlay', 
array('MapsGoogleMaps', 'isGOverlay'));
        }
        
        private static function initializeParams() {
@@ -147,6 +148,18 @@
        public static function getOverlayNames() {
                return array_keys(self::$overlayData);
        }
+       
+       /**
+        * Returns whether the provided value is a valid google overlay.
+        * 
+        * @param $value
+        * 
+        * @return boolean
+        */
+       public static function isGOverlay( $value ) {
+               $value = explode('-', $value);
+               return in_array($value[0], self::getOverlayNames());
+       }
 
        /**
         * Changes the map type name into the corresponding Google Maps API 
identifier.
@@ -218,22 +231,17 @@
                
                $overlayNames = array_keys(self::$overlayData);
                
-               // Create the overlays array, and use the default in case no 
overlays have been provided.
-               if (strlen(trim($overlays)) < 1) {
-                       $overlays = $egMapsGMapOverlays;
-               } else {
-                       $validOverlays = array();
-                       foreach ($overlays as $overlay) {
-                               $segements = explode('-', $overlay);
-                               $name = $segements[0];
-                               
-                               if (in_array($name, $overlayNames)) {
-                                       $isOn = count($segements) > 1 ? 
$segements[1] : '0';
-                                       $validOverlays[$name] = $isOn == '1';
-                               }
-                       } 
-                       $overlays = $validOverlays;
-               }
+               $validOverlays = array();
+               foreach ($overlays as $overlay) {
+                       $segements = explode('-', $overlay);
+                       $name = $segements[0];
+                       
+                       if (in_array($name, $overlayNames)) {
+                               $isOn = count($segements) > 1 ? $segements[1] : 
'0';
+                               $validOverlays[$name] = $isOn == '1';
+                       }
+               } 
+               $overlays = $validOverlays;
                
                // If there are no overlays or there is no control to hold 
them, don't bother the rest.
                if(!$hasOverlayControl || count($overlays) < 1) return;

Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php 2009-12-24 
23:30:30 UTC (rev 60380)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php 2009-12-25 
00:21:57 UTC (rev 60381)
@@ -29,10 +29,11 @@
                
                $this->spesificParameters = array(
                        'overlays' => array(
-                               'type' => 'list-string',
+                               'type' => array('string', 'list'),
                                'criteria' => array(
-                                       'all_in_array' => 
MapsGoogleMaps::getOverlayNames()
-                                       ),                                      
                                                
+                                       'is_google_overlay' => array()
+                                       ),
+                               'output-type' => 'array'                        
                        
                                ),                              
                );
        }

Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php       
2009-12-24 23:30:30 UTC (rev 60380)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php       
2009-12-25 00:21:57 UTC (rev 60381)
@@ -38,8 +38,9 @@
                        'overlays' => array(
                                'type' => array('string', 'list'),
                                'criteria' => array(
-                                       'in_array' => 
MapsGoogleMaps::getOverlayNames()
-                                       ),                                      
                                                
+                                       'is_google_overlay' => array()
+                                       ),
+                               'output-type' => 'array'                        
                                ),      
                        'zoom' => array(
                                'default' => '',        

Modified: trunk/extensions/Maps/Maps.php
===================================================================
--- trunk/extensions/Maps/Maps.php      2009-12-24 23:30:30 UTC (rev 60380)
+++ trunk/extensions/Maps/Maps.php      2009-12-25 00:21:57 UTC (rev 60381)
@@ -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.5.1 a6');
+       define('Maps_VERSION', '0.5.1 a7');
        
        $egMapsScriptPath       = $wgScriptPath . '/extensions/Maps';
        $egMapsIP                       = $IP . '/extensions/Maps';



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to