MediaWiki r65456 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r65455‎ | r65456 (on ViewVC)‎ | r65457 >
Date:22:44, 22 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Partially fixed parameter handling for form inputs
Modified paths:

Diff [purge]

Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php
===================================================================
--- trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php	(revision 65455)
+++ trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php	(revision 65456)
@@ -17,6 +17,8 @@
 	

 	public $serviceName = MapsYahooMaps::SERVICE_NAME;

 	

+	protected $spesificParameters = array();

+	

 	/**

 	 * @see MapsMapFeature::setMapSettings()

 	 *

Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php
===================================================================
--- trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php	(revision 65455)
+++ trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php	(revision 65456)
@@ -17,6 +17,8 @@
 	

 	public $serviceName = MapsOpenLayers::SERVICE_NAME;

 	

+	protected $spesificParameters = array();

+	

 	/**

 	 * @see MapsMapFeature::setMapSettings()

 	 *

Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php
===================================================================
--- trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php	(revision 65455)
+++ trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php	(revision 65456)
@@ -36,9 +36,9 @@
 				'type' => array( 'string', 'list' ),

 				'criteria' => array(

 					'is_google_overlay' => array()

-					),

+				),

 				'default' => $egMapsGMapOverlays,

-				),

+			),

 		);

 	}

 	

Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php
===================================================================
--- trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php	(revision 65455)
+++ trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php	(revision 65456)
@@ -19,6 +19,8 @@
 

 	public $serviceName = MapsGoogleMaps::SERVICE_NAME;

 	

+	protected $spesificParameters = array();

+	

 	/**

 	 * @see MapsMapFeature::setMapSettings()

 	 *

Index: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php
===================================================================
--- trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php	(revision 65455)
+++ trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php	(revision 65456)
@@ -13,7 +13,7 @@
 	die( 'Not an entry point.' );

 }

 

-abstract class SMFormInput extends MapsMapFeature {

+abstract class SMFormInput {

 

 	/**

 	 * Determine if geocoding will be enabled and load the required dependencies.

@@ -39,20 +39,57 @@
 	private $coordinates;

 	

 	/**

+	 * Validates and corrects the provided map properties, and the sets them as class fields.

+	 * 

+	 * @param array $mapProperties

+	 * 

+	 * @return boolean Indicates whether the map should be shown or not.

+	 */

+	protected final function setMapProperties( array $mapProperties ) {

+		global $egMapsServices;

+		

+		/*

+		 * 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).

+		 * 

+		 * FIXME: this causes some wicket error?

+		 */

+		$parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), SMFormInputs::$parameters );

+		$parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] );

+		$parameterInfo = array_merge_recursive( $parameterInfo, $this->spesificParameters ); 		

+		

+		$manager = new ValidatorManager();

+		

+		$result = $manager->manageParameters( $mapProperties, $parameterInfo );

+		

+		$showMap = $result !== false;

+		

+		if ( $showMap ) $this->setMapProperties( $result, __CLASS__ );

+		

+		$this->errorList  = $manager->getErrorList();

+		

+		return $showMap;

+	}	

+	

+	/**

 	 * This function is a hook for Semantic Forms, and returns the HTML needed in 

 	 * the form to handle coordinate data.

 	 * 

 	 * @return array

+	 * 

+	 * TODO: Use function args for sf stuffz

 	 */

 	public final function formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ) {

 		global $wgParser, $sfgTabIndex;

-		// TODO: Use function args for sf stuffz

 

 		$this->coordinates = $coordinates;

 		

 		$this->setMapSettings();

 		

-		parent::setMapProperties( $field_args, __CLASS__ );

+		$this->setMapProperties( $field_args );

 		

 		$this->doMapServiceLoad();

 		

Index: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php
===================================================================
--- trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php	(revision 65455)
+++ trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php	(revision 65456)
@@ -79,7 +79,7 @@
 		

 		$this->featureParameters = SMQueryPrinters::$parameters;

 		

-		if ( self::manageMapProperties( $this->m_params, __CLASS__ ) ) {

+		if ( self::manageMapProperties( $this->m_params ) ) {

 			$this->formatResultData( $res, $outputmode );

 			

 			// Only create a map when there is at least one result.

@@ -107,11 +107,10 @@
 	 * Validates and corrects the provided map properties, and the sets them as class fields.

 	 * 

 	 * @param array $mapProperties

-	 * @param string $className 

 	 * 

 	 * @return boolean Indicates whether the map should be shown or not.

 	 */

-	protected final function manageMapProperties( array $mapProperties, $className ) {

+	protected final function manageMapProperties( array $mapProperties ) {

 		global $egMapsServices;

 		

 		/*

@@ -131,7 +130,7 @@
 		

 		$showMap = $result !== false;

 		

-		if ( $showMap ) $this->setMapProperties( $result, $className );

+		if ( $showMap ) $this->setMapProperties( $result, __CLASS__ );

 		

 		$this->errorList  = $manager->getErrorList();

 		

Status & tagging log

Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox