ggoffy /
wgsitenotice
| 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 | * wgSitenotice module for xoops |
||||||
| 13 | * |
||||||
| 14 | * @copyright XOOPS Project (https://xoops.org) |
||||||
| 15 | * @license GPL 2.0 or later |
||||||
| 16 | * @package wgsitenotice |
||||||
| 17 | * @since 1.0 |
||||||
| 18 | * @min_xoops 2.5.11 |
||||||
| 19 | * @author Goffy (xoops.wedega.com) - Email:<[email protected]> - Website:<https://xoops.wedega.com> |
||||||
| 20 | */ |
||||||
| 21 | |||||||
| 22 | use Xmf\Request; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 23 | |||||||
| 24 | include_once __DIR__ . '/header.php'; |
||||||
| 25 | //It recovered the value of argument op in URL$ |
||||||
| 26 | $op = Request::getString('op', 'list'); |
||||||
| 27 | // Request cont_id |
||||||
| 28 | $cont_id = Request::getInt('cont_id'); |
||||||
| 29 | // Switch options |
||||||
| 30 | switch ($op) |
||||||
| 31 | { |
||||||
| 32 | case 'list': |
||||||
| 33 | default: |
||||||
| 34 | $GLOBALS['xoTheme']->addScript(\WGSITENOTICE_URL . '/assets/js/sortable-contents.js'); |
||||||
| 35 | $start = Request::getInt('start'); |
||||||
| 36 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||||||
| 37 | $template_main = 'wgsitenotice_admin_contents.tpl'; |
||||||
| 38 | $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation(\basename(__FILE__))); |
||||||
| 39 | $adminMenu->addItemButton(\_AM_WGSITENOTICE_CONTENT_ADD, 'contents.php?op=new'); |
||||||
| 40 | $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); |
||||||
| 41 | $cont_crit = new \CriteriaCompo(); |
||||||
|
0 ignored issues
–
show
The type
CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 42 | $cont_crit->setSort('cont_version_id ASC, cont_weight ASC, cont_id'); |
||||||
| 43 | $cont_crit->setOrder('ASC'); |
||||||
| 44 | $contents_rows = $contentsHandler->getCount($cont_crit); |
||||||
| 45 | $cont_crit->setStart($start); |
||||||
| 46 | $cont_crit->setLimit($limit); |
||||||
| 47 | $contents_arr = $contentsHandler->getAll($cont_crit); |
||||||
| 48 | unset($cont_crit); |
||||||
| 49 | $GLOBALS['xoopsTpl']->assign('wgsitenotice_url', \WGSITENOTICE_URL); |
||||||
| 50 | $GLOBALS['xoopsTpl']->assign('wgsitenotice_upload_url', \WGSITENOTICE_UPLOAD_URL); |
||||||
| 51 | $GLOBALS['xoopsTpl']->assign('wgsitenotice_icons_url', \WGSITENOTICE_ICONS_URL); |
||||||
| 52 | $GLOBALS['xoopsTpl']->assign('contents_count', $contents_rows); |
||||||
| 53 | // Table view |
||||||
| 54 | if ($contents_rows > 0) |
||||||
| 55 | { |
||||||
| 56 | $version_id_prev = 0; |
||||||
| 57 | $nb_conts_version = 0; |
||||||
| 58 | foreach (\array_keys($contents_arr) as $i) |
||||||
| 59 | { |
||||||
| 60 | // Get Var cont_id |
||||||
| 61 | $cont['id'] = $contents_arr[$i]->getVar('cont_id'); |
||||||
| 62 | // Get Var cont_version_id |
||||||
| 63 | $cont['version_id'] = $contents_arr[$i]->getVar('cont_version_id'); |
||||||
| 64 | $versions_obj = $versionsHandler->get($cont['version_id']); |
||||||
| 65 | if (\is_object($versions_obj)) { |
||||||
| 66 | $version_name = $versions_obj->getVar('version_name') . ' (' . \_AM_WGSITENOTICE_VERSION_ID . ' ' . $cont['version_id'] . ')'; |
||||||
| 67 | } else { |
||||||
| 68 | $version_name = '- (' . \_AM_WGSITENOTICE_VERSION_ID . ' ' . $cont['version_id'] . ') '; |
||||||
| 69 | } |
||||||
| 70 | $cont['version_name'] = $version_name; |
||||||
| 71 | // Get Var cont_header |
||||||
| 72 | $cont['header'] = $contents_arr[$i]->getVar('cont_header'); |
||||||
| 73 | // Get Var cont_weight |
||||||
| 74 | $cont['weight'] = $contents_arr[$i]->getVar('cont_weight'); |
||||||
| 75 | // Get Var cont_date |
||||||
| 76 | $cont['date'] = \formatTimestamp($contents_arr[$i]->getVar('cont_date')); |
||||||
|
0 ignored issues
–
show
The function
formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 77 | if ($version_id_prev == $cont['version_id']) { |
||||||
| 78 | $cont['new_version'] = 0; |
||||||
| 79 | $cont['nb_conts_version'] = $nb_conts_version; |
||||||
| 80 | } else { |
||||||
| 81 | $cont['new_version'] = 1; |
||||||
| 82 | $nb_conts = new \CriteriaCompo(); |
||||||
| 83 | $nb_conts->add(new \Criteria('cont_version_id', $cont['version_id'])); |
||||||
|
0 ignored issues
–
show
The type
Criteria was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 84 | $nb_conts_version = $contentsHandler->getCount($nb_conts); |
||||||
| 85 | $cont['nb_conts_version'] = $nb_conts_version; |
||||||
| 86 | $version_id_prev = $cont['version_id']; |
||||||
| 87 | } |
||||||
| 88 | $GLOBALS['xoopsTpl']->append('contents_list', $cont); |
||||||
| 89 | unset($cont); |
||||||
| 90 | } |
||||||
| 91 | if ( $contents_rows > $limit ) { |
||||||
| 92 | include_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 93 | $pagenav = new \XoopsPageNav($contents_rows, $limit, $start, 'start', 'op=list&limit=' . $limit); |
||||||
|
0 ignored issues
–
show
The type
XoopsPageNav was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 94 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
||||||
| 95 | } |
||||||
| 96 | } else { |
||||||
| 97 | $GLOBALS['xoopsTpl']->assign('error', \_AM_WGSITENOTICE_THEREARENT_CONTENTS); |
||||||
| 98 | } |
||||||
| 99 | break; |
||||||
| 100 | case 'new': |
||||||
| 101 | $template_main = 'wgsitenotice_admin_contents.tpl'; |
||||||
| 102 | $adminMenu->addItemButton(\_AM_WGSITENOTICE_CONTENTS_LIST, 'contents.php', 'list'); |
||||||
| 103 | $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation(\basename(__FILE__))); |
||||||
| 104 | $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); |
||||||
| 105 | // Get Form |
||||||
| 106 | $contentsObj = $contentsHandler->create(); |
||||||
| 107 | $form = $contentsObj->getForm(); |
||||||
| 108 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
| 109 | break; |
||||||
| 110 | case 'save': |
||||||
| 111 | if ( !$GLOBALS['xoopsSecurity']->check() ) { |
||||||
| 112 | \redirect_header('contents.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||||
|
0 ignored issues
–
show
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 113 | } |
||||||
| 114 | if (isset($cont_id)) { |
||||||
| 115 | $contentsObj = $contentsHandler->get($cont_id); |
||||||
| 116 | } else { |
||||||
| 117 | $contentsObj = $contentsHandler->create(); |
||||||
| 118 | } |
||||||
| 119 | // Set Vars |
||||||
| 120 | // Set Var cont_version_id |
||||||
| 121 | $contentsObj->setVar('cont_version_id', Request::getInt('cont_version_id')); |
||||||
| 122 | // Set Var cont_header |
||||||
| 123 | $contentsObj->setVar('cont_header', Request::getString('cont_header')); |
||||||
| 124 | // Set Var cont_text |
||||||
| 125 | //fix for avoid hiding empty paragraphs in some browsers (instead of: $contentsObj->setVar('cont_weight', $_POST['cont_weight']); |
||||||
| 126 | $cont_text = Request::getString('cont_text', '', 'default', 2); |
||||||
| 127 | $contentsObj->setVar('cont_text', \preg_replace('/<p><\/p>/', '<p> </p>', $cont_text)); |
||||||
| 128 | // Set Var cont_weight |
||||||
| 129 | $contentsObj->setVar('cont_weight', Request::getInt('cont_weight')); |
||||||
| 130 | // Set Var cont_date |
||||||
| 131 | $contentsObj->setVar('cont_date', \time()); |
||||||
| 132 | // Insert Data |
||||||
| 133 | if ($contentsHandler->insert($contentsObj)) { |
||||||
| 134 | \redirect_header('contents.php?op=list', 2, \_AM_WGSITENOTICE_FORMOK); |
||||||
| 135 | } |
||||||
| 136 | // Get Form |
||||||
| 137 | $GLOBALS['xoopsTpl']->assign('error', $contentsObj->getHtmlErrors()); |
||||||
| 138 | $form = $contentsObj->getForm(); |
||||||
| 139 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
| 140 | break; |
||||||
| 141 | case 'edit': |
||||||
| 142 | $template_main = 'wgsitenotice_admin_contents.tpl'; |
||||||
| 143 | $adminMenu->addItemButton(\_AM_WGSITENOTICE_CONTENT_ADD, 'contents.php?op=new'); |
||||||
| 144 | $adminMenu->addItemButton(\_AM_WGSITENOTICE_CONTENTS_LIST, 'contents.php', 'list'); |
||||||
| 145 | $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation(\basename(__FILE__))); |
||||||
| 146 | $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); |
||||||
| 147 | // Get Form |
||||||
| 148 | $contentsObj = $contentsHandler->get($cont_id); |
||||||
| 149 | $form = $contentsObj->getForm(); |
||||||
| 150 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
| 151 | break; |
||||||
| 152 | case 'delete': |
||||||
| 153 | $contentsObj = $contentsHandler->get($cont_id); |
||||||
| 154 | if (1 === Request::getInt('ok')) { |
||||||
| 155 | if ( !$GLOBALS['xoopsSecurity']->check() ) { |
||||||
| 156 | \redirect_header('contents.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||||||
| 157 | } |
||||||
| 158 | if ($contentsHandler->delete($contentsObj)) { |
||||||
| 159 | \redirect_header('contents.php', 3, \_AM_WGSITENOTICE_FORMDELOK); |
||||||
| 160 | } else { |
||||||
| 161 | echo $contentsObj->getHtmlErrors(); |
||||||
| 162 | } |
||||||
| 163 | } else { |
||||||
| 164 | xoops_confirm(['ok' => 1, 'cont_id' => $cont_id, 'op' => 'delete'], $_SERVER['REQUEST_URI'], \sprintf(\_AM_WGSITENOTICE_FORMSUREDEL, $contentsObj->getVar('cont_header', 'n') . ' (' . $contentsObj->getVar('cont_weight') . ')')); |
||||||
|
0 ignored issues
–
show
The function
xoops_confirm was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 165 | } |
||||||
| 166 | break; |
||||||
| 167 | |||||||
| 168 | case 'order': |
||||||
| 169 | $corder = Request::getArray('corder'); |
||||||
| 170 | for ($i = 0, $iMax = \count($corder); $i < $iMax; $i++){ |
||||||
| 171 | $contentsObj = $contentsHandler->get($corder[$i]); |
||||||
| 172 | $contentsObj->setVar('cont_weight',$i+1); |
||||||
| 173 | $contentsHandler->insert($contentsObj); |
||||||
| 174 | } |
||||||
| 175 | break; |
||||||
| 176 | } |
||||||
| 177 | include_once __DIR__ . '/footer.php'; |
||||||
| 178 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths