Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
PFGoogleMapsInput | |
0.00% |
0 / 23 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDefaultCargoTypes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getOtherCargoTypesHandled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHTML | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
getHtmlText | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * @file |
4 | * @ingroup PF |
5 | */ |
6 | |
7 | /** |
8 | * @ingroup PFFormInput |
9 | */ |
10 | class PFGoogleMapsInput extends PFOpenLayersInput { |
11 | |
12 | public static function getName(): string { |
13 | return 'googlemaps'; |
14 | } |
15 | |
16 | public static function getDefaultCargoTypes() { |
17 | return []; |
18 | } |
19 | |
20 | public static function getOtherCargoTypesHandled() { |
21 | return [ 'Coordinates' ]; |
22 | } |
23 | |
24 | public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, array $other_args ) { |
25 | global $wgPageFormsGoogleMapsKey, $wgOut; |
26 | |
27 | $scripts = [ |
28 | "https://maps.googleapis.com/maps/api/js?v=3.exp&key=$wgPageFormsGoogleMapsKey" |
29 | ]; |
30 | $scriptsHTML = ''; |
31 | foreach ( $scripts as $script ) { |
32 | $scriptsHTML .= Html::linkedScript( $script ); |
33 | } |
34 | $wgOut->addHeadItem( $scriptsHTML, $scriptsHTML ); |
35 | $wgOut->addModules( 'ext.pageforms.maps' ); |
36 | |
37 | $height = self::getHeight( $other_args ); |
38 | $width = self::getWidth( $other_args ); |
39 | $fullInputHTML = self::mapLookupHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args, $height, $width ); |
40 | $text = Html::rawElement( 'div', [ 'class' => 'pfGoogleMapsInput' ], $fullInputHTML ); |
41 | |
42 | return $text; |
43 | } |
44 | |
45 | /** |
46 | * Returns the HTML code to be included in the output page for this input. |
47 | * @return string |
48 | */ |
49 | public function getHtmlText(): string { |
50 | return self::getHTML( |
51 | $this->mCurrentValue, |
52 | $this->mInputName, |
53 | $this->mIsMandatory, |
54 | $this->mIsDisabled, |
55 | $this->mOtherArgs |
56 | ); |
57 | } |
58 | } |