1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* @package sitemaker |
6
|
|
|
* @copyright (c) 2019 Daniel A. (blitze) |
7
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace blitze\sitemaker\blocks; |
12
|
|
|
|
13
|
|
|
use blitze\sitemaker\services\blocks\driver\block; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Google Maps Block |
17
|
|
|
*/ |
18
|
|
|
class google_maps extends block |
19
|
|
|
{ |
20
|
|
|
/** @var \phpbb\template\template */ |
21
|
|
|
protected $template; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Constructor |
25
|
|
|
* |
26
|
|
|
* @param \phpbb\template\template $template Template object |
27
|
|
|
*/ |
28
|
|
|
public function __construct(\phpbb\template\template $template) |
29
|
|
|
{ |
30
|
|
|
$this->template = $template; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function get_config(array $settings) |
37
|
|
|
{ |
38
|
|
|
return array( |
39
|
|
|
'legend1' => 'SETTINGS', |
40
|
|
|
'title' => array('lang' => 'MAP_TITLE', 'validate' => 'string', 'type' => 'text:0:255', 'default' => ''), |
41
|
|
|
'location' => array('lang' => 'MAP_LOCATION', 'validate' => 'string', 'type' => 'text:0:255', 'default' => ''), |
42
|
|
|
'coordinates' => array('lang' => 'MAP_COORDINATES', 'validate' => 'string', 'type' => 'text:0:255', 'default' => '', 'explain' => true), |
43
|
|
|
'zoom' => array('lang' => 'MAP_ZOOM_LEVEL', 'validate' => 'int:0:21', 'type' => 'number:0:21', 'maxlength' => 2, 'default' => 14), |
44
|
|
|
'view' => array('lang' => 'MAP_VIEW', 'validate' => 'string', 'type' => 'select', 'options' => $this->view_options(), 'default' => ''), |
45
|
|
|
'height' => array('lang' => 'MAP_HEIGHT', 'validate' => 'int:0', 'type' => 'number', 'default' => 100), |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public function display(array $bdata, $edit_mode = false) |
53
|
|
|
{ |
54
|
|
|
$settings = $bdata['settings']; |
55
|
|
|
|
56
|
|
|
return array( |
57
|
|
|
'title' => 'GOOGLE_MAP', |
58
|
|
|
'data' => array( |
59
|
|
|
'location' => urlencode($settings['location']), |
60
|
|
|
'coordinates' => $settings['coordinates'], |
61
|
|
|
'height' => $settings['height'], |
62
|
|
|
'title' => urlencode($settings['title']), |
63
|
|
|
'view' => $settings['view'], |
64
|
|
|
'zoom' => $settings['zoom'], |
65
|
|
|
'lang_code' => $this->template->retrieve_var('S_USER_LANG'), |
66
|
|
|
) |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return array |
72
|
|
|
*/ |
73
|
|
|
protected function view_options() |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
|
|
'' => 'MAP_VIEW_MAP', |
77
|
|
|
'k' => 'MAP_VIEW_SATELITE', |
78
|
|
|
'h' => 'MAP_VIEW_HYBRID', |
79
|
|
|
'p' => 'MAP_VIEW_TERRAIN', |
80
|
|
|
]; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
|
|
public function get_template() |
87
|
|
|
{ |
88
|
|
|
return '@blitze_sitemaker/blocks/google_maps.html'; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|