r74971 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74970‎ | r74971 | r74972 >
Date:21:50, 18 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fix to OpenLayers layers parameter
Modified paths:
  • /trunk/extensions/Maps/includes/services/OpenLayers/CriterionOLLayer.php (modified) (history)
  • /trunk/extensions/Maps/includes/services/OpenLayers/Maps_OpenLayers.php (modified) (history)
  • /trunk/extensions/Maps/includes/services/OpenLayers/Maps_ParamOLLayers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/services/OpenLayers/Maps_ParamOLLayers.php
@@ -35,9 +35,10 @@
3636 $layerNames = array();
3737
3838 foreach ( $parameter->getValue() as $layerOrGroup ) {
 39+ $lcLayerOrGroup = strtolower( $layerOrGroup );
3940 // Layer groups. Loop over all items and add them when not present yet.
40 - if ( array_key_exists( $layerOrGroup, $egMapsOLLayerGroups ) ) {
41 - foreach ( $egMapsOLLayerGroups[$layerOrGroup] as $layerName ) {
 41+ if ( array_key_exists( $lcLayerOrGroup, $egMapsOLLayerGroups ) ) {
 42+ foreach ( $egMapsOLLayerGroups[$lcLayerOrGroup] as $layerName ) {
4243 if ( !in_array( $layerName, $layerNames ) ) {
4344 if ( is_array( $egMapsOLAvailableLayers[$layerName] ) ) {
4445 $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerName][0];
@@ -50,16 +51,16 @@
5152 }
5253 }
5354 // Single layers. Add them when not present yet.
54 - elseif ( array_key_exists( $layerOrGroup, $egMapsOLAvailableLayers ) ) {
55 - if ( !in_array( $layerOrGroup, $layerNames ) ) {
56 - if ( is_array( $egMapsOLAvailableLayers[$layerOrGroup] ) ) {
57 - $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerOrGroup][0];
 55+ elseif ( array_key_exists( $lcLayerOrGroup, $egMapsOLAvailableLayers ) ) {
 56+ if ( !in_array( $lcLayerOrGroup, $layerNames ) ) {
 57+ if ( is_array( $egMapsOLAvailableLayers[$lcLayerOrGroup] ) ) {
 58+ $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup][0];
5859 }
5960 else {
60 - $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$layerOrGroup];
 61+ $layerDefs[] = 'new ' . $egMapsOLAvailableLayers[$lcLayerOrGroup];
6162 }
6263
63 - $layerNames[] = $layerOrGroup;
 64+ $layerNames[] = $lcLayerOrGroup;
6465 }
6566 }
6667 // Image layers. Check validity and add when not present yet.
@@ -107,9 +108,10 @@
108109 $layerDependencies = array();
109110
110111 foreach ( $layerNames as $layerName ) {
111 - if ( is_array( $egMapsOLAvailableLayers[$layerName] )
112 - && count( $egMapsOLAvailableLayers[$layerName] ) > 1
113 - && array_key_exists( $egMapsOLAvailableLayers[$layerName][1], $egMapsOLLayerDependencies ) ) {
 112+ if ( array_key_exists( $layerName, $egMapsOLAvailableLayers ) // The layer must be defined in php
 113+ && is_array( $egMapsOLAvailableLayers[$layerName] ) // The layer must be an array...
 114+ && count( $egMapsOLAvailableLayers[$layerName] ) > 1 // ...with a second element...
 115+ && array_key_exists( $egMapsOLAvailableLayers[$layerName][1], $egMapsOLLayerDependencies ) ) { //...that is a dependency.
114116 $layerDependencies[] = $egMapsOLLayerDependencies[$egMapsOLAvailableLayers[$layerName][1]];
115117 }
116118 }
Index: trunk/extensions/Maps/includes/services/OpenLayers/Maps_OpenLayers.php
@@ -46,6 +46,7 @@
4747 $params['layers']->setDoManipulationOfDefault( true );
4848 $params['layers']->addCriteria( new CriterionOLLayer() );
4949 $params['layers']->setDefault( $egMapsOLLayers );
 50+ $params['layers']->lowerCaseValue = false;
5051
5152 //$params['imagelayers'] = new ListParameter();
5253 }
@@ -83,9 +84,10 @@
8485 */
8586 public function createMarkersJs( array $markers ) {
8687 $markerItems = array();
87 -
 88+ $defaultGroup = wfMsg( 'maps-markers' );
 89+ //.// TODO
8890 foreach ( $markers as $marker ) {
89 - $markerItems[] = Xml::encodeJsVar( (object)array(
 91+ $markerItems[false ? $marker[5] : $defaultGroup] = Xml::encodeJsVar( (object)array(
9092 'lat' => $marker[0],
9193 'lon' => $marker[1],
9294 'title' => $marker[2],
Index: trunk/extensions/Maps/includes/services/OpenLayers/CriterionOLLayer.php
@@ -30,7 +30,7 @@
3131 $dynamicLayers = MapsOpenLayers::getLayerNames( true );
3232
3333 // Dynamic layers, defined in the settings file or localsettings.
34 - if ( in_array( $value, $dynamicLayers ) ) {
 34+ if ( in_array( strtolower( $value ), $dynamicLayers ) ) {
3535 return true;
3636 }
3737

Status & tagging log