1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* See the enclosed file license.txt for licensing information. |
4
|
|
|
* If you did not receive this file, get it at https://www.gnu.org/licenses/gpl-2.0.html |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2000-2021 XOOPS Project (www.xoops.org) |
7
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
8
|
|
|
* @package installer |
9
|
|
|
* @since 2.3.0 |
10
|
|
|
* @author Haruki Setoyama <[email protected]> |
11
|
|
|
* @author Kazumi Ono <[email protected]> |
12
|
|
|
* @author Skalpa Keo <[email protected]> |
13
|
|
|
* @author Taiwen Jiang <[email protected]> |
14
|
|
|
* @author DuGris (aka L. JEN) <[email protected]> |
15
|
|
|
**/ |
16
|
|
|
|
17
|
|
|
if (!defined('XOOPS_INSTALL')) { |
18
|
|
|
die('XOOPS Custom Installation die'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
22
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
23
|
|
|
|
24
|
|
|
define('PREF_1', _MD_AM_GENERAL); |
25
|
|
|
define('PREF_2', _MD_AM_USERSETTINGS); |
26
|
|
|
define('PREF_3', _MD_AM_METAFOOTER); |
27
|
|
|
define('PREF_4', _MD_AM_CENSOR); |
28
|
|
|
define('PREF_5', _MD_AM_SEARCH); |
29
|
|
|
define('PREF_6', _MD_AM_MAILER); |
30
|
|
|
if (defined('_MD_AM_AUTHENTICATION')) { |
31
|
|
|
define('PREF_7', _MD_AM_AUTHENTICATION); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param $config |
36
|
|
|
* |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
|
|
function createConfigform($config) |
40
|
|
|
{ |
41
|
|
|
xoops_load('XoopsFormRendererBootstrap3'); |
42
|
|
|
XoopsFormRenderer::getInstance()->set(new XoopsFormRendererBootstrap3()); |
43
|
|
|
|
44
|
|
|
/** @var XoopsConfigHandler $config_handler */ |
45
|
|
|
$config_handler = xoops_getHandler('config'); |
46
|
|
|
$GLOBALS['xoopsConfig'] = $xoopsConfig = $config_handler->getConfigsByCat(XOOPS_CONF); |
|
|
|
|
47
|
|
|
|
48
|
|
|
$ret = array(); |
49
|
|
|
$confcount = count($config); |
50
|
|
|
|
51
|
|
|
for ($i = 0; $i < $confcount; ++$i) { |
52
|
|
|
$conf_catid = $config[$i]->getVar('conf_catid'); |
53
|
|
|
if (!isset($ret[$conf_catid])) { |
54
|
|
|
$form_title = constant('PREF_' . $conf_catid); |
55
|
|
|
$ret[$conf_catid] = new XoopsThemeForm($form_title, 'configs', 'index.php', 'post'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$title = constant($config[$i]->getVar('conf_title')); |
59
|
|
|
|
60
|
|
|
switch ($config[$i]->getVar('conf_formtype')) { |
61
|
|
|
case 'textarea': |
62
|
|
|
if ($config[$i]->getVar('conf_valuetype') === 'array') { |
63
|
|
|
// this is exceptional. Only when value type is array, we need a smarter way for this |
64
|
|
|
$ele = ($config[$i]->getVar('conf_value') != '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), installerHtmlSpecialChars(implode('|', $config[$i]->getConfValueForOutput())), 5, 50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50); |
65
|
|
|
} else { |
66
|
|
|
$ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), installerHtmlSpecialChars($config[$i]->getConfValueForOutput()), 5, 100); |
67
|
|
|
} |
68
|
|
|
break; |
69
|
|
|
|
70
|
|
|
case 'select': |
71
|
|
|
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
72
|
|
|
$options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
73
|
|
|
$opcount = count($options); |
74
|
|
|
for ($j = 0; $j < $opcount; ++$j) { |
75
|
|
|
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
76
|
|
|
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
77
|
|
|
$ele->addOption($optval, $optkey); |
78
|
|
|
} |
79
|
|
|
break; |
80
|
|
|
|
81
|
|
|
case 'select_multi': |
82
|
|
|
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
83
|
|
|
$options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
84
|
|
|
$opcount = count($options); |
85
|
|
|
for ($j = 0; $j < $opcount; ++$j) { |
86
|
|
|
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
87
|
|
|
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
88
|
|
|
$ele->addOption($optval, $optkey); |
89
|
|
|
} |
90
|
|
|
break; |
91
|
|
|
|
92
|
|
|
case 'yesno': |
93
|
|
|
$ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); |
94
|
|
|
break; |
95
|
|
|
|
96
|
|
|
case 'theme': |
97
|
|
|
case 'theme_multi': |
98
|
|
|
$ele = ($config[$i]->getVar('conf_formtype') !== 'theme_multi') ? new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()) : new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
99
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
100
|
|
|
$dirlist = XoopsLists::getThemesList(); |
101
|
|
|
if (!empty($dirlist)) { |
102
|
|
|
asort($dirlist); |
103
|
|
|
$ele->addOptionArray($dirlist); |
104
|
|
|
} |
105
|
|
|
// old theme value is used to determine whether to update cache or not. kind of dirty way |
106
|
|
|
$form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput())); |
|
|
|
|
107
|
|
|
break; |
108
|
|
|
|
109
|
|
|
case 'tplset': |
110
|
|
|
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
111
|
|
|
$tplset_handler = xoops_getHandler('tplset'); |
112
|
|
|
$tplsetlist = $tplset_handler->getList(); |
|
|
|
|
113
|
|
|
asort($tplsetlist); |
114
|
|
|
foreach ($tplsetlist as $key => $name) { |
115
|
|
|
$ele->addOption($key, $name); |
116
|
|
|
} |
117
|
|
|
// old theme value is used to determine whether to update cache or not. kind of dirty way |
118
|
|
|
$form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput())); |
119
|
|
|
break; |
120
|
|
|
|
121
|
|
|
case 'timezone': |
122
|
|
|
$ele = new XoopsFormSelectTimezone($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
123
|
|
|
break; |
124
|
|
|
|
125
|
|
|
case 'language': |
126
|
|
|
$ele = new XoopsFormSelectLang($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
127
|
|
|
break; |
128
|
|
|
|
129
|
|
|
case 'startpage': |
130
|
|
|
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
131
|
|
|
/** @var XoopsModuleHandler $module_handler */ |
132
|
|
|
$module_handler = xoops_getHandler('module'); |
133
|
|
|
$criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
134
|
|
|
$criteria->add(new Criteria('isactive', 1)); |
135
|
|
|
$moduleslist = $module_handler->getList($criteria, true); |
136
|
|
|
$moduleslist['--'] = _MD_AM_NONE; |
137
|
|
|
$ele->addOptionArray($moduleslist); |
138
|
|
|
break; |
139
|
|
|
|
140
|
|
|
case 'group': |
141
|
|
|
$ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
142
|
|
|
break; |
143
|
|
|
|
144
|
|
|
case 'group_multi': |
145
|
|
|
$ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
146
|
|
|
break; |
147
|
|
|
|
148
|
|
|
// RMV-NOTIFY - added 'user' and 'user_multi' |
149
|
|
|
case 'user': |
150
|
|
|
$ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
151
|
|
|
break; |
152
|
|
|
|
153
|
|
|
case 'user_multi': |
154
|
|
|
$ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
155
|
|
|
break; |
156
|
|
|
|
157
|
|
|
case 'module_cache': |
158
|
|
|
/** @var XoopsModuleHandler $module_handler */ |
159
|
|
|
$module_handler = xoops_getHandler('module'); |
160
|
|
|
$modules = $module_handler->getObjects(new Criteria('hasmain', 1), true); |
161
|
|
|
$currrent_val = $config[$i]->getConfValueForOutput(); |
162
|
|
|
$cache_options = array( |
163
|
|
|
'0' => _NOCACHE, |
164
|
|
|
'30' => sprintf(_SECONDS, 30), |
165
|
|
|
'60' => _MINUTE, |
166
|
|
|
'300' => sprintf(_MINUTES, 5), |
167
|
|
|
'1800' => sprintf(_MINUTES, 30), |
168
|
|
|
'3600' => _HOUR, |
169
|
|
|
'18000' => sprintf(_HOURS, 5), |
170
|
|
|
'86400' => _DAY, |
171
|
|
|
'259200' => sprintf(_DAYS, 3), |
172
|
|
|
'604800' => _WEEK); |
173
|
|
|
if (count($modules) > 0) { |
174
|
|
|
$ele = new XoopsFormElementTray($title, '<br>'); |
175
|
|
|
foreach (array_keys($modules) as $mid) { |
176
|
|
|
$c_val = isset($currrent_val[$mid]) ? (int)$currrent_val[$mid] : null; |
177
|
|
|
$selform = new XoopsFormSelect($modules[$mid]->getVar('name'), $config[$i]->getVar('conf_name') . "[$mid]", $c_val); |
178
|
|
|
$selform->addOptionArray($cache_options); |
179
|
|
|
$ele->addElement($selform); |
180
|
|
|
unset($selform); |
181
|
|
|
} |
182
|
|
|
} else { |
183
|
|
|
$ele = new XoopsFormLabel($title, _MD_AM_NOMODULE); |
184
|
|
|
} |
185
|
|
|
break; |
186
|
|
|
|
187
|
|
|
case 'site_cache': |
188
|
|
|
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
189
|
|
|
$ele->addOptionArray(array( |
190
|
|
|
'0' => _NOCACHE, |
191
|
|
|
'30' => sprintf(_SECONDS, 30), |
192
|
|
|
'60' => _MINUTE, |
193
|
|
|
'300' => sprintf(_MINUTES, 5), |
194
|
|
|
'1800' => sprintf(_MINUTES, 30), |
195
|
|
|
'3600' => _HOUR, |
196
|
|
|
'18000' => sprintf(_HOURS, 5), |
197
|
|
|
'86400' => _DAY, |
198
|
|
|
'259200' => sprintf(_DAYS, 3), |
199
|
|
|
'604800' => _WEEK)); |
200
|
|
|
break; |
201
|
|
|
|
202
|
|
|
case 'password': |
203
|
|
|
$ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, installerHtmlSpecialChars($config[$i]->getConfValueForOutput())); |
204
|
|
|
break; |
205
|
|
|
|
206
|
|
|
case 'color': |
207
|
|
|
$ele = new XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), installerHtmlSpecialChars($config[$i]->getConfValueForOutput())); |
208
|
|
|
break; |
209
|
|
|
|
210
|
|
|
case 'hidden': |
211
|
|
|
$ele = new XoopsFormHidden($config[$i]->getVar('conf_name'), installerHtmlSpecialChars($config[$i]->getConfValueForOutput())); |
212
|
|
|
break; |
213
|
|
|
|
214
|
|
|
case 'textbox': |
215
|
|
|
default: |
216
|
|
|
$ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, installerHtmlSpecialChars($config[$i]->getConfValueForOutput())); |
217
|
|
|
break; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
if (defined($config[$i]->getVar('conf_desc')) && constant($config[$i]->getVar('conf_desc')) != '') { |
221
|
|
|
$ele->setDescription(constant($config[$i]->getVar('conf_desc'))); |
222
|
|
|
} |
223
|
|
|
$ret[$conf_catid]->addElement($ele); |
224
|
|
|
|
225
|
|
|
$hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); |
226
|
|
|
$ret[$conf_catid]->addElement($hidden); |
227
|
|
|
|
228
|
|
|
unset($ele, $hidden); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
return $ret; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @param $config |
236
|
|
|
* |
237
|
|
|
* @return array |
238
|
|
|
*/ |
239
|
|
|
function createThemeform($config) |
240
|
|
|
{ |
241
|
|
|
xoops_load('XoopsFormRendererBootstrap3'); |
242
|
|
|
XoopsFormRenderer::getInstance()->set(new XoopsFormRendererBootstrap3()); |
243
|
|
|
|
244
|
|
|
$title = (!defined($config->getVar('conf_desc')) || constant($config->getVar('conf_desc')) === '') ? constant($config->getVar('conf_title')) : constant($config->getVar('conf_title')) . '<br><br><span>' . constant($config->getVar('conf_desc')) . '</span>'; |
245
|
|
|
$form_theme_set = new XoopsFormSelect('', $config->getVar('conf_name'), $config->getConfValueForOutput(), 1, false); |
246
|
|
|
$dirlist = XoopsLists::getThemesList(); |
247
|
|
|
if (!empty($dirlist)) { |
248
|
|
|
asort($dirlist); |
249
|
|
|
$form_theme_set->addOptionArray($dirlist); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
$label_content = ''; |
253
|
|
|
|
254
|
|
|
// read ini file for each theme |
255
|
|
|
foreach ($dirlist as $theme) { |
256
|
|
|
// set default value |
257
|
|
|
$theme_ini = array( |
258
|
|
|
'Name' => $theme, |
259
|
|
|
'Description' => '', |
260
|
|
|
'Version' => '', |
261
|
|
|
'Format' => '', |
262
|
|
|
'Author' => '', |
263
|
|
|
'Demo' => '', |
264
|
|
|
'Url' => '', |
265
|
|
|
'Download' => '', |
266
|
|
|
'W3C' => '', |
267
|
|
|
'Licence' => '', |
268
|
|
|
'thumbnail' => 'screenshot.gif', |
269
|
|
|
'screenshot' => 'screenshot.png'); |
270
|
|
|
|
271
|
|
|
if ($theme == $config->getConfValueForOutput()) { |
272
|
|
|
$label_content .= '<div class="theme_preview" id="'.$theme.'" style="display:block;">'; |
273
|
|
|
} else { |
274
|
|
|
$label_content .= '<div class="theme_preview" id="'.$theme.'" style="display:none;">'; |
275
|
|
|
} |
276
|
|
|
if (file_exists(XOOPS_ROOT_PATH . "/themes/$theme/theme.ini")) { |
277
|
|
|
$theme_ini = parse_ini_file(XOOPS_ROOT_PATH . "/themes/$theme/theme.ini"); |
278
|
|
|
if (isset($theme_ini['screenshot']) && $theme_ini['screenshot'] == '') { |
279
|
|
|
$theme_ini['screenshot'] = 'screenshot.png'; |
280
|
|
|
$theme_ini['thumbnail'] = 'thumbnail.png'; |
281
|
|
|
} |
282
|
|
|
} |
283
|
|
|
if (!empty($theme_ini['Description'])) { |
284
|
|
|
$label_content .= '<div class="alert alert-info" role="alert">' . $theme_ini['Description'] . '</div>'; |
285
|
|
|
} |
286
|
|
|
if (isset($theme_ini['screenshot']) && $theme_ini['screenshot'] !== '' && file_exists(XOOPS_ROOT_PATH . '/themes/' . $theme . '/' . $theme_ini['screenshot'])) { |
287
|
|
|
$label_content .= '<img class="img-responsive" src="' . XOOPS_URL . '/themes/' . $theme . '/' . $theme_ini['screenshot'] . '" alt="Screenshot" />'; |
288
|
|
|
} elseif (isset($theme_ini['thumbnail']) && $theme_ini['thumbnail'] !== '' && file_exists(XOOPS_ROOT_PATH . '/themes/' . $theme .'/' . $theme_ini['thumbnail'])) { |
289
|
|
|
$label_content .= '<img class="img-responsive" src="' . XOOPS_URL . '/themes/' . $theme . '/' . $theme_ini['thumbnail'] . '" alt="$theme" />'; |
290
|
|
|
} else { |
291
|
|
|
$label_content .= THEME_NO_SCREENSHOT; |
292
|
|
|
} |
293
|
|
|
$label_content .= '</div>'; |
294
|
|
|
} |
295
|
|
|
// read ini file for each theme |
296
|
|
|
|
297
|
|
|
$form_theme_set->setExtra("onchange='showThemeSelected(this)'"); |
298
|
|
|
|
299
|
|
|
$form = new XoopsThemeForm($title, 'themes', 'index.php', 'post'); |
300
|
|
|
$form->addElement($form_theme_set); |
301
|
|
|
$form->addElement(new XoopsFormLabel('', "<div id='screenshot'>" . $label_content . '</div>')); |
302
|
|
|
|
303
|
|
|
$form->addElement(new XoopsFormHidden('conf_ids[]', $config->getVar('conf_id'))); |
304
|
|
|
|
305
|
|
|
return $ret = array($form); |
|
|
|
|
306
|
|
|
} |
307
|
|
|
|