Completed
Pull Request — master (#52)
by
unknown
05:30
created

SMDisplayAjaxMap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 7
Bugs 0 Features 3
Metric Value
wmc 4
c 7
b 0
f 3
lcom 1
cbo 4
dl 0
loc 98
ccs 0
cts 30
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
B getParameterInfo() 0 31 2
B render() 0 32 1
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();
0 ignored issues
show
Deprecated Code introduced by
The method MapsMapper::getCommonParameters() has been deprecated.

This method has been deprecated.

Loading history...
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() );
0 ignored issues
show
Deprecated Code introduced by
The method MapsDisplayMap::getCommonMapParams() has been deprecated.

This method has been deprecated.

Loading history...
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