XoopsModules25x /
xoopstube
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Module: XoopsTube |
||
| 5 | * |
||
| 6 | * You may not change or alter any portion of this comment or credits |
||
| 7 | * of supporting developers from this source code or any supporting source code |
||
| 8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | * |
||
| 10 | * PHP version 5 |
||
| 11 | * |
||
| 12 | * @category Module |
||
| 13 | * @package Xoopstube |
||
| 14 | * @author XOOPS Development Team |
||
| 15 | * @copyright 2001-2016 XOOPS Project (https://xoops.org) |
||
| 16 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 17 | * @link https://xoops.org/ |
||
| 18 | * @since 1.0.6 |
||
| 19 | */ |
||
| 20 | |||
| 21 | use Xmf\Request; |
||
| 22 | use XoopsModules\Xoopstube\{ |
||
| 23 | Common\LetterChoice, |
||
| 24 | Helper, |
||
| 25 | Thumbnails, |
||
| 26 | Tree, |
||
| 27 | Utility, |
||
| 28 | VideosHandler |
||
| 29 | }; |
||
| 30 | /** @var Helper $helper */ |
||
| 31 | |||
| 32 | $GLOBALS['xoopsOption']['template_main'] = 'xoopstube_viewcat.tpl'; |
||
| 33 | |||
| 34 | require_once __DIR__ . '/header.php'; |
||
| 35 | |||
| 36 | $helper = Helper::getInstance(); |
||
| 37 | |||
| 38 | // Begin Main page Heading etc |
||
| 39 | $cid = Request::getInt('cid', 0, 'GET'); //cleanRequestVars($_REQUEST, 'cid', 0); |
||
| 40 | $selectdate = Request::getString('selectdate', ''); //cleanRequestVars($_REQUEST, 'selectdate', ''); |
||
| 41 | $list = Request::getString('letter', ''); // cleanRequestVars($_REQUEST, 'letter', ''); |
||
| 42 | $start = Request::getInt('start', 0, 'GET'); //cleanRequestVars($_REQUEST, 'start', 0); |
||
| 43 | |||
| 44 | $catsort = $GLOBALS['xoopsModuleConfig']['sortcats']; |
||
| 45 | $mytree = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
| 46 | $arr = $mytree->getFirstChild($cid, $catsort); |
||
| 47 | |||
| 48 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||
| 49 | if (false === Utility::checkGroups($cid)) { |
||
| 50 | redirect_header('index.php', 1, _MD_XOOPSTUBE_MUSTREGFIRST); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | |||
| 55 | //require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 56 | |||
| 57 | //$xoTheme->addStylesheet('modules/' . $moduleDirName . '/assets/css/xtubestyle.css'); |
||
| 58 | |||
| 59 | $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
||
| 60 | //$xoTheme->addScript(XOOPSTUBE_URL . '/assets/js/magnific/jquery.magnific-popup.min.js'); |
||
| 61 | //$xoTheme->addStylesheet(XOOPSTUBE_URL . '/assets/js/magnific/magnific-popup.css'); |
||
| 62 | $xoTheme->addStylesheet(XOOPSTUBE_URL . '/assets/css/module.css'); |
||
| 63 | |||
| 64 | $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
||
| 65 | //$xoTheme->addScript(XOOPSTUBE_URL . '/assets/js/magnific/jquery.magnific-popup.min.js'); |
||
| 66 | //$xoTheme->addStylesheet(XOOPSTUBE_URL . '/assets/js/magnific/magnific-popup.css'); |
||
| 67 | $xoTheme->addStylesheet(XOOPSTUBE_URL . '/assets/css/module.css'); |
||
| 68 | |||
| 69 | $xoopsTpl->assign('mod_url', XOOPSTUBE_URL . '/'); |
||
| 70 | |||
| 71 | global $xoopsModule; |
||
| 72 | |||
| 73 | $myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||
| 74 | |||
| 75 | /* |
||
| 76 | $catarray['letters'] = Utility::getLetters(); |
||
| 77 | //$catarray['letters'] = Utility::getLettersChoice(); |
||
| 78 | $catarray['imageheader'] = Utility::renderImageHeader(); |
||
| 79 | $xoopsTpl->assign('catarray', $catarray); |
||
| 80 | */ |
||
| 81 | |||
| 82 | // Letter Choice Start --------------------------------------- |
||
| 83 | |||
| 84 | Helper::getInstance()->loadLanguage('common'); |
||
| 85 | $xoopsTpl->assign('letterChoiceTitle', constant('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC')); |
||
| 86 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 87 | $videosHandler = $helper->getHandler('Videos'); //new VideosHandler($db); |
||
| 88 | $choicebyletter = new LetterChoice($videosHandler, null, null, range('a', 'z'), 'letter'); |
||
| 89 | //$choicebyletter = new LetterChoice($videosHandler, null, null, range('a', 'z'), 'init', XOOPSTUBE_URL . '/letter.php'); |
||
| 90 | $catarray['letters'] = $choicebyletter->render(); |
||
| 91 | //$catarray['letters'] = $choicebyletter->render($alphaCount, $howmanyother); |
||
| 92 | |||
| 93 | $xoopsTpl->assign('catarray', $catarray); |
||
| 94 | |||
| 95 | // Letter Choice End ------------------------------------ |
||
| 96 | |||
| 97 | //$catArray['letters'] = Utility::getLettersChoice(); |
||
| 98 | //$catArray['letters'] = Utility::getLettersChoice(); |
||
| 99 | //$catArray['toolbar'] = xoopstube_toolbar(); |
||
| 100 | //$xoopsTpl->assign('catarray', $catArray); |
||
| 101 | |||
| 102 | //$catArray['imageheader'] = Utility::headerImage(); |
||
| 103 | ////$catArray['letters'] = Wfdownloads\Utility::lettersChoice(); |
||
| 104 | ///** @var \XoopsDatabase $db */ |
||
| 105 | //$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 106 | //downloadHandler = new Xoopstube\DownloadHandler($db); |
||
| 107 | //$choicebyletter = new LetterChoice(downloadHandler, null, null, range('a', 'z'), 'letter'); |
||
| 108 | //$catarray['letters'] = $choicebyletter->render(); |
||
| 109 | |||
| 110 | // Breadcrumb |
||
| 111 | $pathstring = '<li><a href="index.php">' . _MD_XOOPSTUBE_MAIN . '</a></li>'; |
||
| 112 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcat.php?op='); |
||
| 113 | $xoopsTpl->assign('category_path', $pathstring); |
||
| 114 | $xoopsTpl->assign('category_id', $cid); |
||
| 115 | |||
| 116 | // Display Sub-categories for selected Category |
||
| 117 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||
| 118 | $scount = 1; |
||
| 119 | foreach ($arr as $ele) { |
||
| 120 | if (false === Utility::checkGroups($ele['cid'])) { |
||
| 121 | continue; |
||
| 122 | } |
||
| 123 | $sub_arr = []; |
||
| 124 | $sub_arr = $mytree->getFirstChild($ele['cid'], $catsort); |
||
| 125 | $space = 1; |
||
| 126 | $chcount = 1; |
||
| 127 | $infercategories = ''; |
||
| 128 | foreach ($sub_arr as $sub_ele) { |
||
| 129 | // Subitem file count |
||
| 130 | $hassubitems = Utility::getTotalItems($sub_ele['cid']); |
||
| 131 | // Filter group permissions |
||
| 132 | if (true === Utility::checkGroups($sub_ele['cid'])) { |
||
| 133 | // If subcategory count > 5 then finish adding subcats to $infercategories and end |
||
| 134 | if ($chcount > 5) { |
||
| 135 | $infercategories .= '...'; |
||
| 136 | break; |
||
| 137 | } |
||
| 138 | if ($space > 0) { |
||
| 139 | $infercategories .= ', '; |
||
| 140 | } |
||
| 141 | |||
| 142 | $infercategories .= '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $sub_ele['cid'] . '">' . htmlspecialchars($sub_ele['title']) . '</a> (' . $hassubitems['count'] . ')'; |
||
| 143 | ++$space; |
||
| 144 | ++$chcount; |
||
| 145 | } |
||
| 146 | } |
||
| 147 | $totalvideos = Utility::getTotalItems($ele['cid']); |
||
| 148 | $indicator = Utility::isNewImage($totalvideos['published']); |
||
| 149 | |||
| 150 | // This code is copyright WF-Projects |
||
| 151 | // Using this code without our permission or removing this code voids the license agreement |
||
| 152 | |||
| 153 | $_image = $ele['imgurl'] ? urldecode($ele['imgurl']) : ''; |
||
| 154 | if ('' !== $_image && $GLOBALS['xoopsModuleConfig']['usethumbs']) { |
||
| 155 | $_thumb_image = new Thumbnails($_image, $GLOBALS['xoopsModuleConfig']['catimage'], 'thumbs'); |
||
| 156 | if ($_thumb_image) { |
||
| 157 | $_thumb_image->setUseThumbs(1); |
||
| 158 | $_thumb_image->setImageType('gd2'); |
||
| 159 | $_image = $_thumb_image->createThumbnail($GLOBALS['xoopsModuleConfig']['shotwidth'], $GLOBALS['xoopsModuleConfig']['shotheight'], $GLOBALS['xoopsModuleConfig']['imagequality'], $GLOBALS['xoopsModuleConfig']['updatethumbs'], $GLOBALS['xoopsModuleConfig']['imageAspect']); |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | if (empty($_image) || '' == $_image) { |
||
| 164 | $imgurl = $indicator['image']; |
||
| 165 | $_width = 33; |
||
| 166 | $_height = 24; |
||
| 167 | } else { |
||
| 168 | $imgurl = "{$GLOBALS['xoopsModuleConfig']['catimage']}/$_image"; |
||
| 169 | $_width = $GLOBALS['xoopsModuleConfig']['shotwidth']; |
||
| 170 | $_height = $GLOBALS['xoopsModuleConfig']['shotheight']; |
||
| 171 | } |
||
| 172 | /* |
||
| 173 | * End |
||
| 174 | */ |
||
| 175 | |||
| 176 | $xoopsTpl->append( |
||
| 177 | 'subcategories', |
||
| 178 | [ |
||
| 179 | 'title' => htmlspecialchars($ele['title']), |
||
| 180 | 'id' => $ele['cid'], |
||
| 181 | 'image' => XOOPS_URL . "/$imgurl", |
||
| 182 | 'width' => $_width, |
||
| 183 | 'height' => $_height, |
||
| 184 | 'infercategories' => $infercategories, |
||
| 185 | 'totalvideos' => $totalvideos['count'], |
||
| 186 | 'count' => $scount, |
||
| 187 | 'alttext' => $ele['description'], |
||
| 188 | ] |
||
| 189 | ); |
||
| 190 | ++$scount; |
||
| 191 | } |
||
| 192 | } |
||
| 193 | |||
| 194 | // Show Description for Category listing |
||
| 195 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . $cid; |
||
| 196 | $head_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql)); |
||
| 197 | $html = isset($head_arr['nohtml']) ? 0 : 1; |
||
| 198 | $smiley = isset($head_arr['nosmiley']) ? 0 : 1; |
||
| 199 | $xcodes = isset($head_arr['noxcodes']) ? 0 : 1; |
||
| 200 | $images = isset($head_arr['noimages']) ? 0 : 1; |
||
| 201 | $breaks = isset($head_arr['nobreak']) ? 1 : 0; |
||
| 202 | $tempDescription = isset($head_arr['description']) ? $head_arr['description'] : ''; |
||
| 203 | $description = &$myts->displayTarea($tempDescription, $html, $smiley, $xcodes, $images, $breaks); |
||
| 204 | $xoopsTpl->assign('description', $description); |
||
| 205 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 206 | $moduleHandler = xoops_getHandler('module'); |
||
| 207 | $versioninfo = $moduleHandler->get($xoopsModule->getVar('mid')); |
||
| 208 | if (isset($head_arr['title']) && $head_arr['title'] !== '') { |
||
| 209 | $xoopsTpl->assign('xoops_pagetitle', $versioninfo->getInfo('name') . ': ' . $head_arr['title']); |
||
| 210 | } else { |
||
| 211 | $xoopsTpl->assign('xoops_pagetitle', $versioninfo->getInfo('name')); |
||
| 212 | } |
||
| 213 | |||
| 214 | if (isset($head_arr['client_id']) && (int)$head_arr['client_id'] > 0) { |
||
| 215 | $catarray['imageheader'] = Utility::getBannerFromClientId($head_arr['client_id']); |
||
| 216 | } elseif (isset($head_arr['banner_id']) && (int)$head_arr['banner_id'] > 0) { |
||
| 217 | $catarray['imageheader'] = Utility::getBannerFromBannerId($head_arr['banner_id']); |
||
| 218 | } else { |
||
| 219 | $catarray['imageheader'] = Utility::renderImageHeader(); |
||
| 220 | } |
||
| 221 | $xoopsTpl->assign('catarray', $catarray); |
||
| 222 | // Extract linkload information from database |
||
| 223 | $xoopsTpl->assign('show_category_title', true); |
||
| 224 | |||
| 225 | $orderby0 = (isset($_REQUEST['orderby']) |
||
| 226 | && !empty($_REQUEST['orderby'])) ? Utility::convertOrderByIn(htmlspecialchars($_REQUEST['orderby'], ENT_QUOTES | ENT_HTML5)) : Utility::convertOrderByIn($GLOBALS['xoopsModuleConfig']['linkxorder']); |
||
| 227 | $orderby = Request::getString('orderby', '', 'GET') ? Utility::convertOrderByIn(Request::getString('orderby', '', 'GET')) : Utility::convertOrderByIn($GLOBALS['xoopsModuleConfig']['linkxorder']); |
||
| 228 | |||
| 229 | if ($selectdate) { |
||
| 230 | $d = date('j', $selectdate); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 231 | $m = date('m', $selectdate); |
||
| 232 | $y = date('Y', $selectdate); |
||
| 233 | |||
| 234 | $stat_begin = mktime(0, 0, 0, $m, $d, $y); |
||
| 235 | $stat_end = mktime(23, 59, 59, $m, $d, $y); |
||
| 236 | |||
| 237 | $query = ' WHERE published>=' . $stat_begin . ' AND published<=' . $stat_end . ' AND (expired=0 OR expired>' . time() . ') AND offline=0 AND cid>0'; |
||
| 238 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . $query . ' ORDER BY ' . $orderby; |
||
| 239 | $result = $GLOBALS['xoopsDB']->query($sql, $GLOBALS['xoopsModuleConfig']['perpage'], $start); |
||
| 240 | |||
| 241 | $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . $query; |
||
| 242 | [$count] = $GLOBALS['xoopsDB']->fetchRow($GLOBALS['xoopsDB']->query($sql)); |
||
| 243 | |||
| 244 | $list_by = 'selectdate=' . $selectdate; |
||
| 245 | |||
| 246 | $xoopsTpl->assign('is_selectdate', true); |
||
| 247 | $xoopsTpl->assign('selected_date', Utility::getTimestamp(formatTimestamp($selectdate, $GLOBALS['xoopsModuleConfig']['dateformat']))); |
||
| 248 | } elseif ($list) { |
||
| 249 | $query = " WHERE title LIKE '$list%' AND (published>0 AND published<=" . time() . ') AND (expired=0 OR expired>' . time() . ') AND offline=0 AND cid>0'; |
||
| 250 | |||
| 251 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . $query . ' ORDER BY ' . $orderby; |
||
| 252 | $result = $GLOBALS['xoopsDB']->query($sql, $GLOBALS['xoopsModuleConfig']['perpage'], $start); |
||
| 253 | |||
| 254 | $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . $query; |
||
| 255 | [$count] = $GLOBALS['xoopsDB']->fetchRow($GLOBALS['xoopsDB']->query($sql)); |
||
| 256 | $list_by = "letter=$list"; |
||
| 257 | } else { |
||
| 258 | $query = 'WHERE a.published>0 AND a.published<=' . time() . ' AND (a.expired=0 OR a.expired>' . time() . ') AND a.offline=0' . ' AND (b.cid=a.cid OR (a.cid=' . $cid . ' OR b.cid=' . $cid . '))'; |
||
| 259 | |||
| 260 | $sql = 'SELECT DISTINCT a.* FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' a LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('xoopstube_altcat') . ' b ON b.lid=a.lid ' . $query . ' ORDER BY ' . $orderby; |
||
| 261 | $result = $GLOBALS['xoopsDB']->query($sql, $GLOBALS['xoopsModuleConfig']['perpage'], $start); |
||
| 262 | |||
| 263 | |||
| 264 | // $sql2 = 'SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' a LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('xoopstube_altcat') . ' b ON b.lid=a.lid ' . $query; |
||
| 265 | // [$count] = $GLOBALS['xoopsDB']->fetchRow($GLOBALS['xoopsDB']->query($sql2)); |
||
| 266 | |||
| 267 | $count = $result->num_rows; |
||
| 268 | |||
| 269 | $order = Utility::convertOrderByOut($orderby); |
||
| 270 | $list_by = 'cid=' . $cid . '&orderby=' . $order; |
||
| 271 | $xoopsTpl->assign('show_category_title', false); |
||
| 272 | } |
||
| 273 | $pagenav = new \XoopsPageNav($count, $GLOBALS['xoopsModuleConfig']['perpage'], $start, 'start', $list_by); |
||
| 274 | |||
| 275 | // Show videos |
||
| 276 | if ($count > 0) { |
||
| 277 | $moderate = 0; |
||
| 278 | |||
| 279 | while (false !== ($video_arr = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 280 | if (true === Utility::checkGroups($video_arr['cid'])) { |
||
| 281 | require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/videoloadinfo.php'; |
||
| 282 | $xoopsTpl->append('video', $video); |
||
| 283 | } |
||
| 284 | } |
||
| 285 | |||
| 286 | unset($video_arr); |
||
| 287 | |||
| 288 | // Show order box |
||
| 289 | $xoopsTpl->assign('show_videos', false); |
||
| 290 | if ($count > 1 && 0 !== $cid) { |
||
| 291 | $xoopsTpl->assign('show_videos', true); |
||
| 292 | $orderbyTrans = Utility::convertOrderByTrans($orderby); |
||
| 293 | $xoopsTpl->assign('lang_cursortedby', sprintf(_MD_XOOPSTUBE_CURSORTBY, Utility::convertOrderByTrans($orderby))); |
||
| 294 | $orderby = Utility::convertOrderByOut($orderby); |
||
| 295 | } |
||
| 296 | |||
| 297 | // Screenshots display |
||
| 298 | $xoopsTpl->assign('show_screenshot', false); |
||
| 299 | if (isset($GLOBALS['xoopsModuleConfig']['screenshot']) && 1 == $GLOBALS['xoopsModuleConfig']['screenshot']) { |
||
| 300 | $xoopsTpl->assign('shotwidth', $GLOBALS['xoopsModuleConfig']['shotwidth']); |
||
| 301 | $xoopsTpl->assign('shotheight', $GLOBALS['xoopsModuleConfig']['shotheight']); |
||
| 302 | $xoopsTpl->assign('show_screenshot', true); |
||
| 303 | } |
||
| 304 | |||
| 305 | // Nav page render |
||
| 306 | $page_nav = $pagenav->renderNav(); |
||
| 307 | $istrue = (isset($page_nav) && !empty($page_nav)); |
||
| 308 | $xoopsTpl->assign('page_nav', $istrue); |
||
| 309 | $xoopsTpl->assign('pagenav', $page_nav); |
||
| 310 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||
| 311 | } |
||
| 312 | |||
| 313 | $xoopsTpl->assign('cat_columns', $GLOBALS['xoopsModuleConfig']['catcolumns']); |
||
| 314 | |||
| 315 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 316 |