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