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

SMDisplayAjaxMap::getParameterInfo()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 30
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 30
ccs 0
cts 18
cp 0
rs 8.8571
cc 2
eloc 18
nc 2
nop 1
crap 6
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' => 'maps-displaymap-par-coordinates',
47
        );
48
49
        $params['ajax'] = array(
50
            'type' => 'boolean',
51
            'default' => true,
52
            'message' => 'maps-displaymap-par-ajax',
53
        );
54
55
        $params['coordinatesproperty'] = array(
56
            'default' => 'Has coordinates',
57
            'message' => 'maps-displaymap-par-coordinatesproperty',
58
        );
59
60
        $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...
61
62
        return $params;
63
    }
64
65
    /**
66
     * Renders and returns the output.
67
     * @see ParserHook::render
68
     *
69
     * @since 0.7
70
     *
71
     * @param array $parameters
72
     *
73
     * @return string
74
     */
75
    public function render( array $parameters ) {
76
        // Get the instance of the service class.
77
        $service = MapsMappingServices::getServiceInstance( $parameters['mappingservice'] );
78
        $mapName = $service->getMapId();
79
80
        //$fullParams = $this->validator->getParameters();
81
82
        $configVars = Skin::makeVariablesScript( $service->getConfigVariables() );
83
        $service->addDependencies( $this->parser );
84
        $this->parser->getOutput()->addHeadItem( $configVars );
85
86
        /*if ( array_key_exists( 'zoom', $fullParams ) && $fullParams['zoom']->wasSetToDefault() && count( $parameters['coordinates'] ) > 1 ) {
87
            $parameters['zoom'] = false;
88
        }
89
90
        $this->parser->addTrackingCategory( 'maps-tracking-category' );*/
91
92
        return Html::rawElement(
93
            'div',
94
            array(
95
                'id' => $mapName,
96
                'style' => "width: {$parameters['width']}; height: {$parameters['height']}; background-color: #cccccc; overflow: hidden;",
97
                'class' => 'maps-map maps-' . $service->getName()
98
            ),
99
            wfMessage( 'maps-loading-map' )->inContentLanguage()->escaped() .
100
            Html::element(
101
                'div',
102
                array( 'style' => 'display:none', 'class' => 'mapdata' ),
103
                FormatJson::encode( $parameters )
104
            )
105
        );
106
    }
107
108
}
109