r61219 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61218‎ | r61219 | r61220 >
Date:22:56, 18 January 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.5.2.
* Added icon parameter to display_point(s), allowing you to set the icon for all markers that do not have a specific icon assigned.
* Fixed file path for location specific icons.
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Mapper.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_DisplayPoint.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_DisplayPoint.php
@@ -80,7 +80,12 @@
8181 ),
8282 'label' => array(
8383 'default' => $egMapsDefaultLabel
84 - ),
 84+ ),
 85+ 'icon' => array(
 86+ 'criteria' => array(
 87+ 'not_empty' => array()
 88+ )
 89+ ),
8590 ));
8691 }
8792
Index: trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php
@@ -97,17 +97,32 @@
9898 $markerData = MapsUtils::getLatLon($args[0]);
9999
100100 if (count($args) > 1) {
 101+ // Parse and add the point specific title if it's present.
101102 $markerData['title'] = $this->doEscaping( $parser->recursiveTagParse( $args[1] ) );
102103
103104 if (count($args) > 2) {
 105+ // Parse and add the point specific label if it's present.
104106 $markerData['label'] = $this->doEscaping( $parser->recursiveTagParse( $args[2] ) );
105107
106108 if (count($args) > 3) {
 109+ // Add the point specific icon if it's present.
107110 $markerData['icon'] = $args[3];
108 - }
 111+ }
109112 }
110113 }
111 -
 114+
 115+ // If there is no point specific icon, use the general icon parameter when available.
 116+ if (! array_key_exists('icon', $markerData) && strlen($this->icon) > 0) $markerData['icon'] = $this->icon;
 117+
 118+ // Get the url for the icon when there is one, else set the icon to an empty string.
 119+ if (array_key_exists('icon', $markerData)) {
 120+ $icon_image_page = new ImagePage( Title::newFromText( $markerData['icon'] ) );
 121+ $markerData['icon'] = $icon_image_page->getDisplayedFile()->getURL();
 122+ }
 123+ else {
 124+ $markerData['icon'] = '';
 125+ }
 126+
112127 $this->markerData[] = $markerData;
113128 }
114129 }
@@ -124,10 +139,8 @@
125140 $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
126141 $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
127142
128 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
129 -
130143 $markerItems[] = str_replace( array('lon', 'lat', 'title', 'label', 'icon'),
131 - array($markerData['lon'], $markerData['lat'], $title, $label, $icon),
 144+ array($markerData['lon'], $markerData['lat'], $title, $label, $markerData['icon']),
132145 $this->markerStringFormat
133146 );
134147 }
Index: trunk/extensions/Maps/Maps.php
@@ -33,7 +33,7 @@
3434 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>.';
3535 }
3636 else {
37 - define('Maps_VERSION', '0.5.2 rc1');
 37+ define('Maps_VERSION', '0.5.2 rc2');
3838
3939 $egMapsScriptPath = $wgScriptPath . '/extensions/Maps';
4040 $egMapsIP = $IP . '/extensions/Maps';
Index: trunk/extensions/Maps/Maps_Mapper.php
@@ -31,12 +31,14 @@
3232 'zoom' => array(
3333 'type' => 'integer',
3434 'criteria' => array(
 35+ 'not_empty' => array(),
3536 'in_range' => array(0, 15)
36 - )
 37+ )
3738 ),
3839 'width' => array(
3940 'type' => 'integer',
4041 'criteria' => array(
 42+ 'not_empty' => array(),
4143 'in_range' => $egMapsSizeRestrictions['width']
4244 ),
4345 'default' => $egMapsMapWidth
@@ -44,6 +46,7 @@
4547 'height' => array(
4648 'type' => 'integer',
4749 'criteria' => array(
 50+ 'not_empty' => array(),
4851 'in_range' => $egMapsSizeRestrictions['height']
4952 ),
5053 'default' => $egMapsMapHeight

Status & tagging log