@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | use Xmf\Module\Admin; |
| 4 | 4 | use Xmf\Request; |
| 5 | 5 | use XoopsModules\Songlist\{ |
| 6 | - Form\FormController, |
|
| 7 | - Helper, |
|
| 8 | - Category, |
|
| 9 | - CategoryHandler, |
|
| 10 | - Uploader |
|
| 6 | + Form\FormController, |
|
| 7 | + Helper, |
|
| 8 | + Category, |
|
| 9 | + CategoryHandler, |
|
| 10 | + Uploader |
|
| 11 | 11 | }; |
| 12 | 12 | |
| 13 | 13 | /** @var Category $category */ |
@@ -27,102 +27,102 @@ discard block |
||
| 27 | 27 | $filter = Request::getString('filter', '1,1', 'REQUEST'); |
| 28 | 28 | |
| 29 | 29 | switch ($op) { |
| 30 | - default: |
|
| 31 | - case 'category': |
|
| 32 | - switch ($fct) { |
|
| 33 | - default: |
|
| 34 | - case 'list': |
|
| 35 | - $adminObject = Admin::getInstance(); |
|
| 36 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | - |
|
| 38 | - /** @var CategoryHandler $categoryHandler */ |
|
| 39 | - $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 40 | - |
|
| 41 | - $criteria = $categoryHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | - $ttl = $categoryHandler->getCount($criteria); |
|
| 43 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 44 | - |
|
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | - |
|
| 48 | - foreach ($categoryHandler->filterFields() as $id => $key) { |
|
| 49 | - $GLOBALS['xoopsTpl']->assign( |
|
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | - '<a href="' |
|
| 52 | - . $_SERVER['SCRIPT_NAME'] |
|
| 53 | - . '?start=' |
|
| 54 | - . $GLOBALS['start'] |
|
| 55 | - . '&limit=' |
|
| 56 | - . $GLOBALS['limit'] |
|
| 57 | - . '&sort=' |
|
| 58 | - . $key |
|
| 59 | - . '&order=' |
|
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | - . '&op=' |
|
| 62 | - . $GLOBALS['op'] |
|
| 63 | - . '&filter=' |
|
| 64 | - . $GLOBALS['filter'] |
|
| 65 | - . '">' |
|
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | - . '</a>' |
|
| 68 | - ); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $categoryHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | - |
|
| 79 | - $criteria->setStart($GLOBALS['start']); |
|
| 80 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | - $criteria->setOrder($GLOBALS['order']); |
|
| 83 | - |
|
| 84 | - $categorys = $categoryHandler->getObjects($criteria, true); |
|
| 85 | - foreach ($categorys as $cid => $category) { |
|
| 86 | - if (is_object($category)) { |
|
| 87 | - $GLOBALS['xoopsTpl']->append('categories', $category->toArray()); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormCategory(false)); |
|
| 91 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_category_list.tpl'); |
|
| 93 | - break; |
|
| 94 | - case 'new': |
|
| 95 | - case 'edit': |
|
| 96 | - $adminObject = Admin::getInstance(); |
|
| 97 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | - |
|
| 99 | - $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 100 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | - $category = $categoryHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | - } else { |
|
| 103 | - $category = $categoryHandler->create(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $GLOBALS['xoopsTpl']->assign('form', $category->getForm()); |
|
| 107 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_category_edit.tpl'); |
|
| 109 | - break; |
|
| 110 | - case 'save': |
|
| 111 | - $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 112 | - $id = 0; |
|
| 113 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | - if ($id) { |
|
| 115 | - $category = $categoryHandler->get($id); |
|
| 116 | - } else { |
|
| 117 | - $category = $categoryHandler->create(); |
|
| 118 | - } |
|
| 119 | - $category->setVars($_POST[$id]); |
|
| 120 | - |
|
| 121 | - if (!$id = $categoryHandler->insert($category)) { |
|
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_FAILEDTOSAVE); |
|
| 123 | - exit(0); |
|
| 124 | - } |
|
| 125 | - if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 30 | + default: |
|
| 31 | + case 'category': |
|
| 32 | + switch ($fct) { |
|
| 33 | + default: |
|
| 34 | + case 'list': |
|
| 35 | + $adminObject = Admin::getInstance(); |
|
| 36 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | + |
|
| 38 | + /** @var CategoryHandler $categoryHandler */ |
|
| 39 | + $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 40 | + |
|
| 41 | + $criteria = $categoryHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | + $ttl = $categoryHandler->getCount($criteria); |
|
| 43 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 44 | + |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | + |
|
| 48 | + foreach ($categoryHandler->filterFields() as $id => $key) { |
|
| 49 | + $GLOBALS['xoopsTpl']->assign( |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | + '<a href="' |
|
| 52 | + . $_SERVER['SCRIPT_NAME'] |
|
| 53 | + . '?start=' |
|
| 54 | + . $GLOBALS['start'] |
|
| 55 | + . '&limit=' |
|
| 56 | + . $GLOBALS['limit'] |
|
| 57 | + . '&sort=' |
|
| 58 | + . $key |
|
| 59 | + . '&order=' |
|
| 60 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | + . '&op=' |
|
| 62 | + . $GLOBALS['op'] |
|
| 63 | + . '&filter=' |
|
| 64 | + . $GLOBALS['filter'] |
|
| 65 | + . '">' |
|
| 66 | + . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | + . '</a>' |
|
| 68 | + ); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $categoryHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | + |
|
| 79 | + $criteria->setStart($GLOBALS['start']); |
|
| 80 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | + $criteria->setOrder($GLOBALS['order']); |
|
| 83 | + |
|
| 84 | + $categorys = $categoryHandler->getObjects($criteria, true); |
|
| 85 | + foreach ($categorys as $cid => $category) { |
|
| 86 | + if (is_object($category)) { |
|
| 87 | + $GLOBALS['xoopsTpl']->append('categories', $category->toArray()); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormCategory(false)); |
|
| 91 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_category_list.tpl'); |
|
| 93 | + break; |
|
| 94 | + case 'new': |
|
| 95 | + case 'edit': |
|
| 96 | + $adminObject = Admin::getInstance(); |
|
| 97 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | + |
|
| 99 | + $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 100 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | + $category = $categoryHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | + } else { |
|
| 103 | + $category = $categoryHandler->create(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('form', $category->getForm()); |
|
| 107 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_category_edit.tpl'); |
|
| 109 | + break; |
|
| 110 | + case 'save': |
|
| 111 | + $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 112 | + $id = 0; |
|
| 113 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | + if ($id) { |
|
| 115 | + $category = $categoryHandler->get($id); |
|
| 116 | + } else { |
|
| 117 | + $category = $categoryHandler->create(); |
|
| 118 | + } |
|
| 119 | + $category->setVars($_POST[$id]); |
|
| 120 | + |
|
| 121 | + if (!$id = $categoryHandler->insert($category)) { |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_FAILEDTOSAVE); |
|
| 123 | + exit(0); |
|
| 124 | + } |
|
| 125 | + if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 126 | 126 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
| 127 | 127 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
| 128 | 128 | // foreach (explode('/', $folders) as $folder) { |
@@ -135,95 +135,95 @@ discard block |
||
| 135 | 135 | // } |
| 136 | 136 | |
| 137 | 137 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 138 | - $category = $categoryHandler->get($id); |
|
| 139 | - $uploader = new Uploader( |
|
| 140 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 141 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 142 | - $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 143 | - 0, |
|
| 144 | - 0, |
|
| 145 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 146 | - ); |
|
| 147 | - try { |
|
| 148 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 149 | - } catch (Exception $e) { |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($uploader->fetchMedia('image')) { |
|
| 153 | - if (!$uploader->upload()) { |
|
| 154 | - $adminObject = Admin::getInstance(); |
|
| 155 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 156 | - echo $uploader->getErrors(); |
|
| 157 | - require __DIR__ . '/admin_footer.php'; |
|
| 158 | - exit(0); |
|
| 159 | - } |
|
| 160 | - if (mb_strlen($category->getVar('image'))) { |
|
| 161 | - unlink($GLOBALS['xoops']->path($category->getVar('path')) . $category->getVar('image')); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $category->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 165 | - $category->setVar('image', $uploader->getSavedFileName()); |
|
| 166 | - @$categoryHandler->insert($category); |
|
| 167 | - } else { |
|
| 168 | - $adminObject = Admin::getInstance(); |
|
| 169 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 170 | - echo $uploader->getErrors(); |
|
| 171 | - require __DIR__ . '/admin_footer.php'; |
|
| 172 | - exit(0); |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | - redirect_header( |
|
| 178 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 179 | - 10, |
|
| 180 | - _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY |
|
| 181 | - ); |
|
| 182 | - } else { |
|
| 183 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 184 | - } |
|
| 185 | - exit(0); |
|
| 186 | - case 'savelist': |
|
| 187 | - $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 188 | - foreach ($_REQUEST['id'] as $id) { |
|
| 189 | - $category = $categoryHandler->get($id); |
|
| 190 | - $category->setVars($_POST[$id]); |
|
| 191 | - if (!$categoryHandler->insert($category)) { |
|
| 192 | - redirect_header( |
|
| 193 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 194 | - 10, |
|
| 195 | - _AM_SONGLIST_MSG_CATEGORY_FAILEDTOSAVE |
|
| 196 | - ); |
|
| 197 | - exit(0); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 201 | - exit(0); |
|
| 202 | - case 'delete': |
|
| 203 | - $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 204 | - $id = 0; |
|
| 205 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 206 | - $category = $categoryHandler->get($id); |
|
| 207 | - if (!$categoryHandler->delete($category)) { |
|
| 208 | - redirect_header( |
|
| 209 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 210 | - 10, |
|
| 211 | - _AM_SONGLIST_MSG_CATEGORY_FAILEDTODELETE |
|
| 212 | - ); |
|
| 213 | - exit(0); |
|
| 214 | - } |
|
| 215 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_DELETED); |
|
| 216 | - exit(0); |
|
| 217 | - } |
|
| 218 | - $category = $categoryHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 219 | - xoops_confirm( |
|
| 220 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 221 | - $_SERVER['SCRIPT_NAME'], |
|
| 222 | - sprintf(_AM_SONGLIST_MSG_CATEGORY_DELETE, $category->getVar('name')) |
|
| 223 | - ); |
|
| 224 | - |
|
| 225 | - break; |
|
| 226 | - } |
|
| 138 | + $category = $categoryHandler->get($id); |
|
| 139 | + $uploader = new Uploader( |
|
| 140 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 141 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 142 | + $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 143 | + 0, |
|
| 144 | + 0, |
|
| 145 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 146 | + ); |
|
| 147 | + try { |
|
| 148 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 149 | + } catch (Exception $e) { |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($uploader->fetchMedia('image')) { |
|
| 153 | + if (!$uploader->upload()) { |
|
| 154 | + $adminObject = Admin::getInstance(); |
|
| 155 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 156 | + echo $uploader->getErrors(); |
|
| 157 | + require __DIR__ . '/admin_footer.php'; |
|
| 158 | + exit(0); |
|
| 159 | + } |
|
| 160 | + if (mb_strlen($category->getVar('image'))) { |
|
| 161 | + unlink($GLOBALS['xoops']->path($category->getVar('path')) . $category->getVar('image')); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $category->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 165 | + $category->setVar('image', $uploader->getSavedFileName()); |
|
| 166 | + @$categoryHandler->insert($category); |
|
| 167 | + } else { |
|
| 168 | + $adminObject = Admin::getInstance(); |
|
| 169 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 170 | + echo $uploader->getErrors(); |
|
| 171 | + require __DIR__ . '/admin_footer.php'; |
|
| 172 | + exit(0); |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | + redirect_header( |
|
| 178 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 179 | + 10, |
|
| 180 | + _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY |
|
| 181 | + ); |
|
| 182 | + } else { |
|
| 183 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 184 | + } |
|
| 185 | + exit(0); |
|
| 186 | + case 'savelist': |
|
| 187 | + $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 188 | + foreach ($_REQUEST['id'] as $id) { |
|
| 189 | + $category = $categoryHandler->get($id); |
|
| 190 | + $category->setVars($_POST[$id]); |
|
| 191 | + if (!$categoryHandler->insert($category)) { |
|
| 192 | + redirect_header( |
|
| 193 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 194 | + 10, |
|
| 195 | + _AM_SONGLIST_MSG_CATEGORY_FAILEDTOSAVE |
|
| 196 | + ); |
|
| 197 | + exit(0); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 201 | + exit(0); |
|
| 202 | + case 'delete': |
|
| 203 | + $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
| 204 | + $id = 0; |
|
| 205 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 206 | + $category = $categoryHandler->get($id); |
|
| 207 | + if (!$categoryHandler->delete($category)) { |
|
| 208 | + redirect_header( |
|
| 209 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 210 | + 10, |
|
| 211 | + _AM_SONGLIST_MSG_CATEGORY_FAILEDTODELETE |
|
| 212 | + ); |
|
| 213 | + exit(0); |
|
| 214 | + } |
|
| 215 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_DELETED); |
|
| 216 | + exit(0); |
|
| 217 | + } |
|
| 218 | + $category = $categoryHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 219 | + xoops_confirm( |
|
| 220 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 221 | + $_SERVER['SCRIPT_NAME'], |
|
| 222 | + sprintf(_AM_SONGLIST_MSG_CATEGORY_DELETE, $category->getVar('name')) |
|
| 223 | + ); |
|
| 224 | + |
|
| 225 | + break; |
|
| 226 | + } |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | xoops_cp_footer(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | /** @var Category $category */ |
| 14 | 14 | |
| 15 | -require __DIR__ . '/header.php'; |
|
| 15 | +require __DIR__.'/header.php'; |
|
| 16 | 16 | |
| 17 | 17 | xoops_loadLanguage('admin', 'songlist'); |
| 18 | 18 | |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $criteria = $categoryHandler->getFilterCriteria($GLOBALS['filter']); |
| 42 | 42 | $ttl = $categoryHandler->getCount($criteria); |
| 43 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 43 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); ; |
|
| 44 | 44 | |
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']); |
|
| 46 | 46 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 47 | 47 | |
| 48 | 48 | foreach ($categoryHandler->filterFields() as $id => $key) { |
| 49 | 49 | $GLOBALS['xoopsTpl']->assign( |
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 51 | 51 | '<a href="' |
| 52 | 52 | . $_SERVER['SCRIPT_NAME'] |
| 53 | 53 | . '?start=' |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | . '&sort=' |
| 58 | 58 | . $key |
| 59 | 59 | . '&order=' |
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | 61 | . '&op=' |
| 62 | 62 | . $GLOBALS['op'] |
| 63 | 63 | . '&filter=' |
| 64 | 64 | . $GLOBALS['filter'] |
| 65 | 65 | . '">' |
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | + . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | 67 | . '</a>' |
| 68 | 68 | ); |
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $categoryHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $categoryHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $criteria->setStart($GLOBALS['start']); |
| 80 | 80 | $criteria->setLimit($GLOBALS['limit']); |
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 82 | 82 | $criteria->setOrder($GLOBALS['order']); |
| 83 | 83 | |
| 84 | 84 | $categorys = $categoryHandler->getObjects($criteria, true); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $category->setVars($_POST[$id]); |
| 120 | 120 | |
| 121 | 121 | if (!$id = $categoryHandler->insert($category)) { |
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_FAILEDTOSAVE); |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_FAILEDTOSAVE); |
|
| 123 | 123 | exit(0); |
| 124 | 124 | } |
| 125 | 125 | if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
| 146 | 146 | ); |
| 147 | 147 | try { |
| 148 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 148 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
| 149 | 149 | } catch (Exception $e) { |
| 150 | 150 | } |
| 151 | 151 | |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | $adminObject = Admin::getInstance(); |
| 155 | 155 | $adminObject->displayNavigation(basename(__FILE__)); |
| 156 | 156 | echo $uploader->getErrors(); |
| 157 | - require __DIR__ . '/admin_footer.php'; |
|
| 157 | + require __DIR__.'/admin_footer.php'; |
|
| 158 | 158 | exit(0); |
| 159 | 159 | } |
| 160 | 160 | if (mb_strlen($category->getVar('image'))) { |
| 161 | - unlink($GLOBALS['xoops']->path($category->getVar('path')) . $category->getVar('image')); |
|
| 161 | + unlink($GLOBALS['xoops']->path($category->getVar('path')).$category->getVar('image')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $category->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
@@ -168,19 +168,19 @@ discard block |
||
| 168 | 168 | $adminObject = Admin::getInstance(); |
| 169 | 169 | $adminObject->displayNavigation(basename(__FILE__)); |
| 170 | 170 | echo $uploader->getErrors(); |
| 171 | - require __DIR__ . '/admin_footer.php'; |
|
| 171 | + require __DIR__.'/admin_footer.php'; |
|
| 172 | 172 | exit(0); |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 176 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | 177 | redirect_header( |
| 178 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 178 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 179 | 179 | 10, |
| 180 | 180 | _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY |
| 181 | 181 | ); |
| 182 | 182 | } else { |
| 183 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 183 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 184 | 184 | } |
| 185 | 185 | exit(0); |
| 186 | 186 | case 'savelist': |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | $category->setVars($_POST[$id]); |
| 191 | 191 | if (!$categoryHandler->insert($category)) { |
| 192 | 192 | redirect_header( |
| 193 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 193 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 194 | 194 | 10, |
| 195 | 195 | _AM_SONGLIST_MSG_CATEGORY_FAILEDTOSAVE |
| 196 | 196 | ); |
| 197 | 197 | exit(0); |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 200 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_SAVEDOKEY); |
|
| 201 | 201 | exit(0); |
| 202 | 202 | case 'delete': |
| 203 | 203 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | $category = $categoryHandler->get($id); |
| 207 | 207 | if (!$categoryHandler->delete($category)) { |
| 208 | 208 | redirect_header( |
| 209 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 209 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 210 | 210 | 10, |
| 211 | 211 | _AM_SONGLIST_MSG_CATEGORY_FAILEDTODELETE |
| 212 | 212 | ); |
| 213 | 213 | exit(0); |
| 214 | 214 | } |
| 215 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_DELETED); |
|
| 215 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_CATEGORY_DELETED); |
|
| 216 | 216 | exit(0); |
| 217 | 217 | } |
| 218 | 218 | $category = $categoryHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -3,10 +3,10 @@ discard block |
||
| 3 | 3 | use Xmf\Module\Admin; |
| 4 | 4 | use Xmf\Request; |
| 5 | 5 | use XoopsModules\Songlist\{ |
| 6 | - Form\FormController, |
|
| 7 | - Helper, |
|
| 8 | - Voice, |
|
| 9 | - VoiceHandler, |
|
| 6 | + Form\FormController, |
|
| 7 | + Helper, |
|
| 8 | + Voice, |
|
| 9 | + VoiceHandler, |
|
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | /** @var Voice $voice */ |
@@ -26,152 +26,152 @@ discard block |
||
| 26 | 26 | $filter = Request::getString('filter', '1,1', 'REQUEST'); |
| 27 | 27 | |
| 28 | 28 | switch ($op) { |
| 29 | - default: |
|
| 30 | - case 'voice': |
|
| 31 | - switch ($fct) { |
|
| 32 | - default: |
|
| 33 | - case 'list': |
|
| 34 | - $adminObject = Admin::getInstance(); |
|
| 35 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 36 | - |
|
| 37 | - /** @var VoiceHandler $voiceHandler */ |
|
| 38 | - $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 39 | - |
|
| 40 | - $criteria = $voiceHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 41 | - $ttl = $voiceHandler->getCount($criteria); |
|
| 42 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 43 | - |
|
| 44 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 46 | - |
|
| 47 | - foreach ($voiceHandler->filterFields() as $id => $key) { |
|
| 48 | - $GLOBALS['xoopsTpl']->assign( |
|
| 49 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | - '<a href="' |
|
| 51 | - . $_SERVER['SCRIPT_NAME'] |
|
| 52 | - . '?start=' |
|
| 53 | - . $GLOBALS['start'] |
|
| 54 | - . '&limit=' |
|
| 55 | - . $GLOBALS['limit'] |
|
| 56 | - . '&sort=' |
|
| 57 | - . $key |
|
| 58 | - . '&order=' |
|
| 59 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | - . '&op=' |
|
| 61 | - . $GLOBALS['op'] |
|
| 62 | - . '&filter=' |
|
| 63 | - . $GLOBALS['filter'] |
|
| 64 | - . '">' |
|
| 65 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | - . '</a>' |
|
| 67 | - ); |
|
| 68 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $voiceHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 73 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 74 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 75 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 76 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 77 | - |
|
| 78 | - $criteria->setStart($GLOBALS['start']); |
|
| 79 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 80 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | - $criteria->setOrder($GLOBALS['order']); |
|
| 82 | - |
|
| 83 | - $voices = $voiceHandler->getObjects($criteria, true); |
|
| 84 | - foreach ($voices as $cid => $voice) { |
|
| 85 | - if (is_object($voice)) { |
|
| 86 | - $GLOBALS['xoopsTpl']->append('voice', $voice->toArray()); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormVoice(false)); |
|
| 90 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 91 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_voice_list.tpl'); |
|
| 92 | - break; |
|
| 93 | - case 'new': |
|
| 94 | - case 'edit': |
|
| 95 | - $adminObject = Admin::getInstance(); |
|
| 96 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 97 | - |
|
| 98 | - $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 99 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 100 | - $voice = $voiceHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 101 | - } else { |
|
| 102 | - $voice = $voiceHandler->create(); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $GLOBALS['xoopsTpl']->assign('form', $voice->getForm()); |
|
| 106 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 107 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_voice_edit.tpl'); |
|
| 108 | - break; |
|
| 109 | - case 'save': |
|
| 110 | - $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 111 | - $id = 0; |
|
| 112 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 113 | - if ($id) { |
|
| 114 | - $voice = $voiceHandler->get($id); |
|
| 115 | - } else { |
|
| 116 | - $voice = $voiceHandler->create(); |
|
| 117 | - } |
|
| 118 | - $voice->setVars($_POST[$id]); |
|
| 119 | - |
|
| 120 | - if (!$id = $voiceHandler->insert($voice)) { |
|
| 121 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_FAILEDTOSAVE); |
|
| 122 | - exit(0); |
|
| 123 | - } |
|
| 124 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 125 | - redirect_header( |
|
| 126 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 127 | - 10, |
|
| 128 | - _AM_SONGLIST_MSG_VOICE_SAVEDOKEY |
|
| 129 | - ); |
|
| 130 | - } else { |
|
| 131 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 132 | - } |
|
| 133 | - exit(0); |
|
| 134 | - case 'savelist': |
|
| 135 | - $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 136 | - foreach ($_REQUEST['id'] as $id) { |
|
| 137 | - $voice = $voiceHandler->get($id); |
|
| 138 | - $voice->setVars($_POST[$id]); |
|
| 139 | - if (!$voiceHandler->insert($voice)) { |
|
| 140 | - redirect_header( |
|
| 141 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 142 | - 10, |
|
| 143 | - _AM_SONGLIST_MSG_VOICE_FAILEDTOSAVE |
|
| 144 | - ); |
|
| 145 | - exit(0); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 149 | - exit(0); |
|
| 150 | - case 'delete': |
|
| 151 | - $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 152 | - $id = 0; |
|
| 153 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 154 | - $voice = $voiceHandler->get($id); |
|
| 155 | - if (!$voiceHandler->delete($voice)) { |
|
| 156 | - redirect_header( |
|
| 157 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 158 | - 10, |
|
| 159 | - _AM_SONGLIST_MSG_VOICE_FAILEDTODELETE |
|
| 160 | - ); |
|
| 161 | - exit(0); |
|
| 162 | - } |
|
| 163 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_DELETED); |
|
| 164 | - exit(0); |
|
| 165 | - } |
|
| 166 | - $voice = $voiceHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 167 | - xoops_confirm( |
|
| 168 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 169 | - $_SERVER['SCRIPT_NAME'], |
|
| 170 | - sprintf(_AM_SONGLIST_MSG_VOICE_DELETE, $voice->getVar('name')) |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - break; |
|
| 174 | - } |
|
| 29 | + default: |
|
| 30 | + case 'voice': |
|
| 31 | + switch ($fct) { |
|
| 32 | + default: |
|
| 33 | + case 'list': |
|
| 34 | + $adminObject = Admin::getInstance(); |
|
| 35 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 36 | + |
|
| 37 | + /** @var VoiceHandler $voiceHandler */ |
|
| 38 | + $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 39 | + |
|
| 40 | + $criteria = $voiceHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 41 | + $ttl = $voiceHandler->getCount($criteria); |
|
| 42 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 43 | + |
|
| 44 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 46 | + |
|
| 47 | + foreach ($voiceHandler->filterFields() as $id => $key) { |
|
| 48 | + $GLOBALS['xoopsTpl']->assign( |
|
| 49 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | + '<a href="' |
|
| 51 | + . $_SERVER['SCRIPT_NAME'] |
|
| 52 | + . '?start=' |
|
| 53 | + . $GLOBALS['start'] |
|
| 54 | + . '&limit=' |
|
| 55 | + . $GLOBALS['limit'] |
|
| 56 | + . '&sort=' |
|
| 57 | + . $key |
|
| 58 | + . '&order=' |
|
| 59 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | + . '&op=' |
|
| 61 | + . $GLOBALS['op'] |
|
| 62 | + . '&filter=' |
|
| 63 | + . $GLOBALS['filter'] |
|
| 64 | + . '">' |
|
| 65 | + . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | + . '</a>' |
|
| 67 | + ); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $voiceHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 73 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 74 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 75 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 76 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 77 | + |
|
| 78 | + $criteria->setStart($GLOBALS['start']); |
|
| 79 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 80 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | + $criteria->setOrder($GLOBALS['order']); |
|
| 82 | + |
|
| 83 | + $voices = $voiceHandler->getObjects($criteria, true); |
|
| 84 | + foreach ($voices as $cid => $voice) { |
|
| 85 | + if (is_object($voice)) { |
|
| 86 | + $GLOBALS['xoopsTpl']->append('voice', $voice->toArray()); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormVoice(false)); |
|
| 90 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 91 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_voice_list.tpl'); |
|
| 92 | + break; |
|
| 93 | + case 'new': |
|
| 94 | + case 'edit': |
|
| 95 | + $adminObject = Admin::getInstance(); |
|
| 96 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 97 | + |
|
| 98 | + $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 99 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 100 | + $voice = $voiceHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 101 | + } else { |
|
| 102 | + $voice = $voiceHandler->create(); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $GLOBALS['xoopsTpl']->assign('form', $voice->getForm()); |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 107 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_voice_edit.tpl'); |
|
| 108 | + break; |
|
| 109 | + case 'save': |
|
| 110 | + $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 111 | + $id = 0; |
|
| 112 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 113 | + if ($id) { |
|
| 114 | + $voice = $voiceHandler->get($id); |
|
| 115 | + } else { |
|
| 116 | + $voice = $voiceHandler->create(); |
|
| 117 | + } |
|
| 118 | + $voice->setVars($_POST[$id]); |
|
| 119 | + |
|
| 120 | + if (!$id = $voiceHandler->insert($voice)) { |
|
| 121 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_FAILEDTOSAVE); |
|
| 122 | + exit(0); |
|
| 123 | + } |
|
| 124 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 125 | + redirect_header( |
|
| 126 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 127 | + 10, |
|
| 128 | + _AM_SONGLIST_MSG_VOICE_SAVEDOKEY |
|
| 129 | + ); |
|
| 130 | + } else { |
|
| 131 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 132 | + } |
|
| 133 | + exit(0); |
|
| 134 | + case 'savelist': |
|
| 135 | + $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 136 | + foreach ($_REQUEST['id'] as $id) { |
|
| 137 | + $voice = $voiceHandler->get($id); |
|
| 138 | + $voice->setVars($_POST[$id]); |
|
| 139 | + if (!$voiceHandler->insert($voice)) { |
|
| 140 | + redirect_header( |
|
| 141 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 142 | + 10, |
|
| 143 | + _AM_SONGLIST_MSG_VOICE_FAILEDTOSAVE |
|
| 144 | + ); |
|
| 145 | + exit(0); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 149 | + exit(0); |
|
| 150 | + case 'delete': |
|
| 151 | + $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
|
| 152 | + $id = 0; |
|
| 153 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 154 | + $voice = $voiceHandler->get($id); |
|
| 155 | + if (!$voiceHandler->delete($voice)) { |
|
| 156 | + redirect_header( |
|
| 157 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 158 | + 10, |
|
| 159 | + _AM_SONGLIST_MSG_VOICE_FAILEDTODELETE |
|
| 160 | + ); |
|
| 161 | + exit(0); |
|
| 162 | + } |
|
| 163 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_DELETED); |
|
| 164 | + exit(0); |
|
| 165 | + } |
|
| 166 | + $voice = $voiceHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 167 | + xoops_confirm( |
|
| 168 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 169 | + $_SERVER['SCRIPT_NAME'], |
|
| 170 | + sprintf(_AM_SONGLIST_MSG_VOICE_DELETE, $voice->getVar('name')) |
|
| 171 | + ); |
|
| 172 | + |
|
| 173 | + break; |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | xoops_cp_footer(); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | /** @var Voice $voice */ |
| 13 | 13 | |
| 14 | -require __DIR__ . '/header.php'; |
|
| 14 | +require __DIR__.'/header.php'; |
|
| 15 | 15 | |
| 16 | 16 | xoops_loadLanguage('admin', 'songlist'); |
| 17 | 17 | |
@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $criteria = $voiceHandler->getFilterCriteria($GLOBALS['filter']); |
| 41 | 41 | $ttl = $voiceHandler->getCount($criteria); |
| 42 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 42 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); ; |
|
| 43 | 43 | |
| 44 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 44 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']); |
|
| 45 | 45 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 46 | 46 | |
| 47 | 47 | foreach ($voiceHandler->filterFields() as $id => $key) { |
| 48 | 48 | $GLOBALS['xoopsTpl']->assign( |
| 49 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 49 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 50 | 50 | '<a href="' |
| 51 | 51 | . $_SERVER['SCRIPT_NAME'] |
| 52 | 52 | . '?start=' |
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | . '&sort=' |
| 57 | 57 | . $key |
| 58 | 58 | . '&order=' |
| 59 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 59 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | 60 | . '&op=' |
| 61 | 61 | . $GLOBALS['op'] |
| 62 | 62 | . '&filter=' |
| 63 | 63 | . $GLOBALS['filter'] |
| 64 | 64 | . '">' |
| 65 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 65 | + . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | 66 | . '</a>' |
| 67 | 67 | ); |
| 68 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $voiceHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $voiceHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $criteria->setStart($GLOBALS['start']); |
| 79 | 79 | $criteria->setLimit($GLOBALS['limit']); |
| 80 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 80 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 81 | 81 | $criteria->setOrder($GLOBALS['order']); |
| 82 | 82 | |
| 83 | 83 | $voices = $voiceHandler->getObjects($criteria, true); |
@@ -118,17 +118,17 @@ discard block |
||
| 118 | 118 | $voice->setVars($_POST[$id]); |
| 119 | 119 | |
| 120 | 120 | if (!$id = $voiceHandler->insert($voice)) { |
| 121 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_FAILEDTOSAVE); |
|
| 121 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_FAILEDTOSAVE); |
|
| 122 | 122 | exit(0); |
| 123 | 123 | } |
| 124 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 124 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 125 | 125 | redirect_header( |
| 126 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 126 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 127 | 127 | 10, |
| 128 | 128 | _AM_SONGLIST_MSG_VOICE_SAVEDOKEY |
| 129 | 129 | ); |
| 130 | 130 | } else { |
| 131 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 131 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 132 | 132 | } |
| 133 | 133 | exit(0); |
| 134 | 134 | case 'savelist': |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | $voice->setVars($_POST[$id]); |
| 139 | 139 | if (!$voiceHandler->insert($voice)) { |
| 140 | 140 | redirect_header( |
| 141 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 141 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 142 | 142 | 10, |
| 143 | 143 | _AM_SONGLIST_MSG_VOICE_FAILEDTOSAVE |
| 144 | 144 | ); |
| 145 | 145 | exit(0); |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 148 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_SAVEDOKEY); |
|
| 149 | 149 | exit(0); |
| 150 | 150 | case 'delete': |
| 151 | 151 | $voiceHandler = Helper::getInstance()->getHandler('Voice'); |
@@ -154,13 +154,13 @@ discard block |
||
| 154 | 154 | $voice = $voiceHandler->get($id); |
| 155 | 155 | if (!$voiceHandler->delete($voice)) { |
| 156 | 156 | redirect_header( |
| 157 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 157 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 158 | 158 | 10, |
| 159 | 159 | _AM_SONGLIST_MSG_VOICE_FAILEDTODELETE |
| 160 | 160 | ); |
| 161 | 161 | exit(0); |
| 162 | 162 | } |
| 163 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_DELETED); |
|
| 163 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOICE_DELETED); |
|
| 164 | 164 | exit(0); |
| 165 | 165 | } |
| 166 | 166 | $voice = $voiceHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -3,10 +3,10 @@ discard block |
||
| 3 | 3 | use Xmf\Module\Admin; |
| 4 | 4 | use Xmf\Request; |
| 5 | 5 | use XoopsModules\Songlist\{ |
| 6 | - Helper, |
|
| 7 | - Genre, |
|
| 8 | - GenreHandler, |
|
| 9 | - Form\FormController |
|
| 6 | + Helper, |
|
| 7 | + Genre, |
|
| 8 | + GenreHandler, |
|
| 9 | + Form\FormController |
|
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | /** @var Genre $genre */ |
@@ -26,152 +26,152 @@ discard block |
||
| 26 | 26 | $filter = Request::getString('filter', '1,1', 'REQUEST'); |
| 27 | 27 | |
| 28 | 28 | switch ($op) { |
| 29 | - default: |
|
| 30 | - case 'genre': |
|
| 31 | - switch ($fct) { |
|
| 32 | - default: |
|
| 33 | - case 'list': |
|
| 34 | - $adminObject = Admin::getInstance(); |
|
| 35 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 36 | - |
|
| 37 | - /** @var GenreHandler $genreHandler */ |
|
| 38 | - $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 39 | - |
|
| 40 | - $criteria = $genreHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 41 | - $ttl = $genreHandler->getCount($criteria); |
|
| 42 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 43 | - |
|
| 44 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 46 | - |
|
| 47 | - foreach ($genreHandler->filterFields() as $id => $key) { |
|
| 48 | - $GLOBALS['xoopsTpl']->assign( |
|
| 49 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | - '<a href="' |
|
| 51 | - . $_SERVER['SCRIPT_NAME'] |
|
| 52 | - . '?start=' |
|
| 53 | - . $GLOBALS['start'] |
|
| 54 | - . '&limit=' |
|
| 55 | - . $GLOBALS['limit'] |
|
| 56 | - . '&sort=' |
|
| 57 | - . $key |
|
| 58 | - . '&order=' |
|
| 59 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | - . '&op=' |
|
| 61 | - . $GLOBALS['op'] |
|
| 62 | - . '&filter=' |
|
| 63 | - . $GLOBALS['filter'] |
|
| 64 | - . '">' |
|
| 65 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | - . '</a>' |
|
| 67 | - ); |
|
| 68 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $genreHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 73 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 74 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 75 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 76 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 77 | - |
|
| 78 | - $criteria->setStart($GLOBALS['start']); |
|
| 79 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 80 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | - $criteria->setOrder($GLOBALS['order']); |
|
| 82 | - |
|
| 83 | - $genres = $genreHandler->getObjects($criteria, true); |
|
| 84 | - foreach ($genres as $cid => $genre) { |
|
| 85 | - if (is_object($genre)) { |
|
| 86 | - $GLOBALS['xoopsTpl']->append('genre', $genre->toArray()); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormGenre(false)); |
|
| 90 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 91 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_genre_list.tpl'); |
|
| 92 | - break; |
|
| 93 | - case 'new': |
|
| 94 | - case 'edit': |
|
| 95 | - $adminObject = Admin::getInstance(); |
|
| 96 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 97 | - |
|
| 98 | - $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 99 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 100 | - $genre = $genreHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 101 | - } else { |
|
| 102 | - $genre = $genreHandler->create(); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $GLOBALS['xoopsTpl']->assign('form', $genre->getForm()); |
|
| 106 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 107 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_genre_edit.tpl'); |
|
| 108 | - break; |
|
| 109 | - case 'save': |
|
| 110 | - $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 111 | - $id = 0; |
|
| 112 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 113 | - if ($id) { |
|
| 114 | - $genre = $genreHandler->get($id); |
|
| 115 | - } else { |
|
| 116 | - $genre = $genreHandler->create(); |
|
| 117 | - } |
|
| 118 | - $genre->setVars($_POST[$id]); |
|
| 119 | - |
|
| 120 | - if (!$id = $genreHandler->insert($genre)) { |
|
| 121 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_FAILEDTOSAVE); |
|
| 122 | - exit(0); |
|
| 123 | - } |
|
| 124 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 125 | - redirect_header( |
|
| 126 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 127 | - 10, |
|
| 128 | - _AM_SONGLIST_MSG_GENRE_SAVEDOKEY |
|
| 129 | - ); |
|
| 130 | - } else { |
|
| 131 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 132 | - } |
|
| 133 | - exit(0); |
|
| 134 | - case 'savelist': |
|
| 135 | - $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 136 | - foreach ($_REQUEST['id'] as $id) { |
|
| 137 | - $genre = $genreHandler->get($id); |
|
| 138 | - $genre->setVars($_POST[$id]); |
|
| 139 | - if (!$genreHandler->insert($genre)) { |
|
| 140 | - redirect_header( |
|
| 141 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 142 | - 10, |
|
| 143 | - _AM_SONGLIST_MSG_GENRE_FAILEDTOSAVE |
|
| 144 | - ); |
|
| 145 | - exit(0); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 149 | - exit(0); |
|
| 150 | - case 'delete': |
|
| 151 | - $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 152 | - $id = 0; |
|
| 153 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 154 | - $genre = $genreHandler->get($id); |
|
| 155 | - if (!$genreHandler->delete($genre)) { |
|
| 156 | - redirect_header( |
|
| 157 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 158 | - 10, |
|
| 159 | - _AM_SONGLIST_MSG_GENRE_FAILEDTODELETE |
|
| 160 | - ); |
|
| 161 | - exit(0); |
|
| 162 | - } |
|
| 163 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_DELETED); |
|
| 164 | - exit(0); |
|
| 165 | - } |
|
| 166 | - $genre = $genreHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 167 | - xoops_confirm( |
|
| 168 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 169 | - $_SERVER['SCRIPT_NAME'], |
|
| 170 | - sprintf(_AM_SONGLIST_MSG_GENRE_DELETE, $genre->getVar('name')) |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - break; |
|
| 174 | - } |
|
| 29 | + default: |
|
| 30 | + case 'genre': |
|
| 31 | + switch ($fct) { |
|
| 32 | + default: |
|
| 33 | + case 'list': |
|
| 34 | + $adminObject = Admin::getInstance(); |
|
| 35 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 36 | + |
|
| 37 | + /** @var GenreHandler $genreHandler */ |
|
| 38 | + $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 39 | + |
|
| 40 | + $criteria = $genreHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 41 | + $ttl = $genreHandler->getCount($criteria); |
|
| 42 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 43 | + |
|
| 44 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 46 | + |
|
| 47 | + foreach ($genreHandler->filterFields() as $id => $key) { |
|
| 48 | + $GLOBALS['xoopsTpl']->assign( |
|
| 49 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | + '<a href="' |
|
| 51 | + . $_SERVER['SCRIPT_NAME'] |
|
| 52 | + . '?start=' |
|
| 53 | + . $GLOBALS['start'] |
|
| 54 | + . '&limit=' |
|
| 55 | + . $GLOBALS['limit'] |
|
| 56 | + . '&sort=' |
|
| 57 | + . $key |
|
| 58 | + . '&order=' |
|
| 59 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | + . '&op=' |
|
| 61 | + . $GLOBALS['op'] |
|
| 62 | + . '&filter=' |
|
| 63 | + . $GLOBALS['filter'] |
|
| 64 | + . '">' |
|
| 65 | + . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | + . '</a>' |
|
| 67 | + ); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $genreHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 73 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 74 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 75 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 76 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 77 | + |
|
| 78 | + $criteria->setStart($GLOBALS['start']); |
|
| 79 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 80 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | + $criteria->setOrder($GLOBALS['order']); |
|
| 82 | + |
|
| 83 | + $genres = $genreHandler->getObjects($criteria, true); |
|
| 84 | + foreach ($genres as $cid => $genre) { |
|
| 85 | + if (is_object($genre)) { |
|
| 86 | + $GLOBALS['xoopsTpl']->append('genre', $genre->toArray()); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormGenre(false)); |
|
| 90 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 91 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_genre_list.tpl'); |
|
| 92 | + break; |
|
| 93 | + case 'new': |
|
| 94 | + case 'edit': |
|
| 95 | + $adminObject = Admin::getInstance(); |
|
| 96 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 97 | + |
|
| 98 | + $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 99 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 100 | + $genre = $genreHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 101 | + } else { |
|
| 102 | + $genre = $genreHandler->create(); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $GLOBALS['xoopsTpl']->assign('form', $genre->getForm()); |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 107 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_genre_edit.tpl'); |
|
| 108 | + break; |
|
| 109 | + case 'save': |
|
| 110 | + $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 111 | + $id = 0; |
|
| 112 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 113 | + if ($id) { |
|
| 114 | + $genre = $genreHandler->get($id); |
|
| 115 | + } else { |
|
| 116 | + $genre = $genreHandler->create(); |
|
| 117 | + } |
|
| 118 | + $genre->setVars($_POST[$id]); |
|
| 119 | + |
|
| 120 | + if (!$id = $genreHandler->insert($genre)) { |
|
| 121 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_FAILEDTOSAVE); |
|
| 122 | + exit(0); |
|
| 123 | + } |
|
| 124 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 125 | + redirect_header( |
|
| 126 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 127 | + 10, |
|
| 128 | + _AM_SONGLIST_MSG_GENRE_SAVEDOKEY |
|
| 129 | + ); |
|
| 130 | + } else { |
|
| 131 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 132 | + } |
|
| 133 | + exit(0); |
|
| 134 | + case 'savelist': |
|
| 135 | + $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 136 | + foreach ($_REQUEST['id'] as $id) { |
|
| 137 | + $genre = $genreHandler->get($id); |
|
| 138 | + $genre->setVars($_POST[$id]); |
|
| 139 | + if (!$genreHandler->insert($genre)) { |
|
| 140 | + redirect_header( |
|
| 141 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 142 | + 10, |
|
| 143 | + _AM_SONGLIST_MSG_GENRE_FAILEDTOSAVE |
|
| 144 | + ); |
|
| 145 | + exit(0); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 149 | + exit(0); |
|
| 150 | + case 'delete': |
|
| 151 | + $genreHandler = Helper::getInstance()->getHandler('Genre'); |
|
| 152 | + $id = 0; |
|
| 153 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 154 | + $genre = $genreHandler->get($id); |
|
| 155 | + if (!$genreHandler->delete($genre)) { |
|
| 156 | + redirect_header( |
|
| 157 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 158 | + 10, |
|
| 159 | + _AM_SONGLIST_MSG_GENRE_FAILEDTODELETE |
|
| 160 | + ); |
|
| 161 | + exit(0); |
|
| 162 | + } |
|
| 163 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_DELETED); |
|
| 164 | + exit(0); |
|
| 165 | + } |
|
| 166 | + $genre = $genreHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 167 | + xoops_confirm( |
|
| 168 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 169 | + $_SERVER['SCRIPT_NAME'], |
|
| 170 | + sprintf(_AM_SONGLIST_MSG_GENRE_DELETE, $genre->getVar('name')) |
|
| 171 | + ); |
|
| 172 | + |
|
| 173 | + break; |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | xoops_cp_footer(); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | /** @var Genre $genre */ |
| 13 | 13 | |
| 14 | -require __DIR__ . '/header.php'; |
|
| 14 | +require __DIR__.'/header.php'; |
|
| 15 | 15 | |
| 16 | 16 | xoops_loadLanguage('admin', 'songlist'); |
| 17 | 17 | |
@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $criteria = $genreHandler->getFilterCriteria($GLOBALS['filter']); |
| 41 | 41 | $ttl = $genreHandler->getCount($criteria); |
| 42 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 42 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); ; |
|
| 43 | 43 | |
| 44 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 44 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']); |
|
| 45 | 45 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 46 | 46 | |
| 47 | 47 | foreach ($genreHandler->filterFields() as $id => $key) { |
| 48 | 48 | $GLOBALS['xoopsTpl']->assign( |
| 49 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 49 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 50 | 50 | '<a href="' |
| 51 | 51 | . $_SERVER['SCRIPT_NAME'] |
| 52 | 52 | . '?start=' |
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | . '&sort=' |
| 57 | 57 | . $key |
| 58 | 58 | . '&order=' |
| 59 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 59 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | 60 | . '&op=' |
| 61 | 61 | . $GLOBALS['op'] |
| 62 | 62 | . '&filter=' |
| 63 | 63 | . $GLOBALS['filter'] |
| 64 | 64 | . '">' |
| 65 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 65 | + . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | 66 | . '</a>' |
| 67 | 67 | ); |
| 68 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $genreHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $genreHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $criteria->setStart($GLOBALS['start']); |
| 79 | 79 | $criteria->setLimit($GLOBALS['limit']); |
| 80 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 80 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 81 | 81 | $criteria->setOrder($GLOBALS['order']); |
| 82 | 82 | |
| 83 | 83 | $genres = $genreHandler->getObjects($criteria, true); |
@@ -118,17 +118,17 @@ discard block |
||
| 118 | 118 | $genre->setVars($_POST[$id]); |
| 119 | 119 | |
| 120 | 120 | if (!$id = $genreHandler->insert($genre)) { |
| 121 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_FAILEDTOSAVE); |
|
| 121 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_FAILEDTOSAVE); |
|
| 122 | 122 | exit(0); |
| 123 | 123 | } |
| 124 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 124 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 125 | 125 | redirect_header( |
| 126 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 126 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 127 | 127 | 10, |
| 128 | 128 | _AM_SONGLIST_MSG_GENRE_SAVEDOKEY |
| 129 | 129 | ); |
| 130 | 130 | } else { |
| 131 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 131 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 132 | 132 | } |
| 133 | 133 | exit(0); |
| 134 | 134 | case 'savelist': |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | $genre->setVars($_POST[$id]); |
| 139 | 139 | if (!$genreHandler->insert($genre)) { |
| 140 | 140 | redirect_header( |
| 141 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 141 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 142 | 142 | 10, |
| 143 | 143 | _AM_SONGLIST_MSG_GENRE_FAILEDTOSAVE |
| 144 | 144 | ); |
| 145 | 145 | exit(0); |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 148 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_SAVEDOKEY); |
|
| 149 | 149 | exit(0); |
| 150 | 150 | case 'delete': |
| 151 | 151 | $genreHandler = Helper::getInstance()->getHandler('Genre'); |
@@ -154,13 +154,13 @@ discard block |
||
| 154 | 154 | $genre = $genreHandler->get($id); |
| 155 | 155 | if (!$genreHandler->delete($genre)) { |
| 156 | 156 | redirect_header( |
| 157 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 157 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 158 | 158 | 10, |
| 159 | 159 | _AM_SONGLIST_MSG_GENRE_FAILEDTODELETE |
| 160 | 160 | ); |
| 161 | 161 | exit(0); |
| 162 | 162 | } |
| 163 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_DELETED); |
|
| 163 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_GENRE_DELETED); |
|
| 164 | 164 | exit(0); |
| 165 | 165 | } |
| 166 | 166 | $genre = $genreHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | use Xmf\Module\Admin; |
| 4 | 4 | use Xmf\Request; |
| 5 | 5 | use XoopsModules\Songlist\{ |
| 6 | - Form\FormController, |
|
| 7 | - Helper, |
|
| 8 | - Uploader, |
|
| 9 | - Albums, |
|
| 10 | - AlbumsHandler |
|
| 6 | + Form\FormController, |
|
| 7 | + Helper, |
|
| 8 | + Uploader, |
|
| 9 | + Albums, |
|
| 10 | + AlbumsHandler |
|
| 11 | 11 | }; |
| 12 | 12 | |
| 13 | 13 | /** @var Albums $album */ |
@@ -27,102 +27,102 @@ discard block |
||
| 27 | 27 | $filter = Request::getString('filter', '1,1', 'REQUEST'); |
| 28 | 28 | |
| 29 | 29 | switch ($op) { |
| 30 | - default: |
|
| 31 | - case 'albums': |
|
| 32 | - switch ($fct) { |
|
| 33 | - default: |
|
| 34 | - case 'list': |
|
| 35 | - $adminObject = Admin::getInstance(); |
|
| 36 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | - |
|
| 38 | - /** @var AlbumsHandler $albumsHandler */ |
|
| 39 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 40 | - |
|
| 41 | - $criteria = $albumsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | - $ttl = $albumsHandler->getCount($criteria); |
|
| 43 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); |
|
| 44 | - |
|
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | - |
|
| 48 | - foreach ($albumsHandler->filterFields() as $id => $key) { |
|
| 49 | - $GLOBALS['xoopsTpl']->assign( |
|
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | - '<a href="' |
|
| 52 | - . $_SERVER['SCRIPT_NAME'] |
|
| 53 | - . '?start=' |
|
| 54 | - . $GLOBALS['start'] |
|
| 55 | - . '&limit=' |
|
| 56 | - . $GLOBALS['limit'] |
|
| 57 | - . '&sort=' |
|
| 58 | - . $key |
|
| 59 | - . '&order=' |
|
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' == $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | - . '&op=' |
|
| 62 | - . $GLOBALS['op'] |
|
| 63 | - . '&filter=' |
|
| 64 | - . $GLOBALS['filter'] |
|
| 65 | - . '">' |
|
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | - . '</a>' |
|
| 68 | - ); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | - |
|
| 79 | - $criteria->setStart($GLOBALS['start']); |
|
| 80 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | - $criteria->setOrder($GLOBALS['order']); |
|
| 83 | - |
|
| 84 | - $albumsArray = $albumsHandler->getObjects($criteria, true); |
|
| 85 | - foreach ($albumsArray as $cid => $album) { |
|
| 86 | - if (is_object($album)) { |
|
| 87 | - $GLOBALS['xoopsTpl']->append('albums', $album->toArray()); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormAlbums(false)); |
|
| 91 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_list.tpl'); |
|
| 93 | - break; |
|
| 94 | - case 'new': |
|
| 95 | - case 'edit': |
|
| 96 | - $adminObject = Admin::getInstance(); |
|
| 97 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | - |
|
| 99 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 100 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | - $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | - } else { |
|
| 103 | - $album = $albumsHandler->create(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $GLOBALS['xoopsTpl']->assign('form', $album->getForm()); |
|
| 107 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_edit.tpl'); |
|
| 109 | - break; |
|
| 110 | - case 'save': |
|
| 111 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 112 | - $id = 0; |
|
| 113 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | - if ($id) { |
|
| 115 | - $album = $albumsHandler->get($id); |
|
| 116 | - } else { |
|
| 117 | - $album = $albumsHandler->create(); |
|
| 118 | - } |
|
| 119 | - $album->setVars($_POST[$id]); |
|
| 120 | - |
|
| 121 | - if (!$id = $albumsHandler->insert($album)) { |
|
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE); |
|
| 123 | - exit(0); |
|
| 124 | - } |
|
| 125 | - if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 30 | + default: |
|
| 31 | + case 'albums': |
|
| 32 | + switch ($fct) { |
|
| 33 | + default: |
|
| 34 | + case 'list': |
|
| 35 | + $adminObject = Admin::getInstance(); |
|
| 36 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | + |
|
| 38 | + /** @var AlbumsHandler $albumsHandler */ |
|
| 39 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 40 | + |
|
| 41 | + $criteria = $albumsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | + $ttl = $albumsHandler->getCount($criteria); |
|
| 43 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); |
|
| 44 | + |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | + |
|
| 48 | + foreach ($albumsHandler->filterFields() as $id => $key) { |
|
| 49 | + $GLOBALS['xoopsTpl']->assign( |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | + '<a href="' |
|
| 52 | + . $_SERVER['SCRIPT_NAME'] |
|
| 53 | + . '?start=' |
|
| 54 | + . $GLOBALS['start'] |
|
| 55 | + . '&limit=' |
|
| 56 | + . $GLOBALS['limit'] |
|
| 57 | + . '&sort=' |
|
| 58 | + . $key |
|
| 59 | + . '&order=' |
|
| 60 | + . (($key == $GLOBALS['sort']) ? ('DESC' == $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | + . '&op=' |
|
| 62 | + . $GLOBALS['op'] |
|
| 63 | + . '&filter=' |
|
| 64 | + . $GLOBALS['filter'] |
|
| 65 | + . '">' |
|
| 66 | + . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | + . '</a>' |
|
| 68 | + ); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | + |
|
| 79 | + $criteria->setStart($GLOBALS['start']); |
|
| 80 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | + $criteria->setOrder($GLOBALS['order']); |
|
| 83 | + |
|
| 84 | + $albumsArray = $albumsHandler->getObjects($criteria, true); |
|
| 85 | + foreach ($albumsArray as $cid => $album) { |
|
| 86 | + if (is_object($album)) { |
|
| 87 | + $GLOBALS['xoopsTpl']->append('albums', $album->toArray()); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormAlbums(false)); |
|
| 91 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_list.tpl'); |
|
| 93 | + break; |
|
| 94 | + case 'new': |
|
| 95 | + case 'edit': |
|
| 96 | + $adminObject = Admin::getInstance(); |
|
| 97 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | + |
|
| 99 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 100 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | + $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | + } else { |
|
| 103 | + $album = $albumsHandler->create(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('form', $album->getForm()); |
|
| 107 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_edit.tpl'); |
|
| 109 | + break; |
|
| 110 | + case 'save': |
|
| 111 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 112 | + $id = 0; |
|
| 113 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | + if ($id) { |
|
| 115 | + $album = $albumsHandler->get($id); |
|
| 116 | + } else { |
|
| 117 | + $album = $albumsHandler->create(); |
|
| 118 | + } |
|
| 119 | + $album->setVars($_POST[$id]); |
|
| 120 | + |
|
| 121 | + if (!$id = $albumsHandler->insert($album)) { |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE); |
|
| 123 | + exit(0); |
|
| 124 | + } |
|
| 125 | + if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 126 | 126 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
| 127 | 127 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
| 128 | 128 | // foreach (explode('/', $folders) as $folder) { |
@@ -135,95 +135,95 @@ discard block |
||
| 135 | 135 | // } |
| 136 | 136 | |
| 137 | 137 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 138 | - $album = $albumsHandler->get($id); |
|
| 139 | - $uploader = new Uploader( |
|
| 140 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']. 'albums'), |
|
| 141 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 142 | - $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 143 | - 0, |
|
| 144 | - 0, |
|
| 145 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 146 | - ); |
|
| 147 | - try { |
|
| 148 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 149 | - } catch (Exception $e) { |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($uploader->fetchMedia('image')) { |
|
| 153 | - if (!$uploader->upload()) { |
|
| 154 | - $adminObject = Admin::getInstance(); |
|
| 155 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 156 | - echo $uploader->getErrors(); |
|
| 157 | - require __DIR__ . '/admin_footer.php'; |
|
| 158 | - exit(0); |
|
| 159 | - } |
|
| 160 | - if (mb_strlen($album->getVar('image'))) { |
|
| 161 | - unlink($GLOBALS['xoops']->path($album->getVar('path')) . $album->getVar('image')); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']. 'albums/') ; |
|
| 165 | - $album->setVar('image', $uploader->getSavedFileName()); |
|
| 166 | - @$albumsHandler->insert($album); |
|
| 167 | - } else { |
|
| 168 | - $adminObject = Admin::getInstance(); |
|
| 169 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 170 | - echo $uploader->getErrors(); |
|
| 171 | - require __DIR__ . '/admin_footer.php'; |
|
| 172 | - exit(0); |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ('new' == $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | - redirect_header( |
|
| 178 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 179 | - 10, |
|
| 180 | - _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY |
|
| 181 | - ); |
|
| 182 | - } else { |
|
| 183 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 184 | - } |
|
| 185 | - exit(0); |
|
| 186 | - case 'savelist': |
|
| 187 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 188 | - foreach ($_REQUEST['id'] as $id) { |
|
| 189 | - $album = $albumsHandler->get($id); |
|
| 190 | - $album->setVars($_POST[$id]); |
|
| 191 | - if (!$albumsHandler->insert($album)) { |
|
| 192 | - redirect_header( |
|
| 193 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 194 | - 10, |
|
| 195 | - _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE |
|
| 196 | - ); |
|
| 197 | - exit(0); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 201 | - exit(0); |
|
| 202 | - case 'delete': |
|
| 203 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 204 | - $id = 0; |
|
| 205 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 206 | - $album = $albumsHandler->get($id); |
|
| 207 | - if (!$albumsHandler->delete($album)) { |
|
| 208 | - redirect_header( |
|
| 209 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 210 | - 10, |
|
| 211 | - _AM_SONGLIST_MSG_ALBUMS_FAILEDTODELETE |
|
| 212 | - ); |
|
| 213 | - exit(0); |
|
| 214 | - } |
|
| 215 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_DELETED); |
|
| 216 | - exit(0); |
|
| 217 | - } |
|
| 218 | - $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 219 | - xoops_confirm( |
|
| 220 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 221 | - $_SERVER['SCRIPT_NAME'], |
|
| 222 | - sprintf(_AM_SONGLIST_MSG_ALBUMS_DELETE, $album->getVar('title')) |
|
| 223 | - ); |
|
| 224 | - |
|
| 225 | - break; |
|
| 226 | - } |
|
| 138 | + $album = $albumsHandler->get($id); |
|
| 139 | + $uploader = new Uploader( |
|
| 140 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']. 'albums'), |
|
| 141 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 142 | + $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 143 | + 0, |
|
| 144 | + 0, |
|
| 145 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 146 | + ); |
|
| 147 | + try { |
|
| 148 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 149 | + } catch (Exception $e) { |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($uploader->fetchMedia('image')) { |
|
| 153 | + if (!$uploader->upload()) { |
|
| 154 | + $adminObject = Admin::getInstance(); |
|
| 155 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 156 | + echo $uploader->getErrors(); |
|
| 157 | + require __DIR__ . '/admin_footer.php'; |
|
| 158 | + exit(0); |
|
| 159 | + } |
|
| 160 | + if (mb_strlen($album->getVar('image'))) { |
|
| 161 | + unlink($GLOBALS['xoops']->path($album->getVar('path')) . $album->getVar('image')); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']. 'albums/') ; |
|
| 165 | + $album->setVar('image', $uploader->getSavedFileName()); |
|
| 166 | + @$albumsHandler->insert($album); |
|
| 167 | + } else { |
|
| 168 | + $adminObject = Admin::getInstance(); |
|
| 169 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 170 | + echo $uploader->getErrors(); |
|
| 171 | + require __DIR__ . '/admin_footer.php'; |
|
| 172 | + exit(0); |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ('new' == $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | + redirect_header( |
|
| 178 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 179 | + 10, |
|
| 180 | + _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY |
|
| 181 | + ); |
|
| 182 | + } else { |
|
| 183 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 184 | + } |
|
| 185 | + exit(0); |
|
| 186 | + case 'savelist': |
|
| 187 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 188 | + foreach ($_REQUEST['id'] as $id) { |
|
| 189 | + $album = $albumsHandler->get($id); |
|
| 190 | + $album->setVars($_POST[$id]); |
|
| 191 | + if (!$albumsHandler->insert($album)) { |
|
| 192 | + redirect_header( |
|
| 193 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 194 | + 10, |
|
| 195 | + _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE |
|
| 196 | + ); |
|
| 197 | + exit(0); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 201 | + exit(0); |
|
| 202 | + case 'delete': |
|
| 203 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 204 | + $id = 0; |
|
| 205 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 206 | + $album = $albumsHandler->get($id); |
|
| 207 | + if (!$albumsHandler->delete($album)) { |
|
| 208 | + redirect_header( |
|
| 209 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 210 | + 10, |
|
| 211 | + _AM_SONGLIST_MSG_ALBUMS_FAILEDTODELETE |
|
| 212 | + ); |
|
| 213 | + exit(0); |
|
| 214 | + } |
|
| 215 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_DELETED); |
|
| 216 | + exit(0); |
|
| 217 | + } |
|
| 218 | + $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 219 | + xoops_confirm( |
|
| 220 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 221 | + $_SERVER['SCRIPT_NAME'], |
|
| 222 | + sprintf(_AM_SONGLIST_MSG_ALBUMS_DELETE, $album->getVar('title')) |
|
| 223 | + ); |
|
| 224 | + |
|
| 225 | + break; |
|
| 226 | + } |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | xoops_cp_footer(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | /** @var Albums $album */ |
| 14 | 14 | |
| 15 | -require __DIR__ . '/header.php'; |
|
| 15 | +require __DIR__.'/header.php'; |
|
| 16 | 16 | |
| 17 | 17 | xoops_loadLanguage('admin', 'songlist'); |
| 18 | 18 | |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | $ttl = $albumsHandler->getCount($criteria); |
| 43 | 43 | $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); |
| 44 | 44 | |
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']); |
|
| 46 | 46 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 47 | 47 | |
| 48 | 48 | foreach ($albumsHandler->filterFields() as $id => $key) { |
| 49 | 49 | $GLOBALS['xoopsTpl']->assign( |
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 51 | 51 | '<a href="' |
| 52 | 52 | . $_SERVER['SCRIPT_NAME'] |
| 53 | 53 | . '?start=' |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | . '&sort=' |
| 58 | 58 | . $key |
| 59 | 59 | . '&order=' |
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' == $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | + . (($key==$GLOBALS['sort']) ? ('DESC'==$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | 61 | . '&op=' |
| 62 | 62 | . $GLOBALS['op'] |
| 63 | 63 | . '&filter=' |
| 64 | 64 | . $GLOBALS['filter'] |
| 65 | 65 | . '">' |
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | + . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | 67 | . '</a>' |
| 68 | 68 | ); |
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $criteria->setStart($GLOBALS['start']); |
| 80 | 80 | $criteria->setLimit($GLOBALS['limit']); |
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 82 | 82 | $criteria->setOrder($GLOBALS['order']); |
| 83 | 83 | |
| 84 | 84 | $albumsArray = $albumsHandler->getObjects($criteria, true); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $album->setVars($_POST[$id]); |
| 120 | 120 | |
| 121 | 121 | if (!$id = $albumsHandler->insert($album)) { |
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE); |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE); |
|
| 123 | 123 | exit(0); |
| 124 | 124 | } |
| 125 | 125 | if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 138 | 138 | $album = $albumsHandler->get($id); |
| 139 | 139 | $uploader = new Uploader( |
| 140 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']. 'albums'), |
|
| 140 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].'albums'), |
|
| 141 | 141 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
| 142 | 142 | $GLOBALS['songlistModuleConfig']['filesize_upload'], |
| 143 | 143 | 0, |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
| 146 | 146 | ); |
| 147 | 147 | try { |
| 148 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 148 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
| 149 | 149 | } catch (Exception $e) { |
| 150 | 150 | } |
| 151 | 151 | |
@@ -154,33 +154,33 @@ discard block |
||
| 154 | 154 | $adminObject = Admin::getInstance(); |
| 155 | 155 | $adminObject->displayNavigation(basename(__FILE__)); |
| 156 | 156 | echo $uploader->getErrors(); |
| 157 | - require __DIR__ . '/admin_footer.php'; |
|
| 157 | + require __DIR__.'/admin_footer.php'; |
|
| 158 | 158 | exit(0); |
| 159 | 159 | } |
| 160 | 160 | if (mb_strlen($album->getVar('image'))) { |
| 161 | - unlink($GLOBALS['xoops']->path($album->getVar('path')) . $album->getVar('image')); |
|
| 161 | + unlink($GLOBALS['xoops']->path($album->getVar('path')).$album->getVar('image')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']. 'albums/') ; |
|
| 164 | + $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas'].'albums/'); |
|
| 165 | 165 | $album->setVar('image', $uploader->getSavedFileName()); |
| 166 | 166 | @$albumsHandler->insert($album); |
| 167 | 167 | } else { |
| 168 | 168 | $adminObject = Admin::getInstance(); |
| 169 | 169 | $adminObject->displayNavigation(basename(__FILE__)); |
| 170 | 170 | echo $uploader->getErrors(); |
| 171 | - require __DIR__ . '/admin_footer.php'; |
|
| 171 | + require __DIR__.'/admin_footer.php'; |
|
| 172 | 172 | exit(0); |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ('new' == $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 176 | + if ('new'==$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | 177 | redirect_header( |
| 178 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 178 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 179 | 179 | 10, |
| 180 | 180 | _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY |
| 181 | 181 | ); |
| 182 | 182 | } else { |
| 183 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 183 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 184 | 184 | } |
| 185 | 185 | exit(0); |
| 186 | 186 | case 'savelist': |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | $album->setVars($_POST[$id]); |
| 191 | 191 | if (!$albumsHandler->insert($album)) { |
| 192 | 192 | redirect_header( |
| 193 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 193 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 194 | 194 | 10, |
| 195 | 195 | _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE |
| 196 | 196 | ); |
| 197 | 197 | exit(0); |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 200 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
|
| 201 | 201 | exit(0); |
| 202 | 202 | case 'delete': |
| 203 | 203 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | $album = $albumsHandler->get($id); |
| 207 | 207 | if (!$albumsHandler->delete($album)) { |
| 208 | 208 | redirect_header( |
| 209 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 209 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 210 | 210 | 10, |
| 211 | 211 | _AM_SONGLIST_MSG_ALBUMS_FAILEDTODELETE |
| 212 | 212 | ); |
| 213 | 213 | exit(0); |
| 214 | 214 | } |
| 215 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_DELETED); |
|
| 215 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_DELETED); |
|
| 216 | 216 | exit(0); |
| 217 | 217 | } |
| 218 | 218 | $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | use Xmf\Module\Admin; |
| 4 | 4 | use Xmf\Request; |
| 5 | 5 | use XoopsModules\Songlist\{ |
| 6 | - Form\FormController, |
|
| 7 | - Helper, |
|
| 8 | - Votes, |
|
| 9 | - VotesHandler, |
|
| 10 | - Uploader |
|
| 6 | + Form\FormController, |
|
| 7 | + Helper, |
|
| 8 | + Votes, |
|
| 9 | + VotesHandler, |
|
| 10 | + Uploader |
|
| 11 | 11 | }; |
| 12 | 12 | |
| 13 | 13 | /** @var Votes $votes */ |
@@ -27,102 +27,102 @@ discard block |
||
| 27 | 27 | $filter = Request::getString('filter', '1,1', 'REQUEST'); |
| 28 | 28 | |
| 29 | 29 | switch ($op) { |
| 30 | - default: |
|
| 31 | - case 'votes': |
|
| 32 | - switch ($fct) { |
|
| 33 | - default: |
|
| 34 | - case 'list': |
|
| 35 | - $adminObject = Admin::getInstance(); |
|
| 36 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | - |
|
| 38 | - /** @var VotesHandler $votesHandler */ |
|
| 39 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 40 | - |
|
| 41 | - $criteria = $votesHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | - $ttl = $votesHandler->getCount($criteria); |
|
| 43 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 44 | - |
|
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | - |
|
| 48 | - foreach ($votesHandler->filterFields() as $id => $key) { |
|
| 49 | - $GLOBALS['xoopsTpl']->assign( |
|
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | - '<a href="' |
|
| 52 | - . $_SERVER['SCRIPT_NAME'] |
|
| 53 | - . '?start=' |
|
| 54 | - . $GLOBALS['start'] |
|
| 55 | - . '&limit=' |
|
| 56 | - . $GLOBALS['limit'] |
|
| 57 | - . '&sort=' |
|
| 58 | - . $key |
|
| 59 | - . '&order=' |
|
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | - . '&op=' |
|
| 62 | - . $GLOBALS['op'] |
|
| 63 | - . '&filter=' |
|
| 64 | - . $GLOBALS['filter'] |
|
| 65 | - . '">' |
|
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | - . '</a>' |
|
| 68 | - ); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | - |
|
| 79 | - $criteria->setStart($GLOBALS['start']); |
|
| 80 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | - $criteria->setOrder($GLOBALS['order']); |
|
| 83 | - |
|
| 84 | - $votess = $votesHandler->getObjects($criteria, true); |
|
| 85 | - foreach ($votess as $cid => $votes) { |
|
| 86 | - if (is_object($votes)) { |
|
| 87 | - $GLOBALS['xoopsTpl']->append('categories', $votes->toArray()); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - //$GLOBALS['xoopsTpl']->assign('form', FormController::votes_get_form(false)); |
|
| 91 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_list.tpl'); |
|
| 93 | - break; |
|
| 94 | - case 'new': |
|
| 95 | - case 'edit': |
|
| 96 | - $adminObject = Admin::getInstance(); |
|
| 97 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | - |
|
| 99 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 100 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | - $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | - } else { |
|
| 103 | - $votes = $votesHandler->create(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $GLOBALS['xoopsTpl']->assign('form', $votes->getForm()); |
|
| 107 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_edit.tpl'); |
|
| 109 | - break; |
|
| 110 | - case 'save': |
|
| 111 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 112 | - $id = 0; |
|
| 113 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | - if ($id) { |
|
| 115 | - $votes = $votesHandler->get($id); |
|
| 116 | - } else { |
|
| 117 | - $votes = $votesHandler->create(); |
|
| 118 | - } |
|
| 119 | - $votes->setVars($_POST[$id]); |
|
| 120 | - |
|
| 121 | - if (!$id = $votesHandler->insert($votes)) { |
|
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE); |
|
| 123 | - exit(0); |
|
| 124 | - } |
|
| 125 | - if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 30 | + default: |
|
| 31 | + case 'votes': |
|
| 32 | + switch ($fct) { |
|
| 33 | + default: |
|
| 34 | + case 'list': |
|
| 35 | + $adminObject = Admin::getInstance(); |
|
| 36 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | + |
|
| 38 | + /** @var VotesHandler $votesHandler */ |
|
| 39 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 40 | + |
|
| 41 | + $criteria = $votesHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | + $ttl = $votesHandler->getCount($criteria); |
|
| 43 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 44 | + |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | + |
|
| 48 | + foreach ($votesHandler->filterFields() as $id => $key) { |
|
| 49 | + $GLOBALS['xoopsTpl']->assign( |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | + '<a href="' |
|
| 52 | + . $_SERVER['SCRIPT_NAME'] |
|
| 53 | + . '?start=' |
|
| 54 | + . $GLOBALS['start'] |
|
| 55 | + . '&limit=' |
|
| 56 | + . $GLOBALS['limit'] |
|
| 57 | + . '&sort=' |
|
| 58 | + . $key |
|
| 59 | + . '&order=' |
|
| 60 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | + . '&op=' |
|
| 62 | + . $GLOBALS['op'] |
|
| 63 | + . '&filter=' |
|
| 64 | + . $GLOBALS['filter'] |
|
| 65 | + . '">' |
|
| 66 | + . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | + . '</a>' |
|
| 68 | + ); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | + |
|
| 79 | + $criteria->setStart($GLOBALS['start']); |
|
| 80 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | + $criteria->setOrder($GLOBALS['order']); |
|
| 83 | + |
|
| 84 | + $votess = $votesHandler->getObjects($criteria, true); |
|
| 85 | + foreach ($votess as $cid => $votes) { |
|
| 86 | + if (is_object($votes)) { |
|
| 87 | + $GLOBALS['xoopsTpl']->append('categories', $votes->toArray()); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + //$GLOBALS['xoopsTpl']->assign('form', FormController::votes_get_form(false)); |
|
| 91 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_list.tpl'); |
|
| 93 | + break; |
|
| 94 | + case 'new': |
|
| 95 | + case 'edit': |
|
| 96 | + $adminObject = Admin::getInstance(); |
|
| 97 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | + |
|
| 99 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 100 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | + $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | + } else { |
|
| 103 | + $votes = $votesHandler->create(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('form', $votes->getForm()); |
|
| 107 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_edit.tpl'); |
|
| 109 | + break; |
|
| 110 | + case 'save': |
|
| 111 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 112 | + $id = 0; |
|
| 113 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | + if ($id) { |
|
| 115 | + $votes = $votesHandler->get($id); |
|
| 116 | + } else { |
|
| 117 | + $votes = $votesHandler->create(); |
|
| 118 | + } |
|
| 119 | + $votes->setVars($_POST[$id]); |
|
| 120 | + |
|
| 121 | + if (!$id = $votesHandler->insert($votes)) { |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE); |
|
| 123 | + exit(0); |
|
| 124 | + } |
|
| 125 | + if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 126 | 126 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
| 127 | 127 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
| 128 | 128 | // foreach (explode('/', $folders) as $folder) { |
@@ -135,95 +135,95 @@ discard block |
||
| 135 | 135 | // } |
| 136 | 136 | |
| 137 | 137 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 138 | - $votes = $votesHandler->get($id); |
|
| 139 | - $uploader = new Uploader( |
|
| 140 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 141 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 142 | - $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 143 | - 0, |
|
| 144 | - 0, |
|
| 145 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 146 | - ); |
|
| 147 | - try { |
|
| 148 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 149 | - } catch (Exception $e) { |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($uploader->fetchMedia('image')) { |
|
| 153 | - if (!$uploader->upload()) { |
|
| 154 | - $adminObject = Admin::getInstance(); |
|
| 155 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 156 | - echo $uploader->getErrors(); |
|
| 157 | - require __DIR__ . '/admin_footer.php'; |
|
| 158 | - exit(0); |
|
| 159 | - } |
|
| 160 | - if (mb_strlen($votes->getVar('image'))) { |
|
| 161 | - unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image')); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 165 | - $votes->setVar('image', $uploader->getSavedFileName()); |
|
| 166 | - @$votesHandler->insert($votes); |
|
| 167 | - } else { |
|
| 168 | - $adminObject = Admin::getInstance(); |
|
| 169 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 170 | - echo $uploader->getErrors(); |
|
| 171 | - require __DIR__ . '/admin_footer.php'; |
|
| 172 | - exit(0); |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | - redirect_header( |
|
| 178 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 179 | - 10, |
|
| 180 | - _AM_SONGLIST_MSG_VOTES_SAVEDOKEY |
|
| 181 | - ); |
|
| 182 | - } else { |
|
| 183 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 184 | - } |
|
| 185 | - exit(0); |
|
| 186 | - case 'savelist': |
|
| 187 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 188 | - foreach ($_REQUEST['id'] as $id) { |
|
| 189 | - $votes = $votesHandler->get($id); |
|
| 190 | - $votes->setVars($_POST[$id]); |
|
| 191 | - if (!$votesHandler->insert($votes)) { |
|
| 192 | - redirect_header( |
|
| 193 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 194 | - 10, |
|
| 195 | - _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE |
|
| 196 | - ); |
|
| 197 | - exit(0); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 201 | - exit(0); |
|
| 202 | - case 'delete': |
|
| 203 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 204 | - $id = 0; |
|
| 205 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 206 | - $votes = $votesHandler->get($id); |
|
| 207 | - if (!$votesHandler->delete($votes)) { |
|
| 208 | - redirect_header( |
|
| 209 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 210 | - 10, |
|
| 211 | - _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE |
|
| 212 | - ); |
|
| 213 | - exit(0); |
|
| 214 | - } |
|
| 215 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED); |
|
| 216 | - exit(0); |
|
| 217 | - } |
|
| 218 | - $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 219 | - xoops_confirm( |
|
| 220 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 221 | - $_SERVER['SCRIPT_NAME'], |
|
| 222 | - sprintf(_AM_SONGLIST_MSG_VOTES_DELETE, $votes->getVar('name')) |
|
| 223 | - ); |
|
| 224 | - |
|
| 225 | - break; |
|
| 226 | - } |
|
| 138 | + $votes = $votesHandler->get($id); |
|
| 139 | + $uploader = new Uploader( |
|
| 140 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 141 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 142 | + $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 143 | + 0, |
|
| 144 | + 0, |
|
| 145 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 146 | + ); |
|
| 147 | + try { |
|
| 148 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 149 | + } catch (Exception $e) { |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($uploader->fetchMedia('image')) { |
|
| 153 | + if (!$uploader->upload()) { |
|
| 154 | + $adminObject = Admin::getInstance(); |
|
| 155 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 156 | + echo $uploader->getErrors(); |
|
| 157 | + require __DIR__ . '/admin_footer.php'; |
|
| 158 | + exit(0); |
|
| 159 | + } |
|
| 160 | + if (mb_strlen($votes->getVar('image'))) { |
|
| 161 | + unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image')); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 165 | + $votes->setVar('image', $uploader->getSavedFileName()); |
|
| 166 | + @$votesHandler->insert($votes); |
|
| 167 | + } else { |
|
| 168 | + $adminObject = Admin::getInstance(); |
|
| 169 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 170 | + echo $uploader->getErrors(); |
|
| 171 | + require __DIR__ . '/admin_footer.php'; |
|
| 172 | + exit(0); |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | + redirect_header( |
|
| 178 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 179 | + 10, |
|
| 180 | + _AM_SONGLIST_MSG_VOTES_SAVEDOKEY |
|
| 181 | + ); |
|
| 182 | + } else { |
|
| 183 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 184 | + } |
|
| 185 | + exit(0); |
|
| 186 | + case 'savelist': |
|
| 187 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 188 | + foreach ($_REQUEST['id'] as $id) { |
|
| 189 | + $votes = $votesHandler->get($id); |
|
| 190 | + $votes->setVars($_POST[$id]); |
|
| 191 | + if (!$votesHandler->insert($votes)) { |
|
| 192 | + redirect_header( |
|
| 193 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 194 | + 10, |
|
| 195 | + _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE |
|
| 196 | + ); |
|
| 197 | + exit(0); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 201 | + exit(0); |
|
| 202 | + case 'delete': |
|
| 203 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 204 | + $id = 0; |
|
| 205 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 206 | + $votes = $votesHandler->get($id); |
|
| 207 | + if (!$votesHandler->delete($votes)) { |
|
| 208 | + redirect_header( |
|
| 209 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 210 | + 10, |
|
| 211 | + _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE |
|
| 212 | + ); |
|
| 213 | + exit(0); |
|
| 214 | + } |
|
| 215 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED); |
|
| 216 | + exit(0); |
|
| 217 | + } |
|
| 218 | + $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 219 | + xoops_confirm( |
|
| 220 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 221 | + $_SERVER['SCRIPT_NAME'], |
|
| 222 | + sprintf(_AM_SONGLIST_MSG_VOTES_DELETE, $votes->getVar('name')) |
|
| 223 | + ); |
|
| 224 | + |
|
| 225 | + break; |
|
| 226 | + } |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | xoops_cp_footer(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | /** @var Votes $votes */ |
| 14 | 14 | |
| 15 | -require __DIR__ . '/header.php'; |
|
| 15 | +require __DIR__.'/header.php'; |
|
| 16 | 16 | |
| 17 | 17 | xoops_loadLanguage('admin', 'songlist'); |
| 18 | 18 | |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $criteria = $votesHandler->getFilterCriteria($GLOBALS['filter']); |
| 42 | 42 | $ttl = $votesHandler->getCount($criteria); |
| 43 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 43 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); ; |
|
| 44 | 44 | |
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']); |
|
| 46 | 46 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 47 | 47 | |
| 48 | 48 | foreach ($votesHandler->filterFields() as $id => $key) { |
| 49 | 49 | $GLOBALS['xoopsTpl']->assign( |
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 51 | 51 | '<a href="' |
| 52 | 52 | . $_SERVER['SCRIPT_NAME'] |
| 53 | 53 | . '?start=' |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | . '&sort=' |
| 58 | 58 | . $key |
| 59 | 59 | . '&order=' |
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | 61 | . '&op=' |
| 62 | 62 | . $GLOBALS['op'] |
| 63 | 63 | . '&filter=' |
| 64 | 64 | . $GLOBALS['filter'] |
| 65 | 65 | . '">' |
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | + . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | 67 | . '</a>' |
| 68 | 68 | ); |
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $criteria->setStart($GLOBALS['start']); |
| 80 | 80 | $criteria->setLimit($GLOBALS['limit']); |
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 82 | 82 | $criteria->setOrder($GLOBALS['order']); |
| 83 | 83 | |
| 84 | 84 | $votess = $votesHandler->getObjects($criteria, true); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $votes->setVars($_POST[$id]); |
| 120 | 120 | |
| 121 | 121 | if (!$id = $votesHandler->insert($votes)) { |
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE); |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE); |
|
| 123 | 123 | exit(0); |
| 124 | 124 | } |
| 125 | 125 | if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
| 146 | 146 | ); |
| 147 | 147 | try { |
| 148 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 148 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
| 149 | 149 | } catch (Exception $e) { |
| 150 | 150 | } |
| 151 | 151 | |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | $adminObject = Admin::getInstance(); |
| 155 | 155 | $adminObject->displayNavigation(basename(__FILE__)); |
| 156 | 156 | echo $uploader->getErrors(); |
| 157 | - require __DIR__ . '/admin_footer.php'; |
|
| 157 | + require __DIR__.'/admin_footer.php'; |
|
| 158 | 158 | exit(0); |
| 159 | 159 | } |
| 160 | 160 | if (mb_strlen($votes->getVar('image'))) { |
| 161 | - unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image')); |
|
| 161 | + unlink($GLOBALS['xoops']->path($votes->getVar('path')).$votes->getVar('image')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
@@ -168,19 +168,19 @@ discard block |
||
| 168 | 168 | $adminObject = Admin::getInstance(); |
| 169 | 169 | $adminObject->displayNavigation(basename(__FILE__)); |
| 170 | 170 | echo $uploader->getErrors(); |
| 171 | - require __DIR__ . '/admin_footer.php'; |
|
| 171 | + require __DIR__.'/admin_footer.php'; |
|
| 172 | 172 | exit(0); |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 176 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 177 | 177 | redirect_header( |
| 178 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 178 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 179 | 179 | 10, |
| 180 | 180 | _AM_SONGLIST_MSG_VOTES_SAVEDOKEY |
| 181 | 181 | ); |
| 182 | 182 | } else { |
| 183 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 183 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 184 | 184 | } |
| 185 | 185 | exit(0); |
| 186 | 186 | case 'savelist': |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | $votes->setVars($_POST[$id]); |
| 191 | 191 | if (!$votesHandler->insert($votes)) { |
| 192 | 192 | redirect_header( |
| 193 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 193 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 194 | 194 | 10, |
| 195 | 195 | _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE |
| 196 | 196 | ); |
| 197 | 197 | exit(0); |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 200 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY); |
|
| 201 | 201 | exit(0); |
| 202 | 202 | case 'delete': |
| 203 | 203 | $votesHandler = Helper::getInstance()->getHandler('Votes'); |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | $votes = $votesHandler->get($id); |
| 207 | 207 | if (!$votesHandler->delete($votes)) { |
| 208 | 208 | redirect_header( |
| 209 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 209 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 210 | 210 | 10, |
| 211 | 211 | _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE |
| 212 | 212 | ); |
| 213 | 213 | exit(0); |
| 214 | 214 | } |
| 215 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED); |
|
| 215 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED); |
|
| 216 | 216 | exit(0); |
| 217 | 217 | } |
| 218 | 218 | $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -3,10 +3,10 @@ discard block |
||
| 3 | 3 | use Xmf\Module\Admin; |
| 4 | 4 | use Xmf\Request; |
| 5 | 5 | use XoopsModules\Songlist\{ |
| 6 | - Form\FormController, |
|
| 7 | - Helper, |
|
| 8 | - Requests, |
|
| 9 | - RequestsHandler, |
|
| 6 | + Form\FormController, |
|
| 7 | + Helper, |
|
| 8 | + Requests, |
|
| 9 | + RequestsHandler, |
|
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | /** @var Requests $requests */ |
@@ -27,152 +27,152 @@ discard block |
||
| 27 | 27 | $filter = Request::getString('filter', '1,1', 'REQUEST'); |
| 28 | 28 | |
| 29 | 29 | switch ($op) { |
| 30 | - default: |
|
| 31 | - case 'requests': |
|
| 32 | - switch ($fct) { |
|
| 33 | - default: |
|
| 34 | - case 'list': |
|
| 35 | - $adminObject = Admin::getInstance(); |
|
| 36 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | - |
|
| 38 | - /** @var RequestsHandler $requestsHandler */ |
|
| 39 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 40 | - |
|
| 41 | - $criteria = $requestsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | - $ttl = $requestsHandler->getCount($criteria); |
|
| 43 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 44 | - |
|
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | - |
|
| 48 | - foreach ($requestsHandler->filterFields() as $id => $key) { |
|
| 49 | - $GLOBALS['xoopsTpl']->assign( |
|
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | - '<a href="' |
|
| 52 | - . $_SERVER['SCRIPT_NAME'] |
|
| 53 | - . '?start=' |
|
| 54 | - . $GLOBALS['start'] |
|
| 55 | - . '&limit=' |
|
| 56 | - . $GLOBALS['limit'] |
|
| 57 | - . '&sort=' |
|
| 58 | - . $key |
|
| 59 | - . '&order=' |
|
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | - . '&op=' |
|
| 62 | - . $GLOBALS['op'] |
|
| 63 | - . '&filter=' |
|
| 64 | - . $GLOBALS['filter'] |
|
| 65 | - . '">' |
|
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | - . '</a>' |
|
| 68 | - ); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | - |
|
| 79 | - $criteria->setStart($GLOBALS['start']); |
|
| 80 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | - $criteria->setOrder($GLOBALS['order']); |
|
| 83 | - |
|
| 84 | - $requestss = $requestsHandler->getObjects($criteria, true); |
|
| 85 | - foreach ($requestss as $cid => $requests) { |
|
| 86 | - if (is_object($requests)) { |
|
| 87 | - $GLOBALS['xoopsTpl']->append('requests', $requests->toArray()); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false)); |
|
| 91 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_list.tpl'); |
|
| 93 | - break; |
|
| 94 | - case 'new': |
|
| 95 | - case 'edit': |
|
| 96 | - $adminObject = Admin::getInstance(); |
|
| 97 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | - |
|
| 99 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 100 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | - $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | - } else { |
|
| 103 | - $requests = $requestsHandler->create(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $GLOBALS['xoopsTpl']->assign('form', $requests->getForm()); |
|
| 107 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_edit.tpl'); |
|
| 109 | - break; |
|
| 110 | - case 'save': |
|
| 111 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 112 | - $id = 0; |
|
| 113 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | - if ($id) { |
|
| 115 | - $requests = $requestsHandler->get($id); |
|
| 116 | - } else { |
|
| 117 | - $requests = $requestsHandler->create(); |
|
| 118 | - } |
|
| 119 | - $requests->setVars($_POST[$id]); |
|
| 120 | - |
|
| 121 | - if (!$id = $requestsHandler->insert($requests)) { |
|
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE); |
|
| 123 | - exit(0); |
|
| 124 | - } |
|
| 125 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 126 | - redirect_header( |
|
| 127 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 128 | - 10, |
|
| 129 | - _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY |
|
| 130 | - ); |
|
| 131 | - } else { |
|
| 132 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 133 | - } |
|
| 134 | - exit(0); |
|
| 135 | - case 'savelist': |
|
| 136 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 137 | - foreach ($_REQUEST['id'] as $id) { |
|
| 138 | - $requests = $requestsHandler->get($id); |
|
| 139 | - $requests->setVars($_POST[$id]); |
|
| 140 | - if (!$requestsHandler->insert($requests)) { |
|
| 141 | - redirect_header( |
|
| 142 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 143 | - 10, |
|
| 144 | - _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE |
|
| 145 | - ); |
|
| 146 | - exit(0); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 150 | - exit(0); |
|
| 151 | - case 'delete': |
|
| 152 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 153 | - $id = 0; |
|
| 154 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 155 | - $requests = $requestsHandler->get($id); |
|
| 156 | - if (!$requestsHandler->delete($requests)) { |
|
| 157 | - redirect_header( |
|
| 158 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 159 | - 10, |
|
| 160 | - _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE |
|
| 161 | - ); |
|
| 162 | - exit(0); |
|
| 163 | - } |
|
| 164 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED); |
|
| 165 | - exit(0); |
|
| 166 | - } |
|
| 167 | - $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 168 | - xoops_confirm( |
|
| 169 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 170 | - $_SERVER['SCRIPT_NAME'], |
|
| 171 | - sprintf(_AM_SONGLIST_MSG_REQUESTS_DELETE, $requests->getVar('name')) |
|
| 172 | - ); |
|
| 173 | - |
|
| 174 | - break; |
|
| 175 | - } |
|
| 30 | + default: |
|
| 31 | + case 'requests': |
|
| 32 | + switch ($fct) { |
|
| 33 | + default: |
|
| 34 | + case 'list': |
|
| 35 | + $adminObject = Admin::getInstance(); |
|
| 36 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 37 | + |
|
| 38 | + /** @var RequestsHandler $requestsHandler */ |
|
| 39 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 40 | + |
|
| 41 | + $criteria = $requestsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 42 | + $ttl = $requestsHandler->getCount($criteria); |
|
| 43 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 44 | + |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 46 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 47 | + |
|
| 48 | + foreach ($requestsHandler->filterFields() as $id => $key) { |
|
| 49 | + $GLOBALS['xoopsTpl']->assign( |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 51 | + '<a href="' |
|
| 52 | + . $_SERVER['SCRIPT_NAME'] |
|
| 53 | + . '?start=' |
|
| 54 | + . $GLOBALS['start'] |
|
| 55 | + . '&limit=' |
|
| 56 | + . $GLOBALS['limit'] |
|
| 57 | + . '&sort=' |
|
| 58 | + . $key |
|
| 59 | + . '&order=' |
|
| 60 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | + . '&op=' |
|
| 62 | + . $GLOBALS['op'] |
|
| 63 | + . '&filter=' |
|
| 64 | + . $GLOBALS['filter'] |
|
| 65 | + . '">' |
|
| 66 | + . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | + . '</a>' |
|
| 68 | + ); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 73 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 74 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 75 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 76 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 77 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 78 | + |
|
| 79 | + $criteria->setStart($GLOBALS['start']); |
|
| 80 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 81 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 82 | + $criteria->setOrder($GLOBALS['order']); |
|
| 83 | + |
|
| 84 | + $requestss = $requestsHandler->getObjects($criteria, true); |
|
| 85 | + foreach ($requestss as $cid => $requests) { |
|
| 86 | + if (is_object($requests)) { |
|
| 87 | + $GLOBALS['xoopsTpl']->append('requests', $requests->toArray()); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false)); |
|
| 91 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 92 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_list.tpl'); |
|
| 93 | + break; |
|
| 94 | + case 'new': |
|
| 95 | + case 'edit': |
|
| 96 | + $adminObject = Admin::getInstance(); |
|
| 97 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 98 | + |
|
| 99 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 100 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 101 | + $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 102 | + } else { |
|
| 103 | + $requests = $requestsHandler->create(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('form', $requests->getForm()); |
|
| 107 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 108 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_edit.tpl'); |
|
| 109 | + break; |
|
| 110 | + case 'save': |
|
| 111 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 112 | + $id = 0; |
|
| 113 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 114 | + if ($id) { |
|
| 115 | + $requests = $requestsHandler->get($id); |
|
| 116 | + } else { |
|
| 117 | + $requests = $requestsHandler->create(); |
|
| 118 | + } |
|
| 119 | + $requests->setVars($_POST[$id]); |
|
| 120 | + |
|
| 121 | + if (!$id = $requestsHandler->insert($requests)) { |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE); |
|
| 123 | + exit(0); |
|
| 124 | + } |
|
| 125 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 126 | + redirect_header( |
|
| 127 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 128 | + 10, |
|
| 129 | + _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY |
|
| 130 | + ); |
|
| 131 | + } else { |
|
| 132 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 133 | + } |
|
| 134 | + exit(0); |
|
| 135 | + case 'savelist': |
|
| 136 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 137 | + foreach ($_REQUEST['id'] as $id) { |
|
| 138 | + $requests = $requestsHandler->get($id); |
|
| 139 | + $requests->setVars($_POST[$id]); |
|
| 140 | + if (!$requestsHandler->insert($requests)) { |
|
| 141 | + redirect_header( |
|
| 142 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 143 | + 10, |
|
| 144 | + _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE |
|
| 145 | + ); |
|
| 146 | + exit(0); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 150 | + exit(0); |
|
| 151 | + case 'delete': |
|
| 152 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 153 | + $id = 0; |
|
| 154 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 155 | + $requests = $requestsHandler->get($id); |
|
| 156 | + if (!$requestsHandler->delete($requests)) { |
|
| 157 | + redirect_header( |
|
| 158 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 159 | + 10, |
|
| 160 | + _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE |
|
| 161 | + ); |
|
| 162 | + exit(0); |
|
| 163 | + } |
|
| 164 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED); |
|
| 165 | + exit(0); |
|
| 166 | + } |
|
| 167 | + $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 168 | + xoops_confirm( |
|
| 169 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 170 | + $_SERVER['SCRIPT_NAME'], |
|
| 171 | + sprintf(_AM_SONGLIST_MSG_REQUESTS_DELETE, $requests->getVar('name')) |
|
| 172 | + ); |
|
| 173 | + |
|
| 174 | + break; |
|
| 175 | + } |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | xoops_cp_footer(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** @var Requests $requests */ |
| 13 | 13 | |
| 14 | 14 | |
| 15 | -require __DIR__ . '/header.php'; |
|
| 15 | +require __DIR__.'/header.php'; |
|
| 16 | 16 | |
| 17 | 17 | xoops_loadLanguage('admin', 'songlist'); |
| 18 | 18 | |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $criteria = $requestsHandler->getFilterCriteria($GLOBALS['filter']); |
| 42 | 42 | $ttl = $requestsHandler->getCount($criteria); |
| 43 | - $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST');; |
|
| 43 | + $GLOBALS['sort'] = Request::getString('sort', 'created', 'REQUEST'); ; |
|
| 44 | 44 | |
| 45 | - $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
|
| 45 | + $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']); |
|
| 46 | 46 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 47 | 47 | |
| 48 | 48 | foreach ($requestsHandler->filterFields() as $id => $key) { |
| 49 | 49 | $GLOBALS['xoopsTpl']->assign( |
| 50 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 50 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 51 | 51 | '<a href="' |
| 52 | 52 | . $_SERVER['SCRIPT_NAME'] |
| 53 | 53 | . '?start=' |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | . '&sort=' |
| 58 | 58 | . $key |
| 59 | 59 | . '&order=' |
| 60 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 60 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 61 | 61 | . '&op=' |
| 62 | 62 | . $GLOBALS['op'] |
| 63 | 63 | . '&filter=' |
| 64 | 64 | . $GLOBALS['filter'] |
| 65 | 65 | . '">' |
| 66 | - . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
|
| 66 | + . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) |
|
| 67 | 67 | . '</a>' |
| 68 | 68 | ); |
| 69 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $criteria->setStart($GLOBALS['start']); |
| 80 | 80 | $criteria->setLimit($GLOBALS['limit']); |
| 81 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 81 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 82 | 82 | $criteria->setOrder($GLOBALS['order']); |
| 83 | 83 | |
| 84 | 84 | $requestss = $requestsHandler->getObjects($criteria, true); |
@@ -119,17 +119,17 @@ discard block |
||
| 119 | 119 | $requests->setVars($_POST[$id]); |
| 120 | 120 | |
| 121 | 121 | if (!$id = $requestsHandler->insert($requests)) { |
| 122 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE); |
|
| 122 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE); |
|
| 123 | 123 | exit(0); |
| 124 | 124 | } |
| 125 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 125 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 126 | 126 | redirect_header( |
| 127 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 127 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 128 | 128 | 10, |
| 129 | 129 | _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY |
| 130 | 130 | ); |
| 131 | 131 | } else { |
| 132 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 132 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 133 | 133 | } |
| 134 | 134 | exit(0); |
| 135 | 135 | case 'savelist': |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | $requests->setVars($_POST[$id]); |
| 140 | 140 | if (!$requestsHandler->insert($requests)) { |
| 141 | 141 | redirect_header( |
| 142 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 142 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 143 | 143 | 10, |
| 144 | 144 | _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE |
| 145 | 145 | ); |
| 146 | 146 | exit(0); |
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 149 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY); |
|
| 150 | 150 | exit(0); |
| 151 | 151 | case 'delete': |
| 152 | 152 | $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | $requests = $requestsHandler->get($id); |
| 156 | 156 | if (!$requestsHandler->delete($requests)) { |
| 157 | 157 | redirect_header( |
| 158 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 158 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 159 | 159 | 10, |
| 160 | 160 | _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE |
| 161 | 161 | ); |
| 162 | 162 | exit(0); |
| 163 | 163 | } |
| 164 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED); |
|
| 164 | + redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED); |
|
| 165 | 165 | exit(0); |
| 166 | 166 | } |
| 167 | 167 | $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | //$downloadHandler = new Songlist\DownloadHandler($db); |
| 40 | 40 | |
| 41 | 41 | if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { |
| 42 | - define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
| 43 | - define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 44 | - define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 45 | - define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
| 46 | - define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
| 47 | - define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
| 48 | - define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
| 49 | - define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
| 50 | - define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
| 51 | - define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
| 52 | - define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 53 | - define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 54 | - define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
| 42 | + define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
| 43 | + define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 44 | + define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 45 | + define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
| 46 | + define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
| 47 | + define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
| 48 | + define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
| 49 | + define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
| 50 | + define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
| 51 | + define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
| 52 | + define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 53 | + define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 54 | + define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $pathIcon16 = Admin::iconUrl('', '16'); |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | //$pathModIcon32 = \XoopsModules\Songlist\Helper::getInstance()->getModule()->getInfo('modicons32'); |
| 61 | 61 | |
| 62 | 62 | $icons = [ |
| 63 | - 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
| 64 | - 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
| 65 | - 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
| 66 | - 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
| 67 | - 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
| 68 | - 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
| 69 | - 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
| 70 | - '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
| 71 | - '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
| 63 | + 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
| 64 | + 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
| 65 | + 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
| 66 | + 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
| 67 | + 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
| 68 | + 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
| 69 | + 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
| 70 | + '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
| 71 | + '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
| 72 | 72 | ]; |
| 73 | 73 | |
| 74 | 74 | $debug = false; |
@@ -77,23 +77,23 @@ discard block |
||
| 77 | 77 | $myts = \MyTextSanitizer::getInstance(); |
| 78 | 78 | |
| 79 | 79 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) { |
| 80 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 81 | - $GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
|
| 80 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 81 | + $GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $GLOBALS['xoopsTpl']->assign('mod_url', $helper->url()); |
| 85 | 85 | // Local icons path |
| 86 | 86 | if (is_object($helper->getModule())) { |
| 87 | - $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
|
| 88 | - $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 87 | + $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
|
| 88 | + $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
| 89 | 89 | |
| 90 | - $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
| 91 | - $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
|
| 90 | + $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
| 91 | + $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | xoops_loadLanguage('main', $moduleDirName); |
| 95 | 95 | if (class_exists('D3LanguageManager')) { |
| 96 | - require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; |
|
| 97 | - $langman = D3LanguageManager::getInstance(); |
|
| 98 | - $langman->read('main.php', $moduleDirName); |
|
| 96 | + require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; |
|
| 97 | + $langman = D3LanguageManager::getInstance(); |
|
| 98 | + $langman->read('main.php', $moduleDirName); |
|
| 99 | 99 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | use XoopsModules\Songlist; |
| 20 | 20 | use XoopsModules\Songlist\Helper; |
| 21 | 21 | |
| 22 | -require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 22 | +require_once \dirname(__DIR__).'/preloads/autoloader.php'; |
|
| 23 | 23 | |
| 24 | 24 | $moduleDirName = \basename(\dirname(__DIR__)); |
| 25 | 25 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | //$categoryHandler = new Songlist\CategoryHandler($db); |
| 39 | 39 | //$downloadHandler = new Songlist\DownloadHandler($db); |
| 40 | 40 | |
| 41 | -if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { |
|
| 42 | - define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
| 43 | - define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 44 | - define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
| 45 | - define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/'); |
|
| 46 | - define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
| 47 | - define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images'); |
|
| 48 | - define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
| 49 | - define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
| 50 | - define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
| 51 | - define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
| 52 | - define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 53 | - define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
| 54 | - define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
| 41 | +if (!defined($moduleDirNameUpper.'_CONSTANTS_DEFINED')) { |
|
| 42 | + define($moduleDirNameUpper.'_DIRNAME', basename(dirname(__DIR__))); |
|
| 43 | + define($moduleDirNameUpper.'_ROOT_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/'); |
|
| 44 | + define($moduleDirNameUpper.'_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/'); |
|
| 45 | + define($moduleDirNameUpper.'_URL', XOOPS_URL.'/modules/'.$moduleDirName.'/'); |
|
| 46 | + define($moduleDirNameUpper.'_IMAGE_URL', constant($moduleDirNameUpper.'_URL').'/assets/images/'); |
|
| 47 | + define($moduleDirNameUpper.'_IMAGE_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/assets/images'); |
|
| 48 | + define($moduleDirNameUpper.'_ADMIN_URL', constant($moduleDirNameUpper.'_URL').'/admin/'); |
|
| 49 | + define($moduleDirNameUpper.'_ADMIN_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/admin/'); |
|
| 50 | + define($moduleDirNameUpper.'_ADMIN', constant($moduleDirNameUpper.'_URL').'/admin/index.php'); |
|
| 51 | + define($moduleDirNameUpper.'_AUTHOR_LOGOIMG', constant($moduleDirNameUpper.'_URL').'/assets/images/logoModule.png'); |
|
| 52 | + define($moduleDirNameUpper.'_UPLOAD_URL', XOOPS_UPLOAD_URL.'/'.$moduleDirName); // WITHOUT Trailing slash |
|
| 53 | + define($moduleDirNameUpper.'_UPLOAD_PATH', XOOPS_UPLOAD_PATH.'/'.$moduleDirName); // WITHOUT Trailing slash |
|
| 54 | + define($moduleDirNameUpper.'_CONSTANTS_DEFINED', 1); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $pathIcon16 = Admin::iconUrl('', '16'); |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | //$pathModIcon32 = \XoopsModules\Songlist\Helper::getInstance()->getModule()->getInfo('modicons32'); |
| 61 | 61 | |
| 62 | 62 | $icons = [ |
| 63 | - 'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
| 64 | - 'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
| 65 | - 'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
| 66 | - 'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
| 67 | - 'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
| 68 | - 'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
| 69 | - 'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
| 70 | - '0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
| 71 | - '1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
| 63 | + 'edit' => "<img src='".$pathIcon16."/edit.png' alt="._EDIT."' align='middle'>", |
|
| 64 | + 'delete' => "<img src='".$pathIcon16."/delete.png' alt='"._DELETE."' align='middle'>", |
|
| 65 | + 'clone' => "<img src='".$pathIcon16."/editcopy.png' alt='"._CLONE."' align='middle'>", |
|
| 66 | + 'preview' => "<img src='".$pathIcon16."/view.png' alt='"._PREVIEW."' align='middle'>", |
|
| 67 | + 'print' => "<img src='".$pathIcon16."/printer.png' alt='"._CLONE."' align='middle'>", |
|
| 68 | + 'pdf' => "<img src='".$pathIcon16."/pdf.png' alt='"._CLONE."' align='middle'>", |
|
| 69 | + 'add' => "<img src='".$pathIcon16."/add.png' alt='"._ADD."' align='middle'>", |
|
| 70 | + '0' => "<img src='".$pathIcon16."/0.png' alt='".0."' align='middle'>", |
|
| 71 | + '1' => "<img src='".$pathIcon16."/1.png' alt='".1."' align='middle'>", |
|
| 72 | 72 | ]; |
| 73 | 73 | |
| 74 | 74 | $debug = false; |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
| 88 | 88 | $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
| 89 | 89 | |
| 90 | - $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
| 90 | + $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL.'/modules/'.$moduleDirName.'/'.$pathModIcon16); |
|
| 91 | 91 | $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | xoops_loadLanguage('main', $moduleDirName); |
| 95 | 95 | if (class_exists('D3LanguageManager')) { |
| 96 | - require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3LanguageManager.class.php'; |
|
| 96 | + require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php'; |
|
| 97 | 97 | $langman = D3LanguageManager::getInstance(); |
| 98 | 98 | $langman->read('main.php', $moduleDirName); |
| 99 | 99 | } |
@@ -19,47 +19,47 @@ |
||
| 19 | 19 | $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
| 20 | 20 | |
| 21 | 21 | switch ($op) { |
| 22 | - default: |
|
| 23 | - case 'request': |
|
| 24 | - $url = $requestsHandler->getURL(); |
|
| 25 | - if (!mb_strpos($url, $_SERVER['REQUEST_URI']) && empty($_POST)) { |
|
| 26 | - header('HTTP/1.1 301 Moved Permanently'); |
|
| 27 | - header('Location: ' . $url); |
|
| 28 | - exit(0); |
|
| 29 | - } |
|
| 22 | + default: |
|
| 23 | + case 'request': |
|
| 24 | + $url = $requestsHandler->getURL(); |
|
| 25 | + if (!mb_strpos($url, $_SERVER['REQUEST_URI']) && empty($_POST)) { |
|
| 26 | + header('HTTP/1.1 301 Moved Permanently'); |
|
| 27 | + header('Location: ' . $url); |
|
| 28 | + exit(0); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - switch ($fct) { |
|
| 32 | - case 'save': |
|
| 33 | - if (checkEmail($_POST[0]['email'], true) && !empty($_POST[0]['email'])) { |
|
| 34 | - $request = $requestsHandler->create(); |
|
| 35 | - $request->setVars($_POST[0]); |
|
| 36 | - $rid = $requestsHandler->insert($request); |
|
| 37 | - if ($rid) { |
|
| 38 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT); |
|
| 39 | - } else { |
|
| 40 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT); |
|
| 41 | - } |
|
| 42 | - exit; |
|
| 43 | - } |
|
| 44 | - $error = _MD_SONGLIST_MSG_EMAILNOTSET; |
|
| 31 | + switch ($fct) { |
|
| 32 | + case 'save': |
|
| 33 | + if (checkEmail($_POST[0]['email'], true) && !empty($_POST[0]['email'])) { |
|
| 34 | + $request = $requestsHandler->create(); |
|
| 35 | + $request->setVars($_POST[0]); |
|
| 36 | + $rid = $requestsHandler->insert($request); |
|
| 37 | + if ($rid) { |
|
| 38 | + redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT); |
|
| 39 | + } else { |
|
| 40 | + redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT); |
|
| 41 | + } |
|
| 42 | + exit; |
|
| 43 | + } |
|
| 44 | + $error = _MD_SONGLIST_MSG_EMAILNOTSET; |
|
| 45 | 45 | |
| 46 | - // no break |
|
| 47 | - default: |
|
| 48 | - case 'list': |
|
| 49 | - $GLOBALS['xoopsOption']['template_main'] = 'songlist_requests_index.tpl'; |
|
| 50 | - require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 51 | - if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 52 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 53 | - $GLOBALS['loaded_jquery'] = true; |
|
| 54 | - } |
|
| 55 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 56 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 57 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 58 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false, false)); |
|
| 59 | - if (mb_strlen($error ?? '')) { |
|
| 60 | - xoops_error($error); |
|
| 61 | - } |
|
| 62 | - require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 63 | - break; |
|
| 64 | - } |
|
| 46 | + // no break |
|
| 47 | + default: |
|
| 48 | + case 'list': |
|
| 49 | + $GLOBALS['xoopsOption']['template_main'] = 'songlist_requests_index.tpl'; |
|
| 50 | + require_once $GLOBALS['xoops']->path('/header.php'); |
|
| 51 | + if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 52 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 53 | + $GLOBALS['loaded_jquery'] = true; |
|
| 54 | + } |
|
| 55 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 56 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 57 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 58 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false, false)); |
|
| 59 | + if (mb_strlen($error ?? '')) { |
|
| 60 | + xoops_error($error); |
|
| 61 | + } |
|
| 62 | + require_once $GLOBALS['xoops']->path('/footer.php'); |
|
| 63 | + break; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use XoopsModules\Songlist\RequestsHandler; |
| 7 | 7 | use XoopsModules\Songlist\Form\FormController; |
| 8 | 8 | |
| 9 | -require_once __DIR__ . '/header.php'; |
|
| 9 | +require_once __DIR__.'/header.php'; |
|
| 10 | 10 | |
| 11 | 11 | global $file, $op, $fct, $id, $value, $gid, $cid, $singer, $start, $limit; |
| 12 | 12 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $url = $requestsHandler->getURL(); |
| 25 | 25 | if (!mb_strpos($url, $_SERVER['REQUEST_URI']) && empty($_POST)) { |
| 26 | 26 | header('HTTP/1.1 301 Moved Permanently'); |
| 27 | - header('Location: ' . $url); |
|
| 27 | + header('Location: '.$url); |
|
| 28 | 28 | exit(0); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | $request->setVars($_POST[0]); |
| 36 | 36 | $rid = $requestsHandler->insert($request); |
| 37 | 37 | if ($rid) { |
| 38 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT); |
|
| 38 | + redirect_header($_SERVER['SCRIPT_NAME']."?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT); |
|
| 39 | 39 | } else { |
| 40 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT); |
|
| 40 | + redirect_header($_SERVER['SCRIPT_NAME']."?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT); |
|
| 41 | 41 | } |
| 42 | 42 | exit; |
| 43 | 43 | } |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | $GLOBALS['xoopsOption']['template_main'] = 'songlist_requests_index.tpl'; |
| 50 | 50 | require_once $GLOBALS['xoops']->path('/header.php'); |
| 51 | 51 | if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
| 52 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 52 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 53 | 53 | $GLOBALS['loaded_jquery'] = true; |
| 54 | 54 | } |
| 55 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 55 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 56 | 56 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
| 57 | 57 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
| 58 | 58 | $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false, false)); |
@@ -37,33 +37,33 @@ discard block |
||
| 37 | 37 | $helper->loadLanguage('common'); |
| 38 | 38 | |
| 39 | 39 | switch ($op) { |
| 40 | - case 'load': |
|
| 41 | - if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { |
|
| 42 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 43 | - redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 44 | - } |
|
| 45 | - loadSampleData(); |
|
| 46 | - } else { |
|
| 47 | - xoops_cp_header(); |
|
| 48 | - xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 49 | - xoops_cp_footer(); |
|
| 50 | - } |
|
| 51 | - break; |
|
| 52 | - case 'save': |
|
| 53 | - saveSampleData(); |
|
| 54 | - break; |
|
| 55 | - case 'clear': |
|
| 56 | - if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { |
|
| 57 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 58 | - redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 59 | - } |
|
| 60 | - clearSampleData(); |
|
| 61 | - } else { |
|
| 62 | - xoops_cp_header(); |
|
| 63 | - xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 64 | - xoops_cp_footer(); |
|
| 65 | - } |
|
| 66 | - break; |
|
| 40 | + case 'load': |
|
| 41 | + if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { |
|
| 42 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 43 | + redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 44 | + } |
|
| 45 | + loadSampleData(); |
|
| 46 | + } else { |
|
| 47 | + xoops_cp_header(); |
|
| 48 | + xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 49 | + xoops_cp_footer(); |
|
| 50 | + } |
|
| 51 | + break; |
|
| 52 | + case 'save': |
|
| 53 | + saveSampleData(); |
|
| 54 | + break; |
|
| 55 | + case 'clear': |
|
| 56 | + if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { |
|
| 57 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 58 | + redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 59 | + } |
|
| 60 | + clearSampleData(); |
|
| 61 | + } else { |
|
| 62 | + xoops_cp_header(); |
|
| 63 | + xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 64 | + xoops_cp_footer(); |
|
| 65 | + } |
|
| 66 | + break; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // XMF TableLoad for SAMPLE data |
@@ -73,43 +73,43 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | function loadSampleData(): void |
| 75 | 75 | { |
| 76 | - global $xoopsConfig; |
|
| 77 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 78 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 79 | - |
|
| 80 | - $utility = new Utility(); |
|
| 81 | - $configurator = new Configurator(); |
|
| 82 | - |
|
| 83 | - $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
|
| 84 | - |
|
| 85 | - $language = 'english/'; |
|
| 86 | - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 87 | - $language = $xoopsConfig['language'] . '/'; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - // load module tables |
|
| 91 | - foreach ($tables as $table) { |
|
| 92 | - $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
| 93 | - TableLoad::truncateTable($table); |
|
| 94 | - TableLoad::loadTableFromArray($table, $tabledata); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // load permissions |
|
| 98 | - $table = 'group_permission'; |
|
| 99 | - $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
| 100 | - $mid = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getVar('mid'); |
|
| 101 | - loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid); |
|
| 102 | - |
|
| 103 | - // --- COPY test folder files --------------- |
|
| 104 | - if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) { |
|
| 105 | - // $file = \dirname(__DIR__) . '/testdata/images/'; |
|
| 106 | - foreach (array_keys($configurator->copyTestFolders) as $i) { |
|
| 107 | - $src = $configurator->copyTestFolders[$i][0]; |
|
| 108 | - $dest = $configurator->copyTestFolders[$i][1]; |
|
| 109 | - $utility::rcopy($src, $dest); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS')); |
|
| 76 | + global $xoopsConfig; |
|
| 77 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 78 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 79 | + |
|
| 80 | + $utility = new Utility(); |
|
| 81 | + $configurator = new Configurator(); |
|
| 82 | + |
|
| 83 | + $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
|
| 84 | + |
|
| 85 | + $language = 'english/'; |
|
| 86 | + if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 87 | + $language = $xoopsConfig['language'] . '/'; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + // load module tables |
|
| 91 | + foreach ($tables as $table) { |
|
| 92 | + $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
| 93 | + TableLoad::truncateTable($table); |
|
| 94 | + TableLoad::loadTableFromArray($table, $tabledata); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // load permissions |
|
| 98 | + $table = 'group_permission'; |
|
| 99 | + $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
| 100 | + $mid = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getVar('mid'); |
|
| 101 | + loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid); |
|
| 102 | + |
|
| 103 | + // --- COPY test folder files --------------- |
|
| 104 | + if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) { |
|
| 105 | + // $file = \dirname(__DIR__) . '/testdata/images/'; |
|
| 106 | + foreach (array_keys($configurator->copyTestFolders) as $i) { |
|
| 107 | + $src = $configurator->copyTestFolders[$i][0]; |
|
| 108 | + $dest = $configurator->copyTestFolders[$i][1]; |
|
| 109 | + $utility::rcopy($src, $dest); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS')); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -117,32 +117,32 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | function saveSampleData(): void |
| 119 | 119 | { |
| 120 | - global $xoopsConfig; |
|
| 121 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 122 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 123 | - $helper = Helper::getInstance(); |
|
| 124 | - $tables = $helper->getModule()->getInfo('tables'); |
|
| 125 | - |
|
| 126 | - $languageFolder = __DIR__ . '/' . $xoopsConfig['language']; |
|
| 127 | - if (!file_exists($languageFolder . '/')) { |
|
| 128 | - Utility::createFolder($languageFolder . '/'); |
|
| 129 | - } |
|
| 130 | - $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; |
|
| 131 | - Utility::createFolder($exportFolder); |
|
| 132 | - |
|
| 133 | - // save module tables |
|
| 134 | - foreach ($tables as $table) { |
|
| 135 | - TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // save permissions |
|
| 139 | - $criteria = new \CriteriaCompo(); |
|
| 140 | - $criteria->add(new \Criteria('gperm_modid', $helper->getModule()->getVar('mid'))); |
|
| 141 | - $skipColumns[] = 'gperm_id'; |
|
| 142 | - TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns); |
|
| 143 | - unset($criteria); |
|
| 144 | - |
|
| 145 | - \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS')); |
|
| 120 | + global $xoopsConfig; |
|
| 121 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 122 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 123 | + $helper = Helper::getInstance(); |
|
| 124 | + $tables = $helper->getModule()->getInfo('tables'); |
|
| 125 | + |
|
| 126 | + $languageFolder = __DIR__ . '/' . $xoopsConfig['language']; |
|
| 127 | + if (!file_exists($languageFolder . '/')) { |
|
| 128 | + Utility::createFolder($languageFolder . '/'); |
|
| 129 | + } |
|
| 130 | + $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; |
|
| 131 | + Utility::createFolder($exportFolder); |
|
| 132 | + |
|
| 133 | + // save module tables |
|
| 134 | + foreach ($tables as $table) { |
|
| 135 | + TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // save permissions |
|
| 139 | + $criteria = new \CriteriaCompo(); |
|
| 140 | + $criteria->add(new \Criteria('gperm_modid', $helper->getModule()->getVar('mid'))); |
|
| 141 | + $skipColumns[] = 'gperm_id'; |
|
| 142 | + TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns); |
|
| 143 | + unset($criteria); |
|
| 144 | + |
|
| 145 | + \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS')); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | function exportSchema(): void |
| 152 | 152 | { |
| 153 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 154 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 155 | - |
|
| 156 | - try { |
|
| 157 | - // TODO set exportSchema |
|
| 158 | - // $migrate = new Migrate($moduleDirName); |
|
| 159 | - // $migrate->saveCurrentSchema(); |
|
| 160 | - // |
|
| 161 | - // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); |
|
| 162 | - } catch (\Throwable $e) { |
|
| 163 | - exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); |
|
| 164 | - } |
|
| 153 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 154 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 155 | + |
|
| 156 | + try { |
|
| 157 | + // TODO set exportSchema |
|
| 158 | + // $migrate = new Migrate($moduleDirName); |
|
| 159 | + // $migrate->saveCurrentSchema(); |
|
| 160 | + // |
|
| 161 | + // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); |
|
| 162 | + } catch (\Throwable $e) { |
|
| 163 | + exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -178,45 +178,45 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | function loadTableFromArrayWithReplace($table, $data, $search, $replace): int |
| 180 | 180 | { |
| 181 | - /** @var \XoopsMySQLDatabase $db */ |
|
| 182 | - $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 183 | - |
|
| 184 | - $prefixedTable = $db->prefix($table); |
|
| 185 | - $count = 0; |
|
| 186 | - |
|
| 187 | - $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace); |
|
| 188 | - |
|
| 189 | - $result = $db->queryF($sql); |
|
| 190 | - |
|
| 191 | - foreach ($data as $row) { |
|
| 192 | - $insertInto = 'INSERT INTO ' . $prefixedTable . ' ('; |
|
| 193 | - $valueClause = ' VALUES ('; |
|
| 194 | - $first = true; |
|
| 195 | - foreach ($row as $column => $value) { |
|
| 196 | - if ($first) { |
|
| 197 | - $first = false; |
|
| 198 | - } else { |
|
| 199 | - $insertInto .= ', '; |
|
| 200 | - $valueClause .= ', '; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - $insertInto .= $column; |
|
| 204 | - if ($search === $column) { |
|
| 205 | - $valueClause .= $db->quote($replace); |
|
| 206 | - } else { |
|
| 207 | - $valueClause .= $db->quote($value); |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $sql = $insertInto . ') ' . $valueClause . ')'; |
|
| 212 | - |
|
| 213 | - $result = $db->queryF($sql); |
|
| 214 | - if (false !== $result) { |
|
| 215 | - ++$count; |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - return $count; |
|
| 181 | + /** @var \XoopsMySQLDatabase $db */ |
|
| 182 | + $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 183 | + |
|
| 184 | + $prefixedTable = $db->prefix($table); |
|
| 185 | + $count = 0; |
|
| 186 | + |
|
| 187 | + $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace); |
|
| 188 | + |
|
| 189 | + $result = $db->queryF($sql); |
|
| 190 | + |
|
| 191 | + foreach ($data as $row) { |
|
| 192 | + $insertInto = 'INSERT INTO ' . $prefixedTable . ' ('; |
|
| 193 | + $valueClause = ' VALUES ('; |
|
| 194 | + $first = true; |
|
| 195 | + foreach ($row as $column => $value) { |
|
| 196 | + if ($first) { |
|
| 197 | + $first = false; |
|
| 198 | + } else { |
|
| 199 | + $insertInto .= ', '; |
|
| 200 | + $valueClause .= ', '; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + $insertInto .= $column; |
|
| 204 | + if ($search === $column) { |
|
| 205 | + $valueClause .= $db->quote($replace); |
|
| 206 | + } else { |
|
| 207 | + $valueClause .= $db->quote($value); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $sql = $insertInto . ') ' . $valueClause . ')'; |
|
| 212 | + |
|
| 213 | + $result = $db->queryF($sql); |
|
| 214 | + if (false !== $result) { |
|
| 215 | + ++$count; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + return $count; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -224,15 +224,15 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | function clearSampleData(): void |
| 226 | 226 | { |
| 227 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 228 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 229 | - $helper = Helper::getInstance(); |
|
| 230 | - // Load language files |
|
| 231 | - $helper->loadLanguage('common'); |
|
| 232 | - $tables = $helper->getModule()->getInfo('tables'); |
|
| 233 | - // truncate module tables |
|
| 234 | - foreach ($tables as $table) { |
|
| 235 | - \Xmf\Database\TableLoad::truncateTable($table); |
|
| 236 | - } |
|
| 237 | - redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK')); |
|
| 227 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 228 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
| 229 | + $helper = Helper::getInstance(); |
|
| 230 | + // Load language files |
|
| 231 | + $helper->loadLanguage('common'); |
|
| 232 | + $tables = $helper->getModule()->getInfo('tables'); |
|
| 233 | + // truncate module tables |
|
| 234 | + foreach ($tables as $table) { |
|
| 235 | + \Xmf\Database\TableLoad::truncateTable($table); |
|
| 236 | + } |
|
| 237 | + redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK')); |
|
| 238 | 238 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | /** @var Helper $helper */ |
| 25 | 25 | /** @var Utility $utility */ |
| 26 | 26 | /** @var Configurator $configurator */ |
| 27 | -require \dirname(__DIR__, 3) . '/include/cp_header.php'; |
|
| 28 | -require \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 27 | +require \dirname(__DIR__, 3).'/include/cp_header.php'; |
|
| 28 | +require \dirname(__DIR__).'/preloads/autoloader.php'; |
|
| 29 | 29 | |
| 30 | 30 | $op = Request::getCmd('op', ''); |
| 31 | 31 | |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | switch ($op) { |
| 40 | 40 | case 'load': |
| 41 | - if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { |
|
| 41 | + if (Request::hasVar('ok', 'REQUEST') && 1===Request::getInt('ok', 0)) { |
|
| 42 | 42 | if (!$GLOBALS['xoopsSecurity']->check()) { |
| 43 | 43 | redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 44 | 44 | } |
| 45 | 45 | loadSampleData(); |
| 46 | 46 | } else { |
| 47 | 47 | xoops_cp_header(); |
| 48 | - xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 48 | + xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', constant('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA_CONFIRM'), constant('CO_'.$moduleDirNameUpper.'_'.'CONFIRM'), true); |
|
| 49 | 49 | xoops_cp_footer(); |
| 50 | 50 | } |
| 51 | 51 | break; |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | saveSampleData(); |
| 54 | 54 | break; |
| 55 | 55 | case 'clear': |
| 56 | - if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) { |
|
| 56 | + if (Request::hasVar('ok', 'REQUEST') && 1===Request::getInt('ok', 0)) { |
|
| 57 | 57 | if (!$GLOBALS['xoopsSecurity']->check()) { |
| 58 | 58 | redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 59 | 59 | } |
| 60 | 60 | clearSampleData(); |
| 61 | 61 | } else { |
| 62 | 62 | xoops_cp_header(); |
| 63 | - xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
|
| 63 | + xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA')), constant('CO_'.$moduleDirNameUpper.'_'.'CONFIRM'), true); |
|
| 64 | 64 | xoops_cp_footer(); |
| 65 | 65 | } |
| 66 | 66 | break; |
@@ -83,25 +83,25 @@ discard block |
||
| 83 | 83 | $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables'); |
| 84 | 84 | |
| 85 | 85 | $language = 'english/'; |
| 86 | - if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) { |
|
| 87 | - $language = $xoopsConfig['language'] . '/'; |
|
| 86 | + if (is_dir(__DIR__.'/'.$xoopsConfig['language'])) { |
|
| 87 | + $language = $xoopsConfig['language'].'/'; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // load module tables |
| 91 | 91 | foreach ($tables as $table) { |
| 92 | - $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
| 92 | + $tabledata = Yaml::readWrapped($language.$table.'.yml'); |
|
| 93 | 93 | TableLoad::truncateTable($table); |
| 94 | 94 | TableLoad::loadTableFromArray($table, $tabledata); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // load permissions |
| 98 | 98 | $table = 'group_permission'; |
| 99 | - $tabledata = Yaml::readWrapped($language . $table . '.yml'); |
|
| 99 | + $tabledata = Yaml::readWrapped($language.$table.'.yml'); |
|
| 100 | 100 | $mid = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getVar('mid'); |
| 101 | 101 | loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid); |
| 102 | 102 | |
| 103 | 103 | // --- COPY test folder files --------------- |
| 104 | - if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) { |
|
| 104 | + if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders)>0) { |
|
| 105 | 105 | // $file = \dirname(__DIR__) . '/testdata/images/'; |
| 106 | 106 | foreach (array_keys($configurator->copyTestFolders) as $i) { |
| 107 | 107 | $src = $configurator->copyTestFolders[$i][0]; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $utility::rcopy($src, $dest); |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | - \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS')); |
|
| 112 | + \redirect_header('../admin/index.php', 1, \constant('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA_SUCCESS')); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -123,26 +123,26 @@ discard block |
||
| 123 | 123 | $helper = Helper::getInstance(); |
| 124 | 124 | $tables = $helper->getModule()->getInfo('tables'); |
| 125 | 125 | |
| 126 | - $languageFolder = __DIR__ . '/' . $xoopsConfig['language']; |
|
| 127 | - if (!file_exists($languageFolder . '/')) { |
|
| 128 | - Utility::createFolder($languageFolder . '/'); |
|
| 126 | + $languageFolder = __DIR__.'/'.$xoopsConfig['language']; |
|
| 127 | + if (!file_exists($languageFolder.'/')) { |
|
| 128 | + Utility::createFolder($languageFolder.'/'); |
|
| 129 | 129 | } |
| 130 | - $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/'; |
|
| 130 | + $exportFolder = $languageFolder.'/Exports-'.date('Y-m-d-H-i-s').'/'; |
|
| 131 | 131 | Utility::createFolder($exportFolder); |
| 132 | 132 | |
| 133 | 133 | // save module tables |
| 134 | 134 | foreach ($tables as $table) { |
| 135 | - TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml'); |
|
| 135 | + TableLoad::saveTableToYamlFile($table, $exportFolder.$table.'.yml'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // save permissions |
| 139 | 139 | $criteria = new \CriteriaCompo(); |
| 140 | 140 | $criteria->add(new \Criteria('gperm_modid', $helper->getModule()->getVar('mid'))); |
| 141 | 141 | $skipColumns[] = 'gperm_id'; |
| 142 | - TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns); |
|
| 142 | + TableLoad::saveTableToYamlFile('group_permission', $exportFolder.'group_permission.yml', $criteria, $skipColumns); |
|
| 143 | 143 | unset($criteria); |
| 144 | 144 | |
| 145 | - \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS')); |
|
| 145 | + \redirect_header('../admin/index.php', 1, \constant('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA_SUCCESS')); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | // |
| 161 | 161 | // redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS')); |
| 162 | 162 | } catch (\Throwable $e) { |
| 163 | - exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR')); |
|
| 163 | + exit(constant('CO_'.$moduleDirNameUpper.'_'.'EXPORT_SCHEMA_ERROR')); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | $prefixedTable = $db->prefix($table); |
| 185 | 185 | $count = 0; |
| 186 | 186 | |
| 187 | - $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace); |
|
| 187 | + $sql = 'DELETE FROM '.$prefixedTable.' WHERE `'.$search.'`='.$db->quote($replace); |
|
| 188 | 188 | |
| 189 | 189 | $result = $db->queryF($sql); |
| 190 | 190 | |
| 191 | 191 | foreach ($data as $row) { |
| 192 | - $insertInto = 'INSERT INTO ' . $prefixedTable . ' ('; |
|
| 192 | + $insertInto = 'INSERT INTO '.$prefixedTable.' ('; |
|
| 193 | 193 | $valueClause = ' VALUES ('; |
| 194 | 194 | $first = true; |
| 195 | 195 | foreach ($row as $column => $value) { |
@@ -201,17 +201,17 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $insertInto .= $column; |
| 204 | - if ($search === $column) { |
|
| 204 | + if ($search===$column) { |
|
| 205 | 205 | $valueClause .= $db->quote($replace); |
| 206 | 206 | } else { |
| 207 | 207 | $valueClause .= $db->quote($value); |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - $sql = $insertInto . ') ' . $valueClause . ')'; |
|
| 211 | + $sql = $insertInto.') '.$valueClause.')'; |
|
| 212 | 212 | |
| 213 | 213 | $result = $db->queryF($sql); |
| 214 | - if (false !== $result) { |
|
| 214 | + if (false!==$result) { |
|
| 215 | 215 | ++$count; |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -234,5 +234,5 @@ discard block |
||
| 234 | 234 | foreach ($tables as $table) { |
| 235 | 235 | \Xmf\Database\TableLoad::truncateTable($table); |
| 236 | 236 | } |
| 237 | - redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK')); |
|
| 237 | + redirect_header($helper->url('admin/index.php'), 1, constant('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA_OK')); |
|
| 238 | 238 | } |