Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersUtils.php |
— | — | @@ -74,14 +74,14 @@ |
75 | 75 | */ |
76 | 76 | public static function addOLDependencies(&$output) { |
77 | 77 | global $wgJsMimeType; |
78 | | - global $egOpenLayersOnThisPage, $egMapsIncludePath; |
| 78 | + global $egOpenLayersOnThisPage, $egMapsScriptPath; |
79 | 79 | |
80 | 80 | if (empty($egOpenLayersOnThisPage)) { |
81 | 81 | $egOpenLayersOnThisPage = 0; |
82 | 82 | |
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> |
86 | 86 | <script type='$wgJsMimeType'>initOLSettings(200, 100);</script>\n"; |
87 | 87 | } |
88 | 88 | } |
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | } |
16 | 16 | |
17 | 17 | $wgHooks['LanguageGetMagic'][] = 'efMapsFunctionMagic'; |
| 18 | +$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterParserFunctions'; |
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Adds the magic words for the parser functions |
— | — | @@ -32,6 +33,25 @@ |
33 | 34 | } |
34 | 35 | |
35 | 36 | /** |
| 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 | +/** |
36 | 56 | * A class that holds handlers for the mapping parser functions. |
37 | 57 | * Spesific functions are located in @see MapsUtils |
38 | 58 | * |
— | — | @@ -45,32 +65,11 @@ |
46 | 66 | * |
47 | 67 | */ |
48 | 68 | public static function initialize() { |
49 | | - global $egMapsIP, $wgAutoloadClasses; |
50 | | - $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php'; |
| 69 | + global $egMapsIP, $wgAutoloadClasses, $wgHooks, $wgParser; |
51 | 70 | |
52 | | - self::addParserHooks(); |
| 71 | + $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php'; |
53 | 72 | } |
54 | 73 | |
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 | | - |
75 | 74 | public static function getMapHtml(&$parser, array $params, array $coordFails = array()) { |
76 | 75 | global $wgLang; |
77 | 76 | |
— | — | @@ -214,7 +213,6 @@ |
215 | 214 | |
216 | 215 | if ($isAddress || count($split) == 1) { |
217 | 216 | $address_srting = count($split) == 1 ? $split[0] : $split[1]; |
218 | | - //var_dump($address_srting); |
219 | 217 | $addresses = explode(';', $address_srting); |
220 | 218 | |
221 | 219 | $coordinates = array(); |
— | — | @@ -239,7 +237,7 @@ |
240 | 238 | $params[$i] = 'coordinates=' . implode(';', $coordinates); |
241 | 239 | |
242 | 240 | } |
243 | | - } //exit; |
| 241 | + } |
244 | 242 | |
245 | 243 | return $fails; |
246 | 244 | } |
Index: trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php |
— | — | @@ -1,7 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
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. |
6 | 8 | * |
7 | 9 | * @file Maps_BaseMap.php |
8 | 10 | * @ingroup Maps |
— | — | @@ -15,9 +17,6 @@ |
16 | 18 | |
17 | 19 | abstract class MapsBaseMap extends MapsMapFeature { |
18 | 20 | |
19 | | - // TODO: move this abstract function to a new MapsBaseMapUtils file? |
20 | | - //protected abstract static function getDefaultParams(); |
21 | | - |
22 | 21 | protected $markerData = array(); |
23 | 22 | |
24 | 23 | /** |
— | — | @@ -25,7 +24,8 @@ |
26 | 25 | * mapping services, calling the specific methods and finally returning the resulting output. |
27 | 26 | * |
28 | 27 | * @param unknown_type $parser |
29 | | - * @param array $map |
| 28 | + * @param array $params |
| 29 | + * |
30 | 30 | * @return html |
31 | 31 | */ |
32 | 32 | public final function displayMap(&$parser, array $params) { |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | |
41 | 41 | $this->setMapName(); |
42 | 42 | |
43 | | - $this->setCoordinates(); |
| 43 | + $this->setCoordinates($parser); |
44 | 44 | |
45 | 45 | $this->setZoom(); |
46 | 46 | |
— | — | @@ -54,6 +54,10 @@ |
55 | 55 | return $this->output; |
56 | 56 | } |
57 | 57 | |
| 58 | + /** |
| 59 | + * (non-PHPdoc) |
| 60 | + * @see smw/extensions/Maps/MapsMapFeature#manageMapProperties($mapProperties, $className) |
| 61 | + */ |
58 | 62 | protected function manageMapProperties($params) { |
59 | 63 | parent::manageMapProperties($params, __CLASS__); |
60 | 64 | } |
— | — | @@ -78,8 +82,9 @@ |
79 | 83 | /** |
80 | 84 | * Fills the $markerData array with the locations and their meta data. |
81 | 85 | * |
| 86 | + * @param unknown_type $parser |
82 | 87 | */ |
83 | | - private function setCoordinates() { |
| 88 | + private function setCoordinates($parser) { |
84 | 89 | $this->coordinates = explode(';', $this->coordinates); |
85 | 90 | |
86 | 91 | foreach($this->coordinates as $coordinates) { |
— | — | @@ -91,10 +96,10 @@ |
92 | 97 | $markerData = MapsUtils::getLatLon($args[0]); |
93 | 98 | |
94 | 99 | if (count($args) > 1) { |
95 | | - $markerData['title'] = $args[1]; |
| 100 | + $markerData['title'] = $parser->recursiveTagParse( $args[1] ); |
96 | 101 | |
97 | 102 | if (count($args) > 2) { |
98 | | - $markerData['label'] = $args[2]; |
| 103 | + $markerData['label'] = $parser->recursiveTagParse( $args[2] ); |
99 | 104 | |
100 | 105 | if (count($args) > 3) { |
101 | 106 | $markerData['icon'] = $args[3]; |
— | — | @@ -142,9 +147,9 @@ |
143 | 148 | /** |
144 | 149 | * Parse the wiki text in the title and label values. |
145 | 150 | * |
146 | | - * @param $parser |
| 151 | + * @param unknown_type $parser |
147 | 152 | */ |
148 | | - private function DoParsing(&$parser) { |
| 153 | + private function doParsing(&$parser) { |
149 | 154 | $this->title = $parser->recursiveTagParse( $this->title ); |
150 | 155 | $this->label = $parser->recursiveTagParse( $this->label ); |
151 | 156 | } |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -23,21 +23,15 @@ |
24 | 24 | die( 'Not an entry point.' ); |
25 | 25 | } |
26 | 26 | |
27 | | -define('Maps_VERSION', '0.3.5'); |
| 27 | +define('Maps_VERSION', '0.3.5 a2'); |
28 | 28 | |
29 | 29 | $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
30 | 30 | $egMapsIP = $IP . '/extensions/Maps'; |
31 | | -$egMapsIncludePath = $wgServer . $egMapsScriptPath; |
32 | 31 | |
33 | 32 | // Include the settings file |
34 | 33 | require_once($egMapsIP . '/Maps_Settings.php'); |
35 | 34 | |
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'; |
42 | 36 | |
43 | 37 | $wgExtensionMessagesFiles['Maps'] = $egMapsIP . '/Maps.i18n.php'; |
44 | 38 | |
— | — | @@ -65,7 +59,7 @@ |
66 | 60 | /** |
67 | 61 | * Initialization function for the Maps extension |
68 | 62 | */ |
69 | | -function efMapsSetup() { |
| 63 | +function efMapsSetup() { |
70 | 64 | global $wgExtensionCredits, $wgOut, $wgLang, $wgAutoloadClasses, $IP; |
71 | 65 | global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsScriptPath, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, $egMapsIP, $egMapsAvailableFeatures; |
72 | 66 | |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsUtils.php |
— | — | @@ -115,13 +115,16 @@ |
116 | 116 | * @param string $output |
117 | 117 | */ |
118 | 118 | public static function addGMapDependencies(&$output) { |
119 | | - global $wgJsMimeType, $wgLang; |
120 | | - global $egGoogleMapsKey, $egMapsIncludePath, $egGoogleMapsOnThisPage; |
| 119 | + global $wgJsMimeType, $wgLang, $wgOut; |
| 120 | + global $egGoogleMapsKey, $egMapsScriptPath, $egGoogleMapsOnThisPage; |
121 | 121 | |
122 | 122 | if (empty($egGoogleMapsOnThisPage)) { |
| 123 | + // TODO: strbuilder for performance? |
123 | 124 | $egGoogleMapsOnThisPage = 0; |
| 125 | + |
| 126 | + $wgOut->addScriptFile($egMapsScriptPath . '/GoogleMaps/GoogleMapFunctions.js'); |
124 | 127 | $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>"; |
126 | 129 | } |
127 | 130 | } |
128 | 131 | |
Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | if ((title + label).length > 0) { |
30 | 30 | var bothTxtAreSet = title.length > 0 && label.length > 0; |
31 | 31 | var popupText = bothTxtAreSet ? '<b>' + title + '</b><hr />' + label : title + label; |
| 32 | + popupText = '<div style="overflow:auto;max-height:150px;">' + popupText + '</div>'; |
32 | 33 | |
33 | 34 | GEvent.addListener(marker, 'click', |
34 | 35 | function() { |
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsUtils.php |
— | — | @@ -81,12 +81,12 @@ |
82 | 82 | */ |
83 | 83 | public static function addYMapDependencies(&$output) { |
84 | 84 | global $wgJsMimeType; |
85 | | - global $egYahooMapsKey, $egMapsIncludePath, $egYahooMapsOnThisPage; |
| 85 | + global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage; |
86 | 86 | |
87 | 87 | if (empty($egYahooMapsOnThisPage)) { |
88 | 88 | $egYahooMapsOnThisPage = 0; |
89 | 89 | $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>"; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |