Property changes on: trunk/phase3/maintenance/tests/TitlePermissionTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1 | + native |
Index: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_QueryPrinters.php |
— | — | @@ -1,174 +1,174 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Initialization file for query printer functionality in the Semantic Maps extension
|
6 | | - *
|
7 | | - * @file SM_QueryPrinters.php
|
8 | | - * @ingroup SemanticMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -$wgAutoloadClasses['SMQueryPrinters'] = __FILE__;
|
18 | | -
|
19 | | -$wgHooks['MappingFeatureLoad'][] = 'SMQueryPrinters::initialize';
|
20 | | -
|
21 | | -final class SMQueryPrinters {
|
22 | | -
|
23 | | - public static $parameters = array();
|
24 | | -
|
25 | | - /**
|
26 | | - * Initialization function for Maps query printer functionality.
|
27 | | - */
|
28 | | - public static function initialize() {
|
29 | | - global $smgDir, $wgAutoloadClasses, $egMapsServices;
|
30 | | -
|
31 | | - $wgAutoloadClasses['SMMapper'] = dirname( __FILE__ ) . '/SM_Mapper.php';
|
32 | | - $wgAutoloadClasses['SMMapPrinter'] = dirname( __FILE__ ) . '/SM_MapPrinter.php';
|
33 | | -
|
34 | | - self::initializeParams();
|
35 | | -
|
36 | | - $hasQueryPrinters = false;
|
37 | | -
|
38 | | - foreach ( $egMapsServices as $serviceName => $serviceData ) {
|
39 | | - // Check if the service has a query printer.
|
40 | | - $hasQP = array_key_exists( 'qp', $serviceData['features'] );
|
41 | | -
|
42 | | - // If the service has no QP, skipt it and continue with the next one.
|
43 | | - if ( !$hasQP ) continue;
|
44 | | -
|
45 | | - // At least one query printer will be enabled when this point is reached.
|
46 | | - $hasQueryPrinters = true;
|
47 | | -
|
48 | | - // Initiate the format.
|
49 | | - self::initFormat( $serviceName, $serviceData['features']['qp'], $serviceData['aliases'] );
|
50 | | - }
|
51 | | -
|
52 | | - // Add the 'map' result format if there are mapping services that have QP's loaded.
|
53 | | - if ( $hasQueryPrinters ) self::initFormat( 'map', 'SMMapper' );
|
54 | | -
|
55 | | - return true;
|
56 | | - }
|
57 | | -
|
58 | | - private static function initializeParams() {
|
59 | | - global $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
|
60 | | - global $smgQPForceShow, $smgQPShowTitle, $smgQPTemplate;
|
61 | | -
|
62 | | - self::$parameters = array(
|
63 | | - 'geoservice' => array(
|
64 | | - 'criteria' => array(
|
65 | | - 'in_array' => $egMapsAvailableGeoServices
|
66 | | - ),
|
67 | | - 'default' => $egMapsDefaultGeoService
|
68 | | - ),
|
69 | | - 'format' => array(
|
70 | | - 'required' => true,
|
71 | | - 'default' => $egMapsDefaultServices['qp']
|
72 | | - ),
|
73 | | - 'centre' => array(
|
74 | | - 'aliases' => array( 'center' ),
|
75 | | - ),
|
76 | | - 'forceshow' => array(
|
77 | | - 'type' => 'boolean',
|
78 | | - 'aliases' => array( 'force show' ),
|
79 | | - 'default' => $smgQPForceShow,
|
80 | | - 'output-type' => 'boolean'
|
81 | | - ),
|
82 | | - 'template' => array(
|
83 | | - 'criteria' => array(
|
84 | | - 'not_empty' => array()
|
85 | | - ),
|
86 | | - 'default' => $smgQPTemplate,
|
87 | | - ),
|
88 | | - 'showtitle' => array(
|
89 | | - 'type' => 'boolean',
|
90 | | - 'aliases' => array( 'show title' ),
|
91 | | - 'default' => $smgQPShowTitle,
|
92 | | - 'output-type' => 'boolean'
|
93 | | - ),
|
94 | | - 'icon' => array(
|
95 | | - 'criteria' => array(
|
96 | | - 'not_empty' => array()
|
97 | | - )
|
98 | | - ),
|
99 | | - // SMW #Ask: parameters
|
100 | | - 'limit' => array(
|
101 | | - 'type' => 'integer',
|
102 | | - 'criteria' => array(
|
103 | | - 'in_range' => array( 0 )
|
104 | | - )
|
105 | | - ),
|
106 | | - 'offset' => array(
|
107 | | - 'type' => 'integer'
|
108 | | - ),
|
109 | | - 'sort' => array(),
|
110 | | - 'order' => array(
|
111 | | - 'criteria' => array(
|
112 | | - 'in_array' => array( 'ascending', 'asc', 'descending', 'desc', 'reverse' )
|
113 | | - )
|
114 | | - ),
|
115 | | - 'headers' => array(
|
116 | | - 'criteria' => array(
|
117 | | - 'in_array' => array( 'show', 'hide' )
|
118 | | - )
|
119 | | - ),
|
120 | | - 'mainlabel' => array(),
|
121 | | - 'link' => array(
|
122 | | - 'criteria' => array(
|
123 | | - 'in_array' => array( 'none', 'subject', 'all' )
|
124 | | - )
|
125 | | - ),
|
126 | | - 'default' => array(),
|
127 | | - 'intro' => array(),
|
128 | | - 'outro' => array(),
|
129 | | - 'searchlabel' => array(),
|
130 | | - 'distance' => array(),
|
131 | | - );
|
132 | | - }
|
133 | | -
|
134 | | - /**
|
135 | | - * Add the result format for a mapping service or alias.
|
136 | | - *
|
137 | | - * @param string $format
|
138 | | - * @param string $formatClass
|
139 | | - * @param array $aliases
|
140 | | - */
|
141 | | - private static function initFormat( $format, $formatClass, array $aliases = array() ) {
|
142 | | - global $wgAutoloadClasses, $smgDir, $smwgResultAliases;
|
143 | | -
|
144 | | - // Add the QP to SMW.
|
145 | | - self::addFormatQP( $format, $formatClass );
|
146 | | -
|
147 | | - // If SMW supports aliasing, add the aliases to $smwgResultAliases.
|
148 | | - if ( isset( $smwgResultAliases ) ) {
|
149 | | - $smwgResultAliases[$format] = $aliases;
|
150 | | - }
|
151 | | - else { // If SMW does not support aliasing, add every alias as a format.
|
152 | | - foreach ( $aliases as $alias ) self::addFormatQP( $alias, $formatClass );
|
153 | | - }
|
154 | | - }
|
155 | | -
|
156 | | - /**
|
157 | | - * Adds a QP to SMW's $smwgResultFormats array or SMWQueryProcessor
|
158 | | - * depending on if SMW supports $smwgResultFormats.
|
159 | | - *
|
160 | | - * @param string $format
|
161 | | - * @param string $class
|
162 | | - */
|
163 | | - private static function addFormatQP( $format, $class ) {
|
164 | | - global $smwgResultFormats;
|
165 | | -
|
166 | | - if ( isset( $smwgResultFormats ) ) {
|
167 | | - $smwgResultFormats[$format] = $class;
|
168 | | - }
|
169 | | - else {
|
170 | | - SMWQueryProcessor::$formats[$format] = $class;
|
171 | | - }
|
172 | | - }
|
173 | | -
|
174 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Initialization file for query printer functionality in the Semantic Maps extension |
| 6 | + * |
| 7 | + * @file SM_QueryPrinters.php |
| 8 | + * @ingroup SemanticMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +$wgAutoloadClasses['SMQueryPrinters'] = __FILE__; |
| 18 | + |
| 19 | +$wgHooks['MappingFeatureLoad'][] = 'SMQueryPrinters::initialize'; |
| 20 | + |
| 21 | +final class SMQueryPrinters { |
| 22 | + |
| 23 | + public static $parameters = array(); |
| 24 | + |
| 25 | + /** |
| 26 | + * Initialization function for Maps query printer functionality. |
| 27 | + */ |
| 28 | + public static function initialize() { |
| 29 | + global $smgDir, $wgAutoloadClasses, $egMapsServices; |
| 30 | + |
| 31 | + $wgAutoloadClasses['SMMapper'] = dirname( __FILE__ ) . '/SM_Mapper.php'; |
| 32 | + $wgAutoloadClasses['SMMapPrinter'] = dirname( __FILE__ ) . '/SM_MapPrinter.php'; |
| 33 | + |
| 34 | + self::initializeParams(); |
| 35 | + |
| 36 | + $hasQueryPrinters = false; |
| 37 | + |
| 38 | + foreach ( $egMapsServices as $serviceName => $serviceData ) { |
| 39 | + // Check if the service has a query printer. |
| 40 | + $hasQP = array_key_exists( 'qp', $serviceData['features'] ); |
| 41 | + |
| 42 | + // If the service has no QP, skipt it and continue with the next one. |
| 43 | + if ( !$hasQP ) continue; |
| 44 | + |
| 45 | + // At least one query printer will be enabled when this point is reached. |
| 46 | + $hasQueryPrinters = true; |
| 47 | + |
| 48 | + // Initiate the format. |
| 49 | + self::initFormat( $serviceName, $serviceData['features']['qp'], $serviceData['aliases'] ); |
| 50 | + } |
| 51 | + |
| 52 | + // Add the 'map' result format if there are mapping services that have QP's loaded. |
| 53 | + if ( $hasQueryPrinters ) self::initFormat( 'map', 'SMMapper' ); |
| 54 | + |
| 55 | + return true; |
| 56 | + } |
| 57 | + |
| 58 | + private static function initializeParams() { |
| 59 | + global $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService; |
| 60 | + global $smgQPForceShow, $smgQPShowTitle, $smgQPTemplate; |
| 61 | + |
| 62 | + self::$parameters = array( |
| 63 | + 'geoservice' => array( |
| 64 | + 'criteria' => array( |
| 65 | + 'in_array' => $egMapsAvailableGeoServices |
| 66 | + ), |
| 67 | + 'default' => $egMapsDefaultGeoService |
| 68 | + ), |
| 69 | + 'format' => array( |
| 70 | + 'required' => true, |
| 71 | + 'default' => $egMapsDefaultServices['qp'] |
| 72 | + ), |
| 73 | + 'centre' => array( |
| 74 | + 'aliases' => array( 'center' ), |
| 75 | + ), |
| 76 | + 'forceshow' => array( |
| 77 | + 'type' => 'boolean', |
| 78 | + 'aliases' => array( 'force show' ), |
| 79 | + 'default' => $smgQPForceShow, |
| 80 | + 'output-type' => 'boolean' |
| 81 | + ), |
| 82 | + 'template' => array( |
| 83 | + 'criteria' => array( |
| 84 | + 'not_empty' => array() |
| 85 | + ), |
| 86 | + 'default' => $smgQPTemplate, |
| 87 | + ), |
| 88 | + 'showtitle' => array( |
| 89 | + 'type' => 'boolean', |
| 90 | + 'aliases' => array( 'show title' ), |
| 91 | + 'default' => $smgQPShowTitle, |
| 92 | + 'output-type' => 'boolean' |
| 93 | + ), |
| 94 | + 'icon' => array( |
| 95 | + 'criteria' => array( |
| 96 | + 'not_empty' => array() |
| 97 | + ) |
| 98 | + ), |
| 99 | + // SMW #Ask: parameters |
| 100 | + 'limit' => array( |
| 101 | + 'type' => 'integer', |
| 102 | + 'criteria' => array( |
| 103 | + 'in_range' => array( 0 ) |
| 104 | + ) |
| 105 | + ), |
| 106 | + 'offset' => array( |
| 107 | + 'type' => 'integer' |
| 108 | + ), |
| 109 | + 'sort' => array(), |
| 110 | + 'order' => array( |
| 111 | + 'criteria' => array( |
| 112 | + 'in_array' => array( 'ascending', 'asc', 'descending', 'desc', 'reverse' ) |
| 113 | + ) |
| 114 | + ), |
| 115 | + 'headers' => array( |
| 116 | + 'criteria' => array( |
| 117 | + 'in_array' => array( 'show', 'hide' ) |
| 118 | + ) |
| 119 | + ), |
| 120 | + 'mainlabel' => array(), |
| 121 | + 'link' => array( |
| 122 | + 'criteria' => array( |
| 123 | + 'in_array' => array( 'none', 'subject', 'all' ) |
| 124 | + ) |
| 125 | + ), |
| 126 | + 'default' => array(), |
| 127 | + 'intro' => array(), |
| 128 | + 'outro' => array(), |
| 129 | + 'searchlabel' => array(), |
| 130 | + 'distance' => array(), |
| 131 | + ); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Add the result format for a mapping service or alias. |
| 136 | + * |
| 137 | + * @param string $format |
| 138 | + * @param string $formatClass |
| 139 | + * @param array $aliases |
| 140 | + */ |
| 141 | + private static function initFormat( $format, $formatClass, array $aliases = array() ) { |
| 142 | + global $wgAutoloadClasses, $smgDir, $smwgResultAliases; |
| 143 | + |
| 144 | + // Add the QP to SMW. |
| 145 | + self::addFormatQP( $format, $formatClass ); |
| 146 | + |
| 147 | + // If SMW supports aliasing, add the aliases to $smwgResultAliases. |
| 148 | + if ( isset( $smwgResultAliases ) ) { |
| 149 | + $smwgResultAliases[$format] = $aliases; |
| 150 | + } |
| 151 | + else { // If SMW does not support aliasing, add every alias as a format. |
| 152 | + foreach ( $aliases as $alias ) self::addFormatQP( $alias, $formatClass ); |
| 153 | + } |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Adds a QP to SMW's $smwgResultFormats array or SMWQueryProcessor |
| 158 | + * depending on if SMW supports $smwgResultFormats. |
| 159 | + * |
| 160 | + * @param string $format |
| 161 | + * @param string $class |
| 162 | + */ |
| 163 | + private static function addFormatQP( $format, $class ) { |
| 164 | + global $smwgResultFormats; |
| 165 | + |
| 166 | + if ( isset( $smwgResultFormats ) ) { |
| 167 | + $smwgResultFormats[$format] = $class; |
| 168 | + } |
| 169 | + else { |
| 170 | + SMWQueryProcessor::$formats[$format] = $class; |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | + |
175 | 175 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_QueryPrinters.php |
___________________________________________________________________ |
Added: svn:eol-style |
176 | 176 | + native |
Index: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php |
— | — | @@ -1,358 +1,358 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding abstract class SMMapPrinter.
|
6 | | - *
|
7 | | - * @file SM_MapPrinter.php
|
8 | | - * @ingroup SemanticMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - * @author Robert Buzink
|
12 | | - * @author Yaron Koren
|
13 | | - */
|
14 | | -
|
15 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
16 | | - die( 'Not an entry point.' );
|
17 | | -}
|
18 | | -
|
19 | | -/**
|
20 | | - * Abstract class that provides the common functionallity for all map query printers.
|
21 | | - *
|
22 | | - * @ingroup SemanticMaps
|
23 | | - *
|
24 | | - * @author Jeroen De Dauw
|
25 | | - * @author Robert Buzink
|
26 | | - * @author Yaron Koren
|
27 | | - *
|
28 | | - * TODO:
|
29 | | - * This class is borrowing an awefull lot code from MapsMapFeature, which
|
30 | | - * ideally should be inherited. Since SMWResultPrinter already gets inherited,
|
31 | | - * this is not possible. Finding a better solution to this code redundancy
|
32 | | - * would be nice, cause now changes to MapsMapFeature need to be copied here.
|
33 | | - *
|
34 | | - * The adaptor pattern could be used to prevent this.
|
35 | | - */
|
36 | | -abstract class SMMapPrinter extends SMWResultPrinter {
|
37 | | -
|
38 | | - /**
|
39 | | - * Sets the map service specific element name
|
40 | | - */
|
41 | | - protected abstract function setQueryPrinterSettings();
|
42 | | -
|
43 | | - /**
|
44 | | - * Map service spesific map count and loading of dependencies
|
45 | | - */
|
46 | | - protected abstract function doMapServiceLoad();
|
47 | | -
|
48 | | - /**
|
49 | | - * Gets the query result
|
50 | | - */
|
51 | | - protected abstract function addSpecificMapHTML( Parser $parser );
|
52 | | -
|
53 | | - public $serviceName;
|
54 | | -
|
55 | | - protected $m_locations = array();
|
56 | | -
|
57 | | - protected $defaultZoom;
|
58 | | -
|
59 | | - protected $centreLat;
|
60 | | - protected $centreLon;
|
61 | | -
|
62 | | - protected $output = '';
|
63 | | - protected $errorList;
|
64 | | -
|
65 | | - protected $mapFeature;
|
66 | | -
|
67 | | - protected $featureParameters = array();
|
68 | | - protected $spesificParameters = array();
|
69 | | -
|
70 | | - /**
|
71 | | - * Builds up and returns the HTML for the map, with the queried coordinate data on it.
|
72 | | - *
|
73 | | - * @param unknown_type $res
|
74 | | - * @param unknown_type $outputmode
|
75 | | - *
|
76 | | - * @return array
|
77 | | - */
|
78 | | - public final function getResultText( $res, $outputmode ) {
|
79 | | - $this->setQueryPrinterSettings();
|
80 | | -
|
81 | | - $this->featureParameters = SMQueryPrinters::$parameters;
|
82 | | -
|
83 | | - if ( self::manageMapProperties( $this->m_params ) ) {
|
84 | | - $this->formatResultData( $res, $outputmode );
|
85 | | -
|
86 | | - // Only create a map when there is at least one result.
|
87 | | - if ( count( $this->m_locations ) > 0 || $this->forceshow ) {
|
88 | | - $this->doMapServiceLoad();
|
89 | | -
|
90 | | - $this->setMapName();
|
91 | | -
|
92 | | - $this->setZoom();
|
93 | | -
|
94 | | - $this->setCentre();
|
95 | | -
|
96 | | - global $wgParser;
|
97 | | - $this->addSpecificMapHTML( $wgParser );
|
98 | | - }
|
99 | | - else {
|
100 | | - // TODO: add warning when level high enough and append to error list?
|
101 | | - }
|
102 | | - }
|
103 | | -
|
104 | | - return array( $this->output . $this->errorList, 'noparse' => true, 'isHTML' => true );
|
105 | | - }
|
106 | | -
|
107 | | - /**
|
108 | | - * Validates and corrects the provided map properties, and the sets them as class fields.
|
109 | | - *
|
110 | | - * @param array $mapProperties
|
111 | | - *
|
112 | | - * @return boolean Indicates whether the map should be shown or not.
|
113 | | - */
|
114 | | - protected final function manageMapProperties( array $mapProperties ) {
|
115 | | - global $egMapsServices;
|
116 | | -
|
117 | | - /*
|
118 | | - * Assembliy of the allowed parameters and their information.
|
119 | | - * The main parameters (the ones that are shared by everything) are overidden
|
120 | | - * by the feature parameters (the ones spesific to a feature). The result is then
|
121 | | - * again overidden by the service parameters (the ones spesific to the service),
|
122 | | - * and finally by the spesific parameters (the ones spesific to a service-feature combination).
|
123 | | - */
|
124 | | - $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), $this->featureParameters );
|
125 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] );
|
126 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $this->spesificParameters );
|
127 | | -
|
128 | | - $manager = new ValidatorManager();
|
129 | | -
|
130 | | - $result = $manager->manageParameters( $mapProperties, $parameterInfo );
|
131 | | -
|
132 | | - $showMap = $result !== false;
|
133 | | -
|
134 | | - if ( $showMap ) $this->setMapProperties( $result, __CLASS__ );
|
135 | | -
|
136 | | - $this->errorList = $manager->getErrorList();
|
137 | | -
|
138 | | - return $showMap;
|
139 | | - }
|
140 | | -
|
141 | | - /**
|
142 | | - * Sets the map properties as class fields.
|
143 | | - *
|
144 | | - * @param array $mapProperties
|
145 | | - * @param string $className
|
146 | | - */
|
147 | | - private function setMapProperties( array $mapProperties, $className ) {
|
148 | | - // var_dump($mapProperties); exit;
|
149 | | - foreach ( $mapProperties as $paramName => $paramValue ) {
|
150 | | - if ( ! property_exists( $className, $paramName ) ) {
|
151 | | - $this-> { $paramName } = $paramValue;
|
152 | | - }
|
153 | | - else {
|
154 | | - throw new Exception( 'Attempt to override a class field during map propertie assignment. Field name: ' . $paramName );
|
155 | | - }
|
156 | | - }
|
157 | | - }
|
158 | | -
|
159 | | - public final function getResult( $results, $params, $outputmode ) {
|
160 | | - // Skip checks, results with 0 entries are normal
|
161 | | - $this->readParameters( $params, $outputmode );
|
162 | | - return $this->getResultText( $results, SMW_OUTPUT_HTML );
|
163 | | - }
|
164 | | -
|
165 | | - private function formatResultData( $res, $outputmode ) {
|
166 | | - while ( ( $row = $res->getNext() ) !== false ) {
|
167 | | - $this->addResultRow( $outputmode, $row );
|
168 | | - }
|
169 | | - }
|
170 | | -
|
171 | | - /**
|
172 | | - * This function will loop through all properties (fields) of one record (row),
|
173 | | - * and add the location data, title, label and icon to the m_locations array.
|
174 | | - *
|
175 | | - * @param unknown_type $outputmode
|
176 | | - * @param unknown_type $row The record you want to add data from
|
177 | | - */
|
178 | | - private function addResultRow( $outputmode, $row ) {
|
179 | | - global $wgUser;
|
180 | | - $skin = $wgUser->getSkin();
|
181 | | -
|
182 | | - $title = '';
|
183 | | - $titleForTemplate = '';
|
184 | | - $text = '';
|
185 | | - $lat = '';
|
186 | | - $lon = '';
|
187 | | -
|
188 | | - $coords = array();
|
189 | | - $label = array();
|
190 | | -
|
191 | | - // Loop throught all fields of the record
|
192 | | - foreach ( $row as $i => $field ) {
|
193 | | - $pr = $field->getPrintRequest();
|
194 | | -
|
195 | | - // Loop throught all the parts of the field value
|
196 | | - while ( ( $object = $field->getNextObject() ) !== false ) {
|
197 | | - if ( $object->getTypeID() == '_wpg' && $i == 0 ) {
|
198 | | - if ( $this->showtitle ) $title = $object->getLongText( $outputmode, $skin );
|
199 | | - if ( $this->template ) $titleForTemplate = $object->getLongText( $outputmode, NULL );
|
200 | | - }
|
201 | | -
|
202 | | - if ( $object->getTypeID() != '_geo' && $i != 0 ) {
|
203 | | - if ( $this->template ) {
|
204 | | - if ( $object instanceof SMWWikiPageValue ) {
|
205 | | - $label[] = $object->getTitle()->getPrefixedText();
|
206 | | - } else {
|
207 | | - $label[] = $object->getLongText( $outputmode, $skin );
|
208 | | - }
|
209 | | - }
|
210 | | - else {
|
211 | | - $text .= $pr->getHTMLText( $skin ) . ': ' . $object->getLongText( $outputmode, $skin ) . '<br />';
|
212 | | - }
|
213 | | - }
|
214 | | -
|
215 | | - if ( $pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo' ) {
|
216 | | - $coords[] = $object->getDBkeys();
|
217 | | - }
|
218 | | - }
|
219 | | - }
|
220 | | -
|
221 | | - foreach ( $coords as $coord ) {
|
222 | | - if ( count( $coord ) >= 2 ) {
|
223 | | - $lat = $coord[0];
|
224 | | - $lon = $coord[1];
|
225 | | -
|
226 | | - if ( $lat != '' && $lon != '' ) {
|
227 | | - $icon = $this->getLocationIcon( $row );
|
228 | | -
|
229 | | - if ( $this->template ) {
|
230 | | - global $wgParser;
|
231 | | - $segments = array_merge(
|
232 | | - array( $this->template, 'title=' . $titleForTemplate, 'latitude=' . $lat, 'longitude=' . $lon ),
|
233 | | - $label
|
234 | | - );
|
235 | | - $text = preg_replace( '/\n+/m', '<br />', $wgParser->recursiveTagParse( '{{' . implode( '|', $segments ) . '}}' ) );
|
236 | | - }
|
237 | | -
|
238 | | - $this->m_locations[] = array(
|
239 | | - Xml::escapeJsString( $lat ),
|
240 | | - Xml::escapeJsString( $lon ),
|
241 | | - Xml::escapeJsString( $title ),
|
242 | | - Xml::escapeJsString( $text ),
|
243 | | - Xml::escapeJsString( $icon )
|
244 | | - );
|
245 | | - }
|
246 | | - }
|
247 | | - }
|
248 | | - }
|
249 | | -
|
250 | | - /**
|
251 | | - * Get the icon for a row
|
252 | | - *
|
253 | | - * @param unknown_type $row
|
254 | | - * @return unknown
|
255 | | - */
|
256 | | - private function getLocationIcon( $row ) {
|
257 | | - $icon = '';
|
258 | | - $legend_labels = array();
|
259 | | -
|
260 | | - // Look for display_options field, which can be set by Semantic Compound Queries
|
261 | | - // the location of this field changed in SMW 1.5
|
262 | | - $display_location = method_exists( $row[0], 'getResultSubject' ) ? $display_location = $row[0]->getResultSubject() : $row[0];
|
263 | | -
|
264 | | - if ( property_exists( $display_location, 'display_options' ) && is_array( $display_location->display_options ) ) {
|
265 | | - $display_options = $display_location->display_options;
|
266 | | - if ( array_key_exists( 'icon', $display_options ) ) {
|
267 | | - $icon = $display_options['icon'];
|
268 | | -
|
269 | | - // This is somewhat of a hack - if a legend label has been set, we're getting it for every point, instead of just once per icon
|
270 | | - if ( array_key_exists( 'legend label', $display_options ) ) {
|
271 | | -
|
272 | | - $legend_label = $display_options['legend label'];
|
273 | | -
|
274 | | - if ( ! array_key_exists( $icon, $legend_labels ) ) {
|
275 | | - $legend_labels[$icon] = $legend_label;
|
276 | | - }
|
277 | | - }
|
278 | | - }
|
279 | | - // Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here
|
280 | | - } elseif ( strlen( $this->icon ) > 0 ) {
|
281 | | - $icon_image_page = new ImagePage( Title::newFromText( $this->icon ) );
|
282 | | - $icon = $icon_image_page->getDisplayedFile()->getURL();
|
283 | | - }
|
284 | | -
|
285 | | - return $icon;
|
286 | | - }
|
287 | | -
|
288 | | - /**
|
289 | | - * Sets the zoom level to the provided value, or when not set, to the default.
|
290 | | - *
|
291 | | - */
|
292 | | - private function setZoom() {
|
293 | | - if ( strlen( $this->zoom ) < 1 ) {
|
294 | | - if ( count( $this->m_locations ) > 1 ) {
|
295 | | - $this->zoom = 'null';
|
296 | | - }
|
297 | | - else {
|
298 | | - $this->zoom = $this->defaultZoom;
|
299 | | - }
|
300 | | - }
|
301 | | - }
|
302 | | -
|
303 | | - /**
|
304 | | - * Sets the $centre_lat and $centre_lon fields.
|
305 | | - * Note: this needs to be done AFTRE the maker coordinates are set.
|
306 | | - *
|
307 | | - */
|
308 | | - private function setCentre() {
|
309 | | - // If a centre value is set, use it.
|
310 | | - if ( strlen( $this->centre ) > 0 ) {
|
311 | | - // Geocode and convert if required.
|
312 | | - $centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName );
|
313 | | -
|
314 | | - $this->centreLat = $centre['lat'];
|
315 | | - $this->centreLon = $centre['lon'];
|
316 | | - }
|
317 | | - elseif ( count( $this->m_locations ) > 1 ) {
|
318 | | - // If centre is not set, and there are multiple points, set the values to null, to be auto determined by the JS of the mapping API.
|
319 | | - $this->centreLat = 'null';
|
320 | | - $this->centreLon = 'null';
|
321 | | - }
|
322 | | - elseif ( count( $this->m_locations ) == 1 ) {
|
323 | | - // If centre is not set and there is exactelly one marker, use it's coordinates.
|
324 | | - $this->centreLat = Xml::escapeJsString( $this->m_locations[0][0] );
|
325 | | - $this->centreLon = Xml::escapeJsString( $this->m_locations[0][1] );
|
326 | | - }
|
327 | | - else {
|
328 | | - // If centre is not set and there are no results, centre on the default coordinates.
|
329 | | - global $egMapsMapLat, $egMapsMapLon;
|
330 | | - $this->centreLat = $egMapsMapLat;
|
331 | | - $this->centreLon = $egMapsMapLon;
|
332 | | - }
|
333 | | - }
|
334 | | -
|
335 | | - /**
|
336 | | - * Sets the $mapName field, using the $elementNamePrefix and $elementNr.
|
337 | | - *
|
338 | | - */
|
339 | | - protected function setMapName() {
|
340 | | - $this->mapName = $this->elementNamePrefix . '_' . $this->elementNr;
|
341 | | - }
|
342 | | -
|
343 | | - public final function getName() {
|
344 | | - return wfMsg( 'maps_' . $this->serviceName );
|
345 | | - }
|
346 | | -
|
347 | | - public function getParameters() {
|
348 | | - global $egMapsMapWidth, $egMapsMapHeight;
|
349 | | -
|
350 | | - $params = parent::exportFormatParameters();
|
351 | | -
|
352 | | - $params[] = array( 'name' => 'zoom', 'type' => 'int', 'description' => wfMsg( 'semanticmaps_paramdesc_zoom' ) );
|
353 | | - $params[] = array( 'name' => 'width', 'type' => 'int', 'description' => wfMsgExt( 'semanticmaps_paramdesc_width', 'parsemag', $egMapsMapWidth ) );
|
354 | | - $params[] = array( 'name' => 'height', 'type' => 'int', 'description' => wfMsgExt( 'semanticmaps_paramdesc_height', 'parsemag', $egMapsMapHeight ) );
|
355 | | -
|
356 | | - return $params;
|
357 | | - }
|
358 | | -
|
359 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding abstract class SMMapPrinter. |
| 6 | + * |
| 7 | + * @file SM_MapPrinter.php |
| 8 | + * @ingroup SemanticMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + * @author Robert Buzink |
| 12 | + * @author Yaron Koren |
| 13 | + */ |
| 14 | + |
| 15 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 16 | + die( 'Not an entry point.' ); |
| 17 | +} |
| 18 | + |
| 19 | +/** |
| 20 | + * Abstract class that provides the common functionallity for all map query printers. |
| 21 | + * |
| 22 | + * @ingroup SemanticMaps |
| 23 | + * |
| 24 | + * @author Jeroen De Dauw |
| 25 | + * @author Robert Buzink |
| 26 | + * @author Yaron Koren |
| 27 | + * |
| 28 | + * TODO: |
| 29 | + * This class is borrowing an awefull lot code from MapsMapFeature, which |
| 30 | + * ideally should be inherited. Since SMWResultPrinter already gets inherited, |
| 31 | + * this is not possible. Finding a better solution to this code redundancy |
| 32 | + * would be nice, cause now changes to MapsMapFeature need to be copied here. |
| 33 | + * |
| 34 | + * The adaptor pattern could be used to prevent this. |
| 35 | + */ |
| 36 | +abstract class SMMapPrinter extends SMWResultPrinter { |
| 37 | + |
| 38 | + /** |
| 39 | + * Sets the map service specific element name |
| 40 | + */ |
| 41 | + protected abstract function setQueryPrinterSettings(); |
| 42 | + |
| 43 | + /** |
| 44 | + * Map service spesific map count and loading of dependencies |
| 45 | + */ |
| 46 | + protected abstract function doMapServiceLoad(); |
| 47 | + |
| 48 | + /** |
| 49 | + * Gets the query result |
| 50 | + */ |
| 51 | + protected abstract function addSpecificMapHTML( Parser $parser ); |
| 52 | + |
| 53 | + public $serviceName; |
| 54 | + |
| 55 | + protected $m_locations = array(); |
| 56 | + |
| 57 | + protected $defaultZoom; |
| 58 | + |
| 59 | + protected $centreLat; |
| 60 | + protected $centreLon; |
| 61 | + |
| 62 | + protected $output = ''; |
| 63 | + protected $errorList; |
| 64 | + |
| 65 | + protected $mapFeature; |
| 66 | + |
| 67 | + protected $featureParameters = array(); |
| 68 | + protected $spesificParameters = array(); |
| 69 | + |
| 70 | + /** |
| 71 | + * Builds up and returns the HTML for the map, with the queried coordinate data on it. |
| 72 | + * |
| 73 | + * @param unknown_type $res |
| 74 | + * @param unknown_type $outputmode |
| 75 | + * |
| 76 | + * @return array |
| 77 | + */ |
| 78 | + public final function getResultText( $res, $outputmode ) { |
| 79 | + $this->setQueryPrinterSettings(); |
| 80 | + |
| 81 | + $this->featureParameters = SMQueryPrinters::$parameters; |
| 82 | + |
| 83 | + if ( self::manageMapProperties( $this->m_params ) ) { |
| 84 | + $this->formatResultData( $res, $outputmode ); |
| 85 | + |
| 86 | + // Only create a map when there is at least one result. |
| 87 | + if ( count( $this->m_locations ) > 0 || $this->forceshow ) { |
| 88 | + $this->doMapServiceLoad(); |
| 89 | + |
| 90 | + $this->setMapName(); |
| 91 | + |
| 92 | + $this->setZoom(); |
| 93 | + |
| 94 | + $this->setCentre(); |
| 95 | + |
| 96 | + global $wgParser; |
| 97 | + $this->addSpecificMapHTML( $wgParser ); |
| 98 | + } |
| 99 | + else { |
| 100 | + // TODO: add warning when level high enough and append to error list? |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + return array( $this->output . $this->errorList, 'noparse' => true, 'isHTML' => true ); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Validates and corrects the provided map properties, and the sets them as class fields. |
| 109 | + * |
| 110 | + * @param array $mapProperties |
| 111 | + * |
| 112 | + * @return boolean Indicates whether the map should be shown or not. |
| 113 | + */ |
| 114 | + protected final function manageMapProperties( array $mapProperties ) { |
| 115 | + global $egMapsServices; |
| 116 | + |
| 117 | + /* |
| 118 | + * Assembliy of the allowed parameters and their information. |
| 119 | + * The main parameters (the ones that are shared by everything) are overidden |
| 120 | + * by the feature parameters (the ones spesific to a feature). The result is then |
| 121 | + * again overidden by the service parameters (the ones spesific to the service), |
| 122 | + * and finally by the spesific parameters (the ones spesific to a service-feature combination). |
| 123 | + */ |
| 124 | + $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), $this->featureParameters ); |
| 125 | + $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] ); |
| 126 | + $parameterInfo = array_merge_recursive( $parameterInfo, $this->spesificParameters ); |
| 127 | + |
| 128 | + $manager = new ValidatorManager(); |
| 129 | + |
| 130 | + $result = $manager->manageParameters( $mapProperties, $parameterInfo ); |
| 131 | + |
| 132 | + $showMap = $result !== false; |
| 133 | + |
| 134 | + if ( $showMap ) $this->setMapProperties( $result, __CLASS__ ); |
| 135 | + |
| 136 | + $this->errorList = $manager->getErrorList(); |
| 137 | + |
| 138 | + return $showMap; |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * Sets the map properties as class fields. |
| 143 | + * |
| 144 | + * @param array $mapProperties |
| 145 | + * @param string $className |
| 146 | + */ |
| 147 | + private function setMapProperties( array $mapProperties, $className ) { |
| 148 | + // var_dump($mapProperties); exit; |
| 149 | + foreach ( $mapProperties as $paramName => $paramValue ) { |
| 150 | + if ( ! property_exists( $className, $paramName ) ) { |
| 151 | + $this-> { $paramName } = $paramValue; |
| 152 | + } |
| 153 | + else { |
| 154 | + throw new Exception( 'Attempt to override a class field during map propertie assignment. Field name: ' . $paramName ); |
| 155 | + } |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | + public final function getResult( $results, $params, $outputmode ) { |
| 160 | + // Skip checks, results with 0 entries are normal |
| 161 | + $this->readParameters( $params, $outputmode ); |
| 162 | + return $this->getResultText( $results, SMW_OUTPUT_HTML ); |
| 163 | + } |
| 164 | + |
| 165 | + private function formatResultData( $res, $outputmode ) { |
| 166 | + while ( ( $row = $res->getNext() ) !== false ) { |
| 167 | + $this->addResultRow( $outputmode, $row ); |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * This function will loop through all properties (fields) of one record (row), |
| 173 | + * and add the location data, title, label and icon to the m_locations array. |
| 174 | + * |
| 175 | + * @param unknown_type $outputmode |
| 176 | + * @param unknown_type $row The record you want to add data from |
| 177 | + */ |
| 178 | + private function addResultRow( $outputmode, $row ) { |
| 179 | + global $wgUser; |
| 180 | + $skin = $wgUser->getSkin(); |
| 181 | + |
| 182 | + $title = ''; |
| 183 | + $titleForTemplate = ''; |
| 184 | + $text = ''; |
| 185 | + $lat = ''; |
| 186 | + $lon = ''; |
| 187 | + |
| 188 | + $coords = array(); |
| 189 | + $label = array(); |
| 190 | + |
| 191 | + // Loop throught all fields of the record |
| 192 | + foreach ( $row as $i => $field ) { |
| 193 | + $pr = $field->getPrintRequest(); |
| 194 | + |
| 195 | + // Loop throught all the parts of the field value |
| 196 | + while ( ( $object = $field->getNextObject() ) !== false ) { |
| 197 | + if ( $object->getTypeID() == '_wpg' && $i == 0 ) { |
| 198 | + if ( $this->showtitle ) $title = $object->getLongText( $outputmode, $skin ); |
| 199 | + if ( $this->template ) $titleForTemplate = $object->getLongText( $outputmode, NULL ); |
| 200 | + } |
| 201 | + |
| 202 | + if ( $object->getTypeID() != '_geo' && $i != 0 ) { |
| 203 | + if ( $this->template ) { |
| 204 | + if ( $object instanceof SMWWikiPageValue ) { |
| 205 | + $label[] = $object->getTitle()->getPrefixedText(); |
| 206 | + } else { |
| 207 | + $label[] = $object->getLongText( $outputmode, $skin ); |
| 208 | + } |
| 209 | + } |
| 210 | + else { |
| 211 | + $text .= $pr->getHTMLText( $skin ) . ': ' . $object->getLongText( $outputmode, $skin ) . '<br />'; |
| 212 | + } |
| 213 | + } |
| 214 | + |
| 215 | + if ( $pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo' ) { |
| 216 | + $coords[] = $object->getDBkeys(); |
| 217 | + } |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + foreach ( $coords as $coord ) { |
| 222 | + if ( count( $coord ) >= 2 ) { |
| 223 | + $lat = $coord[0]; |
| 224 | + $lon = $coord[1]; |
| 225 | + |
| 226 | + if ( $lat != '' && $lon != '' ) { |
| 227 | + $icon = $this->getLocationIcon( $row ); |
| 228 | + |
| 229 | + if ( $this->template ) { |
| 230 | + global $wgParser; |
| 231 | + $segments = array_merge( |
| 232 | + array( $this->template, 'title=' . $titleForTemplate, 'latitude=' . $lat, 'longitude=' . $lon ), |
| 233 | + $label |
| 234 | + ); |
| 235 | + $text = preg_replace( '/\n+/m', '<br />', $wgParser->recursiveTagParse( '{{' . implode( '|', $segments ) . '}}' ) ); |
| 236 | + } |
| 237 | + |
| 238 | + $this->m_locations[] = array( |
| 239 | + Xml::escapeJsString( $lat ), |
| 240 | + Xml::escapeJsString( $lon ), |
| 241 | + Xml::escapeJsString( $title ), |
| 242 | + Xml::escapeJsString( $text ), |
| 243 | + Xml::escapeJsString( $icon ) |
| 244 | + ); |
| 245 | + } |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | + |
| 250 | + /** |
| 251 | + * Get the icon for a row |
| 252 | + * |
| 253 | + * @param unknown_type $row |
| 254 | + * @return unknown |
| 255 | + */ |
| 256 | + private function getLocationIcon( $row ) { |
| 257 | + $icon = ''; |
| 258 | + $legend_labels = array(); |
| 259 | + |
| 260 | + // Look for display_options field, which can be set by Semantic Compound Queries |
| 261 | + // the location of this field changed in SMW 1.5 |
| 262 | + $display_location = method_exists( $row[0], 'getResultSubject' ) ? $display_location = $row[0]->getResultSubject() : $row[0]; |
| 263 | + |
| 264 | + if ( property_exists( $display_location, 'display_options' ) && is_array( $display_location->display_options ) ) { |
| 265 | + $display_options = $display_location->display_options; |
| 266 | + if ( array_key_exists( 'icon', $display_options ) ) { |
| 267 | + $icon = $display_options['icon']; |
| 268 | + |
| 269 | + // This is somewhat of a hack - if a legend label has been set, we're getting it for every point, instead of just once per icon |
| 270 | + if ( array_key_exists( 'legend label', $display_options ) ) { |
| 271 | + |
| 272 | + $legend_label = $display_options['legend label']; |
| 273 | + |
| 274 | + if ( ! array_key_exists( $icon, $legend_labels ) ) { |
| 275 | + $legend_labels[$icon] = $legend_label; |
| 276 | + } |
| 277 | + } |
| 278 | + } |
| 279 | + // Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here |
| 280 | + } elseif ( strlen( $this->icon ) > 0 ) { |
| 281 | + $icon_image_page = new ImagePage( Title::newFromText( $this->icon ) ); |
| 282 | + $icon = $icon_image_page->getDisplayedFile()->getURL(); |
| 283 | + } |
| 284 | + |
| 285 | + return $icon; |
| 286 | + } |
| 287 | + |
| 288 | + /** |
| 289 | + * Sets the zoom level to the provided value, or when not set, to the default. |
| 290 | + * |
| 291 | + */ |
| 292 | + private function setZoom() { |
| 293 | + if ( strlen( $this->zoom ) < 1 ) { |
| 294 | + if ( count( $this->m_locations ) > 1 ) { |
| 295 | + $this->zoom = 'null'; |
| 296 | + } |
| 297 | + else { |
| 298 | + $this->zoom = $this->defaultZoom; |
| 299 | + } |
| 300 | + } |
| 301 | + } |
| 302 | + |
| 303 | + /** |
| 304 | + * Sets the $centre_lat and $centre_lon fields. |
| 305 | + * Note: this needs to be done AFTRE the maker coordinates are set. |
| 306 | + * |
| 307 | + */ |
| 308 | + private function setCentre() { |
| 309 | + // If a centre value is set, use it. |
| 310 | + if ( strlen( $this->centre ) > 0 ) { |
| 311 | + // Geocode and convert if required. |
| 312 | + $centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName ); |
| 313 | + |
| 314 | + $this->centreLat = $centre['lat']; |
| 315 | + $this->centreLon = $centre['lon']; |
| 316 | + } |
| 317 | + elseif ( count( $this->m_locations ) > 1 ) { |
| 318 | + // If centre is not set, and there are multiple points, set the values to null, to be auto determined by the JS of the mapping API. |
| 319 | + $this->centreLat = 'null'; |
| 320 | + $this->centreLon = 'null'; |
| 321 | + } |
| 322 | + elseif ( count( $this->m_locations ) == 1 ) { |
| 323 | + // If centre is not set and there is exactelly one marker, use it's coordinates. |
| 324 | + $this->centreLat = Xml::escapeJsString( $this->m_locations[0][0] ); |
| 325 | + $this->centreLon = Xml::escapeJsString( $this->m_locations[0][1] ); |
| 326 | + } |
| 327 | + else { |
| 328 | + // If centre is not set and there are no results, centre on the default coordinates. |
| 329 | + global $egMapsMapLat, $egMapsMapLon; |
| 330 | + $this->centreLat = $egMapsMapLat; |
| 331 | + $this->centreLon = $egMapsMapLon; |
| 332 | + } |
| 333 | + } |
| 334 | + |
| 335 | + /** |
| 336 | + * Sets the $mapName field, using the $elementNamePrefix and $elementNr. |
| 337 | + * |
| 338 | + */ |
| 339 | + protected function setMapName() { |
| 340 | + $this->mapName = $this->elementNamePrefix . '_' . $this->elementNr; |
| 341 | + } |
| 342 | + |
| 343 | + public final function getName() { |
| 344 | + return wfMsg( 'maps_' . $this->serviceName ); |
| 345 | + } |
| 346 | + |
| 347 | + public function getParameters() { |
| 348 | + global $egMapsMapWidth, $egMapsMapHeight; |
| 349 | + |
| 350 | + $params = parent::exportFormatParameters(); |
| 351 | + |
| 352 | + $params[] = array( 'name' => 'zoom', 'type' => 'int', 'description' => wfMsg( 'semanticmaps_paramdesc_zoom' ) ); |
| 353 | + $params[] = array( 'name' => 'width', 'type' => 'int', 'description' => wfMsgExt( 'semanticmaps_paramdesc_width', 'parsemag', $egMapsMapWidth ) ); |
| 354 | + $params[] = array( 'name' => 'height', 'type' => 'int', 'description' => wfMsgExt( 'semanticmaps_paramdesc_height', 'parsemag', $egMapsMapHeight ) ); |
| 355 | + |
| 356 | + return $params; |
| 357 | + } |
| 358 | + |
| 359 | +} |
Property changes on: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php |
___________________________________________________________________ |
Added: svn:eol-style |
360 | 360 | + native |
Index: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_Mapper.php |
— | — | @@ -1,64 +1,64 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * General map query printer class
|
6 | | - *
|
7 | | - * @file SM_Mapper.php
|
8 | | - * @ingroup SemanticMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -final class SMMapper {
|
18 | | -
|
19 | | - private $queryPrinter;
|
20 | | -
|
21 | | - public function __construct( $format, $inline ) {
|
22 | | - global $egMapsDefaultServices, $egMapsServices;
|
23 | | -
|
24 | | - // TODO: allow service parameter to override the default
|
25 | | - // Note: if this is allowed, then the getParameters should only return the base parameters.
|
26 | | - if ( $format == 'map' ) $format = $egMapsDefaultServices['qp'];
|
27 | | -
|
28 | | - $service = MapsMapper::getValidService( $format, 'qp' );
|
29 | | -
|
30 | | - $this->queryPrinter = new $egMapsServices[$service]['features']['qp']( $format, $inline );
|
31 | | - }
|
32 | | -
|
33 | | - public static function getAliases() {
|
34 | | - return $this->queryPrinter->getAliases();
|
35 | | - }
|
36 | | -
|
37 | | - public static function setAliases() {
|
38 | | - return $this->queryPrinter->setAliases();
|
39 | | - }
|
40 | | -
|
41 | | - public function getName() {
|
42 | | - return wfMsg( 'maps_map' );
|
43 | | - }
|
44 | | -
|
45 | | - public function getQueryMode( $context ) {
|
46 | | - return $this->queryPrinter->getQueryMode( $context );
|
47 | | - }
|
48 | | -
|
49 | | - public function getResult( $results, $params, $outputmode ) {
|
50 | | - return $this->queryPrinter->getResult( $results, $params, $outputmode );
|
51 | | - }
|
52 | | -
|
53 | | - protected function getResultText( $res, $outputmode ) {
|
54 | | - return $this->queryPrinter->getResultText( $res, $outputmode );
|
55 | | - }
|
56 | | -
|
57 | | - public function getParameters() {
|
58 | | - return $this->queryPrinter->getParameters();
|
59 | | - }
|
60 | | -
|
61 | | - public function getMimeType( $res ) {
|
62 | | - return $this->queryPrinter->getMimeType( $res );
|
63 | | - }
|
64 | | -
|
65 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * General map query printer class |
| 6 | + * |
| 7 | + * @file SM_Mapper.php |
| 8 | + * @ingroup SemanticMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +final class SMMapper { |
| 18 | + |
| 19 | + private $queryPrinter; |
| 20 | + |
| 21 | + public function __construct( $format, $inline ) { |
| 22 | + global $egMapsDefaultServices, $egMapsServices; |
| 23 | + |
| 24 | + // TODO: allow service parameter to override the default |
| 25 | + // Note: if this is allowed, then the getParameters should only return the base parameters. |
| 26 | + if ( $format == 'map' ) $format = $egMapsDefaultServices['qp']; |
| 27 | + |
| 28 | + $service = MapsMapper::getValidService( $format, 'qp' ); |
| 29 | + |
| 30 | + $this->queryPrinter = new $egMapsServices[$service]['features']['qp']( $format, $inline ); |
| 31 | + } |
| 32 | + |
| 33 | + public static function getAliases() { |
| 34 | + return $this->queryPrinter->getAliases(); |
| 35 | + } |
| 36 | + |
| 37 | + public static function setAliases() { |
| 38 | + return $this->queryPrinter->setAliases(); |
| 39 | + } |
| 40 | + |
| 41 | + public function getName() { |
| 42 | + return wfMsg( 'maps_map' ); |
| 43 | + } |
| 44 | + |
| 45 | + public function getQueryMode( $context ) { |
| 46 | + return $this->queryPrinter->getQueryMode( $context ); |
| 47 | + } |
| 48 | + |
| 49 | + public function getResult( $results, $params, $outputmode ) { |
| 50 | + return $this->queryPrinter->getResult( $results, $params, $outputmode ); |
| 51 | + } |
| 52 | + |
| 53 | + protected function getResultText( $res, $outputmode ) { |
| 54 | + return $this->queryPrinter->getResultText( $res, $outputmode ); |
| 55 | + } |
| 56 | + |
| 57 | + public function getParameters() { |
| 58 | + return $this->queryPrinter->getParameters(); |
| 59 | + } |
| 60 | + |
| 61 | + public function getMimeType( $res ) { |
| 62 | + return $this->queryPrinter->getMimeType( $res ); |
| 63 | + } |
| 64 | + |
| 65 | +} |
Property changes on: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_Mapper.php |
___________________________________________________________________ |
Added: svn:eol-style |
66 | 66 | + native |
Index: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php |
— | — | @@ -1,255 +1,255 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Abstract class that provides the common functionallity for all map form inputs
|
6 | | - *
|
7 | | - * @file SM_FormInput.php
|
8 | | - * @ingroup SemanticMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -abstract class SMFormInput {
|
18 | | -
|
19 | | - /**
|
20 | | - * Determine if geocoding will be enabled and load the required dependencies.
|
21 | | - */
|
22 | | - protected abstract function manageGeocoding();
|
23 | | -
|
24 | | - /**
|
25 | | - * Ensures all dependencies for the used map are loaded, and increases that map service's count
|
26 | | - */
|
27 | | - protected abstract function addFormDependencies();
|
28 | | -
|
29 | | - protected $marker_lat;
|
30 | | - protected $marker_lon;
|
31 | | -
|
32 | | - protected $earthZoom;
|
33 | | -
|
34 | | - protected $showAddresFunction;
|
35 | | -
|
36 | | - protected $enableGeocoding = false;
|
37 | | -
|
38 | | - private $startingCoords = '';
|
39 | | -
|
40 | | - private $coordinates;
|
41 | | -
|
42 | | - /**
|
43 | | - * Validates and corrects the provided map properties, and the sets them as class fields.
|
44 | | - *
|
45 | | - * @param array $mapProperties
|
46 | | - *
|
47 | | - * @return boolean Indicates whether the map should be shown or not.
|
48 | | - */
|
49 | | - protected final function setMapProperties( array $mapProperties ) {
|
50 | | - global $egMapsServices;
|
51 | | -
|
52 | | - /*
|
53 | | - * Assembliy of the allowed parameters and their information.
|
54 | | - * The main parameters (the ones that are shared by everything) are overidden
|
55 | | - * by the feature parameters (the ones spesific to a feature). The result is then
|
56 | | - * again overidden by the service parameters (the ones spesific to the service),
|
57 | | - * and finally by the spesific parameters (the ones spesific to a service-feature combination).
|
58 | | - *
|
59 | | - * FIXME: this causes some wicket error?
|
60 | | - */
|
61 | | - $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), SMFormInputs::$parameters );
|
62 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] );
|
63 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $this->spesificParameters );
|
64 | | -
|
65 | | - $manager = new ValidatorManager();
|
66 | | -
|
67 | | - $result = $manager->manageParameters( $mapProperties, $parameterInfo );
|
68 | | -
|
69 | | - $showMap = $result !== false;
|
70 | | -
|
71 | | - if ( $showMap ) $this->setMapProperties( $result, __CLASS__ );
|
72 | | -
|
73 | | - $this->errorList = $manager->getErrorList();
|
74 | | -
|
75 | | - return $showMap;
|
76 | | - }
|
77 | | -
|
78 | | - /**
|
79 | | - * This function is a hook for Semantic Forms, and returns the HTML needed in
|
80 | | - * the form to handle coordinate data.
|
81 | | - *
|
82 | | - * @return array
|
83 | | - *
|
84 | | - * TODO: Use function args for sf stuffz
|
85 | | - */
|
86 | | - public final function formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ) {
|
87 | | - global $wgParser, $sfgTabIndex;
|
88 | | -
|
89 | | - $this->coordinates = $coordinates;
|
90 | | -
|
91 | | - $this->setMapSettings();
|
92 | | -
|
93 | | - $this->setMapProperties( $field_args );
|
94 | | -
|
95 | | - $this->doMapServiceLoad();
|
96 | | -
|
97 | | - $this->manageGeocoding();
|
98 | | -
|
99 | | - $this->setCoordinates();
|
100 | | - $this->setCentre();
|
101 | | - $this->setZoom();
|
102 | | -
|
103 | | - // Create html element names.
|
104 | | - $this->setMapName();
|
105 | | - $this->mapName .= '_' . $sfgTabIndex;
|
106 | | - $this->geocodeFieldName = $this->elementNamePrefix . '_geocode_' . $this->elementNr . '_' . $sfgTabIndex;
|
107 | | - $this->coordsFieldName = $this->elementNamePrefix . '_coords_' . $this->elementNr . '_' . $sfgTabIndex;
|
108 | | - $this->infoFieldName = $this->elementNamePrefix . '_info_' . $this->elementNr . '_' . $sfgTabIndex;
|
109 | | -
|
110 | | - // Create the non specific form HTML.
|
111 | | - $this->output .= "
|
112 | | - <input id='" . $this->coordsFieldName . "' name='$input_name' type='text' value='$this->startingCoords' size='40' tabindex='$sfgTabIndex'>
|
113 | | - <span id='" . $this->infoFieldName . "' class='error_message'></span>";
|
114 | | -
|
115 | | - if ( $this->enableGeocoding ) $this->addGeocodingField();
|
116 | | -
|
117 | | - $this->addSpecificMapHTML( $wgParser );
|
118 | | -
|
119 | | - return array( $this->output . $this->errorList, '' );
|
120 | | - }
|
121 | | -
|
122 | | - private function addGeocodingField() {
|
123 | | - global $sfgTabIndex, $wgOut, $smgAddedFormJs;
|
124 | | - $sfgTabIndex++;
|
125 | | -
|
126 | | - if ( !$smgAddedFormJs ) {
|
127 | | - $smgAddedFormJs = true;
|
128 | | -
|
129 | | - $n = Xml::escapeJsString( wfMsgForContent( 'maps-abb-north' ) );
|
130 | | - $e = Xml::escapeJsString( wfMsgForContent( 'maps-abb-east' ) );
|
131 | | - $s = Xml::escapeJsString( wfMsgForContent( 'maps-abb-south' ) );
|
132 | | - $w = Xml::escapeJsString( wfMsgForContent( 'maps-abb-south' ) );
|
133 | | - $deg = Xml::escapeJsString( Maps_GEO_DEG );
|
134 | | -
|
135 | | - $wgOut->addInlineScript(
|
136 | | - <<<EOT
|
137 | | -function convertLatToDMS (val) {
|
138 | | - return Math.abs(val) + "$deg " + ( val < 0 ? "$s" : "$n" );
|
139 | | -}
|
140 | | -function convertLngToDMS (val) {
|
141 | | - return Math.abs(val) + "$deg " + ( val < 0 ? "$w" : "$e" );
|
142 | | -}
|
143 | | -EOT
|
144 | | - );
|
145 | | - }
|
146 | | -
|
147 | | - // Retrieve language values.
|
148 | | - $enter_address_here_text = Xml::escapeJsString( wfMsg( 'semanticmaps_enteraddresshere' ) );
|
149 | | - $lookup_coordinates_text = Xml::escapeJsString( wfMsg( 'semanticmaps_lookupcoordinates' ) );
|
150 | | - $not_found_text = Xml::escapeJsString( wfMsg( 'semanticmaps_notfound' ) );
|
151 | | -
|
152 | | - $adress_field = SMFormInput::getDynamicInput( $this->geocodeFieldName, $enter_address_here_text, 'size="30" name="geocode" style="color: #707070" tabindex="' . $sfgTabIndex . '"' );
|
153 | | - $this->output .= "
|
154 | | - <p>
|
155 | | - $adress_field
|
156 | | - <input type='submit' onClick=\"$this->showAddresFunction(document.forms['createbox'].$this->geocodeFieldName.value, '$this->mapName', '$this->coordsFieldName', '$not_found_text'); return false\" value='$lookup_coordinates_text' />
|
157 | | - </p>";
|
158 | | - }
|
159 | | -
|
160 | | - /**
|
161 | | - * Sets the zoom so the whole map is visible in case there is no maker yet,
|
162 | | - * and sets it to the default when there is a marker but no zoom parameter.
|
163 | | - */
|
164 | | - private function setZoom() {
|
165 | | - if ( empty( $this->coordinates ) ) {
|
166 | | - $this->zoom = $this->earthZoom;
|
167 | | - } else if ( strlen( $this->zoom ) < 1 ) {
|
168 | | - $this->zoom = $this->defaultZoom;
|
169 | | - }
|
170 | | - }
|
171 | | -
|
172 | | - /**
|
173 | | - *
|
174 | | - * @param $decimal
|
175 | | - * @return unknown_type
|
176 | | - */
|
177 | | - private static function latDecimal2Degree( $decimal ) {
|
178 | | - $deg = Maps_GEO_DEG;
|
179 | | - if ( $decimal < 0 ) {
|
180 | | - return abs ( $decimal ) . "$deg S";
|
181 | | - } else {
|
182 | | - return $decimal . "$deg N";
|
183 | | - }
|
184 | | - }
|
185 | | -
|
186 | | - /**
|
187 | | - *
|
188 | | - * @param $decimal
|
189 | | - * @return unknown_type
|
190 | | - */
|
191 | | - private static function lonDecimal2Degree( $decimal ) {
|
192 | | - if ( $decimal < 0 ) {
|
193 | | - return abs ( $decimal ) . "° W";
|
194 | | - } else {
|
195 | | - return $decimal . "° E";
|
196 | | - }
|
197 | | - }
|
198 | | -
|
199 | | - /**
|
200 | | - * Sets the $marler_lon and $marler_lat fields and when set, the starting coordinates
|
201 | | - */
|
202 | | - private function setCoordinates() {
|
203 | | - if ( empty( $this->coordinates ) ) {
|
204 | | - // If no coordinates exist yet, no marker should be displayed
|
205 | | - $this->marker_lat = 'null';
|
206 | | - $this->marker_lon = 'null';
|
207 | | - }
|
208 | | - else {
|
209 | | - $marker = MapsCoordinateParser::parseCoordinates( $this->coordinates );
|
210 | | - $this->marker_lat = $marker['lat'];
|
211 | | - $this->marker_lon = $marker['lon'];
|
212 | | - $this->startingCoords = self::latDecimal2Degree( $this->marker_lat ) . ', ' . self::lonDecimal2Degree( $this->marker_lon );
|
213 | | - }
|
214 | | - }
|
215 | | -
|
216 | | - /**
|
217 | | - * Sets the $centre_lat and $centre_lon fields.
|
218 | | - * Note: this needs to be done AFTRE the maker coordinates are set.
|
219 | | - */
|
220 | | - private function setCentre() {
|
221 | | - if ( empty( $this->centre ) ) {
|
222 | | - if ( isset( $this->coordinates ) ) {
|
223 | | - $this->centreLat = $this->marker_lat;
|
224 | | - $this->centreLon = $this->marker_lon;
|
225 | | - }
|
226 | | - else {
|
227 | | - $this->centreLat = '0';
|
228 | | - $this->centreLon = '0';
|
229 | | - }
|
230 | | - }
|
231 | | - else {
|
232 | | - // Geocode and convert if required.
|
233 | | - $centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName );
|
234 | | -
|
235 | | - $this->centreLat = Xml::escapeJsString( $centre['lat'] );
|
236 | | - $this->centreLon = Xml::escapeJsString( $centre['lon'] );
|
237 | | - }
|
238 | | - }
|
239 | | -
|
240 | | - /**
|
241 | | - * Returns html for an html input field with a default value that will automatically dissapear when
|
242 | | - * the user clicks in it, and reappers when the focus on the field is lost and it's still empty.
|
243 | | - *
|
244 | | - * @author Jeroen De Dauw
|
245 | | - *
|
246 | | - * @param string $id
|
247 | | - * @param string $value
|
248 | | - * @param string $args
|
249 | | - *
|
250 | | - * @return html
|
251 | | - */
|
252 | | - private static function getDynamicInput( $id, $value, $args = '' ) {
|
253 | | - return '<input id="' . $id . '" ' . $args . ' value="' . $value . '" onfocus="if (this.value==\'' . $value . '\') {this.value=\'\';}" onblur="if (this.value==\'\') {this.value=\'' . $value . '\';}" />';
|
254 | | - }
|
255 | | -}
|
256 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Abstract class that provides the common functionallity for all map form inputs |
| 6 | + * |
| 7 | + * @file SM_FormInput.php |
| 8 | + * @ingroup SemanticMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +abstract class SMFormInput { |
| 18 | + |
| 19 | + /** |
| 20 | + * Determine if geocoding will be enabled and load the required dependencies. |
| 21 | + */ |
| 22 | + protected abstract function manageGeocoding(); |
| 23 | + |
| 24 | + /** |
| 25 | + * Ensures all dependencies for the used map are loaded, and increases that map service's count |
| 26 | + */ |
| 27 | + protected abstract function addFormDependencies(); |
| 28 | + |
| 29 | + protected $marker_lat; |
| 30 | + protected $marker_lon; |
| 31 | + |
| 32 | + protected $earthZoom; |
| 33 | + |
| 34 | + protected $showAddresFunction; |
| 35 | + |
| 36 | + protected $enableGeocoding = false; |
| 37 | + |
| 38 | + private $startingCoords = ''; |
| 39 | + |
| 40 | + private $coordinates; |
| 41 | + |
| 42 | + /** |
| 43 | + * Validates and corrects the provided map properties, and the sets them as class fields. |
| 44 | + * |
| 45 | + * @param array $mapProperties |
| 46 | + * |
| 47 | + * @return boolean Indicates whether the map should be shown or not. |
| 48 | + */ |
| 49 | + protected final function setMapProperties( array $mapProperties ) { |
| 50 | + global $egMapsServices; |
| 51 | + |
| 52 | + /* |
| 53 | + * Assembliy of the allowed parameters and their information. |
| 54 | + * The main parameters (the ones that are shared by everything) are overidden |
| 55 | + * by the feature parameters (the ones spesific to a feature). The result is then |
| 56 | + * again overidden by the service parameters (the ones spesific to the service), |
| 57 | + * and finally by the spesific parameters (the ones spesific to a service-feature combination). |
| 58 | + * |
| 59 | + * FIXME: this causes some wicket error? |
| 60 | + */ |
| 61 | + $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), SMFormInputs::$parameters ); |
| 62 | + $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] ); |
| 63 | + $parameterInfo = array_merge_recursive( $parameterInfo, $this->spesificParameters ); |
| 64 | + |
| 65 | + $manager = new ValidatorManager(); |
| 66 | + |
| 67 | + $result = $manager->manageParameters( $mapProperties, $parameterInfo ); |
| 68 | + |
| 69 | + $showMap = $result !== false; |
| 70 | + |
| 71 | + if ( $showMap ) $this->setMapProperties( $result, __CLASS__ ); |
| 72 | + |
| 73 | + $this->errorList = $manager->getErrorList(); |
| 74 | + |
| 75 | + return $showMap; |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * This function is a hook for Semantic Forms, and returns the HTML needed in |
| 80 | + * the form to handle coordinate data. |
| 81 | + * |
| 82 | + * @return array |
| 83 | + * |
| 84 | + * TODO: Use function args for sf stuffz |
| 85 | + */ |
| 86 | + public final function formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ) { |
| 87 | + global $wgParser, $sfgTabIndex; |
| 88 | + |
| 89 | + $this->coordinates = $coordinates; |
| 90 | + |
| 91 | + $this->setMapSettings(); |
| 92 | + |
| 93 | + $this->setMapProperties( $field_args ); |
| 94 | + |
| 95 | + $this->doMapServiceLoad(); |
| 96 | + |
| 97 | + $this->manageGeocoding(); |
| 98 | + |
| 99 | + $this->setCoordinates(); |
| 100 | + $this->setCentre(); |
| 101 | + $this->setZoom(); |
| 102 | + |
| 103 | + // Create html element names. |
| 104 | + $this->setMapName(); |
| 105 | + $this->mapName .= '_' . $sfgTabIndex; |
| 106 | + $this->geocodeFieldName = $this->elementNamePrefix . '_geocode_' . $this->elementNr . '_' . $sfgTabIndex; |
| 107 | + $this->coordsFieldName = $this->elementNamePrefix . '_coords_' . $this->elementNr . '_' . $sfgTabIndex; |
| 108 | + $this->infoFieldName = $this->elementNamePrefix . '_info_' . $this->elementNr . '_' . $sfgTabIndex; |
| 109 | + |
| 110 | + // Create the non specific form HTML. |
| 111 | + $this->output .= " |
| 112 | + <input id='" . $this->coordsFieldName . "' name='$input_name' type='text' value='$this->startingCoords' size='40' tabindex='$sfgTabIndex'> |
| 113 | + <span id='" . $this->infoFieldName . "' class='error_message'></span>"; |
| 114 | + |
| 115 | + if ( $this->enableGeocoding ) $this->addGeocodingField(); |
| 116 | + |
| 117 | + $this->addSpecificMapHTML( $wgParser ); |
| 118 | + |
| 119 | + return array( $this->output . $this->errorList, '' ); |
| 120 | + } |
| 121 | + |
| 122 | + private function addGeocodingField() { |
| 123 | + global $sfgTabIndex, $wgOut, $smgAddedFormJs; |
| 124 | + $sfgTabIndex++; |
| 125 | + |
| 126 | + if ( !$smgAddedFormJs ) { |
| 127 | + $smgAddedFormJs = true; |
| 128 | + |
| 129 | + $n = Xml::escapeJsString( wfMsgForContent( 'maps-abb-north' ) ); |
| 130 | + $e = Xml::escapeJsString( wfMsgForContent( 'maps-abb-east' ) ); |
| 131 | + $s = Xml::escapeJsString( wfMsgForContent( 'maps-abb-south' ) ); |
| 132 | + $w = Xml::escapeJsString( wfMsgForContent( 'maps-abb-south' ) ); |
| 133 | + $deg = Xml::escapeJsString( Maps_GEO_DEG ); |
| 134 | + |
| 135 | + $wgOut->addInlineScript( |
| 136 | + <<<EOT |
| 137 | +function convertLatToDMS (val) { |
| 138 | + return Math.abs(val) + "$deg " + ( val < 0 ? "$s" : "$n" ); |
| 139 | +} |
| 140 | +function convertLngToDMS (val) { |
| 141 | + return Math.abs(val) + "$deg " + ( val < 0 ? "$w" : "$e" ); |
| 142 | +} |
| 143 | +EOT |
| 144 | + ); |
| 145 | + } |
| 146 | + |
| 147 | + // Retrieve language values. |
| 148 | + $enter_address_here_text = Xml::escapeJsString( wfMsg( 'semanticmaps_enteraddresshere' ) ); |
| 149 | + $lookup_coordinates_text = Xml::escapeJsString( wfMsg( 'semanticmaps_lookupcoordinates' ) ); |
| 150 | + $not_found_text = Xml::escapeJsString( wfMsg( 'semanticmaps_notfound' ) ); |
| 151 | + |
| 152 | + $adress_field = SMFormInput::getDynamicInput( $this->geocodeFieldName, $enter_address_here_text, 'size="30" name="geocode" style="color: #707070" tabindex="' . $sfgTabIndex . '"' ); |
| 153 | + $this->output .= " |
| 154 | + <p> |
| 155 | + $adress_field |
| 156 | + <input type='submit' onClick=\"$this->showAddresFunction(document.forms['createbox'].$this->geocodeFieldName.value, '$this->mapName', '$this->coordsFieldName', '$not_found_text'); return false\" value='$lookup_coordinates_text' /> |
| 157 | + </p>"; |
| 158 | + } |
| 159 | + |
| 160 | + /** |
| 161 | + * Sets the zoom so the whole map is visible in case there is no maker yet, |
| 162 | + * and sets it to the default when there is a marker but no zoom parameter. |
| 163 | + */ |
| 164 | + private function setZoom() { |
| 165 | + if ( empty( $this->coordinates ) ) { |
| 166 | + $this->zoom = $this->earthZoom; |
| 167 | + } else if ( strlen( $this->zoom ) < 1 ) { |
| 168 | + $this->zoom = $this->defaultZoom; |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * |
| 174 | + * @param $decimal |
| 175 | + * @return unknown_type |
| 176 | + */ |
| 177 | + private static function latDecimal2Degree( $decimal ) { |
| 178 | + $deg = Maps_GEO_DEG; |
| 179 | + if ( $decimal < 0 ) { |
| 180 | + return abs ( $decimal ) . "$deg S"; |
| 181 | + } else { |
| 182 | + return $decimal . "$deg N"; |
| 183 | + } |
| 184 | + } |
| 185 | + |
| 186 | + /** |
| 187 | + * |
| 188 | + * @param $decimal |
| 189 | + * @return unknown_type |
| 190 | + */ |
| 191 | + private static function lonDecimal2Degree( $decimal ) { |
| 192 | + if ( $decimal < 0 ) { |
| 193 | + return abs ( $decimal ) . "° W"; |
| 194 | + } else { |
| 195 | + return $decimal . "° E"; |
| 196 | + } |
| 197 | + } |
| 198 | + |
| 199 | + /** |
| 200 | + * Sets the $marler_lon and $marler_lat fields and when set, the starting coordinates |
| 201 | + */ |
| 202 | + private function setCoordinates() { |
| 203 | + if ( empty( $this->coordinates ) ) { |
| 204 | + // If no coordinates exist yet, no marker should be displayed |
| 205 | + $this->marker_lat = 'null'; |
| 206 | + $this->marker_lon = 'null'; |
| 207 | + } |
| 208 | + else { |
| 209 | + $marker = MapsCoordinateParser::parseCoordinates( $this->coordinates ); |
| 210 | + $this->marker_lat = $marker['lat']; |
| 211 | + $this->marker_lon = $marker['lon']; |
| 212 | + $this->startingCoords = self::latDecimal2Degree( $this->marker_lat ) . ', ' . self::lonDecimal2Degree( $this->marker_lon ); |
| 213 | + } |
| 214 | + } |
| 215 | + |
| 216 | + /** |
| 217 | + * Sets the $centre_lat and $centre_lon fields. |
| 218 | + * Note: this needs to be done AFTRE the maker coordinates are set. |
| 219 | + */ |
| 220 | + private function setCentre() { |
| 221 | + if ( empty( $this->centre ) ) { |
| 222 | + if ( isset( $this->coordinates ) ) { |
| 223 | + $this->centreLat = $this->marker_lat; |
| 224 | + $this->centreLon = $this->marker_lon; |
| 225 | + } |
| 226 | + else { |
| 227 | + $this->centreLat = '0'; |
| 228 | + $this->centreLon = '0'; |
| 229 | + } |
| 230 | + } |
| 231 | + else { |
| 232 | + // Geocode and convert if required. |
| 233 | + $centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName ); |
| 234 | + |
| 235 | + $this->centreLat = Xml::escapeJsString( $centre['lat'] ); |
| 236 | + $this->centreLon = Xml::escapeJsString( $centre['lon'] ); |
| 237 | + } |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * Returns html for an html input field with a default value that will automatically dissapear when |
| 242 | + * the user clicks in it, and reappers when the focus on the field is lost and it's still empty. |
| 243 | + * |
| 244 | + * @author Jeroen De Dauw |
| 245 | + * |
| 246 | + * @param string $id |
| 247 | + * @param string $value |
| 248 | + * @param string $args |
| 249 | + * |
| 250 | + * @return html |
| 251 | + */ |
| 252 | + private static function getDynamicInput( $id, $value, $args = '' ) { |
| 253 | + return '<input id="' . $id . '" ' . $args . ' value="' . $value . '" onfocus="if (this.value==\'' . $value . '\') {this.value=\'\';}" onblur="if (this.value==\'\') {this.value=\'' . $value . '\';}" />'; |
| 254 | + } |
| 255 | +} |
| 256 | + |
Property changes on: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php |
___________________________________________________________________ |
Added: svn:eol-style |
257 | 257 | + native |
Index: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInputs.php |
— | — | @@ -1,128 +1,128 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Initialization file for form input functionality in the Maps extension
|
6 | | - *
|
7 | | - * @file SM_FormInputs.php
|
8 | | - * @ingroup SemanticMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -$wgAutoloadClasses['SMFormInputs'] = __FILE__;
|
18 | | -
|
19 | | -$wgHooks['MappingFeatureLoad'][] = 'SMFormInputs::initialize';
|
20 | | -
|
21 | | -final class SMFormInputs {
|
22 | | -
|
23 | | - public static $parameters = array();
|
24 | | -
|
25 | | - public static function initialize() {
|
26 | | - global $smgDir, $wgAutoloadClasses, $egMapsServices, $sfgFormPrinter;
|
27 | | -
|
28 | | - // This feature can only be enbled when Semantic Forms is loaded.
|
29 | | - if ( isset( $sfgFormPrinter ) ) {
|
30 | | - $hasFormInputs = false;
|
31 | | -
|
32 | | - $wgAutoloadClasses['SMFormInput'] = dirname( __FILE__ ) . '/SM_FormInput.php';
|
33 | | -
|
34 | | - self::initializeParams();
|
35 | | -
|
36 | | - foreach ( $egMapsServices as $serviceName => $serviceData ) {
|
37 | | - // Check if the service has a form input
|
38 | | - $hasFI = array_key_exists( 'fi', $serviceData['features'] );
|
39 | | -
|
40 | | - // If the service has no FI, skipt it and continue with the next one.
|
41 | | - if ( !$hasFI ) continue;
|
42 | | -
|
43 | | - // At least one form input will be enabled when this point is reached.
|
44 | | - $hasFormInputs = true;
|
45 | | -
|
46 | | - // Add the result form input type for the service name.
|
47 | | - self::initFormHook( $serviceName, $serviceName );
|
48 | | -
|
49 | | - // Loop through the service alliases, and add them as form input types.
|
50 | | - foreach ( $serviceData['aliases'] as $alias ) self::initFormHook( $alias, $serviceName );
|
51 | | - }
|
52 | | -
|
53 | | - // Add the 'map' form input type if there are mapping services that have FI's loaded.
|
54 | | - if ( $hasFormInputs ) self::initFormHook( 'map' );
|
55 | | - }
|
56 | | -
|
57 | | - return true;
|
58 | | - }
|
59 | | -
|
60 | | - private static function initializeParams() {
|
61 | | - global $egMapsAvailableServices, $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
|
62 | | -
|
63 | | - self::$parameters = array(
|
64 | | - 'centre' => array(
|
65 | | - 'aliases' => array( 'center' ),
|
66 | | - ),
|
67 | | - 'geoservice' => array(
|
68 | | - 'criteria' => array(
|
69 | | - 'in_array' => array_keys( $egMapsAvailableGeoServices )
|
70 | | - ),
|
71 | | - 'default' => $egMapsDefaultGeoService
|
72 | | - ),
|
73 | | - 'service_name' => array(),
|
74 | | - 'part_of_multiple' => array(),
|
75 | | - 'possible_values' => array(
|
76 | | - 'type' => array( 'string', 'array' ),
|
77 | | - ),
|
78 | | - 'is_list' => array(),
|
79 | | - 'semantic_property' => array(),
|
80 | | - 'value_labels' => array(),
|
81 | | - );
|
82 | | - }
|
83 | | -
|
84 | | - /**
|
85 | | - * Adds a mapping service's form hook.
|
86 | | - *
|
87 | | - * @param string $inputName The name of the form input.
|
88 | | - * @param strig $mainName
|
89 | | - */
|
90 | | - private static function initFormHook( $inputName, $mainName = '' ) {
|
91 | | - global $wgAutoloadClasses, $sfgFormPrinter, $smgDir;
|
92 | | -
|
93 | | - // Add the form input hook for the service.
|
94 | | - $field_args = array();
|
95 | | - if ( strlen( $mainName ) > 0 ) $field_args['service_name'] = $mainName;
|
96 | | - $sfgFormPrinter->setInputTypeHook( $inputName, 'smfSelectFormInputHTML', $field_args );
|
97 | | - }
|
98 | | -
|
99 | | -}
|
100 | | -
|
101 | | -/**
|
102 | | - * Calls the relevant form input class depending on the provided service.
|
103 | | - *
|
104 | | - * @param string $coordinates
|
105 | | - * @param string $input_name
|
106 | | - * @param boolean $is_mandatory
|
107 | | - * @param boolean $is_disabled
|
108 | | - * @param array $field_args
|
109 | | - *
|
110 | | - * @return array
|
111 | | - */
|
112 | | -function smfSelectFormInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args ) {
|
113 | | - global $egMapsServices;
|
114 | | -
|
115 | | - // Get the service name from the field_args, and set it to null if it doesn't exist.
|
116 | | - if ( array_key_exists( 'service_name', $field_args ) ) {
|
117 | | - $service_name = $field_args['service_name'];
|
118 | | - }
|
119 | | - else {
|
120 | | - $service_name = null;
|
121 | | - }
|
122 | | -
|
123 | | - // Ensure the service is valid and create a new instance of the handling form input class.
|
124 | | - $service_name = MapsMapper::getValidService( $service_name, 'fi' );
|
125 | | - $formInput = new $egMapsServices[$service_name]['features']['fi']();
|
126 | | -
|
127 | | - // Get and return the form input HTML from the hook corresponding with the provided service.
|
128 | | - return $formInput->formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args );
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Initialization file for form input functionality in the Maps extension |
| 6 | + * |
| 7 | + * @file SM_FormInputs.php |
| 8 | + * @ingroup SemanticMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +$wgAutoloadClasses['SMFormInputs'] = __FILE__; |
| 18 | + |
| 19 | +$wgHooks['MappingFeatureLoad'][] = 'SMFormInputs::initialize'; |
| 20 | + |
| 21 | +final class SMFormInputs { |
| 22 | + |
| 23 | + public static $parameters = array(); |
| 24 | + |
| 25 | + public static function initialize() { |
| 26 | + global $smgDir, $wgAutoloadClasses, $egMapsServices, $sfgFormPrinter; |
| 27 | + |
| 28 | + // This feature can only be enbled when Semantic Forms is loaded. |
| 29 | + if ( isset( $sfgFormPrinter ) ) { |
| 30 | + $hasFormInputs = false; |
| 31 | + |
| 32 | + $wgAutoloadClasses['SMFormInput'] = dirname( __FILE__ ) . '/SM_FormInput.php'; |
| 33 | + |
| 34 | + self::initializeParams(); |
| 35 | + |
| 36 | + foreach ( $egMapsServices as $serviceName => $serviceData ) { |
| 37 | + // Check if the service has a form input |
| 38 | + $hasFI = array_key_exists( 'fi', $serviceData['features'] ); |
| 39 | + |
| 40 | + // If the service has no FI, skipt it and continue with the next one. |
| 41 | + if ( !$hasFI ) continue; |
| 42 | + |
| 43 | + // At least one form input will be enabled when this point is reached. |
| 44 | + $hasFormInputs = true; |
| 45 | + |
| 46 | + // Add the result form input type for the service name. |
| 47 | + self::initFormHook( $serviceName, $serviceName ); |
| 48 | + |
| 49 | + // Loop through the service alliases, and add them as form input types. |
| 50 | + foreach ( $serviceData['aliases'] as $alias ) self::initFormHook( $alias, $serviceName ); |
| 51 | + } |
| 52 | + |
| 53 | + // Add the 'map' form input type if there are mapping services that have FI's loaded. |
| 54 | + if ( $hasFormInputs ) self::initFormHook( 'map' ); |
| 55 | + } |
| 56 | + |
| 57 | + return true; |
| 58 | + } |
| 59 | + |
| 60 | + private static function initializeParams() { |
| 61 | + global $egMapsAvailableServices, $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService; |
| 62 | + |
| 63 | + self::$parameters = array( |
| 64 | + 'centre' => array( |
| 65 | + 'aliases' => array( 'center' ), |
| 66 | + ), |
| 67 | + 'geoservice' => array( |
| 68 | + 'criteria' => array( |
| 69 | + 'in_array' => array_keys( $egMapsAvailableGeoServices ) |
| 70 | + ), |
| 71 | + 'default' => $egMapsDefaultGeoService |
| 72 | + ), |
| 73 | + 'service_name' => array(), |
| 74 | + 'part_of_multiple' => array(), |
| 75 | + 'possible_values' => array( |
| 76 | + 'type' => array( 'string', 'array' ), |
| 77 | + ), |
| 78 | + 'is_list' => array(), |
| 79 | + 'semantic_property' => array(), |
| 80 | + 'value_labels' => array(), |
| 81 | + ); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Adds a mapping service's form hook. |
| 86 | + * |
| 87 | + * @param string $inputName The name of the form input. |
| 88 | + * @param strig $mainName |
| 89 | + */ |
| 90 | + private static function initFormHook( $inputName, $mainName = '' ) { |
| 91 | + global $wgAutoloadClasses, $sfgFormPrinter, $smgDir; |
| 92 | + |
| 93 | + // Add the form input hook for the service. |
| 94 | + $field_args = array(); |
| 95 | + if ( strlen( $mainName ) > 0 ) $field_args['service_name'] = $mainName; |
| 96 | + $sfgFormPrinter->setInputTypeHook( $inputName, 'smfSelectFormInputHTML', $field_args ); |
| 97 | + } |
| 98 | + |
| 99 | +} |
| 100 | + |
| 101 | +/** |
| 102 | + * Calls the relevant form input class depending on the provided service. |
| 103 | + * |
| 104 | + * @param string $coordinates |
| 105 | + * @param string $input_name |
| 106 | + * @param boolean $is_mandatory |
| 107 | + * @param boolean $is_disabled |
| 108 | + * @param array $field_args |
| 109 | + * |
| 110 | + * @return array |
| 111 | + */ |
| 112 | +function smfSelectFormInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args ) { |
| 113 | + global $egMapsServices; |
| 114 | + |
| 115 | + // Get the service name from the field_args, and set it to null if it doesn't exist. |
| 116 | + if ( array_key_exists( 'service_name', $field_args ) ) { |
| 117 | + $service_name = $field_args['service_name']; |
| 118 | + } |
| 119 | + else { |
| 120 | + $service_name = null; |
| 121 | + } |
| 122 | + |
| 123 | + // Ensure the service is valid and create a new instance of the handling form input class. |
| 124 | + $service_name = MapsMapper::getValidService( $service_name, 'fi' ); |
| 125 | + $formInput = new $egMapsServices[$service_name]['features']['fi'](); |
| 126 | + |
| 127 | + // Get and return the form input HTML from the hook corresponding with the provided service. |
| 128 | + return $formInput->formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ); |
129 | 129 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInputs.php |
___________________________________________________________________ |
Added: svn:eol-style |
130 | 130 | + native |
Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFunctions.js |
— | — | @@ -1,54 +1,54 @@ |
2 | | - /**
|
3 | | - * Javascript functions for Yahoo! Maps functionallity in Semantic Maps
|
4 | | - *
|
5 | | - * @file SM_YahooMapsFunctions.js
|
6 | | - * @ingroup SMYahooMaps
|
7 | | - *
|
8 | | - * @author Jeroen De Dauw
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This function holds spesific functionallity for the Yahoo! Maps form input of Semantic Maps
|
13 | | - * TODO: Refactor as much code as possible to non specific functions
|
14 | | - */
|
15 | | -function makeFormInputYahooMap(mapName, locationFieldName, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon) {
|
16 | | - var map = createYahooMap(document.getElementById(mapName), new YGeoPoint(lat, lon), zoom, type, types, controls, scrollWheelZoom, [getYMarkerData(marker_lat, marker_lon, '', '', '')]);
|
17 | | -
|
18 | | - // Show a starting marker only if marker coordinates are provided
|
19 | | - if (marker_lat != null && marker_lon != null) {
|
20 | | - map.addOverlay(createYMarker(new YGeoPoint(marker_lat, marker_lon)));
|
21 | | - }
|
22 | | -
|
23 | | - // Click event handler for updating the location of the marker
|
24 | | - YEvent.Capture(map, EventsList.MouseClick,
|
25 | | - function(_e, point) {
|
26 | | - var loc = new YGeoPoint(point.Lat, point.Lon)
|
27 | | - map.removeMarkersAll();
|
28 | | - document.getElementById(locationFieldName).value = convertLatToDMS(point.Lat)+', '+convertLngToDMS(point.Lon);
|
29 | | - map.addMarker(loc);
|
30 | | - map.panToLatLon(loc);
|
31 | | - }
|
32 | | - );
|
33 | | -
|
34 | | - // Make the map variable available for other functions
|
35 | | - if (!window.YMaps) window.YMaps = new Object;
|
36 | | - eval("window.YMaps." + mapName + " = map;");
|
37 | | -}
|
38 | | -
|
39 | | -/**
|
40 | | - * This function holds spesific functionallity for the Yahoo! Maps form input of Semantic Maps
|
41 | | - * TODO: Refactor as much code as possible to non specific functions
|
42 | | - */
|
43 | | -function showYAddress(address, mapName, outputElementName, notFoundFormat) {
|
44 | | - var map = YMaps[mapName];
|
45 | | -
|
46 | | - map.removeMarkersAll();
|
47 | | - map.drawZoomAndCenter(address);
|
48 | | -
|
49 | | - YEvent.Capture(map, EventsList.onEndGeoCode,
|
50 | | - function(resultObj) {
|
51 | | - map.addOverlay(new YMarker(resultObj.GeoPoint));
|
52 | | - document.getElementById(outputElementName).value = convertLatToDMS(resultObj.GeoPoint.Lat) + ', ' + convertLngToDMS(resultObj.GeoPoint.Lon);
|
53 | | - }
|
54 | | - );
|
| 2 | + /** |
| 3 | + * Javascript functions for Yahoo! Maps functionallity in Semantic Maps |
| 4 | + * |
| 5 | + * @file SM_YahooMapsFunctions.js |
| 6 | + * @ingroup SMYahooMaps |
| 7 | + * |
| 8 | + * @author Jeroen De Dauw |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This function holds spesific functionallity for the Yahoo! Maps form input of Semantic Maps |
| 13 | + * TODO: Refactor as much code as possible to non specific functions |
| 14 | + */ |
| 15 | +function makeFormInputYahooMap(mapName, locationFieldName, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon) { |
| 16 | + var map = createYahooMap(document.getElementById(mapName), new YGeoPoint(lat, lon), zoom, type, types, controls, scrollWheelZoom, [getYMarkerData(marker_lat, marker_lon, '', '', '')]); |
| 17 | + |
| 18 | + // Show a starting marker only if marker coordinates are provided |
| 19 | + if (marker_lat != null && marker_lon != null) { |
| 20 | + map.addOverlay(createYMarker(new YGeoPoint(marker_lat, marker_lon))); |
| 21 | + } |
| 22 | + |
| 23 | + // Click event handler for updating the location of the marker |
| 24 | + YEvent.Capture(map, EventsList.MouseClick, |
| 25 | + function(_e, point) { |
| 26 | + var loc = new YGeoPoint(point.Lat, point.Lon) |
| 27 | + map.removeMarkersAll(); |
| 28 | + document.getElementById(locationFieldName).value = convertLatToDMS(point.Lat)+', '+convertLngToDMS(point.Lon); |
| 29 | + map.addMarker(loc); |
| 30 | + map.panToLatLon(loc); |
| 31 | + } |
| 32 | + ); |
| 33 | + |
| 34 | + // Make the map variable available for other functions |
| 35 | + if (!window.YMaps) window.YMaps = new Object; |
| 36 | + eval("window.YMaps." + mapName + " = map;"); |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * This function holds spesific functionallity for the Yahoo! Maps form input of Semantic Maps |
| 41 | + * TODO: Refactor as much code as possible to non specific functions |
| 42 | + */ |
| 43 | +function showYAddress(address, mapName, outputElementName, notFoundFormat) { |
| 44 | + var map = YMaps[mapName]; |
| 45 | + |
| 46 | + map.removeMarkersAll(); |
| 47 | + map.drawZoomAndCenter(address); |
| 48 | + |
| 49 | + YEvent.Capture(map, EventsList.onEndGeoCode, |
| 50 | + function(resultObj) { |
| 51 | + map.addOverlay(new YMarker(resultObj.GeoPoint)); |
| 52 | + document.getElementById(outputElementName).value = convertLatToDMS(resultObj.GeoPoint.Lat) + ', ' + convertLngToDMS(resultObj.GeoPoint.Lon); |
| 53 | + } |
| 54 | + ); |
55 | 55 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
56 | 56 | + native |
Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMaps.php |
— | — | @@ -1,27 +1,27 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all Yahoo! Maps related files of the Semantic Maps extension.
|
6 | | - *
|
7 | | - * @defgroup SMYahooMaps Yahoo! Maps
|
8 | | - * @ingroup SemanticMaps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the Yahoo! Maps service.
|
13 | | - *
|
14 | | - * @file SM_YahooMaps.php
|
15 | | - * @ingroup SMYahooMaps
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['SMYahooMapsQP'] = dirname( __FILE__ ) . '/SM_YahooMapsQP.php';
|
25 | | -$wgAutoloadClasses['SMYahooMapsFormInput'] = dirname( __FILE__ ) . '/SM_YahooMapsFormInput.php';
|
26 | | -
|
27 | | -$egMapsServices['yahoomaps']['features']['qp'] = 'SMYahooMapsQP';
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all Yahoo! Maps related files of the Semantic Maps extension. |
| 6 | + * |
| 7 | + * @defgroup SMYahooMaps Yahoo! Maps |
| 8 | + * @ingroup SemanticMaps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the Yahoo! Maps service. |
| 13 | + * |
| 14 | + * @file SM_YahooMaps.php |
| 15 | + * @ingroup SMYahooMaps |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['SMYahooMapsQP'] = dirname( __FILE__ ) . '/SM_YahooMapsQP.php'; |
| 25 | +$wgAutoloadClasses['SMYahooMapsFormInput'] = dirname( __FILE__ ) . '/SM_YahooMapsFormInput.php'; |
| 26 | + |
| 27 | +$egMapsServices['yahoomaps']['features']['qp'] = 'SMYahooMapsQP'; |
28 | 28 | $egMapsServices['yahoomaps']['features']['fi'] = 'SMYahooMapsFormInput'; |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMaps.php |
___________________________________________________________________ |
Added: svn:eol-style |
29 | 29 | + native |
Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsQP.php |
— | — | @@ -1,107 +1,107 @@ |
2 | | -<?php
|
3 | | -/**
|
4 | | - * A query printer for maps using the Yahoo Maps API
|
5 | | - *
|
6 | | - * @file SM_YahooMaps.php
|
7 | | - * @ingroup SMYahooMaps
|
8 | | - *
|
9 | | - * @author Jeroen De Dauw
|
10 | | - */
|
11 | | -
|
12 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
13 | | - die( 'Not an entry point.' );
|
14 | | -}
|
15 | | -
|
16 | | -final class SMYahooMapsQP extends SMMapPrinter {
|
17 | | -
|
18 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME;
|
19 | | -
|
20 | | - /**
|
21 | | - * @see SMMapPrinter::setQueryPrinterSettings()
|
22 | | - *
|
23 | | - */
|
24 | | - protected function setQueryPrinterSettings() {
|
25 | | - global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
|
26 | | -
|
27 | | - $this->elementNamePrefix = $egMapsYahooMapsPrefix;
|
28 | | -
|
29 | | - $this->defaultZoom = $egMapsYahooMapsZoom;
|
30 | | - }
|
31 | | -
|
32 | | - /**
|
33 | | - * @see SMMapPrinter::doMapServiceLoad()
|
34 | | - *
|
35 | | - */
|
36 | | - protected function doMapServiceLoad() {
|
37 | | - global $egYahooMapsOnThisPage;
|
38 | | -
|
39 | | - MapsYahooMaps::addYMapDependencies( $this->output );
|
40 | | - $egYahooMapsOnThisPage++;
|
41 | | -
|
42 | | - $this->elementNr = $egYahooMapsOnThisPage;
|
43 | | - }
|
44 | | -
|
45 | | - /**
|
46 | | - * @see SMMapPrinter::addSpecificMapHTML()
|
47 | | - *
|
48 | | - */
|
49 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
50 | | - // TODO: refactor up like done in maps with display point
|
51 | | - $markerItems = array();
|
52 | | -
|
53 | | - foreach ( $this->m_locations as $location ) {
|
54 | | - // Create a string containing the marker JS.
|
55 | | - list( $lat, $lon, $title, $label, $icon ) = $location;
|
56 | | -
|
57 | | - $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')";
|
58 | | - }
|
59 | | -
|
60 | | - $markersString = implode( ',', $markerItems );
|
61 | | -
|
62 | | - $this->output .= Html::element(
|
63 | | - 'div',
|
64 | | - array(
|
65 | | - 'id' => $this->mapName,
|
66 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
67 | | - ),
|
68 | | - wfMsg('maps-loading-map')
|
69 | | - );
|
70 | | -
|
71 | | - $parser->getOutput()->addHeadItem(
|
72 | | - Html::inlineScript( <<<EOT
|
73 | | -addOnloadHook(
|
74 | | - function() {
|
75 | | - initializeYahooMap(
|
76 | | - '$this->mapName',
|
77 | | - $this->centreLat,
|
78 | | - $this->centreLon,
|
79 | | - $this->zoom,
|
80 | | - $this->type,
|
81 | | - [$this->types],
|
82 | | - [$this->controls],
|
83 | | - $this->autozoom,
|
84 | | - [$markersString]
|
85 | | - );
|
86 | | - }
|
87 | | -);
|
88 | | -EOT
|
89 | | - ) );
|
90 | | - }
|
91 | | -
|
92 | | - /**
|
93 | | - * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list.
|
94 | | - */
|
95 | | - public function getParameters() {
|
96 | | - $params = parent::getParameters();
|
97 | | -
|
98 | | - $allowedTypes = MapsYahooMaps::getTypeNames();
|
99 | | -
|
100 | | - $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsYahooMaps::getControlNames() );
|
101 | | - $params[] = array( 'name' => 'types', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_types' ), 'values' => $allowedTypes );
|
102 | | - $params[] = array( 'name' => 'type', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_type' ), 'values' => $allowedTypes );
|
103 | | - $params[] = array( 'name' => 'autozoom', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_autozoom' ), 'values' => array( 'on', 'off' ) );
|
104 | | -
|
105 | | - return $params;
|
106 | | - }
|
107 | | -
|
| 2 | +<?php |
| 3 | +/** |
| 4 | + * A query printer for maps using the Yahoo Maps API |
| 5 | + * |
| 6 | + * @file SM_YahooMaps.php |
| 7 | + * @ingroup SMYahooMaps |
| 8 | + * |
| 9 | + * @author Jeroen De Dauw |
| 10 | + */ |
| 11 | + |
| 12 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 13 | + die( 'Not an entry point.' ); |
| 14 | +} |
| 15 | + |
| 16 | +final class SMYahooMapsQP extends SMMapPrinter { |
| 17 | + |
| 18 | + public $serviceName = MapsYahooMaps::SERVICE_NAME; |
| 19 | + |
| 20 | + /** |
| 21 | + * @see SMMapPrinter::setQueryPrinterSettings() |
| 22 | + * |
| 23 | + */ |
| 24 | + protected function setQueryPrinterSettings() { |
| 25 | + global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix; |
| 26 | + |
| 27 | + $this->elementNamePrefix = $egMapsYahooMapsPrefix; |
| 28 | + |
| 29 | + $this->defaultZoom = $egMapsYahooMapsZoom; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @see SMMapPrinter::doMapServiceLoad() |
| 34 | + * |
| 35 | + */ |
| 36 | + protected function doMapServiceLoad() { |
| 37 | + global $egYahooMapsOnThisPage; |
| 38 | + |
| 39 | + MapsYahooMaps::addYMapDependencies( $this->output ); |
| 40 | + $egYahooMapsOnThisPage++; |
| 41 | + |
| 42 | + $this->elementNr = $egYahooMapsOnThisPage; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @see SMMapPrinter::addSpecificMapHTML() |
| 47 | + * |
| 48 | + */ |
| 49 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 50 | + // TODO: refactor up like done in maps with display point |
| 51 | + $markerItems = array(); |
| 52 | + |
| 53 | + foreach ( $this->m_locations as $location ) { |
| 54 | + // Create a string containing the marker JS. |
| 55 | + list( $lat, $lon, $title, $label, $icon ) = $location; |
| 56 | + |
| 57 | + $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')"; |
| 58 | + } |
| 59 | + |
| 60 | + $markersString = implode( ',', $markerItems ); |
| 61 | + |
| 62 | + $this->output .= Html::element( |
| 63 | + 'div', |
| 64 | + array( |
| 65 | + 'id' => $this->mapName, |
| 66 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 67 | + ), |
| 68 | + wfMsg('maps-loading-map') |
| 69 | + ); |
| 70 | + |
| 71 | + $parser->getOutput()->addHeadItem( |
| 72 | + Html::inlineScript( <<<EOT |
| 73 | +addOnloadHook( |
| 74 | + function() { |
| 75 | + initializeYahooMap( |
| 76 | + '$this->mapName', |
| 77 | + $this->centreLat, |
| 78 | + $this->centreLon, |
| 79 | + $this->zoom, |
| 80 | + $this->type, |
| 81 | + [$this->types], |
| 82 | + [$this->controls], |
| 83 | + $this->autozoom, |
| 84 | + [$markersString] |
| 85 | + ); |
| 86 | + } |
| 87 | +); |
| 88 | +EOT |
| 89 | + ) ); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list. |
| 94 | + */ |
| 95 | + public function getParameters() { |
| 96 | + $params = parent::getParameters(); |
| 97 | + |
| 98 | + $allowedTypes = MapsYahooMaps::getTypeNames(); |
| 99 | + |
| 100 | + $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsYahooMaps::getControlNames() ); |
| 101 | + $params[] = array( 'name' => 'types', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_types' ), 'values' => $allowedTypes ); |
| 102 | + $params[] = array( 'name' => 'type', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_type' ), 'values' => $allowedTypes ); |
| 103 | + $params[] = array( 'name' => 'autozoom', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_autozoom' ), 'values' => array( 'on', 'off' ) ); |
| 104 | + |
| 105 | + return $params; |
| 106 | + } |
| 107 | + |
108 | 108 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsQP.php |
___________________________________________________________________ |
Added: svn:eol-style |
109 | 109 | + native |
Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -1,118 +1,118 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | -* Form input hook that adds an Yahoo! Maps map format to Semantic Forms
|
6 | | - *
|
7 | | - * @file SM_YahooMapsFormInput.php
|
8 | | - * @ingroup SMYahooMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -final class SMYahooMapsFormInput extends SMFormInput {
|
18 | | -
|
19 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME;
|
20 | | -
|
21 | | - protected $spesificParameters = array();
|
22 | | -
|
23 | | - /**
|
24 | | - * @see MapsMapFeature::setMapSettings()
|
25 | | - *
|
26 | | - */
|
27 | | - protected function setMapSettings() {
|
28 | | - global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
|
29 | | -
|
30 | | - $this->elementNamePrefix = $egMapsYahooMapsPrefix;
|
31 | | - $this->showAddresFunction = 'showYAddress';
|
32 | | -
|
33 | | - $this->earthZoom = 17;
|
34 | | -
|
35 | | - $this->defaultZoom = $egMapsYahooMapsZoom;
|
36 | | - }
|
37 | | -
|
38 | | - /**
|
39 | | - * @see MapsMapFeature::addFormDependencies()
|
40 | | - *
|
41 | | - */
|
42 | | - protected function addFormDependencies() {
|
43 | | - global $wgJsMimeType;
|
44 | | - global $smgScriptPath, $smgYahooFormsOnThisPage, $smgStyleVersion, $egMapsJsExt;
|
45 | | -
|
46 | | - MapsYahooMaps::addYMapDependencies( $this->output );
|
47 | | -
|
48 | | - if ( empty( $smgYahooFormsOnThisPage ) ) {
|
49 | | - $smgYahooFormsOnThisPage = 0;
|
50 | | - $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/YahooMaps/SM_YahooMapsFunctions{$egMapsJsExt}?$smgStyleVersion'></script>";
|
51 | | - }
|
52 | | - }
|
53 | | -
|
54 | | - /**
|
55 | | - * @see MapsMapFeature::doMapServiceLoad()
|
56 | | - *
|
57 | | - */
|
58 | | - protected function doMapServiceLoad() {
|
59 | | - global $egYahooMapsOnThisPage, $smgYahooFormsOnThisPage;
|
60 | | -
|
61 | | - self::addFormDependencies();
|
62 | | -
|
63 | | - $egYahooMapsOnThisPage++;
|
64 | | - $smgYahooFormsOnThisPage++;
|
65 | | -
|
66 | | - $this->elementNr = $egYahooMapsOnThisPage;
|
67 | | - }
|
68 | | -
|
69 | | - /**
|
70 | | - * @see MapsMapFeature::addSpecificMapHTML()
|
71 | | - *
|
72 | | - */
|
73 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
74 | | - global $wgOut;
|
75 | | -
|
76 | | - $this->output .= Html::element(
|
77 | | - 'div',
|
78 | | - array(
|
79 | | - 'id' => $this->mapName,
|
80 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
81 | | - ),
|
82 | | - wfMsg('maps-loading-map')
|
83 | | - );
|
84 | | -
|
85 | | - $wgOut->addInlineScript( <<<EOT
|
86 | | -addOnloadHook(
|
87 | | - function() {
|
88 | | - makeFormInputYahooMap(
|
89 | | - '$this->mapName',
|
90 | | - '$this->coordsFieldName',
|
91 | | - $this->centreLat,
|
92 | | - $this->centreLon,
|
93 | | - $this->zoom,
|
94 | | - $this->type,
|
95 | | - [$this->types],
|
96 | | - [$this->controls],
|
97 | | - $this->autozoom,
|
98 | | - $this->marker_lat,
|
99 | | - $this->marker_lon
|
100 | | - );
|
101 | | - }
|
102 | | -);
|
103 | | -EOT
|
104 | | - );
|
105 | | -
|
106 | | - }
|
107 | | -
|
108 | | - /**
|
109 | | - * @see SMFormInput::manageGeocoding()
|
110 | | - *
|
111 | | - */
|
112 | | - protected function manageGeocoding() {
|
113 | | - global $egYahooMapsKey;
|
114 | | - $this->enableGeocoding = strlen( trim( $egYahooMapsKey ) ) > 0;
|
115 | | - if ( $this->enableGeocoding ) MapsYahooMaps::addYMapDependencies( $this->output );
|
116 | | - }
|
117 | | -
|
118 | | -
|
119 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | +* Form input hook that adds an Yahoo! Maps map format to Semantic Forms |
| 6 | + * |
| 7 | + * @file SM_YahooMapsFormInput.php |
| 8 | + * @ingroup SMYahooMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +final class SMYahooMapsFormInput extends SMFormInput { |
| 18 | + |
| 19 | + public $serviceName = MapsYahooMaps::SERVICE_NAME; |
| 20 | + |
| 21 | + protected $spesificParameters = array(); |
| 22 | + |
| 23 | + /** |
| 24 | + * @see MapsMapFeature::setMapSettings() |
| 25 | + * |
| 26 | + */ |
| 27 | + protected function setMapSettings() { |
| 28 | + global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix; |
| 29 | + |
| 30 | + $this->elementNamePrefix = $egMapsYahooMapsPrefix; |
| 31 | + $this->showAddresFunction = 'showYAddress'; |
| 32 | + |
| 33 | + $this->earthZoom = 17; |
| 34 | + |
| 35 | + $this->defaultZoom = $egMapsYahooMapsZoom; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @see MapsMapFeature::addFormDependencies() |
| 40 | + * |
| 41 | + */ |
| 42 | + protected function addFormDependencies() { |
| 43 | + global $wgJsMimeType; |
| 44 | + global $smgScriptPath, $smgYahooFormsOnThisPage, $smgStyleVersion, $egMapsJsExt; |
| 45 | + |
| 46 | + MapsYahooMaps::addYMapDependencies( $this->output ); |
| 47 | + |
| 48 | + if ( empty( $smgYahooFormsOnThisPage ) ) { |
| 49 | + $smgYahooFormsOnThisPage = 0; |
| 50 | + $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/YahooMaps/SM_YahooMapsFunctions{$egMapsJsExt}?$smgStyleVersion'></script>"; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * @see MapsMapFeature::doMapServiceLoad() |
| 56 | + * |
| 57 | + */ |
| 58 | + protected function doMapServiceLoad() { |
| 59 | + global $egYahooMapsOnThisPage, $smgYahooFormsOnThisPage; |
| 60 | + |
| 61 | + self::addFormDependencies(); |
| 62 | + |
| 63 | + $egYahooMapsOnThisPage++; |
| 64 | + $smgYahooFormsOnThisPage++; |
| 65 | + |
| 66 | + $this->elementNr = $egYahooMapsOnThisPage; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @see MapsMapFeature::addSpecificMapHTML() |
| 71 | + * |
| 72 | + */ |
| 73 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 74 | + global $wgOut; |
| 75 | + |
| 76 | + $this->output .= Html::element( |
| 77 | + 'div', |
| 78 | + array( |
| 79 | + 'id' => $this->mapName, |
| 80 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 81 | + ), |
| 82 | + wfMsg('maps-loading-map') |
| 83 | + ); |
| 84 | + |
| 85 | + $wgOut->addInlineScript( <<<EOT |
| 86 | +addOnloadHook( |
| 87 | + function() { |
| 88 | + makeFormInputYahooMap( |
| 89 | + '$this->mapName', |
| 90 | + '$this->coordsFieldName', |
| 91 | + $this->centreLat, |
| 92 | + $this->centreLon, |
| 93 | + $this->zoom, |
| 94 | + $this->type, |
| 95 | + [$this->types], |
| 96 | + [$this->controls], |
| 97 | + $this->autozoom, |
| 98 | + $this->marker_lat, |
| 99 | + $this->marker_lon |
| 100 | + ); |
| 101 | + } |
| 102 | +); |
| 103 | +EOT |
| 104 | + ); |
| 105 | + |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * @see SMFormInput::manageGeocoding() |
| 110 | + * |
| 111 | + */ |
| 112 | + protected function manageGeocoding() { |
| 113 | + global $egYahooMapsKey; |
| 114 | + $this->enableGeocoding = strlen( trim( $egYahooMapsKey ) ) > 0; |
| 115 | + if ( $this->enableGeocoding ) MapsYahooMaps::addYMapDependencies( $this->output ); |
| 116 | + } |
| 117 | + |
| 118 | + |
| 119 | +} |
Property changes on: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php |
___________________________________________________________________ |
Added: svn:eol-style |
120 | 120 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFunctions.js |
— | — | @@ -1,98 +1,98 @@ |
2 | | - /**
|
3 | | - * Javascript functions for OpenLayers functionallity in Semantic Maps
|
4 | | - *
|
5 | | - * @file SM_OpenLayersFunctions.js
|
6 | | - * @ingroup SMOpenLayers
|
7 | | - *
|
8 | | - * @author Jeroen De Dauw
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This function holds spesific functionallity for the Open Layers form input of Semantic Maps
|
13 | | - */
|
14 | | -function makeFormInputOpenLayer(mapName, locationFieldName, lat, lon, zoom, marker_lat, marker_lon, layers, controls, height) {
|
15 | | - var markers = Array();
|
16 | | -
|
17 | | - // Show a starting marker only if marker coordinates are provided
|
18 | | - if (marker_lat != null && marker_lon != null) {
|
19 | | - markers.push(getOLMarkerData(marker_lon, marker_lat, '', '', ''));
|
20 | | - }
|
21 | | -
|
22 | | - // Click event handler for updating the location of the marker
|
23 | | - // TODO / FIXME: This will probably cause problems when used for multiple maps on one page.
|
24 | | - OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
|
25 | | - defaultHandlerOptions: {
|
26 | | - 'single': true,
|
27 | | - 'double': false,
|
28 | | - 'pixelTolerance': 0,
|
29 | | - 'stopSingle': false,
|
30 | | - 'stopDouble': false
|
31 | | - },
|
32 | | -
|
33 | | - initialize: function(options) {
|
34 | | - this.handlerOptions = OpenLayers.Util.extend(
|
35 | | - {}, this.defaultHandlerOptions
|
36 | | - );
|
37 | | - OpenLayers.Control.prototype.initialize.apply(
|
38 | | - this, arguments
|
39 | | - );
|
40 | | - this.handler = new OpenLayers.Handler.Click(
|
41 | | - this, {
|
42 | | - 'click': this.trigger
|
43 | | - }, this.handlerOptions
|
44 | | - );
|
45 | | - },
|
46 | | -
|
47 | | - trigger: function(e) {
|
48 | | - var lonlat = map.getLonLatFromViewPortPx(e.xy);
|
49 | | -
|
50 | | - replaceMarker(mapName, lonlat);
|
51 | | -
|
52 | | - var proj = new OpenLayers.Projection("EPSG:4326");
|
53 | | - lonlat.transform(map.getProjectionObject(), proj);
|
54 | | -
|
55 | | - document.getElementById(locationFieldName).value = convertLatToDMS(lonlat.lat)+', '+convertLngToDMS(lonlat.lon);
|
56 | | - }
|
57 | | -
|
58 | | - });
|
59 | | -
|
60 | | - var clickHanler = new OpenLayers.Control.Click();
|
61 | | - controls.push(clickHanler);
|
62 | | -
|
63 | | - var map = initOpenLayer(mapName, lon, lat, zoom, layers, controls, markers, height);
|
64 | | -
|
65 | | - // Make the map variable available for other functions
|
66 | | - if (!window.OLMaps) window.OLMaps = new Object;
|
67 | | - eval("window.OLMaps." + mapName + " = map;");
|
68 | | -}
|
69 | | -
|
70 | | -/**
|
71 | | - * Remove all markers from an OL map (that's in window.OLMaps), and place a new one.
|
72 | | - *
|
73 | | - * @param mapName Name of the map as in OLMaps[mapName].
|
74 | | - * @param newLocation The location for the new marker.
|
75 | | - * @return
|
76 | | - */
|
77 | | -function replaceMarker(mapName, newLocation) {
|
78 | | - var map = OLMaps[mapName];
|
79 | | - var markerLayer = map.getLayer('markerLayer');
|
80 | | -
|
81 | | - removeMarkers(markerLayer);
|
82 | | - markerLayer.addMarker(getOLMarker(markerLayer, getOLMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject()));
|
83 | | -
|
84 | | - map.panTo(newLocation);
|
85 | | -}
|
86 | | -
|
87 | | -/**
|
88 | | - * Removes all markers from a marker layer.
|
89 | | - *
|
90 | | - * @param markerLayer The layer to remove all markers from.
|
91 | | - * @return
|
92 | | - */
|
93 | | -function removeMarkers(markerLayer) {
|
94 | | - var markerCollection = markerLayer.markers;
|
95 | | -
|
96 | | - for (i in markerCollection) {
|
97 | | - markerLayer.removeMarker(markerCollection[i]);
|
98 | | - }
|
| 2 | + /** |
| 3 | + * Javascript functions for OpenLayers functionallity in Semantic Maps |
| 4 | + * |
| 5 | + * @file SM_OpenLayersFunctions.js |
| 6 | + * @ingroup SMOpenLayers |
| 7 | + * |
| 8 | + * @author Jeroen De Dauw |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This function holds spesific functionallity for the Open Layers form input of Semantic Maps |
| 13 | + */ |
| 14 | +function makeFormInputOpenLayer(mapName, locationFieldName, lat, lon, zoom, marker_lat, marker_lon, layers, controls, height) { |
| 15 | + var markers = Array(); |
| 16 | + |
| 17 | + // Show a starting marker only if marker coordinates are provided |
| 18 | + if (marker_lat != null && marker_lon != null) { |
| 19 | + markers.push(getOLMarkerData(marker_lon, marker_lat, '', '', '')); |
| 20 | + } |
| 21 | + |
| 22 | + // Click event handler for updating the location of the marker |
| 23 | + // TODO / FIXME: This will probably cause problems when used for multiple maps on one page. |
| 24 | + OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { |
| 25 | + defaultHandlerOptions: { |
| 26 | + 'single': true, |
| 27 | + 'double': false, |
| 28 | + 'pixelTolerance': 0, |
| 29 | + 'stopSingle': false, |
| 30 | + 'stopDouble': false |
| 31 | + }, |
| 32 | + |
| 33 | + initialize: function(options) { |
| 34 | + this.handlerOptions = OpenLayers.Util.extend( |
| 35 | + {}, this.defaultHandlerOptions |
| 36 | + ); |
| 37 | + OpenLayers.Control.prototype.initialize.apply( |
| 38 | + this, arguments |
| 39 | + ); |
| 40 | + this.handler = new OpenLayers.Handler.Click( |
| 41 | + this, { |
| 42 | + 'click': this.trigger |
| 43 | + }, this.handlerOptions |
| 44 | + ); |
| 45 | + }, |
| 46 | + |
| 47 | + trigger: function(e) { |
| 48 | + var lonlat = map.getLonLatFromViewPortPx(e.xy); |
| 49 | + |
| 50 | + replaceMarker(mapName, lonlat); |
| 51 | + |
| 52 | + var proj = new OpenLayers.Projection("EPSG:4326"); |
| 53 | + lonlat.transform(map.getProjectionObject(), proj); |
| 54 | + |
| 55 | + document.getElementById(locationFieldName).value = convertLatToDMS(lonlat.lat)+', '+convertLngToDMS(lonlat.lon); |
| 56 | + } |
| 57 | + |
| 58 | + }); |
| 59 | + |
| 60 | + var clickHanler = new OpenLayers.Control.Click(); |
| 61 | + controls.push(clickHanler); |
| 62 | + |
| 63 | + var map = initOpenLayer(mapName, lon, lat, zoom, layers, controls, markers, height); |
| 64 | + |
| 65 | + // Make the map variable available for other functions |
| 66 | + if (!window.OLMaps) window.OLMaps = new Object; |
| 67 | + eval("window.OLMaps." + mapName + " = map;"); |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * Remove all markers from an OL map (that's in window.OLMaps), and place a new one. |
| 72 | + * |
| 73 | + * @param mapName Name of the map as in OLMaps[mapName]. |
| 74 | + * @param newLocation The location for the new marker. |
| 75 | + * @return |
| 76 | + */ |
| 77 | +function replaceMarker(mapName, newLocation) { |
| 78 | + var map = OLMaps[mapName]; |
| 79 | + var markerLayer = map.getLayer('markerLayer'); |
| 80 | + |
| 81 | + removeMarkers(markerLayer); |
| 82 | + markerLayer.addMarker(getOLMarker(markerLayer, getOLMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject())); |
| 83 | + |
| 84 | + map.panTo(newLocation); |
| 85 | +} |
| 86 | + |
| 87 | +/** |
| 88 | + * Removes all markers from a marker layer. |
| 89 | + * |
| 90 | + * @param markerLayer The layer to remove all markers from. |
| 91 | + * @return |
| 92 | + */ |
| 93 | +function removeMarkers(markerLayer) { |
| 94 | + var markerCollection = markerLayer.markers; |
| 95 | + |
| 96 | + for (i in markerCollection) { |
| 97 | + markerLayer.removeMarker(markerCollection[i]); |
| 98 | + } |
99 | 99 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
100 | 100 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayers.php |
— | — | @@ -1,27 +1,27 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all OpenLayers related files of the Semantic Maps extension.
|
6 | | - *
|
7 | | - * @defgroup SMOpenLayers OpenLayers
|
8 | | - * @ingroup SemanticMaps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the OpenLayers service.
|
13 | | - *
|
14 | | - * @file SM_OpenLayers.php
|
15 | | - * @ingroup SMOpenLayers
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['SMOpenLayersQP'] = dirname( __FILE__ ) . '/SM_OpenLayersQP.php';
|
25 | | -$wgAutoloadClasses['SMOpenLayersFormInput'] = dirname( __FILE__ ) . '/SM_OpenLayersFormInput.php';
|
26 | | -
|
27 | | -$egMapsServices['openlayers']['features']['qp'] = 'SMOpenLayersQP';
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all OpenLayers related files of the Semantic Maps extension. |
| 6 | + * |
| 7 | + * @defgroup SMOpenLayers OpenLayers |
| 8 | + * @ingroup SemanticMaps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the OpenLayers service. |
| 13 | + * |
| 14 | + * @file SM_OpenLayers.php |
| 15 | + * @ingroup SMOpenLayers |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['SMOpenLayersQP'] = dirname( __FILE__ ) . '/SM_OpenLayersQP.php'; |
| 25 | +$wgAutoloadClasses['SMOpenLayersFormInput'] = dirname( __FILE__ ) . '/SM_OpenLayersFormInput.php'; |
| 26 | + |
| 27 | +$egMapsServices['openlayers']['features']['qp'] = 'SMOpenLayersQP'; |
28 | 28 | $egMapsServices['openlayers']['features']['fi'] = 'SMOpenLayersFormInput'; |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayers.php |
___________________________________________________________________ |
Added: svn:eol-style |
29 | 29 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersQP.php |
— | — | @@ -1,103 +1,103 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * A query printer for maps using the Open Layers API
|
6 | | - *
|
7 | | - * @file SM_OpenLayersQP.php
|
8 | | - * @ingroup SMOpenLayers
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -final class SMOpenLayersQP extends SMMapPrinter {
|
18 | | -
|
19 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME;
|
20 | | -
|
21 | | - /**
|
22 | | - * @see SMMapPrinter::setQueryPrinterSettings()
|
23 | | - *
|
24 | | - */
|
25 | | - protected function setQueryPrinterSettings() {
|
26 | | - global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
|
27 | | -
|
28 | | - $this->elementNamePrefix = $egMapsOpenLayersPrefix;
|
29 | | - $this->defaultZoom = $egMapsOpenLayersZoom;
|
30 | | - }
|
31 | | -
|
32 | | - /**
|
33 | | - * @see SMMapPrinter::doMapServiceLoad()
|
34 | | - *
|
35 | | - */
|
36 | | - protected function doMapServiceLoad() {
|
37 | | - global $egOpenLayersOnThisPage;
|
38 | | -
|
39 | | - MapsOpenLayers::addOLDependencies( $this->output );
|
40 | | - $egOpenLayersOnThisPage++;
|
41 | | -
|
42 | | - $this->elementNr = $egOpenLayersOnThisPage;
|
43 | | - }
|
44 | | -
|
45 | | - /**
|
46 | | - * @see SMMapPrinter::addSpecificMapHTML()
|
47 | | - *
|
48 | | - */
|
49 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
50 | | - // TODO: refactor up like done in maps with display point
|
51 | | - $markerItems = array();
|
52 | | -
|
53 | | - foreach ( $this->m_locations as $location ) {
|
54 | | - // Create a string containing the marker JS .
|
55 | | - list( $lat, $lon, $title, $label, $icon ) = $location;
|
56 | | -
|
57 | | - $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
|
58 | | - }
|
59 | | -
|
60 | | - $markersString = implode( ',', $markerItems );
|
61 | | -
|
62 | | - $this->output .= Html::element(
|
63 | | - 'div',
|
64 | | - array(
|
65 | | - 'id' => $this->mapName,
|
66 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
67 | | - ),
|
68 | | - wfMsg('maps-loading-map')
|
69 | | - );
|
70 | | -
|
71 | | - $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
|
72 | | -
|
73 | | - $parser->getOutput()->addHeadItem(
|
74 | | - Html::inlineScript( <<<EOT
|
75 | | -addOnloadHook(
|
76 | | - function() {
|
77 | | - initOpenLayer(
|
78 | | - '$this->mapName',
|
79 | | - $this->centreLat,
|
80 | | - $this->centreLon,
|
81 | | - $this->zoom,
|
82 | | - [$layerItems],
|
83 | | - [$this->controls],
|
84 | | - [$markersString]
|
85 | | - );
|
86 | | - }
|
87 | | -);
|
88 | | -EOT
|
89 | | - ) );
|
90 | | - }
|
91 | | -
|
92 | | - /**
|
93 | | - * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list.
|
94 | | - */
|
95 | | - public function getParameters() {
|
96 | | - $params = parent::getParameters();
|
97 | | -
|
98 | | - $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsOpenLayers::getControlNames() );
|
99 | | - $params[] = array( 'name' => 'layers', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_layers' ), 'values' => MapsOpenLayers::getLayerNames() );
|
100 | | -
|
101 | | - return $params;
|
102 | | - }
|
103 | | -
|
104 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * A query printer for maps using the Open Layers API |
| 6 | + * |
| 7 | + * @file SM_OpenLayersQP.php |
| 8 | + * @ingroup SMOpenLayers |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +final class SMOpenLayersQP extends SMMapPrinter { |
| 18 | + |
| 19 | + public $serviceName = MapsOpenLayers::SERVICE_NAME; |
| 20 | + |
| 21 | + /** |
| 22 | + * @see SMMapPrinter::setQueryPrinterSettings() |
| 23 | + * |
| 24 | + */ |
| 25 | + protected function setQueryPrinterSettings() { |
| 26 | + global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix; |
| 27 | + |
| 28 | + $this->elementNamePrefix = $egMapsOpenLayersPrefix; |
| 29 | + $this->defaultZoom = $egMapsOpenLayersZoom; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @see SMMapPrinter::doMapServiceLoad() |
| 34 | + * |
| 35 | + */ |
| 36 | + protected function doMapServiceLoad() { |
| 37 | + global $egOpenLayersOnThisPage; |
| 38 | + |
| 39 | + MapsOpenLayers::addOLDependencies( $this->output ); |
| 40 | + $egOpenLayersOnThisPage++; |
| 41 | + |
| 42 | + $this->elementNr = $egOpenLayersOnThisPage; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @see SMMapPrinter::addSpecificMapHTML() |
| 47 | + * |
| 48 | + */ |
| 49 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 50 | + // TODO: refactor up like done in maps with display point |
| 51 | + $markerItems = array(); |
| 52 | + |
| 53 | + foreach ( $this->m_locations as $location ) { |
| 54 | + // Create a string containing the marker JS . |
| 55 | + list( $lat, $lon, $title, $label, $icon ) = $location; |
| 56 | + |
| 57 | + $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')"; |
| 58 | + } |
| 59 | + |
| 60 | + $markersString = implode( ',', $markerItems ); |
| 61 | + |
| 62 | + $this->output .= Html::element( |
| 63 | + 'div', |
| 64 | + array( |
| 65 | + 'id' => $this->mapName, |
| 66 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 67 | + ), |
| 68 | + wfMsg('maps-loading-map') |
| 69 | + ); |
| 70 | + |
| 71 | + $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
| 72 | + |
| 73 | + $parser->getOutput()->addHeadItem( |
| 74 | + Html::inlineScript( <<<EOT |
| 75 | +addOnloadHook( |
| 76 | + function() { |
| 77 | + initOpenLayer( |
| 78 | + '$this->mapName', |
| 79 | + $this->centreLat, |
| 80 | + $this->centreLon, |
| 81 | + $this->zoom, |
| 82 | + [$layerItems], |
| 83 | + [$this->controls], |
| 84 | + [$markersString] |
| 85 | + ); |
| 86 | + } |
| 87 | +); |
| 88 | +EOT |
| 89 | + ) ); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list. |
| 94 | + */ |
| 95 | + public function getParameters() { |
| 96 | + $params = parent::getParameters(); |
| 97 | + |
| 98 | + $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsOpenLayers::getControlNames() ); |
| 99 | + $params[] = array( 'name' => 'layers', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_layers' ), 'values' => MapsOpenLayers::getLayerNames() ); |
| 100 | + |
| 101 | + return $params; |
| 102 | + } |
| 103 | + |
| 104 | +} |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersQP.php |
___________________________________________________________________ |
Added: svn:eol-style |
105 | 105 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php |
— | — | @@ -1,114 +1,114 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Form input hook that adds an Open Layers map format to Semantic Forms
|
6 | | - *
|
7 | | - * @file SM_OpenLayersFormInput.php
|
8 | | - * @ingroup SMOpenLayers
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -final class SMOpenLayersFormInput extends SMFormInput {
|
18 | | -
|
19 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME;
|
20 | | -
|
21 | | - protected $spesificParameters = array();
|
22 | | -
|
23 | | - /**
|
24 | | - * @see MapsMapFeature::setMapSettings()
|
25 | | - *
|
26 | | - */
|
27 | | - protected function setMapSettings() {
|
28 | | - global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
|
29 | | -
|
30 | | - $this->elementNamePrefix = $egMapsOpenLayersPrefix;
|
31 | | -
|
32 | | - $this->earthZoom = 1;
|
33 | | -
|
34 | | - $this->defaultZoom = $egMapsOpenLayersZoom;
|
35 | | - }
|
36 | | -
|
37 | | - /**
|
38 | | - * @see MapsMapFeature::addFormDependencies()
|
39 | | - *
|
40 | | - */
|
41 | | - protected function addFormDependencies() {
|
42 | | - global $wgJsMimeType;
|
43 | | - global $smgScriptPath, $smgOLFormsOnThisPage, $smgStyleVersion, $egMapsJsExt;
|
44 | | -
|
45 | | - MapsOpenLayers::addOLDependencies( $this->output );
|
46 | | -
|
47 | | - if ( empty( $smgOLFormsOnThisPage ) ) {
|
48 | | - $smgOLFormsOnThisPage = 0;
|
49 | | - $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/OpenLayers/SM_OpenLayersFunctions{$egMapsJsExt}?$smgStyleVersion'></script>";
|
50 | | - }
|
51 | | - }
|
52 | | -
|
53 | | - /**
|
54 | | - * @see MapsMapFeature::doMapServiceLoad()
|
55 | | - *
|
56 | | - */
|
57 | | - protected function doMapServiceLoad() {
|
58 | | - global $egOpenLayersOnThisPage, $smgOLFormsOnThisPage;
|
59 | | -
|
60 | | - self::addFormDependencies();
|
61 | | -
|
62 | | - $egOpenLayersOnThisPage++;
|
63 | | - $smgOLFormsOnThisPage++;
|
64 | | -
|
65 | | - $this->elementNr = $egOpenLayersOnThisPage;
|
66 | | - }
|
67 | | -
|
68 | | - /**
|
69 | | - * @see MapsMapFeature::addSpecificMapHTML()
|
70 | | - *
|
71 | | - */
|
72 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
73 | | - global $wgOut;
|
74 | | -
|
75 | | - $this->output .= Html::element(
|
76 | | - 'div',
|
77 | | - array(
|
78 | | - 'id' => $this->mapName,
|
79 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
80 | | - ),
|
81 | | - wfMsg('maps-loading-map')
|
82 | | - );
|
83 | | -
|
84 | | - $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
|
85 | | -
|
86 | | - $wgOut->addInlineScript( <<<EOT
|
87 | | -addOnloadHook(
|
88 | | - function() {
|
89 | | - makeFormInputOpenLayer(
|
90 | | - '$this->mapName',
|
91 | | - '$this->coordsFieldName',
|
92 | | - $this->centreLat,
|
93 | | - $this->centreLon,
|
94 | | - $this->zoom,
|
95 | | - $this->marker_lat,
|
96 | | - $this->marker_lon,
|
97 | | - [$layerItems],
|
98 | | - [$this->controls]
|
99 | | - );
|
100 | | - }
|
101 | | -);
|
102 | | -EOT
|
103 | | - );
|
104 | | -
|
105 | | - }
|
106 | | -
|
107 | | - /**
|
108 | | - * @see SMFormInput::manageGeocoding()
|
109 | | - * TODO: find a geocoding service that can be used here
|
110 | | - */
|
111 | | - protected function manageGeocoding() {
|
112 | | - $this->enableGeocoding = false;
|
113 | | - }
|
114 | | -
|
115 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Form input hook that adds an Open Layers map format to Semantic Forms |
| 6 | + * |
| 7 | + * @file SM_OpenLayersFormInput.php |
| 8 | + * @ingroup SMOpenLayers |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +final class SMOpenLayersFormInput extends SMFormInput { |
| 18 | + |
| 19 | + public $serviceName = MapsOpenLayers::SERVICE_NAME; |
| 20 | + |
| 21 | + protected $spesificParameters = array(); |
| 22 | + |
| 23 | + /** |
| 24 | + * @see MapsMapFeature::setMapSettings() |
| 25 | + * |
| 26 | + */ |
| 27 | + protected function setMapSettings() { |
| 28 | + global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix; |
| 29 | + |
| 30 | + $this->elementNamePrefix = $egMapsOpenLayersPrefix; |
| 31 | + |
| 32 | + $this->earthZoom = 1; |
| 33 | + |
| 34 | + $this->defaultZoom = $egMapsOpenLayersZoom; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @see MapsMapFeature::addFormDependencies() |
| 39 | + * |
| 40 | + */ |
| 41 | + protected function addFormDependencies() { |
| 42 | + global $wgJsMimeType; |
| 43 | + global $smgScriptPath, $smgOLFormsOnThisPage, $smgStyleVersion, $egMapsJsExt; |
| 44 | + |
| 45 | + MapsOpenLayers::addOLDependencies( $this->output ); |
| 46 | + |
| 47 | + if ( empty( $smgOLFormsOnThisPage ) ) { |
| 48 | + $smgOLFormsOnThisPage = 0; |
| 49 | + $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/OpenLayers/SM_OpenLayersFunctions{$egMapsJsExt}?$smgStyleVersion'></script>"; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @see MapsMapFeature::doMapServiceLoad() |
| 55 | + * |
| 56 | + */ |
| 57 | + protected function doMapServiceLoad() { |
| 58 | + global $egOpenLayersOnThisPage, $smgOLFormsOnThisPage; |
| 59 | + |
| 60 | + self::addFormDependencies(); |
| 61 | + |
| 62 | + $egOpenLayersOnThisPage++; |
| 63 | + $smgOLFormsOnThisPage++; |
| 64 | + |
| 65 | + $this->elementNr = $egOpenLayersOnThisPage; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * @see MapsMapFeature::addSpecificMapHTML() |
| 70 | + * |
| 71 | + */ |
| 72 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 73 | + global $wgOut; |
| 74 | + |
| 75 | + $this->output .= Html::element( |
| 76 | + 'div', |
| 77 | + array( |
| 78 | + 'id' => $this->mapName, |
| 79 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 80 | + ), |
| 81 | + wfMsg('maps-loading-map') |
| 82 | + ); |
| 83 | + |
| 84 | + $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
| 85 | + |
| 86 | + $wgOut->addInlineScript( <<<EOT |
| 87 | +addOnloadHook( |
| 88 | + function() { |
| 89 | + makeFormInputOpenLayer( |
| 90 | + '$this->mapName', |
| 91 | + '$this->coordsFieldName', |
| 92 | + $this->centreLat, |
| 93 | + $this->centreLon, |
| 94 | + $this->zoom, |
| 95 | + $this->marker_lat, |
| 96 | + $this->marker_lon, |
| 97 | + [$layerItems], |
| 98 | + [$this->controls] |
| 99 | + ); |
| 100 | + } |
| 101 | +); |
| 102 | +EOT |
| 103 | + ); |
| 104 | + |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * @see SMFormInput::manageGeocoding() |
| 109 | + * TODO: find a geocoding service that can be used here |
| 110 | + */ |
| 111 | + protected function manageGeocoding() { |
| 112 | + $this->enableGeocoding = false; |
| 113 | + } |
| 114 | + |
| 115 | +} |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php |
___________________________________________________________________ |
Added: svn:eol-style |
116 | 116 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSMFormInput.php |
— | — | @@ -1,109 +1,109 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Form input hook that adds an OSM map format to Semantic Forms
|
6 | | - *
|
7 | | - * @file SM_OSMFormInput.php
|
8 | | - * @ingroup SMOSM
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -// TODO: the js for this form input does not work yet. Requires fixing before the FI can be enabled.
|
18 | | -
|
19 | | -final class SMOSMFormInput extends SMFormInput {
|
20 | | -
|
21 | | - public $serviceName = MapsOSM::SERVICE_NAME;
|
22 | | -
|
23 | | - /**
|
24 | | - * @see MapsMapFeature::setMapSettings()
|
25 | | - *
|
26 | | - */
|
27 | | - protected function setMapSettings() {
|
28 | | - global $egMapsOSMZoom, $egMapsOSMPrefix;
|
29 | | -
|
30 | | - $this->elementNamePrefix = $egMapsOSMPrefix;
|
31 | | -
|
32 | | - $this->earthZoom = 1;
|
33 | | -
|
34 | | - $this->defaultZoom = $egMapsOSMZoom;
|
35 | | - }
|
36 | | -
|
37 | | - /**
|
38 | | - * @see MapsMapFeature::addFormDependencies()
|
39 | | - *
|
40 | | - */
|
41 | | - protected function addFormDependencies() {
|
42 | | - global $wgJsMimeType;
|
43 | | - global $smgScriptPath, $smgOSMFormsOnThisPage, $smgStyleVersion, $egMapsJsExt;
|
44 | | -
|
45 | | - MapsOSM::addOSMDependencies( $this->output );
|
46 | | -
|
47 | | - if ( empty( $smgOSMFormsOnThisPage ) ) {
|
48 | | - $smgOSMFormsOnThisPage = 0;
|
49 | | - $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/OpenStreetMap/SM_OSMFunctions{$egMapsJsExt}?$smgStyleVersion'></script>";
|
50 | | - }
|
51 | | - }
|
52 | | -
|
53 | | - /**
|
54 | | - * @see MapsMapFeature::doMapServiceLoad()
|
55 | | - *
|
56 | | - */
|
57 | | - protected function doMapServiceLoad() {
|
58 | | - global $egOSMMapsOnThisPage, $smgOSMFormsOnThisPage;
|
59 | | -
|
60 | | - self::addFormDependencies();
|
61 | | -
|
62 | | - $egOSMMapsOnThisPage++;
|
63 | | - $smgOSMFormsOnThisPage++;
|
64 | | -
|
65 | | - $this->elementNr = $egOSMMapsOnThisPage;
|
66 | | - }
|
67 | | -
|
68 | | - /**
|
69 | | - * @see MapsMapFeature::addSpecificMapHTML()
|
70 | | - *
|
71 | | - */
|
72 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
73 | | - global $wgJsMimeType;
|
74 | | -
|
75 | | - $this->output .= <<<EOT
|
76 | | - <script type='$wgJsMimeType'>
|
77 | | - makeOSMFormInput(
|
78 | | - '$this->mapName',
|
79 | | - '$this->coordsFieldName',
|
80 | | - {
|
81 | | - mode: 'osm-wm',
|
82 | | - layer: 'osm-like',
|
83 | | - locale: '$this->lang',
|
84 | | - lat: $this->centreLat,
|
85 | | - lon: $this->centreLon,
|
86 | | - zoom: $this->zoom,
|
87 | | - width: $this->width,
|
88 | | - height: $this->height,
|
89 | | - controls: [$this->controls],
|
90 | | - }
|
91 | | - );
|
92 | | -
|
93 | | -
|
94 | | - </script>
|
95 | | -
|
96 | | - <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
|
97 | | - <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
|
98 | | - </div>
|
99 | | -EOT;
|
100 | | - }
|
101 | | -
|
102 | | - /**
|
103 | | - * @see SMFormInput::manageGeocoding()
|
104 | | - *
|
105 | | - */
|
106 | | - protected function manageGeocoding() {
|
107 | | - $this->enableGeocoding = false;
|
108 | | - }
|
109 | | -
|
110 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Form input hook that adds an OSM map format to Semantic Forms |
| 6 | + * |
| 7 | + * @file SM_OSMFormInput.php |
| 8 | + * @ingroup SMOSM |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +// TODO: the js for this form input does not work yet. Requires fixing before the FI can be enabled. |
| 18 | + |
| 19 | +final class SMOSMFormInput extends SMFormInput { |
| 20 | + |
| 21 | + public $serviceName = MapsOSM::SERVICE_NAME; |
| 22 | + |
| 23 | + /** |
| 24 | + * @see MapsMapFeature::setMapSettings() |
| 25 | + * |
| 26 | + */ |
| 27 | + protected function setMapSettings() { |
| 28 | + global $egMapsOSMZoom, $egMapsOSMPrefix; |
| 29 | + |
| 30 | + $this->elementNamePrefix = $egMapsOSMPrefix; |
| 31 | + |
| 32 | + $this->earthZoom = 1; |
| 33 | + |
| 34 | + $this->defaultZoom = $egMapsOSMZoom; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @see MapsMapFeature::addFormDependencies() |
| 39 | + * |
| 40 | + */ |
| 41 | + protected function addFormDependencies() { |
| 42 | + global $wgJsMimeType; |
| 43 | + global $smgScriptPath, $smgOSMFormsOnThisPage, $smgStyleVersion, $egMapsJsExt; |
| 44 | + |
| 45 | + MapsOSM::addOSMDependencies( $this->output ); |
| 46 | + |
| 47 | + if ( empty( $smgOSMFormsOnThisPage ) ) { |
| 48 | + $smgOSMFormsOnThisPage = 0; |
| 49 | + $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/OpenStreetMap/SM_OSMFunctions{$egMapsJsExt}?$smgStyleVersion'></script>"; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @see MapsMapFeature::doMapServiceLoad() |
| 55 | + * |
| 56 | + */ |
| 57 | + protected function doMapServiceLoad() { |
| 58 | + global $egOSMMapsOnThisPage, $smgOSMFormsOnThisPage; |
| 59 | + |
| 60 | + self::addFormDependencies(); |
| 61 | + |
| 62 | + $egOSMMapsOnThisPage++; |
| 63 | + $smgOSMFormsOnThisPage++; |
| 64 | + |
| 65 | + $this->elementNr = $egOSMMapsOnThisPage; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * @see MapsMapFeature::addSpecificMapHTML() |
| 70 | + * |
| 71 | + */ |
| 72 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 73 | + global $wgJsMimeType; |
| 74 | + |
| 75 | + $this->output .= <<<EOT |
| 76 | + <script type='$wgJsMimeType'> |
| 77 | + makeOSMFormInput( |
| 78 | + '$this->mapName', |
| 79 | + '$this->coordsFieldName', |
| 80 | + { |
| 81 | + mode: 'osm-wm', |
| 82 | + layer: 'osm-like', |
| 83 | + locale: '$this->lang', |
| 84 | + lat: $this->centreLat, |
| 85 | + lon: $this->centreLon, |
| 86 | + zoom: $this->zoom, |
| 87 | + width: $this->width, |
| 88 | + height: $this->height, |
| 89 | + controls: [$this->controls], |
| 90 | + } |
| 91 | + ); |
| 92 | + |
| 93 | + |
| 94 | + </script> |
| 95 | + |
| 96 | + <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'> |
| 97 | + <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script> |
| 98 | + </div> |
| 99 | +EOT; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * @see SMFormInput::manageGeocoding() |
| 104 | + * |
| 105 | + */ |
| 106 | + protected function manageGeocoding() { |
| 107 | + $this->enableGeocoding = false; |
| 108 | + } |
| 109 | + |
| 110 | +} |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSMFormInput.php |
___________________________________________________________________ |
Added: svn:eol-style |
111 | 111 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSMFunctions.js |
— | — | @@ -1,99 +1,99 @@ |
2 | | - /**
|
3 | | - * Javascript functions for OpenStreetMap functionallity in Semantic Maps
|
4 | | - *
|
5 | | - * @file SM_OSMFunctions.js
|
6 | | - * @ingroup SMOSM
|
7 | | - *
|
8 | | - * @author Jeroen De Dauw
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This function holds spesific functionallity for the OpenStreetMap form input of Semantic Maps
|
13 | | - */
|
14 | | -function makeOSMFormInput(mapName, locationFieldName, mapParams) {
|
15 | | - var markers = Array();
|
16 | | -
|
17 | | - // Show a starting marker only if marker coordinates are provided
|
18 | | - if (mapParams.lat != null && mapParams.lon != null) {
|
19 | | - mapParams.markers = [(getOSMMarkerData(mapParams.lon, mapParams.lat, '', '', ''))];
|
20 | | - }
|
21 | | -
|
22 | | - // Click event handler for updating the location of the marker
|
23 | | - // TODO / FIXME: This will probably cause problems when used for multiple maps on one page.
|
24 | | - OpenLayers.Control.ClickHandler = OpenLayers.Class(OpenLayers.Control, {
|
25 | | - defaultHandlerOptions: {
|
26 | | - 'single': true,
|
27 | | - 'double': false,
|
28 | | - 'pixelTolerance': 0,
|
29 | | - 'stopSingle': false,
|
30 | | - 'stopDouble': false
|
31 | | - },
|
32 | | -
|
33 | | - initialize: function(options) {
|
34 | | - this.handlerOptions = OpenLayers.Util.extend(
|
35 | | - {}, this.defaultHandlerOptions
|
36 | | - );
|
37 | | - OpenLayers.Control.prototype.initialize.apply(
|
38 | | - this, arguments
|
39 | | - );
|
40 | | - this.handler = new OpenLayers.Handler.Click(
|
41 | | - this, {
|
42 | | - 'click': this.trigger
|
43 | | - }, this.handlerOptions
|
44 | | - );
|
45 | | - },
|
46 | | -
|
47 | | - trigger: function(e) {
|
48 | | - var lonlat = this.getLonLatFromViewPortPx(e.xy);
|
49 | | -
|
50 | | - replaceMarker(mapName, lonlat);
|
51 | | -
|
52 | | - var proj = new OpenLayers.Projection("EPSG:4326");
|
53 | | - lonlat.transform(map.getProjectionObject(), proj);
|
54 | | -
|
55 | | - document.getElementById(locationFieldName).value = convertLatToDMS(lonlat.lat)+', '+convertLngToDMS(lonlat.lon);
|
56 | | - }
|
57 | | -
|
58 | | - });
|
59 | | -
|
60 | | - var clickHanler = new OpenLayers.Control.ClickHandler();
|
61 | | - mapParams.controls.push(clickHanler);
|
62 | | - mapParams.initializedContols = [];
|
63 | | -
|
64 | | - var map = new slippymap_map(mapName, mapParams);
|
65 | | -
|
66 | | - // Make the map variable available for other functions
|
67 | | - eval("window.slippymaps." + mapName + " = map;");
|
68 | | -}
|
69 | | -
|
70 | | -/**
|
71 | | - * Remove all markers from an OSM map (that's in window.OSMMaps), and place a new one.
|
72 | | - *
|
73 | | - * @param mapName Name of the map as in OSMMaps[mapName].
|
74 | | - * @param newLocation The location for the new marker.
|
75 | | - * @return
|
76 | | - */
|
77 | | -function replaceMarker(mapName, newLocation) {
|
78 | | - var map = slippymaps[mapName];
|
79 | | -
|
80 | | - var markerLayer = map.getLayer('markerLayer');
|
81 | | -
|
82 | | - removeOSMMarkers(markerLayer);
|
83 | | - markerLayer.addMarker(getOSMMarker(markerLayer, getOSMMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject()));
|
84 | | -
|
85 | | - map.panTo(newLocation);
|
86 | | -}
|
87 | | -
|
88 | | -/**
|
89 | | - * Removes all markers from a marker layer.
|
90 | | - *
|
91 | | - * @param markerLayer The layer to remove all markers from.
|
92 | | - * @return
|
93 | | - */
|
94 | | -function removeOSMMarkers(markerLayer) {
|
95 | | - var markerCollection = markerLayer.markers;
|
96 | | -
|
97 | | - for (i in markerCollection) {
|
98 | | - markerLayer.removeMarker(markerCollection[i]);
|
99 | | - }
|
| 2 | + /** |
| 3 | + * Javascript functions for OpenStreetMap functionallity in Semantic Maps |
| 4 | + * |
| 5 | + * @file SM_OSMFunctions.js |
| 6 | + * @ingroup SMOSM |
| 7 | + * |
| 8 | + * @author Jeroen De Dauw |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This function holds spesific functionallity for the OpenStreetMap form input of Semantic Maps |
| 13 | + */ |
| 14 | +function makeOSMFormInput(mapName, locationFieldName, mapParams) { |
| 15 | + var markers = Array(); |
| 16 | + |
| 17 | + // Show a starting marker only if marker coordinates are provided |
| 18 | + if (mapParams.lat != null && mapParams.lon != null) { |
| 19 | + mapParams.markers = [(getOSMMarkerData(mapParams.lon, mapParams.lat, '', '', ''))]; |
| 20 | + } |
| 21 | + |
| 22 | + // Click event handler for updating the location of the marker |
| 23 | + // TODO / FIXME: This will probably cause problems when used for multiple maps on one page. |
| 24 | + OpenLayers.Control.ClickHandler = OpenLayers.Class(OpenLayers.Control, { |
| 25 | + defaultHandlerOptions: { |
| 26 | + 'single': true, |
| 27 | + 'double': false, |
| 28 | + 'pixelTolerance': 0, |
| 29 | + 'stopSingle': false, |
| 30 | + 'stopDouble': false |
| 31 | + }, |
| 32 | + |
| 33 | + initialize: function(options) { |
| 34 | + this.handlerOptions = OpenLayers.Util.extend( |
| 35 | + {}, this.defaultHandlerOptions |
| 36 | + ); |
| 37 | + OpenLayers.Control.prototype.initialize.apply( |
| 38 | + this, arguments |
| 39 | + ); |
| 40 | + this.handler = new OpenLayers.Handler.Click( |
| 41 | + this, { |
| 42 | + 'click': this.trigger |
| 43 | + }, this.handlerOptions |
| 44 | + ); |
| 45 | + }, |
| 46 | + |
| 47 | + trigger: function(e) { |
| 48 | + var lonlat = this.getLonLatFromViewPortPx(e.xy); |
| 49 | + |
| 50 | + replaceMarker(mapName, lonlat); |
| 51 | + |
| 52 | + var proj = new OpenLayers.Projection("EPSG:4326"); |
| 53 | + lonlat.transform(map.getProjectionObject(), proj); |
| 54 | + |
| 55 | + document.getElementById(locationFieldName).value = convertLatToDMS(lonlat.lat)+', '+convertLngToDMS(lonlat.lon); |
| 56 | + } |
| 57 | + |
| 58 | + }); |
| 59 | + |
| 60 | + var clickHanler = new OpenLayers.Control.ClickHandler(); |
| 61 | + mapParams.controls.push(clickHanler); |
| 62 | + mapParams.initializedContols = []; |
| 63 | + |
| 64 | + var map = new slippymap_map(mapName, mapParams); |
| 65 | + |
| 66 | + // Make the map variable available for other functions |
| 67 | + eval("window.slippymaps." + mapName + " = map;"); |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * Remove all markers from an OSM map (that's in window.OSMMaps), and place a new one. |
| 72 | + * |
| 73 | + * @param mapName Name of the map as in OSMMaps[mapName]. |
| 74 | + * @param newLocation The location for the new marker. |
| 75 | + * @return |
| 76 | + */ |
| 77 | +function replaceMarker(mapName, newLocation) { |
| 78 | + var map = slippymaps[mapName]; |
| 79 | + |
| 80 | + var markerLayer = map.getLayer('markerLayer'); |
| 81 | + |
| 82 | + removeOSMMarkers(markerLayer); |
| 83 | + markerLayer.addMarker(getOSMMarker(markerLayer, getOSMMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject())); |
| 84 | + |
| 85 | + map.panTo(newLocation); |
| 86 | +} |
| 87 | + |
| 88 | +/** |
| 89 | + * Removes all markers from a marker layer. |
| 90 | + * |
| 91 | + * @param markerLayer The layer to remove all markers from. |
| 92 | + * @return |
| 93 | + */ |
| 94 | +function removeOSMMarkers(markerLayer) { |
| 95 | + var markerCollection = markerLayer.markers; |
| 96 | + |
| 97 | + for (i in markerCollection) { |
| 98 | + markerLayer.removeMarker(markerCollection[i]); |
| 99 | + } |
100 | 100 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSMFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
101 | 101 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSM.php |
— | — | @@ -1,26 +1,26 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all OpenStreetMap related files of the Semantic Maps extension.
|
6 | | - *
|
7 | | - * @defgroup SMOSM OpenStreetMap
|
8 | | - * @ingroup SemanticMaps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the OpenStreetMap service.
|
13 | | - *
|
14 | | - * @file SM_OSM.php
|
15 | | - * @ingroup SMOSM
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['SMOSMQP'] = dirname( __FILE__ ) . '/SM_SMOSMQP.php';
|
25 | | -
|
26 | | -$egMapsServices['osm']['features']['qp'] = 'SMOSMQP';
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all OpenStreetMap related files of the Semantic Maps extension. |
| 6 | + * |
| 7 | + * @defgroup SMOSM OpenStreetMap |
| 8 | + * @ingroup SemanticMaps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the OpenStreetMap service. |
| 13 | + * |
| 14 | + * @file SM_OSM.php |
| 15 | + * @ingroup SMOSM |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['SMOSMQP'] = dirname( __FILE__ ) . '/SM_SMOSMQP.php'; |
| 25 | + |
| 26 | +$egMapsServices['osm']['features']['qp'] = 'SMOSMQP'; |
27 | 27 | // $egMapsServices['osm']['features']['fi'] = 'SMOSMFormInput'; |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSM.php |
___________________________________________________________________ |
Added: svn:eol-style |
28 | 28 | + native |
Index: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSMQP.php |
— | — | @@ -1,95 +1,95 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * A query printer for maps using the Open Layers API optimized for OSM
|
6 | | - *
|
7 | | - * @file SM_OSMQP.php
|
8 | | - * @ingroup SMOSM
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -final class SMOSMQP extends SMMapPrinter {
|
18 | | -
|
19 | | - public $serviceName = MapsOSM::SERVICE_NAME;
|
20 | | -
|
21 | | - /**
|
22 | | - * @see SMMapPrinter::setQueryPrinterSettings()
|
23 | | - *
|
24 | | - */
|
25 | | - protected function setQueryPrinterSettings() {
|
26 | | - global $egMapsOSMZoom, $egMapsOSMPrefix;
|
27 | | -
|
28 | | - $this->elementNamePrefix = $egMapsOSMPrefix;
|
29 | | - $this->defaultZoom = $egMapsOSMZoom;
|
30 | | - }
|
31 | | -
|
32 | | - /**
|
33 | | - * @see SMMapPrinter::doMapServiceLoad()
|
34 | | - *
|
35 | | - */
|
36 | | - protected function doMapServiceLoad() {
|
37 | | - global $egOSMMapsOnThisPage;
|
38 | | -
|
39 | | - MapsOSM::addOSMDependencies( $this->output );
|
40 | | - $egOSMMapsOnThisPage++;
|
41 | | -
|
42 | | - $this->elementNr = $egOSMMapsOnThisPage;
|
43 | | - }
|
44 | | -
|
45 | | - /**
|
46 | | - * @see SMMapPrinter::addSpecificMapHTML()
|
47 | | - *
|
48 | | - */
|
49 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
50 | | - global $wgJsMimeType;
|
51 | | -
|
52 | | - $markerItems = array();
|
53 | | -
|
54 | | - foreach ( $this->m_locations as $location ) {
|
55 | | - // Create a string containing the marker JS
|
56 | | - list( $lat, $lon, $title, $label, $icon ) = $location;
|
57 | | -
|
58 | | - $markerItems[] = "getOSMMarkerData($lon, $lat, '$title', '$label', '$icon')";
|
59 | | - }
|
60 | | -
|
61 | | - $markersString = implode( ',', $markerItems );
|
62 | | -
|
63 | | - $this->output .= <<<EOT
|
64 | | - <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', {
|
65 | | - mode: 'osm-wm',
|
66 | | - layer: 'osm-like',
|
67 | | - locale: '$this->lang',
|
68 | | - lat: $this->centreLat,
|
69 | | - lon: $this->centreLon,
|
70 | | - zoom: $this->zoom,
|
71 | | - width: $this->width,
|
72 | | - height: $this->height,
|
73 | | - markers: [$markersString],
|
74 | | - controls: [$this->controls]
|
75 | | - });</script>
|
76 | | -
|
77 | | - <!-- map div -->
|
78 | | - <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
|
79 | | - <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
|
80 | | - <!-- /map div -->
|
81 | | - </div>
|
82 | | -EOT;
|
83 | | - }
|
84 | | -
|
85 | | - /**
|
86 | | - * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list.
|
87 | | - */
|
88 | | - public function getParameters() {
|
89 | | - $params = parent::getParameters();
|
90 | | -
|
91 | | - $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsOSM::getControlNames() );
|
92 | | -
|
93 | | - return $params;
|
94 | | - }
|
95 | | -
|
96 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * A query printer for maps using the Open Layers API optimized for OSM |
| 6 | + * |
| 7 | + * @file SM_OSMQP.php |
| 8 | + * @ingroup SMOSM |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +final class SMOSMQP extends SMMapPrinter { |
| 18 | + |
| 19 | + public $serviceName = MapsOSM::SERVICE_NAME; |
| 20 | + |
| 21 | + /** |
| 22 | + * @see SMMapPrinter::setQueryPrinterSettings() |
| 23 | + * |
| 24 | + */ |
| 25 | + protected function setQueryPrinterSettings() { |
| 26 | + global $egMapsOSMZoom, $egMapsOSMPrefix; |
| 27 | + |
| 28 | + $this->elementNamePrefix = $egMapsOSMPrefix; |
| 29 | + $this->defaultZoom = $egMapsOSMZoom; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @see SMMapPrinter::doMapServiceLoad() |
| 34 | + * |
| 35 | + */ |
| 36 | + protected function doMapServiceLoad() { |
| 37 | + global $egOSMMapsOnThisPage; |
| 38 | + |
| 39 | + MapsOSM::addOSMDependencies( $this->output ); |
| 40 | + $egOSMMapsOnThisPage++; |
| 41 | + |
| 42 | + $this->elementNr = $egOSMMapsOnThisPage; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @see SMMapPrinter::addSpecificMapHTML() |
| 47 | + * |
| 48 | + */ |
| 49 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 50 | + global $wgJsMimeType; |
| 51 | + |
| 52 | + $markerItems = array(); |
| 53 | + |
| 54 | + foreach ( $this->m_locations as $location ) { |
| 55 | + // Create a string containing the marker JS |
| 56 | + list( $lat, $lon, $title, $label, $icon ) = $location; |
| 57 | + |
| 58 | + $markerItems[] = "getOSMMarkerData($lon, $lat, '$title', '$label', '$icon')"; |
| 59 | + } |
| 60 | + |
| 61 | + $markersString = implode( ',', $markerItems ); |
| 62 | + |
| 63 | + $this->output .= <<<EOT |
| 64 | + <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', { |
| 65 | + mode: 'osm-wm', |
| 66 | + layer: 'osm-like', |
| 67 | + locale: '$this->lang', |
| 68 | + lat: $this->centreLat, |
| 69 | + lon: $this->centreLon, |
| 70 | + zoom: $this->zoom, |
| 71 | + width: $this->width, |
| 72 | + height: $this->height, |
| 73 | + markers: [$markersString], |
| 74 | + controls: [$this->controls] |
| 75 | + });</script> |
| 76 | + |
| 77 | + <!-- map div --> |
| 78 | + <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'> |
| 79 | + <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script> |
| 80 | + <!-- /map div --> |
| 81 | + </div> |
| 82 | +EOT; |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list. |
| 87 | + */ |
| 88 | + public function getParameters() { |
| 89 | + $params = parent::getParameters(); |
| 90 | + |
| 91 | + $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsOSM::getControlNames() ); |
| 92 | + |
| 93 | + return $params; |
| 94 | + } |
| 95 | + |
| 96 | +} |
Property changes on: trunk/extensions/SemanticMaps/Services/OpenStreetMap/SM_OSMQP.php |
___________________________________________________________________ |
Added: svn:eol-style |
97 | 97 | + native |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php |
— | — | @@ -1,126 +1,126 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * A class that holds static helper functions and extension hooks for the Google Maps service
|
6 | | - *
|
7 | | - * @file SM_GoogleMapsFormInput.php
|
8 | | - * @ingroup SMGoogleMaps
|
9 | | - *
|
10 | | - * @author Robert Buzink
|
11 | | - * @author Yaron Koren
|
12 | | - * @author Jeroen De Dauw
|
13 | | - */
|
14 | | -
|
15 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
16 | | - die( 'Not an entry point.' );
|
17 | | -}
|
18 | | -
|
19 | | -final class SMGoogleMapsFormInput extends SMFormInput {
|
20 | | -
|
21 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME;
|
22 | | -
|
23 | | - protected $spesificParameters = array();
|
24 | | -
|
25 | | - /**
|
26 | | - * @see MapsMapFeature::setMapSettings()
|
27 | | - *
|
28 | | - */
|
29 | | - protected function setMapSettings() {
|
30 | | - global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
|
31 | | -
|
32 | | - $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
|
33 | | - $this->showAddresFunction = 'showGAddress';
|
34 | | -
|
35 | | - $this->earthZoom = 1;
|
36 | | -
|
37 | | - $this->defaultZoom = $egMapsGoogleMapsZoom;
|
38 | | - }
|
39 | | -
|
40 | | - /**
|
41 | | - * (non-PHPdoc)
|
42 | | - * @see smw/extensions/SemanticMaps/FormInputs/SMFormInput#addFormDependencies()
|
43 | | - */
|
44 | | - protected function addFormDependencies() {
|
45 | | - global $wgJsMimeType;
|
46 | | - global $smgScriptPath, $smgGoogleFormsOnThisPage, $smgStyleVersion, $egMapsJsExt;
|
47 | | -
|
48 | | - MapsGoogleMaps::addGMapDependencies( $this->output );
|
49 | | -
|
50 | | - if ( empty( $smgGoogleFormsOnThisPage ) ) {
|
51 | | - $smgGoogleFormsOnThisPage = 0;
|
52 | | - $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/GoogleMaps/SM_GoogleMapsFunctions{$egMapsJsExt}?$smgStyleVersion'></script>";
|
53 | | - }
|
54 | | - }
|
55 | | -
|
56 | | - /**
|
57 | | - * @see MapsMapFeature::doMapServiceLoad()
|
58 | | - *
|
59 | | - */
|
60 | | - protected function doMapServiceLoad() {
|
61 | | - global $egGoogleMapsOnThisPage, $smgGoogleFormsOnThisPage;
|
62 | | -
|
63 | | - self::addFormDependencies();
|
64 | | -
|
65 | | - $egGoogleMapsOnThisPage++;
|
66 | | - $smgGoogleFormsOnThisPage++;
|
67 | | -
|
68 | | - $this->elementNr = $egGoogleMapsOnThisPage;
|
69 | | - }
|
70 | | -
|
71 | | - /**
|
72 | | - * @see MapsMapFeature::addSpecificFormInputHTML()
|
73 | | - *
|
74 | | - */
|
75 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
76 | | - global $wgOut;
|
77 | | -
|
78 | | - // Remove the overlays control in case it's present.
|
79 | | - if ( in_string( 'overlays', $this->controls ) ) {
|
80 | | - $this->controls = str_replace( ",'overlays'", '', $this->controls );
|
81 | | - $this->controls = str_replace( "'overlays',", '', $this->controls );
|
82 | | - }
|
83 | | -
|
84 | | - $this->output .= Html::element(
|
85 | | - 'div',
|
86 | | - array(
|
87 | | - 'id' => $this->mapName,
|
88 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
89 | | - ),
|
90 | | - wfMsg('maps-loading-map')
|
91 | | - );
|
92 | | -
|
93 | | - $wgOut->addInlineScript( <<<EOT
|
94 | | -addOnloadHook(
|
95 | | - function() {
|
96 | | - makeGoogleMapFormInput(
|
97 | | - '$this->mapName',
|
98 | | - '$this->coordsFieldName',
|
99 | | - {
|
100 | | - lat: $this->centreLat,
|
101 | | - lon: $this->centreLon,
|
102 | | - zoom: $this->zoom,
|
103 | | - type: $this->type,
|
104 | | - types: [$this->types],
|
105 | | - controls: [$this->controls],
|
106 | | - scrollWheelZoom: $this->autozoom
|
107 | | - },
|
108 | | - $this->marker_lat,
|
109 | | - $this->marker_lon
|
110 | | - );
|
111 | | - }
|
112 | | -);
|
113 | | -EOT
|
114 | | - );
|
115 | | - }
|
116 | | -
|
117 | | - /**
|
118 | | - * @see SMFormInput::manageGeocoding()
|
119 | | - *
|
120 | | - */
|
121 | | - protected function manageGeocoding() {
|
122 | | - global $egGoogleMapsKey;
|
123 | | - $this->enableGeocoding = strlen( trim( $egGoogleMapsKey ) ) > 0;
|
124 | | - if ( $this->enableGeocoding ) MapsGoogleMaps::addGMapDependencies( $this->output );
|
125 | | - }
|
126 | | -
|
127 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * A class that holds static helper functions and extension hooks for the Google Maps service |
| 6 | + * |
| 7 | + * @file SM_GoogleMapsFormInput.php |
| 8 | + * @ingroup SMGoogleMaps |
| 9 | + * |
| 10 | + * @author Robert Buzink |
| 11 | + * @author Yaron Koren |
| 12 | + * @author Jeroen De Dauw |
| 13 | + */ |
| 14 | + |
| 15 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 16 | + die( 'Not an entry point.' ); |
| 17 | +} |
| 18 | + |
| 19 | +final class SMGoogleMapsFormInput extends SMFormInput { |
| 20 | + |
| 21 | + public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
| 22 | + |
| 23 | + protected $spesificParameters = array(); |
| 24 | + |
| 25 | + /** |
| 26 | + * @see MapsMapFeature::setMapSettings() |
| 27 | + * |
| 28 | + */ |
| 29 | + protected function setMapSettings() { |
| 30 | + global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix; |
| 31 | + |
| 32 | + $this->elementNamePrefix = $egMapsGoogleMapsPrefix; |
| 33 | + $this->showAddresFunction = 'showGAddress'; |
| 34 | + |
| 35 | + $this->earthZoom = 1; |
| 36 | + |
| 37 | + $this->defaultZoom = $egMapsGoogleMapsZoom; |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * (non-PHPdoc) |
| 42 | + * @see smw/extensions/SemanticMaps/FormInputs/SMFormInput#addFormDependencies() |
| 43 | + */ |
| 44 | + protected function addFormDependencies() { |
| 45 | + global $wgJsMimeType; |
| 46 | + global $smgScriptPath, $smgGoogleFormsOnThisPage, $smgStyleVersion, $egMapsJsExt; |
| 47 | + |
| 48 | + MapsGoogleMaps::addGMapDependencies( $this->output ); |
| 49 | + |
| 50 | + if ( empty( $smgGoogleFormsOnThisPage ) ) { |
| 51 | + $smgGoogleFormsOnThisPage = 0; |
| 52 | + $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/GoogleMaps/SM_GoogleMapsFunctions{$egMapsJsExt}?$smgStyleVersion'></script>"; |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * @see MapsMapFeature::doMapServiceLoad() |
| 58 | + * |
| 59 | + */ |
| 60 | + protected function doMapServiceLoad() { |
| 61 | + global $egGoogleMapsOnThisPage, $smgGoogleFormsOnThisPage; |
| 62 | + |
| 63 | + self::addFormDependencies(); |
| 64 | + |
| 65 | + $egGoogleMapsOnThisPage++; |
| 66 | + $smgGoogleFormsOnThisPage++; |
| 67 | + |
| 68 | + $this->elementNr = $egGoogleMapsOnThisPage; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * @see MapsMapFeature::addSpecificFormInputHTML() |
| 73 | + * |
| 74 | + */ |
| 75 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 76 | + global $wgOut; |
| 77 | + |
| 78 | + // Remove the overlays control in case it's present. |
| 79 | + if ( in_string( 'overlays', $this->controls ) ) { |
| 80 | + $this->controls = str_replace( ",'overlays'", '', $this->controls ); |
| 81 | + $this->controls = str_replace( "'overlays',", '', $this->controls ); |
| 82 | + } |
| 83 | + |
| 84 | + $this->output .= Html::element( |
| 85 | + 'div', |
| 86 | + array( |
| 87 | + 'id' => $this->mapName, |
| 88 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 89 | + ), |
| 90 | + wfMsg('maps-loading-map') |
| 91 | + ); |
| 92 | + |
| 93 | + $wgOut->addInlineScript( <<<EOT |
| 94 | +addOnloadHook( |
| 95 | + function() { |
| 96 | + makeGoogleMapFormInput( |
| 97 | + '$this->mapName', |
| 98 | + '$this->coordsFieldName', |
| 99 | + { |
| 100 | + lat: $this->centreLat, |
| 101 | + lon: $this->centreLon, |
| 102 | + zoom: $this->zoom, |
| 103 | + type: $this->type, |
| 104 | + types: [$this->types], |
| 105 | + controls: [$this->controls], |
| 106 | + scrollWheelZoom: $this->autozoom |
| 107 | + }, |
| 108 | + $this->marker_lat, |
| 109 | + $this->marker_lon |
| 110 | + ); |
| 111 | + } |
| 112 | +); |
| 113 | +EOT |
| 114 | + ); |
| 115 | + } |
| 116 | + |
| 117 | + /** |
| 118 | + * @see SMFormInput::manageGeocoding() |
| 119 | + * |
| 120 | + */ |
| 121 | + protected function manageGeocoding() { |
| 122 | + global $egGoogleMapsKey; |
| 123 | + $this->enableGeocoding = strlen( trim( $egGoogleMapsKey ) ) > 0; |
| 124 | + if ( $this->enableGeocoding ) MapsGoogleMaps::addGMapDependencies( $this->output ); |
| 125 | + } |
| 126 | + |
| 127 | +} |
Property changes on: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php |
___________________________________________________________________ |
Added: svn:eol-style |
128 | 128 | + native |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFunctions.js |
— | — | @@ -1,65 +1,65 @@ |
2 | | - /**
|
3 | | - * Javascript functions for Google Maps functionallity in Semantic Maps
|
4 | | - *
|
5 | | - * @file SM_GoogleMapFunctions.js
|
6 | | - * @ingroup SMGoogleMaps
|
7 | | - *
|
8 | | - * @author Jeroen De Dauw
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This function holds spesific functionallity for the Google Maps form input of Semantic Maps
|
13 | | - * TODO: Refactor as much code as possible to non specific functions
|
14 | | - */
|
15 | | -function makeGoogleMapFormInput(mapName, locationFieldName, mapOptions, marker_lat, marker_lon) {
|
16 | | - if (GBrowserIsCompatible()) {
|
17 | | - mapOptions.centre = new GLatLng(mapOptions.lat, mapOptions.lon);
|
18 | | - var map = createGoogleMap(mapName, mapOptions, [getGMarkerData(marker_lat, marker_lon, '', '', '')]);
|
19 | | -
|
20 | | - // Show a starting marker only if marker coordinates are provided
|
21 | | - if (marker_lat != null && marker_lon != null) {
|
22 | | - map.addOverlay(new GMarker(new GLatLng(marker_lat, marker_lon)));
|
23 | | - }
|
24 | | -
|
25 | | - // Click event handler for updating the location of the marker
|
26 | | - GEvent.addListener(map, "click",
|
27 | | - function(overlay, point) {
|
28 | | - if (overlay) {
|
29 | | - map.removeOverlay(overlay);
|
30 | | - } else {
|
31 | | - map.clearOverlays();
|
32 | | - document.getElementById(locationFieldName).value = convertLatToDMS(point.y)+', '+convertLngToDMS(point.x);
|
33 | | - map.addOverlay(new GMarker(point));
|
34 | | - map.panTo(point);
|
35 | | - }
|
36 | | - }
|
37 | | - );
|
38 | | -
|
39 | | - // Make the map variable available for other functions
|
40 | | - if (!window.GMaps) window.GMaps = new Object;
|
41 | | - eval("window.GMaps." + mapName + " = map;");
|
42 | | - }
|
43 | | -}
|
44 | | -
|
45 | | -/**
|
46 | | - * This function holds spesific functionallity for the Google Maps form input of Semantic Maps
|
47 | | - */
|
48 | | -function showGAddress(address, mapName, outputElementName, notFoundFormat) {
|
49 | | - var map = GMaps[mapName];
|
50 | | - var geocoder = new GClientGeocoder();
|
51 | | -
|
52 | | - geocoder.getLatLng(address,
|
53 | | - function(point) {
|
54 | | - if (!point) {
|
55 | | - window.alert(address + ' ' + notFoundFormat);
|
56 | | - } else {
|
57 | | - map.clearOverlays();
|
58 | | - map.setCenter(point, 14);
|
59 | | - var marker = new GMarker(point);
|
60 | | - map.addOverlay(marker);
|
61 | | - document.getElementById(outputElementName).value = convertLatToDMS(point.y) + ', ' + convertLngToDMS(point.x);
|
62 | | - }
|
63 | | - }
|
64 | | - );
|
65 | | -
|
| 2 | + /** |
| 3 | + * Javascript functions for Google Maps functionallity in Semantic Maps |
| 4 | + * |
| 5 | + * @file SM_GoogleMapFunctions.js |
| 6 | + * @ingroup SMGoogleMaps |
| 7 | + * |
| 8 | + * @author Jeroen De Dauw |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This function holds spesific functionallity for the Google Maps form input of Semantic Maps |
| 13 | + * TODO: Refactor as much code as possible to non specific functions |
| 14 | + */ |
| 15 | +function makeGoogleMapFormInput(mapName, locationFieldName, mapOptions, marker_lat, marker_lon) { |
| 16 | + if (GBrowserIsCompatible()) { |
| 17 | + mapOptions.centre = new GLatLng(mapOptions.lat, mapOptions.lon); |
| 18 | + var map = createGoogleMap(mapName, mapOptions, [getGMarkerData(marker_lat, marker_lon, '', '', '')]); |
| 19 | + |
| 20 | + // Show a starting marker only if marker coordinates are provided |
| 21 | + if (marker_lat != null && marker_lon != null) { |
| 22 | + map.addOverlay(new GMarker(new GLatLng(marker_lat, marker_lon))); |
| 23 | + } |
| 24 | + |
| 25 | + // Click event handler for updating the location of the marker |
| 26 | + GEvent.addListener(map, "click", |
| 27 | + function(overlay, point) { |
| 28 | + if (overlay) { |
| 29 | + map.removeOverlay(overlay); |
| 30 | + } else { |
| 31 | + map.clearOverlays(); |
| 32 | + document.getElementById(locationFieldName).value = convertLatToDMS(point.y)+', '+convertLngToDMS(point.x); |
| 33 | + map.addOverlay(new GMarker(point)); |
| 34 | + map.panTo(point); |
| 35 | + } |
| 36 | + } |
| 37 | + ); |
| 38 | + |
| 39 | + // Make the map variable available for other functions |
| 40 | + if (!window.GMaps) window.GMaps = new Object; |
| 41 | + eval("window.GMaps." + mapName + " = map;"); |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +/** |
| 46 | + * This function holds spesific functionallity for the Google Maps form input of Semantic Maps |
| 47 | + */ |
| 48 | +function showGAddress(address, mapName, outputElementName, notFoundFormat) { |
| 49 | + var map = GMaps[mapName]; |
| 50 | + var geocoder = new GClientGeocoder(); |
| 51 | + |
| 52 | + geocoder.getLatLng(address, |
| 53 | + function(point) { |
| 54 | + if (!point) { |
| 55 | + window.alert(address + ' ' + notFoundFormat); |
| 56 | + } else { |
| 57 | + map.clearOverlays(); |
| 58 | + map.setCenter(point, 14); |
| 59 | + var marker = new GMarker(point); |
| 60 | + map.addOverlay(marker); |
| 61 | + document.getElementById(outputElementName).value = convertLatToDMS(point.y) + ', ' + convertLngToDMS(point.x); |
| 62 | + } |
| 63 | + } |
| 64 | + ); |
| 65 | + |
66 | 66 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
67 | 67 | + native |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMaps.php |
— | — | @@ -1,27 +1,27 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all Google Maps related files of the Semantic Maps extension.
|
6 | | - *
|
7 | | - * @defgroup SMGoogleMaps Google Maps
|
8 | | - * @ingroup SemanticMaps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the Google Maps service.
|
13 | | - *
|
14 | | - * @file SM_GoogleMaps.php
|
15 | | - * @ingroup SMGoogleMaps
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['SMGoogleMapsQP'] = dirname( __FILE__ ) . '/SM_GoogleMapsQP.php';
|
25 | | -$wgAutoloadClasses['SMGoogleMapsFormInput'] = dirname( __FILE__ ) . '/SM_GoogleMapsFormInput.php';
|
26 | | -
|
27 | | -$egMapsServices['googlemaps2']['features']['qp'] = 'SMGoogleMapsQP';
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all Google Maps related files of the Semantic Maps extension. |
| 6 | + * |
| 7 | + * @defgroup SMGoogleMaps Google Maps |
| 8 | + * @ingroup SemanticMaps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the Google Maps service. |
| 13 | + * |
| 14 | + * @file SM_GoogleMaps.php |
| 15 | + * @ingroup SMGoogleMaps |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['SMGoogleMapsQP'] = dirname( __FILE__ ) . '/SM_GoogleMapsQP.php'; |
| 25 | +$wgAutoloadClasses['SMGoogleMapsFormInput'] = dirname( __FILE__ ) . '/SM_GoogleMapsFormInput.php'; |
| 26 | + |
| 27 | +$egMapsServices['googlemaps2']['features']['qp'] = 'SMGoogleMapsQP'; |
28 | 28 | $egMapsServices['googlemaps2']['features']['fi'] = 'SMGoogleMapsFormInput'; |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMaps.php |
___________________________________________________________________ |
Added: svn:eol-style |
29 | 29 | + native |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php |
— | — | @@ -1,131 +1,131 @@ |
2 | | -<?php
|
3 | | -/**
|
4 | | - * A query printer for maps using the Google Maps API
|
5 | | - *
|
6 | | - * @file SM_GoogleMaps.php
|
7 | | - * @ingroup SMGoogleMaps
|
8 | | - *
|
9 | | - * @author Robert Buzink
|
10 | | - * @author Yaron Koren
|
11 | | - * @author Jeroen De Dauw
|
12 | | - */
|
13 | | -
|
14 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
15 | | - die( 'Not an entry point.' );
|
16 | | -}
|
17 | | -
|
18 | | -final class SMGoogleMapsQP extends SMMapPrinter {
|
19 | | -
|
20 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME;
|
21 | | -
|
22 | | - protected $spesificParameters;
|
23 | | -
|
24 | | - /**
|
25 | | - * @see SMMapPrinter::setQueryPrinterSettings()
|
26 | | - *
|
27 | | - */
|
28 | | - protected function setQueryPrinterSettings() {
|
29 | | - global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix, $egMapsGMapOverlays;
|
30 | | -
|
31 | | - $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
|
32 | | -
|
33 | | - $this->defaultZoom = $egMapsGoogleMapsZoom;
|
34 | | -
|
35 | | - $this->spesificParameters = array(
|
36 | | - 'overlays' => array(
|
37 | | - 'type' => array( 'string', 'list' ),
|
38 | | - 'criteria' => array(
|
39 | | - 'is_google_overlay' => array()
|
40 | | - ),
|
41 | | - 'default' => $egMapsGMapOverlays,
|
42 | | - ),
|
43 | | - );
|
44 | | - }
|
45 | | -
|
46 | | - /**
|
47 | | - * @see SMMapPrinter::doMapServiceLoad()
|
48 | | - *
|
49 | | - */
|
50 | | - protected function doMapServiceLoad() {
|
51 | | - global $egGoogleMapsOnThisPage;
|
52 | | -
|
53 | | - if ( empty( $egGoogleMapsOnThisPage ) ) {
|
54 | | - $egGoogleMapsOnThisPage = 0;
|
55 | | - MapsGoogleMaps::addGMapDependencies( $this->output );
|
56 | | - }
|
57 | | -
|
58 | | - $egGoogleMapsOnThisPage++;
|
59 | | -
|
60 | | - $this->elementNr = $egGoogleMapsOnThisPage;
|
61 | | - }
|
62 | | -
|
63 | | - /**
|
64 | | - * @see SMMapPrinter::getQueryResult()
|
65 | | - *
|
66 | | - */
|
67 | | - protected function addSpecificMapHTML( Parser $parser ) {
|
68 | | - MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
|
69 | | -
|
70 | | - // TODO: refactor up like done in maps with display point
|
71 | | - $markerItems = array();
|
72 | | -
|
73 | | - foreach ( $this->m_locations as $location ) {
|
74 | | - list( $lat, $lon, $title, $label, $icon ) = $location;
|
75 | | - $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
|
76 | | - }
|
77 | | -
|
78 | | - // Create a string containing the marker JS.
|
79 | | - $markersString = implode( ',', $markerItems );
|
80 | | -
|
81 | | - $this->output .= Html::element(
|
82 | | - 'div',
|
83 | | - array(
|
84 | | - 'id' => $this->mapName,
|
85 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
86 | | - ),
|
87 | | - wfMsg('maps-loading-map')
|
88 | | - );
|
89 | | -
|
90 | | - $parser->getOutput()->addHeadItem(
|
91 | | - Html::inlineScript( <<<EOT
|
92 | | -addOnloadHook(
|
93 | | - function() {
|
94 | | - initializeGoogleMap('$this->mapName',
|
95 | | - {
|
96 | | - lat: $this->centreLat,
|
97 | | - lon: $this->centreLon,
|
98 | | - zoom: $this->zoom,
|
99 | | - type: $this->type,
|
100 | | - types: [$this->types],
|
101 | | - controls: [$this->controls],
|
102 | | - scrollWheelZoom: $this->autozoom
|
103 | | - },
|
104 | | - [$markersString]
|
105 | | - );
|
106 | | - }
|
107 | | -);
|
108 | | -EOT
|
109 | | - ) );
|
110 | | -
|
111 | | -
|
112 | | - }
|
113 | | -
|
114 | | - /**
|
115 | | - * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list.
|
116 | | - */
|
117 | | - public function getParameters() {
|
118 | | - $params = parent::getParameters();
|
119 | | -
|
120 | | - $allowedTypes = MapsGoogleMaps::getTypeNames();
|
121 | | -
|
122 | | - $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsGoogleMaps::getControlNames() );
|
123 | | - $params[] = array( 'name' => 'types', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_types' ), 'values' => $allowedTypes );
|
124 | | - $params[] = array( 'name' => 'type', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_type' ), 'values' => $allowedTypes );
|
125 | | - $params[] = array( 'name' => 'overlays', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_overlays' ), 'values' => MapsGoogleMaps::getOverlayNames() );
|
126 | | - $params[] = array( 'name' => 'autozoom', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_autozoom' ), 'values' => array( 'on', 'off' ) );
|
127 | | -
|
128 | | - return $params;
|
129 | | - }
|
130 | | -
|
131 | | -}
|
132 | | -
|
| 2 | +<?php |
| 3 | +/** |
| 4 | + * A query printer for maps using the Google Maps API |
| 5 | + * |
| 6 | + * @file SM_GoogleMaps.php |
| 7 | + * @ingroup SMGoogleMaps |
| 8 | + * |
| 9 | + * @author Robert Buzink |
| 10 | + * @author Yaron Koren |
| 11 | + * @author Jeroen De Dauw |
| 12 | + */ |
| 13 | + |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 15 | + die( 'Not an entry point.' ); |
| 16 | +} |
| 17 | + |
| 18 | +final class SMGoogleMapsQP extends SMMapPrinter { |
| 19 | + |
| 20 | + public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
| 21 | + |
| 22 | + protected $spesificParameters; |
| 23 | + |
| 24 | + /** |
| 25 | + * @see SMMapPrinter::setQueryPrinterSettings() |
| 26 | + * |
| 27 | + */ |
| 28 | + protected function setQueryPrinterSettings() { |
| 29 | + global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix, $egMapsGMapOverlays; |
| 30 | + |
| 31 | + $this->elementNamePrefix = $egMapsGoogleMapsPrefix; |
| 32 | + |
| 33 | + $this->defaultZoom = $egMapsGoogleMapsZoom; |
| 34 | + |
| 35 | + $this->spesificParameters = array( |
| 36 | + 'overlays' => array( |
| 37 | + 'type' => array( 'string', 'list' ), |
| 38 | + 'criteria' => array( |
| 39 | + 'is_google_overlay' => array() |
| 40 | + ), |
| 41 | + 'default' => $egMapsGMapOverlays, |
| 42 | + ), |
| 43 | + ); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @see SMMapPrinter::doMapServiceLoad() |
| 48 | + * |
| 49 | + */ |
| 50 | + protected function doMapServiceLoad() { |
| 51 | + global $egGoogleMapsOnThisPage; |
| 52 | + |
| 53 | + if ( empty( $egGoogleMapsOnThisPage ) ) { |
| 54 | + $egGoogleMapsOnThisPage = 0; |
| 55 | + MapsGoogleMaps::addGMapDependencies( $this->output ); |
| 56 | + } |
| 57 | + |
| 58 | + $egGoogleMapsOnThisPage++; |
| 59 | + |
| 60 | + $this->elementNr = $egGoogleMapsOnThisPage; |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * @see SMMapPrinter::getQueryResult() |
| 65 | + * |
| 66 | + */ |
| 67 | + protected function addSpecificMapHTML( Parser $parser ) { |
| 68 | + MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); |
| 69 | + |
| 70 | + // TODO: refactor up like done in maps with display point |
| 71 | + $markerItems = array(); |
| 72 | + |
| 73 | + foreach ( $this->m_locations as $location ) { |
| 74 | + list( $lat, $lon, $title, $label, $icon ) = $location; |
| 75 | + $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')"; |
| 76 | + } |
| 77 | + |
| 78 | + // Create a string containing the marker JS. |
| 79 | + $markersString = implode( ',', $markerItems ); |
| 80 | + |
| 81 | + $this->output .= Html::element( |
| 82 | + 'div', |
| 83 | + array( |
| 84 | + 'id' => $this->mapName, |
| 85 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 86 | + ), |
| 87 | + wfMsg('maps-loading-map') |
| 88 | + ); |
| 89 | + |
| 90 | + $parser->getOutput()->addHeadItem( |
| 91 | + Html::inlineScript( <<<EOT |
| 92 | +addOnloadHook( |
| 93 | + function() { |
| 94 | + initializeGoogleMap('$this->mapName', |
| 95 | + { |
| 96 | + lat: $this->centreLat, |
| 97 | + lon: $this->centreLon, |
| 98 | + zoom: $this->zoom, |
| 99 | + type: $this->type, |
| 100 | + types: [$this->types], |
| 101 | + controls: [$this->controls], |
| 102 | + scrollWheelZoom: $this->autozoom |
| 103 | + }, |
| 104 | + [$markersString] |
| 105 | + ); |
| 106 | + } |
| 107 | +); |
| 108 | +EOT |
| 109 | + ) ); |
| 110 | + |
| 111 | + |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list. |
| 116 | + */ |
| 117 | + public function getParameters() { |
| 118 | + $params = parent::getParameters(); |
| 119 | + |
| 120 | + $allowedTypes = MapsGoogleMaps::getTypeNames(); |
| 121 | + |
| 122 | + $params[] = array( 'name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_controls' ), 'values' => MapsGoogleMaps::getControlNames() ); |
| 123 | + $params[] = array( 'name' => 'types', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_types' ), 'values' => $allowedTypes ); |
| 124 | + $params[] = array( 'name' => 'type', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_type' ), 'values' => $allowedTypes ); |
| 125 | + $params[] = array( 'name' => 'overlays', 'type' => 'enum-list', 'description' => wfMsg( 'semanticmaps_paramdesc_overlays' ), 'values' => MapsGoogleMaps::getOverlayNames() ); |
| 126 | + $params[] = array( 'name' => 'autozoom', 'type' => 'enumeration', 'description' => wfMsg( 'semanticmaps_paramdesc_autozoom' ), 'values' => array( 'on', 'off' ) ); |
| 127 | + |
| 128 | + return $params; |
| 129 | + } |
| 130 | + |
| 131 | +} |
| 132 | + |
Property changes on: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php |
___________________________________________________________________ |
Added: svn:eol-style |
133 | 133 | + native |
Property changes on: trunk/extensions/Storyboard/jquery/css/jquery-ui-1.7.2.custom.css |
___________________________________________________________________ |
Added: svn:eol-style |
134 | 134 | + native |
Property changes on: trunk/extensions/Storyboard/jquery/jquery-ui-1.7.2.custom.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
135 | 135 | + native |
Property changes on: trunk/extensions/JS2Support/UploadWizard/README |
___________________________________________________________________ |
Added: svn:eol-style |
136 | 136 | + native |
Property changes on: trunk/extensions/JS2Support/README |
___________________________________________________________________ |
Added: svn:eol-style |
137 | 137 | + native |
Index: trunk/extensions/Maps/Features/DisplayMap/Maps_DisplayMap.php |
— | — | @@ -1,70 +1,70 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the registration and handling functions for the display_map parser function.
|
6 | | - *
|
7 | | - * @file Maps_DisplayMap.php
|
8 | | - * @ingroup Maps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -$wgAutoloadClasses['MapsDisplayMap'] = __FILE__;
|
18 | | -$wgAutoloadClasses['MapsBaseMap'] = dirname( __FILE__ ) . '/Maps_BaseMap.php';
|
19 | | -
|
20 | | -if ( version_compare( $wgVersion, '1.16alpha', '<' ) ) {
|
21 | | - $wgHooks['LanguageGetMagic'][] = 'efMapsDisplayMapMagic';
|
22 | | -}
|
23 | | -$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterDisplayMap';
|
24 | | -
|
25 | | -$egMapsFeatures['pf'][] = 'MapsDisplayMap::initialize';
|
26 | | -
|
27 | | -/**
|
28 | | - * Adds the magic words for the parser functions.
|
29 | | - */
|
30 | | -function efMapsDisplayMapMagic( &$magicWords, $langCode ) {
|
31 | | - $magicWords['display_map'] = array( 0, 'display_map' );
|
32 | | -
|
33 | | - return true; // Unless we return true, other parser functions won't get loaded.
|
34 | | -}
|
35 | | -
|
36 | | -/**
|
37 | | - * Adds the parser function hooks
|
38 | | - */
|
39 | | -function efMapsRegisterDisplayMap( &$wgParser ) {
|
40 | | - // A hook to enable the '#display_map' parser function.
|
41 | | - $wgParser->setFunctionHook( 'display_map', array( 'MapsDisplayMap', 'displayMapRender' ) );
|
42 | | -
|
43 | | - return true;
|
44 | | -}
|
45 | | -
|
46 | | -/**
|
47 | | - * Class containing the rendering functions for the display_map parser function.
|
48 | | - *
|
49 | | - * @author Jeroen De Dauw
|
50 | | - *
|
51 | | - */
|
52 | | -final class MapsDisplayMap {
|
53 | | -
|
54 | | - public static $parameters = array();
|
55 | | -
|
56 | | - public static function initialize() {
|
57 | | - }
|
58 | | -
|
59 | | - /**
|
60 | | - * Returns the output for a display_map call.
|
61 | | - *
|
62 | | - * @param unknown_type $parser
|
63 | | - *
|
64 | | - * @return array
|
65 | | - */
|
66 | | - public static function displayMapRender( &$parser ) {
|
67 | | - $args = func_get_args();
|
68 | | - return MapsParserFunctions::getMapHtml( $parser, $args, 'display_map' );
|
69 | | - }
|
70 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the registration and handling functions for the display_map parser function. |
| 6 | + * |
| 7 | + * @file Maps_DisplayMap.php |
| 8 | + * @ingroup Maps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +$wgAutoloadClasses['MapsDisplayMap'] = __FILE__; |
| 18 | +$wgAutoloadClasses['MapsBaseMap'] = dirname( __FILE__ ) . '/Maps_BaseMap.php'; |
| 19 | + |
| 20 | +if ( version_compare( $wgVersion, '1.16alpha', '<' ) ) { |
| 21 | + $wgHooks['LanguageGetMagic'][] = 'efMapsDisplayMapMagic'; |
| 22 | +} |
| 23 | +$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterDisplayMap'; |
| 24 | + |
| 25 | +$egMapsFeatures['pf'][] = 'MapsDisplayMap::initialize'; |
| 26 | + |
| 27 | +/** |
| 28 | + * Adds the magic words for the parser functions. |
| 29 | + */ |
| 30 | +function efMapsDisplayMapMagic( &$magicWords, $langCode ) { |
| 31 | + $magicWords['display_map'] = array( 0, 'display_map' ); |
| 32 | + |
| 33 | + return true; // Unless we return true, other parser functions won't get loaded. |
| 34 | +} |
| 35 | + |
| 36 | +/** |
| 37 | + * Adds the parser function hooks |
| 38 | + */ |
| 39 | +function efMapsRegisterDisplayMap( &$wgParser ) { |
| 40 | + // A hook to enable the '#display_map' parser function. |
| 41 | + $wgParser->setFunctionHook( 'display_map', array( 'MapsDisplayMap', 'displayMapRender' ) ); |
| 42 | + |
| 43 | + return true; |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | + * Class containing the rendering functions for the display_map parser function. |
| 48 | + * |
| 49 | + * @author Jeroen De Dauw |
| 50 | + * |
| 51 | + */ |
| 52 | +final class MapsDisplayMap { |
| 53 | + |
| 54 | + public static $parameters = array(); |
| 55 | + |
| 56 | + public static function initialize() { |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Returns the output for a display_map call. |
| 61 | + * |
| 62 | + * @param unknown_type $parser |
| 63 | + * |
| 64 | + * @return array |
| 65 | + */ |
| 66 | + public static function displayMapRender( &$parser ) { |
| 67 | + $args = func_get_args(); |
| 68 | + return MapsParserFunctions::getMapHtml( $parser, $args, 'display_map' ); |
| 69 | + } |
| 70 | + |
71 | 71 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Features/DisplayMap/Maps_DisplayMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
72 | 72 | + native |
Index: trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php |
— | — | @@ -1,134 +1,134 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding class MapsBaseMap.
|
6 | | - *
|
7 | | - * @file Maps_BaseMap.php
|
8 | | - * @ingroup Maps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Abstract class MapsBaseMap provides the scafolding for classes handling display_map
|
19 | | - * calls for a spesific mapping service. It inherits from MapsMapFeature and therefore
|
20 | | - * forces inheriting classes to implement sereveral methods.
|
21 | | - *
|
22 | | - * @ingroup Maps
|
23 | | - *
|
24 | | - * @author Jeroen De Dauw
|
25 | | - */
|
26 | | -abstract class MapsBaseMap implements iMapParserFunction {
|
27 | | -
|
28 | | - public $serviceName;
|
29 | | -
|
30 | | - protected $centreLat, $centreLon;
|
31 | | -
|
32 | | - protected $output = '';
|
33 | | -
|
34 | | - protected $spesificParameters = false;
|
35 | | - protected $featureParameters = false;
|
36 | | -
|
37 | | - /**
|
38 | | - * Sets the map properties as class fields.
|
39 | | - *
|
40 | | - * @param array $mapProperties
|
41 | | - */
|
42 | | - protected function setMapProperties( array $mapProperties ) {
|
43 | | - foreach ( $mapProperties as $paramName => $paramValue ) {
|
44 | | - if ( !property_exists( __CLASS__, $paramName ) ) {
|
45 | | - $this-> { $paramName } = $paramValue;
|
46 | | - }
|
47 | | - else {
|
48 | | - // If this happens in any way, it could be a big vunerability, so throw an exception.
|
49 | | - throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName );
|
50 | | - }
|
51 | | - }
|
52 | | - }
|
53 | | -
|
54 | | - /**
|
55 | | - * @return array
|
56 | | - */
|
57 | | - public function getSpecificParameterInfo() {
|
58 | | - return array();
|
59 | | - }
|
60 | | -
|
61 | | - /**
|
62 | | - * @return array
|
63 | | - */
|
64 | | - public function getFeatureParameters() {
|
65 | | - global $egMapsDefaultServices;
|
66 | | -
|
67 | | - return array(
|
68 | | - 'service' => array(
|
69 | | - 'default' => $egMapsDefaultServices['display_map']
|
70 | | - ),
|
71 | | - 'coordinates' => array(
|
72 | | - 'required' => true,
|
73 | | - 'aliases' => array( 'coords', 'location', 'locations' ),
|
74 | | - 'criteria' => array(
|
75 | | - 'is_location' => array()
|
76 | | - ),
|
77 | | - 'output-type' => 'coordinateSet',
|
78 | | - ),
|
79 | | - );
|
80 | | - }
|
81 | | -
|
82 | | - /**
|
83 | | - * Handles the request from the parser hook by doing the work that's common for all
|
84 | | - * mapping services, calling the specific methods and finally returning the resulting output.
|
85 | | - *
|
86 | | - * @param unknown_type $parser
|
87 | | - * @param array $params
|
88 | | - *
|
89 | | - * @return html
|
90 | | - */
|
91 | | - public final function getMapHtml( Parser &$parser, array $params ) {
|
92 | | - $this->featureParameters = MapsDisplayMap::$parameters;
|
93 | | -
|
94 | | - $this->doMapServiceLoad();
|
95 | | -
|
96 | | - $this->setMapProperties( $params );
|
97 | | -
|
98 | | - $this->setCentre();
|
99 | | -
|
100 | | - if ( $this->zoom == 'null' ) {
|
101 | | - $htis->zoom = $this->getDefaultZoom();
|
102 | | - }
|
103 | | -
|
104 | | - $this->addSpecificMapHTML( $parser );
|
105 | | -
|
106 | | - return $this->output;
|
107 | | - }
|
108 | | -
|
109 | | - /**
|
110 | | - * Sets the $centre_lat and $centre_lon fields.
|
111 | | - */
|
112 | | - private function setCentre() {
|
113 | | - if ( empty( $this->coordinates ) ) { // If centre is not set, use the default latitude and longitutde.
|
114 | | - global $egMapsMapLat, $egMapsMapLon;
|
115 | | - $this->centreLat = $egMapsMapLat;
|
116 | | - $this->centreLon = $egMapsMapLon;
|
117 | | - }
|
118 | | - else { // If a centre value is set, geocode when needed and use it.
|
119 | | - $this->coordinates = MapsGeocoder::attemptToGeocode( $this->coordinates, $this->geoservice, $this->serviceName );
|
120 | | -
|
121 | | - // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde.
|
122 | | - if ( $this->coordinates ) {
|
123 | | - $this->centreLat = Xml::escapeJsString( $this->coordinates['lat'] );
|
124 | | - $this->centreLon = Xml::escapeJsString( $this->coordinates['lon'] );
|
125 | | - }
|
126 | | - else { // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used.
|
127 | | - // TODO: Some warning this failed would be nice here.
|
128 | | - global $egMapsMapLat, $egMapsMapLon;
|
129 | | - $this->centreLat = $egMapsMapLat;
|
130 | | - $this->centreLon = $egMapsMapLon;
|
131 | | - }
|
132 | | - }
|
133 | | - }
|
134 | | -
|
135 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding class MapsBaseMap. |
| 6 | + * |
| 7 | + * @file Maps_BaseMap.php |
| 8 | + * @ingroup Maps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Abstract class MapsBaseMap provides the scafolding for classes handling display_map |
| 19 | + * calls for a spesific mapping service. It inherits from MapsMapFeature and therefore |
| 20 | + * forces inheriting classes to implement sereveral methods. |
| 21 | + * |
| 22 | + * @ingroup Maps |
| 23 | + * |
| 24 | + * @author Jeroen De Dauw |
| 25 | + */ |
| 26 | +abstract class MapsBaseMap implements iMapParserFunction { |
| 27 | + |
| 28 | + public $serviceName; |
| 29 | + |
| 30 | + protected $centreLat, $centreLon; |
| 31 | + |
| 32 | + protected $output = ''; |
| 33 | + |
| 34 | + protected $spesificParameters = false; |
| 35 | + protected $featureParameters = false; |
| 36 | + |
| 37 | + /** |
| 38 | + * Sets the map properties as class fields. |
| 39 | + * |
| 40 | + * @param array $mapProperties |
| 41 | + */ |
| 42 | + protected function setMapProperties( array $mapProperties ) { |
| 43 | + foreach ( $mapProperties as $paramName => $paramValue ) { |
| 44 | + if ( !property_exists( __CLASS__, $paramName ) ) { |
| 45 | + $this-> { $paramName } = $paramValue; |
| 46 | + } |
| 47 | + else { |
| 48 | + // If this happens in any way, it could be a big vunerability, so throw an exception. |
| 49 | + throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName ); |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * @return array |
| 56 | + */ |
| 57 | + public function getSpecificParameterInfo() { |
| 58 | + return array(); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @return array |
| 63 | + */ |
| 64 | + public function getFeatureParameters() { |
| 65 | + global $egMapsDefaultServices; |
| 66 | + |
| 67 | + return array( |
| 68 | + 'service' => array( |
| 69 | + 'default' => $egMapsDefaultServices['display_map'] |
| 70 | + ), |
| 71 | + 'coordinates' => array( |
| 72 | + 'required' => true, |
| 73 | + 'aliases' => array( 'coords', 'location', 'locations' ), |
| 74 | + 'criteria' => array( |
| 75 | + 'is_location' => array() |
| 76 | + ), |
| 77 | + 'output-type' => 'coordinateSet', |
| 78 | + ), |
| 79 | + ); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Handles the request from the parser hook by doing the work that's common for all |
| 84 | + * mapping services, calling the specific methods and finally returning the resulting output. |
| 85 | + * |
| 86 | + * @param unknown_type $parser |
| 87 | + * @param array $params |
| 88 | + * |
| 89 | + * @return html |
| 90 | + */ |
| 91 | + public final function getMapHtml( Parser &$parser, array $params ) { |
| 92 | + $this->featureParameters = MapsDisplayMap::$parameters; |
| 93 | + |
| 94 | + $this->doMapServiceLoad(); |
| 95 | + |
| 96 | + $this->setMapProperties( $params ); |
| 97 | + |
| 98 | + $this->setCentre(); |
| 99 | + |
| 100 | + if ( $this->zoom == 'null' ) { |
| 101 | + $htis->zoom = $this->getDefaultZoom(); |
| 102 | + } |
| 103 | + |
| 104 | + $this->addSpecificMapHTML( $parser ); |
| 105 | + |
| 106 | + return $this->output; |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Sets the $centre_lat and $centre_lon fields. |
| 111 | + */ |
| 112 | + private function setCentre() { |
| 113 | + if ( empty( $this->coordinates ) ) { // If centre is not set, use the default latitude and longitutde. |
| 114 | + global $egMapsMapLat, $egMapsMapLon; |
| 115 | + $this->centreLat = $egMapsMapLat; |
| 116 | + $this->centreLon = $egMapsMapLon; |
| 117 | + } |
| 118 | + else { // If a centre value is set, geocode when needed and use it. |
| 119 | + $this->coordinates = MapsGeocoder::attemptToGeocode( $this->coordinates, $this->geoservice, $this->serviceName ); |
| 120 | + |
| 121 | + // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde. |
| 122 | + if ( $this->coordinates ) { |
| 123 | + $this->centreLat = Xml::escapeJsString( $this->coordinates['lat'] ); |
| 124 | + $this->centreLon = Xml::escapeJsString( $this->coordinates['lon'] ); |
| 125 | + } |
| 126 | + else { // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used. |
| 127 | + // TODO: Some warning this failed would be nice here. |
| 128 | + global $egMapsMapLat, $egMapsMapLon; |
| 129 | + $this->centreLat = $egMapsMapLat; |
| 130 | + $this->centreLon = $egMapsMapLon; |
| 131 | + } |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | +} |
Property changes on: trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
136 | 136 | + native |
Index: trunk/extensions/Maps/Features/Maps_ParserFunctions.php |
— | — | @@ -1,135 +1,135 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Initialization file for parser function functionality in the Maps extension
|
6 | | - *
|
7 | | - * @file Maps_ParserFunctions.php
|
8 | | - * @ingroup Maps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -$wgAutoloadClasses['MapsParserFunctions'] = __FILE__;
|
18 | | -
|
19 | | -$wgHooks['MappingFeatureLoad'][] = 'MapsParserFunctions::initialize';
|
20 | | -
|
21 | | -/**
|
22 | | - * A class that holds handlers for the mapping parser functions.
|
23 | | - *
|
24 | | - * @author Jeroen De Dauw
|
25 | | - */
|
26 | | -final class MapsParserFunctions {
|
27 | | -
|
28 | | - /**
|
29 | | - * Initialize the parser functions feature. This function handles the parser function hook,
|
30 | | - * and will load the required classes.
|
31 | | - */
|
32 | | - public static function initialize() {
|
33 | | - global $egMapsDir, $egMapsFeatures;
|
34 | | -
|
35 | | - include_once dirname( __FILE__ ) . '/Maps_iMapParserFunction.php';
|
36 | | -
|
37 | | - // This runs a small hook that enables parser functions to run initialization code.
|
38 | | - foreach ( $egMapsFeatures['pf'] as $hook ) {
|
39 | | - call_user_func( $hook );
|
40 | | - }
|
41 | | -
|
42 | | - return true;
|
43 | | - }
|
44 | | -
|
45 | | - /**
|
46 | | - * Returns the output for the call to the specified parser function.
|
47 | | - *
|
48 | | - * @param Parser $parser
|
49 | | - * @param array $params
|
50 | | - * @param string $parserFunction
|
51 | | - *
|
52 | | - * @return array
|
53 | | - */
|
54 | | - public static function getMapHtml( Parser &$parser, array $args, $parserFunction ) {
|
55 | | - global $wgLang, $egValidatorErrorLevel, $egValidatorFatalLevel, $egMapsServices;
|
56 | | -
|
57 | | - array_shift( $args ); // We already know the $parser.
|
58 | | -
|
59 | | - $parameters = array();
|
60 | | - $setService = false;
|
61 | | -
|
62 | | - foreach( $args as $arg ) {
|
63 | | - $split = explode( '=', $arg );
|
64 | | - $name = strtolower( trim( array_shift( $split ) ) );
|
65 | | - if ( count( $split ) > 0 && self::inParamAliases( $name, 'service', MapsMapper::getCommonParameters() ) ) {
|
66 | | - if ( !$setService ) {
|
67 | | - $service = implode( '=', $split );
|
68 | | - $parameters[] = 'service=' . $service;
|
69 | | - $setService = true;
|
70 | | - }
|
71 | | - } else {
|
72 | | - $parameters[] = $arg;
|
73 | | - }
|
74 | | - }
|
75 | | -
|
76 | | - $service = MapsMapper::getValidService( $setService ? $service : '', $parserFunction );
|
77 | | - $mapClass = new $egMapsServices[$service]['features'][$parserFunction]();
|
78 | | -
|
79 | | - $manager = new ValidatorManager();
|
80 | | -
|
81 | | - /*
|
82 | | - * Assembliy of the allowed parameters and their information.
|
83 | | - * The main parameters (the ones that are shared by everything) are overidden
|
84 | | - * by the feature parameters (the ones spesific to a feature). The result is then
|
85 | | - * again overidden by the service parameters (the ones spesific to the service),
|
86 | | - * and finally by the spesific parameters (the ones spesific to a service-feature combination).
|
87 | | - */
|
88 | | - $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), $mapClass->getFeatureParameters() );
|
89 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$service]['parameters'] );
|
90 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $mapClass->getSpecificParameterInfo() );
|
91 | | -
|
92 | | - $parameters = $manager->manageParameters(
|
93 | | - $parameters,
|
94 | | - $parameterInfo,
|
95 | | - array( 'coordinates' )
|
96 | | - );
|
97 | | -
|
98 | | - $displayMap = $parameters !== false;
|
99 | | -
|
100 | | - if ( $displayMap ) {
|
101 | | - // Call the function according to the map service to get the HTML output.
|
102 | | - $output = $mapClass->getMapHtml( $parser, $parameters ) . $manager->getErrorList();
|
103 | | - } else {
|
104 | | - // TODO: Get failiures
|
105 | | - if ( $egValidatorFatalLevel == Validator_ERRORS_WARN ) {
|
106 | | - $output .= htmlspecialchars( wfMsg( '' ) );
|
107 | | - } elseif ( $egValidatorFatalLevel > Validator_ERRORS_WARN ) {
|
108 | | - $output .= htmlspecialchars( wfMsg( '' ) );
|
109 | | - }
|
110 | | - }
|
111 | | -
|
112 | | - // Return the result.
|
113 | | - return array( $output, 'noparse' => true, 'isHTML' => true );
|
114 | | - }
|
115 | | -
|
116 | | - /**
|
117 | | - * Gets if a provided name is present in the aliases array of a parameter
|
118 | | - * name in the $mainParams array.
|
119 | | - *
|
120 | | - * @param string $name The name you want to check for.
|
121 | | - * @param string $mainParamName The main parameter name.
|
122 | | - * @param array $paramInfo Contains meta data, including aliases, of the possible parameters.
|
123 | | - * @param boolean $compareMainName Boolean indicating wether the main name should also be compared.
|
124 | | - *
|
125 | | - * @return boolean
|
126 | | - */
|
127 | | - public static function inParamAliases( $name, $mainParamName, array $paramInfo = array(), $compareMainName = true ) {
|
128 | | - $equals = $compareMainName && $mainParamName == $name;
|
129 | | -
|
130 | | - if ( !$equals && array_key_exists( $mainParamName, $paramInfo ) ) {
|
131 | | - $equals = in_array( $name, $paramInfo[$mainParamName] );
|
132 | | - }
|
133 | | -
|
134 | | - return $equals;
|
135 | | - }
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Initialization file for parser function functionality in the Maps extension |
| 6 | + * |
| 7 | + * @file Maps_ParserFunctions.php |
| 8 | + * @ingroup Maps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +$wgAutoloadClasses['MapsParserFunctions'] = __FILE__; |
| 18 | + |
| 19 | +$wgHooks['MappingFeatureLoad'][] = 'MapsParserFunctions::initialize'; |
| 20 | + |
| 21 | +/** |
| 22 | + * A class that holds handlers for the mapping parser functions. |
| 23 | + * |
| 24 | + * @author Jeroen De Dauw |
| 25 | + */ |
| 26 | +final class MapsParserFunctions { |
| 27 | + |
| 28 | + /** |
| 29 | + * Initialize the parser functions feature. This function handles the parser function hook, |
| 30 | + * and will load the required classes. |
| 31 | + */ |
| 32 | + public static function initialize() { |
| 33 | + global $egMapsDir, $egMapsFeatures; |
| 34 | + |
| 35 | + include_once dirname( __FILE__ ) . '/Maps_iMapParserFunction.php'; |
| 36 | + |
| 37 | + // This runs a small hook that enables parser functions to run initialization code. |
| 38 | + foreach ( $egMapsFeatures['pf'] as $hook ) { |
| 39 | + call_user_func( $hook ); |
| 40 | + } |
| 41 | + |
| 42 | + return true; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Returns the output for the call to the specified parser function. |
| 47 | + * |
| 48 | + * @param Parser $parser |
| 49 | + * @param array $params |
| 50 | + * @param string $parserFunction |
| 51 | + * |
| 52 | + * @return array |
| 53 | + */ |
| 54 | + public static function getMapHtml( Parser &$parser, array $args, $parserFunction ) { |
| 55 | + global $wgLang, $egValidatorErrorLevel, $egValidatorFatalLevel, $egMapsServices; |
| 56 | + |
| 57 | + array_shift( $args ); // We already know the $parser. |
| 58 | + |
| 59 | + $parameters = array(); |
| 60 | + $setService = false; |
| 61 | + |
| 62 | + foreach( $args as $arg ) { |
| 63 | + $split = explode( '=', $arg ); |
| 64 | + $name = strtolower( trim( array_shift( $split ) ) ); |
| 65 | + if ( count( $split ) > 0 && self::inParamAliases( $name, 'service', MapsMapper::getCommonParameters() ) ) { |
| 66 | + if ( !$setService ) { |
| 67 | + $service = implode( '=', $split ); |
| 68 | + $parameters[] = 'service=' . $service; |
| 69 | + $setService = true; |
| 70 | + } |
| 71 | + } else { |
| 72 | + $parameters[] = $arg; |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + $service = MapsMapper::getValidService( $setService ? $service : '', $parserFunction ); |
| 77 | + $mapClass = new $egMapsServices[$service]['features'][$parserFunction](); |
| 78 | + |
| 79 | + $manager = new ValidatorManager(); |
| 80 | + |
| 81 | + /* |
| 82 | + * Assembliy of the allowed parameters and their information. |
| 83 | + * The main parameters (the ones that are shared by everything) are overidden |
| 84 | + * by the feature parameters (the ones spesific to a feature). The result is then |
| 85 | + * again overidden by the service parameters (the ones spesific to the service), |
| 86 | + * and finally by the spesific parameters (the ones spesific to a service-feature combination). |
| 87 | + */ |
| 88 | + $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), $mapClass->getFeatureParameters() ); |
| 89 | + $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$service]['parameters'] ); |
| 90 | + $parameterInfo = array_merge_recursive( $parameterInfo, $mapClass->getSpecificParameterInfo() ); |
| 91 | + |
| 92 | + $parameters = $manager->manageParameters( |
| 93 | + $parameters, |
| 94 | + $parameterInfo, |
| 95 | + array( 'coordinates' ) |
| 96 | + ); |
| 97 | + |
| 98 | + $displayMap = $parameters !== false; |
| 99 | + |
| 100 | + if ( $displayMap ) { |
| 101 | + // Call the function according to the map service to get the HTML output. |
| 102 | + $output = $mapClass->getMapHtml( $parser, $parameters ) . $manager->getErrorList(); |
| 103 | + } else { |
| 104 | + // TODO: Get failiures |
| 105 | + if ( $egValidatorFatalLevel == Validator_ERRORS_WARN ) { |
| 106 | + $output .= htmlspecialchars( wfMsg( '' ) ); |
| 107 | + } elseif ( $egValidatorFatalLevel > Validator_ERRORS_WARN ) { |
| 108 | + $output .= htmlspecialchars( wfMsg( '' ) ); |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + // Return the result. |
| 113 | + return array( $output, 'noparse' => true, 'isHTML' => true ); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Gets if a provided name is present in the aliases array of a parameter |
| 118 | + * name in the $mainParams array. |
| 119 | + * |
| 120 | + * @param string $name The name you want to check for. |
| 121 | + * @param string $mainParamName The main parameter name. |
| 122 | + * @param array $paramInfo Contains meta data, including aliases, of the possible parameters. |
| 123 | + * @param boolean $compareMainName Boolean indicating wether the main name should also be compared. |
| 124 | + * |
| 125 | + * @return boolean |
| 126 | + */ |
| 127 | + public static function inParamAliases( $name, $mainParamName, array $paramInfo = array(), $compareMainName = true ) { |
| 128 | + $equals = $compareMainName && $mainParamName == $name; |
| 129 | + |
| 130 | + if ( !$equals && array_key_exists( $mainParamName, $paramInfo ) ) { |
| 131 | + $equals = in_array( $name, $paramInfo[$mainParamName] ); |
| 132 | + } |
| 133 | + |
| 134 | + return $equals; |
| 135 | + } |
136 | 136 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Features/Maps_ParserFunctions.php |
___________________________________________________________________ |
Added: svn:eol-style |
137 | 137 | + native |
Index: trunk/extensions/Maps/Features/DisplayPoint/Maps_DisplayPoint.php |
— | — | @@ -1,71 +1,71 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the registration and handling functions for the display_point parser function.
|
6 | | - *
|
7 | | - * @file Maps_DisplayPoint.php
|
8 | | - * @ingroup Maps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -$wgAutoloadClasses['MapsDisplayPoint'] = __FILE__;
|
18 | | -$wgAutoloadClasses['MapsBasePointMap'] = dirname( __FILE__ ) . '/Maps_BasePointMap.php';
|
19 | | -
|
20 | | -if ( version_compare( $wgVersion, '1.16alpha', '<' ) ) {
|
21 | | - $wgHooks['LanguageGetMagic'][] = 'efMapsDisplayPointMagic';
|
22 | | -}
|
23 | | -$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterDisplayPoint';
|
24 | | -
|
25 | | -$egMapsFeatures['pf'][] = 'MapsDisplayPoint::initialize';
|
26 | | -
|
27 | | -/**
|
28 | | - * Adds the magic words for the parser functions.
|
29 | | - */
|
30 | | -function efMapsDisplayPointMagic( &$magicWords, $langCode ) {
|
31 | | - // The display_address(es) aliases are for backward compatibility only, and will be removed eventually.
|
32 | | - $magicWords['display_point'] = array( 0, 'display_point', 'display_points' );
|
33 | | -
|
34 | | - return true; // Unless we return true, other parser functions won't get loaded.
|
35 | | -}
|
36 | | -
|
37 | | -/**
|
38 | | - * Adds the parser function hooks
|
39 | | - */
|
40 | | -function efMapsRegisterDisplayPoint( &$wgParser ) {
|
41 | | - // Hooks to enable the '#display_point' and '#display_points' parser functions.
|
42 | | - $wgParser->setFunctionHook( 'display_point', array( 'MapsDisplayPoint', 'displayPointRender' ) );
|
43 | | -
|
44 | | - return true;
|
45 | | -}
|
46 | | -
|
47 | | -/**
|
48 | | - * Class containing the rendering functions for the display_point parser function.
|
49 | | - *
|
50 | | - * @author Jeroen De Dauw
|
51 | | - *
|
52 | | - */
|
53 | | -final class MapsDisplayPoint {
|
54 | | -
|
55 | | - public static $parameters = array();
|
56 | | -
|
57 | | - public static function initialize() {
|
58 | | - }
|
59 | | -
|
60 | | - /**
|
61 | | - * Returns the output for a display_point call.
|
62 | | - *
|
63 | | - * @param unknown_type $parser
|
64 | | - *
|
65 | | - * @return array
|
66 | | - */
|
67 | | - public static function displayPointRender( &$parser ) {
|
68 | | - $args = func_get_args();
|
69 | | - return MapsParserFunctions::getMapHtml( $parser, $args, 'display_point' );
|
70 | | - }
|
71 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the registration and handling functions for the display_point parser function. |
| 6 | + * |
| 7 | + * @file Maps_DisplayPoint.php |
| 8 | + * @ingroup Maps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +$wgAutoloadClasses['MapsDisplayPoint'] = __FILE__; |
| 18 | +$wgAutoloadClasses['MapsBasePointMap'] = dirname( __FILE__ ) . '/Maps_BasePointMap.php'; |
| 19 | + |
| 20 | +if ( version_compare( $wgVersion, '1.16alpha', '<' ) ) { |
| 21 | + $wgHooks['LanguageGetMagic'][] = 'efMapsDisplayPointMagic'; |
| 22 | +} |
| 23 | +$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterDisplayPoint'; |
| 24 | + |
| 25 | +$egMapsFeatures['pf'][] = 'MapsDisplayPoint::initialize'; |
| 26 | + |
| 27 | +/** |
| 28 | + * Adds the magic words for the parser functions. |
| 29 | + */ |
| 30 | +function efMapsDisplayPointMagic( &$magicWords, $langCode ) { |
| 31 | + // The display_address(es) aliases are for backward compatibility only, and will be removed eventually. |
| 32 | + $magicWords['display_point'] = array( 0, 'display_point', 'display_points' ); |
| 33 | + |
| 34 | + return true; // Unless we return true, other parser functions won't get loaded. |
| 35 | +} |
| 36 | + |
| 37 | +/** |
| 38 | + * Adds the parser function hooks |
| 39 | + */ |
| 40 | +function efMapsRegisterDisplayPoint( &$wgParser ) { |
| 41 | + // Hooks to enable the '#display_point' and '#display_points' parser functions. |
| 42 | + $wgParser->setFunctionHook( 'display_point', array( 'MapsDisplayPoint', 'displayPointRender' ) ); |
| 43 | + |
| 44 | + return true; |
| 45 | +} |
| 46 | + |
| 47 | +/** |
| 48 | + * Class containing the rendering functions for the display_point parser function. |
| 49 | + * |
| 50 | + * @author Jeroen De Dauw |
| 51 | + * |
| 52 | + */ |
| 53 | +final class MapsDisplayPoint { |
| 54 | + |
| 55 | + public static $parameters = array(); |
| 56 | + |
| 57 | + public static function initialize() { |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Returns the output for a display_point call. |
| 62 | + * |
| 63 | + * @param unknown_type $parser |
| 64 | + * |
| 65 | + * @return array |
| 66 | + */ |
| 67 | + public static function displayPointRender( &$parser ) { |
| 68 | + $args = func_get_args(); |
| 69 | + return MapsParserFunctions::getMapHtml( $parser, $args, 'display_point' ); |
| 70 | + } |
| 71 | + |
72 | 72 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Features/DisplayPoint/Maps_DisplayPoint.php |
___________________________________________________________________ |
Added: svn:eol-style |
73 | 73 | + native |
Index: trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php |
— | — | @@ -1,244 +1,244 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding class MapsBasePointMap.
|
6 | | - *
|
7 | | - * @file Maps_BasePointMap.php
|
8 | | - * @ingroup Maps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Abstract class MapsBasePointMap provides the scafolding for classes handling display_point(s)
|
19 | | - * calls for a spesific mapping service. It inherits from MapsMapFeature and therefore forces
|
20 | | - * inheriting classes to implement sereveral methods.
|
21 | | - *
|
22 | | - * @ingroup Maps
|
23 | | - *
|
24 | | - * @author Jeroen De Dauw
|
25 | | - */
|
26 | | -abstract class MapsBasePointMap implements iMapParserFunction {
|
27 | | -
|
28 | | - public $serviceName;
|
29 | | -
|
30 | | - protected $centreLat, $centreLon;
|
31 | | -
|
32 | | - protected $output = '';
|
33 | | -
|
34 | | - protected $spesificParameters = false;
|
35 | | - protected $featureParameters = false;
|
36 | | -
|
37 | | - private $markerData = array();
|
38 | | - protected $markerString;
|
39 | | -
|
40 | | - /**
|
41 | | - * Sets the map properties as class fields.
|
42 | | - *
|
43 | | - * @param array $mapProperties
|
44 | | - */
|
45 | | - protected function setMapProperties( array $mapProperties ) {
|
46 | | - foreach ( $mapProperties as $paramName => $paramValue ) {
|
47 | | - if ( !property_exists( __CLASS__, $paramName ) ) {
|
48 | | - $this-> { $paramName } = $paramValue;
|
49 | | - }
|
50 | | - else {
|
51 | | - // If this happens in any way, it could be a big vunerability, so throw an exception.
|
52 | | - throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName );
|
53 | | - }
|
54 | | - }
|
55 | | - }
|
56 | | -
|
57 | | - /**
|
58 | | - * @return array
|
59 | | - */
|
60 | | - public function getSpecificParameterInfo() {
|
61 | | - return array();
|
62 | | - }
|
63 | | -
|
64 | | - /**
|
65 | | - * @return array
|
66 | | - */
|
67 | | - public function getFeatureParameters() {
|
68 | | - global $egMapsDefaultServices, $egMapsDefaultTitle, $egMapsDefaultLabel;
|
69 | | -
|
70 | | - return array(
|
71 | | - 'service' => array(
|
72 | | - 'default' => $egMapsDefaultServices['display_point']
|
73 | | - ),
|
74 | | - 'centre' => array(
|
75 | | - 'aliases' => array( 'center' ),
|
76 | | - ),
|
77 | | - 'title' => array(
|
78 | | - 'default' => $egMapsDefaultTitle
|
79 | | - ),
|
80 | | - 'label' => array(
|
81 | | - 'default' => $egMapsDefaultLabel
|
82 | | - ),
|
83 | | - 'icon' => array(
|
84 | | - 'criteria' => array(
|
85 | | - 'not_empty' => array()
|
86 | | - )
|
87 | | - ),
|
88 | | - 'coordinates' => array(
|
89 | | - 'required' => true,
|
90 | | - 'type' => array( 'string', 'list', ';' ),
|
91 | | - 'aliases' => array( 'coords', 'location', 'locations' ),
|
92 | | - 'criteria' => array(
|
93 | | - 'are_locations' => array()
|
94 | | - ),
|
95 | | - 'output-type' => 'coordinateSets',
|
96 | | - ),
|
97 | | - );
|
98 | | - }
|
99 | | -
|
100 | | - /**
|
101 | | - * Handles the request from the parser hook by doing the work that's common for all
|
102 | | - * mapping services, calling the specific methods and finally returning the resulting output.
|
103 | | - *
|
104 | | - * @param Parser $parser
|
105 | | - * @param array $params
|
106 | | - *
|
107 | | - * @return html
|
108 | | - */
|
109 | | - public final function getMapHtml( Parser &$parser, array $params ) {
|
110 | | - $this->featureParameters = MapsDisplayPoint::$parameters;
|
111 | | -
|
112 | | - $this->doMapServiceLoad();
|
113 | | -
|
114 | | - $this->setMapProperties( $params );
|
115 | | -
|
116 | | - $this->setMarkerData( $parser );
|
117 | | -
|
118 | | - $this->createMarkerString();
|
119 | | -
|
120 | | - $this->setCentre();
|
121 | | -
|
122 | | - if ( count( $this->markerData ) <= 1 && $this->zoom == 'null' ) {
|
123 | | - $this->zoom = $this->getDefaultZoom();
|
124 | | - }
|
125 | | -
|
126 | | - $this->addSpecificMapHTML( $parser );
|
127 | | -
|
128 | | - return $this->output;
|
129 | | - }
|
130 | | -
|
131 | | - /**
|
132 | | - * Fills the $markerData array with the locations and their meta data.
|
133 | | - *
|
134 | | - * @param unknown_type $parser
|
135 | | - */
|
136 | | - private function setMarkerData( $parser ) {
|
137 | | - $this->title = Xml::escapeJsString( $parser->recursiveTagParse( $this->title ) );
|
138 | | - $this->label = Xml::escapeJsString( $parser->recursiveTagParse( $this->label ) );
|
139 | | -
|
140 | | - foreach ( $this->coordinates as $coordinates ) {
|
141 | | - $args = explode( '~', $coordinates );
|
142 | | -
|
143 | | - $markerData = MapsCoordinateParser::parseCoordinates( $args[0] );
|
144 | | -
|
145 | | - if ( !$markerData ) continue;
|
146 | | -
|
147 | | - if ( count( $args ) > 1 ) {
|
148 | | - // Parse and add the point specific title if it's present.
|
149 | | - $markerData['title'] = $parser->recursiveTagParse( $args[1] );
|
150 | | -
|
151 | | - if ( count( $args ) > 2 ) {
|
152 | | - // Parse and add the point specific label if it's present.
|
153 | | - $markerData['label'] = $parser->recursiveTagParse( $args[2] );
|
154 | | -
|
155 | | - if ( count( $args ) > 3 ) {
|
156 | | - // Add the point specific icon if it's present.
|
157 | | - $markerData['icon'] = $args[3];
|
158 | | - }
|
159 | | - }
|
160 | | - }
|
161 | | -
|
162 | | - // If there is no point specific icon, use the general icon parameter when available.
|
163 | | - if ( ! array_key_exists( 'icon', $markerData ) && strlen( $this->icon ) > 0 ) $markerData['icon'] = $this->icon;
|
164 | | -
|
165 | | - // Get the url for the icon when there is one, else set the icon to an empty string.
|
166 | | - if ( array_key_exists( 'icon', $markerData ) ) {
|
167 | | - $icon_image_page = new ImagePage( Title::newFromText( $markerData['icon'] ) );
|
168 | | - $markerData['icon'] = $icon_image_page->getDisplayedFile()->getURL();
|
169 | | - }
|
170 | | - else {
|
171 | | - $markerData['icon'] = '';
|
172 | | - }
|
173 | | -
|
174 | | - $this->markerData[] = $markerData;
|
175 | | - }
|
176 | | - }
|
177 | | -
|
178 | | - /**
|
179 | | - * Creates a JS string with the marker data. Takes care of escaping the used values.
|
180 | | - */
|
181 | | - private function createMarkerString() {
|
182 | | - $markerItems = array();
|
183 | | -
|
184 | | - foreach ( $this->markerData as $markerData ) {
|
185 | | - $title = array_key_exists( 'title', $markerData ) ? Xml::escapeJsString( $markerData['title'] ) : $this->title;
|
186 | | - $label = array_key_exists( 'label', $markerData ) ? Xml::escapeJsString( $markerData['label'] ) : $this->label;
|
187 | | -
|
188 | | - $markerData['lon'] = Xml::escapeJsString( $markerData['lon'] );
|
189 | | - $markerData['lat'] = Xml::escapeJsString( $markerData['lat'] );
|
190 | | - $markerData['icon'] = Xml::escapeJsString( $markerData['icon'] );
|
191 | | -
|
192 | | - $markerItems[] = str_replace( array( 'lon', 'lat', 'title', 'label', 'icon' ),
|
193 | | - array( $markerData['lon'], $markerData['lat'], $title, $label, $markerData['icon'] ),
|
194 | | - $this->markerStringFormat
|
195 | | - );
|
196 | | - }
|
197 | | -
|
198 | | - $this->markerString = implode( ',', $markerItems );
|
199 | | - }
|
200 | | -
|
201 | | - /**
|
202 | | - * Sets the $centre_lat and $centre_lon fields.
|
203 | | - * Note: this needs to be done AFTRE the maker coordinates are set.
|
204 | | - */
|
205 | | - private function setCentre() {
|
206 | | - if ( empty( $this->centre ) ) {
|
207 | | - if ( count( $this->markerData ) == 1 ) {
|
208 | | - // If centre is not set and there is exactelly one marker, use it's coordinates.
|
209 | | - $this->centreLat = Xml::escapeJsString( $this->markerData[0]['lat'] );
|
210 | | - $this->centreLon = Xml::escapeJsString( $this->markerData[0]['lon'] );
|
211 | | - }
|
212 | | - elseif ( count( $this->markerData ) > 1 ) {
|
213 | | - // If centre is not set and there are multiple markers, set the values to null,
|
214 | | - // to be auto determined by the JS of the mapping API.
|
215 | | - $this->centreLat = 'null';
|
216 | | - $this->centreLon = 'null';
|
217 | | - }
|
218 | | - else {
|
219 | | - // If centre is not set and there are no markers, use the default latitude and longitutde.
|
220 | | - $this->setCentreDefaults();
|
221 | | - }
|
222 | | - }
|
223 | | - else { // If a centre value is set, geocode when needed and use it.
|
224 | | - $this->centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName );
|
225 | | -
|
226 | | - // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde.
|
227 | | - if ( $this->centre ) {
|
228 | | - $this->centreLat = Xml::escapeJsString( $this->centre['lat'] );
|
229 | | - $this->centreLon = Xml::escapeJsString( $this->centre['lon'] );
|
230 | | - }
|
231 | | - else { // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used.
|
232 | | - $this->setCentreDefaults();
|
233 | | - }
|
234 | | - }
|
235 | | - }
|
236 | | -
|
237 | | - /**
|
238 | | - * Sets the centre latitude and longitutde to the defaults.
|
239 | | - */
|
240 | | - private function setCentreDefaults() {
|
241 | | - global $egMapsMapLat, $egMapsMapLon;
|
242 | | - $this->centreLat = $egMapsMapLat;
|
243 | | - $this->centreLon = $egMapsMapLon;
|
244 | | - }
|
245 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding class MapsBasePointMap. |
| 6 | + * |
| 7 | + * @file Maps_BasePointMap.php |
| 8 | + * @ingroup Maps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Abstract class MapsBasePointMap provides the scafolding for classes handling display_point(s) |
| 19 | + * calls for a spesific mapping service. It inherits from MapsMapFeature and therefore forces |
| 20 | + * inheriting classes to implement sereveral methods. |
| 21 | + * |
| 22 | + * @ingroup Maps |
| 23 | + * |
| 24 | + * @author Jeroen De Dauw |
| 25 | + */ |
| 26 | +abstract class MapsBasePointMap implements iMapParserFunction { |
| 27 | + |
| 28 | + public $serviceName; |
| 29 | + |
| 30 | + protected $centreLat, $centreLon; |
| 31 | + |
| 32 | + protected $output = ''; |
| 33 | + |
| 34 | + protected $spesificParameters = false; |
| 35 | + protected $featureParameters = false; |
| 36 | + |
| 37 | + private $markerData = array(); |
| 38 | + protected $markerString; |
| 39 | + |
| 40 | + /** |
| 41 | + * Sets the map properties as class fields. |
| 42 | + * |
| 43 | + * @param array $mapProperties |
| 44 | + */ |
| 45 | + protected function setMapProperties( array $mapProperties ) { |
| 46 | + foreach ( $mapProperties as $paramName => $paramValue ) { |
| 47 | + if ( !property_exists( __CLASS__, $paramName ) ) { |
| 48 | + $this-> { $paramName } = $paramValue; |
| 49 | + } |
| 50 | + else { |
| 51 | + // If this happens in any way, it could be a big vunerability, so throw an exception. |
| 52 | + throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName ); |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @return array |
| 59 | + */ |
| 60 | + public function getSpecificParameterInfo() { |
| 61 | + return array(); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * @return array |
| 66 | + */ |
| 67 | + public function getFeatureParameters() { |
| 68 | + global $egMapsDefaultServices, $egMapsDefaultTitle, $egMapsDefaultLabel; |
| 69 | + |
| 70 | + return array( |
| 71 | + 'service' => array( |
| 72 | + 'default' => $egMapsDefaultServices['display_point'] |
| 73 | + ), |
| 74 | + 'centre' => array( |
| 75 | + 'aliases' => array( 'center' ), |
| 76 | + ), |
| 77 | + 'title' => array( |
| 78 | + 'default' => $egMapsDefaultTitle |
| 79 | + ), |
| 80 | + 'label' => array( |
| 81 | + 'default' => $egMapsDefaultLabel |
| 82 | + ), |
| 83 | + 'icon' => array( |
| 84 | + 'criteria' => array( |
| 85 | + 'not_empty' => array() |
| 86 | + ) |
| 87 | + ), |
| 88 | + 'coordinates' => array( |
| 89 | + 'required' => true, |
| 90 | + 'type' => array( 'string', 'list', ';' ), |
| 91 | + 'aliases' => array( 'coords', 'location', 'locations' ), |
| 92 | + 'criteria' => array( |
| 93 | + 'are_locations' => array() |
| 94 | + ), |
| 95 | + 'output-type' => 'coordinateSets', |
| 96 | + ), |
| 97 | + ); |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Handles the request from the parser hook by doing the work that's common for all |
| 102 | + * mapping services, calling the specific methods and finally returning the resulting output. |
| 103 | + * |
| 104 | + * @param Parser $parser |
| 105 | + * @param array $params |
| 106 | + * |
| 107 | + * @return html |
| 108 | + */ |
| 109 | + public final function getMapHtml( Parser &$parser, array $params ) { |
| 110 | + $this->featureParameters = MapsDisplayPoint::$parameters; |
| 111 | + |
| 112 | + $this->doMapServiceLoad(); |
| 113 | + |
| 114 | + $this->setMapProperties( $params ); |
| 115 | + |
| 116 | + $this->setMarkerData( $parser ); |
| 117 | + |
| 118 | + $this->createMarkerString(); |
| 119 | + |
| 120 | + $this->setCentre(); |
| 121 | + |
| 122 | + if ( count( $this->markerData ) <= 1 && $this->zoom == 'null' ) { |
| 123 | + $this->zoom = $this->getDefaultZoom(); |
| 124 | + } |
| 125 | + |
| 126 | + $this->addSpecificMapHTML( $parser ); |
| 127 | + |
| 128 | + return $this->output; |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * Fills the $markerData array with the locations and their meta data. |
| 133 | + * |
| 134 | + * @param unknown_type $parser |
| 135 | + */ |
| 136 | + private function setMarkerData( $parser ) { |
| 137 | + $this->title = Xml::escapeJsString( $parser->recursiveTagParse( $this->title ) ); |
| 138 | + $this->label = Xml::escapeJsString( $parser->recursiveTagParse( $this->label ) ); |
| 139 | + |
| 140 | + foreach ( $this->coordinates as $coordinates ) { |
| 141 | + $args = explode( '~', $coordinates ); |
| 142 | + |
| 143 | + $markerData = MapsCoordinateParser::parseCoordinates( $args[0] ); |
| 144 | + |
| 145 | + if ( !$markerData ) continue; |
| 146 | + |
| 147 | + if ( count( $args ) > 1 ) { |
| 148 | + // Parse and add the point specific title if it's present. |
| 149 | + $markerData['title'] = $parser->recursiveTagParse( $args[1] ); |
| 150 | + |
| 151 | + if ( count( $args ) > 2 ) { |
| 152 | + // Parse and add the point specific label if it's present. |
| 153 | + $markerData['label'] = $parser->recursiveTagParse( $args[2] ); |
| 154 | + |
| 155 | + if ( count( $args ) > 3 ) { |
| 156 | + // Add the point specific icon if it's present. |
| 157 | + $markerData['icon'] = $args[3]; |
| 158 | + } |
| 159 | + } |
| 160 | + } |
| 161 | + |
| 162 | + // If there is no point specific icon, use the general icon parameter when available. |
| 163 | + if ( ! array_key_exists( 'icon', $markerData ) && strlen( $this->icon ) > 0 ) $markerData['icon'] = $this->icon; |
| 164 | + |
| 165 | + // Get the url for the icon when there is one, else set the icon to an empty string. |
| 166 | + if ( array_key_exists( 'icon', $markerData ) ) { |
| 167 | + $icon_image_page = new ImagePage( Title::newFromText( $markerData['icon'] ) ); |
| 168 | + $markerData['icon'] = $icon_image_page->getDisplayedFile()->getURL(); |
| 169 | + } |
| 170 | + else { |
| 171 | + $markerData['icon'] = ''; |
| 172 | + } |
| 173 | + |
| 174 | + $this->markerData[] = $markerData; |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + /** |
| 179 | + * Creates a JS string with the marker data. Takes care of escaping the used values. |
| 180 | + */ |
| 181 | + private function createMarkerString() { |
| 182 | + $markerItems = array(); |
| 183 | + |
| 184 | + foreach ( $this->markerData as $markerData ) { |
| 185 | + $title = array_key_exists( 'title', $markerData ) ? Xml::escapeJsString( $markerData['title'] ) : $this->title; |
| 186 | + $label = array_key_exists( 'label', $markerData ) ? Xml::escapeJsString( $markerData['label'] ) : $this->label; |
| 187 | + |
| 188 | + $markerData['lon'] = Xml::escapeJsString( $markerData['lon'] ); |
| 189 | + $markerData['lat'] = Xml::escapeJsString( $markerData['lat'] ); |
| 190 | + $markerData['icon'] = Xml::escapeJsString( $markerData['icon'] ); |
| 191 | + |
| 192 | + $markerItems[] = str_replace( array( 'lon', 'lat', 'title', 'label', 'icon' ), |
| 193 | + array( $markerData['lon'], $markerData['lat'], $title, $label, $markerData['icon'] ), |
| 194 | + $this->markerStringFormat |
| 195 | + ); |
| 196 | + } |
| 197 | + |
| 198 | + $this->markerString = implode( ',', $markerItems ); |
| 199 | + } |
| 200 | + |
| 201 | + /** |
| 202 | + * Sets the $centre_lat and $centre_lon fields. |
| 203 | + * Note: this needs to be done AFTRE the maker coordinates are set. |
| 204 | + */ |
| 205 | + private function setCentre() { |
| 206 | + if ( empty( $this->centre ) ) { |
| 207 | + if ( count( $this->markerData ) == 1 ) { |
| 208 | + // If centre is not set and there is exactelly one marker, use it's coordinates. |
| 209 | + $this->centreLat = Xml::escapeJsString( $this->markerData[0]['lat'] ); |
| 210 | + $this->centreLon = Xml::escapeJsString( $this->markerData[0]['lon'] ); |
| 211 | + } |
| 212 | + elseif ( count( $this->markerData ) > 1 ) { |
| 213 | + // If centre is not set and there are multiple markers, set the values to null, |
| 214 | + // to be auto determined by the JS of the mapping API. |
| 215 | + $this->centreLat = 'null'; |
| 216 | + $this->centreLon = 'null'; |
| 217 | + } |
| 218 | + else { |
| 219 | + // If centre is not set and there are no markers, use the default latitude and longitutde. |
| 220 | + $this->setCentreDefaults(); |
| 221 | + } |
| 222 | + } |
| 223 | + else { // If a centre value is set, geocode when needed and use it. |
| 224 | + $this->centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName ); |
| 225 | + |
| 226 | + // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde. |
| 227 | + if ( $this->centre ) { |
| 228 | + $this->centreLat = Xml::escapeJsString( $this->centre['lat'] ); |
| 229 | + $this->centreLon = Xml::escapeJsString( $this->centre['lon'] ); |
| 230 | + } |
| 231 | + else { // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used. |
| 232 | + $this->setCentreDefaults(); |
| 233 | + } |
| 234 | + } |
| 235 | + } |
| 236 | + |
| 237 | + /** |
| 238 | + * Sets the centre latitude and longitutde to the defaults. |
| 239 | + */ |
| 240 | + private function setCentreDefaults() { |
| 241 | + global $egMapsMapLat, $egMapsMapLon; |
| 242 | + $this->centreLat = $egMapsMapLat; |
| 243 | + $this->centreLon = $egMapsMapLon; |
| 244 | + } |
| 245 | +} |
Property changes on: trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
246 | 246 | + native |
Index: trunk/extensions/Maps/Features/Maps_iMapParserFunction.php |
— | — | @@ -1,36 +1,36 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding interface iMapParserFunction.
|
6 | | - *
|
7 | | - * @file Maps_iMapParserFunction.php
|
8 | | - * @ingroup Maps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - *
|
12 | | - * TODO: revise this interface
|
13 | | - */
|
14 | | -
|
15 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
16 | | - die( 'Not an entry point.' );
|
17 | | -}
|
18 | | -
|
19 | | -/**
|
20 | | - * Interface that should be implemented by all mapping feature classes.
|
21 | | - *
|
22 | | - * @author Jeroen De Dauw
|
23 | | - */
|
24 | | -interface iMapParserFunction {
|
25 | | - function getMapHtml( Parser &$parser, array $params );
|
26 | | -
|
27 | | - /**
|
28 | | - * Map service specific map count and loading of dependencies.
|
29 | | - */
|
30 | | - function doMapServiceLoad();
|
31 | | -
|
32 | | - /**
|
33 | | - * Adds the HTML specific to the mapping service to the output.
|
34 | | - */
|
35 | | - function addSpecificMapHTML( Parser $parser );
|
36 | | -}
|
37 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding interface iMapParserFunction. |
| 6 | + * |
| 7 | + * @file Maps_iMapParserFunction.php |
| 8 | + * @ingroup Maps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + * |
| 12 | + * TODO: revise this interface |
| 13 | + */ |
| 14 | + |
| 15 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 16 | + die( 'Not an entry point.' ); |
| 17 | +} |
| 18 | + |
| 19 | +/** |
| 20 | + * Interface that should be implemented by all mapping feature classes. |
| 21 | + * |
| 22 | + * @author Jeroen De Dauw |
| 23 | + */ |
| 24 | +interface iMapParserFunction { |
| 25 | + function getMapHtml( Parser &$parser, array $params ); |
| 26 | + |
| 27 | + /** |
| 28 | + * Map service specific map count and loading of dependencies. |
| 29 | + */ |
| 30 | + function doMapServiceLoad(); |
| 31 | + |
| 32 | + /** |
| 33 | + * Adds the HTML specific to the mapping service to the output. |
| 34 | + */ |
| 35 | + function addSpecificMapHTML( Parser $parser ); |
| 36 | +} |
| 37 | + |
Property changes on: trunk/extensions/Maps/Features/Maps_iMapParserFunction.php |
___________________________________________________________________ |
Added: svn:eol-style |
38 | 38 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispPoint.php |
— | — | @@ -1,106 +1,106 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the MapsGoogleMapsDispPoint class.
|
6 | | - *
|
7 | | - * @file Maps_GoogleMapsDispPoint.php
|
8 | | - * @ingroup MapsGoogleMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Class for handling the display_point(s) parser functions with Google Maps.
|
19 | | - *
|
20 | | - * @ingroup MapsGoogleMaps
|
21 | | - *
|
22 | | - * @author Jeroen De Dauw
|
23 | | - */
|
24 | | -final class MapsGoogleMapsDispPoint extends MapsBasePointMap {
|
25 | | -
|
26 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME;
|
27 | | -
|
28 | | - protected $markerStringFormat = 'getGMarkerData(lat, lon, \'title\', \'label\', "icon")';
|
29 | | -
|
30 | | - protected function getDefaultZoom() {
|
31 | | - global $egMapsGoogleMapsZoom;
|
32 | | - return $egMapsGoogleMapsZoom;
|
33 | | - }
|
34 | | -
|
35 | | - public function getSpecificParameterInfo() {
|
36 | | - global $egMapsGMapOverlays;
|
37 | | - // TODO: it'd be cool to have this static so it can be cheched in order to only init it once.
|
38 | | - $this->spesificParameters = array(
|
39 | | - 'overlays' => array(
|
40 | | - 'type' => array( 'string', 'list' ),
|
41 | | - 'criteria' => array(
|
42 | | - 'is_google_overlay' => array()
|
43 | | - ),
|
44 | | - 'default' => $egMapsGMapOverlays,
|
45 | | - ),
|
46 | | - );
|
47 | | - return $this->spesificParameters;
|
48 | | - }
|
49 | | -
|
50 | | - /**
|
51 | | - * @see MapsBaseMap::doMapServiceLoad()
|
52 | | - */
|
53 | | - public function doMapServiceLoad() {
|
54 | | - global $egGoogleMapsOnThisPage;
|
55 | | -
|
56 | | - MapsGoogleMaps::addGMapDependencies( $this->output );
|
57 | | - $egGoogleMapsOnThisPage++;
|
58 | | -
|
59 | | - $this->elementNr = $egGoogleMapsOnThisPage;
|
60 | | - }
|
61 | | -
|
62 | | - /**
|
63 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
64 | | - */
|
65 | | - public function addSpecificMapHTML( Parser $parser ) {
|
66 | | - global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage;
|
67 | | -
|
68 | | - $mapName = $egMapsGoogleMapsPrefix . '_' . $egGoogleMapsOnThisPage;
|
69 | | -
|
70 | | - MapsGoogleMaps::addOverlayOutput( $this->output, $mapName, $this->overlays, $this->controls );
|
71 | | -
|
72 | | - $this->output .= Html::element(
|
73 | | - 'div',
|
74 | | - array(
|
75 | | - 'id' => $mapName,
|
76 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
77 | | - ),
|
78 | | - wfMsg( 'maps-loading-map' )
|
79 | | - );
|
80 | | -
|
81 | | - $parser->getOutput()->addHeadItem(
|
82 | | - Html::inlineScript(
|
83 | | - <<<EOT
|
84 | | -addOnloadHook(
|
85 | | - function() {
|
86 | | - initializeGoogleMap('$mapName',
|
87 | | - {
|
88 | | - lat: $this->centreLat,
|
89 | | - lon: $this->centreLon,
|
90 | | - zoom: $this->zoom,
|
91 | | - type: $this->type,
|
92 | | - types: [$this->types],
|
93 | | - controls: [$this->controls],
|
94 | | - scrollWheelZoom: $this->autozoom
|
95 | | - },
|
96 | | - [$this->markerString]
|
97 | | - );
|
98 | | - }
|
99 | | -);
|
100 | | -EOT
|
101 | | - )
|
102 | | - );
|
103 | | -
|
104 | | - }
|
105 | | -
|
106 | | -}
|
107 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the MapsGoogleMapsDispPoint class. |
| 6 | + * |
| 7 | + * @file Maps_GoogleMapsDispPoint.php |
| 8 | + * @ingroup MapsGoogleMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Class for handling the display_point(s) parser functions with Google Maps. |
| 19 | + * |
| 20 | + * @ingroup MapsGoogleMaps |
| 21 | + * |
| 22 | + * @author Jeroen De Dauw |
| 23 | + */ |
| 24 | +final class MapsGoogleMapsDispPoint extends MapsBasePointMap { |
| 25 | + |
| 26 | + public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
| 27 | + |
| 28 | + protected $markerStringFormat = 'getGMarkerData(lat, lon, \'title\', \'label\', "icon")'; |
| 29 | + |
| 30 | + protected function getDefaultZoom() { |
| 31 | + global $egMapsGoogleMapsZoom; |
| 32 | + return $egMapsGoogleMapsZoom; |
| 33 | + } |
| 34 | + |
| 35 | + public function getSpecificParameterInfo() { |
| 36 | + global $egMapsGMapOverlays; |
| 37 | + // TODO: it'd be cool to have this static so it can be cheched in order to only init it once. |
| 38 | + $this->spesificParameters = array( |
| 39 | + 'overlays' => array( |
| 40 | + 'type' => array( 'string', 'list' ), |
| 41 | + 'criteria' => array( |
| 42 | + 'is_google_overlay' => array() |
| 43 | + ), |
| 44 | + 'default' => $egMapsGMapOverlays, |
| 45 | + ), |
| 46 | + ); |
| 47 | + return $this->spesificParameters; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @see MapsBaseMap::doMapServiceLoad() |
| 52 | + */ |
| 53 | + public function doMapServiceLoad() { |
| 54 | + global $egGoogleMapsOnThisPage; |
| 55 | + |
| 56 | + MapsGoogleMaps::addGMapDependencies( $this->output ); |
| 57 | + $egGoogleMapsOnThisPage++; |
| 58 | + |
| 59 | + $this->elementNr = $egGoogleMapsOnThisPage; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 64 | + */ |
| 65 | + public function addSpecificMapHTML( Parser $parser ) { |
| 66 | + global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage; |
| 67 | + |
| 68 | + $mapName = $egMapsGoogleMapsPrefix . '_' . $egGoogleMapsOnThisPage; |
| 69 | + |
| 70 | + MapsGoogleMaps::addOverlayOutput( $this->output, $mapName, $this->overlays, $this->controls ); |
| 71 | + |
| 72 | + $this->output .= Html::element( |
| 73 | + 'div', |
| 74 | + array( |
| 75 | + 'id' => $mapName, |
| 76 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 77 | + ), |
| 78 | + wfMsg( 'maps-loading-map' ) |
| 79 | + ); |
| 80 | + |
| 81 | + $parser->getOutput()->addHeadItem( |
| 82 | + Html::inlineScript( |
| 83 | + <<<EOT |
| 84 | +addOnloadHook( |
| 85 | + function() { |
| 86 | + initializeGoogleMap('$mapName', |
| 87 | + { |
| 88 | + lat: $this->centreLat, |
| 89 | + lon: $this->centreLon, |
| 90 | + zoom: $this->zoom, |
| 91 | + type: $this->type, |
| 92 | + types: [$this->types], |
| 93 | + controls: [$this->controls], |
| 94 | + scrollWheelZoom: $this->autozoom |
| 95 | + }, |
| 96 | + [$this->markerString] |
| 97 | + ); |
| 98 | + } |
| 99 | +); |
| 100 | +EOT |
| 101 | + ) |
| 102 | + ); |
| 103 | + |
| 104 | + } |
| 105 | + |
| 106 | +} |
| 107 | + |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispPoint.php |
___________________________________________________________________ |
Added: svn:eol-style |
108 | 108 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js |
— | — | @@ -1,240 +1,240 @@ |
2 | | - /**
|
3 | | - * Javascript functions for Google Maps functionallity in Maps.
|
4 | | - *
|
5 | | - * @file GoogleMapFunctions.js
|
6 | | - * @ingroup MapsGoogleMaps
|
7 | | - *
|
8 | | - * @author Robert Buzink
|
9 | | - * @author Yaron Koren
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -var GOverlays = [
|
14 | | - new GLayer("com.panoramio.all"),
|
15 | | - new GLayer("com.youtube.all"),
|
16 | | - new GLayer("org.wikipedia.en"),
|
17 | | - new GLayer("com.google.webcams")
|
18 | | -];
|
19 | | -
|
20 | | -
|
21 | | -/**
|
22 | | - * Returns GMarker object on the provided location. It will show a popup baloon
|
23 | | - * with title and label when clicked, if either of these is set.
|
24 | | - */
|
25 | | -function createGMarker(point, title, label, icon) {
|
26 | | - var marker;
|
27 | | -
|
28 | | - if (icon != '') {
|
29 | | - var iconObj = new GIcon(G_DEFAULT_ICON);
|
30 | | - iconObj.image = icon;
|
31 | | - marker = new GMarker(point, {icon:iconObj});
|
32 | | - } else {
|
33 | | - marker = new GMarker(point);
|
34 | | - }
|
35 | | -
|
36 | | - if ((title + label).length > 0) {
|
37 | | - var bothTxtAreSet = title.length > 0 && label.length > 0;
|
38 | | - var popupText = bothTxtAreSet ? '<b>' + title + '</b><hr />' + label : title + label;
|
39 | | - popupText = '<div style="overflow:auto;max-height:140px;">' + popupText + '</div>';
|
40 | | -
|
41 | | - GEvent.addListener(marker, 'click',
|
42 | | - function() {
|
43 | | - marker.openInfoWindowHtml(popupText, {maxWidth:350});
|
44 | | - }
|
45 | | - );
|
46 | | - }
|
47 | | -
|
48 | | - return marker;
|
49 | | -}
|
50 | | -
|
51 | | -/**
|
52 | | - * Returns GMap2 object with the provided properties and markers.
|
53 | | - * This is done by setting the map centre and size, and passing the arguments to function createGoogleMap.
|
54 | | - */
|
55 | | -function initializeGoogleMap(mapName, mapOptions, markers) {
|
56 | | - if (GBrowserIsCompatible()) {
|
57 | | - mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null;
|
58 | | - //mapOptions.size = new GSize(mapOptions.width, mapOptions.height);
|
59 | | - return createGoogleMap(mapName, mapOptions, markers);
|
60 | | - }
|
61 | | - else {
|
62 | | - return false;
|
63 | | - }
|
64 | | -}
|
65 | | -
|
66 | | -/**
|
67 | | - * Returns GMap2 object with the provided properties.
|
68 | | - */
|
69 | | -function createGoogleMap(mapName, mapOptions, markers) {
|
70 | | - var mapElement = document.getElementById(mapName);
|
71 | | - var typesContainType = false;
|
72 | | -
|
73 | | - // TODO: Change labels of the moon/mars map types?
|
74 | | - for (var i = 0; i < mapOptions.types.length; i++) {
|
75 | | - if (mapOptions.types[i] == mapOptions.type) typesContainType = true;
|
76 | | - }
|
77 | | -
|
78 | | - if (! typesContainType) mapOptions.types.push(mapOptions.type);
|
79 | | -
|
80 | | - var map = new GMap2(mapElement, {mapTypes: mapOptions.types});
|
81 | | - map.name = mapName;
|
82 | | -
|
83 | | - map.setMapType(mapOptions.type);
|
84 | | -
|
85 | | - // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl
|
86 | | - for (i in mapOptions.controls){
|
87 | | - if (mapOptions.controls[i].toLowerCase() == 'auto') {
|
88 | | - if (mapElement.offsetHeight > 75) mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small';
|
89 | | - }
|
90 | | -
|
91 | | - switch (mapOptions.controls[i]) {
|
92 | | - case 'large' :
|
93 | | - map.addControl(new GLargeMapControl3D());
|
94 | | - break;
|
95 | | - case 'small' :
|
96 | | - map.addControl(new GSmallZoomControl3D());
|
97 | | - break;
|
98 | | - case 'large-original' :
|
99 | | - map.addControl(new GLargeMapControl());
|
100 | | - break;
|
101 | | - case 'small-original' :
|
102 | | - map.addControl(new GSmallMapControl());
|
103 | | - break;
|
104 | | - case 'zoom' :
|
105 | | - map.addControl(new GSmallZoomControl());
|
106 | | - break;
|
107 | | - case 'type' :
|
108 | | - map.addControl(new GMapTypeControl());
|
109 | | - break;
|
110 | | - case 'type-menu' :
|
111 | | - map.addControl(new GMenuMapTypeControl());
|
112 | | - break;
|
113 | | - case 'overlays' :
|
114 | | - map.addControl(new MoreControl());
|
115 | | - break;
|
116 | | - case 'overview' : case 'overview-map' :
|
117 | | - map.addControl(new GOverviewMapControl());
|
118 | | - break;
|
119 | | - case 'scale' :
|
120 | | - map.addControl(new GScaleControl());
|
121 | | - break;
|
122 | | - case 'nav-label' : case 'nav' :
|
123 | | - map.addControl(new GNavLabelControl());
|
124 | | - break;
|
125 | | - }
|
126 | | - }
|
127 | | -
|
128 | | - var bounds = ((mapOptions.zoom == null || mapOptions.centre == null) && markers.length > 1) ? new GLatLngBounds() : null;
|
129 | | -
|
130 | | - for (i in markers) {
|
131 | | - var marker = markers[i];
|
132 | | - map.addOverlay(createGMarker(marker.point, marker.title, marker.label, marker.icon));
|
133 | | - if (bounds != null) bounds.extend(marker.point);
|
134 | | - }
|
135 | | -
|
136 | | - if (bounds != null) {
|
137 | | - map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
|
138 | | - }
|
139 | | -
|
140 | | - if (mapOptions.centre != null) map.setCenter(mapOptions.centre);
|
141 | | - if (mapOptions.zoom != null) map.setZoom(mapOptions.zoom);
|
142 | | -
|
143 | | - if (mapOptions.scrollWheelZoom) map.enableScrollWheelZoom();
|
144 | | -
|
145 | | - map.enableContinuousZoom();
|
146 | | -
|
147 | | - // Make the map variable available for other functions
|
148 | | - if (!window.GMaps) window.GMaps = new Object;
|
149 | | - eval("window.GMaps." + mapName + " = map;");
|
150 | | -
|
151 | | - return map;
|
152 | | -}
|
153 | | -
|
154 | | -function getGMarkerData(lat, lon, title, label, icon) {
|
155 | | - return {point: new GLatLng(lat, lon), title: title, label: label, icon: icon};
|
156 | | -}
|
157 | | -
|
158 | | -function setupCheckboxShiftClick() { return true; }
|
159 | | -
|
160 | | -function MoreControl() {};
|
161 | | -MoreControl.prototype = new GControl();
|
162 | | -
|
163 | | -MoreControl.prototype.initialize = function(map) {
|
164 | | - this.map = map;
|
165 | | -
|
166 | | - var more = document.getElementById(map.name + "-outer-more");
|
167 | | -
|
168 | | - var buttonDiv = document.createElement("div");
|
169 | | - buttonDiv.id = map.name + "-more-button";
|
170 | | - buttonDiv.title = "Show/Hide Overlays";
|
171 | | - buttonDiv.style.border = "1px solid black";
|
172 | | - buttonDiv.style.width = "86px";
|
173 | | -
|
174 | | - var textDiv = document.createElement("div");
|
175 | | - textDiv.id = map.name + "-inner-more";
|
176 | | - textDiv.setAttribute('class', 'inner-more');
|
177 | | - textDiv.appendChild(document.createTextNode("Overlays"));
|
178 | | -
|
179 | | - buttonDiv.appendChild(textDiv);
|
180 | | -
|
181 | | - // Register Event handlers
|
182 | | - more.onmouseover = showGLayerbox;
|
183 | | - more.onmouseout = setGLayerboxClose;
|
184 | | -
|
185 | | - // Insert the button just after outer_more div.
|
186 | | - more.insertBefore(buttonDiv, document.getElementById(map.name + "-more-box").parentNode);
|
187 | | -
|
188 | | - // Remove the whole div from its location and reinsert it to the map.
|
189 | | - map.getContainer().appendChild(more);
|
190 | | -
|
191 | | - return more;
|
192 | | -};
|
193 | | -
|
194 | | -MoreControl.prototype.getDefaultPosition = function() {
|
195 | | - return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 35));
|
196 | | -};
|
197 | | -
|
198 | | -function checkGChecked(mapName) {
|
199 | | - // Returns true if a checkbox is still checked otherwise false.
|
200 | | - var boxes = document.getElementsByName(mapName + "-overlay-box");
|
201 | | - for(var i = 0; i < boxes.length; i++) {
|
202 | | - if(boxes[i].checked) return true;
|
203 | | - }
|
204 | | - return false;
|
205 | | -}
|
206 | | -
|
207 | | -function showGLayerbox() {
|
208 | | - var mapName = this.id.split('-')[0];
|
209 | | - eval("if(window.timer_" + mapName + ") clearTimeout(timer_" + mapName + ");");
|
210 | | - document.getElementById(mapName + "-more-box").style.display = "block";
|
211 | | - var button = document.getElementById(mapName + "-inner-more");
|
212 | | - button.style.borderBottomWidth = "4px";
|
213 | | - button.style.borderBottomColor = "white";
|
214 | | -}
|
215 | | -
|
216 | | -
|
217 | | -function setGLayerboxClose() {
|
218 | | - var mapName = this.id.split('-')[0];
|
219 | | - var layerbox = document.getElementById(mapName + "-more-box");
|
220 | | - var button = document.getElementById(mapName + "-inner-more");
|
221 | | - var bottomColor = checkGChecked(mapName) ? "#6495ed" : "#c0c0c0";
|
222 | | - eval("timer_" + mapName + " = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);");
|
223 | | -}
|
224 | | -
|
225 | | -function switchGLayer(map, checked, layer) {
|
226 | | - var layerbox = document.getElementById(map.name + "-more-box");
|
227 | | - var button = document.getElementById(map.name + "-inner-more");
|
228 | | -
|
229 | | - if(checked) {
|
230 | | - map.addOverlay(layer);
|
231 | | - }
|
232 | | - else {
|
233 | | - map.removeOverlay(layer);
|
234 | | - }
|
235 | | -
|
236 | | -}
|
237 | | -
|
238 | | -function initiateGOverlay(elementId, mapName, urlNr) {
|
239 | | - document.getElementById(elementId).checked = true;
|
240 | | - switchGLayer(GMaps[mapName], true, GOverlays[urlNr]);
|
241 | | -}
|
| 2 | + /** |
| 3 | + * Javascript functions for Google Maps functionallity in Maps. |
| 4 | + * |
| 5 | + * @file GoogleMapFunctions.js |
| 6 | + * @ingroup MapsGoogleMaps |
| 7 | + * |
| 8 | + * @author Robert Buzink |
| 9 | + * @author Yaron Koren |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +var GOverlays = [ |
| 14 | + new GLayer("com.panoramio.all"), |
| 15 | + new GLayer("com.youtube.all"), |
| 16 | + new GLayer("org.wikipedia.en"), |
| 17 | + new GLayer("com.google.webcams") |
| 18 | +]; |
| 19 | + |
| 20 | + |
| 21 | +/** |
| 22 | + * Returns GMarker object on the provided location. It will show a popup baloon |
| 23 | + * with title and label when clicked, if either of these is set. |
| 24 | + */ |
| 25 | +function createGMarker(point, title, label, icon) { |
| 26 | + var marker; |
| 27 | + |
| 28 | + if (icon != '') { |
| 29 | + var iconObj = new GIcon(G_DEFAULT_ICON); |
| 30 | + iconObj.image = icon; |
| 31 | + marker = new GMarker(point, {icon:iconObj}); |
| 32 | + } else { |
| 33 | + marker = new GMarker(point); |
| 34 | + } |
| 35 | + |
| 36 | + if ((title + label).length > 0) { |
| 37 | + var bothTxtAreSet = title.length > 0 && label.length > 0; |
| 38 | + var popupText = bothTxtAreSet ? '<b>' + title + '</b><hr />' + label : title + label; |
| 39 | + popupText = '<div style="overflow:auto;max-height:140px;">' + popupText + '</div>'; |
| 40 | + |
| 41 | + GEvent.addListener(marker, 'click', |
| 42 | + function() { |
| 43 | + marker.openInfoWindowHtml(popupText, {maxWidth:350}); |
| 44 | + } |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | + return marker; |
| 49 | +} |
| 50 | + |
| 51 | +/** |
| 52 | + * Returns GMap2 object with the provided properties and markers. |
| 53 | + * This is done by setting the map centre and size, and passing the arguments to function createGoogleMap. |
| 54 | + */ |
| 55 | +function initializeGoogleMap(mapName, mapOptions, markers) { |
| 56 | + if (GBrowserIsCompatible()) { |
| 57 | + mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null; |
| 58 | + //mapOptions.size = new GSize(mapOptions.width, mapOptions.height); |
| 59 | + return createGoogleMap(mapName, mapOptions, markers); |
| 60 | + } |
| 61 | + else { |
| 62 | + return false; |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +/** |
| 67 | + * Returns GMap2 object with the provided properties. |
| 68 | + */ |
| 69 | +function createGoogleMap(mapName, mapOptions, markers) { |
| 70 | + var mapElement = document.getElementById(mapName); |
| 71 | + var typesContainType = false; |
| 72 | + |
| 73 | + // TODO: Change labels of the moon/mars map types? |
| 74 | + for (var i = 0; i < mapOptions.types.length; i++) { |
| 75 | + if (mapOptions.types[i] == mapOptions.type) typesContainType = true; |
| 76 | + } |
| 77 | + |
| 78 | + if (! typesContainType) mapOptions.types.push(mapOptions.type); |
| 79 | + |
| 80 | + var map = new GMap2(mapElement, {mapTypes: mapOptions.types}); |
| 81 | + map.name = mapName; |
| 82 | + |
| 83 | + map.setMapType(mapOptions.type); |
| 84 | + |
| 85 | + // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl |
| 86 | + for (i in mapOptions.controls){ |
| 87 | + if (mapOptions.controls[i].toLowerCase() == 'auto') { |
| 88 | + if (mapElement.offsetHeight > 75) mapOptions.controls[i] = mapElement.offsetHeight > 320 ? 'large' : 'small'; |
| 89 | + } |
| 90 | + |
| 91 | + switch (mapOptions.controls[i]) { |
| 92 | + case 'large' : |
| 93 | + map.addControl(new GLargeMapControl3D()); |
| 94 | + break; |
| 95 | + case 'small' : |
| 96 | + map.addControl(new GSmallZoomControl3D()); |
| 97 | + break; |
| 98 | + case 'large-original' : |
| 99 | + map.addControl(new GLargeMapControl()); |
| 100 | + break; |
| 101 | + case 'small-original' : |
| 102 | + map.addControl(new GSmallMapControl()); |
| 103 | + break; |
| 104 | + case 'zoom' : |
| 105 | + map.addControl(new GSmallZoomControl()); |
| 106 | + break; |
| 107 | + case 'type' : |
| 108 | + map.addControl(new GMapTypeControl()); |
| 109 | + break; |
| 110 | + case 'type-menu' : |
| 111 | + map.addControl(new GMenuMapTypeControl()); |
| 112 | + break; |
| 113 | + case 'overlays' : |
| 114 | + map.addControl(new MoreControl()); |
| 115 | + break; |
| 116 | + case 'overview' : case 'overview-map' : |
| 117 | + map.addControl(new GOverviewMapControl()); |
| 118 | + break; |
| 119 | + case 'scale' : |
| 120 | + map.addControl(new GScaleControl()); |
| 121 | + break; |
| 122 | + case 'nav-label' : case 'nav' : |
| 123 | + map.addControl(new GNavLabelControl()); |
| 124 | + break; |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + var bounds = ((mapOptions.zoom == null || mapOptions.centre == null) && markers.length > 1) ? new GLatLngBounds() : null; |
| 129 | + |
| 130 | + for (i in markers) { |
| 131 | + var marker = markers[i]; |
| 132 | + map.addOverlay(createGMarker(marker.point, marker.title, marker.label, marker.icon)); |
| 133 | + if (bounds != null) bounds.extend(marker.point); |
| 134 | + } |
| 135 | + |
| 136 | + if (bounds != null) { |
| 137 | + map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); |
| 138 | + } |
| 139 | + |
| 140 | + if (mapOptions.centre != null) map.setCenter(mapOptions.centre); |
| 141 | + if (mapOptions.zoom != null) map.setZoom(mapOptions.zoom); |
| 142 | + |
| 143 | + if (mapOptions.scrollWheelZoom) map.enableScrollWheelZoom(); |
| 144 | + |
| 145 | + map.enableContinuousZoom(); |
| 146 | + |
| 147 | + // Make the map variable available for other functions |
| 148 | + if (!window.GMaps) window.GMaps = new Object; |
| 149 | + eval("window.GMaps." + mapName + " = map;"); |
| 150 | + |
| 151 | + return map; |
| 152 | +} |
| 153 | + |
| 154 | +function getGMarkerData(lat, lon, title, label, icon) { |
| 155 | + return {point: new GLatLng(lat, lon), title: title, label: label, icon: icon}; |
| 156 | +} |
| 157 | + |
| 158 | +function setupCheckboxShiftClick() { return true; } |
| 159 | + |
| 160 | +function MoreControl() {}; |
| 161 | +MoreControl.prototype = new GControl(); |
| 162 | + |
| 163 | +MoreControl.prototype.initialize = function(map) { |
| 164 | + this.map = map; |
| 165 | + |
| 166 | + var more = document.getElementById(map.name + "-outer-more"); |
| 167 | + |
| 168 | + var buttonDiv = document.createElement("div"); |
| 169 | + buttonDiv.id = map.name + "-more-button"; |
| 170 | + buttonDiv.title = "Show/Hide Overlays"; |
| 171 | + buttonDiv.style.border = "1px solid black"; |
| 172 | + buttonDiv.style.width = "86px"; |
| 173 | + |
| 174 | + var textDiv = document.createElement("div"); |
| 175 | + textDiv.id = map.name + "-inner-more"; |
| 176 | + textDiv.setAttribute('class', 'inner-more'); |
| 177 | + textDiv.appendChild(document.createTextNode("Overlays")); |
| 178 | + |
| 179 | + buttonDiv.appendChild(textDiv); |
| 180 | + |
| 181 | + // Register Event handlers |
| 182 | + more.onmouseover = showGLayerbox; |
| 183 | + more.onmouseout = setGLayerboxClose; |
| 184 | + |
| 185 | + // Insert the button just after outer_more div. |
| 186 | + more.insertBefore(buttonDiv, document.getElementById(map.name + "-more-box").parentNode); |
| 187 | + |
| 188 | + // Remove the whole div from its location and reinsert it to the map. |
| 189 | + map.getContainer().appendChild(more); |
| 190 | + |
| 191 | + return more; |
| 192 | +}; |
| 193 | + |
| 194 | +MoreControl.prototype.getDefaultPosition = function() { |
| 195 | + return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 35)); |
| 196 | +}; |
| 197 | + |
| 198 | +function checkGChecked(mapName) { |
| 199 | + // Returns true if a checkbox is still checked otherwise false. |
| 200 | + var boxes = document.getElementsByName(mapName + "-overlay-box"); |
| 201 | + for(var i = 0; i < boxes.length; i++) { |
| 202 | + if(boxes[i].checked) return true; |
| 203 | + } |
| 204 | + return false; |
| 205 | +} |
| 206 | + |
| 207 | +function showGLayerbox() { |
| 208 | + var mapName = this.id.split('-')[0]; |
| 209 | + eval("if(window.timer_" + mapName + ") clearTimeout(timer_" + mapName + ");"); |
| 210 | + document.getElementById(mapName + "-more-box").style.display = "block"; |
| 211 | + var button = document.getElementById(mapName + "-inner-more"); |
| 212 | + button.style.borderBottomWidth = "4px"; |
| 213 | + button.style.borderBottomColor = "white"; |
| 214 | +} |
| 215 | + |
| 216 | + |
| 217 | +function setGLayerboxClose() { |
| 218 | + var mapName = this.id.split('-')[0]; |
| 219 | + var layerbox = document.getElementById(mapName + "-more-box"); |
| 220 | + var button = document.getElementById(mapName + "-inner-more"); |
| 221 | + var bottomColor = checkGChecked(mapName) ? "#6495ed" : "#c0c0c0"; |
| 222 | + eval("timer_" + mapName + " = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);"); |
| 223 | +} |
| 224 | + |
| 225 | +function switchGLayer(map, checked, layer) { |
| 226 | + var layerbox = document.getElementById(map.name + "-more-box"); |
| 227 | + var button = document.getElementById(map.name + "-inner-more"); |
| 228 | + |
| 229 | + if(checked) { |
| 230 | + map.addOverlay(layer); |
| 231 | + } |
| 232 | + else { |
| 233 | + map.removeOverlay(layer); |
| 234 | + } |
| 235 | + |
| 236 | +} |
| 237 | + |
| 238 | +function initiateGOverlay(elementId, mapName, urlNr) { |
| 239 | + document.getElementById(elementId).checked = true; |
| 240 | + switchGLayer(GMaps[mapName], true, GOverlays[urlNr]); |
| 241 | +} |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
242 | 242 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.min.js |
— | — | @@ -1,20 +1,20 @@ |
2 | | -var GOverlays=[new GLayer("com.panoramio.all"),new GLayer("com.youtube.all"),new GLayer("org.wikipedia.en"),new GLayer("com.google.webcams")];function createGMarker(point,title,label,icon){var marker;if(icon!=''){var iconObj=new GIcon(G_DEFAULT_ICON);iconObj.image=icon;marker=new GMarker(point,{icon:iconObj});}else{marker=new GMarker(point);}
|
3 | | -if((title+label).length>0){var bothTxtAreSet=title.length>0&&label.length>0;var popupText=bothTxtAreSet?'<b>'+title+'</b><hr />'+label:title+label;popupText='<div style="overflow:auto;max-height:150px;">'+popupText+'</div>';GEvent.addListener(marker,'click',function(){marker.openInfoWindowHtml(popupText,{maxWidth:350});});}
|
4 | | -return marker;}
|
5 | | -function initializeGoogleMap(mapName,mapOptions,markers){if(GBrowserIsCompatible()){mapOptions.centre=(mapOptions.lat!=null&&mapOptions.lon!=null)?new GLatLng(mapOptions.lat,mapOptions.lon):null;mapOptions.size=new GSize(mapOptions.width,mapOptions.height);return createGoogleMap(mapName,mapOptions,markers);}
|
6 | | -else{return false;}}
|
7 | | -function createGoogleMap(mapName,mapOptions,markers){var mapElement=document.getElementById(mapName);var typesContainType=false;for(var i=0;i<mapOptions.types.length;i++){if(mapOptions.types[i]==mapOptions.type)typesContainType=true;}
|
8 | | -if(!typesContainType)mapOptions.types.push(mapOptions.type);var map=new GMap2(mapElement,{size:mapOptions.size,mapTypes:mapOptions.types});map.name=mapName;map.setMapType(mapOptions.type);for(i in mapOptions.controls){if(mapOptions.controls[i].toLowerCase()=='auto'){if(mapOptions.height>75)mapOptions.controls[i]=mapOptions.height>320?'large':'small';}
|
9 | | -switch(mapOptions.controls[i]){case'large':map.addControl(new GLargeMapControl3D());break;case'small':map.addControl(new GSmallZoomControl3D());break;case'large-original':map.addControl(new GLargeMapControl());break;case'small-original':map.addControl(new GSmallMapControl());break;case'zoom':map.addControl(new GSmallZoomControl());break;case'type':map.addControl(new GMapTypeControl());break;case'type-menu':map.addControl(new GMenuMapTypeControl());break;case'overlays':map.addControl(new MoreControl());break;case'overview':case'overview-map':map.addControl(new GOverviewMapControl());break;case'scale':map.addControl(new GScaleControl());break;case'nav-label':case'nav':map.addControl(new GNavLabelControl());break;}}
|
10 | | -var bounds=((mapOptions.zoom==null||mapOptions.centre==null)&&markers.length>1)?new GLatLngBounds():null;for(i in markers){var marker=markers[i];map.addOverlay(createGMarker(marker.point,marker.title,marker.label,marker.icon));if(bounds!=null)bounds.extend(marker.point);}
|
11 | | -if(bounds!=null){map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds));}
|
12 | | -if(mapOptions.centre!=null)map.setCenter(mapOptions.centre);if(mapOptions.zoom!=null)map.setZoom(mapOptions.zoom);if(mapOptions.scrollWheelZoom)map.enableScrollWheelZoom();map.enableContinuousZoom();if(!window.GMaps)window.GMaps=new Object;eval("window.GMaps."+mapName+" = map;");return map;}
|
13 | | -function getGMarkerData(lat,lon,title,label,icon){return{point:new GLatLng(lat,lon),title:title,label:label,icon:icon};}
|
14 | | -function setupCheckboxShiftClick(){return true;}
|
15 | | -function MoreControl(){};MoreControl.prototype=new GControl();MoreControl.prototype.initialize=function(map){this.map=map;var more=document.getElementById(map.name+"-outer-more");var buttonDiv=document.createElement("div");buttonDiv.id=map.name+"-more-button";buttonDiv.title="Show/Hide Overlays";buttonDiv.style.border="1px solid black";buttonDiv.style.width="86px";var textDiv=document.createElement("div");textDiv.id=map.name+"-inner-more";textDiv.setAttribute('class','inner-more');textDiv.appendChild(document.createTextNode("Overlays"));buttonDiv.appendChild(textDiv);more.onmouseover=showGLayerbox;more.onmouseout=setGLayerboxClose;more.insertBefore(buttonDiv,document.getElementById(map.name+"-more-box").parentNode);map.getContainer().appendChild(more);return more;};MoreControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,35));};function checkGChecked(mapName){var boxes=document.getElementsByName(mapName+"-overlay-box");for(var i=0;i<boxes.length;i++){if(boxes[i].checked)return true;}
|
16 | | -return false;}
|
17 | | -function showGLayerbox(){var mapName=this.id.split('-')[0];eval("if(window.timer_"+mapName+") clearTimeout(timer_"+mapName+");");document.getElementById(mapName+"-more-box").style.display="block";var button=document.getElementById(mapName+"-inner-more");button.style.borderBottomWidth="4px";button.style.borderBottomColor="white";}
|
18 | | -function setGLayerboxClose(){var mapName=this.id.split('-')[0];var layerbox=document.getElementById(mapName+"-more-box");var button=document.getElementById(mapName+"-inner-more");var bottomColor=checkGChecked(mapName)?"#6495ed":"#c0c0c0";eval("timer_"+mapName+" = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);");}
|
19 | | -function switchGLayer(map,checked,layer){var layerbox=document.getElementById(map.name+"-more-box");var button=document.getElementById(map.name+"-inner-more");if(checked){map.addOverlay(layer);}
|
20 | | -else{map.removeOverlay(layer);}}
|
| 2 | +var GOverlays=[new GLayer("com.panoramio.all"),new GLayer("com.youtube.all"),new GLayer("org.wikipedia.en"),new GLayer("com.google.webcams")];function createGMarker(point,title,label,icon){var marker;if(icon!=''){var iconObj=new GIcon(G_DEFAULT_ICON);iconObj.image=icon;marker=new GMarker(point,{icon:iconObj});}else{marker=new GMarker(point);} |
| 3 | +if((title+label).length>0){var bothTxtAreSet=title.length>0&&label.length>0;var popupText=bothTxtAreSet?'<b>'+title+'</b><hr />'+label:title+label;popupText='<div style="overflow:auto;max-height:150px;">'+popupText+'</div>';GEvent.addListener(marker,'click',function(){marker.openInfoWindowHtml(popupText,{maxWidth:350});});} |
| 4 | +return marker;} |
| 5 | +function initializeGoogleMap(mapName,mapOptions,markers){if(GBrowserIsCompatible()){mapOptions.centre=(mapOptions.lat!=null&&mapOptions.lon!=null)?new GLatLng(mapOptions.lat,mapOptions.lon):null;mapOptions.size=new GSize(mapOptions.width,mapOptions.height);return createGoogleMap(mapName,mapOptions,markers);} |
| 6 | +else{return false;}} |
| 7 | +function createGoogleMap(mapName,mapOptions,markers){var mapElement=document.getElementById(mapName);var typesContainType=false;for(var i=0;i<mapOptions.types.length;i++){if(mapOptions.types[i]==mapOptions.type)typesContainType=true;} |
| 8 | +if(!typesContainType)mapOptions.types.push(mapOptions.type);var map=new GMap2(mapElement,{size:mapOptions.size,mapTypes:mapOptions.types});map.name=mapName;map.setMapType(mapOptions.type);for(i in mapOptions.controls){if(mapOptions.controls[i].toLowerCase()=='auto'){if(mapOptions.height>75)mapOptions.controls[i]=mapOptions.height>320?'large':'small';} |
| 9 | +switch(mapOptions.controls[i]){case'large':map.addControl(new GLargeMapControl3D());break;case'small':map.addControl(new GSmallZoomControl3D());break;case'large-original':map.addControl(new GLargeMapControl());break;case'small-original':map.addControl(new GSmallMapControl());break;case'zoom':map.addControl(new GSmallZoomControl());break;case'type':map.addControl(new GMapTypeControl());break;case'type-menu':map.addControl(new GMenuMapTypeControl());break;case'overlays':map.addControl(new MoreControl());break;case'overview':case'overview-map':map.addControl(new GOverviewMapControl());break;case'scale':map.addControl(new GScaleControl());break;case'nav-label':case'nav':map.addControl(new GNavLabelControl());break;}} |
| 10 | +var bounds=((mapOptions.zoom==null||mapOptions.centre==null)&&markers.length>1)?new GLatLngBounds():null;for(i in markers){var marker=markers[i];map.addOverlay(createGMarker(marker.point,marker.title,marker.label,marker.icon));if(bounds!=null)bounds.extend(marker.point);} |
| 11 | +if(bounds!=null){map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds));} |
| 12 | +if(mapOptions.centre!=null)map.setCenter(mapOptions.centre);if(mapOptions.zoom!=null)map.setZoom(mapOptions.zoom);if(mapOptions.scrollWheelZoom)map.enableScrollWheelZoom();map.enableContinuousZoom();if(!window.GMaps)window.GMaps=new Object;eval("window.GMaps."+mapName+" = map;");return map;} |
| 13 | +function getGMarkerData(lat,lon,title,label,icon){return{point:new GLatLng(lat,lon),title:title,label:label,icon:icon};} |
| 14 | +function setupCheckboxShiftClick(){return true;} |
| 15 | +function MoreControl(){};MoreControl.prototype=new GControl();MoreControl.prototype.initialize=function(map){this.map=map;var more=document.getElementById(map.name+"-outer-more");var buttonDiv=document.createElement("div");buttonDiv.id=map.name+"-more-button";buttonDiv.title="Show/Hide Overlays";buttonDiv.style.border="1px solid black";buttonDiv.style.width="86px";var textDiv=document.createElement("div");textDiv.id=map.name+"-inner-more";textDiv.setAttribute('class','inner-more');textDiv.appendChild(document.createTextNode("Overlays"));buttonDiv.appendChild(textDiv);more.onmouseover=showGLayerbox;more.onmouseout=setGLayerboxClose;more.insertBefore(buttonDiv,document.getElementById(map.name+"-more-box").parentNode);map.getContainer().appendChild(more);return more;};MoreControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,35));};function checkGChecked(mapName){var boxes=document.getElementsByName(mapName+"-overlay-box");for(var i=0;i<boxes.length;i++){if(boxes[i].checked)return true;} |
| 16 | +return false;} |
| 17 | +function showGLayerbox(){var mapName=this.id.split('-')[0];eval("if(window.timer_"+mapName+") clearTimeout(timer_"+mapName+");");document.getElementById(mapName+"-more-box").style.display="block";var button=document.getElementById(mapName+"-inner-more");button.style.borderBottomWidth="4px";button.style.borderBottomColor="white";} |
| 18 | +function setGLayerboxClose(){var mapName=this.id.split('-')[0];var layerbox=document.getElementById(mapName+"-more-box");var button=document.getElementById(mapName+"-inner-more");var bottomColor=checkGChecked(mapName)?"#6495ed":"#c0c0c0";eval("timer_"+mapName+" = window.setTimeout(function() { layerbox.style.display = 'none'; button.style.borderBottomWidth = '1px'; button.style.borderBottomColor = bottomColor; }, 400);");} |
| 19 | +function switchGLayer(map,checked,layer){var layerbox=document.getElementById(map.name+"-more-box");var button=document.getElementById(map.name+"-inner-more");if(checked){map.addOverlay(layer);} |
| 20 | +else{map.removeOverlay(layer);}} |
21 | 21 | function initiateGOverlay(elementId,mapName,urlNr){document.getElementById(elementId).checked=true;switchGLayer(GMaps[mapName],true,GOverlays[urlNr]);} |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps/GoogleMapFunctions.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
22 | 22 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispMap.php |
— | — | @@ -1,100 +1,100 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Class for handling the display_map parser function with Google Maps
|
6 | | - *
|
7 | | - * @file Maps_GoogleMapsDispMap.php
|
8 | | - * @ingroup MapsGoogleMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Class for handling the display_map parser functions with Google Maps.
|
19 | | - *
|
20 | | - * @ingroup MapsGoogleMaps
|
21 | | - *
|
22 | | - * @author Jeroen De Dauw
|
23 | | - */
|
24 | | -final class MapsGoogleMapsDispMap extends MapsBaseMap {
|
25 | | -
|
26 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME;
|
27 | | -
|
28 | | - protected function getDefaultZoom() {
|
29 | | - global $egMapsGoogleMapsZoom;
|
30 | | - return $egMapsGoogleMapsZoom;
|
31 | | - }
|
32 | | -
|
33 | | - public function getSpecificParameterInfo() {
|
34 | | - global $egMapsGMapOverlays;
|
35 | | - $this->spesificParameters = array(
|
36 | | - 'overlays' => array(
|
37 | | - 'type' => array( 'string', 'list' ),
|
38 | | - 'criteria' => array(
|
39 | | - 'is_google_overlay' => array()
|
40 | | - ),
|
41 | | - 'default' => $egMapsGMapOverlays,
|
42 | | - ),
|
43 | | - );
|
44 | | - return $this->spesificParameters;
|
45 | | - }
|
46 | | -
|
47 | | - /**
|
48 | | - * @see MapsBaseMap::doMapServiceLoad()
|
49 | | - */
|
50 | | - public function doMapServiceLoad() {
|
51 | | - global $egGoogleMapsOnThisPage;
|
52 | | -
|
53 | | - MapsGoogleMaps::addGMapDependencies( $this->output );
|
54 | | - $egGoogleMapsOnThisPage++;
|
55 | | -
|
56 | | - $this->elementNr = $egGoogleMapsOnThisPage;
|
57 | | - }
|
58 | | -
|
59 | | - /**
|
60 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
61 | | - */
|
62 | | - public function addSpecificMapHTML( Parser $parser ) {
|
63 | | - global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage;
|
64 | | -
|
65 | | - $mapName = $egMapsGoogleMapsPrefix . '_' . $egGoogleMapsOnThisPage;
|
66 | | -
|
67 | | - MapsGoogleMaps::addOverlayOutput( $this->output, $mapName, $this->overlays, $this->controls );
|
68 | | -
|
69 | | - $this->output .= Html::element(
|
70 | | - 'div',
|
71 | | - array(
|
72 | | - 'id' => $mapName,
|
73 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
74 | | - ),
|
75 | | - wfMsg( 'maps-loading-map' )
|
76 | | - );
|
77 | | -
|
78 | | - $parser->getOutput()->addHeadItem(
|
79 | | - Html::inlineScript( <<<EOT
|
80 | | -addOnloadHook(
|
81 | | - function() {
|
82 | | - initializeGoogleMap('$mapName',
|
83 | | - {
|
84 | | - lat: $this->centreLat,
|
85 | | - lon: $this->centreLon,
|
86 | | - zoom: $this->zoom,
|
87 | | - type: $this->type,
|
88 | | - types: [$this->types],
|
89 | | - controls: [$this->controls],
|
90 | | - scrollWheelZoom: $this->autozoom
|
91 | | - },
|
92 | | - []);
|
93 | | - }
|
94 | | -);
|
95 | | -EOT
|
96 | | - ) );
|
97 | | -
|
98 | | - }
|
99 | | -
|
100 | | -}
|
101 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class for handling the display_map parser function with Google Maps |
| 6 | + * |
| 7 | + * @file Maps_GoogleMapsDispMap.php |
| 8 | + * @ingroup MapsGoogleMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Class for handling the display_map parser functions with Google Maps. |
| 19 | + * |
| 20 | + * @ingroup MapsGoogleMaps |
| 21 | + * |
| 22 | + * @author Jeroen De Dauw |
| 23 | + */ |
| 24 | +final class MapsGoogleMapsDispMap extends MapsBaseMap { |
| 25 | + |
| 26 | + public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
| 27 | + |
| 28 | + protected function getDefaultZoom() { |
| 29 | + global $egMapsGoogleMapsZoom; |
| 30 | + return $egMapsGoogleMapsZoom; |
| 31 | + } |
| 32 | + |
| 33 | + public function getSpecificParameterInfo() { |
| 34 | + global $egMapsGMapOverlays; |
| 35 | + $this->spesificParameters = array( |
| 36 | + 'overlays' => array( |
| 37 | + 'type' => array( 'string', 'list' ), |
| 38 | + 'criteria' => array( |
| 39 | + 'is_google_overlay' => array() |
| 40 | + ), |
| 41 | + 'default' => $egMapsGMapOverlays, |
| 42 | + ), |
| 43 | + ); |
| 44 | + return $this->spesificParameters; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @see MapsBaseMap::doMapServiceLoad() |
| 49 | + */ |
| 50 | + public function doMapServiceLoad() { |
| 51 | + global $egGoogleMapsOnThisPage; |
| 52 | + |
| 53 | + MapsGoogleMaps::addGMapDependencies( $this->output ); |
| 54 | + $egGoogleMapsOnThisPage++; |
| 55 | + |
| 56 | + $this->elementNr = $egGoogleMapsOnThisPage; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 61 | + */ |
| 62 | + public function addSpecificMapHTML( Parser $parser ) { |
| 63 | + global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage; |
| 64 | + |
| 65 | + $mapName = $egMapsGoogleMapsPrefix . '_' . $egGoogleMapsOnThisPage; |
| 66 | + |
| 67 | + MapsGoogleMaps::addOverlayOutput( $this->output, $mapName, $this->overlays, $this->controls ); |
| 68 | + |
| 69 | + $this->output .= Html::element( |
| 70 | + 'div', |
| 71 | + array( |
| 72 | + 'id' => $mapName, |
| 73 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 74 | + ), |
| 75 | + wfMsg( 'maps-loading-map' ) |
| 76 | + ); |
| 77 | + |
| 78 | + $parser->getOutput()->addHeadItem( |
| 79 | + Html::inlineScript( <<<EOT |
| 80 | +addOnloadHook( |
| 81 | + function() { |
| 82 | + initializeGoogleMap('$mapName', |
| 83 | + { |
| 84 | + lat: $this->centreLat, |
| 85 | + lon: $this->centreLon, |
| 86 | + zoom: $this->zoom, |
| 87 | + type: $this->type, |
| 88 | + types: [$this->types], |
| 89 | + controls: [$this->controls], |
| 90 | + scrollWheelZoom: $this->autozoom |
| 91 | + }, |
| 92 | + []); |
| 93 | + } |
| 94 | +); |
| 95 | +EOT |
| 96 | + ) ); |
| 97 | + |
| 98 | + } |
| 99 | + |
| 100 | +} |
| 101 | + |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
102 | 102 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -1,373 +1,373 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all Google Maps related files of the Maps extension.
|
6 | | - *
|
7 | | - * @defgroup MapsGoogleMaps Google Maps
|
8 | | - * @ingroup Maps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the Google Maps service
|
13 | | - *
|
14 | | - * @file Maps_GoogleMaps.php
|
15 | | - * @ingroup MapsGoogleMaps
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['MapsGoogleMaps'] = dirname( __FILE__ ) . '/Maps_GoogleMaps.php';
|
25 | | -
|
26 | | -$wgHooks['MappingServiceLoad'][] = 'MapsGoogleMaps::initialize';
|
27 | | -
|
28 | | -$wgAutoloadClasses['MapsGoogleMapsDispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispMap.php';
|
29 | | -$wgAutoloadClasses['MapsGoogleMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispPoint.php';
|
30 | | -
|
31 | | -$egMapsServices[MapsGoogleMaps::SERVICE_NAME] = array(
|
32 | | - 'aliases' => array( 'googlemaps', 'google', 'googlemap', 'gmap', 'gmaps' ),
|
33 | | - 'features' => array(
|
34 | | - 'display_point' => 'MapsGoogleMapsDispPoint',
|
35 | | - 'display_map' => 'MapsGoogleMapsDispMap',
|
36 | | - )
|
37 | | -);
|
38 | | -
|
39 | | -/**
|
40 | | - * Class for Google Maps initialization.
|
41 | | - *
|
42 | | - * @ingroup MapsGoogleMaps
|
43 | | - *
|
44 | | - * @author Jeroen De Dauw
|
45 | | - */
|
46 | | -class MapsGoogleMaps {
|
47 | | -
|
48 | | - const SERVICE_NAME = 'googlemaps2';
|
49 | | -
|
50 | | - public static function initialize() {
|
51 | | - global $wgAutoloadClasses, $egMapsServices;
|
52 | | -
|
53 | | - self::initializeParams();
|
54 | | -
|
55 | | - Validator::addOutputFormat( 'gmaptype', array( __CLASS__, 'setGMapType' ) );
|
56 | | - Validator::addOutputFormat( 'gmaptypes', array( __CLASS__, 'setGMapTypes' ) );
|
57 | | -
|
58 | | - Validator::addValidationFunction( 'is_google_overlay', array( __CLASS__, 'isGOverlay' ) );
|
59 | | -
|
60 | | - return true;
|
61 | | - }
|
62 | | -
|
63 | | - private static function initializeParams() {
|
64 | | - global $egMapsServices, $egMapsGoogleMapsType, $egMapsGoogleMapsTypes, $egMapsGoogleAutozoom, $egMapsGMapControls;
|
65 | | -
|
66 | | - $allowedTypes = self::getTypeNames();
|
67 | | -
|
68 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
|
69 | | - 'controls' => array(
|
70 | | - 'type' => array( 'string', 'list' ),
|
71 | | - 'criteria' => array(
|
72 | | - 'in_array' => self::getControlNames()
|
73 | | - ),
|
74 | | - 'default' => $egMapsGMapControls,
|
75 | | - 'output-type' => array( 'list', ',', '\'' )
|
76 | | - ),
|
77 | | - 'type' => array(
|
78 | | - 'aliases' => array( 'map-type', 'map type' ),
|
79 | | - 'criteria' => array(
|
80 | | - 'in_array' => $allowedTypes
|
81 | | - ),
|
82 | | - 'default' => $egMapsGoogleMapsType, // FIXME: default value should not be used when not present in types parameter.
|
83 | | - 'output-type' => 'gmaptype'
|
84 | | - ),
|
85 | | - 'types' => array(
|
86 | | - 'type' => array( 'string', 'list' ),
|
87 | | - 'aliases' => array( 'map-types', 'map types' ),
|
88 | | - 'criteria' => array(
|
89 | | - 'in_array' => $allowedTypes
|
90 | | - ),
|
91 | | - 'default' => $egMapsGoogleMapsTypes,
|
92 | | - 'output-types' => array( 'gmaptypes', 'list' )
|
93 | | - ),
|
94 | | - 'autozoom' => array(
|
95 | | - 'type' => 'boolean',
|
96 | | - 'aliases' => array( 'auto zoom', 'mouse zoom', 'mousezoom' ),
|
97 | | - 'default' => $egMapsGoogleAutozoom,
|
98 | | - 'output-type' => 'boolstr'
|
99 | | - ),
|
100 | | - );
|
101 | | -
|
102 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 20 );
|
103 | | - }
|
104 | | -
|
105 | | - // http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP
|
106 | | - private static $mapTypes = array(
|
107 | | - 'normal' => 'G_NORMAL_MAP',
|
108 | | - 'satellite' => 'G_SATELLITE_MAP',
|
109 | | - 'hybrid' => 'G_HYBRID_MAP',
|
110 | | - 'terrain' => 'G_PHYSICAL_MAP',
|
111 | | - 'physical' => 'G_PHYSICAL_MAP',
|
112 | | - 'earth' => 'G_SATELLITE_3D_MAP',
|
113 | | - 'sky' => 'G_SKY_VISIBLE_MAP',
|
114 | | - 'moon' => 'G_MOON_VISIBLE_MAP',
|
115 | | - 'moon-elevation' => 'G_MOON_ELEVATION_MAP',
|
116 | | - 'mars' => 'G_MARS_VISIBLE_MAP',
|
117 | | - 'mars-elevation' => 'G_MARS_ELEVATION_MAP',
|
118 | | - 'mars-infrared' => 'G_MARS_INFRARED_MAP'
|
119 | | - );
|
120 | | -
|
121 | | - private static $overlayData = array(
|
122 | | - 'photos' => '0',
|
123 | | - 'videos' => '1',
|
124 | | - 'wikipedia' => '2',
|
125 | | - 'webcams' => '3'
|
126 | | - );
|
127 | | -
|
128 | | - /**
|
129 | | - * Returns the names of all supported map types.
|
130 | | - *
|
131 | | - * @return array
|
132 | | - */
|
133 | | - public static function getTypeNames() {
|
134 | | - return array_keys( self::$mapTypes );
|
135 | | - }
|
136 | | -
|
137 | | - /**
|
138 | | - * Returns the names of all supported controls.
|
139 | | - * This data is a copy of the one used to actually translate the names
|
140 | | - * into the controls, since this resides client side, in GoogleMapFunctions.js.
|
141 | | - *
|
142 | | - * @return array
|
143 | | - */
|
144 | | - public static function getControlNames() {
|
145 | | - return array(
|
146 | | - 'auto', 'large', 'small', 'large-original', 'small-original', 'zoom', 'type', 'type-menu',
|
147 | | - 'overlays', 'overview', 'overview-map', 'scale', 'nav-label', 'nav'
|
148 | | - );
|
149 | | - }
|
150 | | -
|
151 | | - /**
|
152 | | - * Returns the names of all supported map overlays.
|
153 | | - *
|
154 | | - * @return array
|
155 | | - */
|
156 | | - public static function getOverlayNames() {
|
157 | | - return array_keys( self::$overlayData );
|
158 | | - }
|
159 | | -
|
160 | | - /**
|
161 | | - * Returns whether the provided value is a valid google overlay.
|
162 | | - *
|
163 | | - * @param $value
|
164 | | - *
|
165 | | - * @return boolean
|
166 | | - */
|
167 | | - public static function isGOverlay( $value ) {
|
168 | | - $value = explode( '-', $value );
|
169 | | - return in_array( $value[0], self::getOverlayNames() );
|
170 | | - }
|
171 | | -
|
172 | | - /**
|
173 | | - * Changes the map type name into the corresponding Google Maps API v2 identifier.
|
174 | | - *
|
175 | | - * @param string $type
|
176 | | - *
|
177 | | - * @return string
|
178 | | - */
|
179 | | - public static function setGMapType( &$type ) {
|
180 | | - $type = self::$mapTypes[ $type ];
|
181 | | - }
|
182 | | -
|
183 | | - /**
|
184 | | - * Changes the map type names into the corresponding Google Maps API v2 identifiers.
|
185 | | - *
|
186 | | - * @param array $types
|
187 | | - *
|
188 | | - * @return array
|
189 | | - */
|
190 | | - public static function setGMapTypes( array &$types ) {
|
191 | | - for ( $i = count( $types ) - 1; $i >= 0; $i-- ) {
|
192 | | - $types[$i] = self::$mapTypes[ $types[$i] ];
|
193 | | - }
|
194 | | - }
|
195 | | -
|
196 | | - /**
|
197 | | - * Add references to the Google Maps API and required JS file to the provided output
|
198 | | - *
|
199 | | - * @param string $output
|
200 | | - */
|
201 | | - public static function addGMapDependencies( &$output ) {
|
202 | | - global $wgJsMimeType, $wgLang;
|
203 | | - global $egGoogleMapsKey, $egGoogleMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
|
204 | | -
|
205 | | - if ( empty( $egGoogleMapsOnThisPage ) ) {
|
206 | | - $egGoogleMapsOnThisPage = 0;
|
207 | | -
|
208 | | - MapsGoogleMaps::validateGoogleMapsKey();
|
209 | | -
|
210 | | - $langCode = self::getMappedLanguageCode( $wgLang->getCode() );
|
211 | | - $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$langCode}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>";
|
212 | | - }
|
213 | | - }
|
214 | | -
|
215 | | - /**
|
216 | | - * Maps language codes to Google Maps API v2 compatible values.
|
217 | | - *
|
218 | | - * @param string $code
|
219 | | - *
|
220 | | - * @return string The mapped code
|
221 | | - */
|
222 | | - private static function getMappedLanguageCode( $code ) {
|
223 | | - $mappings = array(
|
224 | | - 'en_gb' => 'en',// v2 does not support en_gb - use english :(
|
225 | | - 'he' => 'iw', // iw is googlish for hebrew
|
226 | | - 'fj' => 'fil', // google does not support Fijian - use Filipino as close(?) supported relative
|
227 | | - 'or' => 'en' // v2 does not support Oriya.
|
228 | | - );
|
229 | | - if ( array_key_exists( $code, $mappings ) ) {
|
230 | | - $code = $mappings[$code];
|
231 | | - }
|
232 | | - return $code;
|
233 | | - }
|
234 | | -
|
235 | | - /**
|
236 | | - * This function ensures backward compatibility with Semantic Google Maps and other extensions
|
237 | | - * using $wgGoogleMapsKey instead of $egGoogleMapsKey.
|
238 | | - *
|
239 | | - * FIXME: Possible vunerability when register globals is on.
|
240 | | - */
|
241 | | - public static function validateGoogleMapsKey() {
|
242 | | - global $egGoogleMapsKey, $wgGoogleMapsKey;
|
243 | | -
|
244 | | - if ( isset( $wgGoogleMapsKey ) ) {
|
245 | | - if ( strlen( trim( $egGoogleMapsKey ) ) < 1 ) $egGoogleMapsKey = $wgGoogleMapsKey;
|
246 | | - }
|
247 | | - }
|
248 | | -
|
249 | | - /**
|
250 | | - * Adds the needed output for the overlays control.
|
251 | | - *
|
252 | | - * @param string $output
|
253 | | - * @param string $mapName
|
254 | | - * @param string $overlays
|
255 | | - * @param string $controls
|
256 | | - */
|
257 | | - public static function addOverlayOutput( &$output, $mapName, $overlays, $controls ) {
|
258 | | - global $egMapsGMapOverlays, $egMapsGoogleOverlLoaded, $wgJsMimeType;
|
259 | | -
|
260 | | - // Check to see if there is an overlays control.
|
261 | | - $hasOverlayControl = in_string( 'overlays', $controls );
|
262 | | -
|
263 | | - $overlayNames = array_keys( self::$overlayData );
|
264 | | -
|
265 | | - $validOverlays = array();
|
266 | | - foreach ( $overlays as $overlay ) {
|
267 | | - $segements = explode( '-', $overlay );
|
268 | | - $name = $segements[0];
|
269 | | -
|
270 | | - if ( in_array( $name, $overlayNames ) ) {
|
271 | | - $isOn = count( $segements ) > 1 ? $segements[1] : '0';
|
272 | | - $validOverlays[$name] = $isOn == '1';
|
273 | | - }
|
274 | | - }
|
275 | | - $overlays = $validOverlays;
|
276 | | -
|
277 | | - // If there are no overlays or there is no control to hold them, don't bother the rest.
|
278 | | - if ( !$hasOverlayControl || count( $overlays ) < 1 ) return;
|
279 | | -
|
280 | | - // If the overlays JS and CSS has not yet loaded, do it.
|
281 | | - if ( empty( $egMapsGoogleOverlLoaded ) ) {
|
282 | | - $egMapsGoogleOverlLoaded = true;
|
283 | | - MapsGoogleMaps::addOverlayCss( $output );
|
284 | | - }
|
285 | | -
|
286 | | - // Add the inputs for the overlays.
|
287 | | - $addedOverlays = array();
|
288 | | - $overlayHtml = '';
|
289 | | - $onloadFunctions = array();
|
290 | | - foreach ( $overlays as $overlay => $isOn ) {
|
291 | | - $overlay = strtolower( $overlay );
|
292 | | -
|
293 | | - if ( in_array( $overlay, $overlayNames ) ) {
|
294 | | - if ( ! in_array( $overlay, $addedOverlays ) ) {
|
295 | | - $addedOverlays[] = $overlay;
|
296 | | - $label = wfMsg( 'maps_' . $overlay );
|
297 | | - $urlNr = self::$overlayData[$overlay];
|
298 | | - $overlayHtml .= "<input id='$mapName-overlay-box-$overlay' name='$mapName-overlay-box' type='checkbox' onclick='switchGLayer(GMaps[\"$mapName\"], this.checked, GOverlays[$urlNr])' /> $label <br />";
|
299 | | - if ( $isOn ) {
|
300 | | - $onloadFunctions .= "addOnloadHook( function() { initiateGOverlay('$mapName-overlay-box-$overlay', '$mapName', $urlNr) } );";
|
301 | | - }
|
302 | | - }
|
303 | | - }
|
304 | | - }
|
305 | | -
|
306 | | - $output .= <<<EOT
|
307 | | -<script type='$wgJsMimeType'>var timer_$mapName;</script>
|
308 | | -<div class='outer-more' id='$mapName-outer-more'><form action=''><div class='more-box' id='$mapName-more-box'>
|
309 | | -$overlayHtml
|
310 | | -</div></form></div>
|
311 | | -EOT;
|
312 | | -
|
313 | | - if ( count($onloadFunctions) > 0 ) {
|
314 | | - $output .= "<script type='$wgJsMimeType'>" . implode( "\n", $onloadFunctions ) . '</script>';
|
315 | | - }
|
316 | | - }
|
317 | | -
|
318 | | - /**
|
319 | | - * Add CSS for the overlays.
|
320 | | - *
|
321 | | - * @param $output
|
322 | | - *
|
323 | | - * TODO
|
324 | | - */
|
325 | | - private static function addOverlayCss( &$output ) {
|
326 | | - $css = <<<END
|
327 | | -
|
328 | | -<style type="text/css">
|
329 | | -.inner-more {
|
330 | | - text-align:center;
|
331 | | - font-size:12px;
|
332 | | - background-color: #fff;
|
333 | | - color: #000;
|
334 | | - border: 1px solid #fff;
|
335 | | - border-right-color: #b0b0b0;
|
336 | | - border-bottom-color: #c0c0c0;
|
337 | | - width:7em;
|
338 | | - cursor: pointer;
|
339 | | -}
|
340 | | -
|
341 | | -.inner-more.highlight {
|
342 | | - font-weight: bold;
|
343 | | - border: 1px solid #483D8B;
|
344 | | - border-right-color: #6495ed;
|
345 | | - border-bottom-color: #6495ed;
|
346 | | -}
|
347 | | -
|
348 | | -.more-box { position:absolute;
|
349 | | - top:25px; left:0px;
|
350 | | - margin-top:-1px;
|
351 | | - font-size:12px;
|
352 | | - padding: 6px 4px;
|
353 | | - width:120px;
|
354 | | - background-color: #fff;
|
355 | | - color: #000;
|
356 | | - border: 1px solid gray;
|
357 | | - border-top:1px solid #e2e2e2;
|
358 | | - display: none;
|
359 | | - cursor:default;
|
360 | | -}
|
361 | | -
|
362 | | -.more-box.highlight {
|
363 | | - width:119px;
|
364 | | - border-width:2px;
|
365 | | -}
|
366 | | -</style>
|
367 | | -
|
368 | | -END;
|
369 | | -
|
370 | | - $output .= preg_replace( '/\s+/m', ' ', $css );
|
371 | | - }
|
372 | | -
|
373 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all Google Maps related files of the Maps extension. |
| 6 | + * |
| 7 | + * @defgroup MapsGoogleMaps Google Maps |
| 8 | + * @ingroup Maps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the Google Maps service |
| 13 | + * |
| 14 | + * @file Maps_GoogleMaps.php |
| 15 | + * @ingroup MapsGoogleMaps |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['MapsGoogleMaps'] = dirname( __FILE__ ) . '/Maps_GoogleMaps.php'; |
| 25 | + |
| 26 | +$wgHooks['MappingServiceLoad'][] = 'MapsGoogleMaps::initialize'; |
| 27 | + |
| 28 | +$wgAutoloadClasses['MapsGoogleMapsDispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispMap.php'; |
| 29 | +$wgAutoloadClasses['MapsGoogleMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispPoint.php'; |
| 30 | + |
| 31 | +$egMapsServices[MapsGoogleMaps::SERVICE_NAME] = array( |
| 32 | + 'aliases' => array( 'googlemaps', 'google', 'googlemap', 'gmap', 'gmaps' ), |
| 33 | + 'features' => array( |
| 34 | + 'display_point' => 'MapsGoogleMapsDispPoint', |
| 35 | + 'display_map' => 'MapsGoogleMapsDispMap', |
| 36 | + ) |
| 37 | +); |
| 38 | + |
| 39 | +/** |
| 40 | + * Class for Google Maps initialization. |
| 41 | + * |
| 42 | + * @ingroup MapsGoogleMaps |
| 43 | + * |
| 44 | + * @author Jeroen De Dauw |
| 45 | + */ |
| 46 | +class MapsGoogleMaps { |
| 47 | + |
| 48 | + const SERVICE_NAME = 'googlemaps2'; |
| 49 | + |
| 50 | + public static function initialize() { |
| 51 | + global $wgAutoloadClasses, $egMapsServices; |
| 52 | + |
| 53 | + self::initializeParams(); |
| 54 | + |
| 55 | + Validator::addOutputFormat( 'gmaptype', array( __CLASS__, 'setGMapType' ) ); |
| 56 | + Validator::addOutputFormat( 'gmaptypes', array( __CLASS__, 'setGMapTypes' ) ); |
| 57 | + |
| 58 | + Validator::addValidationFunction( 'is_google_overlay', array( __CLASS__, 'isGOverlay' ) ); |
| 59 | + |
| 60 | + return true; |
| 61 | + } |
| 62 | + |
| 63 | + private static function initializeParams() { |
| 64 | + global $egMapsServices, $egMapsGoogleMapsType, $egMapsGoogleMapsTypes, $egMapsGoogleAutozoom, $egMapsGMapControls; |
| 65 | + |
| 66 | + $allowedTypes = self::getTypeNames(); |
| 67 | + |
| 68 | + $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 69 | + 'controls' => array( |
| 70 | + 'type' => array( 'string', 'list' ), |
| 71 | + 'criteria' => array( |
| 72 | + 'in_array' => self::getControlNames() |
| 73 | + ), |
| 74 | + 'default' => $egMapsGMapControls, |
| 75 | + 'output-type' => array( 'list', ',', '\'' ) |
| 76 | + ), |
| 77 | + 'type' => array( |
| 78 | + 'aliases' => array( 'map-type', 'map type' ), |
| 79 | + 'criteria' => array( |
| 80 | + 'in_array' => $allowedTypes |
| 81 | + ), |
| 82 | + 'default' => $egMapsGoogleMapsType, // FIXME: default value should not be used when not present in types parameter. |
| 83 | + 'output-type' => 'gmaptype' |
| 84 | + ), |
| 85 | + 'types' => array( |
| 86 | + 'type' => array( 'string', 'list' ), |
| 87 | + 'aliases' => array( 'map-types', 'map types' ), |
| 88 | + 'criteria' => array( |
| 89 | + 'in_array' => $allowedTypes |
| 90 | + ), |
| 91 | + 'default' => $egMapsGoogleMapsTypes, |
| 92 | + 'output-types' => array( 'gmaptypes', 'list' ) |
| 93 | + ), |
| 94 | + 'autozoom' => array( |
| 95 | + 'type' => 'boolean', |
| 96 | + 'aliases' => array( 'auto zoom', 'mouse zoom', 'mousezoom' ), |
| 97 | + 'default' => $egMapsGoogleAutozoom, |
| 98 | + 'output-type' => 'boolstr' |
| 99 | + ), |
| 100 | + ); |
| 101 | + |
| 102 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 20 ); |
| 103 | + } |
| 104 | + |
| 105 | + // http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP |
| 106 | + private static $mapTypes = array( |
| 107 | + 'normal' => 'G_NORMAL_MAP', |
| 108 | + 'satellite' => 'G_SATELLITE_MAP', |
| 109 | + 'hybrid' => 'G_HYBRID_MAP', |
| 110 | + 'terrain' => 'G_PHYSICAL_MAP', |
| 111 | + 'physical' => 'G_PHYSICAL_MAP', |
| 112 | + 'earth' => 'G_SATELLITE_3D_MAP', |
| 113 | + 'sky' => 'G_SKY_VISIBLE_MAP', |
| 114 | + 'moon' => 'G_MOON_VISIBLE_MAP', |
| 115 | + 'moon-elevation' => 'G_MOON_ELEVATION_MAP', |
| 116 | + 'mars' => 'G_MARS_VISIBLE_MAP', |
| 117 | + 'mars-elevation' => 'G_MARS_ELEVATION_MAP', |
| 118 | + 'mars-infrared' => 'G_MARS_INFRARED_MAP' |
| 119 | + ); |
| 120 | + |
| 121 | + private static $overlayData = array( |
| 122 | + 'photos' => '0', |
| 123 | + 'videos' => '1', |
| 124 | + 'wikipedia' => '2', |
| 125 | + 'webcams' => '3' |
| 126 | + ); |
| 127 | + |
| 128 | + /** |
| 129 | + * Returns the names of all supported map types. |
| 130 | + * |
| 131 | + * @return array |
| 132 | + */ |
| 133 | + public static function getTypeNames() { |
| 134 | + return array_keys( self::$mapTypes ); |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * Returns the names of all supported controls. |
| 139 | + * This data is a copy of the one used to actually translate the names |
| 140 | + * into the controls, since this resides client side, in GoogleMapFunctions.js. |
| 141 | + * |
| 142 | + * @return array |
| 143 | + */ |
| 144 | + public static function getControlNames() { |
| 145 | + return array( |
| 146 | + 'auto', 'large', 'small', 'large-original', 'small-original', 'zoom', 'type', 'type-menu', |
| 147 | + 'overlays', 'overview', 'overview-map', 'scale', 'nav-label', 'nav' |
| 148 | + ); |
| 149 | + } |
| 150 | + |
| 151 | + /** |
| 152 | + * Returns the names of all supported map overlays. |
| 153 | + * |
| 154 | + * @return array |
| 155 | + */ |
| 156 | + public static function getOverlayNames() { |
| 157 | + return array_keys( self::$overlayData ); |
| 158 | + } |
| 159 | + |
| 160 | + /** |
| 161 | + * Returns whether the provided value is a valid google overlay. |
| 162 | + * |
| 163 | + * @param $value |
| 164 | + * |
| 165 | + * @return boolean |
| 166 | + */ |
| 167 | + public static function isGOverlay( $value ) { |
| 168 | + $value = explode( '-', $value ); |
| 169 | + return in_array( $value[0], self::getOverlayNames() ); |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * Changes the map type name into the corresponding Google Maps API v2 identifier. |
| 174 | + * |
| 175 | + * @param string $type |
| 176 | + * |
| 177 | + * @return string |
| 178 | + */ |
| 179 | + public static function setGMapType( &$type ) { |
| 180 | + $type = self::$mapTypes[ $type ]; |
| 181 | + } |
| 182 | + |
| 183 | + /** |
| 184 | + * Changes the map type names into the corresponding Google Maps API v2 identifiers. |
| 185 | + * |
| 186 | + * @param array $types |
| 187 | + * |
| 188 | + * @return array |
| 189 | + */ |
| 190 | + public static function setGMapTypes( array &$types ) { |
| 191 | + for ( $i = count( $types ) - 1; $i >= 0; $i-- ) { |
| 192 | + $types[$i] = self::$mapTypes[ $types[$i] ]; |
| 193 | + } |
| 194 | + } |
| 195 | + |
| 196 | + /** |
| 197 | + * Add references to the Google Maps API and required JS file to the provided output |
| 198 | + * |
| 199 | + * @param string $output |
| 200 | + */ |
| 201 | + public static function addGMapDependencies( &$output ) { |
| 202 | + global $wgJsMimeType, $wgLang; |
| 203 | + global $egGoogleMapsKey, $egGoogleMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath; |
| 204 | + |
| 205 | + if ( empty( $egGoogleMapsOnThisPage ) ) { |
| 206 | + $egGoogleMapsOnThisPage = 0; |
| 207 | + |
| 208 | + MapsGoogleMaps::validateGoogleMapsKey(); |
| 209 | + |
| 210 | + $langCode = self::getMappedLanguageCode( $wgLang->getCode() ); |
| 211 | + $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$langCode}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>"; |
| 212 | + } |
| 213 | + } |
| 214 | + |
| 215 | + /** |
| 216 | + * Maps language codes to Google Maps API v2 compatible values. |
| 217 | + * |
| 218 | + * @param string $code |
| 219 | + * |
| 220 | + * @return string The mapped code |
| 221 | + */ |
| 222 | + private static function getMappedLanguageCode( $code ) { |
| 223 | + $mappings = array( |
| 224 | + 'en_gb' => 'en',// v2 does not support en_gb - use english :( |
| 225 | + 'he' => 'iw', // iw is googlish for hebrew |
| 226 | + 'fj' => 'fil', // google does not support Fijian - use Filipino as close(?) supported relative |
| 227 | + 'or' => 'en' // v2 does not support Oriya. |
| 228 | + ); |
| 229 | + if ( array_key_exists( $code, $mappings ) ) { |
| 230 | + $code = $mappings[$code]; |
| 231 | + } |
| 232 | + return $code; |
| 233 | + } |
| 234 | + |
| 235 | + /** |
| 236 | + * This function ensures backward compatibility with Semantic Google Maps and other extensions |
| 237 | + * using $wgGoogleMapsKey instead of $egGoogleMapsKey. |
| 238 | + * |
| 239 | + * FIXME: Possible vunerability when register globals is on. |
| 240 | + */ |
| 241 | + public static function validateGoogleMapsKey() { |
| 242 | + global $egGoogleMapsKey, $wgGoogleMapsKey; |
| 243 | + |
| 244 | + if ( isset( $wgGoogleMapsKey ) ) { |
| 245 | + if ( strlen( trim( $egGoogleMapsKey ) ) < 1 ) $egGoogleMapsKey = $wgGoogleMapsKey; |
| 246 | + } |
| 247 | + } |
| 248 | + |
| 249 | + /** |
| 250 | + * Adds the needed output for the overlays control. |
| 251 | + * |
| 252 | + * @param string $output |
| 253 | + * @param string $mapName |
| 254 | + * @param string $overlays |
| 255 | + * @param string $controls |
| 256 | + */ |
| 257 | + public static function addOverlayOutput( &$output, $mapName, $overlays, $controls ) { |
| 258 | + global $egMapsGMapOverlays, $egMapsGoogleOverlLoaded, $wgJsMimeType; |
| 259 | + |
| 260 | + // Check to see if there is an overlays control. |
| 261 | + $hasOverlayControl = in_string( 'overlays', $controls ); |
| 262 | + |
| 263 | + $overlayNames = array_keys( self::$overlayData ); |
| 264 | + |
| 265 | + $validOverlays = array(); |
| 266 | + foreach ( $overlays as $overlay ) { |
| 267 | + $segements = explode( '-', $overlay ); |
| 268 | + $name = $segements[0]; |
| 269 | + |
| 270 | + if ( in_array( $name, $overlayNames ) ) { |
| 271 | + $isOn = count( $segements ) > 1 ? $segements[1] : '0'; |
| 272 | + $validOverlays[$name] = $isOn == '1'; |
| 273 | + } |
| 274 | + } |
| 275 | + $overlays = $validOverlays; |
| 276 | + |
| 277 | + // If there are no overlays or there is no control to hold them, don't bother the rest. |
| 278 | + if ( !$hasOverlayControl || count( $overlays ) < 1 ) return; |
| 279 | + |
| 280 | + // If the overlays JS and CSS has not yet loaded, do it. |
| 281 | + if ( empty( $egMapsGoogleOverlLoaded ) ) { |
| 282 | + $egMapsGoogleOverlLoaded = true; |
| 283 | + MapsGoogleMaps::addOverlayCss( $output ); |
| 284 | + } |
| 285 | + |
| 286 | + // Add the inputs for the overlays. |
| 287 | + $addedOverlays = array(); |
| 288 | + $overlayHtml = ''; |
| 289 | + $onloadFunctions = array(); |
| 290 | + foreach ( $overlays as $overlay => $isOn ) { |
| 291 | + $overlay = strtolower( $overlay ); |
| 292 | + |
| 293 | + if ( in_array( $overlay, $overlayNames ) ) { |
| 294 | + if ( ! in_array( $overlay, $addedOverlays ) ) { |
| 295 | + $addedOverlays[] = $overlay; |
| 296 | + $label = wfMsg( 'maps_' . $overlay ); |
| 297 | + $urlNr = self::$overlayData[$overlay]; |
| 298 | + $overlayHtml .= "<input id='$mapName-overlay-box-$overlay' name='$mapName-overlay-box' type='checkbox' onclick='switchGLayer(GMaps[\"$mapName\"], this.checked, GOverlays[$urlNr])' /> $label <br />"; |
| 299 | + if ( $isOn ) { |
| 300 | + $onloadFunctions .= "addOnloadHook( function() { initiateGOverlay('$mapName-overlay-box-$overlay', '$mapName', $urlNr) } );"; |
| 301 | + } |
| 302 | + } |
| 303 | + } |
| 304 | + } |
| 305 | + |
| 306 | + $output .= <<<EOT |
| 307 | +<script type='$wgJsMimeType'>var timer_$mapName;</script> |
| 308 | +<div class='outer-more' id='$mapName-outer-more'><form action=''><div class='more-box' id='$mapName-more-box'> |
| 309 | +$overlayHtml |
| 310 | +</div></form></div> |
| 311 | +EOT; |
| 312 | + |
| 313 | + if ( count($onloadFunctions) > 0 ) { |
| 314 | + $output .= "<script type='$wgJsMimeType'>" . implode( "\n", $onloadFunctions ) . '</script>'; |
| 315 | + } |
| 316 | + } |
| 317 | + |
| 318 | + /** |
| 319 | + * Add CSS for the overlays. |
| 320 | + * |
| 321 | + * @param $output |
| 322 | + * |
| 323 | + * TODO |
| 324 | + */ |
| 325 | + private static function addOverlayCss( &$output ) { |
| 326 | + $css = <<<END |
| 327 | + |
| 328 | +<style type="text/css"> |
| 329 | +.inner-more { |
| 330 | + text-align:center; |
| 331 | + font-size:12px; |
| 332 | + background-color: #fff; |
| 333 | + color: #000; |
| 334 | + border: 1px solid #fff; |
| 335 | + border-right-color: #b0b0b0; |
| 336 | + border-bottom-color: #c0c0c0; |
| 337 | + width:7em; |
| 338 | + cursor: pointer; |
| 339 | +} |
| 340 | + |
| 341 | +.inner-more.highlight { |
| 342 | + font-weight: bold; |
| 343 | + border: 1px solid #483D8B; |
| 344 | + border-right-color: #6495ed; |
| 345 | + border-bottom-color: #6495ed; |
| 346 | +} |
| 347 | + |
| 348 | +.more-box { position:absolute; |
| 349 | + top:25px; left:0px; |
| 350 | + margin-top:-1px; |
| 351 | + font-size:12px; |
| 352 | + padding: 6px 4px; |
| 353 | + width:120px; |
| 354 | + background-color: #fff; |
| 355 | + color: #000; |
| 356 | + border: 1px solid gray; |
| 357 | + border-top:1px solid #e2e2e2; |
| 358 | + display: none; |
| 359 | + cursor:default; |
| 360 | +} |
| 361 | + |
| 362 | +.more-box.highlight { |
| 363 | + width:119px; |
| 364 | + border-width:2px; |
| 365 | +} |
| 366 | +</style> |
| 367 | + |
| 368 | +END; |
| 369 | + |
| 370 | + $output .= preg_replace( '/\s+/m', ' ', $css ); |
| 371 | + } |
| 372 | + |
| 373 | +} |
374 | 374 | |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php |
___________________________________________________________________ |
Added: svn:eol-style |
375 | 375 | + native |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps3/GoogleMap3Functions.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
376 | 376 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispMap.php |
— | — | @@ -1,87 +1,87 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Class for handling the display_map parser function with Google Maps v3.
|
6 | | - *
|
7 | | - * @file Maps_GoogleMaps3DispMap.php
|
8 | | - * @ingroup MapsGoogleMaps3
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Class for handling the display_map parser functions with Google Maps v3.
|
19 | | - *
|
20 | | - * @ingroup MapsGoogleMaps3
|
21 | | - *
|
22 | | - * @author Jeroen De Dauw
|
23 | | - */
|
24 | | -final class MapsGoogleMaps3DispMap extends MapsBaseMap {
|
25 | | -
|
26 | | - public $serviceName = MapsGoogleMaps3::SERVICE_NAME;
|
27 | | -
|
28 | | - protected function getDefaultZoom() {
|
29 | | - global $egMapsGMaps3Zoom;
|
30 | | - return $egMapsGMaps3Zoom;
|
31 | | - }
|
32 | | -
|
33 | | - /**
|
34 | | - * @see MapsBaseMap::doMapServiceLoad()
|
35 | | - *
|
36 | | - */
|
37 | | - protected function doMapServiceLoad() {
|
38 | | - global $egGMaps3OnThisPage;
|
39 | | -
|
40 | | - MapsGoogleMaps3::addGMap3Dependencies( $this->output );
|
41 | | - $egGMaps3OnThisPage++;
|
42 | | -
|
43 | | - $this->elementNr = $egGMaps3OnThisPage;
|
44 | | - }
|
45 | | -
|
46 | | - /**
|
47 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
48 | | - *
|
49 | | - */
|
50 | | - public function addSpecificMapHTML( Parser $parser ) {
|
51 | | - global $egMapsGMaps3Prefix, $egGMaps3OnThisPage;
|
52 | | -
|
53 | | - $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage;
|
54 | | -
|
55 | | - $this->output .= Html::element(
|
56 | | - 'div',
|
57 | | - array(
|
58 | | - 'id' => $mapName,
|
59 | | - 'width' => $this->width,
|
60 | | - 'height' => $this->height
|
61 | | - ),
|
62 | | - null
|
63 | | - );
|
64 | | -
|
65 | | - $parser->getOutput()->addHeadItem(
|
66 | | - Html::inlineScript( <<<EOT
|
67 | | -addOnloadHook(
|
68 | | - function() {
|
69 | | - initGMap3(
|
70 | | - '$mapName',
|
71 | | - {
|
72 | | - zoom: $this->zoom,
|
73 | | - lat: $this->centreLat,
|
74 | | - lon: $this->centreLon,
|
75 | | - types: [],
|
76 | | - mapTypeId: $this->type
|
77 | | - },
|
78 | | - []
|
79 | | - );
|
80 | | - }
|
81 | | -);
|
82 | | -EOT
|
83 | | - )
|
84 | | - );
|
85 | | - }
|
86 | | -
|
87 | | -}
|
88 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class for handling the display_map parser function with Google Maps v3. |
| 6 | + * |
| 7 | + * @file Maps_GoogleMaps3DispMap.php |
| 8 | + * @ingroup MapsGoogleMaps3 |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Class for handling the display_map parser functions with Google Maps v3. |
| 19 | + * |
| 20 | + * @ingroup MapsGoogleMaps3 |
| 21 | + * |
| 22 | + * @author Jeroen De Dauw |
| 23 | + */ |
| 24 | +final class MapsGoogleMaps3DispMap extends MapsBaseMap { |
| 25 | + |
| 26 | + public $serviceName = MapsGoogleMaps3::SERVICE_NAME; |
| 27 | + |
| 28 | + protected function getDefaultZoom() { |
| 29 | + global $egMapsGMaps3Zoom; |
| 30 | + return $egMapsGMaps3Zoom; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @see MapsBaseMap::doMapServiceLoad() |
| 35 | + * |
| 36 | + */ |
| 37 | + protected function doMapServiceLoad() { |
| 38 | + global $egGMaps3OnThisPage; |
| 39 | + |
| 40 | + MapsGoogleMaps3::addGMap3Dependencies( $this->output ); |
| 41 | + $egGMaps3OnThisPage++; |
| 42 | + |
| 43 | + $this->elementNr = $egGMaps3OnThisPage; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 48 | + * |
| 49 | + */ |
| 50 | + public function addSpecificMapHTML( Parser $parser ) { |
| 51 | + global $egMapsGMaps3Prefix, $egGMaps3OnThisPage; |
| 52 | + |
| 53 | + $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage; |
| 54 | + |
| 55 | + $this->output .= Html::element( |
| 56 | + 'div', |
| 57 | + array( |
| 58 | + 'id' => $mapName, |
| 59 | + 'width' => $this->width, |
| 60 | + 'height' => $this->height |
| 61 | + ), |
| 62 | + null |
| 63 | + ); |
| 64 | + |
| 65 | + $parser->getOutput()->addHeadItem( |
| 66 | + Html::inlineScript( <<<EOT |
| 67 | +addOnloadHook( |
| 68 | + function() { |
| 69 | + initGMap3( |
| 70 | + '$mapName', |
| 71 | + { |
| 72 | + zoom: $this->zoom, |
| 73 | + lat: $this->centreLat, |
| 74 | + lon: $this->centreLon, |
| 75 | + types: [], |
| 76 | + mapTypeId: $this->type |
| 77 | + }, |
| 78 | + [] |
| 79 | + ); |
| 80 | + } |
| 81 | +); |
| 82 | +EOT |
| 83 | + ) |
| 84 | + ); |
| 85 | + } |
| 86 | + |
| 87 | +} |
| 88 | + |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
89 | 89 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php |
— | — | @@ -1,165 +1,165 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all Google Maps v3 related files of the Maps extension.
|
6 | | - *
|
7 | | - * @defgroup MapsGoogleMaps3 Google Maps v3
|
8 | | - * @ingroup Maps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the Google Maps v3 service.
|
13 | | - *
|
14 | | - * @file Maps_GoogleMaps3.php
|
15 | | - * @ingroup MapsGoogleMaps3
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['MapsGoogleMaps3'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3.php';
|
25 | | -
|
26 | | -$wgHooks['MappingServiceLoad'][] = 'MapsGoogleMaps3::initialize';
|
27 | | -
|
28 | | -$wgAutoloadClasses['MapsGoogleMaps3DispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3DispMap.php';
|
29 | | -
|
30 | | -$egMapsServices[MapsGoogleMaps3::SERVICE_NAME] = array(
|
31 | | - 'aliases' => array( 'google3', 'googlemap3', 'gmap3', 'gmaps3' ),
|
32 | | - 'features' => array(
|
33 | | - 'display_map' => 'MapsGoogleMaps3DispMap',
|
34 | | - )
|
35 | | -);
|
36 | | -
|
37 | | -/**
|
38 | | - * Class for Google Maps v3 initialization.
|
39 | | - *
|
40 | | - * @ingroup MapsGoogleMaps3
|
41 | | - *
|
42 | | - * @author Jeroen De Dauw
|
43 | | - */
|
44 | | -class MapsGoogleMaps3 {
|
45 | | -
|
46 | | - const SERVICE_NAME = 'googlemaps3';
|
47 | | -
|
48 | | - public static function initialize() {
|
49 | | - global $wgAutoloadClasses, $egMapsServices;
|
50 | | -
|
51 | | - self::initializeParams();
|
52 | | -
|
53 | | - Validator::addOutputFormat( 'gmap3type', array( 'MapsGoogleMaps3', 'setGMapType' ) );
|
54 | | - Validator::addOutputFormat( 'gmap3types', array( 'MapsGoogleMaps3', 'setGMapTypes' ) );
|
55 | | -
|
56 | | - return true;
|
57 | | - }
|
58 | | -
|
59 | | - private static function initializeParams() {
|
60 | | - global $egMapsServices, $egMapsGMaps3Type, $egMapsGMaps3Types;
|
61 | | -
|
62 | | - $allowedTypes = self::getTypeNames();
|
63 | | -
|
64 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
|
65 | | - 'type' => array(
|
66 | | - 'aliases' => array( 'map-type', 'map type' ),
|
67 | | - 'criteria' => array(
|
68 | | - 'in_array' => $allowedTypes
|
69 | | - ),
|
70 | | - 'default' => $egMapsGMaps3Type, // FIXME: default value should not be used when not present in types parameter.
|
71 | | - 'output-type' => 'gmap3type'
|
72 | | - ),
|
73 | | - /*
|
74 | | - 'types' => array(
|
75 | | - 'type' => array('string', 'list'),
|
76 | | - 'aliases' => array('map-types', 'map types'),
|
77 | | - 'criteria' => array(
|
78 | | - 'in_array' => $allowedTypes
|
79 | | - ),
|
80 | | - 'default' => $egMapsGMaps3Types,
|
81 | | - 'output-types' => array('gmap3types', 'list')
|
82 | | - ),
|
83 | | - */
|
84 | | - );
|
85 | | - }
|
86 | | -
|
87 | | - private static $mapTypes = array(
|
88 | | - 'normal' => 'ROADMAP',
|
89 | | - 'roadmap' => 'ROADMAP',
|
90 | | - 'satellite' => 'SATELLITE',
|
91 | | - 'hybrid' => 'HYBRID',
|
92 | | - 'terrain' => 'TERRAIN',
|
93 | | - 'physical' => 'TERRAIN'
|
94 | | - );
|
95 | | -
|
96 | | - /**
|
97 | | - * Returns the names of all supported map types.
|
98 | | - *
|
99 | | - * @return array
|
100 | | - */
|
101 | | - public static function getTypeNames() {
|
102 | | - return array_keys( self::$mapTypes );
|
103 | | - }
|
104 | | -
|
105 | | - /**
|
106 | | - * Changes the map type name into the corresponding Google Maps API v3 identifier.
|
107 | | - *
|
108 | | - * @param string $type
|
109 | | - *
|
110 | | - * @return string
|
111 | | - */
|
112 | | - public static function setGMapType( &$type ) {
|
113 | | - $type = 'google.maps.MapTypeId.' . self::$mapTypes[ $type ];
|
114 | | - }
|
115 | | -
|
116 | | - /**
|
117 | | - * Changes the map type names into the corresponding Google Maps API v3 identifiers.
|
118 | | - *
|
119 | | - * @param array $types
|
120 | | - *
|
121 | | - * @return array
|
122 | | - */
|
123 | | - public static function setGMapTypes( array &$types ) {
|
124 | | - for ( $i = count( $types ) - 1; $i >= 0; $i-- ) {
|
125 | | - self::setGMapType( $types[$i] );
|
126 | | - }
|
127 | | - }
|
128 | | -
|
129 | | - /**
|
130 | | - * Add references to the Google Maps API v3 and required JS file to the provided output
|
131 | | - *
|
132 | | - * @param string $output
|
133 | | - */
|
134 | | - public static function addGMap3Dependencies( &$output ) {
|
135 | | - global $wgJsMimeType, $wgLang;
|
136 | | - global $egGMaps3OnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
|
137 | | -
|
138 | | - if ( empty( $egGMaps3OnThisPage ) ) {
|
139 | | - $egGMaps3OnThisPage = 0;
|
140 | | -
|
141 | | - $languageCode = self::getMappedLanguageCode( $wgLang->getCode() );
|
142 | | - $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&language={$languageCode}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion'></script>";
|
143 | | - }
|
144 | | - }
|
145 | | -
|
146 | | - /**
|
147 | | - * Maps language codes to Google Maps API v3 compatible values.
|
148 | | - *
|
149 | | - * @param string $code
|
150 | | - *
|
151 | | - * @return string The mapped code
|
152 | | - */
|
153 | | - private static function getMappedLanguageCode( $code ) {
|
154 | | - $mappings = array(
|
155 | | - 'en_gb' => 'en-gb',// v3 supports en_gb - but wants us to call it en-gb
|
156 | | - 'he' => 'iw', // iw is googlish for hebrew
|
157 | | - 'fj' => 'fil', // google does not support Fijian - use Filipino as close(?) supported relative
|
158 | | - );
|
159 | | - if ( array_key_exists( $code, $mappings ) ) {
|
160 | | - $code = $mappings[$code];
|
161 | | - }
|
162 | | - return $code;
|
163 | | - }
|
164 | | -
|
165 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all Google Maps v3 related files of the Maps extension. |
| 6 | + * |
| 7 | + * @defgroup MapsGoogleMaps3 Google Maps v3 |
| 8 | + * @ingroup Maps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the Google Maps v3 service. |
| 13 | + * |
| 14 | + * @file Maps_GoogleMaps3.php |
| 15 | + * @ingroup MapsGoogleMaps3 |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['MapsGoogleMaps3'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3.php'; |
| 25 | + |
| 26 | +$wgHooks['MappingServiceLoad'][] = 'MapsGoogleMaps3::initialize'; |
| 27 | + |
| 28 | +$wgAutoloadClasses['MapsGoogleMaps3DispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3DispMap.php'; |
| 29 | + |
| 30 | +$egMapsServices[MapsGoogleMaps3::SERVICE_NAME] = array( |
| 31 | + 'aliases' => array( 'google3', 'googlemap3', 'gmap3', 'gmaps3' ), |
| 32 | + 'features' => array( |
| 33 | + 'display_map' => 'MapsGoogleMaps3DispMap', |
| 34 | + ) |
| 35 | +); |
| 36 | + |
| 37 | +/** |
| 38 | + * Class for Google Maps v3 initialization. |
| 39 | + * |
| 40 | + * @ingroup MapsGoogleMaps3 |
| 41 | + * |
| 42 | + * @author Jeroen De Dauw |
| 43 | + */ |
| 44 | +class MapsGoogleMaps3 { |
| 45 | + |
| 46 | + const SERVICE_NAME = 'googlemaps3'; |
| 47 | + |
| 48 | + public static function initialize() { |
| 49 | + global $wgAutoloadClasses, $egMapsServices; |
| 50 | + |
| 51 | + self::initializeParams(); |
| 52 | + |
| 53 | + Validator::addOutputFormat( 'gmap3type', array( 'MapsGoogleMaps3', 'setGMapType' ) ); |
| 54 | + Validator::addOutputFormat( 'gmap3types', array( 'MapsGoogleMaps3', 'setGMapTypes' ) ); |
| 55 | + |
| 56 | + return true; |
| 57 | + } |
| 58 | + |
| 59 | + private static function initializeParams() { |
| 60 | + global $egMapsServices, $egMapsGMaps3Type, $egMapsGMaps3Types; |
| 61 | + |
| 62 | + $allowedTypes = self::getTypeNames(); |
| 63 | + |
| 64 | + $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 65 | + 'type' => array( |
| 66 | + 'aliases' => array( 'map-type', 'map type' ), |
| 67 | + 'criteria' => array( |
| 68 | + 'in_array' => $allowedTypes |
| 69 | + ), |
| 70 | + 'default' => $egMapsGMaps3Type, // FIXME: default value should not be used when not present in types parameter. |
| 71 | + 'output-type' => 'gmap3type' |
| 72 | + ), |
| 73 | + /* |
| 74 | + 'types' => array( |
| 75 | + 'type' => array('string', 'list'), |
| 76 | + 'aliases' => array('map-types', 'map types'), |
| 77 | + 'criteria' => array( |
| 78 | + 'in_array' => $allowedTypes |
| 79 | + ), |
| 80 | + 'default' => $egMapsGMaps3Types, |
| 81 | + 'output-types' => array('gmap3types', 'list') |
| 82 | + ), |
| 83 | + */ |
| 84 | + ); |
| 85 | + } |
| 86 | + |
| 87 | + private static $mapTypes = array( |
| 88 | + 'normal' => 'ROADMAP', |
| 89 | + 'roadmap' => 'ROADMAP', |
| 90 | + 'satellite' => 'SATELLITE', |
| 91 | + 'hybrid' => 'HYBRID', |
| 92 | + 'terrain' => 'TERRAIN', |
| 93 | + 'physical' => 'TERRAIN' |
| 94 | + ); |
| 95 | + |
| 96 | + /** |
| 97 | + * Returns the names of all supported map types. |
| 98 | + * |
| 99 | + * @return array |
| 100 | + */ |
| 101 | + public static function getTypeNames() { |
| 102 | + return array_keys( self::$mapTypes ); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * Changes the map type name into the corresponding Google Maps API v3 identifier. |
| 107 | + * |
| 108 | + * @param string $type |
| 109 | + * |
| 110 | + * @return string |
| 111 | + */ |
| 112 | + public static function setGMapType( &$type ) { |
| 113 | + $type = 'google.maps.MapTypeId.' . self::$mapTypes[ $type ]; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Changes the map type names into the corresponding Google Maps API v3 identifiers. |
| 118 | + * |
| 119 | + * @param array $types |
| 120 | + * |
| 121 | + * @return array |
| 122 | + */ |
| 123 | + public static function setGMapTypes( array &$types ) { |
| 124 | + for ( $i = count( $types ) - 1; $i >= 0; $i-- ) { |
| 125 | + self::setGMapType( $types[$i] ); |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + /** |
| 130 | + * Add references to the Google Maps API v3 and required JS file to the provided output |
| 131 | + * |
| 132 | + * @param string $output |
| 133 | + */ |
| 134 | + public static function addGMap3Dependencies( &$output ) { |
| 135 | + global $wgJsMimeType, $wgLang; |
| 136 | + global $egGMaps3OnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath; |
| 137 | + |
| 138 | + if ( empty( $egGMaps3OnThisPage ) ) { |
| 139 | + $egGMaps3OnThisPage = 0; |
| 140 | + |
| 141 | + $languageCode = self::getMappedLanguageCode( $wgLang->getCode() ); |
| 142 | + $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&language={$languageCode}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion'></script>"; |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Maps language codes to Google Maps API v3 compatible values. |
| 148 | + * |
| 149 | + * @param string $code |
| 150 | + * |
| 151 | + * @return string The mapped code |
| 152 | + */ |
| 153 | + private static function getMappedLanguageCode( $code ) { |
| 154 | + $mappings = array( |
| 155 | + 'en_gb' => 'en-gb',// v3 supports en_gb - but wants us to call it en-gb |
| 156 | + 'he' => 'iw', // iw is googlish for hebrew |
| 157 | + 'fj' => 'fil', // google does not support Fijian - use Filipino as close(?) supported relative |
| 158 | + ); |
| 159 | + if ( array_key_exists( $code, $mappings ) ) { |
| 160 | + $code = $mappings[$code]; |
| 161 | + } |
| 162 | + return $code; |
| 163 | + } |
| 164 | + |
| 165 | +} |
166 | 166 | |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php |
___________________________________________________________________ |
Added: svn:eol-style |
167 | 167 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispPoint.php |
— | — | @@ -1,89 +1,89 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the MapsGoogleMaps3DispPoint class.
|
6 | | - *
|
7 | | - * @file Maps_GoogleMaps3DispPoint.php
|
8 | | - * @ingroup MapsGoogleMaps3
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Class for handling the display_point(s) parser functions with Google Maps v3.
|
19 | | - *
|
20 | | - * @ingroup MapsGoogleMaps3
|
21 | | - *
|
22 | | - * @author Jeroen De Dauw
|
23 | | - */
|
24 | | -final class MapsGoogleMaps3DispPoint extends MapsBasePointMap {
|
25 | | -
|
26 | | - public $serviceName = MapsGoogleMaps3::SERVICE_NAME;
|
27 | | -
|
28 | | - protected $markerStringFormat = 'getGMaps3MarkerData(lat, lon, \'title\', \'label\', "icon")';
|
29 | | -
|
30 | | - protected function getDefaultZoom() {
|
31 | | - global $egMapsGMaps3Zoom;
|
32 | | - return $egMapsGMaps3Zoom;
|
33 | | - }
|
34 | | -
|
35 | | - /**
|
36 | | - * @see MapsBaseMap::doMapServiceLoad()
|
37 | | - *
|
38 | | - */
|
39 | | - protected function doMapServiceLoad() {
|
40 | | - global $egGMaps3OnThisPage;
|
41 | | -
|
42 | | - MapsGoogleMaps3::addGMap3Dependencies( $this->output );
|
43 | | - $egGMaps3OnThisPage++;
|
44 | | -
|
45 | | - $this->elementNr = $egGMaps3OnThisPage;
|
46 | | - }
|
47 | | -
|
48 | | - /**
|
49 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
50 | | - *
|
51 | | - */
|
52 | | - public function addSpecificMapHTML( Parser $parser ) {
|
53 | | - global $egMapsGMaps3Prefix, $egGMaps3OnThisPage;
|
54 | | -
|
55 | | - $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage;
|
56 | | -
|
57 | | - $this->output .= Html::element(
|
58 | | - 'div',
|
59 | | - array(
|
60 | | - 'id' => $mapName,
|
61 | | - 'width' => $this->width,
|
62 | | - 'height' => $this->height
|
63 | | - ),
|
64 | | - null
|
65 | | - );
|
66 | | -
|
67 | | - $parser->getOutput()->addHeadItem(
|
68 | | - Html::inlineScript( <<<EOT
|
69 | | -addOnloadHook(
|
70 | | - function() {
|
71 | | - initGMap3(
|
72 | | - '$mapName',
|
73 | | - {
|
74 | | - zoom: $this->zoom,
|
75 | | - lat: $this->centreLat,
|
76 | | - lon: $this->centreLon,
|
77 | | - types: [],
|
78 | | - mapTypeId: $this->type
|
79 | | - },
|
80 | | - [$this->markerString]
|
81 | | - );
|
82 | | - }
|
83 | | -);
|
84 | | -EOT
|
85 | | - )
|
86 | | - );
|
87 | | - }
|
88 | | -
|
89 | | -}
|
90 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the MapsGoogleMaps3DispPoint class. |
| 6 | + * |
| 7 | + * @file Maps_GoogleMaps3DispPoint.php |
| 8 | + * @ingroup MapsGoogleMaps3 |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Class for handling the display_point(s) parser functions with Google Maps v3. |
| 19 | + * |
| 20 | + * @ingroup MapsGoogleMaps3 |
| 21 | + * |
| 22 | + * @author Jeroen De Dauw |
| 23 | + */ |
| 24 | +final class MapsGoogleMaps3DispPoint extends MapsBasePointMap { |
| 25 | + |
| 26 | + public $serviceName = MapsGoogleMaps3::SERVICE_NAME; |
| 27 | + |
| 28 | + protected $markerStringFormat = 'getGMaps3MarkerData(lat, lon, \'title\', \'label\', "icon")'; |
| 29 | + |
| 30 | + protected function getDefaultZoom() { |
| 31 | + global $egMapsGMaps3Zoom; |
| 32 | + return $egMapsGMaps3Zoom; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @see MapsBaseMap::doMapServiceLoad() |
| 37 | + * |
| 38 | + */ |
| 39 | + protected function doMapServiceLoad() { |
| 40 | + global $egGMaps3OnThisPage; |
| 41 | + |
| 42 | + MapsGoogleMaps3::addGMap3Dependencies( $this->output ); |
| 43 | + $egGMaps3OnThisPage++; |
| 44 | + |
| 45 | + $this->elementNr = $egGMaps3OnThisPage; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 50 | + * |
| 51 | + */ |
| 52 | + public function addSpecificMapHTML( Parser $parser ) { |
| 53 | + global $egMapsGMaps3Prefix, $egGMaps3OnThisPage; |
| 54 | + |
| 55 | + $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage; |
| 56 | + |
| 57 | + $this->output .= Html::element( |
| 58 | + 'div', |
| 59 | + array( |
| 60 | + 'id' => $mapName, |
| 61 | + 'width' => $this->width, |
| 62 | + 'height' => $this->height |
| 63 | + ), |
| 64 | + null |
| 65 | + ); |
| 66 | + |
| 67 | + $parser->getOutput()->addHeadItem( |
| 68 | + Html::inlineScript( <<<EOT |
| 69 | +addOnloadHook( |
| 70 | + function() { |
| 71 | + initGMap3( |
| 72 | + '$mapName', |
| 73 | + { |
| 74 | + zoom: $this->zoom, |
| 75 | + lat: $this->centreLat, |
| 76 | + lon: $this->centreLon, |
| 77 | + types: [], |
| 78 | + mapTypeId: $this->type |
| 79 | + }, |
| 80 | + [$this->markerString] |
| 81 | + ); |
| 82 | + } |
| 83 | +); |
| 84 | +EOT |
| 85 | + ) |
| 86 | + ); |
| 87 | + } |
| 88 | + |
| 89 | +} |
| 90 | + |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispPoint.php |
___________________________________________________________________ |
Added: svn:eol-style |
91 | 91 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps3/GoogleMap3Functions.js |
— | — | @@ -1,41 +1,41 @@ |
2 | | - /**
|
3 | | - * Javascript functions for Google Maps v3 functionallity in Maps.
|
4 | | - *
|
5 | | - * @file GoogleMap3Functions.js
|
6 | | - * @ingroup MapsGoogleMaps3
|
7 | | - *
|
8 | | - * @author Jeroen De Dauw
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * Created a new Map object with the provided properties and markers.
|
13 | | - */
|
14 | | -function initGMap3(name, options, markerData) {
|
15 | | - options.center = new google.maps.LatLng(options.lat, options.lon);
|
16 | | -
|
17 | | - var map = new google.maps.Map(document.getElementById(name), options);
|
18 | | -
|
19 | | - // TODO: types - http://code.google.com/apis/maps/documentation/v3/reference.html#MapTypeRegistry
|
20 | | -
|
21 | | - for (marker in markerData) getGMaps3Marker(map, markerData[marker]);
|
22 | | -}
|
23 | | -
|
24 | | -function getGMaps3Marker(map, data) {
|
25 | | - var marker = new google.maps.Marker({position: data.position, map: map, title: data.title, icon: data.icon});
|
26 | | -
|
27 | | - var bothTxtAreSet = data.title.length > 0 && data.label.length > 0;
|
28 | | - var popupText = bothTxtAreSet ? '<b>' + data.title + '</b><hr />' + data.label : data.title + data.label;
|
29 | | -
|
30 | | - var infowindow = new google.maps.InfoWindow({content: popupText});
|
31 | | -
|
32 | | - google.maps.event.addListener(marker, "click", function() {
|
33 | | - infowindow.close();
|
34 | | - infowindow.open(map, marker);
|
35 | | - });
|
36 | | -
|
37 | | - return marker;
|
38 | | -}
|
39 | | -
|
40 | | -function getGMaps3MarkerData(lat, lon, title, label, icon) {
|
41 | | - return {position: new google.maps.LatLng(lat, lon), title: title, label: label, icon: icon};
|
| 2 | + /** |
| 3 | + * Javascript functions for Google Maps v3 functionallity in Maps. |
| 4 | + * |
| 5 | + * @file GoogleMap3Functions.js |
| 6 | + * @ingroup MapsGoogleMaps3 |
| 7 | + * |
| 8 | + * @author Jeroen De Dauw |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * Created a new Map object with the provided properties and markers. |
| 13 | + */ |
| 14 | +function initGMap3(name, options, markerData) { |
| 15 | + options.center = new google.maps.LatLng(options.lat, options.lon); |
| 16 | + |
| 17 | + var map = new google.maps.Map(document.getElementById(name), options); |
| 18 | + |
| 19 | + // TODO: types - http://code.google.com/apis/maps/documentation/v3/reference.html#MapTypeRegistry |
| 20 | + |
| 21 | + for (marker in markerData) getGMaps3Marker(map, markerData[marker]); |
| 22 | +} |
| 23 | + |
| 24 | +function getGMaps3Marker(map, data) { |
| 25 | + var marker = new google.maps.Marker({position: data.position, map: map, title: data.title, icon: data.icon}); |
| 26 | + |
| 27 | + var bothTxtAreSet = data.title.length > 0 && data.label.length > 0; |
| 28 | + var popupText = bothTxtAreSet ? '<b>' + data.title + '</b><hr />' + data.label : data.title + data.label; |
| 29 | + |
| 30 | + var infowindow = new google.maps.InfoWindow({content: popupText}); |
| 31 | + |
| 32 | + google.maps.event.addListener(marker, "click", function() { |
| 33 | + infowindow.close(); |
| 34 | + infowindow.open(map, marker); |
| 35 | + }); |
| 36 | + |
| 37 | + return marker; |
| 38 | +} |
| 39 | + |
| 40 | +function getGMaps3MarkerData(lat, lon, title, label, icon) { |
| 41 | + return {position: new google.maps.LatLng(lat, lon), title: title, label: label, icon: icon}; |
42 | 42 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/GoogleMaps3/GoogleMap3Functions.js |
___________________________________________________________________ |
Added: svn:eol-style |
43 | 43 | + native |
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispPoint.php |
— | — | @@ -1,84 +1,84 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the MapsYahooMapsDispPoint class.
|
6 | | - *
|
7 | | - * @file Maps_YahooMapsDispPoint.php
|
8 | | - * @ingroup MapsYahooMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Class for handling the display_point(s) parser functions with Yahoo! Maps.
|
19 | | - *
|
20 | | - * @author Jeroen De Dauw
|
21 | | - */
|
22 | | -class MapsYahooMapsDispPoint extends MapsBasePointMap {
|
23 | | -
|
24 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME;
|
25 | | -
|
26 | | - protected $markerStringFormat = 'getYMarkerData(lat, lon, \'title\', \'label\', "icon")';
|
27 | | -
|
28 | | - protected function getDefaultZoom() {
|
29 | | - global $egMapsYahooMapsZoom;
|
30 | | - return $egMapsYahooMapsZoom;
|
31 | | - }
|
32 | | -
|
33 | | - /**
|
34 | | - * @see MapsBaseMap::doMapServiceLoad()
|
35 | | - *
|
36 | | - */
|
37 | | - protected function doMapServiceLoad() {
|
38 | | - global $egYahooMapsOnThisPage;
|
39 | | -
|
40 | | - MapsYahooMaps::addYMapDependencies( $this->output );
|
41 | | - $egYahooMapsOnThisPage++;
|
42 | | -
|
43 | | - $this->elementNr = $egYahooMapsOnThisPage;
|
44 | | - }
|
45 | | -
|
46 | | - /**
|
47 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
48 | | - *
|
49 | | - */
|
50 | | - public function addSpecificMapHTML( Parser $parser ) {
|
51 | | - global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage;
|
52 | | -
|
53 | | - $mapName = $egMapsYahooMapsPrefix . '_' . $egYahooMapsOnThisPage;
|
54 | | -
|
55 | | - $this->output .= Html::element(
|
56 | | - 'div',
|
57 | | - array(
|
58 | | - 'id' => $mapName,
|
59 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
60 | | - ),
|
61 | | - wfMsg('maps-loading-map')
|
62 | | - );
|
63 | | -
|
64 | | - $parser->getOutput()->addHeadItem(
|
65 | | - Html::inlineScript( <<<EOT
|
66 | | -addOnloadHook(
|
67 | | - function() {
|
68 | | - initializeYahooMap(
|
69 | | - '$mapName',
|
70 | | - $this->centreLat,
|
71 | | - $this->centreLon,
|
72 | | - $this->zoom,
|
73 | | - $this->type,
|
74 | | - [$this->types],
|
75 | | - [$this->controls],
|
76 | | - $this->autozoom,
|
77 | | - [$this->markerString]
|
78 | | - );
|
79 | | - }
|
80 | | -);
|
81 | | -EOT
|
82 | | - ) );
|
83 | | - }
|
84 | | -
|
85 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the MapsYahooMapsDispPoint class. |
| 6 | + * |
| 7 | + * @file Maps_YahooMapsDispPoint.php |
| 8 | + * @ingroup MapsYahooMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Class for handling the display_point(s) parser functions with Yahoo! Maps. |
| 19 | + * |
| 20 | + * @author Jeroen De Dauw |
| 21 | + */ |
| 22 | +class MapsYahooMapsDispPoint extends MapsBasePointMap { |
| 23 | + |
| 24 | + public $serviceName = MapsYahooMaps::SERVICE_NAME; |
| 25 | + |
| 26 | + protected $markerStringFormat = 'getYMarkerData(lat, lon, \'title\', \'label\', "icon")'; |
| 27 | + |
| 28 | + protected function getDefaultZoom() { |
| 29 | + global $egMapsYahooMapsZoom; |
| 30 | + return $egMapsYahooMapsZoom; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @see MapsBaseMap::doMapServiceLoad() |
| 35 | + * |
| 36 | + */ |
| 37 | + protected function doMapServiceLoad() { |
| 38 | + global $egYahooMapsOnThisPage; |
| 39 | + |
| 40 | + MapsYahooMaps::addYMapDependencies( $this->output ); |
| 41 | + $egYahooMapsOnThisPage++; |
| 42 | + |
| 43 | + $this->elementNr = $egYahooMapsOnThisPage; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 48 | + * |
| 49 | + */ |
| 50 | + public function addSpecificMapHTML( Parser $parser ) { |
| 51 | + global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage; |
| 52 | + |
| 53 | + $mapName = $egMapsYahooMapsPrefix . '_' . $egYahooMapsOnThisPage; |
| 54 | + |
| 55 | + $this->output .= Html::element( |
| 56 | + 'div', |
| 57 | + array( |
| 58 | + 'id' => $mapName, |
| 59 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 60 | + ), |
| 61 | + wfMsg('maps-loading-map') |
| 62 | + ); |
| 63 | + |
| 64 | + $parser->getOutput()->addHeadItem( |
| 65 | + Html::inlineScript( <<<EOT |
| 66 | +addOnloadHook( |
| 67 | + function() { |
| 68 | + initializeYahooMap( |
| 69 | + '$mapName', |
| 70 | + $this->centreLat, |
| 71 | + $this->centreLon, |
| 72 | + $this->zoom, |
| 73 | + $this->type, |
| 74 | + [$this->types], |
| 75 | + [$this->controls], |
| 76 | + $this->autozoom, |
| 77 | + [$this->markerString] |
| 78 | + ); |
| 79 | + } |
| 80 | +); |
| 81 | +EOT |
| 82 | + ) ); |
| 83 | + } |
| 84 | + |
| 85 | +} |
Property changes on: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispPoint.php |
___________________________________________________________________ |
Added: svn:eol-style |
86 | 86 | + native |
Index: trunk/extensions/Maps/Services/YahooMaps/YahooMapFunctions.js |
— | — | @@ -1,113 +1,113 @@ |
2 | | - /**
|
3 | | - * Javascript functions for Yahoo! Maps functionallity in Maps and it's extensions
|
4 | | - *
|
5 | | - * @file YahooMapFunctions.js
|
6 | | - * @ingroup MapsYahooMaps
|
7 | | - *
|
8 | | - * @author Jeroen De Dauw
|
9 | | - */
|
10 | | -
|
11 | | -
|
12 | | -/**
|
13 | | - * Returns YMarker object on the provided location.
|
14 | | - * It will show a popup baloon with title and label when clicked, if either of these is set.
|
15 | | - */
|
16 | | -function createYMarker(geoPoint, title, label, icon){
|
17 | | - var newMarker;
|
18 | | -
|
19 | | - if (icon != '') {
|
20 | | - newMarker = new YMarker(geoPoint, new YImage(icon));
|
21 | | - } else {
|
22 | | - newMarker = new YMarker(geoPoint);
|
23 | | - }
|
24 | | -
|
25 | | - if ((title + label).length > 0) {
|
26 | | - var bothTxtAreSet = title.length > 0 && label.length > 0;
|
27 | | - var markerMarkup = bothTxtAreSet ? '<b>' + title + '</b><hr />' + label : title + label;
|
28 | | - YEvent.Capture(newMarker, EventsList.MouseClick,
|
29 | | - function(){
|
30 | | - newMarker.openSmartWindow(markerMarkup);
|
31 | | - }
|
32 | | - );
|
33 | | - }
|
34 | | -
|
35 | | - return newMarker;
|
36 | | -}
|
37 | | -
|
38 | | -/**
|
39 | | - * Returns YMap object with the provided properties and markers.
|
40 | | - */
|
41 | | -function initializeYahooMap(mapName, lat, lon, zoom, type, types, controls, scrollWheelZoom, markers) {
|
42 | | - var centre = (lon != null && lat != null) ? new YGeoPoint(lat, lon) : null;
|
43 | | - return createYahooMap(document.getElementById(mapName), centre, zoom, type, types, controls, scrollWheelZoom, markers);
|
44 | | -}
|
45 | | -
|
46 | | -/**
|
47 | | - * Returns YMap object with the provided properties.
|
48 | | - */
|
49 | | -function createYahooMap(mapElement, centre, zoom, type, types, controls, scrollWheelZoom, markers) {
|
50 | | - var typesContainType = false;
|
51 | | -
|
52 | | - for (var i = 0; i < types.length; i++) {
|
53 | | - if (types[i] == type) typesContainType = true;
|
54 | | - }
|
55 | | -
|
56 | | - if (! typesContainType) types.push(type);
|
57 | | -
|
58 | | - var map = new YMap(mapElement, type);
|
59 | | -
|
60 | | - map.removeZoomScale();
|
61 | | -
|
62 | | - for (i in controls){
|
63 | | - if (controls[i].toLowerCase() == 'auto-zoom') {
|
64 | | - if (mapElement.offsetHeight > 42) controls[i] = mapElement.offsetHeight > 100 ? 'zoom' : 'zoom-short';
|
65 | | - }
|
66 | | -
|
67 | | - switch (controls[i]) {
|
68 | | - case 'scale' :
|
69 | | - map.addZoomScale();
|
70 | | - case 'type' :
|
71 | | - map.addTypeControl(types);
|
72 | | - break;
|
73 | | - case 'pan' :
|
74 | | - map.addPanControl();
|
75 | | - break;
|
76 | | - case 'zoom' :
|
77 | | - map.addZoomLong();
|
78 | | - break;
|
79 | | - case 'zoom-short' :
|
80 | | - map.addZoomShort();
|
81 | | - break;
|
82 | | - }
|
83 | | - }
|
84 | | -
|
85 | | - map.setMapType(type);
|
86 | | -
|
87 | | - if (!scrollWheelZoom) map.disableKeyControls();
|
88 | | -
|
89 | | - var map_locations = ((zoom == null || centre == null) && markers.length > 1) ? Array() : null;
|
90 | | -
|
91 | | - for (i in markers) {
|
92 | | - var marker = markers[i];
|
93 | | - map.addOverlay(createYMarker(marker.point, marker.title, marker.label, marker.icon));
|
94 | | - if (map_locations != null) map_locations.push(marker.point);
|
95 | | - }
|
96 | | -
|
97 | | - if (map_locations != null) {
|
98 | | - var centerAndZoom = map.getBestZoomAndCenter(map_locations);
|
99 | | - map.drawZoomAndCenter(centerAndZoom.YGeoPoint, centerAndZoom.zoomLevel);
|
100 | | - }
|
101 | | -
|
102 | | - if (zoom != null) map.setZoomLevel(zoom);
|
103 | | -
|
104 | | - // FIXME: the code after this line REFUSES to be executed
|
105 | | - // This is probably caused by the YGeoPoint
|
106 | | - // Notice that the map object will therefore NOT BE RETURNED!
|
107 | | - if (centre != null) map.drawZoomAndCenter(centre);
|
108 | | -
|
109 | | - return map;
|
110 | | -}
|
111 | | -
|
112 | | -function getYMarkerData(lat, lon, title, label, icon) {
|
113 | | - return {point: new YGeoPoint(lat, lon), title: title, label: label, icon: icon};
|
| 2 | + /** |
| 3 | + * Javascript functions for Yahoo! Maps functionallity in Maps and it's extensions |
| 4 | + * |
| 5 | + * @file YahooMapFunctions.js |
| 6 | + * @ingroup MapsYahooMaps |
| 7 | + * |
| 8 | + * @author Jeroen De Dauw |
| 9 | + */ |
| 10 | + |
| 11 | + |
| 12 | +/** |
| 13 | + * Returns YMarker object on the provided location. |
| 14 | + * It will show a popup baloon with title and label when clicked, if either of these is set. |
| 15 | + */ |
| 16 | +function createYMarker(geoPoint, title, label, icon){ |
| 17 | + var newMarker; |
| 18 | + |
| 19 | + if (icon != '') { |
| 20 | + newMarker = new YMarker(geoPoint, new YImage(icon)); |
| 21 | + } else { |
| 22 | + newMarker = new YMarker(geoPoint); |
| 23 | + } |
| 24 | + |
| 25 | + if ((title + label).length > 0) { |
| 26 | + var bothTxtAreSet = title.length > 0 && label.length > 0; |
| 27 | + var markerMarkup = bothTxtAreSet ? '<b>' + title + '</b><hr />' + label : title + label; |
| 28 | + YEvent.Capture(newMarker, EventsList.MouseClick, |
| 29 | + function(){ |
| 30 | + newMarker.openSmartWindow(markerMarkup); |
| 31 | + } |
| 32 | + ); |
| 33 | + } |
| 34 | + |
| 35 | + return newMarker; |
| 36 | +} |
| 37 | + |
| 38 | +/** |
| 39 | + * Returns YMap object with the provided properties and markers. |
| 40 | + */ |
| 41 | +function initializeYahooMap(mapName, lat, lon, zoom, type, types, controls, scrollWheelZoom, markers) { |
| 42 | + var centre = (lon != null && lat != null) ? new YGeoPoint(lat, lon) : null; |
| 43 | + return createYahooMap(document.getElementById(mapName), centre, zoom, type, types, controls, scrollWheelZoom, markers); |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | + * Returns YMap object with the provided properties. |
| 48 | + */ |
| 49 | +function createYahooMap(mapElement, centre, zoom, type, types, controls, scrollWheelZoom, markers) { |
| 50 | + var typesContainType = false; |
| 51 | + |
| 52 | + for (var i = 0; i < types.length; i++) { |
| 53 | + if (types[i] == type) typesContainType = true; |
| 54 | + } |
| 55 | + |
| 56 | + if (! typesContainType) types.push(type); |
| 57 | + |
| 58 | + var map = new YMap(mapElement, type); |
| 59 | + |
| 60 | + map.removeZoomScale(); |
| 61 | + |
| 62 | + for (i in controls){ |
| 63 | + if (controls[i].toLowerCase() == 'auto-zoom') { |
| 64 | + if (mapElement.offsetHeight > 42) controls[i] = mapElement.offsetHeight > 100 ? 'zoom' : 'zoom-short'; |
| 65 | + } |
| 66 | + |
| 67 | + switch (controls[i]) { |
| 68 | + case 'scale' : |
| 69 | + map.addZoomScale(); |
| 70 | + case 'type' : |
| 71 | + map.addTypeControl(types); |
| 72 | + break; |
| 73 | + case 'pan' : |
| 74 | + map.addPanControl(); |
| 75 | + break; |
| 76 | + case 'zoom' : |
| 77 | + map.addZoomLong(); |
| 78 | + break; |
| 79 | + case 'zoom-short' : |
| 80 | + map.addZoomShort(); |
| 81 | + break; |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + map.setMapType(type); |
| 86 | + |
| 87 | + if (!scrollWheelZoom) map.disableKeyControls(); |
| 88 | + |
| 89 | + var map_locations = ((zoom == null || centre == null) && markers.length > 1) ? Array() : null; |
| 90 | + |
| 91 | + for (i in markers) { |
| 92 | + var marker = markers[i]; |
| 93 | + map.addOverlay(createYMarker(marker.point, marker.title, marker.label, marker.icon)); |
| 94 | + if (map_locations != null) map_locations.push(marker.point); |
| 95 | + } |
| 96 | + |
| 97 | + if (map_locations != null) { |
| 98 | + var centerAndZoom = map.getBestZoomAndCenter(map_locations); |
| 99 | + map.drawZoomAndCenter(centerAndZoom.YGeoPoint, centerAndZoom.zoomLevel); |
| 100 | + } |
| 101 | + |
| 102 | + if (zoom != null) map.setZoomLevel(zoom); |
| 103 | + |
| 104 | + // FIXME: the code after this line REFUSES to be executed |
| 105 | + // This is probably caused by the YGeoPoint |
| 106 | + // Notice that the map object will therefore NOT BE RETURNED! |
| 107 | + if (centre != null) map.drawZoomAndCenter(centre); |
| 108 | + |
| 109 | + return map; |
| 110 | +} |
| 111 | + |
| 112 | +function getYMarkerData(lat, lon, title, label, icon) { |
| 113 | + return {point: new YGeoPoint(lat, lon), title: title, label: label, icon: icon}; |
114 | 114 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/YahooMaps/YahooMapFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
115 | 115 | + native |
Index: trunk/extensions/Maps/Services/YahooMaps/YahooMapFunctions.min.js |
— | — | @@ -1,3 +1,3 @@ |
2 | | -function createYMarker(a,d,e,c){var b;b=c!=""?new YMarker(a,new YImage(c)):new YMarker(a);if((d+e).length>0){var g=(a=d.length>0&&e.length>0)?"<b>"+d+"</b><hr />"+e:d+e;YEvent.Capture(b,EventsList.MouseClick,function(){b.openSmartWindow(g)})}return b}function initializeYahooMap(a,d,e,c,b,g,k,h,i,j){d=e!=null&&d!=null?new YGeoPoint(d,e):null;return createYahooMap(document.getElementById(a),d,c,b,g,k,h,i,j)}
|
3 | | -function createYahooMap(a,d,e,c,b,g,k,h,i){for(var j=false,f=0;f<b.length;f++)if(b[f]==c)j=true;j||b.push(c);a=new YMap(a,c);a.removeZoomScale();for(f in g){if(g[f].toLowerCase()=="auto-zoom")if(i>42)g[f]=i>100?"zoom":"zoom-short";switch(g[f]){case "scale":a.addZoomScale();case "type":a.addTypeControl(b);break;case "pan":a.addPanControl();break;case "zoom":a.addZoomLong();break;case "zoom-short":a.addZoomShort();break}}a.setMapType(c);k||a.disableKeyControls();c=(e==null||d==null)&&h.length>1?Array():
|
| 2 | +function createYMarker(a,d,e,c){var b;b=c!=""?new YMarker(a,new YImage(c)):new YMarker(a);if((d+e).length>0){var g=(a=d.length>0&&e.length>0)?"<b>"+d+"</b><hr />"+e:d+e;YEvent.Capture(b,EventsList.MouseClick,function(){b.openSmartWindow(g)})}return b}function initializeYahooMap(a,d,e,c,b,g,k,h,i,j){d=e!=null&&d!=null?new YGeoPoint(d,e):null;return createYahooMap(document.getElementById(a),d,c,b,g,k,h,i,j)} |
| 3 | +function createYahooMap(a,d,e,c,b,g,k,h,i){for(var j=false,f=0;f<b.length;f++)if(b[f]==c)j=true;j||b.push(c);a=new YMap(a,c);a.removeZoomScale();for(f in g){if(g[f].toLowerCase()=="auto-zoom")if(i>42)g[f]=i>100?"zoom":"zoom-short";switch(g[f]){case "scale":a.addZoomScale();case "type":a.addTypeControl(b);break;case "pan":a.addPanControl();break;case "zoom":a.addZoomLong();break;case "zoom-short":a.addZoomShort();break}}a.setMapType(c);k||a.disableKeyControls();c=(e==null||d==null)&&h.length>1?Array(): |
4 | 4 | null;for(f in h){b=h[f];a.addOverlay(createYMarker(b.point,b.title,b.label,b.icon));c!=null&&c.push(b.point)}if(c!=null){h=a.getBestZoomAndCenter(c);a.drawZoomAndCenter(h.YGeoPoint,h.zoomLevel)}e!=null&&a.setZoomLevel(e);d!=null&&a.drawZoomAndCenter(d);return a}function getYMarkerData(a,d,e,c,b){return{point:new YGeoPoint(a,d),title:e,label:c,icon:b}}; |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/YahooMaps/YahooMapFunctions.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
5 | 5 | + native |
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispMap.php |
— | — | @@ -1,75 +1,75 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Class for handling the display_map parser function with Yahoo! Maps
|
6 | | - *
|
7 | | - * @file Maps_YahooMapsDispMap.php
|
8 | | - * @ingroup MapsYahooMaps
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -class MapsYahooMapsDispMap extends MapsBaseMap {
|
18 | | -
|
19 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME;
|
20 | | -
|
21 | | - protected function getDefaultZoom() {
|
22 | | - global $egMapsYahooMapsZoom;
|
23 | | - return $egMapsYahooMapsZoom;
|
24 | | - }
|
25 | | -
|
26 | | - /**
|
27 | | - * @see MapsBaseMap::doMapServiceLoad()
|
28 | | - */
|
29 | | - public function doMapServiceLoad() {
|
30 | | - global $egYahooMapsOnThisPage;
|
31 | | -
|
32 | | - MapsYahooMaps::addYMapDependencies( $this->output );
|
33 | | - $egYahooMapsOnThisPage++;
|
34 | | -
|
35 | | - $this->elementNr = $egYahooMapsOnThisPage;
|
36 | | - }
|
37 | | -
|
38 | | - /**
|
39 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
40 | | - */
|
41 | | - public function addSpecificMapHTML( Parser $parser ) {
|
42 | | - global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage;
|
43 | | -
|
44 | | - $mapName = $egMapsYahooMapsPrefix . '_' . $egYahooMapsOnThisPage;
|
45 | | -
|
46 | | - $this->output .= Html::element(
|
47 | | - 'div',
|
48 | | - array(
|
49 | | - 'id' => $mapName,
|
50 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
51 | | - ),
|
52 | | - wfMsg('maps-loading-map')
|
53 | | - );
|
54 | | -
|
55 | | - $parser->getOutput()->addHeadItem(
|
56 | | - Html::inlineScript( <<<EOT
|
57 | | -addOnloadHook(
|
58 | | - function() {
|
59 | | - initializeYahooMap(
|
60 | | - '$mapName',
|
61 | | - $this->centreLat,
|
62 | | - $this->centreLon,
|
63 | | - $this->zoom,
|
64 | | - $this->type,
|
65 | | - [$this->types],
|
66 | | - [$this->controls],
|
67 | | - $this->autozoom,
|
68 | | - []
|
69 | | - );
|
70 | | - }
|
71 | | -);
|
72 | | -EOT
|
73 | | - ) );
|
74 | | - }
|
75 | | -
|
76 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class for handling the display_map parser function with Yahoo! Maps |
| 6 | + * |
| 7 | + * @file Maps_YahooMapsDispMap.php |
| 8 | + * @ingroup MapsYahooMaps |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +class MapsYahooMapsDispMap extends MapsBaseMap { |
| 18 | + |
| 19 | + public $serviceName = MapsYahooMaps::SERVICE_NAME; |
| 20 | + |
| 21 | + protected function getDefaultZoom() { |
| 22 | + global $egMapsYahooMapsZoom; |
| 23 | + return $egMapsYahooMapsZoom; |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @see MapsBaseMap::doMapServiceLoad() |
| 28 | + */ |
| 29 | + public function doMapServiceLoad() { |
| 30 | + global $egYahooMapsOnThisPage; |
| 31 | + |
| 32 | + MapsYahooMaps::addYMapDependencies( $this->output ); |
| 33 | + $egYahooMapsOnThisPage++; |
| 34 | + |
| 35 | + $this->elementNr = $egYahooMapsOnThisPage; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 40 | + */ |
| 41 | + public function addSpecificMapHTML( Parser $parser ) { |
| 42 | + global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage; |
| 43 | + |
| 44 | + $mapName = $egMapsYahooMapsPrefix . '_' . $egYahooMapsOnThisPage; |
| 45 | + |
| 46 | + $this->output .= Html::element( |
| 47 | + 'div', |
| 48 | + array( |
| 49 | + 'id' => $mapName, |
| 50 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 51 | + ), |
| 52 | + wfMsg('maps-loading-map') |
| 53 | + ); |
| 54 | + |
| 55 | + $parser->getOutput()->addHeadItem( |
| 56 | + Html::inlineScript( <<<EOT |
| 57 | +addOnloadHook( |
| 58 | + function() { |
| 59 | + initializeYahooMap( |
| 60 | + '$mapName', |
| 61 | + $this->centreLat, |
| 62 | + $this->centreLon, |
| 63 | + $this->zoom, |
| 64 | + $this->type, |
| 65 | + [$this->types], |
| 66 | + [$this->controls], |
| 67 | + $this->autozoom, |
| 68 | + [] |
| 69 | + ); |
| 70 | + } |
| 71 | +); |
| 72 | +EOT |
| 73 | + ) ); |
| 74 | + } |
| 75 | + |
| 76 | +} |
Property changes on: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
77 | 77 | + native |
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php |
— | — | @@ -1,172 +1,172 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all Yahoo! Maps related files of the Maps extension.
|
6 | | - *
|
7 | | - * @defgroup MapsYahooMaps Yahoo! Maps
|
8 | | - * @ingroup Maps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the Yahoo! Maps service
|
13 | | - *
|
14 | | - * @file Maps_YahooMaps.php
|
15 | | - * @ingroup MapsYahooMaps
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['MapsYahooMaps'] = dirname( __FILE__ ) . '/Maps_YahooMaps.php';
|
25 | | -
|
26 | | -$wgHooks['MappingServiceLoad'][] = 'MapsYahooMaps::initialize';
|
27 | | -
|
28 | | -$wgAutoloadClasses['MapsYahooMapsDispMap'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispMap.php';
|
29 | | -$wgAutoloadClasses['MapsYahooMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispPoint.php';
|
30 | | -
|
31 | | -$egMapsServices[MapsYahooMaps::SERVICE_NAME] = array(
|
32 | | - 'aliases' => array( 'yahoo', 'yahoomap', 'ymap', 'ymaps' ),
|
33 | | - 'features' => array(
|
34 | | - 'display_point' => 'MapsYahooMapsDispPoint',
|
35 | | - 'display_map' => 'MapsYahooMapsDispMap',
|
36 | | - )
|
37 | | -);
|
38 | | -
|
39 | | -/**
|
40 | | - * Class for Yahoo! Maps initialization.
|
41 | | - *
|
42 | | - * @ingroup MapsYahooMaps
|
43 | | - *
|
44 | | - * @author Jeroen De Dauw
|
45 | | - */
|
46 | | -class MapsYahooMaps {
|
47 | | -
|
48 | | - const SERVICE_NAME = 'yahoomaps';
|
49 | | -
|
50 | | - public static function initialize() {
|
51 | | - global $wgAutoloadClasses, $egMapsServices;
|
52 | | -
|
53 | | - self::initializeParams();
|
54 | | -
|
55 | | - Validator::addOutputFormat( 'ymaptype', array( __CLASS__, 'setYMapType' ) );
|
56 | | - Validator::addOutputFormat( 'ymaptypes', array( __CLASS__, 'setYMapTypes' ) );
|
57 | | -
|
58 | | - return true;
|
59 | | - }
|
60 | | -
|
61 | | - private static function initializeParams() {
|
62 | | - global $egMapsServices, $egMapsYahooAutozoom, $egMapsYahooMapsType, $egMapsYahooMapsTypes, $egMapsYahooMapsZoom, $egMapsYMapControls;
|
63 | | -
|
64 | | - $allowedTypes = MapsYahooMaps::getTypeNames();
|
65 | | -
|
66 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
|
67 | | - 'controls' => array(
|
68 | | - 'type' => array( 'string', 'list' ),
|
69 | | - 'criteria' => array(
|
70 | | - 'in_array' => self::getControlNames()
|
71 | | - ),
|
72 | | - 'default' => $egMapsYMapControls,
|
73 | | - 'output-type' => array( 'list', ',', '\'' )
|
74 | | - ),
|
75 | | - 'type' => array (
|
76 | | - 'aliases' => array( 'map-type', 'map type' ),
|
77 | | - 'criteria' => array(
|
78 | | - 'in_array' => $allowedTypes
|
79 | | - ),
|
80 | | - 'default' => $egMapsYahooMapsType, // FIXME: default value should not be used when not present in types parameter.
|
81 | | - 'output-type' => 'ymaptype'
|
82 | | - ),
|
83 | | - 'types' => array (
|
84 | | - 'type' => array( 'string', 'list' ),
|
85 | | - 'aliases' => array( 'map-types', 'map types' ),
|
86 | | - 'criteria' => array(
|
87 | | - 'in_array' => $allowedTypes
|
88 | | - ),
|
89 | | - 'default' => $egMapsYahooMapsTypes,
|
90 | | - 'output-types' => array( 'ymaptypes', 'list' )
|
91 | | - ),
|
92 | | - 'autozoom' => array(
|
93 | | - 'type' => 'boolean',
|
94 | | - 'aliases' => array( 'auto zoom', 'mouse zoom', 'mousezoom' ),
|
95 | | - 'default' => $egMapsYahooAutozoom,
|
96 | | - 'output-type' => 'boolstr'
|
97 | | - ),
|
98 | | - );
|
99 | | -
|
100 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 1, 13 );
|
101 | | - }
|
102 | | -
|
103 | | - // http://developer.yahoo.com/maps/ajax
|
104 | | - private static $mapTypes = array(
|
105 | | - 'normal' => 'YAHOO_MAP_REG',
|
106 | | - 'satellite' => 'YAHOO_MAP_SAT',
|
107 | | - 'hybrid' => 'YAHOO_MAP_HYB',
|
108 | | - );
|
109 | | -
|
110 | | - /**
|
111 | | - * Returns the names of all supported map types.
|
112 | | - *
|
113 | | - * @return array
|
114 | | - */
|
115 | | - public static function getTypeNames() {
|
116 | | - return array_keys( self::$mapTypes );
|
117 | | - }
|
118 | | -
|
119 | | - /**
|
120 | | - * Returns the names of all supported controls.
|
121 | | - * This data is a copy of the one used to actually translate the names
|
122 | | - * into the controls, since this resides client side, in YahooMapFunctions.js.
|
123 | | - *
|
124 | | - * @return array
|
125 | | - */
|
126 | | - public static function getControlNames() {
|
127 | | - return array( 'scale', 'type', 'pan', 'zoom', 'zoom-short', 'auto-zoom' );
|
128 | | - }
|
129 | | -
|
130 | | - /**
|
131 | | - * Changes the map type name into the corresponding Yahoo! Maps API identifier.
|
132 | | - *
|
133 | | - * @param string $type
|
134 | | - *
|
135 | | - * @return string
|
136 | | - */
|
137 | | - public static function setYMapType( &$type ) {
|
138 | | - $type = self::$mapTypes[ $type ];
|
139 | | - }
|
140 | | -
|
141 | | - /**
|
142 | | - * Changes the map type names into the corresponding Yahoo! Maps API identifiers.
|
143 | | - *
|
144 | | - * @param array $types
|
145 | | - *
|
146 | | - * @return array
|
147 | | - */
|
148 | | - public static function setYMapTypes( array &$types ) {
|
149 | | - for ( $i = count( $types ) - 1; $i >= 0; $i-- ) {
|
150 | | - $types[$i] = self::$mapTypes[ $types[$i] ];
|
151 | | - }
|
152 | | - }
|
153 | | -
|
154 | | - /**
|
155 | | - * Add references to the Yahoo! Maps API and required JS file to the provided output
|
156 | | - *
|
157 | | - * @param string $output
|
158 | | - */
|
159 | | - public static function addYMapDependencies( &$output ) {
|
160 | | - global $wgJsMimeType;
|
161 | | - global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt;
|
162 | | -
|
163 | | - if ( empty( $egYahooMapsOnThisPage ) ) {
|
164 | | - $egYahooMapsOnThisPage = 0;
|
165 | | -
|
166 | | - $dir = dirname( __FILE__ );
|
167 | | -
|
168 | | - $output .= "<script type='$wgJsMimeType' src='http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey'></script>
|
169 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>";
|
170 | | - }
|
171 | | - }
|
172 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all Yahoo! Maps related files of the Maps extension. |
| 6 | + * |
| 7 | + * @defgroup MapsYahooMaps Yahoo! Maps |
| 8 | + * @ingroup Maps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the Yahoo! Maps service |
| 13 | + * |
| 14 | + * @file Maps_YahooMaps.php |
| 15 | + * @ingroup MapsYahooMaps |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['MapsYahooMaps'] = dirname( __FILE__ ) . '/Maps_YahooMaps.php'; |
| 25 | + |
| 26 | +$wgHooks['MappingServiceLoad'][] = 'MapsYahooMaps::initialize'; |
| 27 | + |
| 28 | +$wgAutoloadClasses['MapsYahooMapsDispMap'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispMap.php'; |
| 29 | +$wgAutoloadClasses['MapsYahooMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispPoint.php'; |
| 30 | + |
| 31 | +$egMapsServices[MapsYahooMaps::SERVICE_NAME] = array( |
| 32 | + 'aliases' => array( 'yahoo', 'yahoomap', 'ymap', 'ymaps' ), |
| 33 | + 'features' => array( |
| 34 | + 'display_point' => 'MapsYahooMapsDispPoint', |
| 35 | + 'display_map' => 'MapsYahooMapsDispMap', |
| 36 | + ) |
| 37 | +); |
| 38 | + |
| 39 | +/** |
| 40 | + * Class for Yahoo! Maps initialization. |
| 41 | + * |
| 42 | + * @ingroup MapsYahooMaps |
| 43 | + * |
| 44 | + * @author Jeroen De Dauw |
| 45 | + */ |
| 46 | +class MapsYahooMaps { |
| 47 | + |
| 48 | + const SERVICE_NAME = 'yahoomaps'; |
| 49 | + |
| 50 | + public static function initialize() { |
| 51 | + global $wgAutoloadClasses, $egMapsServices; |
| 52 | + |
| 53 | + self::initializeParams(); |
| 54 | + |
| 55 | + Validator::addOutputFormat( 'ymaptype', array( __CLASS__, 'setYMapType' ) ); |
| 56 | + Validator::addOutputFormat( 'ymaptypes', array( __CLASS__, 'setYMapTypes' ) ); |
| 57 | + |
| 58 | + return true; |
| 59 | + } |
| 60 | + |
| 61 | + private static function initializeParams() { |
| 62 | + global $egMapsServices, $egMapsYahooAutozoom, $egMapsYahooMapsType, $egMapsYahooMapsTypes, $egMapsYahooMapsZoom, $egMapsYMapControls; |
| 63 | + |
| 64 | + $allowedTypes = MapsYahooMaps::getTypeNames(); |
| 65 | + |
| 66 | + $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 67 | + 'controls' => array( |
| 68 | + 'type' => array( 'string', 'list' ), |
| 69 | + 'criteria' => array( |
| 70 | + 'in_array' => self::getControlNames() |
| 71 | + ), |
| 72 | + 'default' => $egMapsYMapControls, |
| 73 | + 'output-type' => array( 'list', ',', '\'' ) |
| 74 | + ), |
| 75 | + 'type' => array ( |
| 76 | + 'aliases' => array( 'map-type', 'map type' ), |
| 77 | + 'criteria' => array( |
| 78 | + 'in_array' => $allowedTypes |
| 79 | + ), |
| 80 | + 'default' => $egMapsYahooMapsType, // FIXME: default value should not be used when not present in types parameter. |
| 81 | + 'output-type' => 'ymaptype' |
| 82 | + ), |
| 83 | + 'types' => array ( |
| 84 | + 'type' => array( 'string', 'list' ), |
| 85 | + 'aliases' => array( 'map-types', 'map types' ), |
| 86 | + 'criteria' => array( |
| 87 | + 'in_array' => $allowedTypes |
| 88 | + ), |
| 89 | + 'default' => $egMapsYahooMapsTypes, |
| 90 | + 'output-types' => array( 'ymaptypes', 'list' ) |
| 91 | + ), |
| 92 | + 'autozoom' => array( |
| 93 | + 'type' => 'boolean', |
| 94 | + 'aliases' => array( 'auto zoom', 'mouse zoom', 'mousezoom' ), |
| 95 | + 'default' => $egMapsYahooAutozoom, |
| 96 | + 'output-type' => 'boolstr' |
| 97 | + ), |
| 98 | + ); |
| 99 | + |
| 100 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 1, 13 ); |
| 101 | + } |
| 102 | + |
| 103 | + // http://developer.yahoo.com/maps/ajax |
| 104 | + private static $mapTypes = array( |
| 105 | + 'normal' => 'YAHOO_MAP_REG', |
| 106 | + 'satellite' => 'YAHOO_MAP_SAT', |
| 107 | + 'hybrid' => 'YAHOO_MAP_HYB', |
| 108 | + ); |
| 109 | + |
| 110 | + /** |
| 111 | + * Returns the names of all supported map types. |
| 112 | + * |
| 113 | + * @return array |
| 114 | + */ |
| 115 | + public static function getTypeNames() { |
| 116 | + return array_keys( self::$mapTypes ); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Returns the names of all supported controls. |
| 121 | + * This data is a copy of the one used to actually translate the names |
| 122 | + * into the controls, since this resides client side, in YahooMapFunctions.js. |
| 123 | + * |
| 124 | + * @return array |
| 125 | + */ |
| 126 | + public static function getControlNames() { |
| 127 | + return array( 'scale', 'type', 'pan', 'zoom', 'zoom-short', 'auto-zoom' ); |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * Changes the map type name into the corresponding Yahoo! Maps API identifier. |
| 132 | + * |
| 133 | + * @param string $type |
| 134 | + * |
| 135 | + * @return string |
| 136 | + */ |
| 137 | + public static function setYMapType( &$type ) { |
| 138 | + $type = self::$mapTypes[ $type ]; |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * Changes the map type names into the corresponding Yahoo! Maps API identifiers. |
| 143 | + * |
| 144 | + * @param array $types |
| 145 | + * |
| 146 | + * @return array |
| 147 | + */ |
| 148 | + public static function setYMapTypes( array &$types ) { |
| 149 | + for ( $i = count( $types ) - 1; $i >= 0; $i-- ) { |
| 150 | + $types[$i] = self::$mapTypes[ $types[$i] ]; |
| 151 | + } |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Add references to the Yahoo! Maps API and required JS file to the provided output |
| 156 | + * |
| 157 | + * @param string $output |
| 158 | + */ |
| 159 | + public static function addYMapDependencies( &$output ) { |
| 160 | + global $wgJsMimeType; |
| 161 | + global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt; |
| 162 | + |
| 163 | + if ( empty( $egYahooMapsOnThisPage ) ) { |
| 164 | + $egYahooMapsOnThisPage = 0; |
| 165 | + |
| 166 | + $dir = dirname( __FILE__ ); |
| 167 | + |
| 168 | + $output .= "<script type='$wgJsMimeType' src='http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey'></script> |
| 169 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>"; |
| 170 | + } |
| 171 | + } |
| 172 | + |
173 | 173 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php |
___________________________________________________________________ |
Added: svn:eol-style |
174 | 174 | + native |
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispPoint.php |
— | — | @@ -1,84 +1,84 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the MapsOpenLayersDispPoint class.
|
6 | | - *
|
7 | | - * @file Maps_OpenLayersDispPoint.php
|
8 | | - * @ingroup MapsOpenLayers
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Class for handling the display_point(s) parser functions with OpenLayers.
|
19 | | - *
|
20 | | - * @author Jeroen De Dauw
|
21 | | - */
|
22 | | -class MapsOpenLayersDispPoint extends MapsBasePointMap {
|
23 | | -
|
24 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME;
|
25 | | -
|
26 | | - protected $markerStringFormat = 'getOLMarkerData(lon, lat, \'title\', \'label\', "icon")';
|
27 | | -
|
28 | | - protected function getDefaultZoom() {
|
29 | | - global $egMapsOpenLayersZoom;
|
30 | | - return $egMapsOpenLayersZoom;
|
31 | | - }
|
32 | | -
|
33 | | - /**
|
34 | | - * @see MapsBaseMap::doMapServiceLoad()
|
35 | | - *
|
36 | | - */
|
37 | | - public function doMapServiceLoad() {
|
38 | | - global $egOpenLayersOnThisPage;
|
39 | | -
|
40 | | - MapsOpenLayers::addOLDependencies( $this->output );
|
41 | | - $egOpenLayersOnThisPage++;
|
42 | | -
|
43 | | - $this->elementNr = $egOpenLayersOnThisPage;
|
44 | | - }
|
45 | | -
|
46 | | - /**
|
47 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
48 | | - *
|
49 | | - */
|
50 | | - public function addSpecificMapHTML( Parser $parser ) {
|
51 | | - global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage;
|
52 | | -
|
53 | | - $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
|
54 | | -
|
55 | | - $mapName = $egMapsOpenLayersPrefix . '_' . $egOpenLayersOnThisPage;
|
56 | | -
|
57 | | - $this->output .= Html::element(
|
58 | | - 'div',
|
59 | | - array(
|
60 | | - 'id' => $mapName,
|
61 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
62 | | - ),
|
63 | | - wfMsg('maps-loading-map')
|
64 | | - );
|
65 | | -
|
66 | | - $parser->getOutput()->addHeadItem(
|
67 | | - Html::inlineScript( <<<EOT
|
68 | | -addOnloadHook(
|
69 | | - function() {
|
70 | | - initOpenLayer(
|
71 | | - '$mapName',
|
72 | | - $this->centreLon,
|
73 | | - $this->centreLat,
|
74 | | - $this->zoom,
|
75 | | - [$layerItems],
|
76 | | - [$this->controls],
|
77 | | - [$this->markerString]
|
78 | | - );
|
79 | | - }
|
80 | | -);
|
81 | | -EOT
|
82 | | - ) );
|
83 | | - }
|
84 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the MapsOpenLayersDispPoint class. |
| 6 | + * |
| 7 | + * @file Maps_OpenLayersDispPoint.php |
| 8 | + * @ingroup MapsOpenLayers |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Class for handling the display_point(s) parser functions with OpenLayers. |
| 19 | + * |
| 20 | + * @author Jeroen De Dauw |
| 21 | + */ |
| 22 | +class MapsOpenLayersDispPoint extends MapsBasePointMap { |
| 23 | + |
| 24 | + public $serviceName = MapsOpenLayers::SERVICE_NAME; |
| 25 | + |
| 26 | + protected $markerStringFormat = 'getOLMarkerData(lon, lat, \'title\', \'label\', "icon")'; |
| 27 | + |
| 28 | + protected function getDefaultZoom() { |
| 29 | + global $egMapsOpenLayersZoom; |
| 30 | + return $egMapsOpenLayersZoom; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @see MapsBaseMap::doMapServiceLoad() |
| 35 | + * |
| 36 | + */ |
| 37 | + public function doMapServiceLoad() { |
| 38 | + global $egOpenLayersOnThisPage; |
| 39 | + |
| 40 | + MapsOpenLayers::addOLDependencies( $this->output ); |
| 41 | + $egOpenLayersOnThisPage++; |
| 42 | + |
| 43 | + $this->elementNr = $egOpenLayersOnThisPage; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 48 | + * |
| 49 | + */ |
| 50 | + public function addSpecificMapHTML( Parser $parser ) { |
| 51 | + global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage; |
| 52 | + |
| 53 | + $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
| 54 | + |
| 55 | + $mapName = $egMapsOpenLayersPrefix . '_' . $egOpenLayersOnThisPage; |
| 56 | + |
| 57 | + $this->output .= Html::element( |
| 58 | + 'div', |
| 59 | + array( |
| 60 | + 'id' => $mapName, |
| 61 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 62 | + ), |
| 63 | + wfMsg('maps-loading-map') |
| 64 | + ); |
| 65 | + |
| 66 | + $parser->getOutput()->addHeadItem( |
| 67 | + Html::inlineScript( <<<EOT |
| 68 | +addOnloadHook( |
| 69 | + function() { |
| 70 | + initOpenLayer( |
| 71 | + '$mapName', |
| 72 | + $this->centreLon, |
| 73 | + $this->centreLat, |
| 74 | + $this->zoom, |
| 75 | + [$layerItems], |
| 76 | + [$this->controls], |
| 77 | + [$this->markerString] |
| 78 | + ); |
| 79 | + } |
| 80 | +); |
| 81 | +EOT |
| 82 | + ) ); |
| 83 | + } |
| 84 | + |
85 | 85 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispPoint.php |
___________________________________________________________________ |
Added: svn:eol-style |
86 | 86 | + native |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayers/OpenLayers.js |
___________________________________________________________________ |
Added: svn:eol-style |
87 | 87 | + native |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayers/theme/default/framedCloud.css |
___________________________________________________________________ |
Added: svn:eol-style |
88 | 88 | + native |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayers/theme/default/google.css |
___________________________________________________________________ |
Added: svn:eol-style |
89 | 89 | + native |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayers/theme/default/style.css |
___________________________________________________________________ |
Added: svn:eol-style |
90 | 90 | + native |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayers/theme/default/ie6-style.css |
___________________________________________________________________ |
Added: svn:eol-style |
91 | 91 | + native |
Index: trunk/extensions/Maps/Services/OpenLayers/OpenLayerFunctions.js |
— | — | @@ -1,171 +1,171 @@ |
2 | | - /**
|
3 | | - * Javascript functions for Open Layers functionallity in Maps and it's extensions
|
4 | | - *
|
5 | | - * @file OpenLayerFunctions.js
|
6 | | - * @ingroup MapsOpenLayers
|
7 | | - *
|
8 | | - * @author Jeroen De Dauw
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * Creates and initializes an OpenLayers map.
|
13 | | - * The resulting map is returned by the function but no further handling is required in most cases.
|
14 | | - */
|
15 | | -function initOpenLayer(mapName, lon, lat, zoom, mapTypes, controls, marker_data){
|
16 | | -
|
17 | | - // Create a new OpenLayers map with without any controls on it.
|
18 | | - var mapOptions = {
|
19 | | - projection: new OpenLayers.Projection("EPSG:900913"),
|
20 | | - displayProjection: new OpenLayers.Projection("EPSG:4326"),
|
21 | | - units: "m",
|
22 | | - numZoomLevels: 18,
|
23 | | - maxResolution: 156543.0339,
|
24 | | - maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34),
|
25 | | - controls: []
|
26 | | - };
|
27 | | -
|
28 | | - var mapElement = document.getElementById(mapName);
|
29 | | -
|
30 | | - // Remove the loading map message.
|
31 | | - mapElement.innerHTML = '';
|
32 | | -
|
33 | | - var map = new OpenLayers.Map(mapName, mapOptions);
|
34 | | -
|
35 | | - // Add the controls.
|
36 | | - for (i in controls) {
|
37 | | -
|
38 | | - // If a string is provided, find the correct name for the control, and use eval to create the object itself.
|
39 | | - if (typeof controls[i] == 'string') {
|
40 | | - if (controls[i].toLowerCase() == 'autopanzoom') {
|
41 | | - if (mapElement.offsetHeight > 140) controls[i] = mapElement.offsetHeight > 320 ? 'panzoombar' : 'panzoom';
|
42 | | - }
|
43 | | -
|
44 | | - control = getValidControlName(controls[i]);
|
45 | | -
|
46 | | - if (control) {
|
47 | | - eval(' map.addControl( new OpenLayers.Control.' + control + '() ); ');
|
48 | | - }
|
49 | | - }
|
50 | | - else {
|
51 | | - map.addControl(controls[i]); // If a control is provided, instead a string, just add it.
|
52 | | - controls[i].activate(); // And activate it.
|
53 | | - }
|
54 | | -
|
55 | | - }
|
56 | | -
|
57 | | - // Add the base layers.
|
58 | | - for (i in mapTypes) map.addLayer(mapTypes[i]);
|
59 | | -
|
60 | | - // Layer to hold the markers.
|
61 | | - var markerLayer = new OpenLayers.Layer.Markers('Markers');
|
62 | | - markerLayer.id= 'markerLayer';
|
63 | | - map.addLayer(markerLayer);
|
64 | | -
|
65 | | - var centerIsSet = lon != null && lat != null;
|
66 | | -
|
67 | | - var bounds = null;
|
68 | | -
|
69 | | - if (marker_data.length > 1 && (!centerIsSet || zoom == null)) {
|
70 | | - bounds = new OpenLayers.Bounds();
|
71 | | - }
|
72 | | -
|
73 | | - for (i in marker_data) {
|
74 | | - marker_data[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
|
75 | | - if (bounds != null) bounds.extend(marker_data[i].lonlat); // Extend the bounds when no center is set.
|
76 | | - markerLayer.addMarker(getOLMarker(markerLayer, marker_data[i], map.getProjectionObject())); // Create and add the marker.
|
77 | | - }
|
78 | | -
|
79 | | - if (bounds != null) map.zoomToExtent(bounds); // If a bounds object has been created, use it to set the zoom and center.
|
80 | | -
|
81 | | - if (centerIsSet) { // When the center is provided, set it.
|
82 | | - var centre = new OpenLayers.LonLat(lon, lat);
|
83 | | - centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
|
84 | | - map.setCenter(centre);
|
85 | | - }
|
86 | | -
|
87 | | - if (zoom != null) map.zoomTo(zoom); // When the zoom is provided, set it.
|
88 | | -
|
89 | | - return map;
|
90 | | -}
|
91 | | -
|
92 | | -/**
|
93 | | - * Gets a valid control name (with excat lower and upper case letters),
|
94 | | - * or returns false when the control is not allowed.
|
95 | | - */
|
96 | | -function getValidControlName(control) {
|
97 | | - var OLControls = ['ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan',
|
98 | | - 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher',
|
99 | | - 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar',
|
100 | | - 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan',
|
101 | | - 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'Permalink',
|
102 | | - 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split',
|
103 | | - 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel',
|
104 | | - 'ZoomToMaxExtent'];
|
105 | | -
|
106 | | - for (i in OLControls) {
|
107 | | - if (control == OLControls[i].toLowerCase()) {
|
108 | | - return OLControls[i];
|
109 | | - }
|
110 | | - }
|
111 | | -
|
112 | | - return false;
|
113 | | -}
|
114 | | -
|
115 | | -function getOLMarker(markerLayer, markerData, projectionObject) {
|
116 | | - var marker;
|
117 | | -
|
118 | | - if (markerData.icon != "") {
|
119 | | - //var iconSize = new OpenLayers.Size(10,17);
|
120 | | - //var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h);
|
121 | | - marker = new OpenLayers.Marker(markerData.lonlat, new OpenLayers.Icon(markerData.icon)); // , iconSize, iconOffset
|
122 | | - } else {
|
123 | | - marker = new OpenLayers.Marker(markerData.lonlat);
|
124 | | - }
|
125 | | -
|
126 | | - if (markerData.title.length + markerData.label.length > 0 ) {
|
127 | | -
|
128 | | - // This is the handler for the mousedown event on the marker, and displays the popup.
|
129 | | - marker.events.register('mousedown', marker,
|
130 | | - function(evt) {
|
131 | | - var popup = new OpenLayers.Feature(markerLayer, markerData.lonlat).createPopup(true);
|
132 | | -
|
133 | | - if (markerData.title.length > 0 && markerData.label.length > 0) { // Add the title and label to the popup text.
|
134 | | - popup.setContentHTML('<b>' + markerData.title + '</b><hr />' + markerData.label);
|
135 | | - }
|
136 | | - else {
|
137 | | - popup.setContentHTML(markerData.title + markerData.label);
|
138 | | - }
|
139 | | -
|
140 | | - popup.setOpacity(0.85);
|
141 | | - markerLayer.map.addPopup(popup);
|
142 | | - OpenLayers.Event.stop(evt); // Stop the event.
|
143 | | - }
|
144 | | - );
|
145 | | -
|
146 | | - }
|
147 | | -
|
148 | | - return marker;
|
149 | | -}
|
150 | | -
|
151 | | -function getOLMarkerData(lon, lat, title, label, icon) {
|
152 | | - lonLat = new OpenLayers.LonLat(lon, lat);
|
153 | | - return {
|
154 | | - lonlat: lonLat,
|
155 | | - title: title,
|
156 | | - label: label,
|
157 | | - icon: icon
|
158 | | - };
|
159 | | -}
|
160 | | -
|
161 | | -function initOLSettings(minWidth, minHeight) {
|
162 | | - OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
|
163 | | - OpenLayers.Util.onImageLoadErrorColor = 'transparent';
|
164 | | - OpenLayers.Feature.prototype.popupClass = OpenLayers.Class(
|
165 | | - OpenLayers.Popup.FramedCloud,
|
166 | | - {
|
167 | | - 'autoSize': true,
|
168 | | - 'minSize': new OpenLayers.Size(minWidth, minHeight)
|
169 | | - }
|
170 | | - );
|
171 | | -}
|
172 | | -
|
| 2 | + /** |
| 3 | + * Javascript functions for Open Layers functionallity in Maps and it's extensions |
| 4 | + * |
| 5 | + * @file OpenLayerFunctions.js |
| 6 | + * @ingroup MapsOpenLayers |
| 7 | + * |
| 8 | + * @author Jeroen De Dauw |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * Creates and initializes an OpenLayers map. |
| 13 | + * The resulting map is returned by the function but no further handling is required in most cases. |
| 14 | + */ |
| 15 | +function initOpenLayer(mapName, lon, lat, zoom, mapTypes, controls, marker_data){ |
| 16 | + |
| 17 | + // Create a new OpenLayers map with without any controls on it. |
| 18 | + var mapOptions = { |
| 19 | + projection: new OpenLayers.Projection("EPSG:900913"), |
| 20 | + displayProjection: new OpenLayers.Projection("EPSG:4326"), |
| 21 | + units: "m", |
| 22 | + numZoomLevels: 18, |
| 23 | + maxResolution: 156543.0339, |
| 24 | + maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34), |
| 25 | + controls: [] |
| 26 | + }; |
| 27 | + |
| 28 | + var mapElement = document.getElementById(mapName); |
| 29 | + |
| 30 | + // Remove the loading map message. |
| 31 | + mapElement.innerHTML = ''; |
| 32 | + |
| 33 | + var map = new OpenLayers.Map(mapName, mapOptions); |
| 34 | + |
| 35 | + // Add the controls. |
| 36 | + for (i in controls) { |
| 37 | + |
| 38 | + // If a string is provided, find the correct name for the control, and use eval to create the object itself. |
| 39 | + if (typeof controls[i] == 'string') { |
| 40 | + if (controls[i].toLowerCase() == 'autopanzoom') { |
| 41 | + if (mapElement.offsetHeight > 140) controls[i] = mapElement.offsetHeight > 320 ? 'panzoombar' : 'panzoom'; |
| 42 | + } |
| 43 | + |
| 44 | + control = getValidControlName(controls[i]); |
| 45 | + |
| 46 | + if (control) { |
| 47 | + eval(' map.addControl( new OpenLayers.Control.' + control + '() ); '); |
| 48 | + } |
| 49 | + } |
| 50 | + else { |
| 51 | + map.addControl(controls[i]); // If a control is provided, instead a string, just add it. |
| 52 | + controls[i].activate(); // And activate it. |
| 53 | + } |
| 54 | + |
| 55 | + } |
| 56 | + |
| 57 | + // Add the base layers. |
| 58 | + for (i in mapTypes) map.addLayer(mapTypes[i]); |
| 59 | + |
| 60 | + // Layer to hold the markers. |
| 61 | + var markerLayer = new OpenLayers.Layer.Markers('Markers'); |
| 62 | + markerLayer.id= 'markerLayer'; |
| 63 | + map.addLayer(markerLayer); |
| 64 | + |
| 65 | + var centerIsSet = lon != null && lat != null; |
| 66 | + |
| 67 | + var bounds = null; |
| 68 | + |
| 69 | + if (marker_data.length > 1 && (!centerIsSet || zoom == null)) { |
| 70 | + bounds = new OpenLayers.Bounds(); |
| 71 | + } |
| 72 | + |
| 73 | + for (i in marker_data) { |
| 74 | + marker_data[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 75 | + if (bounds != null) bounds.extend(marker_data[i].lonlat); // Extend the bounds when no center is set. |
| 76 | + markerLayer.addMarker(getOLMarker(markerLayer, marker_data[i], map.getProjectionObject())); // Create and add the marker. |
| 77 | + } |
| 78 | + |
| 79 | + if (bounds != null) map.zoomToExtent(bounds); // If a bounds object has been created, use it to set the zoom and center. |
| 80 | + |
| 81 | + if (centerIsSet) { // When the center is provided, set it. |
| 82 | + var centre = new OpenLayers.LonLat(lon, lat); |
| 83 | + centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 84 | + map.setCenter(centre); |
| 85 | + } |
| 86 | + |
| 87 | + if (zoom != null) map.zoomTo(zoom); // When the zoom is provided, set it. |
| 88 | + |
| 89 | + return map; |
| 90 | +} |
| 91 | + |
| 92 | +/** |
| 93 | + * Gets a valid control name (with excat lower and upper case letters), |
| 94 | + * or returns false when the control is not allowed. |
| 95 | + */ |
| 96 | +function getValidControlName(control) { |
| 97 | + var OLControls = ['ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan', |
| 98 | + 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher', |
| 99 | + 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar', |
| 100 | + 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan', |
| 101 | + 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'Permalink', |
| 102 | + 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split', |
| 103 | + 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel', |
| 104 | + 'ZoomToMaxExtent']; |
| 105 | + |
| 106 | + for (i in OLControls) { |
| 107 | + if (control == OLControls[i].toLowerCase()) { |
| 108 | + return OLControls[i]; |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + return false; |
| 113 | +} |
| 114 | + |
| 115 | +function getOLMarker(markerLayer, markerData, projectionObject) { |
| 116 | + var marker; |
| 117 | + |
| 118 | + if (markerData.icon != "") { |
| 119 | + //var iconSize = new OpenLayers.Size(10,17); |
| 120 | + //var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h); |
| 121 | + marker = new OpenLayers.Marker(markerData.lonlat, new OpenLayers.Icon(markerData.icon)); // , iconSize, iconOffset |
| 122 | + } else { |
| 123 | + marker = new OpenLayers.Marker(markerData.lonlat); |
| 124 | + } |
| 125 | + |
| 126 | + if (markerData.title.length + markerData.label.length > 0 ) { |
| 127 | + |
| 128 | + // This is the handler for the mousedown event on the marker, and displays the popup. |
| 129 | + marker.events.register('mousedown', marker, |
| 130 | + function(evt) { |
| 131 | + var popup = new OpenLayers.Feature(markerLayer, markerData.lonlat).createPopup(true); |
| 132 | + |
| 133 | + if (markerData.title.length > 0 && markerData.label.length > 0) { // Add the title and label to the popup text. |
| 134 | + popup.setContentHTML('<b>' + markerData.title + '</b><hr />' + markerData.label); |
| 135 | + } |
| 136 | + else { |
| 137 | + popup.setContentHTML(markerData.title + markerData.label); |
| 138 | + } |
| 139 | + |
| 140 | + popup.setOpacity(0.85); |
| 141 | + markerLayer.map.addPopup(popup); |
| 142 | + OpenLayers.Event.stop(evt); // Stop the event. |
| 143 | + } |
| 144 | + ); |
| 145 | + |
| 146 | + } |
| 147 | + |
| 148 | + return marker; |
| 149 | +} |
| 150 | + |
| 151 | +function getOLMarkerData(lon, lat, title, label, icon) { |
| 152 | + lonLat = new OpenLayers.LonLat(lon, lat); |
| 153 | + return { |
| 154 | + lonlat: lonLat, |
| 155 | + title: title, |
| 156 | + label: label, |
| 157 | + icon: icon |
| 158 | + }; |
| 159 | +} |
| 160 | + |
| 161 | +function initOLSettings(minWidth, minHeight) { |
| 162 | + OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; |
| 163 | + OpenLayers.Util.onImageLoadErrorColor = 'transparent'; |
| 164 | + OpenLayers.Feature.prototype.popupClass = OpenLayers.Class( |
| 165 | + OpenLayers.Popup.FramedCloud, |
| 166 | + { |
| 167 | + 'autoSize': true, |
| 168 | + 'minSize': new OpenLayers.Size(minWidth, minHeight) |
| 169 | + } |
| 170 | + ); |
| 171 | +} |
| 172 | + |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayerFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
173 | 173 | + native |
Index: trunk/extensions/Maps/Services/OpenLayers/OpenLayerFunctions.min.js |
— | — | @@ -1,18 +1,18 @@ |
2 | | -function initOpenLayer(mapName,lon,lat,zoom,mapTypes,controls,marker_data,height){var mapOptions={projection:new OpenLayers.Projection("EPSG:900913"),displayProjection:new OpenLayers.Projection("EPSG:4326"),units:"m",numZoomLevels:18,maxResolution:156543.0339,maxExtent:new OpenLayers.Bounds(-20037508,-20037508,20037508,2.003750834E7),controls:[]};var map=new OpenLayers.Map(mapName,mapOptions);for(i in controls)if(typeof controls[i]=="string"){if(controls[i].toLowerCase()=="autopanzoom")if(height>
|
3 | | -140)controls[i]=height>320?"panzoombar":"panzoom";control=getValidControlName(controls[i]);if(control)eval(" map.addControl( new OpenLayers.Control."+control+"() ); ")}else{map.addControl(controls[i]);controls[i].activate()}addMapBaseLayers(map,mapTypes);var markerLayer=new OpenLayers.Layer.Markers("Markers");markerLayer.id="markerLayer";map.addLayer(markerLayer);var centerIsSet=lon!=null&&lat!=null;var bounds=null;if(marker_data.length>1&&(!centerIsSet||zoom==null))bounds=new OpenLayers.Bounds;for(i in marker_data){marker_data[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"),
|
4 | | -new OpenLayers.Projection("EPSG:900913"));if(bounds!=null)bounds.extend(marker_data[i].lonlat);markerLayer.addMarker(getOLMarker(markerLayer,marker_data[i],map.getProjectionObject()))}if(bounds!=null)map.zoomToExtent(bounds);if(centerIsSet){var centre=new OpenLayers.LonLat(lon,lat);centre.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));map.setCenter(centre)}if(zoom!=null)map.zoomTo(zoom);return map}
|
5 | | -function getValidControlName(control){var OLControls=["ArgParser","Attribution","Button","DragFeature","DragPan","DrawFeature","EditingToolbar","GetFeature","KeyboardDefaults","LayerSwitcher","Measure","ModifyFeature","MouseDefaults","MousePosition","MouseToolbar","Navigation","NavigationHistory","NavToolbar","OverviewMap","Pan","Panel","PanPanel","PanZoom","PanZoomBar","Permalink","Scale","ScaleLine","SelectFeature","Snapping","Split","WMSGetFeatureInfo","ZoomBox","ZoomIn","ZoomOut","ZoomPanel",
|
6 | | -"ZoomToMaxExtent"];for(i in OLControls)if(control==OLControls[i].toLowerCase())return OLControls[i];return false}
|
7 | | -function addMapBaseLayers(map,mapTypes){var googleAPILoaded=typeof G_NORMAL_MAP!="undefined";var shownApiError=false;var usedNor=false;var usedSat=false;var usedHyb=false;var usedPhy=false;var usedBingNor=false;var usedBingHyb=false;var usedBingSat=false;var usedYahooNor=false;var usedYahooHyb=false;var usedYahooSat=false;var usedOLWMS=false;var usedOSMnik=false;var usedOSMcycle=false;var usedOSMarender=false;var usedNasa=false;var isDefaultBaseLayer=false;for(i in mapTypes){var newLayer=null;switch(mapTypes[i]){case "google":case "google-normal":case "google-satellite":case "google-hybrid":case "google-physical":if(googleAPILoaded)switch(mapTypes[i]){case "google-normal":if(!usedNor){newLayer=
|
8 | | -new OpenLayers.Layer.Google("Google Streets",{sphericalMercator:true});usedNor=true}break;case "google-satellite":if(!usedSat){newLayer=new OpenLayers.Layer.Google("Google Satellite",{type:G_SATELLITE_MAP,sphericalMercator:true});usedSat=true}break;case "google-hybrid":if(!usedHyb){newLayer=new OpenLayers.Layer.Google("Google Hybrid",{type:G_HYBRID_MAP,sphericalMercator:true});usedHyb=true}break;case "google-physical":if(!usedPhy){newLayer=new OpenLayers.Layer.Google("Google Physical",{type:G_PHYSICAL_MAP,
|
9 | | -sphericalMercator:true});usedPhy=true}break;case "google":if(!usedNor){map.addLayer(new OpenLayers.Layer.Google("Google Streets",{sphericalMercator:true}));usedNor=true}if(!usedSat){map.addLayer(new OpenLayers.Layer.Google("Google Satellite",{type:G_SATELLITE_MAP,sphericalMercator:true}));usedSat=true}if(!usedHyb){map.addLayer(new OpenLayers.Layer.Google("Google Hybrid",{type:G_HYBRID_MAP,sphericalMercator:true}));usedHyb=true}if(!usedPhy){map.addLayer(new OpenLayers.Layer.Google("Google Physical",
|
10 | | -{type:G_PHYSICAL_MAP,sphericalMercator:true}));usedPhy=true}break}else if(!shownApiError){window.alert("Please enter your Google Maps API key to use the Google Maps layers");shownApiError=true}break;case "bing":case "virtual-earth":if(!usedBingNor){map.addLayer(new OpenLayers.Layer.VirtualEarth("Bing Streets",{type:VEMapStyle.Shaded,sphericalMercator:true}));usedBingNor=true}if(!usedBingSat){map.addLayer(new OpenLayers.Layer.VirtualEarth("Bing Satellite",{type:VEMapStyle.Aerial,sphericalMercator:true}));
|
11 | | -usedBingSat=true}if(!usedBingHyb){map.addLayer(new OpenLayers.Layer.VirtualEarth("Bing Hybrid",{type:VEMapStyle.Hybrid,sphericalMercator:true}));usedBingHyb=true}break;case "bing-normal":if(!usedBingNor){newLayer=new OpenLayers.Layer.VirtualEarth("Bing Streets",{type:VEMapStyle.Shaded,sphericalMercator:true});usedBingNor=true}case "bing-satellite":if(!usedBingSat){newLayer=new OpenLayers.Layer.VirtualEarth("Bing Satellite",{type:VEMapStyle.Aerial,sphericalMercator:true});usedBingSat=true}case "bing-hybrid":if(!usedBingHyb){newLayer=
|
12 | | -new OpenLayers.Layer.VirtualEarth("Bing Hybrid",{type:VEMapStyle.Hybrid,sphericalMercator:true});usedBingHyb=true}case "yahoo":if(!usedYahooNor){map.addLayer(new OpenLayers.Layer.Yahoo("Yahoo! Streets"),{sphericalMercator:true});usedYahooNor=true}if(!usedYahooSat){map.addLayer(new OpenLayers.Layer.Yahoo("Yahoo! Satellite",{type:YAHOO_MAP_SAT,sphericalMercator:true}));usedYahooSat=true}if(!usedYahooHyb){map.addLayer(new OpenLayers.Layer.Yahoo("Yahoo! Hybrid",{type:YAHOO_MAP_HYB,sphericalMercator:true}));
|
13 | | -usedYahooHyb=true}break;case "yahoo-normal":if(!usedYahooNor){newLayer=new OpenLayers.Layer.Yahoo("Yahoo! Streets",{sphericalMercator:true});usedYahooNor=true}break;case "yahoo-satellite":if(!usedYahooSat){newLayer=new OpenLayers.Layer.Yahoo("Yahoo! Satellite",{type:YAHOO_MAP_SAT,sphericalMercator:true});usedYahooSat=true}break;case "yahoo-hybrid":if(!usedYahooHyb){newLayer=new OpenLayers.Layer.Yahoo("Yahoo! Hybrid",{type:YAHOO_MAP_HYB,sphericalMercator:true});usedYahooHyb=true}break;case "openlayers":case "open-layers":if(!usedOLWMS){newLayer=
|
14 | | -new OpenLayers.Layer.WMS("OpenLayers WMS","http://labs.metacarta.com/wms/vmap0",{layers:"basic",sphericalMercator:true});usedOLWMS=true}break;case "nasa":if(!usedNasa){newLayer=new OpenLayers.Layer.WMS("NASA Global Mosaic","http://t1.hypercube.telascience.org/cgi-bin/landsat7",{layers:"landsat7",sphericalMercator:true});usedNasa=true}break;case "osm":case "openstreetmap":if(!usedOSMarender){map.addLayer(new OpenLayers.Layer.OSM.Osmarender("OSM arender"));usedOSMarender=true}if(!usedOSMnik){map.addLayer(new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik"),
|
15 | | -{sphericalMercator:true});usedOSMnik=true}if(!usedOSMcycle){map.addLayer(new OpenLayers.Layer.OSM.CycleMap("OSM Cycle Map"),{sphericalMercator:true});usedOSMcycle=true}break;case "osmarender":if(!usedOSMarender){newLayer=new OpenLayers.Layer.OSM.Osmarender("OSM arender");usedOSMarender=true}break;case "osm-nik":case "osm-mapnik":if(!usedOSMnik){newLayer=new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik");usedOSMnik=true}break;case "osm-cycle":case "osm-cyclemap":if(!usedOSMcycle){newLayer=new OpenLayers.Layer.OSM.CycleMap("OSM Cycle Map");
|
16 | | -usedOSMcycle=true}break}if(newLayer!=null)map.addLayer(newLayer)}return map}
|
17 | | -function getOLMarker(markerLayer,markerData,projectionObject){var marker;if(markerData.icon!="")marker=new OpenLayers.Marker(markerData.lonlat,new OpenLayers.Icon(markerData.icon));else marker=new OpenLayers.Marker(markerData.lonlat);if(markerData.title.length+markerData.label.length>0)marker.events.register("mousedown",marker,function(evt){var popup=(new OpenLayers.Feature(markerLayer,markerData.lonlat)).createPopup(true);if(markerData.title.length>0&&markerData.label.length>0)popup.setContentHTML("<b>"+
|
18 | | -markerData.title+"</b><hr />"+markerData.label);else popup.setContentHTML(markerData.title+markerData.label);popup.setOpacity(0.85);markerLayer.map.addPopup(popup);OpenLayers.Event.stop(evt)});return marker}function getOLMarkerData(lon,lat,title,label,icon){lonLat=new OpenLayers.LonLat(lon,lat);return{lonlat:lonLat,title:title,label:label,icon:icon}}
|
| 2 | +function initOpenLayer(mapName,lon,lat,zoom,mapTypes,controls,marker_data,height){var mapOptions={projection:new OpenLayers.Projection("EPSG:900913"),displayProjection:new OpenLayers.Projection("EPSG:4326"),units:"m",numZoomLevels:18,maxResolution:156543.0339,maxExtent:new OpenLayers.Bounds(-20037508,-20037508,20037508,2.003750834E7),controls:[]};var map=new OpenLayers.Map(mapName,mapOptions);for(i in controls)if(typeof controls[i]=="string"){if(controls[i].toLowerCase()=="autopanzoom")if(height> |
| 3 | +140)controls[i]=height>320?"panzoombar":"panzoom";control=getValidControlName(controls[i]);if(control)eval(" map.addControl( new OpenLayers.Control."+control+"() ); ")}else{map.addControl(controls[i]);controls[i].activate()}addMapBaseLayers(map,mapTypes);var markerLayer=new OpenLayers.Layer.Markers("Markers");markerLayer.id="markerLayer";map.addLayer(markerLayer);var centerIsSet=lon!=null&&lat!=null;var bounds=null;if(marker_data.length>1&&(!centerIsSet||zoom==null))bounds=new OpenLayers.Bounds;for(i in marker_data){marker_data[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"), |
| 4 | +new OpenLayers.Projection("EPSG:900913"));if(bounds!=null)bounds.extend(marker_data[i].lonlat);markerLayer.addMarker(getOLMarker(markerLayer,marker_data[i],map.getProjectionObject()))}if(bounds!=null)map.zoomToExtent(bounds);if(centerIsSet){var centre=new OpenLayers.LonLat(lon,lat);centre.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));map.setCenter(centre)}if(zoom!=null)map.zoomTo(zoom);return map} |
| 5 | +function getValidControlName(control){var OLControls=["ArgParser","Attribution","Button","DragFeature","DragPan","DrawFeature","EditingToolbar","GetFeature","KeyboardDefaults","LayerSwitcher","Measure","ModifyFeature","MouseDefaults","MousePosition","MouseToolbar","Navigation","NavigationHistory","NavToolbar","OverviewMap","Pan","Panel","PanPanel","PanZoom","PanZoomBar","Permalink","Scale","ScaleLine","SelectFeature","Snapping","Split","WMSGetFeatureInfo","ZoomBox","ZoomIn","ZoomOut","ZoomPanel", |
| 6 | +"ZoomToMaxExtent"];for(i in OLControls)if(control==OLControls[i].toLowerCase())return OLControls[i];return false} |
| 7 | +function addMapBaseLayers(map,mapTypes){var googleAPILoaded=typeof G_NORMAL_MAP!="undefined";var shownApiError=false;var usedNor=false;var usedSat=false;var usedHyb=false;var usedPhy=false;var usedBingNor=false;var usedBingHyb=false;var usedBingSat=false;var usedYahooNor=false;var usedYahooHyb=false;var usedYahooSat=false;var usedOLWMS=false;var usedOSMnik=false;var usedOSMcycle=false;var usedOSMarender=false;var usedNasa=false;var isDefaultBaseLayer=false;for(i in mapTypes){var newLayer=null;switch(mapTypes[i]){case "google":case "google-normal":case "google-satellite":case "google-hybrid":case "google-physical":if(googleAPILoaded)switch(mapTypes[i]){case "google-normal":if(!usedNor){newLayer= |
| 8 | +new OpenLayers.Layer.Google("Google Streets",{sphericalMercator:true});usedNor=true}break;case "google-satellite":if(!usedSat){newLayer=new OpenLayers.Layer.Google("Google Satellite",{type:G_SATELLITE_MAP,sphericalMercator:true});usedSat=true}break;case "google-hybrid":if(!usedHyb){newLayer=new OpenLayers.Layer.Google("Google Hybrid",{type:G_HYBRID_MAP,sphericalMercator:true});usedHyb=true}break;case "google-physical":if(!usedPhy){newLayer=new OpenLayers.Layer.Google("Google Physical",{type:G_PHYSICAL_MAP, |
| 9 | +sphericalMercator:true});usedPhy=true}break;case "google":if(!usedNor){map.addLayer(new OpenLayers.Layer.Google("Google Streets",{sphericalMercator:true}));usedNor=true}if(!usedSat){map.addLayer(new OpenLayers.Layer.Google("Google Satellite",{type:G_SATELLITE_MAP,sphericalMercator:true}));usedSat=true}if(!usedHyb){map.addLayer(new OpenLayers.Layer.Google("Google Hybrid",{type:G_HYBRID_MAP,sphericalMercator:true}));usedHyb=true}if(!usedPhy){map.addLayer(new OpenLayers.Layer.Google("Google Physical", |
| 10 | +{type:G_PHYSICAL_MAP,sphericalMercator:true}));usedPhy=true}break}else if(!shownApiError){window.alert("Please enter your Google Maps API key to use the Google Maps layers");shownApiError=true}break;case "bing":case "virtual-earth":if(!usedBingNor){map.addLayer(new OpenLayers.Layer.VirtualEarth("Bing Streets",{type:VEMapStyle.Shaded,sphericalMercator:true}));usedBingNor=true}if(!usedBingSat){map.addLayer(new OpenLayers.Layer.VirtualEarth("Bing Satellite",{type:VEMapStyle.Aerial,sphericalMercator:true})); |
| 11 | +usedBingSat=true}if(!usedBingHyb){map.addLayer(new OpenLayers.Layer.VirtualEarth("Bing Hybrid",{type:VEMapStyle.Hybrid,sphericalMercator:true}));usedBingHyb=true}break;case "bing-normal":if(!usedBingNor){newLayer=new OpenLayers.Layer.VirtualEarth("Bing Streets",{type:VEMapStyle.Shaded,sphericalMercator:true});usedBingNor=true}case "bing-satellite":if(!usedBingSat){newLayer=new OpenLayers.Layer.VirtualEarth("Bing Satellite",{type:VEMapStyle.Aerial,sphericalMercator:true});usedBingSat=true}case "bing-hybrid":if(!usedBingHyb){newLayer= |
| 12 | +new OpenLayers.Layer.VirtualEarth("Bing Hybrid",{type:VEMapStyle.Hybrid,sphericalMercator:true});usedBingHyb=true}case "yahoo":if(!usedYahooNor){map.addLayer(new OpenLayers.Layer.Yahoo("Yahoo! Streets"),{sphericalMercator:true});usedYahooNor=true}if(!usedYahooSat){map.addLayer(new OpenLayers.Layer.Yahoo("Yahoo! Satellite",{type:YAHOO_MAP_SAT,sphericalMercator:true}));usedYahooSat=true}if(!usedYahooHyb){map.addLayer(new OpenLayers.Layer.Yahoo("Yahoo! Hybrid",{type:YAHOO_MAP_HYB,sphericalMercator:true})); |
| 13 | +usedYahooHyb=true}break;case "yahoo-normal":if(!usedYahooNor){newLayer=new OpenLayers.Layer.Yahoo("Yahoo! Streets",{sphericalMercator:true});usedYahooNor=true}break;case "yahoo-satellite":if(!usedYahooSat){newLayer=new OpenLayers.Layer.Yahoo("Yahoo! Satellite",{type:YAHOO_MAP_SAT,sphericalMercator:true});usedYahooSat=true}break;case "yahoo-hybrid":if(!usedYahooHyb){newLayer=new OpenLayers.Layer.Yahoo("Yahoo! Hybrid",{type:YAHOO_MAP_HYB,sphericalMercator:true});usedYahooHyb=true}break;case "openlayers":case "open-layers":if(!usedOLWMS){newLayer= |
| 14 | +new OpenLayers.Layer.WMS("OpenLayers WMS","http://labs.metacarta.com/wms/vmap0",{layers:"basic",sphericalMercator:true});usedOLWMS=true}break;case "nasa":if(!usedNasa){newLayer=new OpenLayers.Layer.WMS("NASA Global Mosaic","http://t1.hypercube.telascience.org/cgi-bin/landsat7",{layers:"landsat7",sphericalMercator:true});usedNasa=true}break;case "osm":case "openstreetmap":if(!usedOSMarender){map.addLayer(new OpenLayers.Layer.OSM.Osmarender("OSM arender"));usedOSMarender=true}if(!usedOSMnik){map.addLayer(new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik"), |
| 15 | +{sphericalMercator:true});usedOSMnik=true}if(!usedOSMcycle){map.addLayer(new OpenLayers.Layer.OSM.CycleMap("OSM Cycle Map"),{sphericalMercator:true});usedOSMcycle=true}break;case "osmarender":if(!usedOSMarender){newLayer=new OpenLayers.Layer.OSM.Osmarender("OSM arender");usedOSMarender=true}break;case "osm-nik":case "osm-mapnik":if(!usedOSMnik){newLayer=new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik");usedOSMnik=true}break;case "osm-cycle":case "osm-cyclemap":if(!usedOSMcycle){newLayer=new OpenLayers.Layer.OSM.CycleMap("OSM Cycle Map"); |
| 16 | +usedOSMcycle=true}break}if(newLayer!=null)map.addLayer(newLayer)}return map} |
| 17 | +function getOLMarker(markerLayer,markerData,projectionObject){var marker;if(markerData.icon!="")marker=new OpenLayers.Marker(markerData.lonlat,new OpenLayers.Icon(markerData.icon));else marker=new OpenLayers.Marker(markerData.lonlat);if(markerData.title.length+markerData.label.length>0)marker.events.register("mousedown",marker,function(evt){var popup=(new OpenLayers.Feature(markerLayer,markerData.lonlat)).createPopup(true);if(markerData.title.length>0&&markerData.label.length>0)popup.setContentHTML("<b>"+ |
| 18 | +markerData.title+"</b><hr />"+markerData.label);else popup.setContentHTML(markerData.title+markerData.label);popup.setOpacity(0.85);markerLayer.map.addPopup(popup);OpenLayers.Event.stop(evt)});return marker}function getOLMarkerData(lon,lat,title,label,icon){lonLat=new OpenLayers.LonLat(lon,lat);return{lonlat:lonLat,title:title,label:label,icon:icon}} |
19 | 19 | function initOLSettings(minWidth,minHeight){OpenLayers.IMAGE_RELOAD_ATTEMPTS=3;OpenLayers.Util.onImageLoadErrorColor="transparent";OpenLayers.Feature.prototype.popupClass=OpenLayers.Class(OpenLayers.Popup.FramedCloud,{autoSize:true,minSize:new OpenLayers.Size(minWidth,minHeight)})}; |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayerFunctions.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
20 | 20 | + native |
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispMap.php |
— | — | @@ -1,75 +1,75 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Class for handling the display_map parser function with OpenLayers
|
6 | | - *
|
7 | | - * @file Maps_OpenLayersDispMap.php
|
8 | | - * @ingroup MapsOpenLayers
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -class MapsOpenLayersDispMap extends MapsBaseMap {
|
18 | | -
|
19 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME;
|
20 | | -
|
21 | | - protected function getDefaultZoom() {
|
22 | | - global $egMapsOpenLayersZoom;
|
23 | | - return $egMapsOpenLayersZoom;
|
24 | | - }
|
25 | | -
|
26 | | - /**
|
27 | | - * @see MapsBaseMap::doMapServiceLoad()
|
28 | | - */
|
29 | | - protected function doMapServiceLoad() {
|
30 | | - global $egOpenLayersOnThisPage;
|
31 | | -
|
32 | | - MapsOpenLayers::addOLDependencies( $this->output );
|
33 | | - $egOpenLayersOnThisPage++;
|
34 | | -
|
35 | | - $this->elementNr = $egOpenLayersOnThisPage;
|
36 | | - }
|
37 | | -
|
38 | | - /**
|
39 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
40 | | - */
|
41 | | - public function addSpecificMapHTML( Parser $parser ) {
|
42 | | - global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage;
|
43 | | -
|
44 | | - $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
|
45 | | -
|
46 | | - $mapName = $egMapsOpenLayersPrefix . '_' . $egOpenLayersOnThisPage;
|
47 | | -
|
48 | | - $this->output .= Html::element(
|
49 | | - 'div',
|
50 | | - array(
|
51 | | - 'id' => $mapName,
|
52 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
53 | | - ),
|
54 | | - wfMsg('maps-loading-map')
|
55 | | - );
|
56 | | -
|
57 | | - $parser->getOutput()->addHeadItem(
|
58 | | - Html::inlineScript( <<<EOT
|
59 | | -addOnloadHook(
|
60 | | - function() {
|
61 | | - initOpenLayer(
|
62 | | - '$mapName',
|
63 | | - $this->centreLon,
|
64 | | - $this->centreLat,
|
65 | | - $this->zoom,
|
66 | | - [$layerItems],
|
67 | | - [$this->controls],
|
68 | | - []
|
69 | | - );
|
70 | | - }
|
71 | | -);
|
72 | | -EOT
|
73 | | - ) );
|
74 | | - }
|
75 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class for handling the display_map parser function with OpenLayers |
| 6 | + * |
| 7 | + * @file Maps_OpenLayersDispMap.php |
| 8 | + * @ingroup MapsOpenLayers |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +class MapsOpenLayersDispMap extends MapsBaseMap { |
| 18 | + |
| 19 | + public $serviceName = MapsOpenLayers::SERVICE_NAME; |
| 20 | + |
| 21 | + protected function getDefaultZoom() { |
| 22 | + global $egMapsOpenLayersZoom; |
| 23 | + return $egMapsOpenLayersZoom; |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @see MapsBaseMap::doMapServiceLoad() |
| 28 | + */ |
| 29 | + protected function doMapServiceLoad() { |
| 30 | + global $egOpenLayersOnThisPage; |
| 31 | + |
| 32 | + MapsOpenLayers::addOLDependencies( $this->output ); |
| 33 | + $egOpenLayersOnThisPage++; |
| 34 | + |
| 35 | + $this->elementNr = $egOpenLayersOnThisPage; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 40 | + */ |
| 41 | + public function addSpecificMapHTML( Parser $parser ) { |
| 42 | + global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage; |
| 43 | + |
| 44 | + $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
| 45 | + |
| 46 | + $mapName = $egMapsOpenLayersPrefix . '_' . $egOpenLayersOnThisPage; |
| 47 | + |
| 48 | + $this->output .= Html::element( |
| 49 | + 'div', |
| 50 | + array( |
| 51 | + 'id' => $mapName, |
| 52 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 53 | + ), |
| 54 | + wfMsg('maps-loading-map') |
| 55 | + ); |
| 56 | + |
| 57 | + $parser->getOutput()->addHeadItem( |
| 58 | + Html::inlineScript( <<<EOT |
| 59 | +addOnloadHook( |
| 60 | + function() { |
| 61 | + initOpenLayer( |
| 62 | + '$mapName', |
| 63 | + $this->centreLon, |
| 64 | + $this->centreLat, |
| 65 | + $this->zoom, |
| 66 | + [$layerItems], |
| 67 | + [$this->controls], |
| 68 | + [] |
| 69 | + ); |
| 70 | + } |
| 71 | +); |
| 72 | +EOT |
| 73 | + ) ); |
| 74 | + } |
| 75 | + |
76 | 76 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
77 | 77 | + native |
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayers.php |
— | — | @@ -1,207 +1,207 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all OpenLayers related files of the Maps extension.
|
6 | | - *
|
7 | | - * @defgroup MapsOpenLayers OpenLayers
|
8 | | - * @ingroup Maps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the OpenLayers service
|
13 | | - *
|
14 | | - * @file Maps_OpenLayers.php
|
15 | | - * @ingroup MapsOpenLayers
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - */
|
19 | | -
|
20 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
21 | | - die( 'Not an entry point.' );
|
22 | | -}
|
23 | | -
|
24 | | -$wgAutoloadClasses['MapsOpenLayers'] = dirname( __FILE__ ) . '/Maps_OpenLayers.php';
|
25 | | -
|
26 | | -$wgHooks['MappingServiceLoad'][] = 'MapsOpenLayers::initialize';
|
27 | | -
|
28 | | -$wgAutoloadClasses['MapsOpenLayersDispMap'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispMap.php';
|
29 | | -$wgAutoloadClasses['MapsOpenLayersDispPoint'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispPoint.php';
|
30 | | -
|
31 | | -$egMapsServices[MapsOpenLayers::SERVICE_NAME] = array(
|
32 | | - 'aliases' => array( 'layers', 'openlayer' ),
|
33 | | - 'features' => array(
|
34 | | - 'display_point' => 'MapsOpenLayersDispPoint',
|
35 | | - 'display_map' => 'MapsOpenLayersDispMap',
|
36 | | - )
|
37 | | -);
|
38 | | -
|
39 | | -/**
|
40 | | - * Class for OpenLayers initialization.
|
41 | | - *
|
42 | | - * @ingroup MapsOpenLayers
|
43 | | - *
|
44 | | - * @author Jeroen De Dauw
|
45 | | - */
|
46 | | -class MapsOpenLayers {
|
47 | | -
|
48 | | - const SERVICE_NAME = 'openlayers';
|
49 | | -
|
50 | | - public static function initialize() {
|
51 | | - global $wgAutoloadClasses, $egMapsServices, $egMapsOLLoadedLayers;
|
52 | | -
|
53 | | - $egMapsOLLoadedLayers = array();
|
54 | | -
|
55 | | - self::initializeParams();
|
56 | | -
|
57 | | - Validator::addOutputFormat( 'olgroups', array( __CLASS__, 'unpackLayerGroups' ) );
|
58 | | -
|
59 | | - return true;
|
60 | | - }
|
61 | | -
|
62 | | - private static function initializeParams() {
|
63 | | - global $egMapsServices, $egMapsOLLayers, $egMapsOLControls, $egMapsOpenLayersZoom;
|
64 | | -
|
65 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
|
66 | | - 'controls' => array(
|
67 | | - 'type' => array( 'string', 'list' ),
|
68 | | - 'criteria' => array(
|
69 | | - 'in_array' => self::getControlNames()
|
70 | | - ),
|
71 | | - 'default' => $egMapsOLControls,
|
72 | | - 'output-type' => array( 'list', ',', '\'' )
|
73 | | - ),
|
74 | | - 'layers' => array(
|
75 | | - 'type' => array( 'string', 'list' ),
|
76 | | - 'criteria' => array(
|
77 | | - 'in_array' => self::getLayerNames( true )
|
78 | | - ),
|
79 | | - 'default' => $egMapsOLLayers,
|
80 | | - 'output-types' => array(
|
81 | | - 'unique_items',
|
82 | | - 'olgroups',
|
83 | | - array( 'filtered_array', self::getLayerNames() ),
|
84 | | - )
|
85 | | - ),
|
86 | | - );
|
87 | | -
|
88 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 );
|
89 | | - }
|
90 | | -
|
91 | | - /**
|
92 | | - * Returns the names of all supported controls.
|
93 | | - * This data is a copy of the one used to actually translate the names
|
94 | | - * into the controls, since this resides client side, in OpenLayerFunctions.js.
|
95 | | - *
|
96 | | - * @return array
|
97 | | - */
|
98 | | - public static function getControlNames() {
|
99 | | - return array(
|
100 | | - 'argparser', 'attribution', 'button', 'dragfeature', 'dragpan',
|
101 | | - 'drawfeature', 'editingtoolbar', 'getfeature', 'keyboarddefaults', 'layerswitcher',
|
102 | | - 'measure', 'modifyfeature', 'mousedefaults', 'mouseposition', 'mousetoolbar',
|
103 | | - 'navigation', 'navigationhistory', 'navtoolbar', 'overviewmap', 'pan',
|
104 | | - 'panel', 'panpanel', 'panzoom', 'panzoombar', 'autopanzoom', 'permalink',
|
105 | | - 'scale', 'scaleline', 'selectfeature', 'snapping', 'split',
|
106 | | - 'wmsgetfeatureinfo', 'zoombox', 'zoomin', 'zoomout', 'zoompanel',
|
107 | | - 'zoomtomaxextent'
|
108 | | - );
|
109 | | - }
|
110 | | -
|
111 | | - /**
|
112 | | - * Returns the names of all supported layers.
|
113 | | - *
|
114 | | - * @return array
|
115 | | - */
|
116 | | - public static function getLayerNames( $includeGroups = false ) {
|
117 | | - global $egMapsOLAvailableLayers, $egMapsOLLayerGroups;
|
118 | | - $keys = array_keys( $egMapsOLAvailableLayers );
|
119 | | - if ( $includeGroups ) $keys = array_merge( $keys, array_keys( $egMapsOLLayerGroups ) );
|
120 | | - return $keys;
|
121 | | - }
|
122 | | -
|
123 | | - /**
|
124 | | - * If this is the first open layers map on the page, load the API, styles and extra JS functions
|
125 | | - *
|
126 | | - * @param string $output
|
127 | | - */
|
128 | | - public static function addOLDependencies( &$output ) {
|
129 | | - global $wgJsMimeType;
|
130 | | - global $egOpenLayersOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
|
131 | | -
|
132 | | - if ( empty( $egOpenLayersOnThisPage ) ) {
|
133 | | - $egOpenLayersOnThisPage = 0;
|
134 | | -
|
135 | | - $dir = dirname( __FILE__ );
|
136 | | -
|
137 | | - $output .= "<link rel='stylesheet' href='$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
|
138 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js'></script>
|
139 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>
|
140 | | - <script type='$wgJsMimeType'>initOLSettings(200, 100);</script>\n";
|
141 | | - }
|
142 | | - }
|
143 | | -
|
144 | | - /**
|
145 | | - * Build up a csv string with the layers, to be outputted as a JS array
|
146 | | - *
|
147 | | - * @param string $output
|
148 | | - * @param string $layers
|
149 | | - * @return csv string
|
150 | | - */
|
151 | | - public static function createLayersStringAndLoadDependencies( &$output, array $layers ) {
|
152 | | - global $egMapsOLAvailableLayers;
|
153 | | - $layerStr = array();
|
154 | | -
|
155 | | - foreach ( $layers as $layer ) {
|
156 | | - self::loadDependencyWhenNeeded( $output, $layer );
|
157 | | - $layerStr[] = is_array( $egMapsOLAvailableLayers[$layer] ) ? $egMapsOLAvailableLayers[$layer][0] : $egMapsOLAvailableLayers[$layer];
|
158 | | - }
|
159 | | -
|
160 | | - return 'new ' . implode( ',new ', $layerStr );
|
161 | | - }
|
162 | | -
|
163 | | - /**
|
164 | | - * Load the dependencies of a layer if they are not loaded yet.
|
165 | | - *
|
166 | | - * @param string $output The output to which the html to load the dependencies needs to be added
|
167 | | - * @param string $layer The layer to check (and load the dependencies for
|
168 | | - */
|
169 | | - public static function loadDependencyWhenNeeded( &$output, $layer ) {
|
170 | | - global $wgJsMimeType;
|
171 | | - global $egMapsOLAvailableLayers, $egMapsOLLayerDependencies, $egMapsOLLoadedLayers;
|
172 | | -
|
173 | | - // Check if there is a dependency refered by the layer definition.
|
174 | | - if ( is_array( $egMapsOLAvailableLayers[$layer] )
|
175 | | - && count( $egMapsOLAvailableLayers[$layer] ) > 1
|
176 | | - && array_key_exists( $egMapsOLAvailableLayers[$layer][1], $egMapsOLLayerDependencies )
|
177 | | - && !in_array( $egMapsOLAvailableLayers[$layer][1], $egMapsOLLoadedLayers ) ) {
|
178 | | - // Add the dependency to the output.
|
179 | | - $output .= $egMapsOLLayerDependencies[$egMapsOLAvailableLayers[$layer][1]];
|
180 | | - // Register that it's added so it does not get done multiple times.
|
181 | | - $egMapsOLLoadedLayers[] = $egMapsOLAvailableLayers[$layer][1];
|
182 | | - }
|
183 | | - }
|
184 | | -
|
185 | | - /**
|
186 | | - * Removed the layer groups from the layer list, and adds their members back in.
|
187 | | - *
|
188 | | - * @param array $layers
|
189 | | - */
|
190 | | - public static function unpackLayerGroups( array &$layers ) {
|
191 | | - global $egMapsOLLayerGroups;
|
192 | | -
|
193 | | - $unpacked = array();
|
194 | | -
|
195 | | - foreach ( $layers as $layerOrGroup ) {
|
196 | | - if ( array_key_exists( $layerOrGroup, $egMapsOLLayerGroups ) ) {
|
197 | | - $unpacked = array_merge( $unpacked, $egMapsOLLayerGroups[$layerOrGroup] );
|
198 | | - }
|
199 | | - else {
|
200 | | - $unpacked[] = $layerOrGroup;
|
201 | | - }
|
202 | | - }
|
203 | | -
|
204 | | - $layers = $unpacked;
|
205 | | - }
|
206 | | -
|
207 | | -}
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all OpenLayers related files of the Maps extension. |
| 6 | + * |
| 7 | + * @defgroup MapsOpenLayers OpenLayers |
| 8 | + * @ingroup Maps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the OpenLayers service |
| 13 | + * |
| 14 | + * @file Maps_OpenLayers.php |
| 15 | + * @ingroup MapsOpenLayers |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + */ |
| 19 | + |
| 20 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 21 | + die( 'Not an entry point.' ); |
| 22 | +} |
| 23 | + |
| 24 | +$wgAutoloadClasses['MapsOpenLayers'] = dirname( __FILE__ ) . '/Maps_OpenLayers.php'; |
| 25 | + |
| 26 | +$wgHooks['MappingServiceLoad'][] = 'MapsOpenLayers::initialize'; |
| 27 | + |
| 28 | +$wgAutoloadClasses['MapsOpenLayersDispMap'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispMap.php'; |
| 29 | +$wgAutoloadClasses['MapsOpenLayersDispPoint'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispPoint.php'; |
| 30 | + |
| 31 | +$egMapsServices[MapsOpenLayers::SERVICE_NAME] = array( |
| 32 | + 'aliases' => array( 'layers', 'openlayer' ), |
| 33 | + 'features' => array( |
| 34 | + 'display_point' => 'MapsOpenLayersDispPoint', |
| 35 | + 'display_map' => 'MapsOpenLayersDispMap', |
| 36 | + ) |
| 37 | +); |
| 38 | + |
| 39 | +/** |
| 40 | + * Class for OpenLayers initialization. |
| 41 | + * |
| 42 | + * @ingroup MapsOpenLayers |
| 43 | + * |
| 44 | + * @author Jeroen De Dauw |
| 45 | + */ |
| 46 | +class MapsOpenLayers { |
| 47 | + |
| 48 | + const SERVICE_NAME = 'openlayers'; |
| 49 | + |
| 50 | + public static function initialize() { |
| 51 | + global $wgAutoloadClasses, $egMapsServices, $egMapsOLLoadedLayers; |
| 52 | + |
| 53 | + $egMapsOLLoadedLayers = array(); |
| 54 | + |
| 55 | + self::initializeParams(); |
| 56 | + |
| 57 | + Validator::addOutputFormat( 'olgroups', array( __CLASS__, 'unpackLayerGroups' ) ); |
| 58 | + |
| 59 | + return true; |
| 60 | + } |
| 61 | + |
| 62 | + private static function initializeParams() { |
| 63 | + global $egMapsServices, $egMapsOLLayers, $egMapsOLControls, $egMapsOpenLayersZoom; |
| 64 | + |
| 65 | + $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 66 | + 'controls' => array( |
| 67 | + 'type' => array( 'string', 'list' ), |
| 68 | + 'criteria' => array( |
| 69 | + 'in_array' => self::getControlNames() |
| 70 | + ), |
| 71 | + 'default' => $egMapsOLControls, |
| 72 | + 'output-type' => array( 'list', ',', '\'' ) |
| 73 | + ), |
| 74 | + 'layers' => array( |
| 75 | + 'type' => array( 'string', 'list' ), |
| 76 | + 'criteria' => array( |
| 77 | + 'in_array' => self::getLayerNames( true ) |
| 78 | + ), |
| 79 | + 'default' => $egMapsOLLayers, |
| 80 | + 'output-types' => array( |
| 81 | + 'unique_items', |
| 82 | + 'olgroups', |
| 83 | + array( 'filtered_array', self::getLayerNames() ), |
| 84 | + ) |
| 85 | + ), |
| 86 | + ); |
| 87 | + |
| 88 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 ); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Returns the names of all supported controls. |
| 93 | + * This data is a copy of the one used to actually translate the names |
| 94 | + * into the controls, since this resides client side, in OpenLayerFunctions.js. |
| 95 | + * |
| 96 | + * @return array |
| 97 | + */ |
| 98 | + public static function getControlNames() { |
| 99 | + return array( |
| 100 | + 'argparser', 'attribution', 'button', 'dragfeature', 'dragpan', |
| 101 | + 'drawfeature', 'editingtoolbar', 'getfeature', 'keyboarddefaults', 'layerswitcher', |
| 102 | + 'measure', 'modifyfeature', 'mousedefaults', 'mouseposition', 'mousetoolbar', |
| 103 | + 'navigation', 'navigationhistory', 'navtoolbar', 'overviewmap', 'pan', |
| 104 | + 'panel', 'panpanel', 'panzoom', 'panzoombar', 'autopanzoom', 'permalink', |
| 105 | + 'scale', 'scaleline', 'selectfeature', 'snapping', 'split', |
| 106 | + 'wmsgetfeatureinfo', 'zoombox', 'zoomin', 'zoomout', 'zoompanel', |
| 107 | + 'zoomtomaxextent' |
| 108 | + ); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Returns the names of all supported layers. |
| 113 | + * |
| 114 | + * @return array |
| 115 | + */ |
| 116 | + public static function getLayerNames( $includeGroups = false ) { |
| 117 | + global $egMapsOLAvailableLayers, $egMapsOLLayerGroups; |
| 118 | + $keys = array_keys( $egMapsOLAvailableLayers ); |
| 119 | + if ( $includeGroups ) $keys = array_merge( $keys, array_keys( $egMapsOLLayerGroups ) ); |
| 120 | + return $keys; |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * If this is the first open layers map on the page, load the API, styles and extra JS functions |
| 125 | + * |
| 126 | + * @param string $output |
| 127 | + */ |
| 128 | + public static function addOLDependencies( &$output ) { |
| 129 | + global $wgJsMimeType; |
| 130 | + global $egOpenLayersOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath; |
| 131 | + |
| 132 | + if ( empty( $egOpenLayersOnThisPage ) ) { |
| 133 | + $egOpenLayersOnThisPage = 0; |
| 134 | + |
| 135 | + $dir = dirname( __FILE__ ); |
| 136 | + |
| 137 | + $output .= "<link rel='stylesheet' href='$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' /> |
| 138 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js'></script> |
| 139 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script> |
| 140 | + <script type='$wgJsMimeType'>initOLSettings(200, 100);</script>\n"; |
| 141 | + } |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * Build up a csv string with the layers, to be outputted as a JS array |
| 146 | + * |
| 147 | + * @param string $output |
| 148 | + * @param string $layers |
| 149 | + * @return csv string |
| 150 | + */ |
| 151 | + public static function createLayersStringAndLoadDependencies( &$output, array $layers ) { |
| 152 | + global $egMapsOLAvailableLayers; |
| 153 | + $layerStr = array(); |
| 154 | + |
| 155 | + foreach ( $layers as $layer ) { |
| 156 | + self::loadDependencyWhenNeeded( $output, $layer ); |
| 157 | + $layerStr[] = is_array( $egMapsOLAvailableLayers[$layer] ) ? $egMapsOLAvailableLayers[$layer][0] : $egMapsOLAvailableLayers[$layer]; |
| 158 | + } |
| 159 | + |
| 160 | + return 'new ' . implode( ',new ', $layerStr ); |
| 161 | + } |
| 162 | + |
| 163 | + /** |
| 164 | + * Load the dependencies of a layer if they are not loaded yet. |
| 165 | + * |
| 166 | + * @param string $output The output to which the html to load the dependencies needs to be added |
| 167 | + * @param string $layer The layer to check (and load the dependencies for |
| 168 | + */ |
| 169 | + public static function loadDependencyWhenNeeded( &$output, $layer ) { |
| 170 | + global $wgJsMimeType; |
| 171 | + global $egMapsOLAvailableLayers, $egMapsOLLayerDependencies, $egMapsOLLoadedLayers; |
| 172 | + |
| 173 | + // Check if there is a dependency refered by the layer definition. |
| 174 | + if ( is_array( $egMapsOLAvailableLayers[$layer] ) |
| 175 | + && count( $egMapsOLAvailableLayers[$layer] ) > 1 |
| 176 | + && array_key_exists( $egMapsOLAvailableLayers[$layer][1], $egMapsOLLayerDependencies ) |
| 177 | + && !in_array( $egMapsOLAvailableLayers[$layer][1], $egMapsOLLoadedLayers ) ) { |
| 178 | + // Add the dependency to the output. |
| 179 | + $output .= $egMapsOLLayerDependencies[$egMapsOLAvailableLayers[$layer][1]]; |
| 180 | + // Register that it's added so it does not get done multiple times. |
| 181 | + $egMapsOLLoadedLayers[] = $egMapsOLAvailableLayers[$layer][1]; |
| 182 | + } |
| 183 | + } |
| 184 | + |
| 185 | + /** |
| 186 | + * Removed the layer groups from the layer list, and adds their members back in. |
| 187 | + * |
| 188 | + * @param array $layers |
| 189 | + */ |
| 190 | + public static function unpackLayerGroups( array &$layers ) { |
| 191 | + global $egMapsOLLayerGroups; |
| 192 | + |
| 193 | + $unpacked = array(); |
| 194 | + |
| 195 | + foreach ( $layers as $layerOrGroup ) { |
| 196 | + if ( array_key_exists( $layerOrGroup, $egMapsOLLayerGroups ) ) { |
| 197 | + $unpacked = array_merge( $unpacked, $egMapsOLLayerGroups[$layerOrGroup] ); |
| 198 | + } |
| 199 | + else { |
| 200 | + $unpacked[] = $layerOrGroup; |
| 201 | + } |
| 202 | + } |
| 203 | + |
| 204 | + $layers = $unpacked; |
| 205 | + } |
| 206 | + |
| 207 | +} |
208 | 208 | |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayers.php |
___________________________________________________________________ |
Added: svn:eol-style |
209 | 209 | + native |
Index: trunk/extensions/Maps/Services/OpenLayers/OSM/OpenStreetMap.js |
— | — | @@ -1,141 +1,141 @@ |
2 | | -/**
|
3 | | - * Namespace: Util.OSM
|
4 | | - */
|
5 | | -OpenLayers.Util.OSM = {};
|
6 | | -
|
7 | | -/**
|
8 | | - * Constant: MISSING_TILE_URL
|
9 | | - * {String} URL of image to display for missing tiles
|
10 | | - */
|
11 | | -OpenLayers.Util.OSM.MISSING_TILE_URL = "http://openstreetmap.org/openlayers/img/404.png";
|
12 | | -
|
13 | | -/**
|
14 | | - * Property: originalOnImageLoadError
|
15 | | - * {Function} Original onImageLoadError function.
|
16 | | - */
|
17 | | -OpenLayers.Util.OSM.originalOnImageLoadError = OpenLayers.Util.onImageLoadError;
|
18 | | -
|
19 | | -/**
|
20 | | - * Function: onImageLoadError
|
21 | | - */
|
22 | | -OpenLayers.Util.onImageLoadError = function() {
|
23 | | - if (this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)) {
|
24 | | - this.src = OpenLayers.Util.OSM.MISSING_TILE_URL;
|
25 | | - } else if (this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)) {
|
26 | | - // do nothing - this layer is transparent
|
27 | | - } else {
|
28 | | - OpenLayers.Util.OSM.originalOnImageLoadError;
|
29 | | - }
|
30 | | -};
|
31 | | -
|
32 | | -/**
|
33 | | - * Class: OpenLayers.Layer.OSM.Mapnik
|
34 | | - *
|
35 | | - * Inherits from:
|
36 | | - * - <OpenLayers.Layer.OSM>
|
37 | | - */
|
38 | | -OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
39 | | - /**
|
40 | | - * Constructor: OpenLayers.Layer.OSM.Mapnik
|
41 | | - *
|
42 | | - * Parameters:
|
43 | | - * name - {String}
|
44 | | - * options - {Object} Hashtable of extra options to tag onto the layer
|
45 | | - */
|
46 | | - initialize: function(name, options) {
|
47 | | - var url = [
|
48 | | - "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
|
49 | | - "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
|
50 | | - "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
|
51 | | - ];
|
52 | | - options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
|
53 | | - var newArguments = [name, url, options];
|
54 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
55 | | - },
|
56 | | -
|
57 | | - CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
|
58 | | -});
|
59 | | -
|
60 | | -/**
|
61 | | - * Class: OpenLayers.Layer.OSM.Osmarender
|
62 | | - *
|
63 | | - * Inherits from:
|
64 | | - * - <OpenLayers.Layer.OSM>
|
65 | | - */
|
66 | | -OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
67 | | - /**
|
68 | | - * Constructor: OpenLayers.Layer.OSM.Osmarender
|
69 | | - *
|
70 | | - * Parameters:
|
71 | | - * name - {String}
|
72 | | - * options - {Object} Hashtable of extra options to tag onto the layer
|
73 | | - */
|
74 | | - initialize: function(name, options) {
|
75 | | - var url = [
|
76 | | - "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
|
77 | | - "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
|
78 | | - "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
|
79 | | - ];
|
80 | | - options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options);
|
81 | | - var newArguments = [name, url, options];
|
82 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
83 | | - },
|
84 | | -
|
85 | | - CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
|
86 | | -});
|
87 | | -
|
88 | | -/**
|
89 | | - * Class: OpenLayers.Layer.OSM.CycleMap
|
90 | | - *
|
91 | | - * Inherits from:
|
92 | | - * - <OpenLayers.Layer.OSM>
|
93 | | - */
|
94 | | -OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
95 | | - /**
|
96 | | - * Constructor: OpenLayers.Layer.OSM.CycleMap
|
97 | | - *
|
98 | | - * Parameters:
|
99 | | - * name - {String}
|
100 | | - * options - {Object} Hashtable of extra options to tag onto the layer
|
101 | | - */
|
102 | | - initialize: function(name, options) {
|
103 | | - var url = [
|
104 | | - "http://a.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
|
105 | | - "http://b.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png",
|
106 | | - "http://c.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png"
|
107 | | - ];
|
108 | | - options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options);
|
109 | | - var newArguments = [name, url, options];
|
110 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
111 | | - },
|
112 | | -
|
113 | | - CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap"
|
114 | | -});
|
115 | | -
|
116 | | -/**
|
117 | | - * Class: OpenLayers.Layer.OSM.Maplint
|
118 | | - *
|
119 | | - * Inherits from:
|
120 | | - * - <OpenLayers.Layer.OSM>
|
121 | | - */
|
122 | | -OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
123 | | - /**
|
124 | | - * Constructor: OpenLayers.Layer.OSM.Maplint
|
125 | | - *
|
126 | | - * Parameters:
|
127 | | - * name - {String}
|
128 | | - * options - {Object} Hashtable of extra options to tag onto the layer
|
129 | | - */
|
130 | | - initialize: function(name, options) {
|
131 | | - var url = [
|
132 | | - "http://d.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
|
133 | | - "http://e.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png",
|
134 | | - "http://f.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png"
|
135 | | - ];
|
136 | | - options = OpenLayers.Util.extend({ numZoomLevels: 18, isBaseLayer: false, visibility: false }, options);
|
137 | | - var newArguments = [name, url, options];
|
138 | | - OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
139 | | - },
|
140 | | -
|
141 | | - CLASS_NAME: "OpenLayers.Layer.OSM.Maplint"
|
142 | | -});
|
| 2 | +/** |
| 3 | + * Namespace: Util.OSM |
| 4 | + */ |
| 5 | +OpenLayers.Util.OSM = {}; |
| 6 | + |
| 7 | +/** |
| 8 | + * Constant: MISSING_TILE_URL |
| 9 | + * {String} URL of image to display for missing tiles |
| 10 | + */ |
| 11 | +OpenLayers.Util.OSM.MISSING_TILE_URL = "http://openstreetmap.org/openlayers/img/404.png"; |
| 12 | + |
| 13 | +/** |
| 14 | + * Property: originalOnImageLoadError |
| 15 | + * {Function} Original onImageLoadError function. |
| 16 | + */ |
| 17 | +OpenLayers.Util.OSM.originalOnImageLoadError = OpenLayers.Util.onImageLoadError; |
| 18 | + |
| 19 | +/** |
| 20 | + * Function: onImageLoadError |
| 21 | + */ |
| 22 | +OpenLayers.Util.onImageLoadError = function() { |
| 23 | + if (this.src.match(/^http:\/\/[abc]\.[a-z]+\.openstreetmap\.org\//)) { |
| 24 | + this.src = OpenLayers.Util.OSM.MISSING_TILE_URL; |
| 25 | + } else if (this.src.match(/^http:\/\/[def]\.tah\.openstreetmap\.org\//)) { |
| 26 | + // do nothing - this layer is transparent |
| 27 | + } else { |
| 28 | + OpenLayers.Util.OSM.originalOnImageLoadError; |
| 29 | + } |
| 30 | +}; |
| 31 | + |
| 32 | +/** |
| 33 | + * Class: OpenLayers.Layer.OSM.Mapnik |
| 34 | + * |
| 35 | + * Inherits from: |
| 36 | + * - <OpenLayers.Layer.OSM> |
| 37 | + */ |
| 38 | +OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, { |
| 39 | + /** |
| 40 | + * Constructor: OpenLayers.Layer.OSM.Mapnik |
| 41 | + * |
| 42 | + * Parameters: |
| 43 | + * name - {String} |
| 44 | + * options - {Object} Hashtable of extra options to tag onto the layer |
| 45 | + */ |
| 46 | + initialize: function(name, options) { |
| 47 | + var url = [ |
| 48 | + "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png", |
| 49 | + "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png", |
| 50 | + "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png" |
| 51 | + ]; |
| 52 | + options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options); |
| 53 | + var newArguments = [name, url, options]; |
| 54 | + OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
| 55 | + }, |
| 56 | + |
| 57 | + CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik" |
| 58 | +}); |
| 59 | + |
| 60 | +/** |
| 61 | + * Class: OpenLayers.Layer.OSM.Osmarender |
| 62 | + * |
| 63 | + * Inherits from: |
| 64 | + * - <OpenLayers.Layer.OSM> |
| 65 | + */ |
| 66 | +OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, { |
| 67 | + /** |
| 68 | + * Constructor: OpenLayers.Layer.OSM.Osmarender |
| 69 | + * |
| 70 | + * Parameters: |
| 71 | + * name - {String} |
| 72 | + * options - {Object} Hashtable of extra options to tag onto the layer |
| 73 | + */ |
| 74 | + initialize: function(name, options) { |
| 75 | + var url = [ |
| 76 | + "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png", |
| 77 | + "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png", |
| 78 | + "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png" |
| 79 | + ]; |
| 80 | + options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options); |
| 81 | + var newArguments = [name, url, options]; |
| 82 | + OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
| 83 | + }, |
| 84 | + |
| 85 | + CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender" |
| 86 | +}); |
| 87 | + |
| 88 | +/** |
| 89 | + * Class: OpenLayers.Layer.OSM.CycleMap |
| 90 | + * |
| 91 | + * Inherits from: |
| 92 | + * - <OpenLayers.Layer.OSM> |
| 93 | + */ |
| 94 | +OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, { |
| 95 | + /** |
| 96 | + * Constructor: OpenLayers.Layer.OSM.CycleMap |
| 97 | + * |
| 98 | + * Parameters: |
| 99 | + * name - {String} |
| 100 | + * options - {Object} Hashtable of extra options to tag onto the layer |
| 101 | + */ |
| 102 | + initialize: function(name, options) { |
| 103 | + var url = [ |
| 104 | + "http://a.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png", |
| 105 | + "http://b.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png", |
| 106 | + "http://c.andy.sandbox.cloudmade.com/tiles/cycle/${z}/${x}/${y}.png" |
| 107 | + ]; |
| 108 | + options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options); |
| 109 | + var newArguments = [name, url, options]; |
| 110 | + OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
| 111 | + }, |
| 112 | + |
| 113 | + CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap" |
| 114 | +}); |
| 115 | + |
| 116 | +/** |
| 117 | + * Class: OpenLayers.Layer.OSM.Maplint |
| 118 | + * |
| 119 | + * Inherits from: |
| 120 | + * - <OpenLayers.Layer.OSM> |
| 121 | + */ |
| 122 | +OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, { |
| 123 | + /** |
| 124 | + * Constructor: OpenLayers.Layer.OSM.Maplint |
| 125 | + * |
| 126 | + * Parameters: |
| 127 | + * name - {String} |
| 128 | + * options - {Object} Hashtable of extra options to tag onto the layer |
| 129 | + */ |
| 130 | + initialize: function(name, options) { |
| 131 | + var url = [ |
| 132 | + "http://d.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png", |
| 133 | + "http://e.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png", |
| 134 | + "http://f.tah.openstreetmap.org/Tiles/maplint/${z}/${x}/${y}.png" |
| 135 | + ]; |
| 136 | + options = OpenLayers.Util.extend({ numZoomLevels: 18, isBaseLayer: false, visibility: false }, options); |
| 137 | + var newArguments = [name, url, options]; |
| 138 | + OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); |
| 139 | + }, |
| 140 | + |
| 141 | + CLASS_NAME: "OpenLayers.Layer.OSM.Maplint" |
| 142 | +}); |
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OSM/OpenStreetMap.js |
___________________________________________________________________ |
Added: svn:eol-style |
143 | 143 | + native |
Index: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSMDispPoint.php |
— | — | @@ -1,87 +1,87 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the MapsOSMDispPoint class.
|
6 | | - *
|
7 | | - * @file Maps_OSMDispPoint.php
|
8 | | - * @ingroup MapsOpenStreetMap
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -/**
|
18 | | - * Class for handling the display_point(s) parser functions with OSM.
|
19 | | - *
|
20 | | - * @author Jeroen De Dauw
|
21 | | - */
|
22 | | -class MapsOSMDispPoint extends MapsBasePointMap {
|
23 | | -
|
24 | | - public $serviceName = MapsOSM::SERVICE_NAME;
|
25 | | -
|
26 | | - /**
|
27 | | - * @see MapsBaseMap::setMapSettings()
|
28 | | - *
|
29 | | - */
|
30 | | - protected function setMapSettings() {
|
31 | | - global $egMapsOSMZoom, $egMapsOSMPrefix;
|
32 | | -
|
33 | | - $this->elementNamePrefix = $egMapsOSMPrefix;
|
34 | | - $this->defaultZoom = $egMapsOSMZoom;
|
35 | | -
|
36 | | - $this->markerStringFormat = 'getOSMMarkerData(lat, lon, \'title\', \'label\', "icon")';
|
37 | | - }
|
38 | | -
|
39 | | - /**
|
40 | | - * @see MapsBaseMap::doMapServiceLoad()
|
41 | | - *
|
42 | | - */
|
43 | | - protected function doMapServiceLoad() {
|
44 | | - global $egOSMMapsOnThisPage;
|
45 | | -
|
46 | | - MapsOSM::addOSMDependencies( $this->output );
|
47 | | - $egOSMMapsOnThisPage++;
|
48 | | -
|
49 | | - $this->elementNr = $egOSMMapsOnThisPage;
|
50 | | - }
|
51 | | -
|
52 | | - /**
|
53 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
54 | | - *
|
55 | | - */
|
56 | | - public function addSpecificMapHTML( Parser $parser ) {
|
57 | | - $parser->getOutput()->addHeadItem(
|
58 | | - Html::inlineScript( <<<EOT
|
59 | | -addOnloadHook(
|
60 | | - function() {
|
61 | | - slippymaps['$this->mapName'] = new slippymap_map(
|
62 | | - '$this->mapName',
|
63 | | - {
|
64 | | - layer: 'osm-like',
|
65 | | - locale: '$this->lang',
|
66 | | - lat: $this->centreLat,
|
67 | | - lon: $this->centreLon,
|
68 | | - zoom: $this->zoom,
|
69 | | - markers: [$this->markerString],
|
70 | | - controls: [$this->controls]
|
71 | | - }
|
72 | | - );
|
73 | | - slippymaps['$this->mapName'].init();
|
74 | | - }
|
75 | | -);
|
76 | | -EOT
|
77 | | - ) );
|
78 | | -
|
79 | | - $this->output .= Html::element(
|
80 | | - 'div',
|
81 | | - array(
|
82 | | - 'id' => $this->mapName,
|
83 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
84 | | - ),
|
85 | | - wfMsg('maps-loading-map')
|
86 | | - );
|
87 | | - }
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the MapsOSMDispPoint class. |
| 6 | + * |
| 7 | + * @file Maps_OSMDispPoint.php |
| 8 | + * @ingroup MapsOpenStreetMap |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Class for handling the display_point(s) parser functions with OSM. |
| 19 | + * |
| 20 | + * @author Jeroen De Dauw |
| 21 | + */ |
| 22 | +class MapsOSMDispPoint extends MapsBasePointMap { |
| 23 | + |
| 24 | + public $serviceName = MapsOSM::SERVICE_NAME; |
| 25 | + |
| 26 | + /** |
| 27 | + * @see MapsBaseMap::setMapSettings() |
| 28 | + * |
| 29 | + */ |
| 30 | + protected function setMapSettings() { |
| 31 | + global $egMapsOSMZoom, $egMapsOSMPrefix; |
| 32 | + |
| 33 | + $this->elementNamePrefix = $egMapsOSMPrefix; |
| 34 | + $this->defaultZoom = $egMapsOSMZoom; |
| 35 | + |
| 36 | + $this->markerStringFormat = 'getOSMMarkerData(lat, lon, \'title\', \'label\', "icon")'; |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @see MapsBaseMap::doMapServiceLoad() |
| 41 | + * |
| 42 | + */ |
| 43 | + protected function doMapServiceLoad() { |
| 44 | + global $egOSMMapsOnThisPage; |
| 45 | + |
| 46 | + MapsOSM::addOSMDependencies( $this->output ); |
| 47 | + $egOSMMapsOnThisPage++; |
| 48 | + |
| 49 | + $this->elementNr = $egOSMMapsOnThisPage; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 54 | + * |
| 55 | + */ |
| 56 | + public function addSpecificMapHTML( Parser $parser ) { |
| 57 | + $parser->getOutput()->addHeadItem( |
| 58 | + Html::inlineScript( <<<EOT |
| 59 | +addOnloadHook( |
| 60 | + function() { |
| 61 | + slippymaps['$this->mapName'] = new slippymap_map( |
| 62 | + '$this->mapName', |
| 63 | + { |
| 64 | + layer: 'osm-like', |
| 65 | + locale: '$this->lang', |
| 66 | + lat: $this->centreLat, |
| 67 | + lon: $this->centreLon, |
| 68 | + zoom: $this->zoom, |
| 69 | + markers: [$this->markerString], |
| 70 | + controls: [$this->controls] |
| 71 | + } |
| 72 | + ); |
| 73 | + slippymaps['$this->mapName'].init(); |
| 74 | + } |
| 75 | +); |
| 76 | +EOT |
| 77 | + ) ); |
| 78 | + |
| 79 | + $this->output .= Html::element( |
| 80 | + 'div', |
| 81 | + array( |
| 82 | + 'id' => $this->mapName, |
| 83 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 84 | + ), |
| 85 | + wfMsg('maps-loading-map') |
| 86 | + ); |
| 87 | + } |
88 | 88 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSMDispPoint.php |
___________________________________________________________________ |
Added: svn:eol-style |
89 | 89 | + native |
Index: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSMCgiBin.php |
— | — | @@ -1,180 +1,180 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * File holding the MapsOSMCgiBin class.
|
6 | | - *
|
7 | | - * @file Maps_OSMCgiBin.php
|
8 | | - * @ingroup MapsOpenStreetMap
|
9 | | - *
|
10 | | - * @author Ævar Arnfjörð Bjarmason
|
11 | | - * @author Jeroen De Dauw
|
12 | | - */
|
13 | | -
|
14 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
15 | | - die( 'Not an entry point.' );
|
16 | | -}
|
17 | | -
|
18 | | -/**
|
19 | | - * A class for static image requests.
|
20 | | - *
|
21 | | - * @author Ævar Arnfjörð Bjarmason
|
22 | | - * @author Jeroen De Dauw
|
23 | | - */
|
24 | | -
|
25 | | -final class MapsOSMCgiBin {
|
26 | | - private $lat;
|
27 | | - private $lon;
|
28 | | - private $zoom;
|
29 | | - private $width;
|
30 | | - private $height;
|
31 | | - private $url;
|
32 | | -
|
33 | | - /** borrowed from OpenLayers.DOTS_PER_UNIT */
|
34 | | - private static $INCHES_PER_UNIT = array (
|
35 | | - 'dd' => 4374754,
|
36 | | - 'm' => 39.3701
|
37 | | - );
|
38 | | -
|
39 | | - /** borrowed from OpenLayers.DOTS_PER_INCH */
|
40 | | - private static $DOTS_PER_INCH = 72;
|
41 | | -
|
42 | | - /** pixel size in meters */
|
43 | | - private static $PIXEL_SIZE = 0.00028;
|
44 | | -
|
45 | | - /**
|
46 | | - * Constructor
|
47 | | - */
|
48 | | - public function __construct( $lat, $lon, $zoom, $width, $height, $lang, $options ) {
|
49 | | - $this->lat = $lat;
|
50 | | - $this->lon = $lon;
|
51 | | - $this->zoom = $zoom;
|
52 | | - $this->width = $width;
|
53 | | - $this->height = $height;
|
54 | | - $this->lang = $lang;
|
55 | | - $this->options = $options;
|
56 | | -
|
57 | | - self::initResolutionsAndScales();
|
58 | | - self::setBounds();
|
59 | | - }
|
60 | | -
|
61 | | - /**
|
62 | | - * Returns the image url.
|
63 | | - *
|
64 | | - * @return string
|
65 | | - */
|
66 | | - public function getUrl() {
|
67 | | - $urlElements = array();
|
68 | | -
|
69 | | - $urlElements[] = $this->options['base_url'];
|
70 | | - $urlElements[] = '?bbox=';
|
71 | | - $urlElements[] = implode( ',', $this->bounds );
|
72 | | - $urlElements[] = '&scale=';
|
73 | | - $urlElements[] = $this->scale;
|
74 | | - $urlElements[] = '&format=';
|
75 | | - $urlElements[] = $this->options['format'];
|
76 | | - $urlElements[] = '&locale=';
|
77 | | - $urlElements[] = $this->lang;
|
78 | | -
|
79 | | - if ( array_key_exists( 'maptype', $this->options ) ) {
|
80 | | - $urlElements[] = '&maptype=';
|
81 | | - $urlElements[] = $this->options['maptype'];
|
82 | | - }
|
83 | | -
|
84 | | - return implode( '', $urlElements );
|
85 | | - }
|
86 | | -
|
87 | | - /**
|
88 | | - * This sets the map bounds
|
89 | | - */
|
90 | | - public function setBounds() {
|
91 | | -
|
92 | | - /* Determine scale and map bounds for static render request */
|
93 | | - $resolution = $this->resolutions[round( $this->zoom )];
|
94 | | - $this->scale = self::getScaleFromResolution( $resolution );
|
95 | | -
|
96 | | - /*
|
97 | | - * Calculate width for Mapnik output using a standard pixel size of 0.00028m
|
98 | | - * @see http://trac.mapnik.org/wiki/ScaleAndPpi
|
99 | | - */
|
100 | | - $w_deg = $this->width * self::$PIXEL_SIZE * $this->scale;
|
101 | | - $h_deg = $this->height * self::$PIXEL_SIZE * $this->scale;
|
102 | | -
|
103 | | - $center = array( $this->lon, $this->lat );
|
104 | | - if ( $this->options['sphericalMercator'] ) {
|
105 | | - // Calculate bounds within a spherical mercator projection if that is what the scale is based on.
|
106 | | - $mercatorCenter = self::forwardMercator( $center );
|
107 | | -
|
108 | | - $this->bounds = self::inverseMercator(
|
109 | | - array(
|
110 | | - $mercatorCenter[0] - $w_deg / 2,
|
111 | | - $mercatorCenter[1] - $h_deg / 2,
|
112 | | - $mercatorCenter[0] + $w_deg / 2,
|
113 | | - $mercatorCenter[1] + $h_deg / 2
|
114 | | - )
|
115 | | - );
|
116 | | - }
|
117 | | - else {
|
118 | | - // Calculate bounds within WGS84
|
119 | | - $this->bounds = array(
|
120 | | - $center[0] - $w_deg / 2,
|
121 | | - $center[1] - $h_deg / 2,
|
122 | | - $center[0] + $w_deg / 2,
|
123 | | - $center[1] + $h_deg / 2
|
124 | | - );
|
125 | | - }
|
126 | | - }
|
127 | | -
|
128 | | - /**
|
129 | | - * Borrowed from OpenLayers.Util.getScaleFromResolution
|
130 | | - */
|
131 | | - protected function getScaleFromResolution( $resolution ) {
|
132 | | - return $resolution * self::$INCHES_PER_UNIT[$this->options['unit']] * self::$DOTS_PER_INCH;
|
133 | | - }
|
134 | | -
|
135 | | - /**
|
136 | | - * Determines resolutions and scales based on a maximum resolution and number of zoom levels
|
137 | | - * Borrowed from OpenLayers.Layer.initResolutions
|
138 | | - */
|
139 | | - protected function initResolutionsAndScales() {
|
140 | | - $this->resolutions = array();
|
141 | | - $base = 2;
|
142 | | -
|
143 | | - for ( $i = 0; $i < $this->options['numZoomLevels']; $i++ ) {
|
144 | | - $this->resolutions[$i] = $this->options['maxResolution'] / pow( $base, $i );
|
145 | | - $this->scales[$i] = $this->getScaleFromResolution( $this->resolutions[$i] );
|
146 | | - }
|
147 | | - }
|
148 | | -
|
149 | | - /**
|
150 | | - * Convert from WGS84 to spherical mercator.
|
151 | | - */
|
152 | | - private static function forwardMercator( array $lonlat ) {
|
153 | | - for ( $i = 0; $i < count( $lonlat ); $i += 2 ) {
|
154 | | - /* lon */
|
155 | | - $lonlat[$i] = $lonlat[$i] * ( 2 * M_PI * 6378137 / 2.0 ) / 180.0;
|
156 | | -
|
157 | | - /* lat */
|
158 | | - $lonlat[$i + 1] = log( tan( ( 90 + $lonlat[$i + 1] ) * M_PI / 360.0 ) ) / ( M_PI / 180.0 );
|
159 | | - $lonlat[$i + 1] = $lonlat[$i + 1] * ( 2 * M_PI * 6378137 / 2.0 ) / 180.0;
|
160 | | - }
|
161 | | - return $lonlat;
|
162 | | - }
|
163 | | -
|
164 | | - /**
|
165 | | - * Convert from spherical mercator to WGS84.
|
166 | | - */
|
167 | | - private static function inverseMercator( array $lonlat ) {
|
168 | | - for ( $i = 0; $i < count( $lonlat ); $i += 2 ) {
|
169 | | - /* lon */
|
170 | | - $lonlat[$i] = $lonlat[$i] / ( ( 2 * M_PI * 6378137 / 2.0 ) / 180.0 );
|
171 | | -
|
172 | | - /* lat */
|
173 | | - $lonlat[$i + 1] = $lonlat[$i + 1] / ( ( 2 * M_PI * 6378137 / 2.0 ) / 180.0 );
|
174 | | - $lonlat[$i + 1] = 180.0 / M_PI * ( 2 * atan( exp( $lonlat[$i + 1] * M_PI / 180.0 ) ) - M_PI / 2 );
|
175 | | - }
|
176 | | -
|
177 | | - return $lonlat;
|
178 | | - }
|
179 | | -
|
180 | | -}
|
181 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the MapsOSMCgiBin class. |
| 6 | + * |
| 7 | + * @file Maps_OSMCgiBin.php |
| 8 | + * @ingroup MapsOpenStreetMap |
| 9 | + * |
| 10 | + * @author Ævar Arnfjörð Bjarmason |
| 11 | + * @author Jeroen De Dauw |
| 12 | + */ |
| 13 | + |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 15 | + die( 'Not an entry point.' ); |
| 16 | +} |
| 17 | + |
| 18 | +/** |
| 19 | + * A class for static image requests. |
| 20 | + * |
| 21 | + * @author Ævar Arnfjörð Bjarmason |
| 22 | + * @author Jeroen De Dauw |
| 23 | + */ |
| 24 | + |
| 25 | +final class MapsOSMCgiBin { |
| 26 | + private $lat; |
| 27 | + private $lon; |
| 28 | + private $zoom; |
| 29 | + private $width; |
| 30 | + private $height; |
| 31 | + private $url; |
| 32 | + |
| 33 | + /** borrowed from OpenLayers.DOTS_PER_UNIT */ |
| 34 | + private static $INCHES_PER_UNIT = array ( |
| 35 | + 'dd' => 4374754, |
| 36 | + 'm' => 39.3701 |
| 37 | + ); |
| 38 | + |
| 39 | + /** borrowed from OpenLayers.DOTS_PER_INCH */ |
| 40 | + private static $DOTS_PER_INCH = 72; |
| 41 | + |
| 42 | + /** pixel size in meters */ |
| 43 | + private static $PIXEL_SIZE = 0.00028; |
| 44 | + |
| 45 | + /** |
| 46 | + * Constructor |
| 47 | + */ |
| 48 | + public function __construct( $lat, $lon, $zoom, $width, $height, $lang, $options ) { |
| 49 | + $this->lat = $lat; |
| 50 | + $this->lon = $lon; |
| 51 | + $this->zoom = $zoom; |
| 52 | + $this->width = $width; |
| 53 | + $this->height = $height; |
| 54 | + $this->lang = $lang; |
| 55 | + $this->options = $options; |
| 56 | + |
| 57 | + self::initResolutionsAndScales(); |
| 58 | + self::setBounds(); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns the image url. |
| 63 | + * |
| 64 | + * @return string |
| 65 | + */ |
| 66 | + public function getUrl() { |
| 67 | + $urlElements = array(); |
| 68 | + |
| 69 | + $urlElements[] = $this->options['base_url']; |
| 70 | + $urlElements[] = '?bbox='; |
| 71 | + $urlElements[] = implode( ',', $this->bounds ); |
| 72 | + $urlElements[] = '&scale='; |
| 73 | + $urlElements[] = $this->scale; |
| 74 | + $urlElements[] = '&format='; |
| 75 | + $urlElements[] = $this->options['format']; |
| 76 | + $urlElements[] = '&locale='; |
| 77 | + $urlElements[] = $this->lang; |
| 78 | + |
| 79 | + if ( array_key_exists( 'maptype', $this->options ) ) { |
| 80 | + $urlElements[] = '&maptype='; |
| 81 | + $urlElements[] = $this->options['maptype']; |
| 82 | + } |
| 83 | + |
| 84 | + return implode( '', $urlElements ); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * This sets the map bounds |
| 89 | + */ |
| 90 | + public function setBounds() { |
| 91 | + |
| 92 | + /* Determine scale and map bounds for static render request */ |
| 93 | + $resolution = $this->resolutions[round( $this->zoom )]; |
| 94 | + $this->scale = self::getScaleFromResolution( $resolution ); |
| 95 | + |
| 96 | + /* |
| 97 | + * Calculate width for Mapnik output using a standard pixel size of 0.00028m |
| 98 | + * @see http://trac.mapnik.org/wiki/ScaleAndPpi |
| 99 | + */ |
| 100 | + $w_deg = $this->width * self::$PIXEL_SIZE * $this->scale; |
| 101 | + $h_deg = $this->height * self::$PIXEL_SIZE * $this->scale; |
| 102 | + |
| 103 | + $center = array( $this->lon, $this->lat ); |
| 104 | + if ( $this->options['sphericalMercator'] ) { |
| 105 | + // Calculate bounds within a spherical mercator projection if that is what the scale is based on. |
| 106 | + $mercatorCenter = self::forwardMercator( $center ); |
| 107 | + |
| 108 | + $this->bounds = self::inverseMercator( |
| 109 | + array( |
| 110 | + $mercatorCenter[0] - $w_deg / 2, |
| 111 | + $mercatorCenter[1] - $h_deg / 2, |
| 112 | + $mercatorCenter[0] + $w_deg / 2, |
| 113 | + $mercatorCenter[1] + $h_deg / 2 |
| 114 | + ) |
| 115 | + ); |
| 116 | + } |
| 117 | + else { |
| 118 | + // Calculate bounds within WGS84 |
| 119 | + $this->bounds = array( |
| 120 | + $center[0] - $w_deg / 2, |
| 121 | + $center[1] - $h_deg / 2, |
| 122 | + $center[0] + $w_deg / 2, |
| 123 | + $center[1] + $h_deg / 2 |
| 124 | + ); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Borrowed from OpenLayers.Util.getScaleFromResolution |
| 130 | + */ |
| 131 | + protected function getScaleFromResolution( $resolution ) { |
| 132 | + return $resolution * self::$INCHES_PER_UNIT[$this->options['unit']] * self::$DOTS_PER_INCH; |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Determines resolutions and scales based on a maximum resolution and number of zoom levels |
| 137 | + * Borrowed from OpenLayers.Layer.initResolutions |
| 138 | + */ |
| 139 | + protected function initResolutionsAndScales() { |
| 140 | + $this->resolutions = array(); |
| 141 | + $base = 2; |
| 142 | + |
| 143 | + for ( $i = 0; $i < $this->options['numZoomLevels']; $i++ ) { |
| 144 | + $this->resolutions[$i] = $this->options['maxResolution'] / pow( $base, $i ); |
| 145 | + $this->scales[$i] = $this->getScaleFromResolution( $this->resolutions[$i] ); |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + /** |
| 150 | + * Convert from WGS84 to spherical mercator. |
| 151 | + */ |
| 152 | + private static function forwardMercator( array $lonlat ) { |
| 153 | + for ( $i = 0; $i < count( $lonlat ); $i += 2 ) { |
| 154 | + /* lon */ |
| 155 | + $lonlat[$i] = $lonlat[$i] * ( 2 * M_PI * 6378137 / 2.0 ) / 180.0; |
| 156 | + |
| 157 | + /* lat */ |
| 158 | + $lonlat[$i + 1] = log( tan( ( 90 + $lonlat[$i + 1] ) * M_PI / 360.0 ) ) / ( M_PI / 180.0 ); |
| 159 | + $lonlat[$i + 1] = $lonlat[$i + 1] * ( 2 * M_PI * 6378137 / 2.0 ) / 180.0; |
| 160 | + } |
| 161 | + return $lonlat; |
| 162 | + } |
| 163 | + |
| 164 | + /** |
| 165 | + * Convert from spherical mercator to WGS84. |
| 166 | + */ |
| 167 | + private static function inverseMercator( array $lonlat ) { |
| 168 | + for ( $i = 0; $i < count( $lonlat ); $i += 2 ) { |
| 169 | + /* lon */ |
| 170 | + $lonlat[$i] = $lonlat[$i] / ( ( 2 * M_PI * 6378137 / 2.0 ) / 180.0 ); |
| 171 | + |
| 172 | + /* lat */ |
| 173 | + $lonlat[$i + 1] = $lonlat[$i + 1] / ( ( 2 * M_PI * 6378137 / 2.0 ) / 180.0 ); |
| 174 | + $lonlat[$i + 1] = 180.0 / M_PI * ( 2 * atan( exp( $lonlat[$i + 1] * M_PI / 180.0 ) ) - M_PI / 2 ); |
| 175 | + } |
| 176 | + |
| 177 | + return $lonlat; |
| 178 | + } |
| 179 | + |
| 180 | +} |
| 181 | + |
Property changes on: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSMCgiBin.php |
___________________________________________________________________ |
Added: svn:eol-style |
182 | 182 | + native |
Index: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSMDispMap.php |
— | — | @@ -1,166 +1,166 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * Class for handling the display_map parser function with OSM.
|
6 | | - *
|
7 | | - * @file Maps_OSMDispMap.php
|
8 | | - * @ingroup MapsOpenStreetMap
|
9 | | - *
|
10 | | - * @author Jeroen De Dauw
|
11 | | - */
|
12 | | -
|
13 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
14 | | - die( 'Not an entry point.' );
|
15 | | -}
|
16 | | -
|
17 | | -class MapsOSMDispMap extends MapsBaseMap {
|
18 | | -
|
19 | | - public $serviceName = MapsOSM::SERVICE_NAME;
|
20 | | -
|
21 | | - /**
|
22 | | - * @see MapsBaseMap::setMapSettings()
|
23 | | - *
|
24 | | - */
|
25 | | - protected function setMapSettings() {
|
26 | | - global $egMapsOSMZoom, $egMapsOSMPrefix, $egMapsOSMStaticAsDefault, $egMapsOSMStaticActivatable;
|
27 | | -
|
28 | | - $this->elementNamePrefix = $egMapsOSMPrefix;
|
29 | | - $this->defaultZoom = $egMapsOSMZoom;
|
30 | | -
|
31 | | - $modes = MapsOSM::getModeNames();
|
32 | | -
|
33 | | - $this->spesificParameters = array(
|
34 | | - 'static' => array(
|
35 | | - 'type' => 'boolean',
|
36 | | - 'default' => $egMapsOSMStaticAsDefault,
|
37 | | - 'output-type' => 'boolean'
|
38 | | - ),
|
39 | | - 'mode' => array(
|
40 | | - 'criteria' => array(
|
41 | | - 'in_array' => $modes
|
42 | | - ),
|
43 | | - 'default' => $modes[0]
|
44 | | - ),
|
45 | | - 'activatable' => array(
|
46 | | - 'type' => 'boolean',
|
47 | | - 'default' => $egMapsOSMStaticActivatable,
|
48 | | - 'output-type' => 'boolean'
|
49 | | - ),
|
50 | | - );
|
51 | | - }
|
52 | | -
|
53 | | - /**
|
54 | | - * @see MapsBaseMap::doMapServiceLoad()
|
55 | | - *
|
56 | | - */
|
57 | | - protected function doMapServiceLoad() {
|
58 | | - global $egOSMMapsOnThisPage;
|
59 | | -
|
60 | | - MapsOSM::addOSMDependencies( $this->output );
|
61 | | - $egOSMMapsOnThisPage++;
|
62 | | -
|
63 | | - $this->elementNr = $egOSMMapsOnThisPage;
|
64 | | - }
|
65 | | -
|
66 | | - /**
|
67 | | - * @see MapsBaseMap::addSpecificMapHTML()
|
68 | | - *
|
69 | | - */
|
70 | | - public function addSpecificMapHTML( Parser $parser ) {
|
71 | | - $parser->getOutput()->addHeadItem(
|
72 | | - Html::inlineScript( <<<EOT
|
73 | | -addOnloadHook(
|
74 | | - function() {
|
75 | | - slippymaps['$this->mapName'] = new slippymap_map(
|
76 | | - '$this->mapName',
|
77 | | - {
|
78 | | - mode: '$this->mode',
|
79 | | - layer: 'osm-like',
|
80 | | - locale: '$this->lang',
|
81 | | - lat: $this->centreLat,
|
82 | | - lon: $this->centreLon,
|
83 | | - zoom: $this->zoom,
|
84 | | - markers: [],
|
85 | | - controls: [$this->controls]
|
86 | | - }
|
87 | | - );
|
88 | | - }
|
89 | | -);
|
90 | | -EOT
|
91 | | - ) );
|
92 | | -
|
93 | | - $this->output .= $this->static ? $this->getStaticMap() : $this->getDynamicMap();
|
94 | | - }
|
95 | | -
|
96 | | - /**
|
97 | | - * Returns html for a dynamic map.
|
98 | | - *
|
99 | | - * @return string
|
100 | | - */
|
101 | | - private function getDynamicMap() {
|
102 | | - global $wgOut;
|
103 | | -
|
104 | | - $wgOut->addInlineScript( <<<EOT
|
105 | | -addOnloadHook(
|
106 | | - function() {
|
107 | | - slippymaps['$this->mapName'].init();
|
108 | | - }
|
109 | | -);
|
110 | | -EOT
|
111 | | - );
|
112 | | -
|
113 | | - return Html::element(
|
114 | | - 'div',
|
115 | | - array(
|
116 | | - 'id' => $this->mapName,
|
117 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
118 | | - ),
|
119 | | - wfMsg('maps-loading-map')
|
120 | | - );
|
121 | | - }
|
122 | | -
|
123 | | - /**
|
124 | | - * Returns html for a static map.
|
125 | | - *
|
126 | | - * @return string
|
127 | | - */
|
128 | | - private function getStaticMap() {
|
129 | | - $mode = MapsOSM::getModeData( $this->mode );
|
130 | | -
|
131 | | - $staticType = $mode['handler'];
|
132 | | - $staticOptions = $mode['options'];
|
133 | | -
|
134 | | - $static = new $staticType( $this->centreLat, $this->centreLon, $this->zoom, $this->width, $this->height, $this->lang, $staticOptions );
|
135 | | - $rendering_url = $static->getUrl();
|
136 | | -
|
137 | | - $alt = wfMsg( 'maps_centred_on', $this->centreLat, $this->centreLon );
|
138 | | - $title = $this->activatable ? wfMsg( 'maps_click_to_activate' ) : $alt;
|
139 | | -
|
140 | | - $image = array(
|
141 | | - 'class' => 'mapPreview',
|
142 | | - 'src' => $rendering_url,
|
143 | | - 'width' => $this->width,
|
144 | | - 'height' => $this->height,
|
145 | | - 'alt' => $alt,
|
146 | | - 'title' => $title,
|
147 | | - );
|
148 | | -
|
149 | | - if ( $this->activatable ) {
|
150 | | - $image['onclick'] = "slippymaps['$this->mapName'].init();";
|
151 | | - }
|
152 | | -
|
153 | | - return Html::element(
|
154 | | - 'div',
|
155 | | - array(
|
156 | | - 'id' => $this->mapName,
|
157 | | - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
|
158 | | - ),
|
159 | | - Html::element(
|
160 | | - 'img',
|
161 | | - $image
|
162 | | - )
|
163 | | - );
|
164 | | - }
|
165 | | -
|
166 | | -}
|
167 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class for handling the display_map parser function with OSM. |
| 6 | + * |
| 7 | + * @file Maps_OSMDispMap.php |
| 8 | + * @ingroup MapsOpenStreetMap |
| 9 | + * |
| 10 | + * @author Jeroen De Dauw |
| 11 | + */ |
| 12 | + |
| 13 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 14 | + die( 'Not an entry point.' ); |
| 15 | +} |
| 16 | + |
| 17 | +class MapsOSMDispMap extends MapsBaseMap { |
| 18 | + |
| 19 | + public $serviceName = MapsOSM::SERVICE_NAME; |
| 20 | + |
| 21 | + /** |
| 22 | + * @see MapsBaseMap::setMapSettings() |
| 23 | + * |
| 24 | + */ |
| 25 | + protected function setMapSettings() { |
| 26 | + global $egMapsOSMZoom, $egMapsOSMPrefix, $egMapsOSMStaticAsDefault, $egMapsOSMStaticActivatable; |
| 27 | + |
| 28 | + $this->elementNamePrefix = $egMapsOSMPrefix; |
| 29 | + $this->defaultZoom = $egMapsOSMZoom; |
| 30 | + |
| 31 | + $modes = MapsOSM::getModeNames(); |
| 32 | + |
| 33 | + $this->spesificParameters = array( |
| 34 | + 'static' => array( |
| 35 | + 'type' => 'boolean', |
| 36 | + 'default' => $egMapsOSMStaticAsDefault, |
| 37 | + 'output-type' => 'boolean' |
| 38 | + ), |
| 39 | + 'mode' => array( |
| 40 | + 'criteria' => array( |
| 41 | + 'in_array' => $modes |
| 42 | + ), |
| 43 | + 'default' => $modes[0] |
| 44 | + ), |
| 45 | + 'activatable' => array( |
| 46 | + 'type' => 'boolean', |
| 47 | + 'default' => $egMapsOSMStaticActivatable, |
| 48 | + 'output-type' => 'boolean' |
| 49 | + ), |
| 50 | + ); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @see MapsBaseMap::doMapServiceLoad() |
| 55 | + * |
| 56 | + */ |
| 57 | + protected function doMapServiceLoad() { |
| 58 | + global $egOSMMapsOnThisPage; |
| 59 | + |
| 60 | + MapsOSM::addOSMDependencies( $this->output ); |
| 61 | + $egOSMMapsOnThisPage++; |
| 62 | + |
| 63 | + $this->elementNr = $egOSMMapsOnThisPage; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @see MapsBaseMap::addSpecificMapHTML() |
| 68 | + * |
| 69 | + */ |
| 70 | + public function addSpecificMapHTML( Parser $parser ) { |
| 71 | + $parser->getOutput()->addHeadItem( |
| 72 | + Html::inlineScript( <<<EOT |
| 73 | +addOnloadHook( |
| 74 | + function() { |
| 75 | + slippymaps['$this->mapName'] = new slippymap_map( |
| 76 | + '$this->mapName', |
| 77 | + { |
| 78 | + mode: '$this->mode', |
| 79 | + layer: 'osm-like', |
| 80 | + locale: '$this->lang', |
| 81 | + lat: $this->centreLat, |
| 82 | + lon: $this->centreLon, |
| 83 | + zoom: $this->zoom, |
| 84 | + markers: [], |
| 85 | + controls: [$this->controls] |
| 86 | + } |
| 87 | + ); |
| 88 | + } |
| 89 | +); |
| 90 | +EOT |
| 91 | + ) ); |
| 92 | + |
| 93 | + $this->output .= $this->static ? $this->getStaticMap() : $this->getDynamicMap(); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Returns html for a dynamic map. |
| 98 | + * |
| 99 | + * @return string |
| 100 | + */ |
| 101 | + private function getDynamicMap() { |
| 102 | + global $wgOut; |
| 103 | + |
| 104 | + $wgOut->addInlineScript( <<<EOT |
| 105 | +addOnloadHook( |
| 106 | + function() { |
| 107 | + slippymaps['$this->mapName'].init(); |
| 108 | + } |
| 109 | +); |
| 110 | +EOT |
| 111 | + ); |
| 112 | + |
| 113 | + return Html::element( |
| 114 | + 'div', |
| 115 | + array( |
| 116 | + 'id' => $this->mapName, |
| 117 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 118 | + ), |
| 119 | + wfMsg('maps-loading-map') |
| 120 | + ); |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * Returns html for a static map. |
| 125 | + * |
| 126 | + * @return string |
| 127 | + */ |
| 128 | + private function getStaticMap() { |
| 129 | + $mode = MapsOSM::getModeData( $this->mode ); |
| 130 | + |
| 131 | + $staticType = $mode['handler']; |
| 132 | + $staticOptions = $mode['options']; |
| 133 | + |
| 134 | + $static = new $staticType( $this->centreLat, $this->centreLon, $this->zoom, $this->width, $this->height, $this->lang, $staticOptions ); |
| 135 | + $rendering_url = $static->getUrl(); |
| 136 | + |
| 137 | + $alt = wfMsg( 'maps_centred_on', $this->centreLat, $this->centreLon ); |
| 138 | + $title = $this->activatable ? wfMsg( 'maps_click_to_activate' ) : $alt; |
| 139 | + |
| 140 | + $image = array( |
| 141 | + 'class' => 'mapPreview', |
| 142 | + 'src' => $rendering_url, |
| 143 | + 'width' => $this->width, |
| 144 | + 'height' => $this->height, |
| 145 | + 'alt' => $alt, |
| 146 | + 'title' => $title, |
| 147 | + ); |
| 148 | + |
| 149 | + if ( $this->activatable ) { |
| 150 | + $image['onclick'] = "slippymaps['$this->mapName'].init();"; |
| 151 | + } |
| 152 | + |
| 153 | + return Html::element( |
| 154 | + 'div', |
| 155 | + array( |
| 156 | + 'id' => $this->mapName, |
| 157 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 158 | + ), |
| 159 | + Html::element( |
| 160 | + 'img', |
| 161 | + $image |
| 162 | + ) |
| 163 | + ); |
| 164 | + } |
| 165 | + |
| 166 | +} |
| 167 | + |
Property changes on: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSMDispMap.php |
___________________________________________________________________ |
Added: svn:eol-style |
168 | 168 | + native |
Index: trunk/extensions/Maps/Services/OpenStreetMap/OSMFunctions.js |
— | — | @@ -1,202 +1,202 @@ |
2 | | -/*
|
3 | | - * @file OSMFunctions.js
|
4 | | - * @ingroup MapsOpenStreetMap
|
5 | | - *
|
6 | | - * @author Harry Wood, Jens Frank, Grant Slater, Raymond Spekking, Jeroen De Dauw and others
|
7 | | - *
|
8 | | - * @description
|
9 | | - *
|
10 | | - * Javascript functions for OSM optimized Open Layers functionallity in Maps and it's extensions
|
11 | | - *
|
12 | | - * This defines what happens when <slippymap> tag is placed in the wikitext
|
13 | | - *
|
14 | | - * We show a map based on the lat/lon/zoom data passed in. This extension brings in
|
15 | | - * the OpenLayers javascript, to show a slippy map.
|
16 | | - *
|
17 | | - * Usage example:
|
18 | | - * <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender></slippymap>
|
19 | | - *
|
20 | | - * Tile images are not cached local to the wiki.
|
21 | | - * To acheive this (remove the OSM dependency) you might set up a squid proxy,
|
22 | | - * and modify the requests URLs here accordingly.
|
23 | | - *
|
24 | | - * This file should be placed in the mediawiki 'extensions' directory
|
25 | | - * ...and then it needs to be 'included' within LocalSettings.php
|
26 | | - *
|
27 | | - * This program is free software; you can redistribute it and/or modify
|
28 | | - * it under the terms of the GNU General Public License as published by
|
29 | | - * the Free Software Foundation; either version 2 of the License, or
|
30 | | - * (at your option) any later version.
|
31 | | - *
|
32 | | - * This program is distributed in the hope that it will be useful,
|
33 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
34 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
35 | | - * GNU General Public License for more details.
|
36 | | - *
|
37 | | - * You should have received a copy of the GNU General Public License
|
38 | | - * along with this program; if not, write to the Free Software
|
39 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
40 | | - *
|
41 | | - */
|
42 | | -
|
43 | | -var slippymaps = new Array();
|
44 | | -var mapId = 0;
|
45 | | -var layer = null;
|
46 | | -
|
47 | | -/**
|
48 | | - * Gets a valid control name (with excat lower and upper case letters),
|
49 | | - * or returns false when the control is not allowed.
|
50 | | - */
|
51 | | -function getValidControlName(control) {
|
52 | | - var OLControls = ['ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan',
|
53 | | - 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher',
|
54 | | - 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar',
|
55 | | - 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan',
|
56 | | - 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'Permalink',
|
57 | | - 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split',
|
58 | | - 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel',
|
59 | | - 'ZoomToMaxExtent'];
|
60 | | -
|
61 | | - for (i in OLControls) {
|
62 | | - if (control == OLControls[i].toLowerCase()) {
|
63 | | - return OLControls[i];
|
64 | | - }
|
65 | | - }
|
66 | | -
|
67 | | - return false;
|
68 | | -}
|
69 | | -
|
70 | | -function slippymap_map(mapId, mapParams) {
|
71 | | - var self = this;
|
72 | | - this.mapId = mapId;
|
73 | | -
|
74 | | - for (key in mapParams)
|
75 | | - this[key] = mapParams[key];
|
76 | | -
|
77 | | - // Add the controls
|
78 | | - this.mapOptions = {controls: []};
|
79 | | -
|
80 | | - for (i in this.controls) {
|
81 | | - if (typeof controls[i] == 'string') {
|
82 | | - if (this.controls[i].toLowerCase() == 'autopanzoom') {
|
83 | | - //if (this.height > 140) this.controls[i] = this.height > 320 ? 'panzoombar' : 'panzoom';
|
84 | | - }
|
85 | | -
|
86 | | - control = getValidControlName(this.controls[i]);
|
87 | | -
|
88 | | - if (control) {
|
89 | | - eval(' this.mapOptions.controls.push( new OpenLayers.Control.' + control + '() ); ');
|
90 | | - }
|
91 | | - }
|
92 | | - else {
|
93 | | - this.mapOptions.controls.push(controls[i]); // If a control is provided, instead a string, just add it.
|
94 | | - controls[i].activate(); // And activate it.
|
95 | | - }
|
96 | | - }
|
97 | | -}
|
98 | | -
|
99 | | -slippymap_map.prototype.init = function() {
|
100 | | - /* Swap out against the preview image */
|
101 | | - var previewImage = document.getElementById(this.mapId + '-preview');
|
102 | | - if (previewImage)
|
103 | | - previewImage.style.display = 'none';
|
104 | | -
|
105 | | - this.map = this.osm_create(this.mapId, this.lon, this.lat, this.zoom, this.initializedContols);
|
106 | | -
|
107 | | - var centerIsSet = this.lon != null && this.lat != null;
|
108 | | -
|
109 | | - var bounds = null;
|
110 | | -
|
111 | | - if (this.markers.length > 0) {
|
112 | | - var markerLayer = new OpenLayers.Layer.Markers('Markers');
|
113 | | - markerLayer.id= 'markerLayer';
|
114 | | - this.map.addLayer(markerLayer);
|
115 | | -
|
116 | | - if (this.markers.length > 1 && (!centerIsSet || this.zoom == null)) {
|
117 | | - bounds = new OpenLayers.Bounds();
|
118 | | - }
|
119 | | -
|
120 | | - for (i in this.markers) {
|
121 | | - this.markers[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
|
122 | | - if (bounds != null) bounds.extend(this.markers[i].lonlat); // Extend the bounds when no center is set
|
123 | | - markerLayer.addMarker(getOSMMarker(markerLayer, this.markers[i], this.map.getProjectionObject())); // Create and add the marker
|
124 | | - }
|
125 | | -
|
126 | | - }
|
127 | | -
|
128 | | - if (bounds != null) map.zoomToExtent(bounds); // If a bounds object has been created, use it to set the zoom and center
|
129 | | -
|
130 | | - if (centerIsSet) { // When the center is provided, set it
|
131 | | - var centre = new OpenLayers.LonLat(this.lon, this.lat);
|
132 | | - centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
|
133 | | - this.map.setCenter(centre);
|
134 | | - }
|
135 | | -
|
136 | | - if (this.zoom != null) this.map.zoomTo(this.zoom); // When the zoom is provided, set it
|
137 | | -}
|
138 | | -
|
139 | | -slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom, initializedContols) {
|
140 | | - var osmLayer;
|
141 | | - var map = new OpenLayers.Map(mapId, this.mapOptions /* all provided for by OSM.js */);
|
142 | | -
|
143 | | - if (initializedContols) {
|
144 | | - for (i in initializedContols) {
|
145 | | - map.addControl(initializedContols[i]);
|
146 | | - initializedContols[i].activate();
|
147 | | - }
|
148 | | - }
|
149 | | -
|
150 | | - if (this.layer == 'osm-like') {
|
151 | | - osmLayer = new OpenLayers.Layer.OSM("OpenStreetMap", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png');
|
152 | | - }
|
153 | | -
|
154 | | - map.addLayers([osmLayer]);
|
155 | | - map.setCenter(new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject()), zoom);
|
156 | | - return map;
|
157 | | -}
|
158 | | -
|
159 | | -function getOSMMarkerData(lon, lat, title, label, icon) {
|
160 | | - lonLat = new OpenLayers.LonLat(lon, lat);
|
161 | | - return {
|
162 | | - lonlat: lonLat,
|
163 | | - title: title,
|
164 | | - label: label,
|
165 | | - icon: icon
|
166 | | - };
|
167 | | -}
|
168 | | -
|
169 | | -
|
170 | | -function getOSMMarker(markerLayer, markerData, projectionObject) {
|
171 | | - var marker;
|
172 | | -
|
173 | | - if (markerData.icon != '') {
|
174 | | - marker = new OpenLayers.Marker(markerData.lonlat, new OpenLayers.Icon(markerData.icon));
|
175 | | - } else {
|
176 | | - marker = new OpenLayers.Marker(markerData.lonlat);
|
177 | | - }
|
178 | | -
|
179 | | - if (markerData.title.length + markerData.label.length > 0 ) {
|
180 | | -
|
181 | | - // This is the handler for the mousedown event on the marker, and displays the popup
|
182 | | - marker.events.register('mousedown', marker,
|
183 | | - function(evt) {
|
184 | | - var popup = new OpenLayers.Feature(markerLayer, markerData.lonlat).createPopup(true);
|
185 | | -
|
186 | | - if (markerData.title.length > 0 && markerData.label.length > 0) { // Add the title and label to the popup text
|
187 | | - popup.setContentHTML('<b>' + markerData.title + "</b><hr />" + markerData.label);
|
188 | | - }
|
189 | | - else {
|
190 | | - popup.setContentHTML(markerData.title + markerData.label);
|
191 | | - }
|
192 | | -
|
193 | | - popup.setOpacity(0.85);
|
194 | | - markerLayer.map.addPopup(popup);
|
195 | | - OpenLayers.Event.stop(evt); // Stop the event
|
196 | | - }
|
197 | | - );
|
198 | | -
|
199 | | - }
|
200 | | -
|
201 | | - return marker;
|
202 | | -}
|
203 | | -
|
| 2 | +/* |
| 3 | + * @file OSMFunctions.js |
| 4 | + * @ingroup MapsOpenStreetMap |
| 5 | + * |
| 6 | + * @author Harry Wood, Jens Frank, Grant Slater, Raymond Spekking, Jeroen De Dauw and others |
| 7 | + * |
| 8 | + * @description |
| 9 | + * |
| 10 | + * Javascript functions for OSM optimized Open Layers functionallity in Maps and it's extensions |
| 11 | + * |
| 12 | + * This defines what happens when <slippymap> tag is placed in the wikitext |
| 13 | + * |
| 14 | + * We show a map based on the lat/lon/zoom data passed in. This extension brings in |
| 15 | + * the OpenLayers javascript, to show a slippy map. |
| 16 | + * |
| 17 | + * Usage example: |
| 18 | + * <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender></slippymap> |
| 19 | + * |
| 20 | + * Tile images are not cached local to the wiki. |
| 21 | + * To acheive this (remove the OSM dependency) you might set up a squid proxy, |
| 22 | + * and modify the requests URLs here accordingly. |
| 23 | + * |
| 24 | + * This file should be placed in the mediawiki 'extensions' directory |
| 25 | + * ...and then it needs to be 'included' within LocalSettings.php |
| 26 | + * |
| 27 | + * This program is free software; you can redistribute it and/or modify |
| 28 | + * it under the terms of the GNU General Public License as published by |
| 29 | + * the Free Software Foundation; either version 2 of the License, or |
| 30 | + * (at your option) any later version. |
| 31 | + * |
| 32 | + * This program is distributed in the hope that it will be useful, |
| 33 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 34 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 35 | + * GNU General Public License for more details. |
| 36 | + * |
| 37 | + * You should have received a copy of the GNU General Public License |
| 38 | + * along with this program; if not, write to the Free Software |
| 39 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 40 | + * |
| 41 | + */ |
| 42 | + |
| 43 | +var slippymaps = new Array(); |
| 44 | +var mapId = 0; |
| 45 | +var layer = null; |
| 46 | + |
| 47 | +/** |
| 48 | + * Gets a valid control name (with excat lower and upper case letters), |
| 49 | + * or returns false when the control is not allowed. |
| 50 | + */ |
| 51 | +function getValidControlName(control) { |
| 52 | + var OLControls = ['ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan', |
| 53 | + 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher', |
| 54 | + 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar', |
| 55 | + 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan', |
| 56 | + 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'Permalink', |
| 57 | + 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split', |
| 58 | + 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel', |
| 59 | + 'ZoomToMaxExtent']; |
| 60 | + |
| 61 | + for (i in OLControls) { |
| 62 | + if (control == OLControls[i].toLowerCase()) { |
| 63 | + return OLControls[i]; |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + return false; |
| 68 | +} |
| 69 | + |
| 70 | +function slippymap_map(mapId, mapParams) { |
| 71 | + var self = this; |
| 72 | + this.mapId = mapId; |
| 73 | + |
| 74 | + for (key in mapParams) |
| 75 | + this[key] = mapParams[key]; |
| 76 | + |
| 77 | + // Add the controls |
| 78 | + this.mapOptions = {controls: []}; |
| 79 | + |
| 80 | + for (i in this.controls) { |
| 81 | + if (typeof controls[i] == 'string') { |
| 82 | + if (this.controls[i].toLowerCase() == 'autopanzoom') { |
| 83 | + //if (this.height > 140) this.controls[i] = this.height > 320 ? 'panzoombar' : 'panzoom'; |
| 84 | + } |
| 85 | + |
| 86 | + control = getValidControlName(this.controls[i]); |
| 87 | + |
| 88 | + if (control) { |
| 89 | + eval(' this.mapOptions.controls.push( new OpenLayers.Control.' + control + '() ); '); |
| 90 | + } |
| 91 | + } |
| 92 | + else { |
| 93 | + this.mapOptions.controls.push(controls[i]); // If a control is provided, instead a string, just add it. |
| 94 | + controls[i].activate(); // And activate it. |
| 95 | + } |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +slippymap_map.prototype.init = function() { |
| 100 | + /* Swap out against the preview image */ |
| 101 | + var previewImage = document.getElementById(this.mapId + '-preview'); |
| 102 | + if (previewImage) |
| 103 | + previewImage.style.display = 'none'; |
| 104 | + |
| 105 | + this.map = this.osm_create(this.mapId, this.lon, this.lat, this.zoom, this.initializedContols); |
| 106 | + |
| 107 | + var centerIsSet = this.lon != null && this.lat != null; |
| 108 | + |
| 109 | + var bounds = null; |
| 110 | + |
| 111 | + if (this.markers.length > 0) { |
| 112 | + var markerLayer = new OpenLayers.Layer.Markers('Markers'); |
| 113 | + markerLayer.id= 'markerLayer'; |
| 114 | + this.map.addLayer(markerLayer); |
| 115 | + |
| 116 | + if (this.markers.length > 1 && (!centerIsSet || this.zoom == null)) { |
| 117 | + bounds = new OpenLayers.Bounds(); |
| 118 | + } |
| 119 | + |
| 120 | + for (i in this.markers) { |
| 121 | + this.markers[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 122 | + if (bounds != null) bounds.extend(this.markers[i].lonlat); // Extend the bounds when no center is set |
| 123 | + markerLayer.addMarker(getOSMMarker(markerLayer, this.markers[i], this.map.getProjectionObject())); // Create and add the marker |
| 124 | + } |
| 125 | + |
| 126 | + } |
| 127 | + |
| 128 | + if (bounds != null) map.zoomToExtent(bounds); // If a bounds object has been created, use it to set the zoom and center |
| 129 | + |
| 130 | + if (centerIsSet) { // When the center is provided, set it |
| 131 | + var centre = new OpenLayers.LonLat(this.lon, this.lat); |
| 132 | + centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
| 133 | + this.map.setCenter(centre); |
| 134 | + } |
| 135 | + |
| 136 | + if (this.zoom != null) this.map.zoomTo(this.zoom); // When the zoom is provided, set it |
| 137 | +} |
| 138 | + |
| 139 | +slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom, initializedContols) { |
| 140 | + var osmLayer; |
| 141 | + var map = new OpenLayers.Map(mapId, this.mapOptions /* all provided for by OSM.js */); |
| 142 | + |
| 143 | + if (initializedContols) { |
| 144 | + for (i in initializedContols) { |
| 145 | + map.addControl(initializedContols[i]); |
| 146 | + initializedContols[i].activate(); |
| 147 | + } |
| 148 | + } |
| 149 | + |
| 150 | + if (this.layer == 'osm-like') { |
| 151 | + osmLayer = new OpenLayers.Layer.OSM("OpenStreetMap", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png'); |
| 152 | + } |
| 153 | + |
| 154 | + map.addLayers([osmLayer]); |
| 155 | + map.setCenter(new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject()), zoom); |
| 156 | + return map; |
| 157 | +} |
| 158 | + |
| 159 | +function getOSMMarkerData(lon, lat, title, label, icon) { |
| 160 | + lonLat = new OpenLayers.LonLat(lon, lat); |
| 161 | + return { |
| 162 | + lonlat: lonLat, |
| 163 | + title: title, |
| 164 | + label: label, |
| 165 | + icon: icon |
| 166 | + }; |
| 167 | +} |
| 168 | + |
| 169 | + |
| 170 | +function getOSMMarker(markerLayer, markerData, projectionObject) { |
| 171 | + var marker; |
| 172 | + |
| 173 | + if (markerData.icon != '') { |
| 174 | + marker = new OpenLayers.Marker(markerData.lonlat, new OpenLayers.Icon(markerData.icon)); |
| 175 | + } else { |
| 176 | + marker = new OpenLayers.Marker(markerData.lonlat); |
| 177 | + } |
| 178 | + |
| 179 | + if (markerData.title.length + markerData.label.length > 0 ) { |
| 180 | + |
| 181 | + // This is the handler for the mousedown event on the marker, and displays the popup |
| 182 | + marker.events.register('mousedown', marker, |
| 183 | + function(evt) { |
| 184 | + var popup = new OpenLayers.Feature(markerLayer, markerData.lonlat).createPopup(true); |
| 185 | + |
| 186 | + if (markerData.title.length > 0 && markerData.label.length > 0) { // Add the title and label to the popup text |
| 187 | + popup.setContentHTML('<b>' + markerData.title + "</b><hr />" + markerData.label); |
| 188 | + } |
| 189 | + else { |
| 190 | + popup.setContentHTML(markerData.title + markerData.label); |
| 191 | + } |
| 192 | + |
| 193 | + popup.setOpacity(0.85); |
| 194 | + markerLayer.map.addPopup(popup); |
| 195 | + OpenLayers.Event.stop(evt); // Stop the event |
| 196 | + } |
| 197 | + ); |
| 198 | + |
| 199 | + } |
| 200 | + |
| 201 | + return marker; |
| 202 | +} |
| 203 | + |
Property changes on: trunk/extensions/Maps/Services/OpenStreetMap/OSMFunctions.js |
___________________________________________________________________ |
Added: svn:eol-style |
204 | 204 | + native |
Index: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSM.php |
— | — | @@ -1,166 +1,166 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -/**
|
5 | | - * This groupe contains all OpenStreetMap related files of the Maps extension.
|
6 | | - *
|
7 | | - * @defgroup MapsOpenStreetMap OpenStreetMap
|
8 | | - * @ingroup Maps
|
9 | | - */
|
10 | | -
|
11 | | -/**
|
12 | | - * This file holds the general information for the OSM optimized OpenLayers service
|
13 | | - *
|
14 | | - * @file Maps_OSM.php
|
15 | | - * @ingroup MapsOpenStreetMap
|
16 | | - *
|
17 | | - * @author Jeroen De Dauw
|
18 | | - *
|
19 | | - * FIXME: this file has not been changed to work with 0.6
|
20 | | - */
|
21 | | -
|
22 | | -if ( !defined( 'MEDIAWIKI' ) ) {
|
23 | | - die( 'Not an entry point.' );
|
24 | | -}
|
25 | | -
|
26 | | -$egMapsServices['osm'] = array(
|
27 | | - 'pf' => array(
|
28 | | - 'display_point' => array( 'class' => 'MapsOSMDispPoint', 'file' => 'OpenStreetMap/Maps_OSMDispPoint.php', 'local' => true ),
|
29 | | - 'display_map' => array( 'class' => 'MapsOSMDispMap', 'file' => 'OpenStreetMap/Maps_OSMDispMap.php', 'local' => true ),
|
30 | | - ),
|
31 | | - 'classes' => array(
|
32 | | - array( 'class' => 'MapsOSM', 'file' => 'OpenStreetMap/Maps_OSM.php', 'local' => true ),
|
33 | | - array( 'class' => 'MapsOSMCgiBin', 'file' => 'OpenStreetMap/Maps_OSMCgiBin.php', 'local' => true ),
|
34 | | - ),
|
35 | | - 'aliases' => array( 'openstreetmap', 'openstreetmaps' ),
|
36 | | - );
|
37 | | -
|
38 | | -/**
|
39 | | - * Class for OpenStreetMap initialization.
|
40 | | - *
|
41 | | - * @ingroup MapsOpenStreetMap
|
42 | | - *
|
43 | | - * @author Jeroen De Dauw
|
44 | | - */
|
45 | | -class MapsOSM {
|
46 | | -
|
47 | | - const SERVICE_NAME = 'osm';
|
48 | | -
|
49 | | - public static function initialize() {
|
50 | | - self::initializeParams();
|
51 | | - }
|
52 | | -
|
53 | | - private static function initializeParams() {
|
54 | | - global $wgLang;
|
55 | | - global $egMapsServices, $egMapsOSMZoom, $egMapsOSMControls;
|
56 | | -
|
57 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] = $egMapsOSMZoom;
|
58 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 );
|
59 | | -
|
60 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
|
61 | | - 'controls' => array(
|
62 | | - 'type' => array( 'string', 'list' ),
|
63 | | - 'criteria' => array(
|
64 | | - 'in_array' => self::getControlNames()
|
65 | | - ),
|
66 | | - 'default' => $egMapsOSMControls,
|
67 | | - 'output-type' => array( 'list', ',', '\'' )
|
68 | | - ),
|
69 | | - 'lang' => array(
|
70 | | - 'aliases' => array( 'locale', 'language' ),
|
71 | | - 'criteria' => array(
|
72 | | - 'in_array' => array_keys( Language::getLanguageNames( false ) )
|
73 | | - ),
|
74 | | - 'default' => $wgLang->getCode()
|
75 | | - ),
|
76 | | - );
|
77 | | - }
|
78 | | -
|
79 | | - /**
|
80 | | - * Returns the names of all supported controls.
|
81 | | - * This data is a copy of the one used to actually translate the names
|
82 | | - * into the controls, since this resides client side, in OSMFunctions.js.
|
83 | | - *
|
84 | | - * @return array
|
85 | | - */
|
86 | | - public static function getControlNames() {
|
87 | | - return array(
|
88 | | - 'ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan',
|
89 | | - 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher',
|
90 | | - 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar',
|
91 | | - 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan',
|
92 | | - 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'AutoPanZoom', 'Permalink',
|
93 | | - 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split',
|
94 | | - 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel',
|
95 | | - 'ZoomToMaxExtent'
|
96 | | - );
|
97 | | - }
|
98 | | -
|
99 | | - private static $modes = array(
|
100 | | - 'osm-wm' => array(
|
101 | | - 'handler' => 'MapsOSMCgiBin',
|
102 | | - 'options' => array(
|
103 | | - 'base_url' => 'http://cassini.toolserver.org/cgi-bin/export',
|
104 | | -
|
105 | | - 'format' => 'png',
|
106 | | - 'numZoomLevels' => 16,
|
107 | | - 'maxResolution' => 156543.0339,
|
108 | | - 'unit' => 'm',
|
109 | | - 'sphericalMercator' => true,
|
110 | | -
|
111 | | - 'maptype' => 'osm-like'
|
112 | | - ),
|
113 | | - ),
|
114 | | -
|
115 | | - 'osm' => array(
|
116 | | - 'handler' => 'MapsOSMCgiBin',
|
117 | | - 'options' => array(
|
118 | | - 'base_url' => 'http://tile.openstreetmap.org/cgi-bin/export',
|
119 | | -
|
120 | | - 'format' => 'png',
|
121 | | - 'numZoomLevels' => 16,
|
122 | | - 'maxResolution' => 156543.0339,
|
123 | | - 'unit' => 'm',
|
124 | | - 'sphericalMercator' => true
|
125 | | - ),
|
126 | | - ),
|
127 | | - );
|
128 | | -
|
129 | | - /**
|
130 | | - * Returns an array containing the names of all modes.
|
131 | | - *
|
132 | | - * @return array
|
133 | | - */
|
134 | | - public static function getModeNames() {
|
135 | | - return array_keys( self::$modes );
|
136 | | - }
|
137 | | -
|
138 | | - /**
|
139 | | - * Returns the data of a mode.
|
140 | | - *
|
141 | | - * @param string $modeName
|
142 | | - * @return array
|
143 | | - */
|
144 | | - public static function getModeData( $modeName ) {
|
145 | | - return self::$modes[$modeName];
|
146 | | - }
|
147 | | -
|
148 | | - /**
|
149 | | - * If this is the first OSM map on the page, load the OpenLayers API, OSM styles and extra JS functions
|
150 | | - *
|
151 | | - * @param string $output
|
152 | | - */
|
153 | | - public static function addOSMDependencies( &$output ) {
|
154 | | - global $wgJsMimeType;
|
155 | | - global $egOSMMapsOnThisPage, $egMapsScriptPath, $egMapsStyleVersion, $egMapsJsExt;
|
156 | | -
|
157 | | - if ( empty( $egOSMMapsOnThisPage ) ) {
|
158 | | - $egOSMMapsOnThisPage = 0;
|
159 | | -
|
160 | | - $output .= "<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
|
161 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>
|
162 | | - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMap/OSMFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>
|
163 | | - <script type='$wgJsMimeType'>slippymaps = Array();</script>\n";
|
164 | | - }
|
165 | | - }
|
166 | | -
|
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This groupe contains all OpenStreetMap related files of the Maps extension. |
| 6 | + * |
| 7 | + * @defgroup MapsOpenStreetMap OpenStreetMap |
| 8 | + * @ingroup Maps |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This file holds the general information for the OSM optimized OpenLayers service |
| 13 | + * |
| 14 | + * @file Maps_OSM.php |
| 15 | + * @ingroup MapsOpenStreetMap |
| 16 | + * |
| 17 | + * @author Jeroen De Dauw |
| 18 | + * |
| 19 | + * FIXME: this file has not been changed to work with 0.6 |
| 20 | + */ |
| 21 | + |
| 22 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 23 | + die( 'Not an entry point.' ); |
| 24 | +} |
| 25 | + |
| 26 | +$egMapsServices['osm'] = array( |
| 27 | + 'pf' => array( |
| 28 | + 'display_point' => array( 'class' => 'MapsOSMDispPoint', 'file' => 'OpenStreetMap/Maps_OSMDispPoint.php', 'local' => true ), |
| 29 | + 'display_map' => array( 'class' => 'MapsOSMDispMap', 'file' => 'OpenStreetMap/Maps_OSMDispMap.php', 'local' => true ), |
| 30 | + ), |
| 31 | + 'classes' => array( |
| 32 | + array( 'class' => 'MapsOSM', 'file' => 'OpenStreetMap/Maps_OSM.php', 'local' => true ), |
| 33 | + array( 'class' => 'MapsOSMCgiBin', 'file' => 'OpenStreetMap/Maps_OSMCgiBin.php', 'local' => true ), |
| 34 | + ), |
| 35 | + 'aliases' => array( 'openstreetmap', 'openstreetmaps' ), |
| 36 | + ); |
| 37 | + |
| 38 | +/** |
| 39 | + * Class for OpenStreetMap initialization. |
| 40 | + * |
| 41 | + * @ingroup MapsOpenStreetMap |
| 42 | + * |
| 43 | + * @author Jeroen De Dauw |
| 44 | + */ |
| 45 | +class MapsOSM { |
| 46 | + |
| 47 | + const SERVICE_NAME = 'osm'; |
| 48 | + |
| 49 | + public static function initialize() { |
| 50 | + self::initializeParams(); |
| 51 | + } |
| 52 | + |
| 53 | + private static function initializeParams() { |
| 54 | + global $wgLang; |
| 55 | + global $egMapsServices, $egMapsOSMZoom, $egMapsOSMControls; |
| 56 | + |
| 57 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] = $egMapsOSMZoom; |
| 58 | + $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 ); |
| 59 | + |
| 60 | + $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 61 | + 'controls' => array( |
| 62 | + 'type' => array( 'string', 'list' ), |
| 63 | + 'criteria' => array( |
| 64 | + 'in_array' => self::getControlNames() |
| 65 | + ), |
| 66 | + 'default' => $egMapsOSMControls, |
| 67 | + 'output-type' => array( 'list', ',', '\'' ) |
| 68 | + ), |
| 69 | + 'lang' => array( |
| 70 | + 'aliases' => array( 'locale', 'language' ), |
| 71 | + 'criteria' => array( |
| 72 | + 'in_array' => array_keys( Language::getLanguageNames( false ) ) |
| 73 | + ), |
| 74 | + 'default' => $wgLang->getCode() |
| 75 | + ), |
| 76 | + ); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Returns the names of all supported controls. |
| 81 | + * This data is a copy of the one used to actually translate the names |
| 82 | + * into the controls, since this resides client side, in OSMFunctions.js. |
| 83 | + * |
| 84 | + * @return array |
| 85 | + */ |
| 86 | + public static function getControlNames() { |
| 87 | + return array( |
| 88 | + 'ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan', |
| 89 | + 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher', |
| 90 | + 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar', |
| 91 | + 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan', |
| 92 | + 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'AutoPanZoom', 'Permalink', |
| 93 | + 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split', |
| 94 | + 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel', |
| 95 | + 'ZoomToMaxExtent' |
| 96 | + ); |
| 97 | + } |
| 98 | + |
| 99 | + private static $modes = array( |
| 100 | + 'osm-wm' => array( |
| 101 | + 'handler' => 'MapsOSMCgiBin', |
| 102 | + 'options' => array( |
| 103 | + 'base_url' => 'http://cassini.toolserver.org/cgi-bin/export', |
| 104 | + |
| 105 | + 'format' => 'png', |
| 106 | + 'numZoomLevels' => 16, |
| 107 | + 'maxResolution' => 156543.0339, |
| 108 | + 'unit' => 'm', |
| 109 | + 'sphericalMercator' => true, |
| 110 | + |
| 111 | + 'maptype' => 'osm-like' |
| 112 | + ), |
| 113 | + ), |
| 114 | + |
| 115 | + 'osm' => array( |
| 116 | + 'handler' => 'MapsOSMCgiBin', |
| 117 | + 'options' => array( |
| 118 | + 'base_url' => 'http://tile.openstreetmap.org/cgi-bin/export', |
| 119 | + |
| 120 | + 'format' => 'png', |
| 121 | + 'numZoomLevels' => 16, |
| 122 | + 'maxResolution' => 156543.0339, |
| 123 | + 'unit' => 'm', |
| 124 | + 'sphericalMercator' => true |
| 125 | + ), |
| 126 | + ), |
| 127 | + ); |
| 128 | + |
| 129 | + /** |
| 130 | + * Returns an array containing the names of all modes. |
| 131 | + * |
| 132 | + * @return array |
| 133 | + */ |
| 134 | + public static function getModeNames() { |
| 135 | + return array_keys( self::$modes ); |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * Returns the data of a mode. |
| 140 | + * |
| 141 | + * @param string $modeName |
| 142 | + * @return array |
| 143 | + */ |
| 144 | + public static function getModeData( $modeName ) { |
| 145 | + return self::$modes[$modeName]; |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * If this is the first OSM map on the page, load the OpenLayers API, OSM styles and extra JS functions |
| 150 | + * |
| 151 | + * @param string $output |
| 152 | + */ |
| 153 | + public static function addOSMDependencies( &$output ) { |
| 154 | + global $wgJsMimeType; |
| 155 | + global $egOSMMapsOnThisPage, $egMapsScriptPath, $egMapsStyleVersion, $egMapsJsExt; |
| 156 | + |
| 157 | + if ( empty( $egOSMMapsOnThisPage ) ) { |
| 158 | + $egOSMMapsOnThisPage = 0; |
| 159 | + |
| 160 | + $output .= "<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' /> |
| 161 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script> |
| 162 | + <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMap/OSMFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script> |
| 163 | + <script type='$wgJsMimeType'>slippymaps = Array();</script>\n"; |
| 164 | + } |
| 165 | + } |
| 166 | + |
167 | 167 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/OpenStreetMap/Maps_OSM.php |
___________________________________________________________________ |
Added: svn:eol-style |
168 | 168 | + native |
Index: trunk/extensions/Maps/Services/OpenStreetMap/OSMFunctions.min.js |
— | — | @@ -1,21 +1,21 @@ |
2 | | -var slippymaps=new Array();var mapId=0;var layer=null;if(false){addOnloadHook(slippymap_init);}
|
3 | | -function slippymap_init(){for(keyName in slippymaps){slippymaps[keyName].init();}}
|
4 | | -function getValidControlName(control){var OLControls=['ArgParser','Attribution','Button','DragFeature','DragPan','DrawFeature','EditingToolbar','GetFeature','KeyboardDefaults','LayerSwitcher','Measure','ModifyFeature','MouseDefaults','MousePosition','MouseToolbar','Navigation','NavigationHistory','NavToolbar','OverviewMap','Pan','Panel','PanPanel','PanZoom','PanZoomBar','Permalink','Scale','ScaleLine','SelectFeature','Snapping','Split','WMSGetFeatureInfo','ZoomBox','ZoomIn','ZoomOut','ZoomPanel','ZoomToMaxExtent'];for(i in OLControls){if(control==OLControls[i].toLowerCase()){return OLControls[i];}}
|
5 | | -return false;}
|
6 | | -function slippymap_map(mapId,mapParams){var self=this;this.mapId=mapId;for(key in mapParams)
|
7 | | -this[key]=mapParams[key];this.mapOptions={controls:[]};for(i in this.controls){if(this.controls[i].toLowerCase()=='autopanzoom'){if(this.height>140)this.controls[i]=this.height>320?'panzoombar':'panzoom';}
|
8 | | -control=getValidControlName(this.controls[i]);if(control){eval(' this.mapOptions.controls.push( new OpenLayers.Control.'+control+'() ); ');}}}
|
9 | | -slippymap_map.prototype.init=function(){var previewImage=document.getElementById(this.mapId+'-preview');if(previewImage)
|
10 | | -previewImage.style.display='none';this.map=this.osm_create(this.mapId,this.lon,this.lat,this.zoom,this.initializedContols);var centerIsSet=this.lon!=null&&this.lat!=null;var bounds=null;if(this.markers.length>0){var markerLayer=new OpenLayers.Layer.Markers('Markers');markerLayer.id='markerLayer';this.map.addLayer(markerLayer);if(this.markers.length>1&&(!centerIsSet||this.zoom==null)){bounds=new OpenLayers.Bounds();}
|
11 | | -for(i in this.markers){this.markers[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));if(bounds!=null)bounds.extend(this.markers[i].lonlat);markerLayer.addMarker(getOSMMarker(markerLayer,this.markers[i],this.map.getProjectionObject()));}}
|
12 | | -if(bounds!=null)map.zoomToExtent(bounds);if(centerIsSet){var centre=new OpenLayers.LonLat(this.lon,this.lat);centre.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));this.map.setCenter(centre);}
|
13 | | -if(this.zoom!=null)this.map.zoomTo(this.zoom);}
|
14 | | -slippymap_map.prototype.osm_create=function(mapId,lon,lat,zoom,initializedContols){var osmLayer;var map=new OpenLayers.Map(mapId,this.mapOptions);if(initializedContols){for(i in initializedContols){map.addControl(initializedContols[i]);initializedContols[i].activate();}}
|
15 | | -if(this.layer=='osm-like'){osmLayer=new OpenLayers.Layer.OSM("OpenStreetMap",'http://cassini.toolserver.org/tiles/osm-like/'+this.locale+'/${z}/${x}/${y}.png');}
|
16 | | -map.addLayers([osmLayer]);map.setCenter(new OpenLayers.LonLat(lon,lat).transform(new OpenLayers.Projection('EPSG:4326'),map.getProjectionObject()),zoom);return map;}
|
17 | | -function getOSMMarkerData(lon,lat,title,label,icon){lonLat=new OpenLayers.LonLat(lon,lat);return{lonlat:lonLat,title:title,label:label,icon:icon};}
|
18 | | -function getOSMMarker(markerLayer,markerData,projectionObject){var marker;if(markerData.icon!=''){marker=new OpenLayers.Marker(markerData.lonlat,new OpenLayers.Icon(markerData.icon));}else{marker=new OpenLayers.Marker(markerData.lonlat);}
|
19 | | -if(markerData.title.length+markerData.label.length>0){marker.events.register('mousedown',marker,function(evt){var popup=new OpenLayers.Feature(markerLayer,markerData.lonlat).createPopup(true);if(markerData.title.length>0&&markerData.label.length>0){popup.setContentHTML('<b>'+markerData.title+"</b><hr />"+markerData.label);}
|
20 | | -else{popup.setContentHTML(markerData.title+markerData.label);}
|
21 | | -popup.setOpacity(0.85);markerLayer.map.addPopup(popup);OpenLayers.Event.stop(evt);});}
|
| 2 | +var slippymaps=new Array();var mapId=0;var layer=null;if(false){addOnloadHook(slippymap_init);} |
| 3 | +function slippymap_init(){for(keyName in slippymaps){slippymaps[keyName].init();}} |
| 4 | +function getValidControlName(control){var OLControls=['ArgParser','Attribution','Button','DragFeature','DragPan','DrawFeature','EditingToolbar','GetFeature','KeyboardDefaults','LayerSwitcher','Measure','ModifyFeature','MouseDefaults','MousePosition','MouseToolbar','Navigation','NavigationHistory','NavToolbar','OverviewMap','Pan','Panel','PanPanel','PanZoom','PanZoomBar','Permalink','Scale','ScaleLine','SelectFeature','Snapping','Split','WMSGetFeatureInfo','ZoomBox','ZoomIn','ZoomOut','ZoomPanel','ZoomToMaxExtent'];for(i in OLControls){if(control==OLControls[i].toLowerCase()){return OLControls[i];}} |
| 5 | +return false;} |
| 6 | +function slippymap_map(mapId,mapParams){var self=this;this.mapId=mapId;for(key in mapParams) |
| 7 | +this[key]=mapParams[key];this.mapOptions={controls:[]};for(i in this.controls){if(this.controls[i].toLowerCase()=='autopanzoom'){if(this.height>140)this.controls[i]=this.height>320?'panzoombar':'panzoom';} |
| 8 | +control=getValidControlName(this.controls[i]);if(control){eval(' this.mapOptions.controls.push( new OpenLayers.Control.'+control+'() ); ');}}} |
| 9 | +slippymap_map.prototype.init=function(){var previewImage=document.getElementById(this.mapId+'-preview');if(previewImage) |
| 10 | +previewImage.style.display='none';this.map=this.osm_create(this.mapId,this.lon,this.lat,this.zoom,this.initializedContols);var centerIsSet=this.lon!=null&&this.lat!=null;var bounds=null;if(this.markers.length>0){var markerLayer=new OpenLayers.Layer.Markers('Markers');markerLayer.id='markerLayer';this.map.addLayer(markerLayer);if(this.markers.length>1&&(!centerIsSet||this.zoom==null)){bounds=new OpenLayers.Bounds();} |
| 11 | +for(i in this.markers){this.markers[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));if(bounds!=null)bounds.extend(this.markers[i].lonlat);markerLayer.addMarker(getOSMMarker(markerLayer,this.markers[i],this.map.getProjectionObject()));}} |
| 12 | +if(bounds!=null)map.zoomToExtent(bounds);if(centerIsSet){var centre=new OpenLayers.LonLat(this.lon,this.lat);centre.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));this.map.setCenter(centre);} |
| 13 | +if(this.zoom!=null)this.map.zoomTo(this.zoom);} |
| 14 | +slippymap_map.prototype.osm_create=function(mapId,lon,lat,zoom,initializedContols){var osmLayer;var map=new OpenLayers.Map(mapId,this.mapOptions);if(initializedContols){for(i in initializedContols){map.addControl(initializedContols[i]);initializedContols[i].activate();}} |
| 15 | +if(this.layer=='osm-like'){osmLayer=new OpenLayers.Layer.OSM("OpenStreetMap",'http://cassini.toolserver.org/tiles/osm-like/'+this.locale+'/${z}/${x}/${y}.png');} |
| 16 | +map.addLayers([osmLayer]);map.setCenter(new OpenLayers.LonLat(lon,lat).transform(new OpenLayers.Projection('EPSG:4326'),map.getProjectionObject()),zoom);return map;} |
| 17 | +function getOSMMarkerData(lon,lat,title,label,icon){lonLat=new OpenLayers.LonLat(lon,lat);return{lonlat:lonLat,title:title,label:label,icon:icon};} |
| 18 | +function getOSMMarker(markerLayer,markerData,projectionObject){var marker;if(markerData.icon!=''){marker=new OpenLayers.Marker(markerData.lonlat,new OpenLayers.Icon(markerData.icon));}else{marker=new OpenLayers.Marker(markerData.lonlat);} |
| 19 | +if(markerData.title.length+markerData.label.length>0){marker.events.register('mousedown',marker,function(evt){var popup=new OpenLayers.Feature(markerLayer,markerData.lonlat).createPopup(true);if(markerData.title.length>0&&markerData.label.length>0){popup.setContentHTML('<b>'+markerData.title+"</b><hr />"+markerData.label);} |
| 20 | +else{popup.setContentHTML(markerData.title+markerData.label);} |
| 21 | +popup.setOpacity(0.85);markerLayer.map.addPopup(popup);OpenLayers.Event.stop(evt);});} |
22 | 22 | return marker;} |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/Services/OpenStreetMap/OSMFunctions.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
23 | 23 | + native |