-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublic.php
More file actions
126 lines (113 loc) · 3.3 KB
/
public.php
File metadata and controls
126 lines (113 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of Magix CMS.
# Magix CMS, a CMS optimized for SEO
# Copyright (C) 2010 - 2011 Gerits Aurelien <aurelien@magix-cms.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# -- END LICENSE BLOCK -----------------------------------
require_once('db/gmap.php');
class plugins_gmap_public extends database_plugins_gmap {
protected $template, $getlang;
/**
*
* paramètre pour la requête JSON
* @var uniqp
*/
public $json_multi_data;
/**
* @access public
* Constructor
*/
function __construct() {
$this->template = new frontend_controller_plugins();
$currentLang = parent::getLangId($this->template->getLanguage());
$this->getlang = $currentLang['idlang'];
if($this->getlang == null) {
$default = parent::getDefaultLang();
$this->getlang = $default['idlang'];
}
}
/**
* Retrieve and return the data
* @param string $context
* @param string $type
* @param string|int|null $id
* @return mixed
*/
private function getItems($type, $id = null, $context = 'all') {
$params = array(':lang' => $this->getlang);
if($id) {
$params[':id'] = $id;
$context = 'one';
}
$data = parent::fetchData(array('context'=>$context,'type'=>$type),$params);
$this->template->assign($type,$data);
return $data;
}
/**
* Load map data
* @access private
*/
private function setMapConfig() {
$addresses = $this->getItems('addresses');
$config = parent::fetchData(array('context' => 'all','type' => 'config'));
$configId = '';
$configValue = '';
foreach($config as $key){
$configId[] = $key['config_id'];
$configValue[] = $key['config_value'];
}
$setConfig = array_combine($configId,$configValue);
if($addresses != null) {
$map = [];
foreach ($addresses as $addr){
$mark = '{';
foreach ($addr as $k => $v) {
$mark .= '"'.$k.'":'.json_encode($v).',';
}
$mark = substr($mark, 0, -1).'}';
$map[] = $mark;
}
$setConfig['markers'] = '['.implode(',',$map).']';
}
else {
$setConfig['markers'] = '[]';
}
$config = [];
foreach ($setConfig as $k => $v) {
if($k != 'markers')
$v = json_encode($v);
$config[]= $k.':'.$v;
}
$this->template->assign('config_gmap','{'.implode(',',$config).'}');
}
/**
* @access public
* Execute le plugin dans la partie public
*/
public function run() {
$this->template->assign('plugin_status',parent::c_show_tables());
$this->template->configLoad();
if(parent::c_show_tables()) {
$this->getItems('page',null,'one');
$this->setMapConfig();
$this->template->display('index.tpl');
}
else {
$this->template->display('index.tpl');
}
}
}