@@ -22,102 +22,102 @@ discard block |
||
| 22 | 22 | $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
| 23 | 23 | |
| 24 | 24 | switch ($op) { |
| 25 | - default: |
|
| 26 | - case 'albums': |
|
| 27 | - switch ($fct) { |
|
| 28 | - default: |
|
| 29 | - case 'list': |
|
| 30 | - $adminObject = Admin::getInstance(); |
|
| 31 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 32 | - |
|
| 33 | - /** @var AlbumsHandler $albumsHandler */ |
|
| 34 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 35 | - |
|
| 36 | - $criteria = $albumsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 37 | - $ttl = $albumsHandler->getCount($criteria); |
|
| 38 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 39 | - |
|
| 40 | - $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']); |
|
| 41 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 42 | - |
|
| 43 | - foreach ($albumsHandler->filterFields() as $id => $key) { |
|
| 44 | - $GLOBALS['xoopsTpl']->assign( |
|
| 45 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 46 | - '<a href="' |
|
| 47 | - . $_SERVER['SCRIPT_NAME'] |
|
| 48 | - . '?start=' |
|
| 49 | - . $GLOBALS['start'] |
|
| 50 | - . '&limit=' |
|
| 51 | - . $GLOBALS['limit'] |
|
| 52 | - . '&sort=' |
|
| 53 | - . $key |
|
| 54 | - . '&order=' |
|
| 55 | - . (($key == $GLOBALS['sort']) ? ('DESC' == $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 56 | - . '&op=' |
|
| 57 | - . $GLOBALS['op'] |
|
| 58 | - . '&filter=' |
|
| 59 | - . $GLOBALS['filter'] |
|
| 60 | - . '">' |
|
| 61 | - . (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))) |
|
| 62 | - . '</a>' |
|
| 63 | - ); |
|
| 64 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 68 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 70 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 71 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 73 | - |
|
| 74 | - $criteria->setStart($GLOBALS['start']); |
|
| 75 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 76 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 77 | - $criteria->setOrder($GLOBALS['order']); |
|
| 78 | - |
|
| 79 | - $albumsArray = $albumsHandler->getObjects($criteria, true); |
|
| 80 | - foreach ($albumsArray as $cid => $album) { |
|
| 81 | - if (is_object($album)) { |
|
| 82 | - $GLOBALS['xoopsTpl']->append('albums', $album->toArray()); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormAlbums(false)); |
|
| 86 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 87 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_list.tpl'); |
|
| 88 | - break; |
|
| 89 | - case 'new': |
|
| 90 | - case 'edit': |
|
| 91 | - $adminObject = Admin::getInstance(); |
|
| 92 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 93 | - |
|
| 94 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 95 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 96 | - $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 97 | - } else { |
|
| 98 | - $album = $albumsHandler->create(); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $GLOBALS['xoopsTpl']->assign('form', $album->getForm()); |
|
| 102 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 103 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_edit.tpl'); |
|
| 104 | - break; |
|
| 105 | - case 'save': |
|
| 106 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 107 | - $id = 0; |
|
| 108 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 109 | - if ($id) { |
|
| 110 | - $album = $albumsHandler->get($id); |
|
| 111 | - } else { |
|
| 112 | - $album = $albumsHandler->create(); |
|
| 113 | - } |
|
| 114 | - $album->setVars($_POST[$id]); |
|
| 115 | - |
|
| 116 | - if (!$id = $albumsHandler->insert($album)) { |
|
| 117 | - 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); |
|
| 118 | - exit(0); |
|
| 119 | - } |
|
| 120 | - if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 25 | + default: |
|
| 26 | + case 'albums': |
|
| 27 | + switch ($fct) { |
|
| 28 | + default: |
|
| 29 | + case 'list': |
|
| 30 | + $adminObject = Admin::getInstance(); |
|
| 31 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 32 | + |
|
| 33 | + /** @var AlbumsHandler $albumsHandler */ |
|
| 34 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 35 | + |
|
| 36 | + $criteria = $albumsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 37 | + $ttl = $albumsHandler->getCount($criteria); |
|
| 38 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 39 | + |
|
| 40 | + $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']); |
|
| 41 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 42 | + |
|
| 43 | + foreach ($albumsHandler->filterFields() as $id => $key) { |
|
| 44 | + $GLOBALS['xoopsTpl']->assign( |
|
| 45 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 46 | + '<a href="' |
|
| 47 | + . $_SERVER['SCRIPT_NAME'] |
|
| 48 | + . '?start=' |
|
| 49 | + . $GLOBALS['start'] |
|
| 50 | + . '&limit=' |
|
| 51 | + . $GLOBALS['limit'] |
|
| 52 | + . '&sort=' |
|
| 53 | + . $key |
|
| 54 | + . '&order=' |
|
| 55 | + . (($key == $GLOBALS['sort']) ? ('DESC' == $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 56 | + . '&op=' |
|
| 57 | + . $GLOBALS['op'] |
|
| 58 | + . '&filter=' |
|
| 59 | + . $GLOBALS['filter'] |
|
| 60 | + . '">' |
|
| 61 | + . (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))) |
|
| 62 | + . '</a>' |
|
| 63 | + ); |
|
| 64 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 70 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 71 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 73 | + |
|
| 74 | + $criteria->setStart($GLOBALS['start']); |
|
| 75 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 76 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 77 | + $criteria->setOrder($GLOBALS['order']); |
|
| 78 | + |
|
| 79 | + $albumsArray = $albumsHandler->getObjects($criteria, true); |
|
| 80 | + foreach ($albumsArray as $cid => $album) { |
|
| 81 | + if (is_object($album)) { |
|
| 82 | + $GLOBALS['xoopsTpl']->append('albums', $album->toArray()); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormAlbums(false)); |
|
| 86 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 87 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_list.tpl'); |
|
| 88 | + break; |
|
| 89 | + case 'new': |
|
| 90 | + case 'edit': |
|
| 91 | + $adminObject = Admin::getInstance(); |
|
| 92 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 93 | + |
|
| 94 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 95 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 96 | + $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 97 | + } else { |
|
| 98 | + $album = $albumsHandler->create(); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $GLOBALS['xoopsTpl']->assign('form', $album->getForm()); |
|
| 102 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 103 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_edit.tpl'); |
|
| 104 | + break; |
|
| 105 | + case 'save': |
|
| 106 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 107 | + $id = 0; |
|
| 108 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 109 | + if ($id) { |
|
| 110 | + $album = $albumsHandler->get($id); |
|
| 111 | + } else { |
|
| 112 | + $album = $albumsHandler->create(); |
|
| 113 | + } |
|
| 114 | + $album->setVars($_POST[$id]); |
|
| 115 | + |
|
| 116 | + if (!$id = $albumsHandler->insert($album)) { |
|
| 117 | + 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); |
|
| 118 | + exit(0); |
|
| 119 | + } |
|
| 120 | + if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 121 | 121 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
| 122 | 122 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
| 123 | 123 | // foreach (explode('/', $folders) as $folder) { |
@@ -130,99 +130,99 @@ discard block |
||
| 130 | 130 | // } |
| 131 | 131 | |
| 132 | 132 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 133 | - $album = $albumsHandler->get($id); |
|
| 134 | - $uploader = new Uploader( |
|
| 135 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']. 'albums'), |
|
| 136 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 137 | - $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 138 | - 0, |
|
| 139 | - 0, |
|
| 140 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 141 | - ); |
|
| 142 | - try { |
|
| 143 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 144 | - } catch (Exception $e) { |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - if ($uploader->fetchMedia('image')) { |
|
| 148 | - if (!$uploader->upload()) { |
|
| 149 | - $adminObject = Admin::getInstance(); |
|
| 150 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 151 | - echo $uploader->getErrors(); |
|
| 152 | - require __DIR__ . '/admin_footer.php'; |
|
| 153 | - exit(0); |
|
| 154 | - } |
|
| 155 | - if (mb_strlen($album->getVar('image'))) { |
|
| 156 | - unlink($GLOBALS['xoops']->path($album->getVar('path')) . $album->getVar('image')); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']. 'albums/') ; |
|
| 160 | - $album->setVar('image', $uploader->getSavedFileName()); |
|
| 161 | - @$albumsHandler->insert($album); |
|
| 162 | - } else { |
|
| 163 | - $adminObject = Admin::getInstance(); |
|
| 164 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 165 | - echo $uploader->getErrors(); |
|
| 166 | - require __DIR__ . '/admin_footer.php'; |
|
| 167 | - exit(0); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - if ('new' == $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 172 | - redirect_header( |
|
| 173 | - $_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'], |
|
| 174 | - 10, |
|
| 175 | - _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY |
|
| 176 | - ); |
|
| 177 | - } else { |
|
| 178 | - 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); |
|
| 179 | - } |
|
| 180 | - exit(0); |
|
| 181 | - |
|
| 182 | - break; |
|
| 183 | - case 'savelist': |
|
| 184 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 185 | - foreach ($_REQUEST['id'] as $id) { |
|
| 186 | - $album = $albumsHandler->get($id); |
|
| 187 | - $album->setVars($_POST[$id]); |
|
| 188 | - if (!$albumsHandler->insert($album)) { |
|
| 189 | - redirect_header( |
|
| 190 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 191 | - 10, |
|
| 192 | - _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE |
|
| 193 | - ); |
|
| 194 | - exit(0); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - 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); |
|
| 198 | - exit(0); |
|
| 199 | - break; |
|
| 200 | - case 'delete': |
|
| 201 | - $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 202 | - $id = 0; |
|
| 203 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 204 | - $album = $albumsHandler->get($id); |
|
| 205 | - if (!$albumsHandler->delete($album)) { |
|
| 206 | - redirect_header( |
|
| 207 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 208 | - 10, |
|
| 209 | - _AM_SONGLIST_MSG_ALBUMS_FAILEDTODELETE |
|
| 210 | - ); |
|
| 211 | - exit(0); |
|
| 212 | - } |
|
| 213 | - 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); |
|
| 214 | - exit(0); |
|
| 215 | - } |
|
| 216 | - $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 217 | - xoops_confirm( |
|
| 218 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 219 | - $_SERVER['SCRIPT_NAME'], |
|
| 220 | - sprintf(_AM_SONGLIST_MSG_ALBUMS_DELETE, $album->getVar('title')) |
|
| 221 | - ); |
|
| 222 | - |
|
| 223 | - break; |
|
| 224 | - } |
|
| 225 | - break; |
|
| 133 | + $album = $albumsHandler->get($id); |
|
| 134 | + $uploader = new Uploader( |
|
| 135 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']. 'albums'), |
|
| 136 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 137 | + $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 138 | + 0, |
|
| 139 | + 0, |
|
| 140 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 141 | + ); |
|
| 142 | + try { |
|
| 143 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 144 | + } catch (Exception $e) { |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + if ($uploader->fetchMedia('image')) { |
|
| 148 | + if (!$uploader->upload()) { |
|
| 149 | + $adminObject = Admin::getInstance(); |
|
| 150 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 151 | + echo $uploader->getErrors(); |
|
| 152 | + require __DIR__ . '/admin_footer.php'; |
|
| 153 | + exit(0); |
|
| 154 | + } |
|
| 155 | + if (mb_strlen($album->getVar('image'))) { |
|
| 156 | + unlink($GLOBALS['xoops']->path($album->getVar('path')) . $album->getVar('image')); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']. 'albums/') ; |
|
| 160 | + $album->setVar('image', $uploader->getSavedFileName()); |
|
| 161 | + @$albumsHandler->insert($album); |
|
| 162 | + } else { |
|
| 163 | + $adminObject = Admin::getInstance(); |
|
| 164 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 165 | + echo $uploader->getErrors(); |
|
| 166 | + require __DIR__ . '/admin_footer.php'; |
|
| 167 | + exit(0); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + if ('new' == $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 172 | + redirect_header( |
|
| 173 | + $_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'], |
|
| 174 | + 10, |
|
| 175 | + _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY |
|
| 176 | + ); |
|
| 177 | + } else { |
|
| 178 | + 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); |
|
| 179 | + } |
|
| 180 | + exit(0); |
|
| 181 | + |
|
| 182 | + break; |
|
| 183 | + case 'savelist': |
|
| 184 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 185 | + foreach ($_REQUEST['id'] as $id) { |
|
| 186 | + $album = $albumsHandler->get($id); |
|
| 187 | + $album->setVars($_POST[$id]); |
|
| 188 | + if (!$albumsHandler->insert($album)) { |
|
| 189 | + redirect_header( |
|
| 190 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 191 | + 10, |
|
| 192 | + _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE |
|
| 193 | + ); |
|
| 194 | + exit(0); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + 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); |
|
| 198 | + exit(0); |
|
| 199 | + break; |
|
| 200 | + case 'delete': |
|
| 201 | + $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
|
| 202 | + $id = 0; |
|
| 203 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 204 | + $album = $albumsHandler->get($id); |
|
| 205 | + if (!$albumsHandler->delete($album)) { |
|
| 206 | + redirect_header( |
|
| 207 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 208 | + 10, |
|
| 209 | + _AM_SONGLIST_MSG_ALBUMS_FAILEDTODELETE |
|
| 210 | + ); |
|
| 211 | + exit(0); |
|
| 212 | + } |
|
| 213 | + 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); |
|
| 214 | + exit(0); |
|
| 215 | + } |
|
| 216 | + $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 217 | + xoops_confirm( |
|
| 218 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 219 | + $_SERVER['SCRIPT_NAME'], |
|
| 220 | + sprintf(_AM_SONGLIST_MSG_ALBUMS_DELETE, $album->getVar('title')) |
|
| 221 | + ); |
|
| 222 | + |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | + break; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | xoops_cp_footer(); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use XoopsModules\Songlist\AlbumsHandler; |
| 8 | 8 | use XoopsModules\Songlist\Form\FormController; |
| 9 | 9 | |
| 10 | -require __DIR__ . '/header.php'; |
|
| 10 | +require __DIR__.'/header.php'; |
|
| 11 | 11 | |
| 12 | 12 | xoops_loadLanguage('admin', 'songlist'); |
| 13 | 13 | |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
| 19 | 19 | $start = Request::getInt('start', 0, 'REQUEST'); |
| 20 | 20 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
| 21 | -$sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 22 | -$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
|
| 21 | +$sort = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 22 | +$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1'; |
|
| 23 | 23 | |
| 24 | 24 | switch ($op) { |
| 25 | 25 | default: |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $criteria = $albumsHandler->getFilterCriteria($GLOBALS['filter']); |
| 37 | 37 | $ttl = $albumsHandler->getCount($criteria); |
| 38 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 38 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 39 | 39 | |
| 40 | - $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']); |
|
| 40 | + $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']); |
|
| 41 | 41 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 42 | 42 | |
| 43 | 43 | foreach ($albumsHandler->filterFields() as $id => $key) { |
| 44 | 44 | $GLOBALS['xoopsTpl']->assign( |
| 45 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 45 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 46 | 46 | '<a href="' |
| 47 | 47 | . $_SERVER['SCRIPT_NAME'] |
| 48 | 48 | . '?start=' |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | . '&sort=' |
| 53 | 53 | . $key |
| 54 | 54 | . '&order=' |
| 55 | - . (($key == $GLOBALS['sort']) ? ('DESC' == $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 55 | + . (($key==$GLOBALS['sort']) ? ('DESC'==$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 56 | 56 | . '&op=' |
| 57 | 57 | . $GLOBALS['op'] |
| 58 | 58 | . '&filter=' |
| 59 | 59 | . $GLOBALS['filter'] |
| 60 | 60 | . '">' |
| 61 | - . (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))) |
|
| 61 | + . (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))) |
|
| 62 | 62 | . '</a>' |
| 63 | 63 | ); |
| 64 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 64 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $criteria->setStart($GLOBALS['start']); |
| 75 | 75 | $criteria->setLimit($GLOBALS['limit']); |
| 76 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 76 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 77 | 77 | $criteria->setOrder($GLOBALS['order']); |
| 78 | 78 | |
| 79 | 79 | $albumsArray = $albumsHandler->getObjects($criteria, true); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $album->setVars($_POST[$id]); |
| 115 | 115 | |
| 116 | 116 | if (!$id = $albumsHandler->insert($album)) { |
| 117 | - 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); |
|
| 117 | + 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); |
|
| 118 | 118 | exit(0); |
| 119 | 119 | } |
| 120 | 120 | if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 133 | 133 | $album = $albumsHandler->get($id); |
| 134 | 134 | $uploader = new Uploader( |
| 135 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']. 'albums'), |
|
| 135 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].'albums'), |
|
| 136 | 136 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
| 137 | 137 | $GLOBALS['songlistModuleConfig']['filesize_upload'], |
| 138 | 138 | 0, |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
| 141 | 141 | ); |
| 142 | 142 | try { |
| 143 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 143 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
| 144 | 144 | } catch (Exception $e) { |
| 145 | 145 | } |
| 146 | 146 | |
@@ -149,33 +149,33 @@ discard block |
||
| 149 | 149 | $adminObject = Admin::getInstance(); |
| 150 | 150 | $adminObject->displayNavigation(basename(__FILE__)); |
| 151 | 151 | echo $uploader->getErrors(); |
| 152 | - require __DIR__ . '/admin_footer.php'; |
|
| 152 | + require __DIR__.'/admin_footer.php'; |
|
| 153 | 153 | exit(0); |
| 154 | 154 | } |
| 155 | 155 | if (mb_strlen($album->getVar('image'))) { |
| 156 | - unlink($GLOBALS['xoops']->path($album->getVar('path')) . $album->getVar('image')); |
|
| 156 | + unlink($GLOBALS['xoops']->path($album->getVar('path')).$album->getVar('image')); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']. 'albums/') ; |
|
| 159 | + $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas'].'albums/'); |
|
| 160 | 160 | $album->setVar('image', $uploader->getSavedFileName()); |
| 161 | 161 | @$albumsHandler->insert($album); |
| 162 | 162 | } else { |
| 163 | 163 | $adminObject = Admin::getInstance(); |
| 164 | 164 | $adminObject->displayNavigation(basename(__FILE__)); |
| 165 | 165 | echo $uploader->getErrors(); |
| 166 | - require __DIR__ . '/admin_footer.php'; |
|
| 166 | + require __DIR__.'/admin_footer.php'; |
|
| 167 | 167 | exit(0); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ('new' == $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 171 | + if ('new'==$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 172 | 172 | redirect_header( |
| 173 | - $_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'], |
|
| 173 | + $_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'], |
|
| 174 | 174 | 10, |
| 175 | 175 | _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY |
| 176 | 176 | ); |
| 177 | 177 | } else { |
| 178 | - 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); |
|
| 178 | + 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); |
|
| 179 | 179 | } |
| 180 | 180 | exit(0); |
| 181 | 181 | |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | $album->setVars($_POST[$id]); |
| 188 | 188 | if (!$albumsHandler->insert($album)) { |
| 189 | 189 | redirect_header( |
| 190 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 190 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 191 | 191 | 10, |
| 192 | 192 | _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE |
| 193 | 193 | ); |
| 194 | 194 | exit(0); |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - 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); |
|
| 197 | + 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); |
|
| 198 | 198 | exit(0); |
| 199 | 199 | break; |
| 200 | 200 | case 'delete': |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | $album = $albumsHandler->get($id); |
| 205 | 205 | if (!$albumsHandler->delete($album)) { |
| 206 | 206 | redirect_header( |
| 207 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 207 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 208 | 208 | 10, |
| 209 | 209 | _AM_SONGLIST_MSG_ALBUMS_FAILEDTODELETE |
| 210 | 210 | ); |
| 211 | 211 | exit(0); |
| 212 | 212 | } |
| 213 | - 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); |
|
| 213 | + 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); |
|
| 214 | 214 | exit(0); |
| 215 | 215 | } |
| 216 | 216 | $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -22,102 +22,102 @@ discard block |
||
| 22 | 22 | $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
| 23 | 23 | |
| 24 | 24 | switch ($op) { |
| 25 | - default: |
|
| 26 | - case 'votes': |
|
| 27 | - switch ($fct) { |
|
| 28 | - default: |
|
| 29 | - case 'list': |
|
| 30 | - $adminObject = Admin::getInstance(); |
|
| 31 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 32 | - |
|
| 33 | - /** @var VotesHandler $votesHandler */ |
|
| 34 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 35 | - |
|
| 36 | - $criteria = $votesHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 37 | - $ttl = $votesHandler->getCount($criteria); |
|
| 38 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 39 | - |
|
| 40 | - $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']); |
|
| 41 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 42 | - |
|
| 43 | - foreach ($votesHandler->filterFields() as $id => $key) { |
|
| 44 | - $GLOBALS['xoopsTpl']->assign( |
|
| 45 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 46 | - '<a href="' |
|
| 47 | - . $_SERVER['SCRIPT_NAME'] |
|
| 48 | - . '?start=' |
|
| 49 | - . $GLOBALS['start'] |
|
| 50 | - . '&limit=' |
|
| 51 | - . $GLOBALS['limit'] |
|
| 52 | - . '&sort=' |
|
| 53 | - . $key |
|
| 54 | - . '&order=' |
|
| 55 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 56 | - . '&op=' |
|
| 57 | - . $GLOBALS['op'] |
|
| 58 | - . '&filter=' |
|
| 59 | - . $GLOBALS['filter'] |
|
| 60 | - . '">' |
|
| 61 | - . (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))) |
|
| 62 | - . '</a>' |
|
| 63 | - ); |
|
| 64 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 68 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 70 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 71 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 73 | - |
|
| 74 | - $criteria->setStart($GLOBALS['start']); |
|
| 75 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 76 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 77 | - $criteria->setOrder($GLOBALS['order']); |
|
| 78 | - |
|
| 79 | - $votess = $votesHandler->getObjects($criteria, true); |
|
| 80 | - foreach ($votess as $cid => $votes) { |
|
| 81 | - if (is_object($votes)) { |
|
| 82 | - $GLOBALS['xoopsTpl']->append('categories', $votes->toArray()); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - //$GLOBALS['xoopsTpl']->assign('form', FormController::votes_get_form(false)); |
|
| 86 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 87 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_list.tpl'); |
|
| 88 | - break; |
|
| 89 | - case 'new': |
|
| 90 | - case 'edit': |
|
| 91 | - $adminObject = Admin::getInstance(); |
|
| 92 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 93 | - |
|
| 94 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 95 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 96 | - $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 97 | - } else { |
|
| 98 | - $votes = $votesHandler->create(); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $GLOBALS['xoopsTpl']->assign('form', $votes->getForm()); |
|
| 102 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 103 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_edit.tpl'); |
|
| 104 | - break; |
|
| 105 | - case 'save': |
|
| 106 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 107 | - $id = 0; |
|
| 108 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 109 | - if ($id) { |
|
| 110 | - $votes = $votesHandler->get($id); |
|
| 111 | - } else { |
|
| 112 | - $votes = $votesHandler->create(); |
|
| 113 | - } |
|
| 114 | - $votes->setVars($_POST[$id]); |
|
| 115 | - |
|
| 116 | - if (!$id = $votesHandler->insert($votes)) { |
|
| 117 | - 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); |
|
| 118 | - exit(0); |
|
| 119 | - } |
|
| 120 | - if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 25 | + default: |
|
| 26 | + case 'votes': |
|
| 27 | + switch ($fct) { |
|
| 28 | + default: |
|
| 29 | + case 'list': |
|
| 30 | + $adminObject = Admin::getInstance(); |
|
| 31 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 32 | + |
|
| 33 | + /** @var VotesHandler $votesHandler */ |
|
| 34 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 35 | + |
|
| 36 | + $criteria = $votesHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 37 | + $ttl = $votesHandler->getCount($criteria); |
|
| 38 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 39 | + |
|
| 40 | + $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']); |
|
| 41 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 42 | + |
|
| 43 | + foreach ($votesHandler->filterFields() as $id => $key) { |
|
| 44 | + $GLOBALS['xoopsTpl']->assign( |
|
| 45 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 46 | + '<a href="' |
|
| 47 | + . $_SERVER['SCRIPT_NAME'] |
|
| 48 | + . '?start=' |
|
| 49 | + . $GLOBALS['start'] |
|
| 50 | + . '&limit=' |
|
| 51 | + . $GLOBALS['limit'] |
|
| 52 | + . '&sort=' |
|
| 53 | + . $key |
|
| 54 | + . '&order=' |
|
| 55 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 56 | + . '&op=' |
|
| 57 | + . $GLOBALS['op'] |
|
| 58 | + . '&filter=' |
|
| 59 | + . $GLOBALS['filter'] |
|
| 60 | + . '">' |
|
| 61 | + . (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))) |
|
| 62 | + . '</a>' |
|
| 63 | + ); |
|
| 64 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 70 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 71 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 73 | + |
|
| 74 | + $criteria->setStart($GLOBALS['start']); |
|
| 75 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 76 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 77 | + $criteria->setOrder($GLOBALS['order']); |
|
| 78 | + |
|
| 79 | + $votess = $votesHandler->getObjects($criteria, true); |
|
| 80 | + foreach ($votess as $cid => $votes) { |
|
| 81 | + if (is_object($votes)) { |
|
| 82 | + $GLOBALS['xoopsTpl']->append('categories', $votes->toArray()); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + //$GLOBALS['xoopsTpl']->assign('form', FormController::votes_get_form(false)); |
|
| 86 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 87 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_list.tpl'); |
|
| 88 | + break; |
|
| 89 | + case 'new': |
|
| 90 | + case 'edit': |
|
| 91 | + $adminObject = Admin::getInstance(); |
|
| 92 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 93 | + |
|
| 94 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 95 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 96 | + $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 97 | + } else { |
|
| 98 | + $votes = $votesHandler->create(); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $GLOBALS['xoopsTpl']->assign('form', $votes->getForm()); |
|
| 102 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 103 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_edit.tpl'); |
|
| 104 | + break; |
|
| 105 | + case 'save': |
|
| 106 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 107 | + $id = 0; |
|
| 108 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 109 | + if ($id) { |
|
| 110 | + $votes = $votesHandler->get($id); |
|
| 111 | + } else { |
|
| 112 | + $votes = $votesHandler->create(); |
|
| 113 | + } |
|
| 114 | + $votes->setVars($_POST[$id]); |
|
| 115 | + |
|
| 116 | + if (!$id = $votesHandler->insert($votes)) { |
|
| 117 | + 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); |
|
| 118 | + exit(0); |
|
| 119 | + } |
|
| 120 | + if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
|
| 121 | 121 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
| 122 | 122 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
| 123 | 123 | // foreach (explode('/', $folders) as $folder) { |
@@ -130,99 +130,99 @@ discard block |
||
| 130 | 130 | // } |
| 131 | 131 | |
| 132 | 132 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 133 | - $votes = $votesHandler->get($id); |
|
| 134 | - $uploader = new Uploader( |
|
| 135 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 136 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 137 | - $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 138 | - 0, |
|
| 139 | - 0, |
|
| 140 | - explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 141 | - ); |
|
| 142 | - try { |
|
| 143 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 144 | - } catch (Exception $e) { |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - if ($uploader->fetchMedia('image')) { |
|
| 148 | - if (!$uploader->upload()) { |
|
| 149 | - $adminObject = Admin::getInstance(); |
|
| 150 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 151 | - echo $uploader->getErrors(); |
|
| 152 | - require __DIR__ . '/admin_footer.php'; |
|
| 153 | - exit(0); |
|
| 154 | - } |
|
| 155 | - if (mb_strlen($votes->getVar('image'))) { |
|
| 156 | - unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image')); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 160 | - $votes->setVar('image', $uploader->getSavedFileName()); |
|
| 161 | - @$votesHandler->insert($votes); |
|
| 162 | - } else { |
|
| 163 | - $adminObject = Admin::getInstance(); |
|
| 164 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 165 | - echo $uploader->getErrors(); |
|
| 166 | - require __DIR__ . '/admin_footer.php'; |
|
| 167 | - exit(0); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 172 | - redirect_header( |
|
| 173 | - $_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'], |
|
| 174 | - 10, |
|
| 175 | - _AM_SONGLIST_MSG_VOTES_SAVEDOKEY |
|
| 176 | - ); |
|
| 177 | - } else { |
|
| 178 | - 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); |
|
| 179 | - } |
|
| 180 | - exit(0); |
|
| 181 | - |
|
| 182 | - break; |
|
| 183 | - case 'savelist': |
|
| 184 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 185 | - foreach ($_REQUEST['id'] as $id) { |
|
| 186 | - $votes = $votesHandler->get($id); |
|
| 187 | - $votes->setVars($_POST[$id]); |
|
| 188 | - if (!$votesHandler->insert($votes)) { |
|
| 189 | - redirect_header( |
|
| 190 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 191 | - 10, |
|
| 192 | - _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE |
|
| 193 | - ); |
|
| 194 | - exit(0); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - 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); |
|
| 198 | - exit(0); |
|
| 199 | - break; |
|
| 200 | - case 'delete': |
|
| 201 | - $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 202 | - $id = 0; |
|
| 203 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 204 | - $votes = $votesHandler->get($id); |
|
| 205 | - if (!$votesHandler->delete($votes)) { |
|
| 206 | - redirect_header( |
|
| 207 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 208 | - 10, |
|
| 209 | - _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE |
|
| 210 | - ); |
|
| 211 | - exit(0); |
|
| 212 | - } |
|
| 213 | - 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); |
|
| 214 | - exit(0); |
|
| 215 | - } |
|
| 216 | - $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 217 | - xoops_confirm( |
|
| 218 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 219 | - $_SERVER['SCRIPT_NAME'], |
|
| 220 | - sprintf(_AM_SONGLIST_MSG_VOTES_DELETE, $votes->getVar('name')) |
|
| 221 | - ); |
|
| 222 | - |
|
| 223 | - break; |
|
| 224 | - } |
|
| 225 | - break; |
|
| 133 | + $votes = $votesHandler->get($id); |
|
| 134 | + $uploader = new Uploader( |
|
| 135 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 136 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
|
| 137 | + $GLOBALS['songlistModuleConfig']['filesize_upload'], |
|
| 138 | + 0, |
|
| 139 | + 0, |
|
| 140 | + explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
|
| 141 | + ); |
|
| 142 | + try { |
|
| 143 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 144 | + } catch (Exception $e) { |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + if ($uploader->fetchMedia('image')) { |
|
| 148 | + if (!$uploader->upload()) { |
|
| 149 | + $adminObject = Admin::getInstance(); |
|
| 150 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 151 | + echo $uploader->getErrors(); |
|
| 152 | + require __DIR__ . '/admin_footer.php'; |
|
| 153 | + exit(0); |
|
| 154 | + } |
|
| 155 | + if (mb_strlen($votes->getVar('image'))) { |
|
| 156 | + unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image')); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
|
| 160 | + $votes->setVar('image', $uploader->getSavedFileName()); |
|
| 161 | + @$votesHandler->insert($votes); |
|
| 162 | + } else { |
|
| 163 | + $adminObject = Admin::getInstance(); |
|
| 164 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 165 | + echo $uploader->getErrors(); |
|
| 166 | + require __DIR__ . '/admin_footer.php'; |
|
| 167 | + exit(0); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 172 | + redirect_header( |
|
| 173 | + $_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'], |
|
| 174 | + 10, |
|
| 175 | + _AM_SONGLIST_MSG_VOTES_SAVEDOKEY |
|
| 176 | + ); |
|
| 177 | + } else { |
|
| 178 | + 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); |
|
| 179 | + } |
|
| 180 | + exit(0); |
|
| 181 | + |
|
| 182 | + break; |
|
| 183 | + case 'savelist': |
|
| 184 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 185 | + foreach ($_REQUEST['id'] as $id) { |
|
| 186 | + $votes = $votesHandler->get($id); |
|
| 187 | + $votes->setVars($_POST[$id]); |
|
| 188 | + if (!$votesHandler->insert($votes)) { |
|
| 189 | + redirect_header( |
|
| 190 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 191 | + 10, |
|
| 192 | + _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE |
|
| 193 | + ); |
|
| 194 | + exit(0); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + 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); |
|
| 198 | + exit(0); |
|
| 199 | + break; |
|
| 200 | + case 'delete': |
|
| 201 | + $votesHandler = Helper::getInstance()->getHandler('Votes'); |
|
| 202 | + $id = 0; |
|
| 203 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 204 | + $votes = $votesHandler->get($id); |
|
| 205 | + if (!$votesHandler->delete($votes)) { |
|
| 206 | + redirect_header( |
|
| 207 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 208 | + 10, |
|
| 209 | + _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE |
|
| 210 | + ); |
|
| 211 | + exit(0); |
|
| 212 | + } |
|
| 213 | + 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); |
|
| 214 | + exit(0); |
|
| 215 | + } |
|
| 216 | + $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 217 | + xoops_confirm( |
|
| 218 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 219 | + $_SERVER['SCRIPT_NAME'], |
|
| 220 | + sprintf(_AM_SONGLIST_MSG_VOTES_DELETE, $votes->getVar('name')) |
|
| 221 | + ); |
|
| 222 | + |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | + break; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | xoops_cp_footer(); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use XoopsModules\Songlist\VotesHandler; |
| 8 | 8 | use XoopsModules\Songlist\Form\FormController; |
| 9 | 9 | |
| 10 | -require __DIR__ . '/header.php'; |
|
| 10 | +require __DIR__.'/header.php'; |
|
| 11 | 11 | |
| 12 | 12 | xoops_loadLanguage('admin', 'songlist'); |
| 13 | 13 | |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
| 19 | 19 | $start = Request::getInt('start', 0, 'REQUEST'); |
| 20 | 20 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
| 21 | -$sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 22 | -$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
|
| 21 | +$sort = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 22 | +$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1'; |
|
| 23 | 23 | |
| 24 | 24 | switch ($op) { |
| 25 | 25 | default: |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $criteria = $votesHandler->getFilterCriteria($GLOBALS['filter']); |
| 37 | 37 | $ttl = $votesHandler->getCount($criteria); |
| 38 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 38 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 39 | 39 | |
| 40 | - $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']); |
|
| 40 | + $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']); |
|
| 41 | 41 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 42 | 42 | |
| 43 | 43 | foreach ($votesHandler->filterFields() as $id => $key) { |
| 44 | 44 | $GLOBALS['xoopsTpl']->assign( |
| 45 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 45 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 46 | 46 | '<a href="' |
| 47 | 47 | . $_SERVER['SCRIPT_NAME'] |
| 48 | 48 | . '?start=' |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | . '&sort=' |
| 53 | 53 | . $key |
| 54 | 54 | . '&order=' |
| 55 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 55 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 56 | 56 | . '&op=' |
| 57 | 57 | . $GLOBALS['op'] |
| 58 | 58 | . '&filter=' |
| 59 | 59 | . $GLOBALS['filter'] |
| 60 | 60 | . '">' |
| 61 | - . (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))) |
|
| 61 | + . (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))) |
|
| 62 | 62 | . '</a>' |
| 63 | 63 | ); |
| 64 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 64 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $criteria->setStart($GLOBALS['start']); |
| 75 | 75 | $criteria->setLimit($GLOBALS['limit']); |
| 76 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 76 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 77 | 77 | $criteria->setOrder($GLOBALS['order']); |
| 78 | 78 | |
| 79 | 79 | $votess = $votesHandler->getObjects($criteria, true); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $votes->setVars($_POST[$id]); |
| 115 | 115 | |
| 116 | 116 | if (!$id = $votesHandler->insert($votes)) { |
| 117 | - 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); |
|
| 117 | + 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); |
|
| 118 | 118 | exit(0); |
| 119 | 119 | } |
| 120 | 120 | if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
| 141 | 141 | ); |
| 142 | 142 | try { |
| 143 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 143 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
| 144 | 144 | } catch (Exception $e) { |
| 145 | 145 | } |
| 146 | 146 | |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | $adminObject = Admin::getInstance(); |
| 150 | 150 | $adminObject->displayNavigation(basename(__FILE__)); |
| 151 | 151 | echo $uploader->getErrors(); |
| 152 | - require __DIR__ . '/admin_footer.php'; |
|
| 152 | + require __DIR__.'/admin_footer.php'; |
|
| 153 | 153 | exit(0); |
| 154 | 154 | } |
| 155 | 155 | if (mb_strlen($votes->getVar('image'))) { |
| 156 | - unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image')); |
|
| 156 | + unlink($GLOBALS['xoops']->path($votes->getVar('path')).$votes->getVar('image')); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']); |
@@ -163,19 +163,19 @@ discard block |
||
| 163 | 163 | $adminObject = Admin::getInstance(); |
| 164 | 164 | $adminObject->displayNavigation(basename(__FILE__)); |
| 165 | 165 | echo $uploader->getErrors(); |
| 166 | - require __DIR__ . '/admin_footer.php'; |
|
| 166 | + require __DIR__.'/admin_footer.php'; |
|
| 167 | 167 | exit(0); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 171 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 172 | 172 | redirect_header( |
| 173 | - $_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'], |
|
| 173 | + $_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'], |
|
| 174 | 174 | 10, |
| 175 | 175 | _AM_SONGLIST_MSG_VOTES_SAVEDOKEY |
| 176 | 176 | ); |
| 177 | 177 | } else { |
| 178 | - 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); |
|
| 178 | + 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); |
|
| 179 | 179 | } |
| 180 | 180 | exit(0); |
| 181 | 181 | |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | $votes->setVars($_POST[$id]); |
| 188 | 188 | if (!$votesHandler->insert($votes)) { |
| 189 | 189 | redirect_header( |
| 190 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 190 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 191 | 191 | 10, |
| 192 | 192 | _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE |
| 193 | 193 | ); |
| 194 | 194 | exit(0); |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - 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); |
|
| 197 | + 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); |
|
| 198 | 198 | exit(0); |
| 199 | 199 | break; |
| 200 | 200 | case 'delete': |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | $votes = $votesHandler->get($id); |
| 205 | 205 | if (!$votesHandler->delete($votes)) { |
| 206 | 206 | redirect_header( |
| 207 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 207 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 208 | 208 | 10, |
| 209 | 209 | _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE |
| 210 | 210 | ); |
| 211 | 211 | exit(0); |
| 212 | 212 | } |
| 213 | - 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); |
|
| 213 | + 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); |
|
| 214 | 214 | exit(0); |
| 215 | 215 | } |
| 216 | 216 | $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -38,28 +38,28 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $perm_desc = ''; |
| 40 | 40 | switch ($op) { |
| 41 | - case 'visibility': |
|
| 42 | - //header("Location: visibility.php"); |
|
| 43 | - redirect_header('field_visibility.php', 0, _AM_SONGLIST_PROF_VISIBLE); |
|
| 44 | - break; |
|
| 45 | - case 'edit': |
|
| 46 | - $title_of_form = _AM_SONGLIST_PROF_EDITABLE; |
|
| 47 | - $perm_name = 'songlist_edit'; |
|
| 48 | - $restriction = 'field_edit'; |
|
| 49 | - $anonymous = false; |
|
| 50 | - break; |
|
| 51 | - case 'post': |
|
| 52 | - $title_of_form = _AM_SONGLIST_PROF_POST; |
|
| 53 | - $perm_name = 'songlist_post'; |
|
| 54 | - $restriction = ''; |
|
| 55 | - $anonymous = true; |
|
| 56 | - break; |
|
| 57 | - case 'search': |
|
| 58 | - $title_of_form = _AM_SONGLIST_PROF_SEARCH; |
|
| 59 | - $perm_name = 'songlist_search'; |
|
| 60 | - $restriction = ''; |
|
| 61 | - $anonymous = true; |
|
| 62 | - break; |
|
| 41 | + case 'visibility': |
|
| 42 | + //header("Location: visibility.php"); |
|
| 43 | + redirect_header('field_visibility.php', 0, _AM_SONGLIST_PROF_VISIBLE); |
|
| 44 | + break; |
|
| 45 | + case 'edit': |
|
| 46 | + $title_of_form = _AM_SONGLIST_PROF_EDITABLE; |
|
| 47 | + $perm_name = 'songlist_edit'; |
|
| 48 | + $restriction = 'field_edit'; |
|
| 49 | + $anonymous = false; |
|
| 50 | + break; |
|
| 51 | + case 'post': |
|
| 52 | + $title_of_form = _AM_SONGLIST_PROF_POST; |
|
| 53 | + $perm_name = 'songlist_post'; |
|
| 54 | + $restriction = ''; |
|
| 55 | + $anonymous = true; |
|
| 56 | + break; |
|
| 57 | + case 'search': |
|
| 58 | + $title_of_form = _AM_SONGLIST_PROF_SEARCH; |
|
| 59 | + $perm_name = 'songlist_search'; |
|
| 60 | + $restriction = ''; |
|
| 61 | + $anonymous = true; |
|
| 62 | + break; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $module_id = $GLOBALS['songlistModule']->getVar('mid'); |
@@ -67,43 +67,43 @@ discard block |
||
| 67 | 67 | $form = new \XoopsGroupPermForm($title_of_form, $module_id, $perm_name, $perm_desc, 'admin/field_permissions.php', $anonymous); |
| 68 | 68 | |
| 69 | 69 | if ('access' === $op) { |
| 70 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
| 71 | - $memberHandler = xoops_getHandler('member'); |
|
| 72 | - $glist = $memberHandler->getGroupList(); |
|
| 73 | - foreach (array_keys($glist) as $i) { |
|
| 74 | - if (XOOPS_GROUP_ANONYMOUS != $i) { |
|
| 75 | - $form->addItem($i, $glist[$i]); |
|
| 76 | - } |
|
| 77 | - } |
|
| 70 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
| 71 | + $memberHandler = xoops_getHandler('member'); |
|
| 72 | + $glist = $memberHandler->getGroupList(); |
|
| 73 | + foreach (array_keys($glist) as $i) { |
|
| 74 | + if (XOOPS_GROUP_ANONYMOUS != $i) { |
|
| 75 | + $form->addItem($i, $glist[$i]); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | } else { |
| 79 | - $extrasHandler = Helper::getInstance()->getHandler('Extras'); |
|
| 80 | - $tempFields = $extrasHandler->loadFields(); |
|
| 81 | - if ($tempFields && is_array($tempFields)) { |
|
| 82 | - $fields = array_merge([], $tempFields); |
|
| 83 | - if ('search' !== $op) { |
|
| 84 | - foreach (array_keys($fields) as $i) { |
|
| 85 | - if ('' == $restriction || $fields[$i]->getVar($restriction)) { |
|
| 86 | - $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - } else { |
|
| 90 | - $searchable_types = [ |
|
| 91 | - 'textbox', |
|
| 92 | - 'select', |
|
| 93 | - 'radio', |
|
| 94 | - 'yesno', |
|
| 95 | - 'date', |
|
| 96 | - 'datetime', |
|
| 97 | - 'timezone', |
|
| 98 | - 'language', |
|
| 99 | - ]; |
|
| 100 | - foreach (array_keys($fields) as $i) { |
|
| 101 | - if (in_array($fields[$i]->getVar('field_type'), $searchable_types, true)) { |
|
| 102 | - $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 79 | + $extrasHandler = Helper::getInstance()->getHandler('Extras'); |
|
| 80 | + $tempFields = $extrasHandler->loadFields(); |
|
| 81 | + if ($tempFields && is_array($tempFields)) { |
|
| 82 | + $fields = array_merge([], $tempFields); |
|
| 83 | + if ('search' !== $op) { |
|
| 84 | + foreach (array_keys($fields) as $i) { |
|
| 85 | + if ('' == $restriction || $fields[$i]->getVar($restriction)) { |
|
| 86 | + $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + } else { |
|
| 90 | + $searchable_types = [ |
|
| 91 | + 'textbox', |
|
| 92 | + 'select', |
|
| 93 | + 'radio', |
|
| 94 | + 'yesno', |
|
| 95 | + 'date', |
|
| 96 | + 'datetime', |
|
| 97 | + 'timezone', |
|
| 98 | + 'language', |
|
| 99 | + ]; |
|
| 100 | + foreach (array_keys($fields) as $i) { |
|
| 101 | + if (in_array($fields[$i]->getVar('field_type'), $searchable_types, true)) { |
|
| 102 | + $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | $form->display(); |
| 109 | 109 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | use Xmf\Module\Admin; |
| 18 | 18 | use XoopsModules\Songlist\Helper; |
| 19 | 19 | |
| 20 | -require_once __DIR__ . '/header.php'; |
|
| 20 | +require_once __DIR__.'/header.php'; |
|
| 21 | 21 | xoops_cp_header(); |
| 22 | 22 | |
| 23 | 23 | $adminObject = Admin::getInstance(); |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | require_once $GLOBALS['xoops']->path('/class/xoopsform/grouppermform.php'); |
| 67 | 67 | $form = new \XoopsGroupPermForm($title_of_form, $module_id, $perm_name, $perm_desc, 'admin/field_permissions.php', $anonymous); |
| 68 | 68 | |
| 69 | -if ('access' === $op) { |
|
| 69 | +if ('access'===$op) { |
|
| 70 | 70 | /** @var \XoopsMemberHandler $memberHandler */ |
| 71 | 71 | $memberHandler = xoops_getHandler('member'); |
| 72 | 72 | $glist = $memberHandler->getGroupList(); |
| 73 | 73 | foreach (array_keys($glist) as $i) { |
| 74 | - if (XOOPS_GROUP_ANONYMOUS != $i) { |
|
| 74 | + if (XOOPS_GROUP_ANONYMOUS!=$i) { |
|
| 75 | 75 | $form->addItem($i, $glist[$i]); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | $tempFields = $extrasHandler->loadFields(); |
| 81 | 81 | if ($tempFields && is_array($tempFields)) { |
| 82 | 82 | $fields = array_merge([], $tempFields); |
| 83 | - if ('search' !== $op) { |
|
| 83 | + if ('search'!==$op) { |
|
| 84 | 84 | foreach (array_keys($fields) as $i) { |
| 85 | - if ('' == $restriction || $fields[$i]->getVar($restriction)) { |
|
| 85 | + if (''==$restriction || $fields[$i]->getVar($restriction)) { |
|
| 86 | 86 | $form->addItem($fields[$i]->getVar('field_id'), xoops_substr($fields[$i]->getVar('field_title'), 0, 25)); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | use Xmf\Request; |
| 22 | 22 | use XoopsModules\Songlist\{ |
| 23 | - Common\Cloner, |
|
| 24 | - Helper, |
|
| 25 | - Utility |
|
| 23 | + Common\Cloner, |
|
| 24 | + Helper, |
|
| 25 | + Utility |
|
| 26 | 26 | }; |
| 27 | 27 | |
| 28 | 28 | require_once __DIR__ . '/admin_header.php'; |
@@ -32,53 +32,53 @@ discard block |
||
| 32 | 32 | $helper = Helper::getInstance(); |
| 33 | 33 | |
| 34 | 34 | if ('submit' === Request::getString('op', '', 'POST')) { |
| 35 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 36 | - redirect_header('clone.php', 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 37 | - } |
|
| 35 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 36 | + redirect_header('clone.php', 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - // $clone = $_POST['clone']; |
|
| 40 | - $clone = Request::getString('clone', '', 'POST'); |
|
| 39 | + // $clone = $_POST['clone']; |
|
| 40 | + $clone = Request::getString('clone', '', 'POST'); |
|
| 41 | 41 | |
| 42 | - //check if name is valid |
|
| 43 | - if (empty($clone) || preg_match('/[^a-zA-Z0-9\_\-]/', $clone)) { |
|
| 44 | - redirect_header('clone.php', 3, sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_INVALIDNAME'), $clone)); |
|
| 45 | - } |
|
| 42 | + //check if name is valid |
|
| 43 | + if (empty($clone) || preg_match('/[^a-zA-Z0-9\_\-]/', $clone)) { |
|
| 44 | + redirect_header('clone.php', 3, sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_INVALIDNAME'), $clone)); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - // Check wether the cloned module exists or not |
|
| 48 | - if ($clone && is_dir($GLOBALS['xoops']->path('modules/' . $clone))) { |
|
| 49 | - redirect_header('clone.php', 3, sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_EXISTS'), $clone)); |
|
| 50 | - } |
|
| 47 | + // Check wether the cloned module exists or not |
|
| 48 | + if ($clone && is_dir($GLOBALS['xoops']->path('modules/' . $clone))) { |
|
| 49 | + redirect_header('clone.php', 3, sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_EXISTS'), $clone)); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $patterns = [ |
|
| 53 | - \mb_strtolower($helper->dirname()) => \mb_strtolower($clone), |
|
| 54 | - \mb_strtoupper($helper->dirname()) => \mb_strtoupper($clone), |
|
| 55 | - ucfirst(mb_strtolower($helper->dirname())) => ucfirst(mb_strtolower($clone)), |
|
| 56 | - ]; |
|
| 52 | + $patterns = [ |
|
| 53 | + \mb_strtolower($helper->dirname()) => \mb_strtolower($clone), |
|
| 54 | + \mb_strtoupper($helper->dirname()) => \mb_strtoupper($clone), |
|
| 55 | + ucfirst(mb_strtolower($helper->dirname())) => ucfirst(mb_strtolower($clone)), |
|
| 56 | + ]; |
|
| 57 | 57 | |
| 58 | - $patKeys = array_keys($patterns); |
|
| 59 | - $patValues = array_values($patterns); |
|
| 60 | - Cloner::cloneFileFolder($helper->path()); |
|
| 61 | - $logocreated = Cloner::createLogo(mb_strtolower($clone)); |
|
| 58 | + $patKeys = array_keys($patterns); |
|
| 59 | + $patValues = array_values($patterns); |
|
| 60 | + Cloner::cloneFileFolder($helper->path()); |
|
| 61 | + $logocreated = Cloner::createLogo(mb_strtolower($clone)); |
|
| 62 | 62 | |
| 63 | - $msg = ''; |
|
| 64 | - if (is_dir($GLOBALS['xoops']->path('modules/' . \mb_strtolower($clone)))) { |
|
| 65 | - $msg .= sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_CONGRAT'), "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(mb_strtolower($clone)) . '</a>') . "<br>\n"; |
|
| 66 | - if (!$logocreated) { |
|
| 67 | - $msg .= constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_IMAGEFAIL'); |
|
| 68 | - } |
|
| 69 | - } else { |
|
| 70 | - $msg .= constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_FAIL'); |
|
| 71 | - } |
|
| 72 | - echo $msg; |
|
| 63 | + $msg = ''; |
|
| 64 | + if (is_dir($GLOBALS['xoops']->path('modules/' . \mb_strtolower($clone)))) { |
|
| 65 | + $msg .= sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_CONGRAT'), "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(mb_strtolower($clone)) . '</a>') . "<br>\n"; |
|
| 66 | + if (!$logocreated) { |
|
| 67 | + $msg .= constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_IMAGEFAIL'); |
|
| 68 | + } |
|
| 69 | + } else { |
|
| 70 | + $msg .= constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_FAIL'); |
|
| 71 | + } |
|
| 72 | + echo $msg; |
|
| 73 | 73 | } else { |
| 74 | - require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 75 | - $form = new \XoopsThemeForm(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_TITLE'), (string)$helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true); |
|
| 76 | - $clone = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME'), 'clone', 20, 20, ''); |
|
| 77 | - $clone->setDescription(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME_DSC')); |
|
| 78 | - $form->addElement($clone, true); |
|
| 79 | - $form->addElement(new \XoopsFormHidden('op', 'submit')); |
|
| 80 | - $form->addElement(new \XoopsFormButton('', '', _SUBMIT, 'submit')); |
|
| 81 | - $form->display(); |
|
| 74 | + require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 75 | + $form = new \XoopsThemeForm(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_TITLE'), (string)$helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true); |
|
| 76 | + $clone = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME'), 'clone', 20, 20, ''); |
|
| 77 | + $clone->setDescription(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME_DSC')); |
|
| 78 | + $form->addElement($clone, true); |
|
| 79 | + $form->addElement(new \XoopsFormHidden('op', 'submit')); |
|
| 80 | + $form->addElement(new \XoopsFormButton('', '', _SUBMIT, 'submit')); |
|
| 81 | + $form->display(); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | require_once __DIR__ . '/admin_footer.php'; |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | Utility |
| 26 | 26 | }; |
| 27 | 27 | |
| 28 | -require_once __DIR__ . '/admin_header.php'; |
|
| 28 | +require_once __DIR__.'/admin_header.php'; |
|
| 29 | 29 | |
| 30 | 30 | xoops_cp_header(); |
| 31 | 31 | |
| 32 | 32 | $helper = Helper::getInstance(); |
| 33 | 33 | |
| 34 | -if ('submit' === Request::getString('op', '', 'POST')) { |
|
| 34 | +if ('submit'===Request::getString('op', '', 'POST')) { |
|
| 35 | 35 | if (!$GLOBALS['xoopsSecurity']->check()) { |
| 36 | 36 | redirect_header('clone.php', 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
| 37 | 37 | } |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | //check if name is valid |
| 43 | 43 | if (empty($clone) || preg_match('/[^a-zA-Z0-9\_\-]/', $clone)) { |
| 44 | - redirect_header('clone.php', 3, sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_INVALIDNAME'), $clone)); |
|
| 44 | + redirect_header('clone.php', 3, sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_INVALIDNAME'), $clone)); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Check wether the cloned module exists or not |
| 48 | - if ($clone && is_dir($GLOBALS['xoops']->path('modules/' . $clone))) { |
|
| 49 | - redirect_header('clone.php', 3, sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_EXISTS'), $clone)); |
|
| 48 | + if ($clone && is_dir($GLOBALS['xoops']->path('modules/'.$clone))) { |
|
| 49 | + redirect_header('clone.php', 3, sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_EXISTS'), $clone)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $patterns = [ |
@@ -61,24 +61,24 @@ discard block |
||
| 61 | 61 | $logocreated = Cloner::createLogo(mb_strtolower($clone)); |
| 62 | 62 | |
| 63 | 63 | $msg = ''; |
| 64 | - if (is_dir($GLOBALS['xoops']->path('modules/' . \mb_strtolower($clone)))) { |
|
| 65 | - $msg .= sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_CONGRAT'), "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(mb_strtolower($clone)) . '</a>') . "<br>\n"; |
|
| 64 | + if (is_dir($GLOBALS['xoops']->path('modules/'.\mb_strtolower($clone)))) { |
|
| 65 | + $msg .= sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_CONGRAT'), "<a href='".XOOPS_URL."/modules/system/admin.php?fct=modulesadmin'>".ucfirst(mb_strtolower($clone)).'</a>')."<br>\n"; |
|
| 66 | 66 | if (!$logocreated) { |
| 67 | - $msg .= constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_IMAGEFAIL'); |
|
| 67 | + $msg .= constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_IMAGEFAIL'); |
|
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | - $msg .= constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_FAIL'); |
|
| 70 | + $msg .= constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_FAIL'); |
|
| 71 | 71 | } |
| 72 | 72 | echo $msg; |
| 73 | 73 | } else { |
| 74 | 74 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
| 75 | - $form = new \XoopsThemeForm(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_TITLE'), (string)$helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true); |
|
| 76 | - $clone = new \XoopsFormText(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME'), 'clone', 20, 20, ''); |
|
| 77 | - $clone->setDescription(constant('CO_' . $moduleDirNameUpper . '_' . 'CLONE_NAME_DSC')); |
|
| 75 | + $form = new \XoopsThemeForm(sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_TITLE'), (string) $helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true); |
|
| 76 | + $clone = new \XoopsFormText(constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_NAME'), 'clone', 20, 20, ''); |
|
| 77 | + $clone->setDescription(constant('CO_'.$moduleDirNameUpper.'_'.'CLONE_NAME_DSC')); |
|
| 78 | 78 | $form->addElement($clone, true); |
| 79 | 79 | $form->addElement(new \XoopsFormHidden('op', 'submit')); |
| 80 | 80 | $form->addElement(new \XoopsFormButton('', '', _SUBMIT, 'submit')); |
| 81 | 81 | $form->display(); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -require_once __DIR__ . '/admin_footer.php'; |
|
| 84 | +require_once __DIR__.'/admin_footer.php'; |
|
@@ -21,156 +21,156 @@ |
||
| 21 | 21 | $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
| 22 | 22 | |
| 23 | 23 | switch ($op) { |
| 24 | - default: |
|
| 25 | - case 'requests': |
|
| 26 | - switch ($fct) { |
|
| 27 | - default: |
|
| 28 | - case 'list': |
|
| 29 | - $adminObject = Admin::getInstance(); |
|
| 30 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 31 | - |
|
| 32 | - /** @var RequestsHandler $requestsHandler */ |
|
| 33 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 34 | - |
|
| 35 | - $criteria = $requestsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 36 | - $ttl = $requestsHandler->getCount($criteria); |
|
| 37 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 38 | - |
|
| 39 | - $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']); |
|
| 40 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 41 | - |
|
| 42 | - foreach ($requestsHandler->filterFields() as $id => $key) { |
|
| 43 | - $GLOBALS['xoopsTpl']->assign( |
|
| 44 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 45 | - '<a href="' |
|
| 46 | - . $_SERVER['SCRIPT_NAME'] |
|
| 47 | - . '?start=' |
|
| 48 | - . $GLOBALS['start'] |
|
| 49 | - . '&limit=' |
|
| 50 | - . $GLOBALS['limit'] |
|
| 51 | - . '&sort=' |
|
| 52 | - . $key |
|
| 53 | - . '&order=' |
|
| 54 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 55 | - . '&op=' |
|
| 56 | - . $GLOBALS['op'] |
|
| 57 | - . '&filter=' |
|
| 58 | - . $GLOBALS['filter'] |
|
| 59 | - . '">' |
|
| 60 | - . (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))) |
|
| 61 | - . '</a>' |
|
| 62 | - ); |
|
| 63 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 67 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 68 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 70 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 71 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 72 | - |
|
| 73 | - $criteria->setStart($GLOBALS['start']); |
|
| 74 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 75 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 76 | - $criteria->setOrder($GLOBALS['order']); |
|
| 77 | - |
|
| 78 | - $requestss = $requestsHandler->getObjects($criteria, true); |
|
| 79 | - foreach ($requestss as $cid => $requests) { |
|
| 80 | - if (is_object($requests)) { |
|
| 81 | - $GLOBALS['xoopsTpl']->append('requests', $requests->toArray()); |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false)); |
|
| 85 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 86 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_list.tpl'); |
|
| 87 | - break; |
|
| 88 | - case 'new': |
|
| 89 | - case 'edit': |
|
| 90 | - $adminObject = Admin::getInstance(); |
|
| 91 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 92 | - |
|
| 93 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 94 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 95 | - $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 96 | - } else { |
|
| 97 | - $requests = $requestsHandler->create(); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $GLOBALS['xoopsTpl']->assign('form', $requests->getForm()); |
|
| 101 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 102 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_edit.tpl'); |
|
| 103 | - break; |
|
| 104 | - case 'save': |
|
| 105 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 106 | - $id = 0; |
|
| 107 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 108 | - if ($id) { |
|
| 109 | - $requests = $requestsHandler->get($id); |
|
| 110 | - } else { |
|
| 111 | - $requests = $requestsHandler->create(); |
|
| 112 | - } |
|
| 113 | - $requests->setVars($_POST[$id]); |
|
| 114 | - |
|
| 115 | - if (!$id = $requestsHandler->insert($requests)) { |
|
| 116 | - 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); |
|
| 117 | - exit(0); |
|
| 118 | - } |
|
| 119 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 120 | - redirect_header( |
|
| 121 | - $_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'], |
|
| 122 | - 10, |
|
| 123 | - _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY |
|
| 124 | - ); |
|
| 125 | - } else { |
|
| 126 | - 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); |
|
| 127 | - } |
|
| 128 | - exit(0); |
|
| 129 | - |
|
| 130 | - break; |
|
| 131 | - case 'savelist': |
|
| 132 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 133 | - foreach ($_REQUEST['id'] as $id) { |
|
| 134 | - $requests = $requestsHandler->get($id); |
|
| 135 | - $requests->setVars($_POST[$id]); |
|
| 136 | - if (!$requestsHandler->insert($requests)) { |
|
| 137 | - redirect_header( |
|
| 138 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 139 | - 10, |
|
| 140 | - _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE |
|
| 141 | - ); |
|
| 142 | - exit(0); |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - 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); |
|
| 146 | - exit(0); |
|
| 147 | - break; |
|
| 148 | - case 'delete': |
|
| 149 | - $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 150 | - $id = 0; |
|
| 151 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 152 | - $requests = $requestsHandler->get($id); |
|
| 153 | - if (!$requestsHandler->delete($requests)) { |
|
| 154 | - redirect_header( |
|
| 155 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 156 | - 10, |
|
| 157 | - _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE |
|
| 158 | - ); |
|
| 159 | - exit(0); |
|
| 160 | - } |
|
| 161 | - 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); |
|
| 162 | - exit(0); |
|
| 163 | - } |
|
| 164 | - $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 165 | - xoops_confirm( |
|
| 166 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 167 | - $_SERVER['SCRIPT_NAME'], |
|
| 168 | - sprintf(_AM_SONGLIST_MSG_REQUESTS_DELETE, $requests->getVar('name')) |
|
| 169 | - ); |
|
| 170 | - |
|
| 171 | - break; |
|
| 172 | - } |
|
| 173 | - break; |
|
| 24 | + default: |
|
| 25 | + case 'requests': |
|
| 26 | + switch ($fct) { |
|
| 27 | + default: |
|
| 28 | + case 'list': |
|
| 29 | + $adminObject = Admin::getInstance(); |
|
| 30 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 31 | + |
|
| 32 | + /** @var RequestsHandler $requestsHandler */ |
|
| 33 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 34 | + |
|
| 35 | + $criteria = $requestsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 36 | + $ttl = $requestsHandler->getCount($criteria); |
|
| 37 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 38 | + |
|
| 39 | + $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']); |
|
| 40 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 41 | + |
|
| 42 | + foreach ($requestsHandler->filterFields() as $id => $key) { |
|
| 43 | + $GLOBALS['xoopsTpl']->assign( |
|
| 44 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 45 | + '<a href="' |
|
| 46 | + . $_SERVER['SCRIPT_NAME'] |
|
| 47 | + . '?start=' |
|
| 48 | + . $GLOBALS['start'] |
|
| 49 | + . '&limit=' |
|
| 50 | + . $GLOBALS['limit'] |
|
| 51 | + . '&sort=' |
|
| 52 | + . $key |
|
| 53 | + . '&order=' |
|
| 54 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 55 | + . '&op=' |
|
| 56 | + . $GLOBALS['op'] |
|
| 57 | + . '&filter=' |
|
| 58 | + . $GLOBALS['filter'] |
|
| 59 | + . '">' |
|
| 60 | + . (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))) |
|
| 61 | + . '</a>' |
|
| 62 | + ); |
|
| 63 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 67 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 70 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 71 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 72 | + |
|
| 73 | + $criteria->setStart($GLOBALS['start']); |
|
| 74 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 75 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 76 | + $criteria->setOrder($GLOBALS['order']); |
|
| 77 | + |
|
| 78 | + $requestss = $requestsHandler->getObjects($criteria, true); |
|
| 79 | + foreach ($requestss as $cid => $requests) { |
|
| 80 | + if (is_object($requests)) { |
|
| 81 | + $GLOBALS['xoopsTpl']->append('requests', $requests->toArray()); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false)); |
|
| 85 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 86 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_list.tpl'); |
|
| 87 | + break; |
|
| 88 | + case 'new': |
|
| 89 | + case 'edit': |
|
| 90 | + $adminObject = Admin::getInstance(); |
|
| 91 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 92 | + |
|
| 93 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 94 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 95 | + $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 96 | + } else { |
|
| 97 | + $requests = $requestsHandler->create(); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $GLOBALS['xoopsTpl']->assign('form', $requests->getForm()); |
|
| 101 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 102 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_edit.tpl'); |
|
| 103 | + break; |
|
| 104 | + case 'save': |
|
| 105 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 106 | + $id = 0; |
|
| 107 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 108 | + if ($id) { |
|
| 109 | + $requests = $requestsHandler->get($id); |
|
| 110 | + } else { |
|
| 111 | + $requests = $requestsHandler->create(); |
|
| 112 | + } |
|
| 113 | + $requests->setVars($_POST[$id]); |
|
| 114 | + |
|
| 115 | + if (!$id = $requestsHandler->insert($requests)) { |
|
| 116 | + 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); |
|
| 117 | + exit(0); |
|
| 118 | + } |
|
| 119 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 120 | + redirect_header( |
|
| 121 | + $_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'], |
|
| 122 | + 10, |
|
| 123 | + _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY |
|
| 124 | + ); |
|
| 125 | + } else { |
|
| 126 | + 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); |
|
| 127 | + } |
|
| 128 | + exit(0); |
|
| 129 | + |
|
| 130 | + break; |
|
| 131 | + case 'savelist': |
|
| 132 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 133 | + foreach ($_REQUEST['id'] as $id) { |
|
| 134 | + $requests = $requestsHandler->get($id); |
|
| 135 | + $requests->setVars($_POST[$id]); |
|
| 136 | + if (!$requestsHandler->insert($requests)) { |
|
| 137 | + redirect_header( |
|
| 138 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 139 | + 10, |
|
| 140 | + _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE |
|
| 141 | + ); |
|
| 142 | + exit(0); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + 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); |
|
| 146 | + exit(0); |
|
| 147 | + break; |
|
| 148 | + case 'delete': |
|
| 149 | + $requestsHandler = Helper::getInstance()->getHandler('Requests'); |
|
| 150 | + $id = 0; |
|
| 151 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 152 | + $requests = $requestsHandler->get($id); |
|
| 153 | + if (!$requestsHandler->delete($requests)) { |
|
| 154 | + redirect_header( |
|
| 155 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 156 | + 10, |
|
| 157 | + _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE |
|
| 158 | + ); |
|
| 159 | + exit(0); |
|
| 160 | + } |
|
| 161 | + 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); |
|
| 162 | + exit(0); |
|
| 163 | + } |
|
| 164 | + $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 165 | + xoops_confirm( |
|
| 166 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 167 | + $_SERVER['SCRIPT_NAME'], |
|
| 168 | + sprintf(_AM_SONGLIST_MSG_REQUESTS_DELETE, $requests->getVar('name')) |
|
| 169 | + ); |
|
| 170 | + |
|
| 171 | + break; |
|
| 172 | + } |
|
| 173 | + break; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | xoops_cp_footer(); |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use XoopsModules\Songlist\RequestsHandler; |
| 7 | 7 | use XoopsModules\Songlist\Form\FormController; |
| 8 | 8 | |
| 9 | -require __DIR__ . '/header.php'; |
|
| 9 | +require __DIR__.'/header.php'; |
|
| 10 | 10 | |
| 11 | 11 | xoops_loadLanguage('admin', 'songlist'); |
| 12 | 12 | |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
| 18 | 18 | $start = Request::getInt('start', 0, 'REQUEST'); |
| 19 | 19 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
| 20 | -$sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 21 | -$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
|
| 20 | +$sort = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 21 | +$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1'; |
|
| 22 | 22 | |
| 23 | 23 | switch ($op) { |
| 24 | 24 | default: |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $criteria = $requestsHandler->getFilterCriteria($GLOBALS['filter']); |
| 36 | 36 | $ttl = $requestsHandler->getCount($criteria); |
| 37 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 37 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 38 | 38 | |
| 39 | - $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']); |
|
| 39 | + $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']); |
|
| 40 | 40 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 41 | 41 | |
| 42 | 42 | foreach ($requestsHandler->filterFields() as $id => $key) { |
| 43 | 43 | $GLOBALS['xoopsTpl']->assign( |
| 44 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 44 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 45 | 45 | '<a href="' |
| 46 | 46 | . $_SERVER['SCRIPT_NAME'] |
| 47 | 47 | . '?start=' |
@@ -51,16 +51,16 @@ discard block |
||
| 51 | 51 | . '&sort=' |
| 52 | 52 | . $key |
| 53 | 53 | . '&order=' |
| 54 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 54 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 55 | 55 | . '&op=' |
| 56 | 56 | . $GLOBALS['op'] |
| 57 | 57 | . '&filter=' |
| 58 | 58 | . $GLOBALS['filter'] |
| 59 | 59 | . '">' |
| 60 | - . (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))) |
|
| 60 | + . (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))) |
|
| 61 | 61 | . '</a>' |
| 62 | 62 | ); |
| 63 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 63 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $criteria->setStart($GLOBALS['start']); |
| 74 | 74 | $criteria->setLimit($GLOBALS['limit']); |
| 75 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 75 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 76 | 76 | $criteria->setOrder($GLOBALS['order']); |
| 77 | 77 | |
| 78 | 78 | $requestss = $requestsHandler->getObjects($criteria, true); |
@@ -113,17 +113,17 @@ discard block |
||
| 113 | 113 | $requests->setVars($_POST[$id]); |
| 114 | 114 | |
| 115 | 115 | if (!$id = $requestsHandler->insert($requests)) { |
| 116 | - 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); |
|
| 116 | + 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); |
|
| 117 | 117 | exit(0); |
| 118 | 118 | } |
| 119 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
| 119 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
| 120 | 120 | redirect_header( |
| 121 | - $_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'], |
|
| 121 | + $_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'], |
|
| 122 | 122 | 10, |
| 123 | 123 | _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY |
| 124 | 124 | ); |
| 125 | 125 | } else { |
| 126 | - 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); |
|
| 126 | + 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); |
|
| 127 | 127 | } |
| 128 | 128 | exit(0); |
| 129 | 129 | |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | $requests->setVars($_POST[$id]); |
| 136 | 136 | if (!$requestsHandler->insert($requests)) { |
| 137 | 137 | redirect_header( |
| 138 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 138 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 139 | 139 | 10, |
| 140 | 140 | _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE |
| 141 | 141 | ); |
| 142 | 142 | exit(0); |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | - 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); |
|
| 145 | + 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); |
|
| 146 | 146 | exit(0); |
| 147 | 147 | break; |
| 148 | 148 | case 'delete': |
@@ -152,13 +152,13 @@ discard block |
||
| 152 | 152 | $requests = $requestsHandler->get($id); |
| 153 | 153 | if (!$requestsHandler->delete($requests)) { |
| 154 | 154 | redirect_header( |
| 155 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 155 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 156 | 156 | 10, |
| 157 | 157 | _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE |
| 158 | 158 | ); |
| 159 | 159 | exit(0); |
| 160 | 160 | } |
| 161 | - 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); |
|
| 161 | + 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); |
|
| 162 | 162 | exit(0); |
| 163 | 163 | } |
| 164 | 164 | $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -1,4 +1,4 @@ |
||
| 1 | 1 | <?php declare(strict_types=1); |
| 2 | 2 | |
| 3 | -require_once __DIR__ . '/header.php'; |
|
| 4 | -require_once XOOPS_ROOT_PATH . '/modules/tag/list.tag.php'; |
|
| 3 | +require_once __DIR__.'/header.php'; |
|
| 4 | +require_once XOOPS_ROOT_PATH.'/modules/tag/list.tag.php'; |
|
@@ -29,19 +29,19 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function xoops_module_pre_install_songlist(\XoopsModule $module): bool |
| 31 | 31 | { |
| 32 | - require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 33 | - $utility = new Utility(); |
|
| 34 | - $xoopsSuccess = $utility::checkVerXoops($module); |
|
| 35 | - $phpSuccess = $utility::checkVerPhp($module); |
|
| 32 | + require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 33 | + $utility = new Utility(); |
|
| 34 | + $xoopsSuccess = $utility::checkVerXoops($module); |
|
| 35 | + $phpSuccess = $utility::checkVerPhp($module); |
|
| 36 | 36 | |
| 37 | - if ($xoopsSuccess && $phpSuccess) { |
|
| 38 | - $moduleTables = &$module->getInfo('tables'); |
|
| 39 | - foreach ($moduleTables as $table) { |
|
| 40 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 37 | + if ($xoopsSuccess && $phpSuccess) { |
|
| 38 | + $moduleTables = &$module->getInfo('tables'); |
|
| 39 | + foreach ($moduleTables as $table) { |
|
| 40 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return $xoopsSuccess && $phpSuccess; |
|
| 44 | + return $xoopsSuccess && $phpSuccess; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -52,48 +52,48 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function xoops_module_install_songlist(\XoopsModule $module): bool |
| 54 | 54 | { |
| 55 | - require \dirname(__DIR__, 3) . '/mainfile.php'; |
|
| 55 | + require \dirname(__DIR__, 3) . '/mainfile.php'; |
|
| 56 | 56 | |
| 57 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 58 | - $helper = Helper::getInstance(); |
|
| 59 | - $utility = new Utility(); |
|
| 60 | - $configurator = new Songlist\Common\Configurator(); |
|
| 61 | - // Load language files |
|
| 62 | - $helper->loadLanguage('admin'); |
|
| 63 | - $helper->loadLanguage('modinfo'); |
|
| 57 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
| 58 | + $helper = Helper::getInstance(); |
|
| 59 | + $utility = new Utility(); |
|
| 60 | + $configurator = new Songlist\Common\Configurator(); |
|
| 61 | + // Load language files |
|
| 62 | + $helper->loadLanguage('admin'); |
|
| 63 | + $helper->loadLanguage('modinfo'); |
|
| 64 | 64 | |
| 65 | - // default Permission Settings ---------------------- |
|
| 66 | - global $xoopsModule; |
|
| 67 | - $moduleId = $xoopsModule->getVar('mid'); |
|
| 68 | - // $moduleId2 = \XoopsModules\Songlist\Helper::getInstance()->getModule()->mid(); |
|
| 69 | - /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
| 70 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 71 | - // access rights ------------------------------------------ |
|
| 72 | - $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 73 | - $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 74 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 75 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
| 76 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
| 65 | + // default Permission Settings ---------------------- |
|
| 66 | + global $xoopsModule; |
|
| 67 | + $moduleId = $xoopsModule->getVar('mid'); |
|
| 68 | + // $moduleId2 = \XoopsModules\Songlist\Helper::getInstance()->getModule()->mid(); |
|
| 69 | + /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
| 70 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 71 | + // access rights ------------------------------------------ |
|
| 72 | + $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 73 | + $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 74 | + $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 75 | + $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
| 76 | + $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
| 77 | 77 | |
| 78 | - // --- CREATE FOLDERS --------------- |
|
| 79 | - if (count($configurator->uploadFolders) > 0) { |
|
| 80 | - // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
| 81 | - foreach (array_keys($configurator->uploadFolders) as $i) { |
|
| 82 | - $utility::createFolder($configurator->uploadFolders[$i]); |
|
| 83 | - } |
|
| 84 | - } |
|
| 78 | + // --- CREATE FOLDERS --------------- |
|
| 79 | + if (count($configurator->uploadFolders) > 0) { |
|
| 80 | + // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
| 81 | + foreach (array_keys($configurator->uploadFolders) as $i) { |
|
| 82 | + $utility::createFolder($configurator->uploadFolders[$i]); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - // --- COPY blank.png FILES --------------- |
|
| 87 | - if (count($configurator->copyBlankFiles) > 0) { |
|
| 88 | - $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
|
| 89 | - foreach (array_keys($configurator->copyBlankFiles) as $i) { |
|
| 90 | - $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
|
| 91 | - $utility::copyFile($file, $dest); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - //delete .html entries from the tpl table |
|
| 95 | - $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.tpl%'"; |
|
| 96 | - $GLOBALS['xoopsDB']->queryF($sql); |
|
| 86 | + // --- COPY blank.png FILES --------------- |
|
| 87 | + if (count($configurator->copyBlankFiles) > 0) { |
|
| 88 | + $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
|
| 89 | + foreach (array_keys($configurator->copyBlankFiles) as $i) { |
|
| 90 | + $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
|
| 91 | + $utility::copyFile($file, $dest); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + //delete .html entries from the tpl table |
|
| 95 | + $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.tpl%'"; |
|
| 96 | + $GLOBALS['xoopsDB']->queryF($sql); |
|
| 97 | 97 | |
| 98 | - return true; |
|
| 98 | + return true; |
|
| 99 | 99 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function xoops_module_pre_install_songlist(\XoopsModule $module): bool |
| 31 | 31 | { |
| 32 | - require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
| 32 | + require_once \dirname(__DIR__).'/preloads/autoloader.php'; |
|
| 33 | 33 | $utility = new Utility(); |
| 34 | 34 | $xoopsSuccess = $utility::checkVerXoops($module); |
| 35 | 35 | $phpSuccess = $utility::checkVerPhp($module); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | if ($xoopsSuccess && $phpSuccess) { |
| 38 | 38 | $moduleTables = &$module->getInfo('tables'); |
| 39 | 39 | foreach ($moduleTables as $table) { |
| 40 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
| 40 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS '.$GLOBALS['xoopsDB']->prefix($table).';'); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function xoops_module_install_songlist(\XoopsModule $module): bool |
| 54 | 54 | { |
| 55 | - require \dirname(__DIR__, 3) . '/mainfile.php'; |
|
| 55 | + require \dirname(__DIR__, 3).'/mainfile.php'; |
|
| 56 | 56 | |
| 57 | 57 | $moduleDirName = \basename(\dirname(__DIR__)); |
| 58 | 58 | $helper = Helper::getInstance(); |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
| 70 | 70 | $grouppermHandler = xoops_getHandler('groupperm'); |
| 71 | 71 | // access rights ------------------------------------------ |
| 72 | - $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 73 | - $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 74 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 75 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
| 76 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
| 72 | + $grouppermHandler->addRight($moduleDirName.'_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 73 | + $grouppermHandler->addRight($moduleDirName.'_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 74 | + $grouppermHandler->addRight($moduleDirName.'_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
| 75 | + $grouppermHandler->addRight($moduleDirName.'_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
| 76 | + $grouppermHandler->addRight($moduleDirName.'_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
| 77 | 77 | |
| 78 | 78 | // --- CREATE FOLDERS --------------- |
| 79 | - if (count($configurator->uploadFolders) > 0) { |
|
| 79 | + if (count($configurator->uploadFolders)>0) { |
|
| 80 | 80 | // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
| 81 | 81 | foreach (array_keys($configurator->uploadFolders) as $i) { |
| 82 | 82 | $utility::createFolder($configurator->uploadFolders[$i]); |
@@ -84,15 +84,15 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // --- COPY blank.png FILES --------------- |
| 87 | - if (count($configurator->copyBlankFiles) > 0) { |
|
| 88 | - $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
|
| 87 | + if (count($configurator->copyBlankFiles)>0) { |
|
| 88 | + $file = \dirname(__DIR__).'/assets/images/blank.png'; |
|
| 89 | 89 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
| 90 | - $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
|
| 90 | + $dest = $configurator->copyBlankFiles[$i].'/blank.png'; |
|
| 91 | 91 | $utility::copyFile($file, $dest); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | //delete .html entries from the tpl table |
| 95 | - $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.tpl%'"; |
|
| 95 | + $sql = 'DELETE FROM '.$GLOBALS['xoopsDB']->prefix('tplfile')." WHERE `tpl_module` = '".$xoopsModule->getVar('dirname', 'n')."' AND `tpl_file` LIKE '%.tpl%'"; |
|
| 96 | 96 | $GLOBALS['xoopsDB']->queryF($sql); |
| 97 | 97 | |
| 98 | 98 | return true; |
@@ -5,12 +5,12 @@ |
||
| 5 | 5 | /** @var \XoopsConfigHandler $configHandler */ |
| 6 | 6 | $configHandler = xoops_getHandler('config'); |
| 7 | 7 | if (!isset($GLOBALS['songlistModule'])) { |
| 8 | - $GLOBALS['songlistModule'] = $moduleHandler->getByDirname('songlist'); |
|
| 8 | + $GLOBALS['songlistModule'] = $moduleHandler->getByDirname('songlist'); |
|
| 9 | 9 | } |
| 10 | 10 | if (is_object($GLOBALS['songlistModule'])) { |
| 11 | - if (!isset($GLOBALS['songlistModuleConfig'])) { |
|
| 12 | - $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
|
| 13 | - } |
|
| 11 | + if (!isset($GLOBALS['songlistModuleConfig'])) { |
|
| 12 | + $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
|
| 13 | + } |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
@@ -9,611 +9,611 @@ |
||
| 9 | 9 | use XoopsModules\Songlist\Form\SelectVoiceForm; |
| 10 | 10 | |
| 11 | 11 | if (!function_exists('songlist_getToken')) { |
| 12 | - /** |
|
| 13 | - * @return mixed |
|
| 14 | - */ |
|
| 15 | - function songlist_getToken() |
|
| 16 | - { |
|
| 17 | - $sql = 'SELECT md5(rand()/rand()*rand()/rand()*rand()*rand()/rand()*rand()) as `salt`'; |
|
| 18 | - $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
| 19 | - [$salt] = $GLOBALS['xoopsDB']->fetchRow($result); |
|
| 20 | - |
|
| 21 | - return $salt; |
|
| 22 | - } |
|
| 12 | + /** |
|
| 13 | + * @return mixed |
|
| 14 | + */ |
|
| 15 | + function songlist_getToken() |
|
| 16 | + { |
|
| 17 | + $sql = 'SELECT md5(rand()/rand()*rand()/rand()*rand()*rand()/rand()*rand()) as `salt`'; |
|
| 18 | + $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
| 19 | + [$salt] = $GLOBALS['xoopsDB']->fetchRow($result); |
|
| 20 | + |
|
| 21 | + return $salt; |
|
| 22 | + } |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if (!function_exists('ucword')) { |
| 26 | - /** |
|
| 27 | - * @param $string |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - function ucword($string): string |
|
| 31 | - { |
|
| 32 | - $ret = []; |
|
| 33 | - foreach (explode(' ', \mb_strtolower($string)) as $part) { |
|
| 34 | - $ret[] = ucfirst($part); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - return implode(' ', $ret); |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * @param $string |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + function ucword($string): string |
|
| 31 | + { |
|
| 32 | + $ret = []; |
|
| 33 | + foreach (explode(' ', \mb_strtolower($string)) as $part) { |
|
| 34 | + $ret[] = ucfirst($part); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + return implode(' ', $ret); |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | if (!function_exists('songlist_getIPData')) { |
| 42 | - /** |
|
| 43 | - * @param bool|string $ip |
|
| 44 | - * @return array |
|
| 45 | - */ |
|
| 46 | - function songlist_getIPData($ip = false): array |
|
| 47 | - { |
|
| 48 | - $ret = []; |
|
| 49 | - if (is_object($GLOBALS['xoopsUser'])) { |
|
| 50 | - $ret['uid'] = $GLOBALS['xoopsUser']->getVar('uid'); |
|
| 51 | - $ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname'); |
|
| 52 | - $ret['email'] = $GLOBALS['xoopsUser']->getVar('email'); |
|
| 53 | - } else { |
|
| 54 | - $ret['uid'] = 0; |
|
| 55 | - $ret['uname'] = ($_REQUEST['uname'] ?? ''); |
|
| 56 | - $ret['email'] = ($_REQUEST['email'] ?? ''); |
|
| 57 | - } |
|
| 58 | - $ret['agent'] = $_SERVER['HTTP_USER_AGENT']; |
|
| 59 | - if ($ip) { |
|
| 60 | - $ret['is_proxied'] = false; |
|
| 61 | - $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 62 | - $ret['long'] = @ip2long($ip); |
|
| 63 | - if (is_ipv6($ip)) { |
|
| 64 | - $ret['ip6'] = true; |
|
| 65 | - $ret['ip4'] = false; |
|
| 66 | - } else { |
|
| 67 | - $ret['ip4'] = true; |
|
| 68 | - $ret['ip6'] = false; |
|
| 69 | - } |
|
| 70 | - $ret['ip'] = $ip; |
|
| 71 | - } elseif (Request::hasVar('HTTP_X_FORWARDED_FOR', 'SERVER')) { |
|
| 72 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 73 | - $ret['is_proxied'] = true; |
|
| 74 | - $proxy_ip = $_SERVER['REMOTE_ADDR']; |
|
| 75 | - $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 76 | - $ret['long'] = @ip2long($ip); |
|
| 77 | - if (is_ipv6($ip)) { |
|
| 78 | - $ret['ip6'] = true; |
|
| 79 | - $ret['proxy-ip6'] = true; |
|
| 80 | - $ret['ip4'] = false; |
|
| 81 | - $ret['proxy-ip4'] = false; |
|
| 82 | - } else { |
|
| 83 | - $ret['ip4'] = true; |
|
| 84 | - $ret['proxy-ip4'] = true; |
|
| 85 | - $ret['ip6'] = false; |
|
| 86 | - $ret['proxy-ip6'] = false; |
|
| 87 | - } |
|
| 88 | - $ret['ip'] = $ip; |
|
| 89 | - $ret['proxy-ip'] = $proxy_ip; |
|
| 90 | - } else { |
|
| 91 | - $ret['is_proxied'] = false; |
|
| 92 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 93 | - $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 94 | - $ret['long'] = @ip2long($ip); |
|
| 95 | - if (is_ipv6($ip)) { |
|
| 96 | - $ret['ip6'] = true; |
|
| 97 | - $ret['ip4'] = false; |
|
| 98 | - } else { |
|
| 99 | - $ret['ip4'] = true; |
|
| 100 | - $ret['ip6'] = false; |
|
| 101 | - } |
|
| 102 | - $ret['ip'] = $ip; |
|
| 103 | - } |
|
| 104 | - $ret['made'] = time(); |
|
| 105 | - |
|
| 106 | - return $ret; |
|
| 107 | - } |
|
| 42 | + /** |
|
| 43 | + * @param bool|string $ip |
|
| 44 | + * @return array |
|
| 45 | + */ |
|
| 46 | + function songlist_getIPData($ip = false): array |
|
| 47 | + { |
|
| 48 | + $ret = []; |
|
| 49 | + if (is_object($GLOBALS['xoopsUser'])) { |
|
| 50 | + $ret['uid'] = $GLOBALS['xoopsUser']->getVar('uid'); |
|
| 51 | + $ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname'); |
|
| 52 | + $ret['email'] = $GLOBALS['xoopsUser']->getVar('email'); |
|
| 53 | + } else { |
|
| 54 | + $ret['uid'] = 0; |
|
| 55 | + $ret['uname'] = ($_REQUEST['uname'] ?? ''); |
|
| 56 | + $ret['email'] = ($_REQUEST['email'] ?? ''); |
|
| 57 | + } |
|
| 58 | + $ret['agent'] = $_SERVER['HTTP_USER_AGENT']; |
|
| 59 | + if ($ip) { |
|
| 60 | + $ret['is_proxied'] = false; |
|
| 61 | + $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 62 | + $ret['long'] = @ip2long($ip); |
|
| 63 | + if (is_ipv6($ip)) { |
|
| 64 | + $ret['ip6'] = true; |
|
| 65 | + $ret['ip4'] = false; |
|
| 66 | + } else { |
|
| 67 | + $ret['ip4'] = true; |
|
| 68 | + $ret['ip6'] = false; |
|
| 69 | + } |
|
| 70 | + $ret['ip'] = $ip; |
|
| 71 | + } elseif (Request::hasVar('HTTP_X_FORWARDED_FOR', 'SERVER')) { |
|
| 72 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 73 | + $ret['is_proxied'] = true; |
|
| 74 | + $proxy_ip = $_SERVER['REMOTE_ADDR']; |
|
| 75 | + $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 76 | + $ret['long'] = @ip2long($ip); |
|
| 77 | + if (is_ipv6($ip)) { |
|
| 78 | + $ret['ip6'] = true; |
|
| 79 | + $ret['proxy-ip6'] = true; |
|
| 80 | + $ret['ip4'] = false; |
|
| 81 | + $ret['proxy-ip4'] = false; |
|
| 82 | + } else { |
|
| 83 | + $ret['ip4'] = true; |
|
| 84 | + $ret['proxy-ip4'] = true; |
|
| 85 | + $ret['ip6'] = false; |
|
| 86 | + $ret['proxy-ip6'] = false; |
|
| 87 | + } |
|
| 88 | + $ret['ip'] = $ip; |
|
| 89 | + $ret['proxy-ip'] = $proxy_ip; |
|
| 90 | + } else { |
|
| 91 | + $ret['is_proxied'] = false; |
|
| 92 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 93 | + $ret['network-addy'] = @gethostbyaddr($ip); |
|
| 94 | + $ret['long'] = @ip2long($ip); |
|
| 95 | + if (is_ipv6($ip)) { |
|
| 96 | + $ret['ip6'] = true; |
|
| 97 | + $ret['ip4'] = false; |
|
| 98 | + } else { |
|
| 99 | + $ret['ip4'] = true; |
|
| 100 | + $ret['ip6'] = false; |
|
| 101 | + } |
|
| 102 | + $ret['ip'] = $ip; |
|
| 103 | + } |
|
| 104 | + $ret['made'] = time(); |
|
| 105 | + |
|
| 106 | + return $ret; |
|
| 107 | + } |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | if (!function_exists('is_ipv6')) { |
| 111 | - /** |
|
| 112 | - * @param string $ip |
|
| 113 | - * @return bool |
|
| 114 | - */ |
|
| 115 | - function is_ipv6($ip = ''): bool |
|
| 116 | - { |
|
| 117 | - if ('' == $ip) { |
|
| 118 | - return false; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - if (mb_substr_count($ip, ':') > 0) { |
|
| 122 | - return true; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return false; |
|
| 126 | - } |
|
| 111 | + /** |
|
| 112 | + * @param string $ip |
|
| 113 | + * @return bool |
|
| 114 | + */ |
|
| 115 | + function is_ipv6($ip = ''): bool |
|
| 116 | + { |
|
| 117 | + if ('' == $ip) { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + if (mb_substr_count($ip, ':') > 0) { |
|
| 122 | + return true; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + return false; |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | if (!function_exists('songlist_getFilterElement')) { |
| 130 | - /** |
|
| 131 | - * @param $filter |
|
| 132 | - * @param $field |
|
| 133 | - * @param string $sort |
|
| 134 | - * @param string $op |
|
| 135 | - * @param string $fct |
|
| 136 | - * @return bool|\XoopsModules\Songlist\Form\SelectAlbumForm|\XoopsModules\Songlist\Form\SelectArtistForm|\XoopsModules\Songlist\Form\SelectCategoryForm|\XoopsModules\Songlist\Form\SelectGenreForm|\XoopsModules\Songlist\Form\SelectVoiceForm |
|
| 137 | - */ |
|
| 138 | - function songlist_getFilterElement($filter, $field, $sort = 'created', $op = '', $fct = '') |
|
| 139 | - { |
|
| 140 | - $components = songlist_getFilterURLComponents($filter, $field, $sort); |
|
| 141 | - $ele = false; |
|
| 142 | - require_once __DIR__ . '/songlist.object.php'; |
|
| 143 | - switch ($field) { |
|
| 144 | - case 'gid': |
|
| 145 | - if ('genre' !== $op) { |
|
| 146 | - $ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 147 | - $ele->setExtra( |
|
| 148 | - 'onchange="window.open(\'' |
|
| 149 | - . $_SERVER['SCRIPT_NAME'] |
|
| 150 | - . '?' |
|
| 151 | - . $components['extra'] |
|
| 152 | - . '&filter=' |
|
| 153 | - . $components['filter'] |
|
| 154 | - . (!empty($components['filter']) ? '|' : '') |
|
| 155 | - . $field |
|
| 156 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 157 | - . (!empty($components['operator']) ? '+\',' |
|
| 158 | - . $components['operator'] |
|
| 159 | - . '\'' : '') |
|
| 160 | - . ',\'_self\')"' |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - break; |
|
| 164 | - case 'vcid': |
|
| 165 | - if ('voice' !== $op) { |
|
| 166 | - $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 167 | - $ele->setExtra( |
|
| 168 | - 'onchange="window.open(\'' |
|
| 169 | - . $_SERVER['SCRIPT_NAME'] |
|
| 170 | - . '?' |
|
| 171 | - . $components['extra'] |
|
| 172 | - . '&filter=' |
|
| 173 | - . $components['filter'] |
|
| 174 | - . (!empty($components['filter']) ? '|' : '') |
|
| 175 | - . $field |
|
| 176 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 177 | - . (!empty($components['operator']) ? '+\',' |
|
| 178 | - . $components['operator'] |
|
| 179 | - . '\'' : '') |
|
| 180 | - . ',\'_self\')"' |
|
| 181 | - ); |
|
| 182 | - } |
|
| 183 | - break; |
|
| 184 | - case 'cid': |
|
| 185 | - if ('category' !== $op) { |
|
| 186 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 187 | - $ele->setExtra( |
|
| 188 | - 'onchange="window.open(\'' |
|
| 189 | - . $_SERVER['SCRIPT_NAME'] |
|
| 190 | - . '?' |
|
| 191 | - . $components['extra'] |
|
| 192 | - . '&filter=' |
|
| 193 | - . $components['filter'] |
|
| 194 | - . (!empty($components['filter']) ? '|' : '') |
|
| 195 | - . $field |
|
| 196 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 197 | - . (!empty($components['operator']) ? '+\',' |
|
| 198 | - . $components['operator'] |
|
| 199 | - . '\'' : '') |
|
| 200 | - . ',\'_self\')"' |
|
| 201 | - ); |
|
| 202 | - } |
|
| 203 | - break; |
|
| 204 | - case 'pid': |
|
| 205 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 206 | - $ele->setExtra( |
|
| 207 | - 'onchange="window.open(\'' |
|
| 208 | - . $_SERVER['SCRIPT_NAME'] |
|
| 209 | - . '?' |
|
| 210 | - . $components['extra'] |
|
| 211 | - . '&filter=' |
|
| 212 | - . $components['filter'] |
|
| 213 | - . (!empty($components['filter']) ? '|' : '') |
|
| 214 | - . $field |
|
| 215 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 216 | - . (!empty($components['operator']) ? '+\',' |
|
| 217 | - . $components['operator'] |
|
| 218 | - . '\'' : '') |
|
| 219 | - . ',\'_self\')"' |
|
| 220 | - ); |
|
| 221 | - break; |
|
| 222 | - case 'abid': |
|
| 223 | - if ('albums' !== $op) { |
|
| 224 | - $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 225 | - $ele->setExtra( |
|
| 226 | - 'onchange="window.open(\'' |
|
| 227 | - . $_SERVER['SCRIPT_NAME'] |
|
| 228 | - . '?' |
|
| 229 | - . $components['extra'] |
|
| 230 | - . '&filter=' |
|
| 231 | - . $components['filter'] |
|
| 232 | - . (!empty($components['filter']) ? '|' : '') |
|
| 233 | - . $field |
|
| 234 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 235 | - . (!empty($components['operator']) ? '+\',' |
|
| 236 | - . $components['operator'] |
|
| 237 | - . '\'' : '') |
|
| 238 | - . ',\'_self\')"' |
|
| 239 | - ); |
|
| 240 | - } |
|
| 241 | - break; |
|
| 242 | - case 'aid': |
|
| 243 | - if ('artists' !== $op) { |
|
| 244 | - $ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 245 | - $ele->setExtra( |
|
| 246 | - 'onchange="window.open(\'' |
|
| 247 | - . $_SERVER['SCRIPT_NAME'] |
|
| 248 | - . '?' |
|
| 249 | - . $components['extra'] |
|
| 250 | - . '&filter=' |
|
| 251 | - . $components['filter'] |
|
| 252 | - . (!empty($components['filter']) ? '|' : '') |
|
| 253 | - . $field |
|
| 254 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 255 | - . (!empty($components['operator']) ? '+\',' |
|
| 256 | - . $components['operator'] |
|
| 257 | - . '\'' : '') |
|
| 258 | - . ',\'_self\')"' |
|
| 259 | - ); |
|
| 260 | - } |
|
| 261 | - break; |
|
| 262 | - case 'sid': |
|
| 263 | - if ('songs' !== $op) { |
|
| 264 | - $ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 265 | - $ele->setExtra( |
|
| 266 | - 'onchange="window.open(\'' |
|
| 267 | - . $_SERVER['SCRIPT_NAME'] |
|
| 268 | - . '?' |
|
| 269 | - . $components['extra'] |
|
| 270 | - . '&filter=' |
|
| 271 | - . $components['filter'] |
|
| 272 | - . (!empty($components['filter']) ? '|' : '') |
|
| 273 | - . $field |
|
| 274 | - . ',\'+this.options[this.selectedIndex].value' |
|
| 275 | - . (!empty($components['operator']) ? '+\',' |
|
| 276 | - . $components['operator'] |
|
| 277 | - . '\'' : '') |
|
| 278 | - . ',\'_self\')"' |
|
| 279 | - ); |
|
| 280 | - } |
|
| 281 | - break; |
|
| 282 | - case 'name': |
|
| 283 | - case 'title': |
|
| 284 | - case 'artists': |
|
| 285 | - case 'albums': |
|
| 286 | - case 'songs': |
|
| 287 | - case 'hits': |
|
| 288 | - case 'rank': |
|
| 289 | - case 'votes': |
|
| 290 | - case 'description': |
|
| 291 | - case 'lyrics': |
|
| 292 | - case 'songid': |
|
| 293 | - case 'tags': |
|
| 294 | - $ele = new \XoopsFormElementTray(''); |
|
| 295 | - $ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value'])); |
|
| 296 | - $button = new \XoopsFormButton('', 'button_' . $field . '', '[+]'); |
|
| 297 | - $button->setExtra( |
|
| 298 | - 'onclick="window.open(\'' |
|
| 299 | - . $_SERVER['SCRIPT_NAME'] |
|
| 300 | - . '?' |
|
| 301 | - . $components['extra'] |
|
| 302 | - . '&filter=' |
|
| 303 | - . $components['filter'] |
|
| 304 | - . (!empty($components['filter']) ? '|' : '') |
|
| 305 | - . $field |
|
| 306 | - . ',\'+$(\'#filter_' |
|
| 307 | - . $field |
|
| 308 | - . '\').val()' |
|
| 309 | - . (!empty($components['operator']) ? '+\',' |
|
| 310 | - . $components['operator'] |
|
| 311 | - . '\'' : '') |
|
| 312 | - . ',\'_self\')"' |
|
| 313 | - ); |
|
| 314 | - $ele->addElement($button); |
|
| 315 | - break; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - return $ele; |
|
| 319 | - } |
|
| 130 | + /** |
|
| 131 | + * @param $filter |
|
| 132 | + * @param $field |
|
| 133 | + * @param string $sort |
|
| 134 | + * @param string $op |
|
| 135 | + * @param string $fct |
|
| 136 | + * @return bool|\XoopsModules\Songlist\Form\SelectAlbumForm|\XoopsModules\Songlist\Form\SelectArtistForm|\XoopsModules\Songlist\Form\SelectCategoryForm|\XoopsModules\Songlist\Form\SelectGenreForm|\XoopsModules\Songlist\Form\SelectVoiceForm |
|
| 137 | + */ |
|
| 138 | + function songlist_getFilterElement($filter, $field, $sort = 'created', $op = '', $fct = '') |
|
| 139 | + { |
|
| 140 | + $components = songlist_getFilterURLComponents($filter, $field, $sort); |
|
| 141 | + $ele = false; |
|
| 142 | + require_once __DIR__ . '/songlist.object.php'; |
|
| 143 | + switch ($field) { |
|
| 144 | + case 'gid': |
|
| 145 | + if ('genre' !== $op) { |
|
| 146 | + $ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 147 | + $ele->setExtra( |
|
| 148 | + 'onchange="window.open(\'' |
|
| 149 | + . $_SERVER['SCRIPT_NAME'] |
|
| 150 | + . '?' |
|
| 151 | + . $components['extra'] |
|
| 152 | + . '&filter=' |
|
| 153 | + . $components['filter'] |
|
| 154 | + . (!empty($components['filter']) ? '|' : '') |
|
| 155 | + . $field |
|
| 156 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 157 | + . (!empty($components['operator']) ? '+\',' |
|
| 158 | + . $components['operator'] |
|
| 159 | + . '\'' : '') |
|
| 160 | + . ',\'_self\')"' |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + break; |
|
| 164 | + case 'vcid': |
|
| 165 | + if ('voice' !== $op) { |
|
| 166 | + $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 167 | + $ele->setExtra( |
|
| 168 | + 'onchange="window.open(\'' |
|
| 169 | + . $_SERVER['SCRIPT_NAME'] |
|
| 170 | + . '?' |
|
| 171 | + . $components['extra'] |
|
| 172 | + . '&filter=' |
|
| 173 | + . $components['filter'] |
|
| 174 | + . (!empty($components['filter']) ? '|' : '') |
|
| 175 | + . $field |
|
| 176 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 177 | + . (!empty($components['operator']) ? '+\',' |
|
| 178 | + . $components['operator'] |
|
| 179 | + . '\'' : '') |
|
| 180 | + . ',\'_self\')"' |
|
| 181 | + ); |
|
| 182 | + } |
|
| 183 | + break; |
|
| 184 | + case 'cid': |
|
| 185 | + if ('category' !== $op) { |
|
| 186 | + $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 187 | + $ele->setExtra( |
|
| 188 | + 'onchange="window.open(\'' |
|
| 189 | + . $_SERVER['SCRIPT_NAME'] |
|
| 190 | + . '?' |
|
| 191 | + . $components['extra'] |
|
| 192 | + . '&filter=' |
|
| 193 | + . $components['filter'] |
|
| 194 | + . (!empty($components['filter']) ? '|' : '') |
|
| 195 | + . $field |
|
| 196 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 197 | + . (!empty($components['operator']) ? '+\',' |
|
| 198 | + . $components['operator'] |
|
| 199 | + . '\'' : '') |
|
| 200 | + . ',\'_self\')"' |
|
| 201 | + ); |
|
| 202 | + } |
|
| 203 | + break; |
|
| 204 | + case 'pid': |
|
| 205 | + $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 206 | + $ele->setExtra( |
|
| 207 | + 'onchange="window.open(\'' |
|
| 208 | + . $_SERVER['SCRIPT_NAME'] |
|
| 209 | + . '?' |
|
| 210 | + . $components['extra'] |
|
| 211 | + . '&filter=' |
|
| 212 | + . $components['filter'] |
|
| 213 | + . (!empty($components['filter']) ? '|' : '') |
|
| 214 | + . $field |
|
| 215 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 216 | + . (!empty($components['operator']) ? '+\',' |
|
| 217 | + . $components['operator'] |
|
| 218 | + . '\'' : '') |
|
| 219 | + . ',\'_self\')"' |
|
| 220 | + ); |
|
| 221 | + break; |
|
| 222 | + case 'abid': |
|
| 223 | + if ('albums' !== $op) { |
|
| 224 | + $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 225 | + $ele->setExtra( |
|
| 226 | + 'onchange="window.open(\'' |
|
| 227 | + . $_SERVER['SCRIPT_NAME'] |
|
| 228 | + . '?' |
|
| 229 | + . $components['extra'] |
|
| 230 | + . '&filter=' |
|
| 231 | + . $components['filter'] |
|
| 232 | + . (!empty($components['filter']) ? '|' : '') |
|
| 233 | + . $field |
|
| 234 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 235 | + . (!empty($components['operator']) ? '+\',' |
|
| 236 | + . $components['operator'] |
|
| 237 | + . '\'' : '') |
|
| 238 | + . ',\'_self\')"' |
|
| 239 | + ); |
|
| 240 | + } |
|
| 241 | + break; |
|
| 242 | + case 'aid': |
|
| 243 | + if ('artists' !== $op) { |
|
| 244 | + $ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 245 | + $ele->setExtra( |
|
| 246 | + 'onchange="window.open(\'' |
|
| 247 | + . $_SERVER['SCRIPT_NAME'] |
|
| 248 | + . '?' |
|
| 249 | + . $components['extra'] |
|
| 250 | + . '&filter=' |
|
| 251 | + . $components['filter'] |
|
| 252 | + . (!empty($components['filter']) ? '|' : '') |
|
| 253 | + . $field |
|
| 254 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 255 | + . (!empty($components['operator']) ? '+\',' |
|
| 256 | + . $components['operator'] |
|
| 257 | + . '\'' : '') |
|
| 258 | + . ',\'_self\')"' |
|
| 259 | + ); |
|
| 260 | + } |
|
| 261 | + break; |
|
| 262 | + case 'sid': |
|
| 263 | + if ('songs' !== $op) { |
|
| 264 | + $ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 265 | + $ele->setExtra( |
|
| 266 | + 'onchange="window.open(\'' |
|
| 267 | + . $_SERVER['SCRIPT_NAME'] |
|
| 268 | + . '?' |
|
| 269 | + . $components['extra'] |
|
| 270 | + . '&filter=' |
|
| 271 | + . $components['filter'] |
|
| 272 | + . (!empty($components['filter']) ? '|' : '') |
|
| 273 | + . $field |
|
| 274 | + . ',\'+this.options[this.selectedIndex].value' |
|
| 275 | + . (!empty($components['operator']) ? '+\',' |
|
| 276 | + . $components['operator'] |
|
| 277 | + . '\'' : '') |
|
| 278 | + . ',\'_self\')"' |
|
| 279 | + ); |
|
| 280 | + } |
|
| 281 | + break; |
|
| 282 | + case 'name': |
|
| 283 | + case 'title': |
|
| 284 | + case 'artists': |
|
| 285 | + case 'albums': |
|
| 286 | + case 'songs': |
|
| 287 | + case 'hits': |
|
| 288 | + case 'rank': |
|
| 289 | + case 'votes': |
|
| 290 | + case 'description': |
|
| 291 | + case 'lyrics': |
|
| 292 | + case 'songid': |
|
| 293 | + case 'tags': |
|
| 294 | + $ele = new \XoopsFormElementTray(''); |
|
| 295 | + $ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value'])); |
|
| 296 | + $button = new \XoopsFormButton('', 'button_' . $field . '', '[+]'); |
|
| 297 | + $button->setExtra( |
|
| 298 | + 'onclick="window.open(\'' |
|
| 299 | + . $_SERVER['SCRIPT_NAME'] |
|
| 300 | + . '?' |
|
| 301 | + . $components['extra'] |
|
| 302 | + . '&filter=' |
|
| 303 | + . $components['filter'] |
|
| 304 | + . (!empty($components['filter']) ? '|' : '') |
|
| 305 | + . $field |
|
| 306 | + . ',\'+$(\'#filter_' |
|
| 307 | + . $field |
|
| 308 | + . '\').val()' |
|
| 309 | + . (!empty($components['operator']) ? '+\',' |
|
| 310 | + . $components['operator'] |
|
| 311 | + . '\'' : '') |
|
| 312 | + . ',\'_self\')"' |
|
| 313 | + ); |
|
| 314 | + $ele->addElement($button); |
|
| 315 | + break; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + return $ele; |
|
| 319 | + } |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | if (!function_exists('songlist_getFilterURLComponents')) { |
| 323 | - /** |
|
| 324 | - * @param $filter |
|
| 325 | - * @param $field |
|
| 326 | - * @param string $sort |
|
| 327 | - * @return array |
|
| 328 | - */ |
|
| 329 | - function songlist_getFilterURLComponents($filter, $field, $sort = 'created'): array |
|
| 330 | - { |
|
| 331 | - $parts = explode('|', $filter); |
|
| 332 | - $ret = []; |
|
| 333 | - $value = ''; |
|
| 334 | - $ele_value = ''; |
|
| 335 | - $operator = ''; |
|
| 336 | - foreach ($parts as $part) { |
|
| 337 | - $var = explode(',', $part); |
|
| 338 | - if (count($var) > 1) { |
|
| 339 | - if ($var[0] == $field) { |
|
| 340 | - $ele_value = $var[1]; |
|
| 341 | - if (isset($var[2])) { |
|
| 342 | - $operator = $var[2]; |
|
| 343 | - } |
|
| 344 | - } elseif (1 != $var[0]) { |
|
| 345 | - $ret[] = implode(',', $var); |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - $pagenav = []; |
|
| 350 | - $pagenav['op'] = $_REQUEST['op'] ?? 'videos'; |
|
| 351 | - $pagenav['fct'] = $_REQUEST['fct'] ?? 'list'; |
|
| 352 | - $pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST'); |
|
| 353 | - $pagenav['start'] = 0; |
|
| 354 | - $pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
|
| 355 | - $pagenav['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort; |
|
| 356 | - $retb = []; |
|
| 357 | - foreach ($pagenav as $key => $value) { |
|
| 358 | - $retb[] = "$key=$value"; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - return ['value' => $ele_value, 'field' => $field, 'operator' => $operator, 'filter' => implode('|', $ret), 'extra' => implode('&', $retb)]; |
|
| 362 | - } |
|
| 323 | + /** |
|
| 324 | + * @param $filter |
|
| 325 | + * @param $field |
|
| 326 | + * @param string $sort |
|
| 327 | + * @return array |
|
| 328 | + */ |
|
| 329 | + function songlist_getFilterURLComponents($filter, $field, $sort = 'created'): array |
|
| 330 | + { |
|
| 331 | + $parts = explode('|', $filter); |
|
| 332 | + $ret = []; |
|
| 333 | + $value = ''; |
|
| 334 | + $ele_value = ''; |
|
| 335 | + $operator = ''; |
|
| 336 | + foreach ($parts as $part) { |
|
| 337 | + $var = explode(',', $part); |
|
| 338 | + if (count($var) > 1) { |
|
| 339 | + if ($var[0] == $field) { |
|
| 340 | + $ele_value = $var[1]; |
|
| 341 | + if (isset($var[2])) { |
|
| 342 | + $operator = $var[2]; |
|
| 343 | + } |
|
| 344 | + } elseif (1 != $var[0]) { |
|
| 345 | + $ret[] = implode(',', $var); |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + $pagenav = []; |
|
| 350 | + $pagenav['op'] = $_REQUEST['op'] ?? 'videos'; |
|
| 351 | + $pagenav['fct'] = $_REQUEST['fct'] ?? 'list'; |
|
| 352 | + $pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST'); |
|
| 353 | + $pagenav['start'] = 0; |
|
| 354 | + $pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
|
| 355 | + $pagenav['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort; |
|
| 356 | + $retb = []; |
|
| 357 | + foreach ($pagenav as $key => $value) { |
|
| 358 | + $retb[] = "$key=$value"; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + return ['value' => $ele_value, 'field' => $field, 'operator' => $operator, 'filter' => implode('|', $ret), 'extra' => implode('&', $retb)]; |
|
| 362 | + } |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | if (!function_exists('songlist_obj2array')) { |
| 366 | - /** |
|
| 367 | - * @param $objects |
|
| 368 | - * @return array |
|
| 369 | - */ |
|
| 370 | - function songlist_obj2array($objects): array |
|
| 371 | - { |
|
| 372 | - $ret = []; |
|
| 373 | - foreach ((array)$objects as $key => $value) { |
|
| 374 | - if (is_a($value, 'stdClass')) { |
|
| 375 | - $ret[$key] = songlist_obj2array($value); |
|
| 376 | - } elseif (is_array($value)) { |
|
| 377 | - $ret[$key] = songlist_obj2array($value); |
|
| 378 | - } else { |
|
| 379 | - $ret[$key] = $value; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - return $ret; |
|
| 384 | - } |
|
| 366 | + /** |
|
| 367 | + * @param $objects |
|
| 368 | + * @return array |
|
| 369 | + */ |
|
| 370 | + function songlist_obj2array($objects): array |
|
| 371 | + { |
|
| 372 | + $ret = []; |
|
| 373 | + foreach ((array)$objects as $key => $value) { |
|
| 374 | + if (is_a($value, 'stdClass')) { |
|
| 375 | + $ret[$key] = songlist_obj2array($value); |
|
| 376 | + } elseif (is_array($value)) { |
|
| 377 | + $ret[$key] = songlist_obj2array($value); |
|
| 378 | + } else { |
|
| 379 | + $ret[$key] = $value; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + return $ret; |
|
| 384 | + } |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | if (!function_exists('songlist_shortenurl')) { |
| 388 | - /** |
|
| 389 | - * @param $url |
|
| 390 | - * @return mixed |
|
| 391 | - */ |
|
| 392 | - function songlist_shortenurl($url) |
|
| 393 | - { |
|
| 394 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 395 | - $moduleHandler = xoops_getHandler('module'); |
|
| 396 | - /** @var \XoopsConfigHandler $configHandler */ |
|
| 397 | - $configHandler = xoops_getHandler('config'); |
|
| 398 | - $GLOBALS['songlistModule'] = $moduleHandler->getByDirname('songlist'); |
|
| 399 | - $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
|
| 400 | - |
|
| 401 | - if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) { |
|
| 402 | - $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url); |
|
| 403 | - $cookies = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie'; |
|
| 404 | - if (!$ch = curl_init($source_url)) { |
|
| 405 | - return $url; |
|
| 406 | - } |
|
| 407 | - curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); |
|
| 408 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 409 | - curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['songlistModuleConfig']['user_agent']); |
|
| 410 | - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $GLOBALS['songlistModuleConfig']['curl_connect_timeout']); |
|
| 411 | - curl_setopt($ch, CURLOPT_TIMEOUT, $GLOBALS['songlistModuleConfig']['curl_timeout']); |
|
| 412 | - $data = curl_exec($ch); |
|
| 413 | - curl_close($ch); |
|
| 414 | - $result = songlist_object2array(json_decode($data)); |
|
| 415 | - $result['status_code'] = 200; |
|
| 416 | - if ($result['status_code']) { |
|
| 417 | - if (!empty($result['data']['url'])) { |
|
| 418 | - return $result['data']['url']; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - return $url; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - return $url; |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - return $url; |
|
| 428 | - } |
|
| 388 | + /** |
|
| 389 | + * @param $url |
|
| 390 | + * @return mixed |
|
| 391 | + */ |
|
| 392 | + function songlist_shortenurl($url) |
|
| 393 | + { |
|
| 394 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 395 | + $moduleHandler = xoops_getHandler('module'); |
|
| 396 | + /** @var \XoopsConfigHandler $configHandler */ |
|
| 397 | + $configHandler = xoops_getHandler('config'); |
|
| 398 | + $GLOBALS['songlistModule'] = $moduleHandler->getByDirname('songlist'); |
|
| 399 | + $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
|
| 400 | + |
|
| 401 | + if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) { |
|
| 402 | + $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url); |
|
| 403 | + $cookies = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie'; |
|
| 404 | + if (!$ch = curl_init($source_url)) { |
|
| 405 | + return $url; |
|
| 406 | + } |
|
| 407 | + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); |
|
| 408 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 409 | + curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['songlistModuleConfig']['user_agent']); |
|
| 410 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $GLOBALS['songlistModuleConfig']['curl_connect_timeout']); |
|
| 411 | + curl_setopt($ch, CURLOPT_TIMEOUT, $GLOBALS['songlistModuleConfig']['curl_timeout']); |
|
| 412 | + $data = curl_exec($ch); |
|
| 413 | + curl_close($ch); |
|
| 414 | + $result = songlist_object2array(json_decode($data)); |
|
| 415 | + $result['status_code'] = 200; |
|
| 416 | + if ($result['status_code']) { |
|
| 417 | + if (!empty($result['data']['url'])) { |
|
| 418 | + return $result['data']['url']; |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + return $url; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + return $url; |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + return $url; |
|
| 428 | + } |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | if (!function_exists('songlist_xml2array')) { |
| 432 | - /** |
|
| 433 | - * @param $contents |
|
| 434 | - * @param int $get_attributes |
|
| 435 | - * @param string $priority |
|
| 436 | - * @return array|void |
|
| 437 | - */ |
|
| 438 | - function songlist_xml2array($contents, $get_attributes = 1, $priority = 'tag') |
|
| 439 | - { |
|
| 440 | - if (!$contents) { |
|
| 441 | - return []; |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - if (!function_exists('xml_parser_create')) { |
|
| 445 | - return []; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - //Get the XML parser of PHP - PHP must have this module for the parser to work |
|
| 449 | - $parser = xml_parser_create(''); |
|
| 450 | - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); # https://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
| 451 | - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 452 | - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 453 | - xml_parse_into_struct($parser, trim($contents), $xml_values); |
|
| 454 | - xml_parser_free($parser); |
|
| 455 | - |
|
| 456 | - if (!$xml_values) { |
|
| 457 | - return; |
|
| 458 | - }//Hmm... |
|
| 459 | - |
|
| 460 | - //Initializations |
|
| 461 | - $xml_array = []; |
|
| 462 | - $parents = []; |
|
| 463 | - $opened_tags = []; |
|
| 464 | - $arr = []; |
|
| 465 | - |
|
| 466 | - $current = &$xml_array; //Refference |
|
| 467 | - |
|
| 468 | - //Go through the tags. |
|
| 469 | - $repeated_tag_index = []; //Multiple tags with same name will be turned into an array |
|
| 470 | - foreach ($xml_values as $data) { |
|
| 471 | - unset($attributes, $value); //Remove existing values, or there will be trouble |
|
| 472 | - |
|
| 473 | - //This command will extract these variables into the foreach scope |
|
| 474 | - // tag(string), type(string), level(int), attributes(array). |
|
| 475 | - extract($data); //We could use the array by itself, but this cooler. |
|
| 476 | - |
|
| 477 | - $result = []; |
|
| 478 | - $attributes_data = []; |
|
| 479 | - |
|
| 480 | - if (isset($value)) { |
|
| 481 | - if ('tag' === $priority) { |
|
| 482 | - $result = $value; |
|
| 483 | - } else { |
|
| 484 | - $result['value'] = $value; |
|
| 485 | - } //Put the value in a assoc array if we are in the 'Attribute' mode |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - //Set the attributes too. |
|
| 489 | - if (isset($attributes) and $get_attributes) { |
|
| 490 | - foreach ($attributes as $attr => $val) { |
|
| 491 | - if ('tag' === $priority) { |
|
| 492 | - $attributes_data[$attr] = $val; |
|
| 493 | - } else { |
|
| 494 | - $result['attr'][$attr] = $val; |
|
| 495 | - } //Set all the attributes in a array called 'attr' |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - //See tag status and do the needed. |
|
| 500 | - if ('open' === $type) {//The starting of the tag '<tag>' |
|
| 501 | - $parent[$level - 1] = &$current; |
|
| 502 | - if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag |
|
| 503 | - $current[$tag] = $result; |
|
| 504 | - if ($attributes_data) { |
|
| 505 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 506 | - } |
|
| 507 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 508 | - |
|
| 509 | - $current = &$current[$tag]; |
|
| 510 | - } else { //There was another element with the same tag name |
|
| 511 | - if (isset($current[$tag][0])) {//If there is a 0th element it is already an array |
|
| 512 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 513 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 514 | - } else {//This section will make the value an array if multiple tags with the same name appear together |
|
| 515 | - $current[$tag] = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array |
|
| 516 | - $repeated_tag_index[$tag . '_' . $level] = 2; |
|
| 517 | - |
|
| 518 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 519 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 520 | - unset($current[$tag . '_attr']); |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; |
|
| 524 | - $current = &$current[$tag][$last_item_index]; |
|
| 525 | - } |
|
| 526 | - } elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>' |
|
| 527 | - //See if the key is already taken. |
|
| 528 | - if (isset($current[$tag])) { //If taken, put all things inside a list(array) |
|
| 529 | - if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... |
|
| 530 | - // ...push the new element into that array. |
|
| 531 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 532 | - |
|
| 533 | - if ('tag' === $priority and $get_attributes and $attributes_data) { |
|
| 534 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 535 | - } |
|
| 536 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 537 | - } else { //If it is not an array... |
|
| 538 | - $current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value |
|
| 539 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 540 | - if ('tag' === $priority and $get_attributes) { |
|
| 541 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 542 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 543 | - unset($current[$tag . '_attr']); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - if ($attributes_data) { |
|
| 547 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 548 | - } |
|
| 549 | - } |
|
| 550 | - $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken |
|
| 551 | - } |
|
| 552 | - } else { //New Key |
|
| 553 | - $current[$tag] = $result; |
|
| 554 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 555 | - if ('tag' === $priority and $attributes_data) { |
|
| 556 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 557 | - } |
|
| 558 | - } |
|
| 559 | - } elseif ('close' === $type) { //End of tag '</tag>' |
|
| 560 | - $current = &$parent[$level - 1]; |
|
| 561 | - } |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - return $xml_array; |
|
| 565 | - } |
|
| 432 | + /** |
|
| 433 | + * @param $contents |
|
| 434 | + * @param int $get_attributes |
|
| 435 | + * @param string $priority |
|
| 436 | + * @return array|void |
|
| 437 | + */ |
|
| 438 | + function songlist_xml2array($contents, $get_attributes = 1, $priority = 'tag') |
|
| 439 | + { |
|
| 440 | + if (!$contents) { |
|
| 441 | + return []; |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + if (!function_exists('xml_parser_create')) { |
|
| 445 | + return []; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + //Get the XML parser of PHP - PHP must have this module for the parser to work |
|
| 449 | + $parser = xml_parser_create(''); |
|
| 450 | + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); # https://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
| 451 | + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 452 | + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 453 | + xml_parse_into_struct($parser, trim($contents), $xml_values); |
|
| 454 | + xml_parser_free($parser); |
|
| 455 | + |
|
| 456 | + if (!$xml_values) { |
|
| 457 | + return; |
|
| 458 | + }//Hmm... |
|
| 459 | + |
|
| 460 | + //Initializations |
|
| 461 | + $xml_array = []; |
|
| 462 | + $parents = []; |
|
| 463 | + $opened_tags = []; |
|
| 464 | + $arr = []; |
|
| 465 | + |
|
| 466 | + $current = &$xml_array; //Refference |
|
| 467 | + |
|
| 468 | + //Go through the tags. |
|
| 469 | + $repeated_tag_index = []; //Multiple tags with same name will be turned into an array |
|
| 470 | + foreach ($xml_values as $data) { |
|
| 471 | + unset($attributes, $value); //Remove existing values, or there will be trouble |
|
| 472 | + |
|
| 473 | + //This command will extract these variables into the foreach scope |
|
| 474 | + // tag(string), type(string), level(int), attributes(array). |
|
| 475 | + extract($data); //We could use the array by itself, but this cooler. |
|
| 476 | + |
|
| 477 | + $result = []; |
|
| 478 | + $attributes_data = []; |
|
| 479 | + |
|
| 480 | + if (isset($value)) { |
|
| 481 | + if ('tag' === $priority) { |
|
| 482 | + $result = $value; |
|
| 483 | + } else { |
|
| 484 | + $result['value'] = $value; |
|
| 485 | + } //Put the value in a assoc array if we are in the 'Attribute' mode |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + //Set the attributes too. |
|
| 489 | + if (isset($attributes) and $get_attributes) { |
|
| 490 | + foreach ($attributes as $attr => $val) { |
|
| 491 | + if ('tag' === $priority) { |
|
| 492 | + $attributes_data[$attr] = $val; |
|
| 493 | + } else { |
|
| 494 | + $result['attr'][$attr] = $val; |
|
| 495 | + } //Set all the attributes in a array called 'attr' |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + //See tag status and do the needed. |
|
| 500 | + if ('open' === $type) {//The starting of the tag '<tag>' |
|
| 501 | + $parent[$level - 1] = &$current; |
|
| 502 | + if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag |
|
| 503 | + $current[$tag] = $result; |
|
| 504 | + if ($attributes_data) { |
|
| 505 | + $current[$tag . '_attr'] = $attributes_data; |
|
| 506 | + } |
|
| 507 | + $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 508 | + |
|
| 509 | + $current = &$current[$tag]; |
|
| 510 | + } else { //There was another element with the same tag name |
|
| 511 | + if (isset($current[$tag][0])) {//If there is a 0th element it is already an array |
|
| 512 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 513 | + $repeated_tag_index[$tag . '_' . $level]++; |
|
| 514 | + } else {//This section will make the value an array if multiple tags with the same name appear together |
|
| 515 | + $current[$tag] = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array |
|
| 516 | + $repeated_tag_index[$tag . '_' . $level] = 2; |
|
| 517 | + |
|
| 518 | + if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 519 | + $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 520 | + unset($current[$tag . '_attr']); |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; |
|
| 524 | + $current = &$current[$tag][$last_item_index]; |
|
| 525 | + } |
|
| 526 | + } elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>' |
|
| 527 | + //See if the key is already taken. |
|
| 528 | + if (isset($current[$tag])) { //If taken, put all things inside a list(array) |
|
| 529 | + if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... |
|
| 530 | + // ...push the new element into that array. |
|
| 531 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 532 | + |
|
| 533 | + if ('tag' === $priority and $get_attributes and $attributes_data) { |
|
| 534 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 535 | + } |
|
| 536 | + $repeated_tag_index[$tag . '_' . $level]++; |
|
| 537 | + } else { //If it is not an array... |
|
| 538 | + $current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value |
|
| 539 | + $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 540 | + if ('tag' === $priority and $get_attributes) { |
|
| 541 | + if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 542 | + $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 543 | + unset($current[$tag . '_attr']); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + if ($attributes_data) { |
|
| 547 | + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | + $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken |
|
| 551 | + } |
|
| 552 | + } else { //New Key |
|
| 553 | + $current[$tag] = $result; |
|
| 554 | + $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 555 | + if ('tag' === $priority and $attributes_data) { |
|
| 556 | + $current[$tag . '_attr'] = $attributes_data; |
|
| 557 | + } |
|
| 558 | + } |
|
| 559 | + } elseif ('close' === $type) { //End of tag '</tag>' |
|
| 560 | + $current = &$parent[$level - 1]; |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + return $xml_array; |
|
| 565 | + } |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | if (!function_exists('songlist_toXml')) { |
| 569 | - /** |
|
| 570 | - * @param $array |
|
| 571 | - * @param $name |
|
| 572 | - * @param $standalone |
|
| 573 | - * @param $beginning |
|
| 574 | - * @param $nested |
|
| 575 | - * @return string |
|
| 576 | - */ |
|
| 577 | - function songlist_toXml($array, $name, $standalone, $beginning, $nested): string |
|
| 578 | - { |
|
| 579 | - $output = ''; |
|
| 580 | - if ($beginning) { |
|
| 581 | - if ($standalone) { |
|
| 582 | - header('content-type:text/xml;charset=' . _CHARSET); |
|
| 583 | - } |
|
| 584 | - $output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n"; |
|
| 585 | - $output .= '<' . $name . '>' . "\n"; |
|
| 586 | - $nested = 0; |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - if (is_array($array)) { |
|
| 590 | - foreach ($array as $key => $value) { |
|
| 591 | - ++$nested; |
|
| 592 | - if (is_array($value)) { |
|
| 593 | - $output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 594 | - ++$nested; |
|
| 595 | - $output .= songlist_toXml($value, $name, false, false, $nested); |
|
| 596 | - $nested--; |
|
| 597 | - $output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 598 | - } elseif ('' != $value) { |
|
| 599 | - ++$nested; |
|
| 600 | - $output .= str_repeat("\t", (int)$nested) . ' <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 601 | - $nested--; |
|
| 602 | - } |
|
| 603 | - $nested--; |
|
| 604 | - } |
|
| 605 | - } elseif ('' != $array) { |
|
| 606 | - ++$nested; |
|
| 607 | - $output .= str_repeat("\t", (int)$nested) . trim($array) . "\n"; |
|
| 608 | - $nested--; |
|
| 609 | - } |
|
| 610 | - |
|
| 611 | - if ($beginning) { |
|
| 612 | - $output .= '</' . $name . '>'; |
|
| 613 | - |
|
| 614 | - return $output; |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - return $output; |
|
| 618 | - } |
|
| 569 | + /** |
|
| 570 | + * @param $array |
|
| 571 | + * @param $name |
|
| 572 | + * @param $standalone |
|
| 573 | + * @param $beginning |
|
| 574 | + * @param $nested |
|
| 575 | + * @return string |
|
| 576 | + */ |
|
| 577 | + function songlist_toXml($array, $name, $standalone, $beginning, $nested): string |
|
| 578 | + { |
|
| 579 | + $output = ''; |
|
| 580 | + if ($beginning) { |
|
| 581 | + if ($standalone) { |
|
| 582 | + header('content-type:text/xml;charset=' . _CHARSET); |
|
| 583 | + } |
|
| 584 | + $output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n"; |
|
| 585 | + $output .= '<' . $name . '>' . "\n"; |
|
| 586 | + $nested = 0; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + if (is_array($array)) { |
|
| 590 | + foreach ($array as $key => $value) { |
|
| 591 | + ++$nested; |
|
| 592 | + if (is_array($value)) { |
|
| 593 | + $output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 594 | + ++$nested; |
|
| 595 | + $output .= songlist_toXml($value, $name, false, false, $nested); |
|
| 596 | + $nested--; |
|
| 597 | + $output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 598 | + } elseif ('' != $value) { |
|
| 599 | + ++$nested; |
|
| 600 | + $output .= str_repeat("\t", (int)$nested) . ' <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 601 | + $nested--; |
|
| 602 | + } |
|
| 603 | + $nested--; |
|
| 604 | + } |
|
| 605 | + } elseif ('' != $array) { |
|
| 606 | + ++$nested; |
|
| 607 | + $output .= str_repeat("\t", (int)$nested) . trim($array) . "\n"; |
|
| 608 | + $nested--; |
|
| 609 | + } |
|
| 610 | + |
|
| 611 | + if ($beginning) { |
|
| 612 | + $output .= '</' . $name . '>'; |
|
| 613 | + |
|
| 614 | + return $output; |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + return $output; |
|
| 618 | + } |
|
| 619 | 619 | } |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function is_ipv6($ip = ''): bool |
| 116 | 116 | { |
| 117 | - if ('' == $ip) { |
|
| 117 | + if (''==$ip) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if (mb_substr_count($ip, ':') > 0) { |
|
| 121 | + if (mb_substr_count($ip, ':')>0) { |
|
| 122 | 122 | return true; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | $components = songlist_getFilterURLComponents($filter, $field, $sort); |
| 141 | 141 | $ele = false; |
| 142 | - require_once __DIR__ . '/songlist.object.php'; |
|
| 142 | + require_once __DIR__.'/songlist.object.php'; |
|
| 143 | 143 | switch ($field) { |
| 144 | 144 | case 'gid': |
| 145 | - if ('genre' !== $op) { |
|
| 146 | - $ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 145 | + if ('genre'!==$op) { |
|
| 146 | + $ele = new SelectGenreForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 147 | 147 | $ele->setExtra( |
| 148 | 148 | 'onchange="window.open(\'' |
| 149 | 149 | . $_SERVER['SCRIPT_NAME'] |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | break; |
| 164 | 164 | case 'vcid': |
| 165 | - if ('voice' !== $op) { |
|
| 166 | - $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 165 | + if ('voice'!==$op) { |
|
| 166 | + $ele = new SelectVoiceForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 167 | 167 | $ele->setExtra( |
| 168 | 168 | 'onchange="window.open(\'' |
| 169 | 169 | . $_SERVER['SCRIPT_NAME'] |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | break; |
| 184 | 184 | case 'cid': |
| 185 | - if ('category' !== $op) { |
|
| 186 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 185 | + if ('category'!==$op) { |
|
| 186 | + $ele = new SelectCategoryForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 187 | 187 | $ele->setExtra( |
| 188 | 188 | 'onchange="window.open(\'' |
| 189 | 189 | . $_SERVER['SCRIPT_NAME'] |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | break; |
| 204 | 204 | case 'pid': |
| 205 | - $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 205 | + $ele = new SelectCategoryForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 206 | 206 | $ele->setExtra( |
| 207 | 207 | 'onchange="window.open(\'' |
| 208 | 208 | . $_SERVER['SCRIPT_NAME'] |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | ); |
| 221 | 221 | break; |
| 222 | 222 | case 'abid': |
| 223 | - if ('albums' !== $op) { |
|
| 224 | - $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 223 | + if ('albums'!==$op) { |
|
| 224 | + $ele = new SelectAlbumForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 225 | 225 | $ele->setExtra( |
| 226 | 226 | 'onchange="window.open(\'' |
| 227 | 227 | . $_SERVER['SCRIPT_NAME'] |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | break; |
| 242 | 242 | case 'aid': |
| 243 | - if ('artists' !== $op) { |
|
| 244 | - $ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 243 | + if ('artists'!==$op) { |
|
| 244 | + $ele = new SelectArtistForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 245 | 245 | $ele->setExtra( |
| 246 | 246 | 'onchange="window.open(\'' |
| 247 | 247 | . $_SERVER['SCRIPT_NAME'] |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | break; |
| 262 | 262 | case 'sid': |
| 263 | - if ('songs' !== $op) { |
|
| 264 | - $ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false); |
|
| 263 | + if ('songs'!==$op) { |
|
| 264 | + $ele = new SelectSongForm('', 'filter_'.$field.'', $components['value'], 1, false); |
|
| 265 | 265 | $ele->setExtra( |
| 266 | 266 | 'onchange="window.open(\'' |
| 267 | 267 | . $_SERVER['SCRIPT_NAME'] |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | case 'songid': |
| 293 | 293 | case 'tags': |
| 294 | 294 | $ele = new \XoopsFormElementTray(''); |
| 295 | - $ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value'])); |
|
| 296 | - $button = new \XoopsFormButton('', 'button_' . $field . '', '[+]'); |
|
| 295 | + $ele->addElement(new \XoopsFormText('', 'filter_'.$field.'', 11, 40, $components['value'])); |
|
| 296 | + $button = new \XoopsFormButton('', 'button_'.$field.'', '[+]'); |
|
| 297 | 297 | $button->setExtra( |
| 298 | 298 | 'onclick="window.open(\'' |
| 299 | 299 | . $_SERVER['SCRIPT_NAME'] |
@@ -335,13 +335,13 @@ discard block |
||
| 335 | 335 | $operator = ''; |
| 336 | 336 | foreach ($parts as $part) { |
| 337 | 337 | $var = explode(',', $part); |
| 338 | - if (count($var) > 1) { |
|
| 339 | - if ($var[0] == $field) { |
|
| 338 | + if (count($var)>1) { |
|
| 339 | + if ($var[0]==$field) { |
|
| 340 | 340 | $ele_value = $var[1]; |
| 341 | 341 | if (isset($var[2])) { |
| 342 | 342 | $operator = $var[2]; |
| 343 | 343 | } |
| 344 | - } elseif (1 != $var[0]) { |
|
| 344 | + } elseif (1!=$var[0]) { |
|
| 345 | 345 | $ret[] = implode(',', $var); |
| 346 | 346 | } |
| 347 | 347 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST'); |
| 353 | 353 | $pagenav['start'] = 0; |
| 354 | 354 | $pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
| 355 | - $pagenav['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort; |
|
| 355 | + $pagenav['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : $sort; |
|
| 356 | 356 | $retb = []; |
| 357 | 357 | foreach ($pagenav as $key => $value) { |
| 358 | 358 | $retb[] = "$key=$value"; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | function songlist_obj2array($objects): array |
| 371 | 371 | { |
| 372 | 372 | $ret = []; |
| 373 | - foreach ((array)$objects as $key => $value) { |
|
| 373 | + foreach ((array) $objects as $key => $value) { |
|
| 374 | 374 | if (is_a($value, 'stdClass')) { |
| 375 | 375 | $ret[$key] = songlist_obj2array($value); |
| 376 | 376 | } elseif (is_array($value)) { |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
| 400 | 400 | |
| 401 | 401 | if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) { |
| 402 | - $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url); |
|
| 403 | - $cookies = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie'; |
|
| 402 | + $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'].'/shorten?login='.$GLOBALS['songlistModuleConfig']['bitly_username'].'&apiKey='.$GLOBALS['songlistModuleConfig']['bitly_apikey'].'&format=json&longUrl='.urlencode($url); |
|
| 403 | + $cookies = XOOPS_ROOT_PATH.'/uploads/songlist_'.md5($GLOBALS['songlistModuleConfig']['bitly_apikey']).'.cookie'; |
|
| 404 | 404 | if (!$ch = curl_init($source_url)) { |
| 405 | 405 | return $url; |
| 406 | 406 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | $attributes_data = []; |
| 479 | 479 | |
| 480 | 480 | if (isset($value)) { |
| 481 | - if ('tag' === $priority) { |
|
| 481 | + if ('tag'===$priority) { |
|
| 482 | 482 | $result = $value; |
| 483 | 483 | } else { |
| 484 | 484 | $result['value'] = $value; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | //Set the attributes too. |
| 489 | 489 | if (isset($attributes) and $get_attributes) { |
| 490 | 490 | foreach ($attributes as $attr => $val) { |
| 491 | - if ('tag' === $priority) { |
|
| 491 | + if ('tag'===$priority) { |
|
| 492 | 492 | $attributes_data[$attr] = $val; |
| 493 | 493 | } else { |
| 494 | 494 | $result['attr'][$attr] = $val; |
@@ -497,67 +497,67 @@ discard block |
||
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | //See tag status and do the needed. |
| 500 | - if ('open' === $type) {//The starting of the tag '<tag>' |
|
| 501 | - $parent[$level - 1] = &$current; |
|
| 500 | + if ('open'===$type) {//The starting of the tag '<tag>' |
|
| 501 | + $parent[$level-1] = &$current; |
|
| 502 | 502 | if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag |
| 503 | 503 | $current[$tag] = $result; |
| 504 | 504 | if ($attributes_data) { |
| 505 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 505 | + $current[$tag.'_attr'] = $attributes_data; |
|
| 506 | 506 | } |
| 507 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 507 | + $repeated_tag_index[$tag.'_'.$level] = 1; |
|
| 508 | 508 | |
| 509 | 509 | $current = &$current[$tag]; |
| 510 | 510 | } else { //There was another element with the same tag name |
| 511 | 511 | if (isset($current[$tag][0])) {//If there is a 0th element it is already an array |
| 512 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 513 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 512 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; |
|
| 513 | + $repeated_tag_index[$tag.'_'.$level]++; |
|
| 514 | 514 | } else {//This section will make the value an array if multiple tags with the same name appear together |
| 515 | 515 | $current[$tag] = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array |
| 516 | - $repeated_tag_index[$tag . '_' . $level] = 2; |
|
| 516 | + $repeated_tag_index[$tag.'_'.$level] = 2; |
|
| 517 | 517 | |
| 518 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 519 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 520 | - unset($current[$tag . '_attr']); |
|
| 518 | + if (isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 519 | + $current[$tag]['0_attr'] = $current[$tag.'_attr']; |
|
| 520 | + unset($current[$tag.'_attr']); |
|
| 521 | 521 | } |
| 522 | 522 | } |
| 523 | - $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; |
|
| 523 | + $last_item_index = $repeated_tag_index[$tag.'_'.$level]-1; |
|
| 524 | 524 | $current = &$current[$tag][$last_item_index]; |
| 525 | 525 | } |
| 526 | - } elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>' |
|
| 526 | + } elseif ('complete'===$type) { //Tags that ends in 1 line '<tag>' |
|
| 527 | 527 | //See if the key is already taken. |
| 528 | 528 | if (isset($current[$tag])) { //If taken, put all things inside a list(array) |
| 529 | 529 | if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... |
| 530 | 530 | // ...push the new element into that array. |
| 531 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; |
|
| 531 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; |
|
| 532 | 532 | |
| 533 | - if ('tag' === $priority and $get_attributes and $attributes_data) { |
|
| 534 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 533 | + if ('tag'===$priority and $get_attributes and $attributes_data) { |
|
| 534 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level].'_attr'] = $attributes_data; |
|
| 535 | 535 | } |
| 536 | - $repeated_tag_index[$tag . '_' . $level]++; |
|
| 536 | + $repeated_tag_index[$tag.'_'.$level]++; |
|
| 537 | 537 | } else { //If it is not an array... |
| 538 | 538 | $current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value |
| 539 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 540 | - if ('tag' === $priority and $get_attributes) { |
|
| 541 | - if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 542 | - $current[$tag]['0_attr'] = $current[$tag . '_attr']; |
|
| 543 | - unset($current[$tag . '_attr']); |
|
| 539 | + $repeated_tag_index[$tag.'_'.$level] = 1; |
|
| 540 | + if ('tag'===$priority and $get_attributes) { |
|
| 541 | + if (isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well |
|
| 542 | + $current[$tag]['0_attr'] = $current[$tag.'_attr']; |
|
| 543 | + unset($current[$tag.'_attr']); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | if ($attributes_data) { |
| 547 | - $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; |
|
| 547 | + $current[$tag][$repeated_tag_index[$tag.'_'.$level].'_attr'] = $attributes_data; |
|
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | - $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken |
|
| 550 | + $repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken |
|
| 551 | 551 | } |
| 552 | 552 | } else { //New Key |
| 553 | 553 | $current[$tag] = $result; |
| 554 | - $repeated_tag_index[$tag . '_' . $level] = 1; |
|
| 555 | - if ('tag' === $priority and $attributes_data) { |
|
| 556 | - $current[$tag . '_attr'] = $attributes_data; |
|
| 554 | + $repeated_tag_index[$tag.'_'.$level] = 1; |
|
| 555 | + if ('tag'===$priority and $attributes_data) { |
|
| 556 | + $current[$tag.'_attr'] = $attributes_data; |
|
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | - } elseif ('close' === $type) { //End of tag '</tag>' |
|
| 560 | - $current = &$parent[$level - 1]; |
|
| 559 | + } elseif ('close'===$type) { //End of tag '</tag>' |
|
| 560 | + $current = &$parent[$level-1]; |
|
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | |
@@ -579,10 +579,10 @@ discard block |
||
| 579 | 579 | $output = ''; |
| 580 | 580 | if ($beginning) { |
| 581 | 581 | if ($standalone) { |
| 582 | - header('content-type:text/xml;charset=' . _CHARSET); |
|
| 582 | + header('content-type:text/xml;charset='._CHARSET); |
|
| 583 | 583 | } |
| 584 | - $output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n"; |
|
| 585 | - $output .= '<' . $name . '>' . "\n"; |
|
| 584 | + $output .= '<'.'?'.'xml version="1.0" encoding="'._CHARSET.'"'.'?'.'>'."\n"; |
|
| 585 | + $output .= '<'.$name.'>'."\n"; |
|
| 586 | 586 | $nested = 0; |
| 587 | 587 | } |
| 588 | 588 | |
@@ -590,26 +590,26 @@ discard block |
||
| 590 | 590 | foreach ($array as $key => $value) { |
| 591 | 591 | ++$nested; |
| 592 | 592 | if (is_array($value)) { |
| 593 | - $output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 593 | + $output .= str_repeat("\t", (int) $nested).'<'.(is_string($key) ? $key : $name.'_'.$key).'>'."\n"; |
|
| 594 | 594 | ++$nested; |
| 595 | 595 | $output .= songlist_toXml($value, $name, false, false, $nested); |
| 596 | 596 | $nested--; |
| 597 | - $output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 598 | - } elseif ('' != $value) { |
|
| 597 | + $output .= str_repeat("\t", (int) $nested).'</'.(is_string($key) ? $key : $name.'_'.$key).'>'."\n"; |
|
| 598 | + } elseif (''!=$value) { |
|
| 599 | 599 | ++$nested; |
| 600 | - $output .= str_repeat("\t", (int)$nested) . ' <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n"; |
|
| 600 | + $output .= str_repeat("\t", (int) $nested).' <'.(is_string($key) ? $key : $name.'_'.$key).'>'.trim($value).'</'.(is_string($key) ? $key : $name.'_'.$key).'>'."\n"; |
|
| 601 | 601 | $nested--; |
| 602 | 602 | } |
| 603 | 603 | $nested--; |
| 604 | 604 | } |
| 605 | - } elseif ('' != $array) { |
|
| 605 | + } elseif (''!=$array) { |
|
| 606 | 606 | ++$nested; |
| 607 | - $output .= str_repeat("\t", (int)$nested) . trim($array) . "\n"; |
|
| 607 | + $output .= str_repeat("\t", (int) $nested).trim($array)."\n"; |
|
| 608 | 608 | $nested--; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | if ($beginning) { |
| 612 | - $output .= '</' . $name . '>'; |
|
| 612 | + $output .= '</'.$name.'>'; |
|
| 613 | 613 | |
| 614 | 614 | return $output; |
| 615 | 615 | } |