1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
15
|
|
|
* @author XOOPS Development Team |
16
|
|
|
*/ |
17
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
18
|
|
|
|
19
|
|
|
$usespaw = empty($_GET['usespaw']) ? 0 : 1; |
20
|
|
|
|
21
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
22
|
|
|
$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'admin.php'); |
23
|
|
|
if (isset($block['name'])) { |
24
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_NAME, $block['name'])); |
25
|
|
|
} |
26
|
|
|
$side_select = new \XoopsFormSelect(_AM_BLKTYPE, 'bside', $block['side']); |
27
|
|
|
$side_select->addOptionArray( |
28
|
|
|
[ |
29
|
|
|
0 => _AM_SBLEFT, |
30
|
|
|
1 => _AM_SBRIGHT, |
31
|
|
|
3 => _AM_CBLEFT, |
32
|
|
|
4 => _AM_CBRIGHT, |
33
|
|
|
5 => _AM_CBCENTER, |
34
|
|
|
] |
35
|
|
|
); |
36
|
|
|
$form->addElement($side_select); |
37
|
|
|
$form->addElement(new \XoopsFormText(_AM_WEIGHT, 'bweight', 2, 5, $block['weight'])); |
38
|
|
|
$form->addElement(new \XoopsFormRadioYN(_AM_VISIBLE, 'bvisible', $block['visible'])); |
39
|
|
|
$mod_select = new \XoopsFormSelect(_AM_VISIBLEIN, 'bmodule', $block['modules'], 5, true); |
40
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
41
|
|
|
$moduleHandler = xoops_getHandler('module'); |
42
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); |
43
|
|
|
$criteria->add(new \Criteria('isactive', 1)); |
44
|
|
|
$module_list = $moduleHandler->getList($criteria); |
45
|
|
|
$module_list[-1] = _AM_TOPPAGE; |
46
|
|
|
$module_list[0] = _AM_ALLPAGES; |
47
|
|
|
ksort($module_list); |
48
|
|
|
$mod_select->addOptionArray($module_list); |
49
|
|
|
$form->addElement($mod_select); |
50
|
|
|
$form->addElement(new \XoopsFormText(_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false); |
51
|
|
|
|
52
|
|
|
if ($block['is_custom']) { |
53
|
|
|
// Custom Block's textarea |
54
|
|
|
$notice_for_tags = '<span style="font-size:x-small;font-weight:bold;">' . _AM_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>'; |
55
|
|
|
$current_op = 'clone' === @$_GET['op'] ? 'clone' : 'edit'; |
56
|
|
|
$uri_to_myself = XOOPS_URL . "/modules/blocksadmin/admin/admin.php?fct=blocksadmin&op=$current_op&bid={$block['bid']}"; |
57
|
|
|
$can_use_spaw = true; |
58
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
59
|
|
|
$textarea = new \XoopsFormDhtmlTextArea(_AM_CONTENT, 'bcontent', htmlspecialchars($block['content'], ENT_QUOTES | ENT_HTML5), 15, 70); |
60
|
|
|
if ($can_use_spaw) { |
|
|
|
|
61
|
|
|
$textarea->setDescription($notice_for_tags . "<br><br><a href='$uri_to_myself&usespaw=1'>SPAW</a>"); |
62
|
|
|
} else { |
63
|
|
|
$textarea->setDescription($notice_for_tags); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$form->addElement($textarea, true); |
67
|
|
|
|
68
|
|
|
$ctype_select = new \XoopsFormSelect(_AM_CTYPE, 'bctype', $block['ctype']); |
69
|
|
|
$ctype_select->addOptionArray( |
70
|
|
|
[ |
71
|
|
|
'H' => _AM_HTML, |
72
|
|
|
'P' => _AM_PHP, |
73
|
|
|
'S' => _AM_AFWSMILE, |
74
|
|
|
'T' => _AM_AFNOSMILE, |
75
|
|
|
] |
76
|
|
|
); |
77
|
|
|
$form->addElement($ctype_select); |
78
|
|
|
} else { |
79
|
|
|
if ('' != $block['template'] && !defined('XOOPS_ORETEKI')) { |
80
|
|
|
/** @var \XoopsTplfileHandler $tplfileHandler */ |
81
|
|
|
$tplfileHandler = xoops_getHandler('tplfile'); |
82
|
|
|
$btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); |
83
|
|
|
if (count($btemplate) > 0) { |
84
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&op=edittpl&id=' . $btemplate[0]->getVar('tpl_id') . '">' . _AM_EDITTPL . '</a>')); |
85
|
|
|
} else { |
86
|
|
|
$btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']); |
87
|
|
|
if (count($btemplate2) > 0) { |
88
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&op=edittpl&id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . _AM_EDITTPL . '</a>')); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
if (false !== $block['edit_form']) { |
93
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_OPTIONS, $block['edit_form'])); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
$cache_select = new \XoopsFormSelect(_AM_BCACHETIME, 'bcachetime', $block['cachetime']); |
97
|
|
|
$cache_select->addOptionArray( |
98
|
|
|
[ |
99
|
|
|
0 => _NOCACHE, |
100
|
|
|
30 => sprintf(_SECONDS, 30), |
101
|
|
|
60 => _MINUTE, |
102
|
|
|
300 => sprintf(_MINUTES, 5), |
103
|
|
|
1800 => sprintf(_MINUTES, 30), |
104
|
|
|
3600 => _HOUR, |
105
|
|
|
18000 => sprintf(_HOURS, 5), |
106
|
|
|
86400 => _DAY, |
107
|
|
|
259200 => sprintf(_DAYS, 3), |
108
|
|
|
604800 => _WEEK, |
109
|
|
|
2592000 => _MONTH, |
110
|
|
|
] |
111
|
|
|
); |
112
|
|
|
$form->addElement($cache_select); |
113
|
|
|
if (isset($block['bid'])) { |
114
|
|
|
$form->addElement(new \XoopsFormHidden('bid', $block['bid'])); |
115
|
|
|
} |
116
|
|
|
// $form->addElement(new \XoopsFormHidden('options', $block['options'])); |
117
|
|
|
$form->addElement(new \XoopsFormHidden('op', $block['op'])); |
118
|
|
|
$form->addElement(new \XoopsFormHidden('fct', 'blocksadmin')); |
119
|
|
|
$buttonTray = new \XoopsFormElementTray('', ' '); |
120
|
|
|
if ($block['is_custom']) { |
121
|
|
|
$buttonTray->addElement(new \XoopsFormButton('', 'previewblock', _PREVIEW, 'submit')); |
122
|
|
|
} |
123
|
|
|
$buttonTray->addElement(new \XoopsFormButton('', 'submitblock', $block['submit_button'], 'submit')); |
124
|
|
|
$form->addElement($buttonTray); |
125
|
|
|
|
126
|
|
|
// checks browser compatibility with the control |
127
|
|
|
/** |
128
|
|
|
* @return bool |
129
|
|
|
*/ |
130
|
|
|
function check_browser_can_use_spaw() |
131
|
|
|
{ |
132
|
|
|
$browser = $_SERVER['HTTP_USER_AGENT']; |
133
|
|
|
// check if msie |
134
|
|
|
if (preg_match('/MSIE[^;]*/i', $browser, $msie)) { |
135
|
|
|
// get version |
136
|
|
|
if (preg_match('/[0-9]+\.[0-9]+/i', $msie[0], $version)) { |
137
|
|
|
// check version |
138
|
|
|
if ((float)$version[0] >= 5.5) { |
139
|
|
|
// finally check if it's not opera impersonating ie |
140
|
|
|
if (!preg_match('/opera/i', $browser)) { |
141
|
|
|
return true; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
return false; |
148
|
|
|
} |
149
|
|
|
|