r57585 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57584‎ | r57585 | r57586 >
Date:19:42, 9 October 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.3.5
Modified paths:
  • /trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php (modified) (history)
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayersUtils.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMapsUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersUtils.php
@@ -74,14 +74,14 @@
7575 */
7676 public static function addOLDependencies(&$output) {
7777 global $wgJsMimeType;
78 - global $egOpenLayersOnThisPage, $egMapsIncludePath;
 78+ global $egOpenLayersOnThisPage, $egMapsScriptPath;
7979
8080 if (empty($egOpenLayersOnThisPage)) {
8181 $egOpenLayersOnThisPage = 0;
8282
83 - $output .="<link rel='stylesheet' href='$egMapsIncludePath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
84 - <script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OpenLayers/OpenLayers.js'></script>
85 - <script type='$wgJsMimeType' src='$egMapsIncludePath/OpenLayers/OpenLayerFunctions.js'></script>
 83+ $output .="<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
 84+ <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>
 85+ <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayerFunctions.js'></script>
8686 <script type='$wgJsMimeType'>initOLSettings(200, 100);</script>\n";
8787 }
8888 }
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
@@ -14,6 +14,7 @@
1515 }
1616
1717 $wgHooks['LanguageGetMagic'][] = 'efMapsFunctionMagic';
 18+$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterParserFunctions';
1819
1920 /**
2021 * Adds the magic words for the parser functions
@@ -32,6 +33,25 @@
3334 }
3435
3536 /**
 37+ * Adds the parser function hooks
 38+ */
 39+function efMapsRegisterParserFunctions(&$wgParser) {
 40+ // A hooks to enable the '#display_point' and '#display_points' parser functions
 41+ $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') );
 42+ $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') );
 43+
 44+ // A hooks to enable the '#display_adress' and '#display_adresses' parser functions
 45+ $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') );
 46+ $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') );
 47+
 48+ // A hook to enable the geocoder parser functions
 49+ $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder') );
 50+ $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 'renderGeocoderLat') );
 51+ $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 'renderGeocoderLng') );
 52+ return true;
 53+}
 54+
 55+/**
3656 * A class that holds handlers for the mapping parser functions.
3757 * Spesific functions are located in @see MapsUtils
3858 *
@@ -45,32 +65,11 @@
4666 *
4767 */
4868 public static function initialize() {
49 - global $egMapsIP, $wgAutoloadClasses;
50 - $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php';
 69+ global $egMapsIP, $wgAutoloadClasses, $wgHooks, $wgParser;
5170
52 - self::addParserHooks();
 71+ $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php';
5372 }
5473
55 - /**
56 - * Adds the parser function hooks
57 - */
58 - private static function addParserHooks() {
59 - global $wgParser;
60 -
61 - // A hooks to enable the '#display_point' and '#display_points' parser functions
62 - $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') );
63 - $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') );
64 -
65 - // A hooks to enable the '#display_adress' and '#display_adresses' parser functions
66 - $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') );
67 - $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') );
68 -
69 - // A hook to enable the geocoder parser functions
70 - $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder') );
71 - $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 'renderGeocoderLat') );
72 - $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 'renderGeocoderLng') );
73 - }
74 -
7574 public static function getMapHtml(&$parser, array $params, array $coordFails = array()) {
7675 global $wgLang;
7776
@@ -214,7 +213,6 @@
215214
216215 if ($isAddress || count($split) == 1) {
217216 $address_srting = count($split) == 1 ? $split[0] : $split[1];
218 - //var_dump($address_srting);
219217 $addresses = explode(';', $address_srting);
220218
221219 $coordinates = array();
@@ -239,7 +237,7 @@
240238 $params[$i] = 'coordinates=' . implode(';', $coordinates);
241239
242240 }
243 - } //exit;
 241+ }
244242
245243 return $fails;
246244 }
Index: trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php
@@ -1,7 +1,9 @@
22 <?php
33
44 /**
5 - * MapsBaseMap is an abstract class inherited by the map services classes
 5+ * Abstract class MapsBaseMap provides the scafolding for classes handling parser function
 6+ * calls for a spesific mapping service. It inherits from MapsMapFeature and therefore
 7+ * forces inheriting classes to implement sereveral methods.
68 *
79 * @file Maps_BaseMap.php
810 * @ingroup Maps
@@ -15,9 +17,6 @@
1618
1719 abstract class MapsBaseMap extends MapsMapFeature {
1820
19 - // TODO: move this abstract function to a new MapsBaseMapUtils file?
20 - //protected abstract static function getDefaultParams();
21 -
2221 protected $markerData = array();
2322
2423 /**
@@ -25,7 +24,8 @@
2625 * mapping services, calling the specific methods and finally returning the resulting output.
2726 *
2827 * @param unknown_type $parser
29 - * @param array $map
 28+ * @param array $params
 29+ *
3030 * @return html
3131 */
3232 public final function displayMap(&$parser, array $params) {
@@ -39,7 +39,7 @@
4040
4141 $this->setMapName();
4242
43 - $this->setCoordinates();
 43+ $this->setCoordinates($parser);
4444
4545 $this->setZoom();
4646
@@ -54,6 +54,10 @@
5555 return $this->output;
5656 }
5757
 58+ /**
 59+ * (non-PHPdoc)
 60+ * @see smw/extensions/Maps/MapsMapFeature#manageMapProperties($mapProperties, $className)
 61+ */
5862 protected function manageMapProperties($params) {
5963 parent::manageMapProperties($params, __CLASS__);
6064 }
@@ -78,8 +82,9 @@
7983 /**
8084 * Fills the $markerData array with the locations and their meta data.
8185 *
 86+ * @param unknown_type $parser
8287 */
83 - private function setCoordinates() {
 88+ private function setCoordinates($parser) {
8489 $this->coordinates = explode(';', $this->coordinates);
8590
8691 foreach($this->coordinates as $coordinates) {
@@ -91,10 +96,10 @@
9297 $markerData = MapsUtils::getLatLon($args[0]);
9398
9499 if (count($args) > 1) {
95 - $markerData['title'] = $args[1];
 100+ $markerData['title'] = $parser->recursiveTagParse( $args[1] );
96101
97102 if (count($args) > 2) {
98 - $markerData['label'] = $args[2];
 103+ $markerData['label'] = $parser->recursiveTagParse( $args[2] );
99104
100105 if (count($args) > 3) {
101106 $markerData['icon'] = $args[3];
@@ -142,9 +147,9 @@
143148 /**
144149 * Parse the wiki text in the title and label values.
145150 *
146 - * @param $parser
 151+ * @param unknown_type $parser
147152 */
148 - private function DoParsing(&$parser) {
 153+ private function doParsing(&$parser) {
149154 $this->title = $parser->recursiveTagParse( $this->title );
150155 $this->label = $parser->recursiveTagParse( $this->label );
151156 }
Index: trunk/extensions/Maps/Maps.php
@@ -23,21 +23,15 @@
2424 die( 'Not an entry point.' );
2525 }
2626
27 -define('Maps_VERSION', '0.3.5');
 27+define('Maps_VERSION', '0.3.5 a2');
2828
2929 $egMapsScriptPath = $wgScriptPath . '/extensions/Maps';
3030 $egMapsIP = $IP . '/extensions/Maps';
31 -$egMapsIncludePath = $wgServer . $egMapsScriptPath;
3231
3332 // Include the settings file
3433 require_once($egMapsIP . '/Maps_Settings.php');
3534
36 -// Add the extensions initializing function
37 -if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
38 - $wgHooks['ParserFirstCallInit'][] = 'efMapsSetup';
39 -} else {
40 - $wgExtensionFunctions[] = 'efMapsSetup'; // Legacy support
41 -}
 35+$wgExtensionFunctions[] = 'efMapsSetup';
4236
4337 $wgExtensionMessagesFiles['Maps'] = $egMapsIP . '/Maps.i18n.php';
4438
@@ -65,7 +59,7 @@
6660 /**
6761 * Initialization function for the Maps extension
6862 */
69 -function efMapsSetup() {
 63+function efMapsSetup() {
7064 global $wgExtensionCredits, $wgOut, $wgLang, $wgAutoloadClasses, $IP;
7165 global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsScriptPath, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, $egMapsIP, $egMapsAvailableFeatures;
7266
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php
@@ -115,13 +115,16 @@
116116 * @param string $output
117117 */
118118 public static function addGMapDependencies(&$output) {
119 - global $wgJsMimeType, $wgLang;
120 - global $egGoogleMapsKey, $egMapsIncludePath, $egGoogleMapsOnThisPage;
 119+ global $wgJsMimeType, $wgLang, $wgOut;
 120+ global $egGoogleMapsKey, $egMapsScriptPath, $egGoogleMapsOnThisPage;
121121
122122 if (empty($egGoogleMapsOnThisPage)) {
 123+ // TODO: strbuilder for performance?
123124 $egGoogleMapsOnThisPage = 0;
 125+
 126+ $wgOut->addScriptFile($egMapsScriptPath . '/GoogleMaps/GoogleMapFunctions.js');
124127 $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$wgLang->getCode()}' type='$wgJsMimeType'></script>
125 - <script type='$wgJsMimeType' src='$egMapsIncludePath/GoogleMaps/GoogleMapFunctions.js'></script>";
 128+ <script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions.js'></script>";
126129 }
127130 }
128131
Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js
@@ -28,6 +28,7 @@
2929 if ((title + label).length > 0) {
3030 var bothTxtAreSet = title.length > 0 && label.length > 0;
3131 var popupText = bothTxtAreSet ? '<b>' + title + '</b><hr />' + label : title + label;
 32+ popupText = '<div style="overflow:auto;max-height:150px;">' + popupText + '</div>';
3233
3334 GEvent.addListener(marker, 'click',
3435 function() {
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsUtils.php
@@ -81,12 +81,12 @@
8282 */
8383 public static function addYMapDependencies(&$output) {
8484 global $wgJsMimeType;
85 - global $egYahooMapsKey, $egMapsIncludePath, $egYahooMapsOnThisPage;
 85+ global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage;
8686
8787 if (empty($egYahooMapsOnThisPage)) {
8888 $egYahooMapsOnThisPage = 0;
8989 $output .= "<script type='$wgJsMimeType' src='http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey'></script>
90 - <script type='$wgJsMimeType' src='$egMapsIncludePath/YahooMaps/YahooMapFunctions.js'></script>";
 90+ <script type='$wgJsMimeType' src='$egMapsScriptPath/YahooMaps/YahooMapFunctions.js'></script>";
9191 }
9292 }
9393

Status & tagging log