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