
jeroendedauw at svn
Nov 20, 2009, 9:04 AM
Post #1 of 1
(62 views)
Permalink
|
|
SVN: [59290] trunk/extensions/Maps
|
|
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59290 Revision: 59290 Author: jeroendedauw Date: 2009-11-20 17:04:22 +0000 (Fri, 20 Nov 2009) Log Message: ----------- Changes for 0.5. http://www.mediawiki.org/wiki/Extension:Maps/Future#Maps_0.5 Modified Paths: -------------- trunk/extensions/Maps/Maps.php trunk/extensions/Maps/Maps_MapFeature.php trunk/extensions/Maps/Maps_Mapper.php trunk/extensions/Maps/Maps_Settings.php trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php Added Paths: ----------- trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php Modified: trunk/extensions/Maps/Maps.php =================================================================== --- trunk/extensions/Maps/Maps.php 2009-11-20 15:37:28 UTC (rev 59289) +++ trunk/extensions/Maps/Maps.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -23,8 +23,14 @@ die( 'Not an entry point.' ); } -define('Maps_VERSION', '0.5 a1'); +define('Maps_VERSION', '0.5 a3'); +// Constants indicating the strictness of the parameter validation. +define('Maps_ERRORS_NONE', 0); +define('Maps_ERRORS_WARN', 1); +define('Maps_ERRORS_SHOW', 2); +define('Maps_ERRORS_STRICT', 3); + $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; $egMapsIP = $IP . '/extensions/Maps'; @@ -47,7 +53,7 @@ if (empty($egMapsServices)) $egMapsServices = array(); /** - * Initialization function for the Maps extension + * Initialization function for the Maps extension. */ function efMapsSetup() { global $wgExtensionCredits, $wgOut, $wgLang, $wgAutoloadClasses, $IP; @@ -56,11 +62,8 @@ // Enure that the default service and geoservice are one of the enabled ones. $egMapsDefaultService = in_array($egMapsDefaultService, $egMapsAvailableServices) ? $egMapsDefaultService : $egMapsAvailableServices[0]; if (!in_array($egMapsDefaultGeoService, $egMapsAvailableGeoServices)) { - foreach($egMapsAvailableGeoServices as $geoServiceName => $value) { - $defService = $geoServiceName; - continue; - } - $egMapsDefaultGeoService = $defService; + reset($egMapsAvailableGeoServices); + $egMapsDefaultGeoService = current($egMapsAvailableGeoServices); } wfLoadExtensionMessages( 'Maps' ); Modified: trunk/extensions/Maps/Maps_MapFeature.php =================================================================== --- trunk/extensions/Maps/Maps_MapFeature.php 2009-11-20 15:37:28 UTC (rev 59289) +++ trunk/extensions/Maps/Maps_MapFeature.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -1,7 +1,7 @@ <?php /** - * MapsMapFeature bundles some base functionallity for all general mapping feature classes. + * File holding class MapsMapFeature. * * @file Maps_MapFeature.php * @ingroup Maps @@ -13,6 +13,11 @@ die( 'Not an entry point.' ); } +/** + * MapsMapFeature bundles base functionallity for all general mapping feature classes. + * + * @author Jeroen De Dauw + */ abstract class MapsMapFeature { /** @@ -32,8 +37,8 @@ public $serviceName; - protected $defaultParams = array(); - + protected $defaultParams = array(); + protected $defaultZoom; protected $elementNr; @@ -45,13 +50,18 @@ protected $centre_lon; protected $output = ''; + protected $errors = array(); /** - * Sets the map properties as class fields. + * Validates and corrects the provided map properties, and the sets them as class fields. + * + * @param array $mapProperties + * @param string $className */ - protected function manageMapProperties($mapProperties, $className) { + protected function manageMapProperties(array $mapProperties, $className) { global $egMapsServices; + // TODO: implement strict parameter validation, put errors in array. $mapProperties = MapsMapper::getValidParams($mapProperties, $egMapsServices[$this->serviceName]['parameters']); $mapProperties = MapsMapper::setDefaultParValues($mapProperties, $this->defaultParams); @@ -72,7 +82,7 @@ * Sets the $mapName field, using the $elementNamePrefix and $elementNr. */ protected function setMapName() { - $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr; + $this->mapName = $this->elementNamePrefix . '_' . $this->elementNr; } } \ No newline at end of file Modified: trunk/extensions/Maps/Maps_Mapper.php =================================================================== --- trunk/extensions/Maps/Maps_Mapper.php 2009-11-20 15:37:28 UTC (rev 59289) +++ trunk/extensions/Maps/Maps_Mapper.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -32,7 +32,8 @@ 'height' => array(), 'controls' => array(), 'label' => array(), - 'title' => array() + 'title' => array(), + 'lang' => array('locale', 'language') ); /** Modified: trunk/extensions/Maps/Maps_Settings.php =================================================================== --- trunk/extensions/Maps/Maps_Settings.php 2009-11-20 15:37:28 UTC (rev 59289) +++ trunk/extensions/Maps/Maps_Settings.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -116,8 +116,15 @@ -# General map properties configuration +# General map configuration +# Integer. The strictness of the parameter validation and resulting error report. +# Maps_ERRORS_NONE : Maps will not show any errors, and make the best of the imput it got. +# Maps_ERRORS_WARN : Maps will make the best of the imput it got, but will show warnings for omitted coordinates. +# Maps_ERRORS_SHOW : Maps will make the best of the imput it got, but will show a list of all errors. +# Maps_ERRORS_STRICT: Maps will only show a map when there are no errors, if there are, a list of them will be shown. +$egMapsErrorLevel = Maps_ERRORS_WARN; + # Integer. The default width and height of a map. These values will only be used when the user does not provide them. $egMapsMapWidth = 600; $egMapsMapHeight = 350; Modified: trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php =================================================================== --- trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php 2009-11-20 15:37:28 UTC (rev 59289) +++ trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -15,7 +15,7 @@ die( 'Not an entry point.' ); } -abstract class MapsBaseMap extends MapsMapFeature { +abstract class MapsBaseMap extends MapsMapFeature implements iDisplayFunction { /** * Handles the request from the parser hook by doing the work that's common for all @@ -29,7 +29,7 @@ public final function displayMap(&$parser, array $params) { $this->setMapSettings(); - $coords = $this->manageMapProperties($params, __CLASS__); + parent::manageMapProperties($params, __CLASS__); $this->doMapServiceLoad(); @@ -45,14 +45,6 @@ } /** - * (non-PHPdoc) - * @see smw/extensions/Maps/MapsMapFeature#manageMapProperties($mapProperties, $className) - */ - protected function manageMapProperties($params, $className) { - parent::manageMapProperties($params, $className); - } - - /** * Sets the zoom level to the provided value. When no zoom is provided, set * it to the default when there is only one location, or the best fitting soom when * there are multiple locations. Modified: trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php =================================================================== --- trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php 2009-11-20 15:37:28 UTC (rev 59289) +++ trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -20,7 +20,7 @@ * * @author Jeroen De Dauw */ -abstract class MapsBasePointMap extends MapsMapFeature { +abstract class MapsBasePointMap extends MapsMapFeature implements iDisplayFunction { private $markerData = array(); protected $markerStringFormat = ''; @@ -38,7 +38,7 @@ public final function displayMap(&$parser, array $params) { $this->setMapSettings(); - /* $coords = */ $this->manageMapProperties($params, __CLASS__); + parent::manageMapProperties($params, __CLASS__); $this->doMapServiceLoad(); @@ -62,14 +62,6 @@ } /** - * (non-PHPdoc) - * @see smw/extensions/Maps/MapsMapFeature#manageMapProperties($mapProperties, $className) - */ - protected function manageMapProperties($params, $className) { - parent::manageMapProperties($params, $className); - } - - /** * Sets the zoom level to the provided value. When no zoom is provided, set * it to the default when there is only one location, or the best fitting soom when * there are multiple locations. Modified: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php =================================================================== --- trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php 2009-11-20 15:37:28 UTC (rev 59289) +++ trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -27,6 +27,8 @@ public static function initialize() { global $egMapsIP, $IP, $wgAutoloadClasses, $egMapsServices; + include_once $egMapsIP . '/ParserFunctions/Maps_iDisplayFunction.php'; + foreach($egMapsServices as $serviceName => $serviceData) { // Check if the service has parser function support $hasPFs = array_key_exists('pf', $serviceData); @@ -39,7 +41,7 @@ $file = $parser_data['local'] ? $egMapsIP . '/' . $parser_data['file'] : $IP . '/extensions/' . $parser_data['file']; $wgAutoloadClasses[$parser_data['class']] = $file; } - } + } } /** Added: trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php =================================================================== --- trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php (rev 0) +++ trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php 2009-11-20 17:04:22 UTC (rev 59290) @@ -0,0 +1,23 @@ +<?php + +/** + * File holding interface iDisplayFunction. + * + * @file Maps_iDisplayFunction.php + * @ingroup Maps + * + * @author Jeroen De Dauw + */ + +if( !defined( 'MEDIAWIKI' ) ) { + die( 'Not an entry point.' ); +} + +/** + * Interface that should be implemented by all display_ parser functions. + * + * @author Jeroen De Dauw + */ +interface iDisplayFunction { + public function displayMap(&$parser, array $params); +} \ No newline at end of file _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|