1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class for the 'display_map_ajax' parser hooks. |
5
|
|
|
* |
6
|
|
|
* @since 0.7 |
7
|
|
|
* |
8
|
|
|
* @licence GNU GPL v2+ |
9
|
|
|
* @author Jeroen De Dauw < [email protected] > |
10
|
|
|
* @author Peter Grassberger < [email protected] > |
11
|
|
|
*/ |
12
|
|
|
class SMDisplayAjaxMap extends MapsDisplayMap { |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Gets the name of the parser hook. |
16
|
|
|
* @see ParserHook::getName |
17
|
|
|
* |
18
|
|
|
* @since 0.7 |
19
|
|
|
* |
20
|
|
|
* @return string |
21
|
|
|
*/ |
22
|
|
|
protected function getName() { |
23
|
|
|
return 'display_ajax_map'; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Returns an array containing the parameter info. |
28
|
|
|
* @see ParserHook::getParameterInfo |
29
|
|
|
* |
30
|
|
|
* @since 0.7 |
31
|
|
|
* |
32
|
|
|
* @return array |
33
|
|
|
*/ |
34
|
|
|
protected function getParameterInfo( $type ) { |
35
|
|
|
$params = MapsMapper::getCommonParameters(); |
|
|
|
|
36
|
|
|
|
37
|
|
|
$params['mappingservice']['feature'] = 'display_ajax_map'; |
38
|
|
|
|
39
|
|
|
$params['coordinates'] = array( |
40
|
|
|
//'type' => 'mapslocation', |
41
|
|
|
//'aliases' => array( 'coords', 'location', 'address', 'addresses', 'locations', 'points' ), |
42
|
|
|
'dependencies' => array( 'mappingservice', 'geoservice' ), |
43
|
|
|
'default' => '', |
44
|
|
|
'islist' => true, |
45
|
|
|
'delimiter' => $type === ParserHook::TYPE_FUNCTION ? ';' : "\n", |
46
|
|
|
'message' => 'semanticmaps-displaymap-par-coordinates', |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
$params['coordinatesproperty'] = array( |
50
|
|
|
'default' => 'Has coordinates', |
51
|
|
|
'message' => 'semanticmaps-displaymap-par-coordinatesproperty', |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
$params['ajaxquery'] = array( |
55
|
|
|
'default' => '', |
56
|
|
|
'islist' => true, |
57
|
|
|
'delimiter' => ';', |
58
|
|
|
'message' => 'semanticmaps-displaymap-par-ajaxquery', |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
$params = array_merge( $params, self::getCommonMapParams() ); |
|
|
|
|
62
|
|
|
|
63
|
|
|
return $params; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Renders and returns the output. |
68
|
|
|
* @see ParserHook::render |
69
|
|
|
* |
70
|
|
|
* @since 0.7 |
71
|
|
|
* |
72
|
|
|
* @param array $parameters |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function render( array $parameters ) { |
77
|
|
|
// Get the instance of the service class. |
78
|
|
|
$service = MapsMappingServices::getServiceInstance( $parameters['mappingservice'] ); |
79
|
|
|
$mapName = $service->getMapId(); |
80
|
|
|
|
81
|
|
|
//$fullParams = $this->validator->getParameters(); |
82
|
|
|
|
83
|
|
|
$configVars = Skin::makeVariablesScript( $service->getConfigVariables() ); |
84
|
|
|
$service->addDependencies( $this->parser ); |
85
|
|
|
$this->parser->getOutput()->addHeadItem( $configVars ); |
86
|
|
|
|
87
|
|
|
/*if ( array_key_exists( 'zoom', $fullParams ) && $fullParams['zoom']->wasSetToDefault() && count( $parameters['coordinates'] ) > 1 ) { |
88
|
|
|
$parameters['zoom'] = false; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
$this->parser->addTrackingCategory( 'maps-tracking-category' );*/ |
92
|
|
|
|
93
|
|
|
return Html::rawElement( |
94
|
|
|
'div', |
95
|
|
|
array( |
96
|
|
|
'id' => $mapName, |
97
|
|
|
'style' => "width: {$parameters['width']}; height: {$parameters['height']}; background-color: #cccccc; overflow: hidden;", |
98
|
|
|
'class' => 'maps-map maps-' . $service->getName() |
99
|
|
|
), |
100
|
|
|
wfMessage( 'maps-loading-map' )->inContentLanguage()->escaped() . |
101
|
|
|
Html::element( |
102
|
|
|
'div', |
103
|
|
|
array( 'style' => 'display:none', 'class' => 'mapdata' ), |
104
|
|
|
FormatJson::encode( $parameters ) |
105
|
|
|
) |
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
} |
110
|
|
|
|
This method has been deprecated.