1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* You may not change or alter any portion of this comment or credits |
5
|
|
|
* of supporting developers from this source code or any supporting source code |
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
* |
8
|
|
|
* This program is distributed in the hope that it will be useful, |
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
16
|
|
|
* @author XOOPS Development Team |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use XoopsModules\Blocksadmin\{ |
20
|
|
|
Helper |
21
|
|
|
}; |
22
|
|
|
|
23
|
|
|
/** @var Helper $helper */ |
24
|
|
|
|
25
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
26
|
|
|
exit; |
27
|
|
|
} |
28
|
|
|
require_once __DIR__ . '/admin_header.php'; |
29
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
30
|
|
|
$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
31
|
|
|
|
32
|
|
|
$helper = Helper::getInstance(); |
33
|
|
|
$helper->loadLanguage('admin', 'system'); |
|
|
|
|
34
|
|
|
$helper->loadLanguage('common'); |
35
|
|
|
|
36
|
|
|
$usespaw = empty($_GET['usespaw']) ? 0 : 1; |
37
|
|
|
|
38
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
39
|
|
|
//$form = new XoopsThemeForm($block['form_title'], 'blockform', XOOPS_URL."/modules/blocksadmin/admin/admin.php" ) ; |
40
|
|
|
$form = new XoopsThemeForm($block['form_title'], 'blockform', 'admin.php', 'post', true); |
41
|
|
|
if (isset($block['name'])) { |
42
|
|
|
$form->addElement(new XoopsFormLabel(_AM_SYSTEM_BLOCKS_NAME, $block['name'])); |
43
|
|
|
} |
44
|
|
|
$side_select = new XoopsFormSelect(_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']); |
45
|
|
|
$side_select->addOptionArray([ |
46
|
|
|
0 => _AM_SYSTEM_BLOCKS_SBLEFT, |
47
|
|
|
1 => _AM_SYSTEM_BLOCKS_SBRIGHT, |
48
|
|
|
3 => _AM_SYSTEM_BLOCKS_CBLEFT, |
49
|
|
|
4 => _AM_SYSTEM_BLOCKS_CBRIGHT, |
50
|
|
|
5 => _AM_SYSTEM_BLOCKS_CBCENTER, |
51
|
|
|
7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT, |
52
|
|
|
8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT, |
53
|
|
|
9 => _AM_SYSTEM_BLOCKS_CBBOTTOM, |
54
|
|
|
10 => _AM_SYSTEM_BLOCKS_CBFOOTERLEFT, |
55
|
|
|
11 => _AM_SYSTEM_BLOCKS_CBFOOTERRIGHT, |
56
|
|
|
12 => _AM_SYSTEM_BLOCKS_CBFOOTERCENTER, |
57
|
|
|
]); |
58
|
|
|
$form->addElement($side_select); |
59
|
|
|
$form->addElement(new XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight'])); |
60
|
|
|
$form->addElement(new XoopsFormRadioYN(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible'])); |
61
|
|
|
$mod_select = new XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true); |
62
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
63
|
|
|
$moduleHandler = xoops_getHandler('module'); |
64
|
|
|
$criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
65
|
|
|
$criteria->add(new Criteria('isactive', 1)); |
66
|
|
|
$module_list = $moduleHandler->getList($criteria); |
67
|
|
|
$module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; |
68
|
|
|
$module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; |
69
|
|
|
ksort($module_list); |
70
|
|
|
$mod_select->addOptionArray($module_list); |
71
|
|
|
$form->addElement($mod_select); |
72
|
|
|
$form->addElement(new XoopsFormText(_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false); |
73
|
|
|
|
74
|
|
|
if ($block['is_custom']) { |
75
|
|
|
// Custom Block's textarea |
76
|
|
|
$notice_for_tags = '<span style="font-size:x-small;font-weight:bold;">' . _AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>'; |
77
|
|
|
$current_op = 'clone' === @$_GET['op'] ? 'clone' : 'edit'; |
78
|
|
|
$uri_to_myself = XOOPS_URL . "/modules/blocksadmin/admin/admin.php?fct=blocksadmin&op=$current_op&bid={$block['bid']}"; |
79
|
|
|
// $can_use_spaw = check_browser_can_use_spaw() ; |
80
|
|
|
$myts = MyTextSanitizer::getInstance(); |
81
|
|
|
$textarea = new XoopsFormDhtmlTextArea(_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', htmlspecialchars($block['content'], ENT_QUOTES | ENT_HTML5), 15, 70); |
82
|
|
|
$textarea->setDescription($notice_for_tags); |
83
|
|
|
|
84
|
|
|
$form->addElement($textarea, true); |
85
|
|
|
|
86
|
|
|
$ctype_select = new XoopsFormSelect(_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']); |
87
|
|
|
$ctype_select->addOptionArray(['H' => _AM_SYSTEM_BLOCKS_HTML, 'P' => _AM_SYSTEM_BLOCKS_PHP, 'S' => _AM_SYSTEM_BLOCKS_AFWSMILE, 'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE]); |
88
|
|
|
$form->addElement($ctype_select); |
89
|
|
|
} else { |
90
|
|
|
if ('' != $block['template'] && !defined('XOOPS_ORETEKI')) { |
91
|
|
|
/** @var \XoopsTplfileHandler $tplfileHandler */ |
92
|
|
|
$tplfileHandler = xoops_getHandler('tplfile'); |
93
|
|
|
$btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); |
94
|
|
|
if (count($btemplate) > 0) { |
95
|
|
|
$form->addElement(new XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&op=edittpl&id=' . $btemplate[0]->getVar('tpl_id') . '">' . _AM_SYSTEM_BLOCKS_EDITTPL . '</a>')); |
96
|
|
|
} else { |
97
|
|
|
$btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']); |
98
|
|
|
if (count($btemplate2) > 0) { |
99
|
|
|
$form->addElement(new XoopsFormLabel(_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&op=edittpl&id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . _AM_SYSTEM_BLOCKS_EDITTPL . '</a>')); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
if (false !== $block['edit_form']) { |
104
|
|
|
$form->addElement(new XoopsFormLabel(_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form'])); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
$cache_select = new XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['cachetime']); |
108
|
|
|
$cache_select->addOptionArray(['0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK, '2592000' => _MONTH]); |
109
|
|
|
$form->addElement($cache_select); |
110
|
|
|
if (isset($block['bid'])) { |
111
|
|
|
$form->addElement(new XoopsFormHidden('bid', $block['bid'])); |
112
|
|
|
} |
113
|
|
|
// $form->addElement(new XoopsFormHidden('options', $block['options'])); |
114
|
|
|
$form->addElement(new XoopsFormHidden('op', $block['op'])); |
115
|
|
|
$form->addElement(new XoopsFormHidden('fct', 'blocksadmin')); |
116
|
|
|
$button_tray = new XoopsFormElementTray('', ' '); |
117
|
|
|
if ($block['is_custom']) { |
118
|
|
|
$button_tray->addElement(new XoopsFormButton('', 'previewblock', _PREVIEW, 'submit')); |
119
|
|
|
} |
120
|
|
|
$button_tray->addElement(new XoopsFormButton('', 'submitblock', $block['submit_button'], 'submit')); |
121
|
|
|
$form->addElement($button_tray); |
122
|
|
|
|
123
|
|
|
// checks browser compatibility with the control |
124
|
|
|
/** |
125
|
|
|
* @return bool |
126
|
|
|
*/ |
127
|
|
|
function check_browser_can_use_spaw() |
128
|
|
|
{ |
129
|
|
|
$browser = $_SERVER['HTTP_USER_AGENT']; |
130
|
|
|
// check if msie |
131
|
|
|
if (preg_match('/MSIE[^;]*/i', $browser, $msie)) { |
132
|
|
|
// get version |
133
|
|
|
if (preg_match('/\d+\.\d+/i', $msie[0], $version)) { |
134
|
|
|
// check version |
135
|
|
|
if ((float)$version[0] >= 5.5) { |
136
|
|
|
// finally check if it's not opera impersonating ie |
137
|
|
|
if (false !== mb_strpos($browser, 'opera')) { |
138
|
|
|
return true; |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
return false; |
145
|
|
|
} |
146
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.