http://www.mediawiki.org/wiki/Special:Code/MediaWiki/65456
Revision: 65456
Author: jeroendedauw
Date: 2010-04-22 22:44:01 +0000 (Thu, 22 Apr 2010)
Log Message:
-----------
Partially fixed parameter handling for form inputs
Modified Paths:
--------------
trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php
trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php
trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php
trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php
trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php
trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php
Modified: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php
===================================================================
--- trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php
2010-04-22 22:39:24 UTC (rev 65455)
+++ trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php
2010-04-22 22:44:01 UTC (rev 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();
Modified: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php
===================================================================
--- trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php
2010-04-22 22:39:24 UTC (rev 65455)
+++ trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php
2010-04-22 22:44:01 UTC (rev 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();
Modified:
trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php
===================================================================
---
trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php
2010-04-22 22:39:24 UTC (rev 65455)
+++
trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php
2010-04-22 22:44:01 UTC (rev 65456)
@@ -19,6 +19,8 @@
public $serviceName = MapsGoogleMaps::SERVICE_NAME;
+ protected $spesificParameters = array();
+
/**
* @see MapsMapFeature::setMapSettings()
*
Modified: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php
===================================================================
--- trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php
2010-04-22 22:39:24 UTC (rev 65455)
+++ trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php
2010-04-22 22:44:01 UTC (rev 65456)
@@ -36,9 +36,9 @@
'type' => array( 'string', 'list' ),
'criteria' => array(
'is_google_overlay' => array()
- ),
+ ),
'default' => $egMapsGMapOverlays,
- ),
+ ),
);
}
Modified:
trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php
===================================================================
---
trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php
2010-04-22 22:39:24 UTC (rev 65455)
+++
trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php
2010-04-22 22:44:01 UTC (rev 65456)
@@ -17,6 +17,8 @@
public $serviceName = MapsOpenLayers::SERVICE_NAME;
+ protected $spesificParameters = array();
+
/**
* @see MapsMapFeature::setMapSettings()
*
Modified:
trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php
===================================================================
--- trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php
2010-04-22 22:39:24 UTC (rev 65455)
+++ trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php
2010-04-22 22:44:01 UTC (rev 65456)
@@ -17,6 +17,8 @@
public $serviceName = MapsYahooMaps::SERVICE_NAME;
+ protected $spesificParameters = array();
+
/**
* @see MapsMapFeature::setMapSettings()
*
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs