mambax7 /
smartfaq
| 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 | * PHP version 5 |
||||||
| 8 | * |
||||||
| 9 | * @category Module |
||||||
| 10 | * @author XOOPS Development Team |
||||||
| 11 | * @copyright XOOPS Project |
||||||
| 12 | * @link https://www.xoops.org |
||||||
| 13 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||||||
| 14 | */ |
||||||
| 15 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||||
| 16 | |||||||
| 17 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
| 18 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName |
||||||
| 19 | |||||||
| 20 | $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true); |
||||||
| 21 | if (isset($block['name'])) { |
||||||
| 22 | $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_NAME, $block['name'])); |
||||||
| 23 | } |
||||||
| 24 | $side_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']); |
||||||
| 25 | $side_select->addOptionArray([ |
||||||
| 26 | 0 => _AM_SYSTEM_BLOCKS_SBLEFT, |
||||||
| 27 | 1 => _AM_SYSTEM_BLOCKS_SBRIGHT, |
||||||
| 28 | 3 => _AM_SYSTEM_BLOCKS_CBLEFT, |
||||||
| 29 | 4 => _AM_SYSTEM_BLOCKS_CBRIGHT, |
||||||
| 30 | 5 => _AM_SYSTEM_BLOCKS_CBCENTER, |
||||||
| 31 | 7 => _AM_SYSTEM_BLOCKS_CBBOTTOMLEFT, |
||||||
| 32 | 8 => _AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT, |
||||||
| 33 | 9 => _AM_SYSTEM_BLOCKS_CBBOTTOM, |
||||||
| 34 | ]); |
||||||
| 35 | $form->addElement($side_select); |
||||||
| 36 | $form->addElement(new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight'])); |
||||||
| 37 | $form->addElement(new \XoopsFormRadioYN(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible'])); |
||||||
| 38 | $mod_select = new \XoopsFormSelect(constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true); |
||||||
| 39 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||||
| 40 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 41 | $criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); |
||||||
| 42 | $criteria->add(new \Criteria('isactive', 1)); |
||||||
| 43 | $module_list = $moduleHandler->getList($criteria); |
||||||
| 44 | $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; |
||||||
| 45 | $module_list[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; |
||||||
| 46 | ksort($module_list); |
||||||
| 47 | $mod_select->addOptionArray($module_list); |
||||||
| 48 | $form->addElement($mod_select); |
||||||
| 49 | $form->addElement(new \XoopsFormText(_AM_TITLE, 'btitle', 50, 255, $block['title']), false); |
||||||
| 50 | if ($block['is_custom']) { |
||||||
| 51 | $textarea = new \XoopsFormDhtmlTextArea(_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70); |
||||||
| 52 | $textarea->setDescription('<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>'); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 53 | $form->addElement($textarea, true); |
||||||
| 54 | $ctype_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']); |
||||||
| 55 | $ctype_select->addOptionArray([ |
||||||
| 56 | 'H' => _AM_SYSTEM_BLOCKS_HTML, |
||||||
| 57 | 'P' => _AM_SYSTEM_BLOCKS_PHP, |
||||||
| 58 | 'S' => _AM_SYSTEM_BLOCKS_AFWSMILE, |
||||||
| 59 | 'T' => _AM_SYSTEM_BLOCKS_AFNOSMILE, |
||||||
| 60 | ]); |
||||||
| 61 | $form->addElement($ctype_select); |
||||||
| 62 | } else { |
||||||
| 63 | if ('' !== $block['template']) { |
||||||
| 64 | $tplfileHandler = xoops_getHandler('tplfile'); |
||||||
| 65 | $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']); |
||||||
|
0 ignored issues
–
show
The method
find() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsTplfileHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 66 | if (count($btemplate) > 0) { |
||||||
| 67 | $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>')); |
||||||
| 68 | } else { |
||||||
| 69 | $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']); |
||||||
| 70 | if (count($btemplate2) > 0) { |
||||||
| 71 | $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>')); |
||||||
| 72 | } |
||||||
| 73 | } |
||||||
| 74 | } |
||||||
| 75 | if (false !== $block['edit_form']) { |
||||||
| 76 | $form->addElement(new \XoopsFormLabel(_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form'])); |
||||||
| 77 | } |
||||||
| 78 | } |
||||||
| 79 | $cache_select = new \XoopsFormSelect(_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']); |
||||||
| 80 | $cache_select->addOptionArray([ |
||||||
| 81 | '0' => _NOCACHE, |
||||||
| 82 | '30' => sprintf(_SECONDS, 30), |
||||||
| 83 | '60' => _MINUTE, |
||||||
| 84 | '300' => sprintf(_MINUTES, 5), |
||||||
| 85 | '1800' => sprintf(_MINUTES, 30), |
||||||
| 86 | '3600' => _HOUR, |
||||||
| 87 | '18000' => sprintf(_HOURS, 5), |
||||||
| 88 | '86400' => _DAY, |
||||||
| 89 | '259200' => sprintf(_DAYS, 3), |
||||||
| 90 | '604800' => _WEEK, |
||||||
| 91 | '2592000' => _MONTH, |
||||||
| 92 | ]); |
||||||
| 93 | $form->addElement($cache_select); |
||||||
| 94 | |||||||
| 95 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 96 | $groups = $grouppermHandler->getGroupIds('block_read', $block['bid']); |
||||||
|
0 ignored issues
–
show
The method
getGroupIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 97 | |||||||
| 98 | $form->addElement(new \XoopsFormSelectGroup(_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true)); |
||||||
| 99 | |||||||
| 100 | if (isset($block['bid'])) { |
||||||
| 101 | $form->addElement(new \XoopsFormHidden('bid', $block['bid'])); |
||||||
| 102 | } |
||||||
| 103 | $form->addElement(new \XoopsFormHidden('op', $block['op'])); |
||||||
| 104 | $form->addElement(new \XoopsFormHidden('fct', 'blocksadmin')); |
||||||
| 105 | $buttonTray = new \XoopsFormElementTray('', ' '); |
||||||
| 106 | if ($block['is_custom']) { |
||||||
| 107 | $buttonTray->addElement(new \XoopsFormButton('', 'previewblock', _PREVIEW, 'submit')); |
||||||
| 108 | } |
||||||
| 109 | |||||||
| 110 | //Submit buttons |
||||||
| 111 | $buttonTray = new \XoopsFormElementTray('', ''); |
||||||
| 112 | $submit_button = new \XoopsFormButton('', 'submitblock', _SUBMIT, 'submit'); |
||||||
| 113 | $buttonTray->addElement($submit_button); |
||||||
| 114 | |||||||
| 115 | $cancel_button = new \XoopsFormButton('', '', _CANCEL, 'button'); |
||||||
| 116 | $cancel_button->setExtra('onclick="history.go(-1)"'); |
||||||
| 117 | $buttonTray->addElement($cancel_button); |
||||||
| 118 | |||||||
| 119 | $form->addElement($buttonTray); |
||||||
| 120 |