/** * Callback function for shortcode [tnt_video_list] */ function tntSCVideoList($attr) { $tntOptions = get_option('tntVideoManageOptions'); //Get cat ID $catID = $attr['id']; //Get column $columnOption = $tntOptions['columnPerRow']; $columns = isset($attr['col']) ? $attr['col'] : $columnOption; //Get video width $videoWidthOption = $tntOptions['videoWidth']; $vidWidth = isset($attr['width']) ? $attr['width'] : $videoWidthOption; //Get video height $videoHeightOption = $tntOptions['videoHeight']; $vidHeight = isset($attr['height']) ? $attr['height'] : $videoHeightOption; //Get Limit $limitOption = $tntOptions['limitPerPage']; $numLimit = isset($attr['limit']) ? $attr['limit'] : $limitOption; //Get Order and Order by $arrVideoOrder = array('videoid', 'addingdate', 'editingdate', 'alphabet', 'ordernumber'); $arrVideoOrderBy = array('asc', 'desc'); $orderOption = $tntOptions['videoOrder']; $orderbyOption = $tntOptions['videoOrderBy']; $vidOrder = isset($attr['order']) && in_array($attr['order'], $arrVideoOrder) ? $attr['order'] : $orderOption; $vidOrderBy = isset($attr['orderby']) && in_array($attr['orderby'], $arrVideoOrderBy) ? $attr['orderby'] : $orderbyOption; //Get videos by catID $args = array('catID' => $catID, 'isPublish' => 1); $videoList = TNT_Video::tntGetVideos($args); //Get all information for pagination $items = count($videoList); if ($items > 0) { $p = new TNT_Pagination(); $p->items($items); $p->limit($numLimit); // Limit entries per page $p->target($_SERVER["REQUEST_URI"]); $p->calculate(); // Calculates what to show $p->parameterName('paged'); $p->adjacents(1); //No. of page away from the current page $pageMix = explode('/page/', $_SERVER["REQUEST_URI"]); $page = ''; if (isset($pageMix[1])) { $page = (int) substr($pageMix[1], 0, 5); } else { if ($_GET['paged'] != '') { $page = $_GET['paged']; } else { $page = 1; } } $p->page = $page != null ? $page : 1; //Query for limit paging $limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit; } else { echo "No Record Found! Category ID was not existed!"; exit; } //Get videos by options switch ($vidOrder) { case 'addingdate': $vidOrder = 'date_created'; break; case 'editingdate': $vidOrder = 'date_modified'; break; case 'alphabet': $vidOrder = 'video_title'; break; case 'ordernumber': $vidOrder = 'video_order'; break; default: $vidOrder = 'video_id'; break; } $args = array('catID' => $catID, 'isPublish' => 1, 'limitText' => $limit, 'orderBy' => $vidOrder, 'order' => $vidOrderBy); $videoListLimit = TNT_Video::tntGetVideos($args); //Show template $vListToShow = ""; foreach ($videoListLimit as $video) { $v = ""; $videoTypeTitle = $video->video_type_title; $linkEmbed = ""; $thumbImg = ""; switch ($videoTypeTitle) { case "Youtube": $linkEmbed = tntGetYoutubeEmbedLink($video->video_link); $thumbImg = tntGetYoutubeThumbLink($video->video_link); break; case "Vimeo": $linkEmbed = tntGetVimeoEmbedLink($video->video_link); $thumbImg = tntGetVimeoThumbLink($video->video_link); break; case "DailyMotion": $linkEmbed = tntGetDailymotionEmbedLink($video->video_link); $thumbImg = tntGetDailymotionThumbLink($video->video_link); break; default: break; } $v['videoTitle'] = $video->video_title; $v['videoThumb'] = $thumbImg; $v['videoUrl'] = $video->video_link; $v['videoEmbed'] = $linkEmbed; $v['videoWidth'] = $vidWidth; $v['videoHeight'] = $vidHeight; $vListToShow[] = $v; } $tntPagi = $p->getOutput(); $view = tntTemplateVideoList($vListToShow, $tntPagi, $columns); return $view; }