@@ -8,14 +8,14 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | function b_songlist_popular_genre_show($options): ?array |
| 10 | 10 | { |
| 11 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | - $handler = Helper::getInstance()->getHandler('Genre'); |
|
| 13 | - $objects = $handler->getTop(1); |
|
| 14 | - if (is_object($objects[0])) { |
|
| 15 | - return $objects[0]->toArray(true); |
|
| 16 | - } |
|
| 11 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | + $handler = Helper::getInstance()->getHandler('Genre'); |
|
| 13 | + $objects = $handler->getTop(1); |
|
| 14 | + if (is_object($objects[0])) { |
|
| 15 | + return $objects[0]->toArray(true); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - return null; |
|
| 18 | + return null; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -8,14 +8,14 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | function b_songlist_popular_song_show($options): ?array |
| 10 | 10 | { |
| 11 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | - $handler = Helper::getInstance()->getHandler('Songs'); |
|
| 13 | - $objects = $handler->getTop(1); |
|
| 14 | - if (is_object($objects[0])) { |
|
| 15 | - return $objects[0]->toArray(true); |
|
| 16 | - } |
|
| 11 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | + $handler = Helper::getInstance()->getHandler('Songs'); |
|
| 13 | + $objects = $handler->getTop(1); |
|
| 14 | + if (is_object($objects[0])) { |
|
| 15 | + return $objects[0]->toArray(true); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - return null; |
|
| 18 | + return null; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -8,19 +8,19 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function b_songlist_popular_genres_show($options): ?array |
| 10 | 10 | { |
| 11 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | - $handler = Helper::getInstance()->getHandler('Genre'); |
|
| 13 | - $objects = $handler->getTop($options[0]); |
|
| 14 | - if (count($objects) > 0) { |
|
| 15 | - $ret = []; |
|
| 16 | - foreach ($objects as $id => $object) { |
|
| 17 | - $ret[$id] = $object->toArray(true); |
|
| 18 | - } |
|
| 11 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | + $handler = Helper::getInstance()->getHandler('Genre'); |
|
| 13 | + $objects = $handler->getTop($options[0]); |
|
| 14 | + if (count($objects) > 0) { |
|
| 15 | + $ret = []; |
|
| 16 | + foreach ($objects as $id => $object) { |
|
| 17 | + $ret[$id] = $object->toArray(true); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - return $ret; |
|
| 21 | - } |
|
| 20 | + return $ret; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - return null; |
|
| 23 | + return null; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function b_songlist_popular_genres_edit($options): string |
| 31 | 31 | { |
| 32 | - xoops_load('XoopsFormLoader'); |
|
| 33 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 34 | - $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
|
| 32 | + xoops_load('XoopsFormLoader'); |
|
| 33 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 34 | + $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
|
| 35 | 35 | |
| 36 | - return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 36 | + return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 37 | 37 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | xoops_loadLanguage('blocks', 'songlist'); |
| 12 | 12 | $handler = Helper::getInstance()->getHandler('Genre'); |
| 13 | 13 | $objects = $handler->getTop($options[0]); |
| 14 | - if (count($objects) > 0) { |
|
| 14 | + if (count($objects)>0) { |
|
| 15 | 15 | $ret = []; |
| 16 | 16 | foreach ($objects as $id => $object) { |
| 17 | 17 | $ret[$id] = $object->toArray(true); |
@@ -33,5 +33,5 @@ discard block |
||
| 33 | 33 | xoops_loadLanguage('blocks', 'songlist'); |
| 34 | 34 | $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
| 35 | 35 | |
| 36 | - return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 36 | + return _BL_SONGLIST_NUMBEROFITEMS.$num->render(); |
|
| 37 | 37 | } |
@@ -8,14 +8,14 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | function b_songlist_popular_album_show($options): ?array |
| 10 | 10 | { |
| 11 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | - $handler = Helper::getInstance()->getHandler('Albums'); |
|
| 13 | - $objects = $handler->getTop(1); |
|
| 14 | - if (is_object($objects[0])) { |
|
| 15 | - return $objects[0]->toArray(true); |
|
| 16 | - } |
|
| 11 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | + $handler = Helper::getInstance()->getHandler('Albums'); |
|
| 13 | + $objects = $handler->getTop(1); |
|
| 14 | + if (is_object($objects[0])) { |
|
| 15 | + return $objects[0]->toArray(true); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - return null; |
|
| 18 | + return null; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -8,19 +8,19 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function b_songlist_popular_songs_show($options): ?array |
| 10 | 10 | { |
| 11 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | - $handler = Helper::getInstance()->getHandler('Songs'); |
|
| 13 | - $objects = $handler->getTop($options[0]); |
|
| 14 | - if (count($objects) > 0) { |
|
| 15 | - $ret = []; |
|
| 16 | - foreach ($objects as $id => $object) { |
|
| 17 | - $ret[$id] = $object->toArray(true); |
|
| 18 | - } |
|
| 11 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | + $handler = Helper::getInstance()->getHandler('Songs'); |
|
| 13 | + $objects = $handler->getTop($options[0]); |
|
| 14 | + if (count($objects) > 0) { |
|
| 15 | + $ret = []; |
|
| 16 | + foreach ($objects as $id => $object) { |
|
| 17 | + $ret[$id] = $object->toArray(true); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - return $ret; |
|
| 21 | - } |
|
| 20 | + return $ret; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - return null; |
|
| 23 | + return null; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function b_songlist_popular_songs_edit($options): string |
| 31 | 31 | { |
| 32 | - xoops_load('XoopsFormLoader'); |
|
| 33 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 34 | - $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
|
| 32 | + xoops_load('XoopsFormLoader'); |
|
| 33 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 34 | + $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
|
| 35 | 35 | |
| 36 | - return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 36 | + return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 37 | 37 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | xoops_loadLanguage('blocks', 'songlist'); |
| 12 | 12 | $handler = Helper::getInstance()->getHandler('Songs'); |
| 13 | 13 | $objects = $handler->getTop($options[0]); |
| 14 | - if (count($objects) > 0) { |
|
| 14 | + if (count($objects)>0) { |
|
| 15 | 15 | $ret = []; |
| 16 | 16 | foreach ($objects as $id => $object) { |
| 17 | 17 | $ret[$id] = $object->toArray(true); |
@@ -33,5 +33,5 @@ discard block |
||
| 33 | 33 | xoops_loadLanguage('blocks', 'songlist'); |
| 34 | 34 | $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
| 35 | 35 | |
| 36 | - return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 36 | + return _BL_SONGLIST_NUMBEROFITEMS.$num->render(); |
|
| 37 | 37 | } |
@@ -8,19 +8,19 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function b_songlist_popular_artists_show($options): ?array |
| 10 | 10 | { |
| 11 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | - $handler = Helper::getInstance()->getHandler('Artists'); |
|
| 13 | - $objects = $handler->getTop($options[0]); |
|
| 14 | - if (count($objects) > 0) { |
|
| 15 | - $ret = []; |
|
| 16 | - foreach ($objects as $id => $object) { |
|
| 17 | - $ret[$id] = $object->toArray(true); //TODO mb why do we need toArray()? |
|
| 18 | - } |
|
| 11 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 12 | + $handler = Helper::getInstance()->getHandler('Artists'); |
|
| 13 | + $objects = $handler->getTop($options[0]); |
|
| 14 | + if (count($objects) > 0) { |
|
| 15 | + $ret = []; |
|
| 16 | + foreach ($objects as $id => $object) { |
|
| 17 | + $ret[$id] = $object->toArray(true); //TODO mb why do we need toArray()? |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - return $ret; |
|
| 21 | - } |
|
| 20 | + return $ret; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - return null; |
|
| 23 | + return null; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function b_songlist_popular_artists_edit($options): string |
| 31 | 31 | { |
| 32 | - xoops_load('XoopsFormLoader'); |
|
| 33 | - xoops_loadLanguage('blocks', 'songlist'); |
|
| 34 | - $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
|
| 32 | + xoops_load('XoopsFormLoader'); |
|
| 33 | + xoops_loadLanguage('blocks', 'songlist'); |
|
| 34 | + $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
|
| 35 | 35 | |
| 36 | - return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 36 | + return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 37 | 37 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | xoops_loadLanguage('blocks', 'songlist'); |
| 12 | 12 | $handler = Helper::getInstance()->getHandler('Artists'); |
| 13 | 13 | $objects = $handler->getTop($options[0]); |
| 14 | - if (count($objects) > 0) { |
|
| 14 | + if (count($objects)>0) { |
|
| 15 | 15 | $ret = []; |
| 16 | 16 | foreach ($objects as $id => $object) { |
| 17 | 17 | $ret[$id] = $object->toArray(true); //TODO mb why do we need toArray()? |
@@ -33,5 +33,5 @@ discard block |
||
| 33 | 33 | xoops_loadLanguage('blocks', 'songlist'); |
| 34 | 34 | $num = new \XoopsformText('', 'options[0]', 10, 10, $options[0]); |
| 35 | 35 | |
| 36 | - return _BL_SONGLIST_NUMBEROFITEMS . $num->render(); |
|
| 36 | + return _BL_SONGLIST_NUMBEROFITEMS.$num->render(); |
|
| 37 | 37 | } |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | $criteria_cat = new \CriteriaCompo(); |
| 14 | 14 | $cids = $categoryHandler->GetCatAndSubCat($_SESSION['cid']); |
| 15 | 15 | if ($_SESSION['cid'] > 0) { |
| 16 | - $cids[$_SESSION['cid']] = $_SESSION['cid']; |
|
| 16 | + $cids[$_SESSION['cid']] = $_SESSION['cid']; |
|
| 17 | 17 | } |
| 18 | 18 | if (count($cids) > 0 && 0 != $_SESSION['cid']) { |
| 19 | - foreach ($cids as $cid) { |
|
| 20 | - $criteria_cat->add(new \Criteria('`cids`', '%"' . $cid . '"%', 'LIKE'), 'OR'); |
|
| 21 | - } |
|
| 19 | + foreach ($cids as $cid) { |
|
| 20 | + $criteria_cat->add(new \Criteria('`cids`', '%"' . $cid . '"%', 'LIKE'), 'OR'); |
|
| 21 | + } |
|
| 22 | 22 | } else { |
| 23 | - $criteria_cat->add(new \Criteria(''), 'OR'); |
|
| 23 | + $criteria_cat->add(new \Criteria(''), 'OR'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $criteria_cat->setSort('created'); |
@@ -35,197 +35,197 @@ discard block |
||
| 35 | 35 | $col = 1; |
| 36 | 36 | $row = 1; |
| 37 | 37 | foreach ($categories as $category) { |
| 38 | - $cat[$row][$col] = $category->toArray(true); |
|
| 39 | - $cat[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 40 | - ++$col; |
|
| 41 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 42 | - ++$row; |
|
| 43 | - $col = 1; |
|
| 44 | - } |
|
| 38 | + $cat[$row][$col] = $category->toArray(true); |
|
| 39 | + $cat[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 40 | + ++$col; |
|
| 41 | + if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 42 | + ++$row; |
|
| 43 | + $col = 1; |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | if (1 != $col) { |
| 47 | - $col--; |
|
| 48 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 49 | - $cat[$row][$j][$categoryHandler->keyName] = 0; |
|
| 50 | - $cat[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 51 | - } |
|
| 47 | + $col--; |
|
| 48 | + for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 49 | + $cat[$row][$j][$categoryHandler->keyName] = 0; |
|
| 50 | + $cat[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** @var ArtistsHandler $artistsHandler */ |
| 55 | 55 | $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
| 56 | 56 | switch ((string)$GLOBALS['op']) { |
| 57 | - default: |
|
| 58 | - case 'item': |
|
| 59 | - switch ($fct) { |
|
| 60 | - default: |
|
| 61 | - case 'list': |
|
| 62 | - $pagenav = new \XoopsPageNav($artistsHandler->getCount($criteria_cat), $limit, $start, 'start', "op=$op&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 63 | - |
|
| 64 | - $criteria_cat->setLimit($limit); |
|
| 65 | - $criteria_cat->setStart($start); |
|
| 66 | - |
|
| 67 | - $artists = $artistsHandler->getObjects($criteria_cat, false); |
|
| 68 | - |
|
| 69 | - $ret = []; |
|
| 70 | - $col = 1; |
|
| 71 | - $row = 1; |
|
| 72 | - foreach ($artists as $artist) { |
|
| 73 | - $ret[$row][$col] = $artist->toArray(true); |
|
| 74 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 75 | - ++$col; |
|
| 76 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 77 | - ++$row; |
|
| 78 | - $col = 1; |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - if (1 != $col) { |
|
| 82 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 83 | - $ret[$row][$j][$artistsHandler->keyName] = 0; |
|
| 84 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $url = $artistsHandler->getURL(false); |
|
| 89 | - if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 90 | - header('HTTP/1.1 301 Moved Permanently'); |
|
| 91 | - header('Location: ' . $url); |
|
| 92 | - exit(0); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_index.tpl'; |
|
| 96 | - require $GLOBALS['xoops']->path('/header.php'); |
|
| 97 | - if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 98 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 99 | - $GLOBALS['loaded_jquery'] = true; |
|
| 100 | - } |
|
| 101 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 102 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 103 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 104 | - $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 105 | - $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 106 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 107 | - $GLOBALS['xoopsTpl']->assign('cid', $_SESSION['cid']); |
|
| 108 | - if (0 != $_SESSION['cid']) { |
|
| 109 | - $category = $categoryHandler->get($_SESSION['cid']); |
|
| 110 | - $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 111 | - } |
|
| 112 | - $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 113 | - require $GLOBALS['xoops']->path('/footer.php'); |
|
| 114 | - break; |
|
| 115 | - case 'item': |
|
| 116 | - $artist = $artistsHandler->get($id); |
|
| 117 | - |
|
| 118 | - $url = $artist->getURL(true); |
|
| 119 | - if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 120 | - header('HTTP/1.1 301 Moved Permanently'); |
|
| 121 | - header('Location: ' . $url); |
|
| 122 | - exit(0); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_item.tpl'; |
|
| 126 | - require $GLOBALS['xoops']->path('/header.php'); |
|
| 127 | - if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 128 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 129 | - $GLOBALS['loaded_jquery'] = true; |
|
| 130 | - } |
|
| 131 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 132 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 133 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 134 | - $GLOBALS['xoopsTpl']->assign('songs', false); |
|
| 135 | - $GLOBALS['xoopsTpl']->assign('artist', $artist->toArray(true)); |
|
| 136 | - $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 137 | - $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 138 | - require $GLOBALS['xoops']->path('/footer.php'); |
|
| 139 | - break; |
|
| 140 | - } |
|
| 141 | - break; |
|
| 142 | - case 'browseby': |
|
| 143 | - switch ($fct) { |
|
| 144 | - default: |
|
| 145 | - case 'title': |
|
| 146 | - case 'lyrics': |
|
| 147 | - case 'artist': |
|
| 148 | - case 'album': |
|
| 149 | - $browse_criteria = new \CriteriaCompo(); |
|
| 150 | - switch ($value) { |
|
| 151 | - case '0': |
|
| 152 | - for ($u = 0; $u < 10; ++$u) { |
|
| 153 | - $browse_criteria->add(new \Criteria('name', $u . '%', 'LIKE'), 'OR'); |
|
| 154 | - } |
|
| 155 | - break; |
|
| 156 | - default: |
|
| 157 | - $browse_criteria->add(new \Criteria('name', \mb_strtoupper($value) . '%', 'LIKE'), 'OR'); |
|
| 158 | - $browse_criteria->add(new \Criteria('name', \mb_strtolower($value) . '%', 'LIKE'), 'OR'); |
|
| 159 | - break; |
|
| 160 | - } |
|
| 161 | - $criteria = new \CriteriaCompo($criteria_cat, 'AND'); |
|
| 162 | - $criteria->add($browse_criteria); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $pagenav = new \XoopsPageNav($artistsHandler->getCount($criteria), $limit, $start, 'start', "op={$GLOBALS['op']}&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 166 | - |
|
| 167 | - $criteria->setLimit($limit); |
|
| 168 | - $criteria->setStart($start); |
|
| 169 | - |
|
| 170 | - $artists = $artistsHandler->getObjects($criteria, false); |
|
| 171 | - |
|
| 172 | - $ret = []; |
|
| 173 | - $col = 1; |
|
| 174 | - $row = 1; |
|
| 175 | - foreach ($artists as $artist) { |
|
| 176 | - $ret[$row][$col] = $artist->toArray(true); |
|
| 177 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 178 | - ++$col; |
|
| 179 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 180 | - ++$row; |
|
| 181 | - $col = 1; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - if (1 != $col) { |
|
| 185 | - $col--; |
|
| 186 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 187 | - $ret[$row][$j][$artistsHandler->keyName] = 0; |
|
| 188 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - $url = $artistsHandler->getURL(false); |
|
| 193 | - if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 194 | - header('HTTP/1.1 301 Moved Permanently'); |
|
| 195 | - header('Location: ' . $url); |
|
| 196 | - exit(0); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_index.tpl'; |
|
| 200 | - require $GLOBALS['xoops']->path('/header.php'); |
|
| 201 | - if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 202 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 203 | - $GLOBALS['loaded_jquery'] = true; |
|
| 204 | - } |
|
| 205 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 206 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 207 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 208 | - $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 209 | - $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 210 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 211 | - $GLOBALS['xoopsTpl']->assign('cid', $_SESSION['cid']); |
|
| 212 | - if (0 != $_SESSION['cid']) { |
|
| 213 | - $category = $categoryHandler->get($_SESSION['cid']); |
|
| 214 | - $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 215 | - } |
|
| 216 | - $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 217 | - require $GLOBALS['xoops']->path('/footer.php'); |
|
| 218 | - |
|
| 219 | - break; |
|
| 220 | - case 'category': |
|
| 221 | - switch ($fct) { |
|
| 222 | - default: |
|
| 223 | - case 'set': |
|
| 224 | - $_SESSION['cid'] = $id; |
|
| 225 | - break; |
|
| 226 | - case 'home': |
|
| 227 | - unset($_SESSION['cid']); |
|
| 228 | - break; |
|
| 229 | - } |
|
| 230 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=0&value=%&start=0&limit=$limit&cid=" . $_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 57 | + default: |
|
| 58 | + case 'item': |
|
| 59 | + switch ($fct) { |
|
| 60 | + default: |
|
| 61 | + case 'list': |
|
| 62 | + $pagenav = new \XoopsPageNav($artistsHandler->getCount($criteria_cat), $limit, $start, 'start', "op=$op&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 63 | + |
|
| 64 | + $criteria_cat->setLimit($limit); |
|
| 65 | + $criteria_cat->setStart($start); |
|
| 66 | + |
|
| 67 | + $artists = $artistsHandler->getObjects($criteria_cat, false); |
|
| 68 | + |
|
| 69 | + $ret = []; |
|
| 70 | + $col = 1; |
|
| 71 | + $row = 1; |
|
| 72 | + foreach ($artists as $artist) { |
|
| 73 | + $ret[$row][$col] = $artist->toArray(true); |
|
| 74 | + $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 75 | + ++$col; |
|
| 76 | + if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 77 | + ++$row; |
|
| 78 | + $col = 1; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + if (1 != $col) { |
|
| 82 | + for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 83 | + $ret[$row][$j][$artistsHandler->keyName] = 0; |
|
| 84 | + $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $url = $artistsHandler->getURL(false); |
|
| 89 | + if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 90 | + header('HTTP/1.1 301 Moved Permanently'); |
|
| 91 | + header('Location: ' . $url); |
|
| 92 | + exit(0); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_index.tpl'; |
|
| 96 | + require $GLOBALS['xoops']->path('/header.php'); |
|
| 97 | + if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 98 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 99 | + $GLOBALS['loaded_jquery'] = true; |
|
| 100 | + } |
|
| 101 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 102 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 103 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 104 | + $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 105 | + $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 106 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 107 | + $GLOBALS['xoopsTpl']->assign('cid', $_SESSION['cid']); |
|
| 108 | + if (0 != $_SESSION['cid']) { |
|
| 109 | + $category = $categoryHandler->get($_SESSION['cid']); |
|
| 110 | + $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 111 | + } |
|
| 112 | + $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 113 | + require $GLOBALS['xoops']->path('/footer.php'); |
|
| 114 | + break; |
|
| 115 | + case 'item': |
|
| 116 | + $artist = $artistsHandler->get($id); |
|
| 117 | + |
|
| 118 | + $url = $artist->getURL(true); |
|
| 119 | + if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 120 | + header('HTTP/1.1 301 Moved Permanently'); |
|
| 121 | + header('Location: ' . $url); |
|
| 122 | + exit(0); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_item.tpl'; |
|
| 126 | + require $GLOBALS['xoops']->path('/header.php'); |
|
| 127 | + if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 128 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 129 | + $GLOBALS['loaded_jquery'] = true; |
|
| 130 | + } |
|
| 131 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 132 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 133 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 134 | + $GLOBALS['xoopsTpl']->assign('songs', false); |
|
| 135 | + $GLOBALS['xoopsTpl']->assign('artist', $artist->toArray(true)); |
|
| 136 | + $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 137 | + $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 138 | + require $GLOBALS['xoops']->path('/footer.php'); |
|
| 139 | + break; |
|
| 140 | + } |
|
| 141 | + break; |
|
| 142 | + case 'browseby': |
|
| 143 | + switch ($fct) { |
|
| 144 | + default: |
|
| 145 | + case 'title': |
|
| 146 | + case 'lyrics': |
|
| 147 | + case 'artist': |
|
| 148 | + case 'album': |
|
| 149 | + $browse_criteria = new \CriteriaCompo(); |
|
| 150 | + switch ($value) { |
|
| 151 | + case '0': |
|
| 152 | + for ($u = 0; $u < 10; ++$u) { |
|
| 153 | + $browse_criteria->add(new \Criteria('name', $u . '%', 'LIKE'), 'OR'); |
|
| 154 | + } |
|
| 155 | + break; |
|
| 156 | + default: |
|
| 157 | + $browse_criteria->add(new \Criteria('name', \mb_strtoupper($value) . '%', 'LIKE'), 'OR'); |
|
| 158 | + $browse_criteria->add(new \Criteria('name', \mb_strtolower($value) . '%', 'LIKE'), 'OR'); |
|
| 159 | + break; |
|
| 160 | + } |
|
| 161 | + $criteria = new \CriteriaCompo($criteria_cat, 'AND'); |
|
| 162 | + $criteria->add($browse_criteria); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $pagenav = new \XoopsPageNav($artistsHandler->getCount($criteria), $limit, $start, 'start', "op={$GLOBALS['op']}&fct=$fct&id=$id&value=$value&limit=$limit"); |
|
| 166 | + |
|
| 167 | + $criteria->setLimit($limit); |
|
| 168 | + $criteria->setStart($start); |
|
| 169 | + |
|
| 170 | + $artists = $artistsHandler->getObjects($criteria, false); |
|
| 171 | + |
|
| 172 | + $ret = []; |
|
| 173 | + $col = 1; |
|
| 174 | + $row = 1; |
|
| 175 | + foreach ($artists as $artist) { |
|
| 176 | + $ret[$row][$col] = $artist->toArray(true); |
|
| 177 | + $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 178 | + ++$col; |
|
| 179 | + if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 180 | + ++$row; |
|
| 181 | + $col = 1; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + if (1 != $col) { |
|
| 185 | + $col--; |
|
| 186 | + for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 187 | + $ret[$row][$j][$artistsHandler->keyName] = 0; |
|
| 188 | + $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + $url = $artistsHandler->getURL(false); |
|
| 193 | + if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
|
| 194 | + header('HTTP/1.1 301 Moved Permanently'); |
|
| 195 | + header('Location: ' . $url); |
|
| 196 | + exit(0); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_index.tpl'; |
|
| 200 | + require $GLOBALS['xoops']->path('/header.php'); |
|
| 201 | + if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
|
| 202 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 203 | + $GLOBALS['loaded_jquery'] = true; |
|
| 204 | + } |
|
| 205 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 206 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 207 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 208 | + $GLOBALS['xoopsTpl']->assign('results', $ret); |
|
| 209 | + $GLOBALS['xoopsTpl']->assign('categories', $cat); |
|
| 210 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 211 | + $GLOBALS['xoopsTpl']->assign('cid', $_SESSION['cid']); |
|
| 212 | + if (0 != $_SESSION['cid']) { |
|
| 213 | + $category = $categoryHandler->get($_SESSION['cid']); |
|
| 214 | + $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
|
| 215 | + } |
|
| 216 | + $GLOBALS['xoopsTpl']->assign('uri', $_SERVER['REQUEST_URI']); |
|
| 217 | + require $GLOBALS['xoops']->path('/footer.php'); |
|
| 218 | + |
|
| 219 | + break; |
|
| 220 | + case 'category': |
|
| 221 | + switch ($fct) { |
|
| 222 | + default: |
|
| 223 | + case 'set': |
|
| 224 | + $_SESSION['cid'] = $id; |
|
| 225 | + break; |
|
| 226 | + case 'home': |
|
| 227 | + unset($_SESSION['cid']); |
|
| 228 | + break; |
|
| 229 | + } |
|
| 230 | + redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=0&value=%&start=0&limit=$limit&cid=" . $_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 231 | 231 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | use XoopsModules\Songlist\CategoryHandler; |
| 5 | 5 | use XoopsModules\Songlist\ArtistsHandler; |
| 6 | 6 | |
| 7 | -require_once __DIR__ . '/header.php'; |
|
| 7 | +require_once __DIR__.'/header.php'; |
|
| 8 | 8 | |
| 9 | 9 | global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit; |
| 10 | 10 | |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
| 13 | 13 | $criteria_cat = new \CriteriaCompo(); |
| 14 | 14 | $cids = $categoryHandler->GetCatAndSubCat($_SESSION['cid']); |
| 15 | -if ($_SESSION['cid'] > 0) { |
|
| 15 | +if ($_SESSION['cid']>0) { |
|
| 16 | 16 | $cids[$_SESSION['cid']] = $_SESSION['cid']; |
| 17 | 17 | } |
| 18 | -if (count($cids) > 0 && 0 != $_SESSION['cid']) { |
|
| 18 | +if (count($cids)>0 && 0!=$_SESSION['cid']) { |
|
| 19 | 19 | foreach ($cids as $cid) { |
| 20 | - $criteria_cat->add(new \Criteria('`cids`', '%"' . $cid . '"%', 'LIKE'), 'OR'); |
|
| 20 | + $criteria_cat->add(new \Criteria('`cids`', '%"'.$cid.'"%', 'LIKE'), 'OR'); |
|
| 21 | 21 | } |
| 22 | 22 | } else { |
| 23 | 23 | $criteria_cat->add(new \Criteria(''), 'OR'); |
@@ -36,24 +36,24 @@ discard block |
||
| 36 | 36 | $row = 1; |
| 37 | 37 | foreach ($categories as $category) { |
| 38 | 38 | $cat[$row][$col] = $category->toArray(true); |
| 39 | - $cat[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 39 | + $cat[$row][$col]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 40 | 40 | ++$col; |
| 41 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 41 | + if ($col>$GLOBALS['songlistModuleConfig']['cols']) { |
|
| 42 | 42 | ++$row; |
| 43 | 43 | $col = 1; |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | -if (1 != $col) { |
|
| 46 | +if (1!=$col) { |
|
| 47 | 47 | $col--; |
| 48 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 48 | + for ($j = $col; $j<=$GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 49 | 49 | $cat[$row][$j][$categoryHandler->keyName] = 0; |
| 50 | - $cat[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 50 | + $cat[$row][$j]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** @var ArtistsHandler $artistsHandler */ |
| 55 | 55 | $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
| 56 | -switch ((string)$GLOBALS['op']) { |
|
| 56 | +switch ((string) $GLOBALS['op']) { |
|
| 57 | 57 | default: |
| 58 | 58 | case 'item': |
| 59 | 59 | switch ($fct) { |
@@ -71,41 +71,41 @@ discard block |
||
| 71 | 71 | $row = 1; |
| 72 | 72 | foreach ($artists as $artist) { |
| 73 | 73 | $ret[$row][$col] = $artist->toArray(true); |
| 74 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 74 | + $ret[$row][$col]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 75 | 75 | ++$col; |
| 76 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 76 | + if ($col>$GLOBALS['songlistModuleConfig']['cols']) { |
|
| 77 | 77 | ++$row; |
| 78 | 78 | $col = 1; |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - if (1 != $col) { |
|
| 82 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 81 | + if (1!=$col) { |
|
| 82 | + for ($j = $col; $j<=$GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 83 | 83 | $ret[$row][$j][$artistsHandler->keyName] = 0; |
| 84 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 84 | + $ret[$row][$j]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $url = $artistsHandler->getURL(false); |
| 89 | 89 | if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
| 90 | 90 | header('HTTP/1.1 301 Moved Permanently'); |
| 91 | - header('Location: ' . $url); |
|
| 91 | + header('Location: '.$url); |
|
| 92 | 92 | exit(0); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_index.tpl'; |
| 96 | 96 | require $GLOBALS['xoops']->path('/header.php'); |
| 97 | 97 | if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
| 98 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 98 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 99 | 99 | $GLOBALS['loaded_jquery'] = true; |
| 100 | 100 | } |
| 101 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 101 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 102 | 102 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
| 103 | 103 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
| 104 | 104 | $GLOBALS['xoopsTpl']->assign('results', $ret); |
| 105 | 105 | $GLOBALS['xoopsTpl']->assign('categories', $cat); |
| 106 | 106 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 107 | 107 | $GLOBALS['xoopsTpl']->assign('cid', $_SESSION['cid']); |
| 108 | - if (0 != $_SESSION['cid']) { |
|
| 108 | + if (0!=$_SESSION['cid']) { |
|
| 109 | 109 | $category = $categoryHandler->get($_SESSION['cid']); |
| 110 | 110 | $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
| 111 | 111 | } |
@@ -118,17 +118,17 @@ discard block |
||
| 118 | 118 | $url = $artist->getURL(true); |
| 119 | 119 | if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
| 120 | 120 | header('HTTP/1.1 301 Moved Permanently'); |
| 121 | - header('Location: ' . $url); |
|
| 121 | + header('Location: '.$url); |
|
| 122 | 122 | exit(0); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_item.tpl'; |
| 126 | 126 | require $GLOBALS['xoops']->path('/header.php'); |
| 127 | 127 | if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
| 128 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 128 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 129 | 129 | $GLOBALS['loaded_jquery'] = true; |
| 130 | 130 | } |
| 131 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 131 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 132 | 132 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
| 133 | 133 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
| 134 | 134 | $GLOBALS['xoopsTpl']->assign('songs', false); |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | $browse_criteria = new \CriteriaCompo(); |
| 150 | 150 | switch ($value) { |
| 151 | 151 | case '0': |
| 152 | - for ($u = 0; $u < 10; ++$u) { |
|
| 153 | - $browse_criteria->add(new \Criteria('name', $u . '%', 'LIKE'), 'OR'); |
|
| 152 | + for ($u = 0; $u<10; ++$u) { |
|
| 153 | + $browse_criteria->add(new \Criteria('name', $u.'%', 'LIKE'), 'OR'); |
|
| 154 | 154 | } |
| 155 | 155 | break; |
| 156 | 156 | default: |
| 157 | - $browse_criteria->add(new \Criteria('name', \mb_strtoupper($value) . '%', 'LIKE'), 'OR'); |
|
| 158 | - $browse_criteria->add(new \Criteria('name', \mb_strtolower($value) . '%', 'LIKE'), 'OR'); |
|
| 157 | + $browse_criteria->add(new \Criteria('name', \mb_strtoupper($value).'%', 'LIKE'), 'OR'); |
|
| 158 | + $browse_criteria->add(new \Criteria('name', \mb_strtolower($value).'%', 'LIKE'), 'OR'); |
|
| 159 | 159 | break; |
| 160 | 160 | } |
| 161 | 161 | $criteria = new \CriteriaCompo($criteria_cat, 'AND'); |
@@ -174,42 +174,42 @@ discard block |
||
| 174 | 174 | $row = 1; |
| 175 | 175 | foreach ($artists as $artist) { |
| 176 | 176 | $ret[$row][$col] = $artist->toArray(true); |
| 177 | - $ret[$row][$col]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 177 | + $ret[$row][$col]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 178 | 178 | ++$col; |
| 179 | - if ($col > $GLOBALS['songlistModuleConfig']['cols']) { |
|
| 179 | + if ($col>$GLOBALS['songlistModuleConfig']['cols']) { |
|
| 180 | 180 | ++$row; |
| 181 | 181 | $col = 1; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | - if (1 != $col) { |
|
| 184 | + if (1!=$col) { |
|
| 185 | 185 | $col--; |
| 186 | - for ($j = $col; $j <= $GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 186 | + for ($j = $col; $j<=$GLOBALS['songlistModuleConfig']['cols']; ++$j) { |
|
| 187 | 187 | $ret[$row][$j][$artistsHandler->keyName] = 0; |
| 188 | - $ret[$row][$j]['width'] = floor(100 / $GLOBALS['songlistModuleConfig']['cols']) . '%'; |
|
| 188 | + $ret[$row][$j]['width'] = floor(100/$GLOBALS['songlistModuleConfig']['cols']).'%'; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $url = $artistsHandler->getURL(false); |
| 193 | 193 | if (!mb_strpos($url, $_SERVER['REQUEST_URI'])) { |
| 194 | 194 | header('HTTP/1.1 301 Moved Permanently'); |
| 195 | - header('Location: ' . $url); |
|
| 195 | + header('Location: '.$url); |
|
| 196 | 196 | exit(0); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $GLOBALS['xoopsOption']['template_main'] = 'songlist_artists_index.tpl'; |
| 200 | 200 | require $GLOBALS['xoops']->path('/header.php'); |
| 201 | 201 | if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) { |
| 202 | - $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 202 | + $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']); |
|
| 203 | 203 | $GLOBALS['loaded_jquery'] = true; |
| 204 | 204 | } |
| 205 | - $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 205 | + $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']); |
|
| 206 | 206 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
| 207 | 207 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
| 208 | 208 | $GLOBALS['xoopsTpl']->assign('results', $ret); |
| 209 | 209 | $GLOBALS['xoopsTpl']->assign('categories', $cat); |
| 210 | 210 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 211 | 211 | $GLOBALS['xoopsTpl']->assign('cid', $_SESSION['cid']); |
| 212 | - if (0 != $_SESSION['cid']) { |
|
| 212 | + if (0!=$_SESSION['cid']) { |
|
| 213 | 213 | $category = $categoryHandler->get($_SESSION['cid']); |
| 214 | 214 | $GLOBALS['xoopsTpl']->assign('category', $category->toArray(true)); |
| 215 | 215 | } |
@@ -227,5 +227,5 @@ discard block |
||
| 227 | 227 | unset($_SESSION['cid']); |
| 228 | 228 | break; |
| 229 | 229 | } |
| 230 | - redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=0&value=%&start=0&limit=$limit&cid=" . $_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 230 | + redirect_header($_SERVER['SCRIPT_NAME']."?op=item&fct=list&id=0&value=%&start=0&limit=$limit&cid=".$_SESSION['cid'], 10, _MD_SONGLIST_MSG_CATEGORYCHANGED); |
|
| 231 | 231 | } |
@@ -23,101 +23,101 @@ discard block |
||
| 23 | 23 | $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
| 24 | 24 | |
| 25 | 25 | switch ($op) { |
| 26 | - default: |
|
| 27 | - case 'songs': |
|
| 28 | - switch ($fct) { |
|
| 29 | - default: |
|
| 30 | - case 'list': |
|
| 31 | - $adminObject = Admin::getInstance(); |
|
| 32 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 26 | + default: |
|
| 27 | + case 'songs': |
|
| 28 | + switch ($fct) { |
|
| 29 | + default: |
|
| 30 | + case 'list': |
|
| 31 | + $adminObject = Admin::getInstance(); |
|
| 32 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 33 | 33 | |
| 34 | - /** @var SongsHandler $songsHandler */ |
|
| 35 | - $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 34 | + /** @var SongsHandler $songsHandler */ |
|
| 35 | + $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 36 | 36 | |
| 37 | - $criteria = $songsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 38 | - $ttl = $songsHandler->getCount($criteria); |
|
| 39 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 37 | + $criteria = $songsHandler->getFilterCriteria($GLOBALS['filter']); |
|
| 38 | + $ttl = $songsHandler->getCount($criteria); |
|
| 39 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 40 | 40 | |
| 41 | - $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']); |
|
| 42 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 41 | + $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']); |
|
| 42 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
| 43 | 43 | |
| 44 | - foreach ($songsHandler->filterFields() as $id => $key) { |
|
| 45 | - $GLOBALS['xoopsTpl']->assign( |
|
| 46 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 47 | - '<a href="' |
|
| 48 | - . $_SERVER['SCRIPT_NAME'] |
|
| 49 | - . '?start=' |
|
| 50 | - . $GLOBALS['start'] |
|
| 51 | - . '&limit=' |
|
| 52 | - . $GLOBALS['limit'] |
|
| 53 | - . '&sort=' |
|
| 54 | - . $key |
|
| 55 | - . '&order=' |
|
| 56 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 57 | - . '&op=' |
|
| 58 | - . $GLOBALS['op'] |
|
| 59 | - . '&filter=' |
|
| 60 | - . $GLOBALS['filter'] |
|
| 61 | - . '">' |
|
| 62 | - . (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))) |
|
| 63 | - . '</a>' |
|
| 64 | - ); |
|
| 65 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $songsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 66 | - } |
|
| 44 | + foreach ($songsHandler->filterFields() as $id => $key) { |
|
| 45 | + $GLOBALS['xoopsTpl']->assign( |
|
| 46 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 47 | + '<a href="' |
|
| 48 | + . $_SERVER['SCRIPT_NAME'] |
|
| 49 | + . '?start=' |
|
| 50 | + . $GLOBALS['start'] |
|
| 51 | + . '&limit=' |
|
| 52 | + . $GLOBALS['limit'] |
|
| 53 | + . '&sort=' |
|
| 54 | + . $key |
|
| 55 | + . '&order=' |
|
| 56 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 57 | + . '&op=' |
|
| 58 | + . $GLOBALS['op'] |
|
| 59 | + . '&filter=' |
|
| 60 | + . $GLOBALS['filter'] |
|
| 61 | + . '">' |
|
| 62 | + . (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))) |
|
| 63 | + . '</a>' |
|
| 64 | + ); |
|
| 65 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $songsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 70 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 71 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 72 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 73 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 68 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
| 70 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
| 71 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
| 72 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
| 73 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
| 74 | 74 | |
| 75 | - $criteria->setStart($GLOBALS['start']); |
|
| 76 | - $criteria->setLimit($GLOBALS['limit']); |
|
| 77 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 78 | - $criteria->setOrder($GLOBALS['order']); |
|
| 75 | + $criteria->setStart($GLOBALS['start']); |
|
| 76 | + $criteria->setLimit($GLOBALS['limit']); |
|
| 77 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 78 | + $criteria->setOrder($GLOBALS['order']); |
|
| 79 | 79 | |
| 80 | - $songss = $songsHandler->getObjects($criteria, true); |
|
| 81 | - foreach ($songss as $cid => $songs) { |
|
| 82 | - if (is_object($songs)) { |
|
| 83 | - $GLOBALS['xoopsTpl']->append('songs', $songs->toArray()); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormSongs(false)); |
|
| 87 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 88 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_songs_list.tpl'); |
|
| 89 | - break; |
|
| 90 | - case 'new': |
|
| 91 | - case 'edit': |
|
| 92 | - $adminObject = Admin::getInstance(); |
|
| 93 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 80 | + $songss = $songsHandler->getObjects($criteria, true); |
|
| 81 | + foreach ($songss as $cid => $songs) { |
|
| 82 | + if (is_object($songs)) { |
|
| 83 | + $GLOBALS['xoopsTpl']->append('songs', $songs->toArray()); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormSongs(false)); |
|
| 87 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 88 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_songs_list.tpl'); |
|
| 89 | + break; |
|
| 90 | + case 'new': |
|
| 91 | + case 'edit': |
|
| 92 | + $adminObject = Admin::getInstance(); |
|
| 93 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 94 | 94 | |
| 95 | - require_once $GLOBALS['xoops']->path('/class/pagenav.php'); |
|
| 95 | + require_once $GLOBALS['xoops']->path('/class/pagenav.php'); |
|
| 96 | 96 | |
| 97 | - $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 98 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 99 | - $songs = $songsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 100 | - } else { |
|
| 101 | - $songs = $songsHandler->create(); |
|
| 102 | - } |
|
| 97 | + $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 98 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 99 | + $songs = $songsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 100 | + } else { |
|
| 101 | + $songs = $songsHandler->create(); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $GLOBALS['xoopsTpl']->assign('form', $songs->getForm()); |
|
| 105 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 106 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_songs_edit.tpl'); |
|
| 107 | - break; |
|
| 108 | - case 'save': |
|
| 109 | - $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 110 | - $extrasHandler = Helper::getInstance()->getHandler('Extras'); |
|
| 111 | - $id = 0; |
|
| 112 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 113 | - if ($id) { |
|
| 114 | - $songs = $songsHandler->get($id); |
|
| 115 | - } else { |
|
| 116 | - $songs = $songsHandler->create(); |
|
| 117 | - } |
|
| 118 | - $songs->setVars($_POST[$id]); |
|
| 104 | + $GLOBALS['xoopsTpl']->assign('form', $songs->getForm()); |
|
| 105 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
| 106 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_songs_edit.tpl'); |
|
| 107 | + break; |
|
| 108 | + case 'save': |
|
| 109 | + $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 110 | + $extrasHandler = Helper::getInstance()->getHandler('Extras'); |
|
| 111 | + $id = 0; |
|
| 112 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
| 113 | + if ($id) { |
|
| 114 | + $songs = $songsHandler->get($id); |
|
| 115 | + } else { |
|
| 116 | + $songs = $songsHandler->create(); |
|
| 117 | + } |
|
| 118 | + $songs->setVars($_POST[$id]); |
|
| 119 | 119 | |
| 120 | - if (Request::hasVar('mp3' . $id, 'FILES') && !empty($_FILES['mp3' . $id]['title'])) { |
|
| 120 | + if (Request::hasVar('mp3' . $id, 'FILES') && !empty($_FILES['mp3' . $id]['title'])) { |
|
| 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,74 +130,74 @@ discard block |
||
| 130 | 130 | // } |
| 131 | 131 | |
| 132 | 132 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 133 | - $uploader = new Uploader( |
|
| 134 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 135 | - explode('|', $GLOBALS['songlistModuleConfig']['mp3_mimetype']), |
|
| 136 | - $GLOBALS['songlistModuleConfig']['mp3_filesize'], |
|
| 137 | - 0, |
|
| 138 | - 0, |
|
| 139 | - explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions']) |
|
| 140 | - ); |
|
| 141 | - try { |
|
| 142 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 143 | - } catch (Exception $e) { |
|
| 144 | - } |
|
| 133 | + $uploader = new Uploader( |
|
| 134 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 135 | + explode('|', $GLOBALS['songlistModuleConfig']['mp3_mimetype']), |
|
| 136 | + $GLOBALS['songlistModuleConfig']['mp3_filesize'], |
|
| 137 | + 0, |
|
| 138 | + 0, |
|
| 139 | + explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions']) |
|
| 140 | + ); |
|
| 141 | + try { |
|
| 142 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 143 | + } catch (Exception $e) { |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - if ($uploader->fetchMedia('mp3' . $id)) { |
|
| 147 | - if (!$uploader->upload()) { |
|
| 148 | - $adminObject = Admin::getInstance(); |
|
| 149 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 150 | - echo $uploader->getErrors(); |
|
| 151 | - xoops_cp_footer(); |
|
| 152 | - exit(0); |
|
| 153 | - } |
|
| 154 | - if (mb_strlen($songs->getVar('mp3'))) { |
|
| 155 | - unlink($GLOBALS['xoops']->path($songs->getVar('path')) . basename($songs->getVar('mp3'))); |
|
| 156 | - } |
|
| 146 | + if ($uploader->fetchMedia('mp3' . $id)) { |
|
| 147 | + if (!$uploader->upload()) { |
|
| 148 | + $adminObject = Admin::getInstance(); |
|
| 149 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 150 | + echo $uploader->getErrors(); |
|
| 151 | + xoops_cp_footer(); |
|
| 152 | + exit(0); |
|
| 153 | + } |
|
| 154 | + if (mb_strlen($songs->getVar('mp3'))) { |
|
| 155 | + unlink($GLOBALS['xoops']->path($songs->getVar('path')) . basename($songs->getVar('mp3'))); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - $songs->setVar('mp3', XOOPS_URL . '/' . str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']) . $uploader->getSavedFileName()); |
|
| 159 | - } else { |
|
| 160 | - $adminObject = Admin::getInstance(); |
|
| 161 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 162 | - echo $uploader->getErrors(); |
|
| 163 | - xoops_cp_footer(); |
|
| 164 | - exit(0); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - if (!$id = $songsHandler->insert($songs)) { |
|
| 168 | - 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_SONGS_FAILEDTOSAVE); |
|
| 169 | - exit(0); |
|
| 170 | - } |
|
| 171 | - $extra = $extrasHandler->get($id); |
|
| 172 | - $extra->setVars($_POST[$id]); |
|
| 173 | - $extra->setVar('sid', $id); |
|
| 174 | - $extrasHandler->insert($extra); |
|
| 158 | + $songs->setVar('mp3', XOOPS_URL . '/' . str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']) . $uploader->getSavedFileName()); |
|
| 159 | + } else { |
|
| 160 | + $adminObject = Admin::getInstance(); |
|
| 161 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 162 | + echo $uploader->getErrors(); |
|
| 163 | + xoops_cp_footer(); |
|
| 164 | + exit(0); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + if (!$id = $songsHandler->insert($songs)) { |
|
| 168 | + 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_SONGS_FAILEDTOSAVE); |
|
| 169 | + exit(0); |
|
| 170 | + } |
|
| 171 | + $extra = $extrasHandler->get($id); |
|
| 172 | + $extra->setVars($_POST[$id]); |
|
| 173 | + $extra->setVar('sid', $id); |
|
| 174 | + $extrasHandler->insert($extra); |
|
| 175 | 175 | |
| 176 | - if ($GLOBALS['songlistModuleConfig']['tags'] && file_exists(XOOPS_ROOT_PATH . '/modules/tag/class/tag.php')) { |
|
| 177 | - $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); |
|
| 178 | - $tagHandler->updateByItem($_POST['tags'], $id, $GLOBALS['songlistModule']->getVar('dirname'), $songs->getVar('cid')); |
|
| 179 | - } |
|
| 176 | + if ($GLOBALS['songlistModuleConfig']['tags'] && file_exists(XOOPS_ROOT_PATH . '/modules/tag/class/tag.php')) { |
|
| 177 | + $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); |
|
| 178 | + $tagHandler->updateByItem($_POST['tags'], $id, $GLOBALS['songlistModule']->getVar('dirname'), $songs->getVar('cid')); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - if ('new' === isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']]:'') { |
|
| 182 | - redirect_header( |
|
| 183 | - $_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'], |
|
| 184 | - 10, |
|
| 185 | - _AM_SONGLIST_MSG_SONGS_SAVEDOKEY |
|
| 186 | - ); |
|
| 187 | - } else { |
|
| 188 | - 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_SONGS_SAVEDOKEY); |
|
| 189 | - } |
|
| 190 | - exit(0); |
|
| 181 | + if ('new' === isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']]:'') { |
|
| 182 | + redirect_header( |
|
| 183 | + $_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'], |
|
| 184 | + 10, |
|
| 185 | + _AM_SONGLIST_MSG_SONGS_SAVEDOKEY |
|
| 186 | + ); |
|
| 187 | + } else { |
|
| 188 | + 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_SONGS_SAVEDOKEY); |
|
| 189 | + } |
|
| 190 | + exit(0); |
|
| 191 | 191 | |
| 192 | - break; |
|
| 193 | - case 'savelist': |
|
| 194 | - print_r($_FILES); |
|
| 195 | - exit; |
|
| 196 | - $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 197 | - foreach ($_REQUEST['id'] as $id) { |
|
| 198 | - $songs = $songsHandler->get($id); |
|
| 199 | - $songs->setVars($_POST[$id]); |
|
| 200 | - if (Request::hasVar('mp3' . $id, 'FILES') && !empty($_FILES['mp3' . $id]['title'])) { |
|
| 192 | + break; |
|
| 193 | + case 'savelist': |
|
| 194 | + print_r($_FILES); |
|
| 195 | + exit; |
|
| 196 | + $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 197 | + foreach ($_REQUEST['id'] as $id) { |
|
| 198 | + $songs = $songsHandler->get($id); |
|
| 199 | + $songs->setVars($_POST[$id]); |
|
| 200 | + if (Request::hasVar('mp3' . $id, 'FILES') && !empty($_FILES['mp3' . $id]['title'])) { |
|
| 201 | 201 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
| 202 | 202 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
| 203 | 203 | // foreach (explode('/', $folders) as $folder) { |
@@ -210,78 +210,78 @@ discard block |
||
| 210 | 210 | // } |
| 211 | 211 | |
| 212 | 212 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
| 213 | - $uploader = new Uploader( |
|
| 214 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 215 | - explode('|', $GLOBALS['songlistModuleConfig']['mp3_mimetype']), |
|
| 216 | - $GLOBALS['songlistModuleConfig']['mp3_filesize'], |
|
| 217 | - 0, |
|
| 218 | - 0, |
|
| 219 | - explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions']) |
|
| 220 | - ); |
|
| 221 | - try { |
|
| 222 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 223 | - } catch (Exception $e) { |
|
| 224 | - } |
|
| 213 | + $uploader = new Uploader( |
|
| 214 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
| 215 | + explode('|', $GLOBALS['songlistModuleConfig']['mp3_mimetype']), |
|
| 216 | + $GLOBALS['songlistModuleConfig']['mp3_filesize'], |
|
| 217 | + 0, |
|
| 218 | + 0, |
|
| 219 | + explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions']) |
|
| 220 | + ); |
|
| 221 | + try { |
|
| 222 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 223 | + } catch (Exception $e) { |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - if ($uploader->fetchMedia('mp3' . $id)) { |
|
| 227 | - if (!$uploader->upload()) { |
|
| 228 | - $adminObject = Admin::getInstance(); |
|
| 229 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 230 | - echo $uploader->getErrors(); |
|
| 231 | - xoops_cp_footer(); |
|
| 232 | - exit(0); |
|
| 233 | - } |
|
| 234 | - if (mb_strlen($songs->getVar('mp3'))) { |
|
| 235 | - unlink($GLOBALS['xoops']->path($songs->getVar('path')) . basename($songs->getVar('mp3'))); |
|
| 236 | - } |
|
| 226 | + if ($uploader->fetchMedia('mp3' . $id)) { |
|
| 227 | + if (!$uploader->upload()) { |
|
| 228 | + $adminObject = Admin::getInstance(); |
|
| 229 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 230 | + echo $uploader->getErrors(); |
|
| 231 | + xoops_cp_footer(); |
|
| 232 | + exit(0); |
|
| 233 | + } |
|
| 234 | + if (mb_strlen($songs->getVar('mp3'))) { |
|
| 235 | + unlink($GLOBALS['xoops']->path($songs->getVar('path')) . basename($songs->getVar('mp3'))); |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - $songs->setVar('mp3', XOOPS_URL . '/' . str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']) . $uploader->getSavedFileName()); |
|
| 239 | - } else { |
|
| 240 | - $adminObject = Admin::getInstance(); |
|
| 241 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 242 | - echo $uploader->getErrors(); |
|
| 243 | - xoops_cp_footer(); |
|
| 244 | - exit(0); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - if (!$songsHandler->insert($songs)) { |
|
| 248 | - redirect_header( |
|
| 249 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 250 | - 10, |
|
| 251 | - _AM_SONGLIST_MSG_SONGS_FAILEDTOSAVE |
|
| 252 | - ); |
|
| 253 | - exit(0); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - 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_SONGS_SAVEDOKEY); |
|
| 257 | - exit(0); |
|
| 258 | - break; |
|
| 259 | - case 'delete': |
|
| 260 | - $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 261 | - $id = 0; |
|
| 262 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 263 | - $songs = $songsHandler->get($id); |
|
| 264 | - if (!$songsHandler->delete($songs)) { |
|
| 265 | - redirect_header( |
|
| 266 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 267 | - 10, |
|
| 268 | - _AM_SONGLIST_MSG_SONGS_FAILEDTODELETE |
|
| 269 | - ); |
|
| 270 | - exit(0); |
|
| 271 | - } |
|
| 272 | - 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_SONGS_DELETED); |
|
| 273 | - exit(0); |
|
| 274 | - } |
|
| 275 | - $songs = $songsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 276 | - xoops_confirm( |
|
| 277 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 278 | - $_SERVER['SCRIPT_NAME'], |
|
| 279 | - sprintf(_AM_SONGLIST_MSG_SONGS_DELETE, $songs->getVar('name')) |
|
| 280 | - ); |
|
| 238 | + $songs->setVar('mp3', XOOPS_URL . '/' . str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']) . $uploader->getSavedFileName()); |
|
| 239 | + } else { |
|
| 240 | + $adminObject = Admin::getInstance(); |
|
| 241 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 242 | + echo $uploader->getErrors(); |
|
| 243 | + xoops_cp_footer(); |
|
| 244 | + exit(0); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + if (!$songsHandler->insert($songs)) { |
|
| 248 | + redirect_header( |
|
| 249 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 250 | + 10, |
|
| 251 | + _AM_SONGLIST_MSG_SONGS_FAILEDTOSAVE |
|
| 252 | + ); |
|
| 253 | + exit(0); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + 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_SONGS_SAVEDOKEY); |
|
| 257 | + exit(0); |
|
| 258 | + break; |
|
| 259 | + case 'delete': |
|
| 260 | + $songsHandler = Helper::getInstance()->getHandler('Songs'); |
|
| 261 | + $id = 0; |
|
| 262 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
| 263 | + $songs = $songsHandler->get($id); |
|
| 264 | + if (!$songsHandler->delete($songs)) { |
|
| 265 | + redirect_header( |
|
| 266 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 267 | + 10, |
|
| 268 | + _AM_SONGLIST_MSG_SONGS_FAILEDTODELETE |
|
| 269 | + ); |
|
| 270 | + exit(0); |
|
| 271 | + } |
|
| 272 | + 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_SONGS_DELETED); |
|
| 273 | + exit(0); |
|
| 274 | + } |
|
| 275 | + $songs = $songsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
| 276 | + xoops_confirm( |
|
| 277 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
| 278 | + $_SERVER['SCRIPT_NAME'], |
|
| 279 | + sprintf(_AM_SONGLIST_MSG_SONGS_DELETE, $songs->getVar('name')) |
|
| 280 | + ); |
|
| 281 | 281 | |
| 282 | - break; |
|
| 283 | - } |
|
| 284 | - break; |
|
| 282 | + break; |
|
| 283 | + } |
|
| 284 | + break; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | xoops_cp_footer(); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use XoopsModules\Songlist\Form\FormController; |
| 9 | 9 | |
| 10 | 10 | |
| 11 | -require __DIR__ . '/header.php'; |
|
| 11 | +require __DIR__.'/header.php'; |
|
| 12 | 12 | |
| 13 | 13 | xoops_loadLanguage('admin', 'songlist'); |
| 14 | 14 | |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
| 20 | 20 | $start = Request::getInt('start', 0, 'REQUEST'); |
| 21 | 21 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
| 22 | -$sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 23 | -$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
|
| 22 | +$sort = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 23 | +$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1'; |
|
| 24 | 24 | |
| 25 | 25 | switch ($op) { |
| 26 | 26 | default: |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $criteria = $songsHandler->getFilterCriteria($GLOBALS['filter']); |
| 38 | 38 | $ttl = $songsHandler->getCount($criteria); |
| 39 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
| 39 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
| 40 | 40 | |
| 41 | - $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 | + $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']); |
|
| 42 | 42 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
| 43 | 43 | |
| 44 | 44 | foreach ($songsHandler->filterFields() as $id => $key) { |
| 45 | 45 | $GLOBALS['xoopsTpl']->assign( |
| 46 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
| 46 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
| 47 | 47 | '<a href="' |
| 48 | 48 | . $_SERVER['SCRIPT_NAME'] |
| 49 | 49 | . '?start=' |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | . '&sort=' |
| 54 | 54 | . $key |
| 55 | 55 | . '&order=' |
| 56 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 56 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
| 57 | 57 | . '&op=' |
| 58 | 58 | . $GLOBALS['op'] |
| 59 | 59 | . '&filter=' |
| 60 | 60 | . $GLOBALS['filter'] |
| 61 | 61 | . '">' |
| 62 | - . (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 | + . (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))) |
|
| 63 | 63 | . '</a>' |
| 64 | 64 | ); |
| 65 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $songsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 65 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $songsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $criteria->setStart($GLOBALS['start']); |
| 76 | 76 | $criteria->setLimit($GLOBALS['limit']); |
| 77 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
| 77 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
| 78 | 78 | $criteria->setOrder($GLOBALS['order']); |
| 79 | 79 | |
| 80 | 80 | $songss = $songsHandler->getObjects($criteria, true); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | $songs->setVars($_POST[$id]); |
| 119 | 119 | |
| 120 | - if (Request::hasVar('mp3' . $id, 'FILES') && !empty($_FILES['mp3' . $id]['title'])) { |
|
| 120 | + if (Request::hasVar('mp3'.$id, 'FILES') && !empty($_FILES['mp3'.$id]['title'])) { |
|
| 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) { |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions']) |
| 140 | 140 | ); |
| 141 | 141 | try { |
| 142 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 142 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
| 143 | 143 | } catch (Exception $e) { |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ($uploader->fetchMedia('mp3' . $id)) { |
|
| 146 | + if ($uploader->fetchMedia('mp3'.$id)) { |
|
| 147 | 147 | if (!$uploader->upload()) { |
| 148 | 148 | $adminObject = Admin::getInstance(); |
| 149 | 149 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | exit(0); |
| 153 | 153 | } |
| 154 | 154 | if (mb_strlen($songs->getVar('mp3'))) { |
| 155 | - unlink($GLOBALS['xoops']->path($songs->getVar('path')) . basename($songs->getVar('mp3'))); |
|
| 155 | + unlink($GLOBALS['xoops']->path($songs->getVar('path')).basename($songs->getVar('mp3'))); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $songs->setVar('mp3', XOOPS_URL . '/' . str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']) . $uploader->getSavedFileName()); |
|
| 158 | + $songs->setVar('mp3', XOOPS_URL.'/'.str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']).$uploader->getSavedFileName()); |
|
| 159 | 159 | } else { |
| 160 | 160 | $adminObject = Admin::getInstance(); |
| 161 | 161 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | if (!$id = $songsHandler->insert($songs)) { |
| 168 | - 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_SONGS_FAILEDTOSAVE); |
|
| 168 | + 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_SONGS_FAILEDTOSAVE); |
|
| 169 | 169 | exit(0); |
| 170 | 170 | } |
| 171 | 171 | $extra = $extrasHandler->get($id); |
@@ -173,19 +173,19 @@ discard block |
||
| 173 | 173 | $extra->setVar('sid', $id); |
| 174 | 174 | $extrasHandler->insert($extra); |
| 175 | 175 | |
| 176 | - if ($GLOBALS['songlistModuleConfig']['tags'] && file_exists(XOOPS_ROOT_PATH . '/modules/tag/class/tag.php')) { |
|
| 176 | + if ($GLOBALS['songlistModuleConfig']['tags'] && file_exists(XOOPS_ROOT_PATH.'/modules/tag/class/tag.php')) { |
|
| 177 | 177 | $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); |
| 178 | 178 | $tagHandler->updateByItem($_POST['tags'], $id, $GLOBALS['songlistModule']->getVar('dirname'), $songs->getVar('cid')); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ('new' === isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']]:'') { |
|
| 181 | + if ('new'===isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']] : '') { |
|
| 182 | 182 | redirect_header( |
| 183 | - $_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'], |
|
| 183 | + $_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'], |
|
| 184 | 184 | 10, |
| 185 | 185 | _AM_SONGLIST_MSG_SONGS_SAVEDOKEY |
| 186 | 186 | ); |
| 187 | 187 | } else { |
| 188 | - 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_SONGS_SAVEDOKEY); |
|
| 188 | + 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_SONGS_SAVEDOKEY); |
|
| 189 | 189 | } |
| 190 | 190 | exit(0); |
| 191 | 191 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | foreach ($_REQUEST['id'] as $id) { |
| 198 | 198 | $songs = $songsHandler->get($id); |
| 199 | 199 | $songs->setVars($_POST[$id]); |
| 200 | - if (Request::hasVar('mp3' . $id, 'FILES') && !empty($_FILES['mp3' . $id]['title'])) { |
|
| 200 | + if (Request::hasVar('mp3'.$id, 'FILES') && !empty($_FILES['mp3'.$id]['title'])) { |
|
| 201 | 201 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
| 202 | 202 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
| 203 | 203 | // foreach (explode('/', $folders) as $folder) { |
@@ -219,11 +219,11 @@ discard block |
||
| 219 | 219 | explode('|', $GLOBALS['songlistModuleConfig']['mp3_extensions']) |
| 220 | 220 | ); |
| 221 | 221 | try { |
| 222 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
| 222 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
| 223 | 223 | } catch (Exception $e) { |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ($uploader->fetchMedia('mp3' . $id)) { |
|
| 226 | + if ($uploader->fetchMedia('mp3'.$id)) { |
|
| 227 | 227 | if (!$uploader->upload()) { |
| 228 | 228 | $adminObject = Admin::getInstance(); |
| 229 | 229 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -232,10 +232,10 @@ discard block |
||
| 232 | 232 | exit(0); |
| 233 | 233 | } |
| 234 | 234 | if (mb_strlen($songs->getVar('mp3'))) { |
| 235 | - unlink($GLOBALS['xoops']->path($songs->getVar('path')) . basename($songs->getVar('mp3'))); |
|
| 235 | + unlink($GLOBALS['xoops']->path($songs->getVar('path')).basename($songs->getVar('mp3'))); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $songs->setVar('mp3', XOOPS_URL . '/' . str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']) . $uploader->getSavedFileName()); |
|
| 238 | + $songs->setVar('mp3', XOOPS_URL.'/'.str_replace(DS, '/', $GLOBALS['songlistModuleConfig']['upload_areas']).$uploader->getSavedFileName()); |
|
| 239 | 239 | } else { |
| 240 | 240 | $adminObject = Admin::getInstance(); |
| 241 | 241 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | if (!$songsHandler->insert($songs)) { |
| 248 | 248 | redirect_header( |
| 249 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 249 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 250 | 250 | 10, |
| 251 | 251 | _AM_SONGLIST_MSG_SONGS_FAILEDTOSAVE |
| 252 | 252 | ); |
| 253 | 253 | exit(0); |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | - 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_SONGS_SAVEDOKEY); |
|
| 256 | + 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_SONGS_SAVEDOKEY); |
|
| 257 | 257 | exit(0); |
| 258 | 258 | break; |
| 259 | 259 | case 'delete': |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | $songs = $songsHandler->get($id); |
| 264 | 264 | if (!$songsHandler->delete($songs)) { |
| 265 | 265 | redirect_header( |
| 266 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
| 266 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
| 267 | 267 | 10, |
| 268 | 268 | _AM_SONGLIST_MSG_SONGS_FAILEDTODELETE |
| 269 | 269 | ); |
| 270 | 270 | exit(0); |
| 271 | 271 | } |
| 272 | - 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_SONGS_DELETED); |
|
| 272 | + 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_SONGS_DELETED); |
|
| 273 | 273 | exit(0); |
| 274 | 274 | } |
| 275 | 275 | $songs = $songsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -10,84 +10,84 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : (!empty($_REQUEST['id']) ? 'edit' : 'list'))); |
| 12 | 12 | $fieldHandler = Helper::getInstance() |
| 13 | - ->getHandler('Field'); |
|
| 13 | + ->getHandler('Field'); |
|
| 14 | 14 | switch ($op) { |
| 15 | - default: |
|
| 16 | - case 'list': |
|
| 17 | - $adminObject = Admin::getInstance(); |
|
| 18 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 15 | + default: |
|
| 16 | + case 'list': |
|
| 17 | + $adminObject = Admin::getInstance(); |
|
| 18 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 19 | 19 | |
| 20 | - $fields = $fieldHandler->getObjects(null, false, false); |
|
| 20 | + $fields = $fieldHandler->getObjects(null, false, false); |
|
| 21 | 21 | |
| 22 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 23 | - $moduleHandler = xoops_getHandler('module'); |
|
| 24 | - $modules = $moduleHandler->getObjects(null, true); |
|
| 22 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
| 23 | + $moduleHandler = xoops_getHandler('module'); |
|
| 24 | + $modules = $moduleHandler->getObjects(null, true); |
|
| 25 | 25 | |
| 26 | - $categories = []; |
|
| 27 | - $weights = []; |
|
| 26 | + $categories = []; |
|
| 27 | + $weights = []; |
|
| 28 | 28 | |
| 29 | - $GLOBALS['categoryHandler'] = Helper::getInstance() |
|
| 30 | - ->getHandler('Category'); |
|
| 31 | - $criteria = new \CriteriaCompo(); |
|
| 32 | - $criteria->setSort('weight'); |
|
| 33 | - $category = $GLOBALS['categoryHandler']->getObjects($criteria, true); |
|
| 34 | - $fieldcategories = []; |
|
| 35 | - if ($category) { |
|
| 36 | - unset($criteria); |
|
| 29 | + $GLOBALS['categoryHandler'] = Helper::getInstance() |
|
| 30 | + ->getHandler('Category'); |
|
| 31 | + $criteria = new \CriteriaCompo(); |
|
| 32 | + $criteria->setSort('weight'); |
|
| 33 | + $category = $GLOBALS['categoryHandler']->getObjects($criteria, true); |
|
| 34 | + $fieldcategories = []; |
|
| 35 | + if ($category) { |
|
| 36 | + unset($criteria); |
|
| 37 | 37 | |
| 38 | - $categories[0] = ['cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT]; |
|
| 39 | - if (count($category) > 0) { |
|
| 40 | - foreach (array_keys($category) as $i) { |
|
| 41 | - $categories[$category[$i]->getVar('cid')] = ['cid' => $category[$i]->getVar('cid'), 'name' => $category[$i]->getVar('name')]; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - $GLOBALS['xoopsTpl']->assign('categories', $categories); |
|
| 45 | - } |
|
| 38 | + $categories[0] = ['cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT]; |
|
| 39 | + if (count($category) > 0) { |
|
| 40 | + foreach (array_keys($category) as $i) { |
|
| 41 | + $categories[$category[$i]->getVar('cid')] = ['cid' => $category[$i]->getVar('cid'), 'name' => $category[$i]->getVar('name')]; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + $GLOBALS['xoopsTpl']->assign('categories', $categories); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $valuetypes = [ |
|
| 48 | - XOBJ_DTYPE_ARRAY => _AM_SONGLIST_FIELDS_ARRAY, |
|
| 49 | - XOBJ_DTYPE_EMAIL => _AM_SONGLIST_FIELDS_EMAIL, |
|
| 50 | - XOBJ_DTYPE_INT => _AM_SONGLIST_FIELDS_INT, |
|
| 51 | - XOBJ_DTYPE_TXTAREA => _AM_SONGLIST_FIELDS_TXTAREA, |
|
| 52 | - XOBJ_DTYPE_TXTBOX => _AM_SONGLIST_FIELDS_TXTBOX, |
|
| 53 | - XOBJ_DTYPE_URL => _AM_SONGLIST_FIELDS_URL, |
|
| 54 | - XOBJ_DTYPE_OTHER => _AM_SONGLIST_FIELDS_OTHER, |
|
| 55 | - XOBJ_DTYPE_MTIME => _AM_SONGLIST_FIELDS_DATE, |
|
| 56 | - ]; |
|
| 47 | + $valuetypes = [ |
|
| 48 | + XOBJ_DTYPE_ARRAY => _AM_SONGLIST_FIELDS_ARRAY, |
|
| 49 | + XOBJ_DTYPE_EMAIL => _AM_SONGLIST_FIELDS_EMAIL, |
|
| 50 | + XOBJ_DTYPE_INT => _AM_SONGLIST_FIELDS_INT, |
|
| 51 | + XOBJ_DTYPE_TXTAREA => _AM_SONGLIST_FIELDS_TXTAREA, |
|
| 52 | + XOBJ_DTYPE_TXTBOX => _AM_SONGLIST_FIELDS_TXTBOX, |
|
| 53 | + XOBJ_DTYPE_URL => _AM_SONGLIST_FIELDS_URL, |
|
| 54 | + XOBJ_DTYPE_OTHER => _AM_SONGLIST_FIELDS_OTHER, |
|
| 55 | + XOBJ_DTYPE_MTIME => _AM_SONGLIST_FIELDS_DATE, |
|
| 56 | + ]; |
|
| 57 | 57 | |
| 58 | - $fieldtypes = [ |
|
| 59 | - 'checkbox' => _AM_SONGLIST_FIELDS_CHECKBOX, |
|
| 60 | - 'group' => _AM_SONGLIST_FIELDS_GROUP, |
|
| 61 | - 'group_multi' => _AM_SONGLIST_FIELDS_GROUPMULTI, |
|
| 62 | - 'language' => _AM_SONGLIST_FIELDS_LANGUAGE, |
|
| 63 | - 'radio' => _AM_SONGLIST_FIELDS_RADIO, |
|
| 64 | - 'select' => _AM_SONGLIST_FIELDS_SELECT, |
|
| 65 | - 'select_multi' => _AM_SONGLIST_FIELDS_SELECTMULTI, |
|
| 66 | - 'textarea' => _AM_SONGLIST_FIELDS_TEXTAREA, |
|
| 67 | - 'dhtml' => _AM_SONGLIST_FIELDS_DHTMLTEXTAREA, |
|
| 68 | - 'editor' => _AM_SONGLIST_FIELDS_EDITOR, |
|
| 69 | - 'textbox' => _AM_SONGLIST_FIELDS_TEXTBOX, |
|
| 70 | - 'timezone' => _AM_SONGLIST_FIELDS_TIMEZONE, |
|
| 71 | - 'yesno' => _AM_SONGLIST_FIELDS_YESNO, |
|
| 72 | - 'date' => _AM_SONGLIST_FIELDS_DATE, |
|
| 73 | - 'datetime' => _AM_SONGLIST_FIELDS_DATETIME, |
|
| 74 | - 'longdate' => _AM_SONGLIST_FIELDS_LONGDATE, |
|
| 75 | - 'theme' => _AM_SONGLIST_FIELDS_THEME, |
|
| 76 | - 'autotext' => _AM_SONGLIST_FIELDS_AUTOTEXT, |
|
| 77 | - 'rank' => _AM_SONGLIST_FIELDS_RANK, |
|
| 78 | - ]; |
|
| 58 | + $fieldtypes = [ |
|
| 59 | + 'checkbox' => _AM_SONGLIST_FIELDS_CHECKBOX, |
|
| 60 | + 'group' => _AM_SONGLIST_FIELDS_GROUP, |
|
| 61 | + 'group_multi' => _AM_SONGLIST_FIELDS_GROUPMULTI, |
|
| 62 | + 'language' => _AM_SONGLIST_FIELDS_LANGUAGE, |
|
| 63 | + 'radio' => _AM_SONGLIST_FIELDS_RADIO, |
|
| 64 | + 'select' => _AM_SONGLIST_FIELDS_SELECT, |
|
| 65 | + 'select_multi' => _AM_SONGLIST_FIELDS_SELECTMULTI, |
|
| 66 | + 'textarea' => _AM_SONGLIST_FIELDS_TEXTAREA, |
|
| 67 | + 'dhtml' => _AM_SONGLIST_FIELDS_DHTMLTEXTAREA, |
|
| 68 | + 'editor' => _AM_SONGLIST_FIELDS_EDITOR, |
|
| 69 | + 'textbox' => _AM_SONGLIST_FIELDS_TEXTBOX, |
|
| 70 | + 'timezone' => _AM_SONGLIST_FIELDS_TIMEZONE, |
|
| 71 | + 'yesno' => _AM_SONGLIST_FIELDS_YESNO, |
|
| 72 | + 'date' => _AM_SONGLIST_FIELDS_DATE, |
|
| 73 | + 'datetime' => _AM_SONGLIST_FIELDS_DATETIME, |
|
| 74 | + 'longdate' => _AM_SONGLIST_FIELDS_LONGDATE, |
|
| 75 | + 'theme' => _AM_SONGLIST_FIELDS_THEME, |
|
| 76 | + 'autotext' => _AM_SONGLIST_FIELDS_AUTOTEXT, |
|
| 77 | + 'rank' => _AM_SONGLIST_FIELDS_RANK, |
|
| 78 | + ]; |
|
| 79 | 79 | |
| 80 | - foreach (array_keys($fields) as $i) { |
|
| 81 | - $fields[$i]['canEdit'] = $fields[$i]['field_config'] || $fields[$i]['field_show'] || $fields[$i]['field_edit']; |
|
| 82 | - $fields[$i]['canDelete'] = $fields[$i]['field_config']; |
|
| 83 | - $fields[$i]['fieldtype'] = $fieldtypes[$fields[$i]['field_type']]; |
|
| 84 | - $fields[$i]['valuetype'] = $valuetypes[$fields[$i]['field_valuetype']]; |
|
| 85 | - $fieldcategories[$i][] = $fields[$i]; |
|
| 86 | - $weights[$i] = $fields[$i]['field_weight']; |
|
| 87 | - } |
|
| 88 | - //sort fields order in categories |
|
| 80 | + foreach (array_keys($fields) as $i) { |
|
| 81 | + $fields[$i]['canEdit'] = $fields[$i]['field_config'] || $fields[$i]['field_show'] || $fields[$i]['field_edit']; |
|
| 82 | + $fields[$i]['canDelete'] = $fields[$i]['field_config']; |
|
| 83 | + $fields[$i]['fieldtype'] = $fieldtypes[$fields[$i]['field_type']]; |
|
| 84 | + $fields[$i]['valuetype'] = $valuetypes[$fields[$i]['field_valuetype']]; |
|
| 85 | + $fieldcategories[$i][] = $fields[$i]; |
|
| 86 | + $weights[$i] = $fields[$i]['field_weight']; |
|
| 87 | + } |
|
| 88 | + //sort fields order in categories |
|
| 89 | 89 | // ray('$fields', $fields); |
| 90 | - foreach (array_keys($fields) as $i) { |
|
| 90 | + foreach (array_keys($fields) as $i) { |
|
| 91 | 91 | // ray('$i = ' . $i)->red(); |
| 92 | 92 | // ray('$weights: <br>' , $weights)->red(); |
| 93 | 93 | // ray('$fieldcategories: <br>' , $fieldcategories)->red(); |
@@ -95,237 +95,237 @@ discard block |
||
| 95 | 95 | // ray('$categories: <br>', $categories)->red(); |
| 96 | 96 | // ray('$categories[$i]: <br>', $categories[$i])->red(); |
| 97 | 97 | |
| 98 | - array_multisort( |
|
| 99 | - $weights |
|
| 100 | - , |
|
| 101 | - SORT_ASC |
|
| 102 | - , |
|
| 103 | - array_keys($fieldcategories) |
|
| 104 | - , |
|
| 105 | - SORT_ASC |
|
| 106 | - , |
|
| 107 | - $categories[$i] |
|
| 108 | - ); |
|
| 98 | + array_multisort( |
|
| 99 | + $weights |
|
| 100 | + , |
|
| 101 | + SORT_ASC |
|
| 102 | + , |
|
| 103 | + array_keys($fieldcategories) |
|
| 104 | + , |
|
| 105 | + SORT_ASC |
|
| 106 | + , |
|
| 107 | + $categories[$i] |
|
| 108 | + ); |
|
| 109 | 109 | // ray($i)->blue(); |
| 110 | 110 | // ray('$weights: <br>', $weights)->blue(); |
| 111 | 111 | // ray('$fieldcategories: <br>', $fieldcategories)->blue(); |
| 112 | 112 | // ray(array_keys($fieldcategories))->blue(); |
| 113 | 113 | // ray('Categories: <br>', $categories)->blue(); |
| 114 | 114 | // ray('$categories[$i]: <br>', $categories[$i])->blue(); |
| 115 | - } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - ksort($categories); |
|
| 118 | - $GLOBALS['xoopsTpl']->assign('fieldcategories', $fieldcategories); |
|
| 119 | - $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
|
| 120 | - $template_main = 'songlist_cpanel_fieldlist.tpl'; |
|
| 121 | - break; |
|
| 122 | - case 'new': |
|
| 123 | - $adminObject = Admin::getInstance(); |
|
| 124 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 125 | - $obj = $fieldHandler->create(); |
|
| 126 | - $form = FormController::getFieldForm($obj); |
|
| 127 | - $form->display(); |
|
| 128 | - break; |
|
| 129 | - case 'edit': |
|
| 130 | - $adminObject = Admin::getInstance(); |
|
| 131 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 132 | - $obj = $fieldHandler->get($_REQUEST['id']); |
|
| 133 | - if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
| 134 | - redirect_header('field.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
| 135 | - } |
|
| 136 | - $form = FormController::getFieldForm($obj); |
|
| 137 | - $form->display(); |
|
| 138 | - break; |
|
| 139 | - case 'reorder': |
|
| 140 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 141 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 142 | - } |
|
| 117 | + ksort($categories); |
|
| 118 | + $GLOBALS['xoopsTpl']->assign('fieldcategories', $fieldcategories); |
|
| 119 | + $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
|
| 120 | + $template_main = 'songlist_cpanel_fieldlist.tpl'; |
|
| 121 | + break; |
|
| 122 | + case 'new': |
|
| 123 | + $adminObject = Admin::getInstance(); |
|
| 124 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 125 | + $obj = $fieldHandler->create(); |
|
| 126 | + $form = FormController::getFieldForm($obj); |
|
| 127 | + $form->display(); |
|
| 128 | + break; |
|
| 129 | + case 'edit': |
|
| 130 | + $adminObject = Admin::getInstance(); |
|
| 131 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 132 | + $obj = $fieldHandler->get($_REQUEST['id']); |
|
| 133 | + if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
| 134 | + redirect_header('field.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
| 135 | + } |
|
| 136 | + $form = FormController::getFieldForm($obj); |
|
| 137 | + $form->display(); |
|
| 138 | + break; |
|
| 139 | + case 'reorder': |
|
| 140 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 141 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids']) > 0) { |
|
| 145 | - $oldweight = $_POST['oldweight']; |
|
| 146 | - $oldcat = $_POST['oldcat']; |
|
| 147 | - $oldcategories = $_POST['oldcategories']; |
|
| 148 | - $categories = $_POST['categories']; |
|
| 149 | - $weight = $_POST['weight']; |
|
| 150 | - $ids = []; |
|
| 151 | - foreach ($_POST['field_ids'] as $field_id) { |
|
| 152 | - if ($oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
| 153 | - //if field has changed |
|
| 154 | - $ids[] = (int)$field_id; |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - if (count($ids) > 0) { |
|
| 158 | - $errors = []; |
|
| 159 | - //if there are changed fields, fetch the fieldcategory objects |
|
| 160 | - $fieldHandler = Helper::getInstance() |
|
| 161 | - ->getHandler('Field'); |
|
| 162 | - $fields = $fieldHandler->getObjects(new \Criteria('field_id', '(' . implode(',', $ids) . ')', 'IN'), true); |
|
| 163 | - foreach ($ids as $i) { |
|
| 164 | - $fields[$i]->setVar('field_weight', (int)$weight[$i]); |
|
| 165 | - $fields[$i]->setVar('cids', $categories[$i]); |
|
| 166 | - if (!$fieldHandler->insert($fields[$i])) { |
|
| 167 | - $errors = array_merge($errors, $fields[$i]->getErrors()); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - if (0 == count($errors)) { |
|
| 171 | - //no errors |
|
| 172 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
| 173 | - } else { |
|
| 174 | - redirect_header('field.php', 3, implode('<br>', $errors)); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
| 179 | - break; |
|
| 180 | - case 'save': |
|
| 181 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 182 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 183 | - } |
|
| 184 | - $redirect_to_edit = false; |
|
| 185 | - if (Request::hasVar('id', 'REQUEST')) { |
|
| 186 | - $obj = $fieldHandler->get($_REQUEST['id']); |
|
| 187 | - if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
| 188 | - redirect_header('fields.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
| 189 | - } |
|
| 190 | - } else { |
|
| 191 | - $obj = $fieldHandler->create(); |
|
| 192 | - $obj->setVar('field_name', $_REQUEST['field_name']); |
|
| 193 | - $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid')); |
|
| 194 | - $obj->setVar('field_show', 1); |
|
| 195 | - $obj->setVar('field_edit', 1); |
|
| 196 | - $obj->setVar('field_config', 1); |
|
| 197 | - $redirect_to_edit = true; |
|
| 198 | - } |
|
| 199 | - $obj->setVar('field_title', $_REQUEST['field_title']); |
|
| 200 | - $obj->setVar('field_description', $_REQUEST['field_description']); |
|
| 201 | - if ($obj->getVar('field_config')) { |
|
| 202 | - $obj->setVar('field_type', $_REQUEST['field_type']); |
|
| 203 | - if (Request::hasVar('field_valuetype', 'REQUEST')) { |
|
| 204 | - $obj->setVar('field_valuetype', $_REQUEST['field_valuetype']); |
|
| 205 | - } |
|
| 206 | - $options = $obj->getVar('field_options'); |
|
| 144 | + if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids']) > 0) { |
|
| 145 | + $oldweight = $_POST['oldweight']; |
|
| 146 | + $oldcat = $_POST['oldcat']; |
|
| 147 | + $oldcategories = $_POST['oldcategories']; |
|
| 148 | + $categories = $_POST['categories']; |
|
| 149 | + $weight = $_POST['weight']; |
|
| 150 | + $ids = []; |
|
| 151 | + foreach ($_POST['field_ids'] as $field_id) { |
|
| 152 | + if ($oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
| 153 | + //if field has changed |
|
| 154 | + $ids[] = (int)$field_id; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + if (count($ids) > 0) { |
|
| 158 | + $errors = []; |
|
| 159 | + //if there are changed fields, fetch the fieldcategory objects |
|
| 160 | + $fieldHandler = Helper::getInstance() |
|
| 161 | + ->getHandler('Field'); |
|
| 162 | + $fields = $fieldHandler->getObjects(new \Criteria('field_id', '(' . implode(',', $ids) . ')', 'IN'), true); |
|
| 163 | + foreach ($ids as $i) { |
|
| 164 | + $fields[$i]->setVar('field_weight', (int)$weight[$i]); |
|
| 165 | + $fields[$i]->setVar('cids', $categories[$i]); |
|
| 166 | + if (!$fieldHandler->insert($fields[$i])) { |
|
| 167 | + $errors = array_merge($errors, $fields[$i]->getErrors()); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + if (0 == count($errors)) { |
|
| 171 | + //no errors |
|
| 172 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
| 173 | + } else { |
|
| 174 | + redirect_header('field.php', 3, implode('<br>', $errors)); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
| 179 | + break; |
|
| 180 | + case 'save': |
|
| 181 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 182 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 183 | + } |
|
| 184 | + $redirect_to_edit = false; |
|
| 185 | + if (Request::hasVar('id', 'REQUEST')) { |
|
| 186 | + $obj = $fieldHandler->get($_REQUEST['id']); |
|
| 187 | + if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
| 188 | + redirect_header('fields.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
| 189 | + } |
|
| 190 | + } else { |
|
| 191 | + $obj = $fieldHandler->create(); |
|
| 192 | + $obj->setVar('field_name', $_REQUEST['field_name']); |
|
| 193 | + $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid')); |
|
| 194 | + $obj->setVar('field_show', 1); |
|
| 195 | + $obj->setVar('field_edit', 1); |
|
| 196 | + $obj->setVar('field_config', 1); |
|
| 197 | + $redirect_to_edit = true; |
|
| 198 | + } |
|
| 199 | + $obj->setVar('field_title', $_REQUEST['field_title']); |
|
| 200 | + $obj->setVar('field_description', $_REQUEST['field_description']); |
|
| 201 | + if ($obj->getVar('field_config')) { |
|
| 202 | + $obj->setVar('field_type', $_REQUEST['field_type']); |
|
| 203 | + if (Request::hasVar('field_valuetype', 'REQUEST')) { |
|
| 204 | + $obj->setVar('field_valuetype', $_REQUEST['field_valuetype']); |
|
| 205 | + } |
|
| 206 | + $options = $obj->getVar('field_options'); |
|
| 207 | 207 | |
| 208 | - if (Request::hasVar('removeOptions', 'REQUEST') && is_array($_REQUEST['removeOptions'])) { |
|
| 209 | - foreach ($_REQUEST['removeOptions'] as $index) { |
|
| 210 | - unset($options[$index]); |
|
| 211 | - } |
|
| 212 | - $redirect_to_edit = true; |
|
| 213 | - } |
|
| 208 | + if (Request::hasVar('removeOptions', 'REQUEST') && is_array($_REQUEST['removeOptions'])) { |
|
| 209 | + foreach ($_REQUEST['removeOptions'] as $index) { |
|
| 210 | + unset($options[$index]); |
|
| 211 | + } |
|
| 212 | + $redirect_to_edit = true; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if (Request::hasVar('addOption', 'REQUEST')) { |
|
| 216 | - foreach ($_REQUEST['addOption'] as $option) { |
|
| 217 | - if (empty($option['value'])) { |
|
| 218 | - continue; |
|
| 219 | - } |
|
| 220 | - $options[$option['key']] = $option['value']; |
|
| 221 | - $redirect_to_edit = true; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - $obj->setVar('field_options', $options); |
|
| 225 | - } |
|
| 226 | - if ($obj->getVar('field_edit')) { |
|
| 227 | - $required = Request::getInt('field_required', 0, 'REQUEST'); |
|
| 228 | - $obj->setVar('field_required', $required); //0 = no, 1 = yes |
|
| 229 | - if (Request::hasVar('field_maxlength', 'REQUEST')) { |
|
| 230 | - $obj->setVar('field_maxlength', $_REQUEST['field_maxlength']); |
|
| 231 | - } |
|
| 232 | - if (Request::hasVar('field_default', 'REQUEST')) { |
|
| 233 | - $field_default = $obj->getValueForSave($_REQUEST['field_default']); |
|
| 234 | - //Check for multiple selections |
|
| 235 | - if (is_array($field_default)) { |
|
| 236 | - $obj->setVar('field_default', serialize($field_default)); |
|
| 237 | - } else { |
|
| 238 | - $obj->setVar('field_default', $field_default); |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - } |
|
| 215 | + if (Request::hasVar('addOption', 'REQUEST')) { |
|
| 216 | + foreach ($_REQUEST['addOption'] as $option) { |
|
| 217 | + if (empty($option['value'])) { |
|
| 218 | + continue; |
|
| 219 | + } |
|
| 220 | + $options[$option['key']] = $option['value']; |
|
| 221 | + $redirect_to_edit = true; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + $obj->setVar('field_options', $options); |
|
| 225 | + } |
|
| 226 | + if ($obj->getVar('field_edit')) { |
|
| 227 | + $required = Request::getInt('field_required', 0, 'REQUEST'); |
|
| 228 | + $obj->setVar('field_required', $required); //0 = no, 1 = yes |
|
| 229 | + if (Request::hasVar('field_maxlength', 'REQUEST')) { |
|
| 230 | + $obj->setVar('field_maxlength', $_REQUEST['field_maxlength']); |
|
| 231 | + } |
|
| 232 | + if (Request::hasVar('field_default', 'REQUEST')) { |
|
| 233 | + $field_default = $obj->getValueForSave($_REQUEST['field_default']); |
|
| 234 | + //Check for multiple selections |
|
| 235 | + if (is_array($field_default)) { |
|
| 236 | + $obj->setVar('field_default', serialize($field_default)); |
|
| 237 | + } else { |
|
| 238 | + $obj->setVar('field_default', $field_default); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - $obj->setVar('field_weight', $_REQUEST['field_weight']); |
|
| 244 | - $obj->setVar('cids', $_REQUEST['cids']); |
|
| 243 | + $obj->setVar('field_weight', $_REQUEST['field_weight']); |
|
| 244 | + $obj->setVar('cids', $_REQUEST['cids']); |
|
| 245 | 245 | |
| 246 | - if ($fieldHandler->insert($obj)) { |
|
| 247 | - /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
| 248 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 246 | + if ($fieldHandler->insert($obj)) { |
|
| 247 | + /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
| 248 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 249 | 249 | |
| 250 | - $perm_arr = []; |
|
| 251 | - if ($obj->getVar('field_show')) { |
|
| 252 | - $perm_arr[] = 'songlist_show'; |
|
| 253 | - $perm_arr[] = 'songlist_visible'; |
|
| 254 | - } |
|
| 255 | - if ($obj->getVar('field_edit')) { |
|
| 256 | - $perm_arr[] = 'songlist_edit'; |
|
| 257 | - } |
|
| 258 | - if ($obj->getVar('field_edit') || $obj->getVar('field_show')) { |
|
| 259 | - $perm_arr[] = 'songlist_search'; |
|
| 260 | - } |
|
| 261 | - if (count($perm_arr) > 0) { |
|
| 262 | - foreach ($perm_arr as $perm) { |
|
| 263 | - $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm)); |
|
| 264 | - $criteria->add(new \Criteria('gperm_itemid', (int)$obj->getVar('field_id'))); |
|
| 265 | - $criteria->add(new \Criteria('gperm_modid', (int)$GLOBALS['songlistModule']->getVar('mid'))); |
|
| 266 | - if (isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm])) { |
|
| 267 | - $perms = $grouppermHandler->getObjects($criteria); |
|
| 268 | - if (count($perms) > 0) { |
|
| 269 | - foreach (array_keys($perms) as $i) { |
|
| 270 | - $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
|
| 271 | - } |
|
| 272 | - } else { |
|
| 273 | - $groups = []; |
|
| 274 | - } |
|
| 275 | - foreach ($_REQUEST[$perm] as $grouoid) { |
|
| 276 | - $grouoid = (int)$grouoid; |
|
| 277 | - if (!isset($groups[$grouoid])) { |
|
| 278 | - $perm_obj = $grouppermHandler->create(); |
|
| 279 | - $perm_obj->setVar('gperm_name', $perm); |
|
| 280 | - $perm_obj->setVar('gperm_itemid', (int)$obj->getVar('field_id')); |
|
| 281 | - $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid')); |
|
| 282 | - $perm_obj->setVar('gperm_groupid', $grouoid); |
|
| 283 | - $grouppermHandler->insert($perm_obj); |
|
| 284 | - unset($perm_obj); |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
|
| 288 | - if (count($removed_groups) > 0) { |
|
| 289 | - $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $removed_groups) . ')', 'IN')); |
|
| 290 | - $grouppermHandler->deleteAll($criteria); |
|
| 291 | - } |
|
| 292 | - unset($groups); |
|
| 293 | - } else { |
|
| 294 | - $grouppermHandler->deleteAll($criteria); |
|
| 295 | - } |
|
| 296 | - unset($criteria); |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
| 300 | - redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
| 301 | - } |
|
| 250 | + $perm_arr = []; |
|
| 251 | + if ($obj->getVar('field_show')) { |
|
| 252 | + $perm_arr[] = 'songlist_show'; |
|
| 253 | + $perm_arr[] = 'songlist_visible'; |
|
| 254 | + } |
|
| 255 | + if ($obj->getVar('field_edit')) { |
|
| 256 | + $perm_arr[] = 'songlist_edit'; |
|
| 257 | + } |
|
| 258 | + if ($obj->getVar('field_edit') || $obj->getVar('field_show')) { |
|
| 259 | + $perm_arr[] = 'songlist_search'; |
|
| 260 | + } |
|
| 261 | + if (count($perm_arr) > 0) { |
|
| 262 | + foreach ($perm_arr as $perm) { |
|
| 263 | + $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm)); |
|
| 264 | + $criteria->add(new \Criteria('gperm_itemid', (int)$obj->getVar('field_id'))); |
|
| 265 | + $criteria->add(new \Criteria('gperm_modid', (int)$GLOBALS['songlistModule']->getVar('mid'))); |
|
| 266 | + if (isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm])) { |
|
| 267 | + $perms = $grouppermHandler->getObjects($criteria); |
|
| 268 | + if (count($perms) > 0) { |
|
| 269 | + foreach (array_keys($perms) as $i) { |
|
| 270 | + $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
|
| 271 | + } |
|
| 272 | + } else { |
|
| 273 | + $groups = []; |
|
| 274 | + } |
|
| 275 | + foreach ($_REQUEST[$perm] as $grouoid) { |
|
| 276 | + $grouoid = (int)$grouoid; |
|
| 277 | + if (!isset($groups[$grouoid])) { |
|
| 278 | + $perm_obj = $grouppermHandler->create(); |
|
| 279 | + $perm_obj->setVar('gperm_name', $perm); |
|
| 280 | + $perm_obj->setVar('gperm_itemid', (int)$obj->getVar('field_id')); |
|
| 281 | + $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid')); |
|
| 282 | + $perm_obj->setVar('gperm_groupid', $grouoid); |
|
| 283 | + $grouppermHandler->insert($perm_obj); |
|
| 284 | + unset($perm_obj); |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
|
| 288 | + if (count($removed_groups) > 0) { |
|
| 289 | + $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $removed_groups) . ')', 'IN')); |
|
| 290 | + $grouppermHandler->deleteAll($criteria); |
|
| 291 | + } |
|
| 292 | + unset($groups); |
|
| 293 | + } else { |
|
| 294 | + $grouppermHandler->deleteAll($criteria); |
|
| 295 | + } |
|
| 296 | + unset($criteria); |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
| 300 | + redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - echo $obj->getHtmlErrors(); |
|
| 304 | - $form = FormController::getFieldForm($obj); |
|
| 305 | - $form->display(); |
|
| 306 | - break; |
|
| 307 | - case 'delete': |
|
| 308 | - $obj = $fieldHandler->get($_REQUEST['id']); |
|
| 309 | - if (!$obj->getVar('field_config')) { |
|
| 310 | - redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
| 311 | - } |
|
| 312 | - if (Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
| 313 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 314 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 315 | - } |
|
| 316 | - if ($fieldHandler->delete($obj)) { |
|
| 317 | - redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
| 318 | - } else { |
|
| 319 | - echo $obj->getHtmlErrors(); |
|
| 320 | - } |
|
| 321 | - } else { |
|
| 322 | - xoops_confirm(['ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'], $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title'))); |
|
| 323 | - } |
|
| 324 | - break; |
|
| 303 | + echo $obj->getHtmlErrors(); |
|
| 304 | + $form = FormController::getFieldForm($obj); |
|
| 305 | + $form->display(); |
|
| 306 | + break; |
|
| 307 | + case 'delete': |
|
| 308 | + $obj = $fieldHandler->get($_REQUEST['id']); |
|
| 309 | + if (!$obj->getVar('field_config')) { |
|
| 310 | + redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
| 311 | + } |
|
| 312 | + if (Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
| 313 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 314 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 315 | + } |
|
| 316 | + if ($fieldHandler->delete($obj)) { |
|
| 317 | + redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
| 318 | + } else { |
|
| 319 | + echo $obj->getHtmlErrors(); |
|
| 320 | + } |
|
| 321 | + } else { |
|
| 322 | + xoops_confirm(['ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'], $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title'))); |
|
| 323 | + } |
|
| 324 | + break; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | if (isset($template_main)) { |
| 328 | - $GLOBALS['xoopsTpl']->display("db:{$template_main}"); |
|
| 328 | + $GLOBALS['xoopsTpl']->display("db:{$template_main}"); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | xoops_cp_footer(); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use XoopsModules\Songlist\Helper; |
| 6 | 6 | use XoopsModules\Songlist\Form\FormController; |
| 7 | 7 | |
| 8 | -require_once __DIR__ . '/header.php'; |
|
| 8 | +require_once __DIR__.'/header.php'; |
|
| 9 | 9 | xoops_cp_header(); |
| 10 | 10 | |
| 11 | 11 | $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : (!empty($_REQUEST['id']) ? 'edit' : 'list'))); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | unset($criteria); |
| 37 | 37 | |
| 38 | 38 | $categories[0] = ['cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT]; |
| 39 | - if (count($category) > 0) { |
|
| 39 | + if (count($category)>0) { |
|
| 40 | 40 | foreach (array_keys($category) as $i) { |
| 41 | 41 | $categories[$category[$i]->getVar('cid')] = ['cid' => $category[$i]->getVar('cid'), 'name' => $category[$i]->getVar('name')]; |
| 42 | 42 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids']) > 0) { |
|
| 144 | + if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids'])>0) { |
|
| 145 | 145 | $oldweight = $_POST['oldweight']; |
| 146 | 146 | $oldcat = $_POST['oldcat']; |
| 147 | 147 | $oldcategories = $_POST['oldcategories']; |
@@ -149,25 +149,25 @@ discard block |
||
| 149 | 149 | $weight = $_POST['weight']; |
| 150 | 150 | $ids = []; |
| 151 | 151 | foreach ($_POST['field_ids'] as $field_id) { |
| 152 | - if ($oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
| 152 | + if ($oldweight[$field_id]!=$weight[$field_id] || $oldcat[$field_id]!=$category[$field_id] || count($oldcategories[$field_id])!=count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
| 153 | 153 | //if field has changed |
| 154 | - $ids[] = (int)$field_id; |
|
| 154 | + $ids[] = (int) $field_id; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | - if (count($ids) > 0) { |
|
| 157 | + if (count($ids)>0) { |
|
| 158 | 158 | $errors = []; |
| 159 | 159 | //if there are changed fields, fetch the fieldcategory objects |
| 160 | 160 | $fieldHandler = Helper::getInstance() |
| 161 | 161 | ->getHandler('Field'); |
| 162 | - $fields = $fieldHandler->getObjects(new \Criteria('field_id', '(' . implode(',', $ids) . ')', 'IN'), true); |
|
| 162 | + $fields = $fieldHandler->getObjects(new \Criteria('field_id', '('.implode(',', $ids).')', 'IN'), true); |
|
| 163 | 163 | foreach ($ids as $i) { |
| 164 | - $fields[$i]->setVar('field_weight', (int)$weight[$i]); |
|
| 164 | + $fields[$i]->setVar('field_weight', (int) $weight[$i]); |
|
| 165 | 165 | $fields[$i]->setVar('cids', $categories[$i]); |
| 166 | 166 | if (!$fieldHandler->insert($fields[$i])) { |
| 167 | 167 | $errors = array_merge($errors, $fields[$i]->getErrors()); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | - if (0 == count($errors)) { |
|
| 170 | + if (0==count($errors)) { |
|
| 171 | 171 | //no errors |
| 172 | 172 | redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
| 173 | 173 | } else { |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | if ($obj->getVar('field_edit') || $obj->getVar('field_show')) { |
| 259 | 259 | $perm_arr[] = 'songlist_search'; |
| 260 | 260 | } |
| 261 | - if (count($perm_arr) > 0) { |
|
| 261 | + if (count($perm_arr)>0) { |
|
| 262 | 262 | foreach ($perm_arr as $perm) { |
| 263 | 263 | $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm)); |
| 264 | - $criteria->add(new \Criteria('gperm_itemid', (int)$obj->getVar('field_id'))); |
|
| 265 | - $criteria->add(new \Criteria('gperm_modid', (int)$GLOBALS['songlistModule']->getVar('mid'))); |
|
| 264 | + $criteria->add(new \Criteria('gperm_itemid', (int) $obj->getVar('field_id'))); |
|
| 265 | + $criteria->add(new \Criteria('gperm_modid', (int) $GLOBALS['songlistModule']->getVar('mid'))); |
|
| 266 | 266 | if (isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm])) { |
| 267 | 267 | $perms = $grouppermHandler->getObjects($criteria); |
| 268 | - if (count($perms) > 0) { |
|
| 268 | + if (count($perms)>0) { |
|
| 269 | 269 | foreach (array_keys($perms) as $i) { |
| 270 | 270 | $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
| 271 | 271 | } |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | $groups = []; |
| 274 | 274 | } |
| 275 | 275 | foreach ($_REQUEST[$perm] as $grouoid) { |
| 276 | - $grouoid = (int)$grouoid; |
|
| 276 | + $grouoid = (int) $grouoid; |
|
| 277 | 277 | if (!isset($groups[$grouoid])) { |
| 278 | 278 | $perm_obj = $grouppermHandler->create(); |
| 279 | 279 | $perm_obj->setVar('gperm_name', $perm); |
| 280 | - $perm_obj->setVar('gperm_itemid', (int)$obj->getVar('field_id')); |
|
| 280 | + $perm_obj->setVar('gperm_itemid', (int) $obj->getVar('field_id')); |
|
| 281 | 281 | $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid')); |
| 282 | 282 | $perm_obj->setVar('gperm_groupid', $grouoid); |
| 283 | 283 | $grouppermHandler->insert($perm_obj); |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
| 288 | - if (count($removed_groups) > 0) { |
|
| 289 | - $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $removed_groups) . ')', 'IN')); |
|
| 288 | + if (count($removed_groups)>0) { |
|
| 289 | + $criteria->add(new \Criteria('gperm_groupid', '('.implode(',', $removed_groups).')', 'IN')); |
|
| 290 | 290 | $grouppermHandler->deleteAll($criteria); |
| 291 | 291 | } |
| 292 | 292 | unset($groups); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | unset($criteria); |
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | - $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
| 299 | + $url = $redirect_to_edit ? 'field.php?op=edit&id='.$obj->getVar('field_id') : 'field.php'; |
|
| 300 | 300 | redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | if (!$obj->getVar('field_config')) { |
| 310 | 310 | redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
| 311 | 311 | } |
| 312 | - if (Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
| 312 | + if (Request::hasVar('ok', 'REQUEST') && 1==$_REQUEST['ok']) { |
|
| 313 | 313 | if (!$GLOBALS['xoopsSecurity']->check()) { |
| 314 | 314 | redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 315 | 315 | } |