-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin_config.php
242 lines (219 loc) · 5.61 KB
/
admin_config.php
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
/**
* @file
* Class installations to handle configuration forms on Admin UI.
*/
require_once('../../class2.php');
if(!e107::isInstalled('cookie_consent') || !getperms("P"))
{
e107::redirect(e_BASE . 'index.php');
}
// [PLUGINS]/cookie_consent/languages/[LANGUAGE]/[LANGUAGE]_admin.php
e107::lan('cookie_consent', true, true);
/**
* Class cookie_consent_admin.
*/
class cookie_consent_admin extends e_admin_dispatcher
{
/**
* Required (set by child class).
*
* Controller map array in format.
* @code
* 'MODE' => array(
* 'controller' =>'CONTROLLER_CLASS_NAME',
* 'path' => 'CONTROLLER SCRIPT PATH',
* 'ui' => 'UI_CLASS', // extend of 'comments_admin_form_ui'
* 'uipath' => 'path/to/ui/',
* );
* @endcode
*
* @var array
*/
protected $modes = array(
'main' => array(
'controller' => 'cookie_consent_admin_ui',
'path' => null,
),
);
/**
* Optional (set by child class).
*
* Required for admin menu render. Format:
* @code
* 'mode/action' => array(
* 'caption' => 'Link title',
* 'perm' => '0',
* 'url' => '{e_PLUGIN}plugname/admin_config.php',
* ...
* );
* @endcode
*
* Note that 'perm' and 'userclass' restrictions are inherited from the $modes, $access and $perm, so you don't
* have to set that vars if you don't need any additional 'visual' control.
*
* All valid key-value pair (see e107::getNav()->admin function) are accepted.
*
* @var array
*/
protected $adminMenu = array(
'main/prefs' => array(
'caption' => LAN_COOKIE_CONSENT_ADMIN_01,
'perm' => 'P',
),
);
/**
* Optional (set by child class).
*
* @var string
*/
protected $menuTitle = LAN_PLUGIN_COOKIE_CONSENT_NAME;
}
/**
* Class cookie_consent_admin_ui.
*/
class cookie_consent_admin_ui extends e_admin_ui
{
/**
* Could be LAN constant (multi-language support).
*
* @var string plugin name
*/
protected $pluginTitle = LAN_PLUGIN_COOKIE_CONSENT_NAME;
/**
* Plugin name.
*
* @var string
*/
protected $pluginName = "cookie_consent";
/**
* Example: array('0' => 'Tab label', '1' => 'Another label');
* Referenced from $prefs property per field - 'tab => xxx' where xxx is the tab key (identifier).
*
* @var array edit/create form tabs
*/
protected $preftabs = array(
LAN_COOKIE_CONSENT_ADMIN_01,
);
/**
* Plugin Preference description array.
*
* @var array
*/
protected $prefs = array(
'message' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_12,
'help' => LAN_COOKIE_CONSENT_ADMIN_13,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'dismiss' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_14,
'help' => LAN_COOKIE_CONSENT_ADMIN_15,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'learnMore' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_16,
'help' => LAN_COOKIE_CONSENT_ADMIN_17,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'link' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_18,
'help' => LAN_COOKIE_CONSENT_ADMIN_19,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'container' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_20,
'help' => LAN_COOKIE_CONSENT_ADMIN_21,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'theme' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_10,
'help' => LAN_COOKIE_CONSENT_ADMIN_11,
'type' => 'dropdown',
'data' => 'str',
'writeParms' => array(
'optArray' => array(
'light-floating' => LAN_COOKIE_CONSENT_ADMIN_02,
'light-bottom' => LAN_COOKIE_CONSENT_ADMIN_03,
'light-top' => LAN_COOKIE_CONSENT_ADMIN_04,
'dark-floating' => LAN_COOKIE_CONSENT_ADMIN_05,
'dark-floating-tada' => LAN_COOKIE_CONSENT_ADMIN_06,
'dark-inline' => LAN_COOKIE_CONSENT_ADMIN_07,
'dark-bottom' => LAN_COOKIE_CONSENT_ADMIN_08,
'dark-top' => LAN_COOKIE_CONSENT_ADMIN_09,
),
),
'tab' => 0,
),
'path' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_22,
'help' => LAN_COOKIE_CONSENT_ADMIN_23,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'domain' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_24,
'help' => LAN_COOKIE_CONSENT_ADMIN_25,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'expiryDays' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_26,
'help' => LAN_COOKIE_CONSENT_ADMIN_27,
'type' => 'number',
'data' => 'int',
'tab' => 0,
),
'target' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_28,
'help' => LAN_COOKIE_CONSENT_ADMIN_29,
'type' => 'text',
'data' => 'str',
'tab' => 0,
),
'cdn' => array(
'title' => LAN_COOKIE_CONSENT_ADMIN_30,
'type' => 'boolean',
'writeParms' => 'label=yesno',
'data' => 'int',
'tab' => 0,
),
);
/**
* User defined init.
*/
public function init()
{
$prefs = e107::getPlugConfig('cookie_consent')->getPref();
if(empty($prefs['domain']))
{
e107::getPlugConfig('cookie_consent')->set('domain', $_SERVER['HTTP_HOST'])->save(false, true, false);
// FIXME find a way to set default value instead of e107::getPlugConfig().
// $this->fields['domain']['writeParms']['default'] = $_SERVER['HTTP_HOST'];
}
// After submit.
if (varset($_POST['cdn'], 0) == 0)
{
$cache = e107::getCache();
$cacheID = 'library_manager_' . md5('cookieconsent2');
$cache->clear($cacheID, true);
}
}
}
new cookie_consent_admin();
require_once(e_ADMIN . "auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN . "footer.php");
exit;