Total Complexity | 80 |
Total Lines | 684 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Complex classes like Blocksadmin often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Blocksadmin, and based on these observations, apply Extract Interface, too.
1 | <?php declare(strict_types=1); |
||
28 | class Blocksadmin |
||
29 | { |
||
30 | /** |
||
31 | * @var \XoopsMySQLDatabase|null |
||
32 | */ |
||
33 | public $db; |
||
34 | /** |
||
35 | * @var \XoopsModules\Tag\Helper |
||
36 | */ |
||
37 | public $helper; |
||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | public $moduleDirName; |
||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | public $moduleDirNameUpper; |
||
46 | |||
47 | /** |
||
48 | * Blocksadmin constructor. |
||
49 | */ |
||
50 | public function __construct(?\XoopsDatabase $db, Helper $helper) |
||
51 | { |
||
52 | if (null === $db) { |
||
53 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
54 | } |
||
55 | $this->db = $db; |
||
56 | $this->helper = $helper; |
||
57 | $this->moduleDirName = \basename(\dirname(__DIR__, 2)); |
||
58 | $this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName); |
||
59 | \xoops_loadLanguage('admin', 'system'); |
||
60 | \xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
61 | \xoops_loadLanguage('admin/groups', 'system'); |
||
62 | \xoops_loadLanguage('common', $this->moduleDirName); |
||
63 | \xoops_loadLanguage('blocksadmin', $this->moduleDirName); |
||
64 | } |
||
65 | |||
66 | public function listBlocks(): void |
||
67 | { |
||
68 | global $xoopsModule, $pathIcon16; |
||
69 | require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
70 | // xoops_loadLanguage('admin', 'system'); |
||
71 | // xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
72 | // xoops_loadLanguage('admin/groups', 'system'); |
||
73 | // xoops_loadLanguage('common', $moduleDirName); |
||
74 | // xoops_loadLanguage('blocks', $moduleDirName); |
||
75 | |||
76 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
77 | $moduleHandler = \xoops_getHandler('module'); |
||
78 | /** @var \XoopsMemberHandler $memberHandler */ |
||
79 | $memberHandler = \xoops_getHandler('member'); |
||
80 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
81 | $grouppermHandler = \xoops_getHandler('groupperm'); |
||
82 | $groups = $memberHandler->getGroups(); |
||
83 | $criteria = new \CriteriaCompo(new \Criteria('hasmain', '1')); |
||
84 | $criteria->add(new \Criteria('isactive', '1')); |
||
85 | $moduleList = $moduleHandler->getList($criteria); |
||
86 | $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE; |
||
87 | $moduleList[0] = \_AM_SYSTEM_BLOCKS_ALLPAGES; |
||
88 | \ksort($moduleList); |
||
89 | echo " |
||
90 | <h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>'; |
||
91 | echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>"; |
||
92 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||
93 | echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'> |
||
94 | <tr valign='middle'><th align='center'>" |
||
95 | . \_AM_SYSTEM_BLOCKS_TITLE |
||
96 | . "</th><th align='center' nowrap='nowrap'>" |
||
97 | . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE') |
||
98 | . '<br>' |
||
99 | . _LEFT |
||
100 | . '-' |
||
101 | . _CENTER |
||
102 | . '-' |
||
103 | . _RIGHT |
||
104 | . "</th><th align='center'>" |
||
105 | . \constant( |
||
106 | 'CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT' |
||
107 | ) |
||
108 | . "</th><th align='center'>" |
||
109 | . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE') |
||
110 | . "</th><th align='center'>" |
||
111 | . \_AM_SYSTEM_BLOCKS_VISIBLEIN |
||
112 | . "</th><th align='center'>" |
||
113 | . \_AM_SYSTEM_ADGS |
||
114 | . "</th><th align='center'>" |
||
115 | . \_AM_SYSTEM_BLOCKS_BCACHETIME |
||
116 | . "</th><th align='center'>" |
||
117 | . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION') |
||
118 | . '</th></tr> |
||
119 | '; |
||
120 | $blockArray = \XoopsBlock::getByModule($xoopsModule->mid()); |
||
|
|||
121 | $blockCount = \count($blockArray); |
||
122 | $class = 'even'; |
||
123 | $cachetimes = [ |
||
124 | 0 => _NOCACHE, |
||
125 | 30 => \sprintf(_SECONDS, 30), |
||
126 | 60 => _MINUTE, |
||
127 | 300 => \sprintf(_MINUTES, 5), |
||
128 | 1800 => \sprintf(_MINUTES, 30), |
||
129 | 3600 => _HOUR, |
||
130 | 18000 => \sprintf(_HOURS, 5), |
||
131 | 86400 => _DAY, |
||
132 | 259200 => \sprintf(_DAYS, 3), |
||
133 | 604800 => _WEEK, |
||
134 | 2592000 => _MONTH, |
||
135 | ]; |
||
136 | foreach ($blockArray as $i) { |
||
137 | $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); |
||
138 | $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); |
||
139 | $result = $this->db->query($sql); |
||
140 | $modules = []; |
||
141 | if (!$result instanceof \mysqli_result) { |
||
142 | \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR); |
||
143 | } |
||
144 | while (false !== ($row = $this->db->fetchArray($result))) { |
||
145 | $modules[] = (int)$row['module_id']; |
||
146 | } |
||
147 | |||
148 | $cachetimeOptions = ''; |
||
149 | foreach ($cachetimes as $cachetime => $cachetimeName) { |
||
150 | if ($i->getVar('bcachetime') == $cachetime) { |
||
151 | $cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n"; |
||
152 | } else { |
||
153 | $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n"; |
||
154 | } |
||
155 | } |
||
156 | |||
157 | $ssel7 = ''; |
||
158 | $ssel6 = $ssel7; |
||
159 | $ssel5 = $ssel6; |
||
160 | $ssel4 = $ssel5; |
||
161 | $ssel3 = $ssel4; |
||
162 | $ssel2 = $ssel3; |
||
163 | $ssel1 = $ssel2; |
||
164 | $ssel0 = $ssel1; |
||
165 | $sel1 = $ssel0; |
||
166 | $sel0 = $sel1; |
||
167 | if (1 === $i->getVar('visible')) { |
||
168 | $sel1 = ' checked'; |
||
169 | } else { |
||
170 | $sel0 = ' checked'; |
||
171 | } |
||
172 | if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) { |
||
173 | $ssel0 = ' checked'; |
||
174 | } elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) { |
||
175 | $ssel1 = ' checked'; |
||
176 | } elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) { |
||
177 | $ssel2 = ' checked'; |
||
178 | } elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) { |
||
179 | $ssel4 = ' checked'; |
||
180 | } elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) { |
||
181 | $ssel3 = ' checked'; |
||
182 | } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) { |
||
183 | $ssel5 = ' checked'; |
||
184 | } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) { |
||
185 | $ssel6 = ' checked'; |
||
186 | } elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) { |
||
187 | $ssel7 = ' checked'; |
||
188 | } |
||
189 | if ('' === $i->getVar('title')) { |
||
190 | $title = ' '; |
||
191 | } else { |
||
192 | $title = $i->getVar('title'); |
||
193 | } |
||
194 | $name = $i->getVar('name'); |
||
195 | echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" |
||
196 | . $i->getVar('bid') |
||
197 | . "]' value='" |
||
198 | . $title |
||
199 | . "'></td><td class='$class' align='center' nowrap='nowrap'> |
||
200 | <div align='center' > |
||
201 | <input type='radio' name='side[" |
||
202 | . $i->getVar('bid') |
||
203 | . "]' value='" |
||
204 | . \XOOPS_CENTERBLOCK_LEFT |
||
205 | . "'$ssel2> |
||
206 | <input type='radio' name='side[" |
||
207 | . $i->getVar('bid') |
||
208 | . "]' value='" |
||
209 | . \XOOPS_CENTERBLOCK_CENTER |
||
210 | . "'$ssel3> |
||
211 | <input type='radio' name='side[" |
||
212 | . $i->getVar('bid') |
||
213 | . "]' value='" |
||
214 | . \XOOPS_CENTERBLOCK_RIGHT |
||
215 | . "'$ssel4> |
||
216 | </div> |
||
217 | <div> |
||
218 | <span style='float:right;'><input type='radio' name='side[" |
||
219 | . $i->getVar('bid') |
||
220 | . "]' value='" |
||
221 | . \XOOPS_SIDEBLOCK_RIGHT |
||
222 | . "'$ssel1></span> |
||
223 | <div align='left'><input type='radio' name='side[" |
||
224 | . $i->getVar('bid') |
||
225 | . "]' value='" |
||
226 | . \XOOPS_SIDEBLOCK_LEFT |
||
227 | . "'$ssel0></div> |
||
228 | </div> |
||
229 | <div align='center'> |
||
230 | <input type='radio' name='side[" |
||
231 | . $i->getVar('bid') |
||
232 | . "]' value='" |
||
233 | . \XOOPS_CENTERBLOCK_BOTTOMLEFT |
||
234 | . "'$ssel5> |
||
235 | <input type='radio' name='side[" |
||
236 | . $i->getVar('bid') |
||
237 | . "]' value='" |
||
238 | . \XOOPS_CENTERBLOCK_BOTTOM |
||
239 | . "'$ssel7> |
||
240 | <input type='radio' name='side[" |
||
241 | . $i->getVar('bid') |
||
242 | . "]' value='" |
||
243 | . \XOOPS_CENTERBLOCK_BOTTOMRIGHT |
||
244 | . "'$ssel6> |
||
245 | </div> |
||
246 | </td><td class='$class' align='center'><input type='text' name='weight[" |
||
247 | . $i->getVar('bid') |
||
248 | . "]' value='" |
||
249 | . $i->getVar('weight') |
||
250 | . "' size='5' maxlength='5'></td><td class='$class' align='center' nowrap><input type='radio' name='visible[" |
||
251 | . $i->getVar('bid') |
||
252 | . "]' value='1'$sel1>" |
||
253 | . _YES |
||
254 | . " <input type='radio' name='visible[" |
||
255 | . $i->getVar('bid') |
||
256 | . "]' value='0'$sel0>" |
||
257 | . _NO |
||
258 | . '</td>'; |
||
259 | |||
260 | echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||
261 | foreach ($moduleList as $k => $v) { |
||
262 | echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>"; |
||
263 | } |
||
264 | echo '</select></td>'; |
||
265 | |||
266 | echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||
267 | foreach ($groups as $grp) { |
||
268 | echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>'; |
||
269 | } |
||
270 | echo '</select></td>'; |
||
271 | |||
272 | // Cache lifetime |
||
273 | echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select> |
||
274 | </td>'; |
||
275 | |||
276 | // Actions |
||
277 | |||
278 | echo "<td class='$class' align='center'> |
||
279 | <a href='blocksadmin.php?op=edit&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
280 | <a href='blocksadmin.php?op=clone&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
281 | // if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { |
||
282 | // echo " <a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&op=delete&bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'> |
||
283 | // </a>"; |
||
284 | // } |
||
285 | |||
286 | // if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { |
||
287 | if (!\in_array($i->getVar('block_type'), ['M', 'S'])) { |
||
288 | echo " |
||
289 | <a href='blocksadmin.php?op=delete&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'> |
||
290 | </a>"; |
||
291 | } |
||
292 | echo " |
||
293 | <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'> |
||
294 | <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'> |
||
295 | <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'> |
||
296 | <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'> |
||
297 | <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'> |
||
298 | <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'> |
||
299 | <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'> |
||
300 | </td></tr> |
||
301 | "; |
||
302 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
303 | } |
||
304 | echo "<tr><td class='foot' align='center' colspan='8'> |
||
305 | <input type='hidden' name='op' value='order'> |
||
306 | " . $GLOBALS['xoopsSecurity']->getTokenHTML() . " |
||
307 | <input type='submit' name='submit' value='" . _SUBMIT . "'> |
||
308 | </td></tr></table> |
||
309 | </form> |
||
310 | <br><br>"; |
||
311 | } |
||
312 | |||
313 | public function deleteBlock(int $bid): void |
||
314 | { |
||
315 | // \xoops_cp_header(); |
||
316 | |||
317 | \xoops_loadLanguage('admin', 'system'); |
||
318 | \xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
319 | \xoops_loadLanguage('admin/groups', 'system'); |
||
320 | |||
321 | $myblock = new \XoopsBlock($bid); |
||
322 | |||
323 | $sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid); |
||
324 | $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error()); |
||
325 | |||
326 | $sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid); |
||
327 | $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error()); |
||
328 | |||
329 | $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED); |
||
330 | } |
||
331 | |||
332 | public function cloneBlock(int $bid): void |
||
333 | { |
||
334 | //require __DIR__ . '/admin_header.php'; |
||
335 | // \xoops_cp_header(); |
||
336 | |||
337 | \xoops_loadLanguage('admin', 'system'); |
||
338 | \xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
339 | \xoops_loadLanguage('admin/groups', 'system'); |
||
340 | |||
341 | $myblock = new \XoopsBlock($bid); |
||
342 | $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid; |
||
343 | $result = $this->db->query($sql); |
||
344 | $modules = []; |
||
345 | if ($result instanceof \mysqli_result) { |
||
346 | while (false !== ($row = $this->db->fetchArray($result))) { |
||
347 | $modules[] = (int)$row['module_id']; |
||
348 | } |
||
349 | } |
||
350 | $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']); |
||
351 | $block = [ |
||
352 | 'title' => $myblock->getVar('title') . ' Clone', |
||
353 | 'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'), |
||
354 | 'name' => $myblock->getVar('name'), |
||
355 | 'side' => $myblock->getVar('side'), |
||
356 | 'weight' => $myblock->getVar('weight'), |
||
357 | 'visible' => $myblock->getVar('visible'), |
||
358 | 'content' => $myblock->getVar('content', 'N'), |
||
359 | 'modules' => $modules, |
||
360 | 'is_custom' => $isCustom, |
||
361 | 'ctype' => $myblock->getVar('c_type'), |
||
362 | 'bcachetime' => $myblock->getVar('bcachetime'), |
||
363 | 'op' => 'clone_ok', |
||
364 | 'bid' => $myblock->getVar('bid'), |
||
365 | 'edit_form' => $myblock->getOptions(), |
||
366 | 'template' => $myblock->getVar('template'), |
||
367 | 'options' => $myblock->getVar('options'), |
||
368 | ]; |
||
369 | echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a> <span style="font-weight:bold;">»»</span> ' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>'; |
||
370 | // $form = new Blockform(); |
||
371 | // $form->render(); |
||
372 | |||
373 | echo $this->render($block); |
||
374 | // xoops_cp_footer(); |
||
375 | // require_once __DIR__ . '/admin_footer.php'; |
||
376 | // exit(); |
||
377 | } |
||
378 | |||
379 | public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void |
||
380 | { |
||
381 | \xoops_loadLanguage('admin', 'system'); |
||
382 | \xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
383 | \xoops_loadLanguage('admin/groups', 'system'); |
||
384 | |||
385 | $block = new \XoopsBlock($bid); |
||
386 | $clone = $block->xoopsClone(); |
||
387 | if (empty($bmodule)) { |
||
388 | // \xoops_cp_header(); |
||
389 | \xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); |
||
390 | \xoops_cp_footer(); |
||
391 | exit(); |
||
392 | } |
||
393 | $clone->setVar('side', $bside); |
||
394 | $clone->setVar('weight', $bweight); |
||
395 | $clone->setVar('visible', $bvisible); |
||
396 | //$clone->setVar('content', $_POST['bcontent']); |
||
397 | $clone->setVar('title', Request::getString('btitle', '', 'POST')); |
||
398 | $clone->setVar('bcachetime', $bcachetime); |
||
399 | if (\is_array($options) && (\count($options) > 0)) { |
||
400 | $options = \implode('|', $options); |
||
401 | $clone->setVar('options', $options); |
||
402 | } |
||
403 | $clone->setVar('bid', 0); |
||
404 | if (\in_array($block->getVar('block_type'), ['C', 'E'])) { |
||
405 | $clone->setVar('block_type', 'E'); |
||
406 | } else { |
||
407 | $clone->setVar('block_type', 'D'); |
||
408 | } |
||
409 | // $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105 |
||
410 | if ($clone->store()) { |
||
411 | $newid = $clone->id(); //get the id of the cloned block |
||
412 | } |
||
413 | if (!$newid) { |
||
414 | // \xoops_cp_header(); |
||
415 | $clone->getHtmlErrors(); |
||
416 | \xoops_cp_footer(); |
||
417 | exit(); |
||
418 | } |
||
419 | if ('' !== $clone->getVar('template')) { |
||
420 | /** @var \XoopsTplfileHandler $tplfileHandler */ |
||
421 | $tplfileHandler = \xoops_getHandler('tplfile'); |
||
422 | $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid); |
||
423 | if (\count($btemplate) > 0) { |
||
424 | $tplclone = $btemplate[0]->xoopsClone(); |
||
425 | $tplclone->setVar('tpl_id', 0); |
||
426 | $tplclone->setVar('tpl_refid', $newid); |
||
427 | $tplfileHandler->insert($tplclone); |
||
428 | } |
||
429 | } |
||
430 | |||
431 | foreach ($bmodule as $bmid) { |
||
432 | $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; |
||
433 | $this->db->query($sql); |
||
434 | } |
||
435 | //$groups = &$GLOBALS['xoopsUser']->getGroups(); |
||
436 | foreach ($groups as $iValue) { |
||
437 | $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')"; |
||
438 | $this->db->query($sql); |
||
439 | } |
||
440 | $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED); |
||
441 | } |
||
442 | |||
443 | public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void |
||
444 | { |
||
445 | $myblock = new \XoopsBlock($bid); |
||
446 | $myblock->setVar('title', $title); |
||
447 | $myblock->setVar('weight', $weight); |
||
448 | $myblock->setVar('visible', $visible); |
||
449 | $myblock->setVar('side', $side); |
||
450 | $myblock->setVar('bcachetime', $bcachetime); |
||
451 | $myblock->store(); |
||
452 | // /** @var \XoopsBlockHandler $blockHandler */ |
||
453 | // $blockHandler = \xoops_getHandler('block'); |
||
454 | // return $blockHandler->insert($myblock); |
||
455 | } |
||
456 | |||
457 | public function editBlock(int $bid): void |
||
458 | { |
||
459 | // require_once \dirname(__DIR__,2) . '/admin/admin_header.php'; |
||
460 | // \xoops_cp_header(); |
||
461 | \xoops_loadLanguage('admin', 'system'); |
||
462 | \xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
463 | \xoops_loadLanguage('admin/groups', 'system'); |
||
464 | // mpu_adm_menu(); |
||
465 | $myblock = new \XoopsBlock($bid); |
||
466 | $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid; |
||
467 | $result = $this->db->query($sql); |
||
468 | $modules = []; |
||
469 | if ($result instanceof \mysqli_result) { |
||
470 | while (false !== ($row = $this->db->fetchArray($result))) { |
||
471 | $modules[] = (int)$row['module_id']; |
||
472 | } |
||
473 | } |
||
474 | $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']); |
||
475 | $block = [ |
||
476 | 'title' => $myblock->getVar('title'), |
||
477 | 'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK, |
||
478 | // 'name' => $myblock->getVar('name'), |
||
479 | 'side' => $myblock->getVar('side'), |
||
480 | 'weight' => $myblock->getVar('weight'), |
||
481 | 'visible' => $myblock->getVar('visible'), |
||
482 | 'content' => $myblock->getVar('content', 'N'), |
||
483 | 'modules' => $modules, |
||
484 | 'is_custom' => $isCustom, |
||
485 | 'ctype' => $myblock->getVar('c_type'), |
||
486 | 'bcachetime' => $myblock->getVar('bcachetime'), |
||
487 | 'op' => 'edit_ok', |
||
488 | 'bid' => $myblock->getVar('bid'), |
||
489 | 'edit_form' => $myblock->getOptions(), |
||
490 | 'template' => $myblock->getVar('template'), |
||
491 | 'options' => $myblock->getVar('options'), |
||
492 | ]; |
||
493 | echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a> <span style="font-weight:bold;">»»</span> ' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>'; |
||
494 | |||
495 | echo $this->render($block); |
||
496 | } |
||
497 | |||
498 | public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void |
||
547 | } |
||
548 | |||
549 | public function orderBlock( |
||
602 | } |
||
603 | |||
604 | public function render(?array $block = null) |
||
605 | { |
||
606 | \xoops_load('XoopsFormLoader'); |
||
712 | } |
||
713 | } |
||
714 | |||
715 | |||
716 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.