function widget($args, $instance) { ## and after_title are the array keys." - These are set up by the theme extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); $show = 3; ## WIDGET CODE GOES HERE global $wpdb; ## These are our own options //Show no of video in this widgets if ($instance['show']) { if (absint($instance['show'])) { $show = $instance['show']; } } ?> <!-- Recent videos For Getting The Page Id More and Video--> <?php $moreName = $wpdb->get_var('SELECT ID from ' . $wpdb->prefix . 'posts WHERE post_content LIKE "%[videomore]%" and post_status="publish" and post_type="page" limit 1'); ## For video category $sql = 'SELECT * FROM ' . $wpdb->prefix . 'hdflvvideoshare_playlist WHERE is_publish=1 LIMIT ' . $show; $features = $wpdb->get_results($sql); $moreCategories = $wpdb->get_results('SELECT COUNT(*) AS contus FROM ' . $wpdb->prefix . 'hdflvvideoshare_playlist WHERE is_publish=1'); $countCategories = $moreCategories[0]->contus; $div = ''; $more_videos_link = get_morepage_permalink($moreName, 'categories'); echo $before_widget; $div .= '<div id="videos-category" class="widget widget_categories sidebar-wrap "> <h3 class="widget-title"><a href="' . $more_videos_link . '">' . $title . '</a></h3>'; $div .= '<ul class="ulwidget clearfix">'; ## were there any posts found? if (!empty($features)) { ## posts were found, loop through them foreach ($features as $feature) { $fetched = $feature->playlist_name; $playlist_slugname = $feature->playlist_slugname; $playlist_id = $feature->pid; $div .= '<li>'; $playlist_url = get_playlist_permalink($moreName, $playlist_id, $playlist_slugname); $div .= '<a class="videoHname " href="' . $playlist_url . '">' . $fetched . '</a>'; $div .= '</li>'; } } else { $div .= '<li>' . __('No Categories', 'video_gallery') . '</li>'; } ## end list if ($show < $countCategories) { $div .= '<li><div class="right video-more"><a href="' . $more_videos_link . '">' . __('More Categories', 'video_gallery') . ' »</a></div></li>'; } $div .= '</ul></div>'; echo balanceTags($div); echo $after_widget; }
function widget($args, $instance) { // and after_title are the array keys." - These are set up by the theme extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); $show = 3; if (!empty($title)) { // WIDGET CODE GOES HERE $tt = 1; } global $wpdb, $wp_version, $popular_posts_current_ID; // These are our own options $options = get_option('widget_ContusFeaturedVideos'); // $title = $instance['title']; // Title in sidebar for widget if ($instance['show']) { if (absint($instance['show'])) { $show = $instance['show']; } } $excerpt = $options['excerpt']; // Showing the excerpt or not $exclude = $options['exclude']; // Categories to exclude $site_url = get_site_url(); $dir = dirname(plugin_basename(__FILE__)); $dirExp = explode('/', $dir); $dirPage = $dirExp[0]; ?> <!-- Recent videos --> <script type="text/javascript"> var baseurl; baseurl = '<?php echo $site_url; ?> '; folder = '<?php echo $dirPage; ?> ' </script> <!-- For Getting The Page Id More and Video--> <?php $moreName = $wpdb->get_var("SELECT ID FROM " . $wpdb->prefix . "posts WHERE post_content LIKE '%[videomore]%' AND post_status='publish' AND post_type='page' LIMIT 1"); $settings_result = $wpdb->get_row("SELECT ratingscontrol,view_visible FROM " . $wpdb->prefix . "hdflvvideoshare_settings WHERE settings_id='1'"); $more_videos_link = get_morepage_permalink($moreName, 'featured'); ?> <!-- For Featured Videos --> <?php echo $before_widget; $fetched = ''; $ratearray = array("nopos1", "onepos1", "twopos1", "threepos1", "fourpos1", "fivepos1"); $viewslang = __('Views', 'video_gallery'); $viewlang = __('View', 'video_gallery'); $div = '<div id="featured-videos" class="sidebar-wrap "> <h3 class="widget-title"><a href="' . $more_videos_link . '">' . $title . '</a></h3>'; $sql = "SELECT DISTINCT a.*,s.guid,b.playlist_id,p.playlist_name FROM " . $wpdb->prefix . "hdflvvideoshare a\r\n LEFT JOIN " . $wpdb->prefix . "hdflvvideoshare_med2play b ON a.vid=b.media_id\r\n LEFT JOIN " . $wpdb->prefix . "hdflvvideoshare_playlist p ON p.pid=b.playlist_id\r\n LEFT JOIN " . $wpdb->prefix . "posts s ON s.ID=a.slug\r\n WHERE a.publish='1' AND p.is_publish='1' AND a.featured='1' GROUP BY a.vid ORDER BY a.ordering ASC LIMIT " . $show; $features = $wpdb->get_results($sql); if (!empty($features)) { $playlist_id = $features[0]->playlist_id; $fetched = $features[0]->playlist_name; } $moreF = $wpdb->get_results("SELECT COUNT(a.vid) AS contus FROM " . $wpdb->prefix . "hdflvvideoshare a\r\n LEFT JOIN " . $wpdb->prefix . "hdflvvideoshare_med2play b ON a.vid=b.media_id LEFT JOIN " . $wpdb->prefix . "hdflvvideoshare_playlist p ON p.pid=b.playlist_id WHERE a.publish='1' AND p.is_publish='1' AND a.featured='1'"); $countF = $moreF[0]->contus; $div .= '<ul class="ulwidget">'; // were there any posts found? if (!empty($features)) { // posts were found, loop through them $image_path = str_replace('plugins/' . $dirPage . '/', 'uploads/videogallery/', APPTHA_VGALLERY_BASEURL); $_imagePath = APPTHA_VGALLERY_BASEURL . 'images' . DS; foreach ($features as $feature) { $file_type = $feature->file_type; // Video Type $imageFea = $feature->image; // VIDEO IMAGE $guid = get_video_permalink($feature->slug); // guid if ($imageFea == '') { // If there is no thumb image for video $imageFea = $_imagePath . 'nothumbimage.jpg'; } else { if ($file_type == 2 || $file_type == 5) { // For uploaded image if ($file_type == 2 && strpos($imageFea, '/')) { $imageFea = $imageFea; } else { $imageFea = $image_path . $imageFea; } } if ($file_type == 3) { $imageFea = $imageFea; } } $vidF = $feature->vid; $name = strlen($feature->name); // output to screen $div .= '<li class="clearfix sideThumb">'; $div .= '<div class="imgBorder"><a href="' . $guid . '" title="' . $feature->name . '"><img src="' . $imageFea . '" alt="' . $feature->name . '" class="img" width="120" height="80" style="width: 120px; height: 80px;" /></a>'; if ($feature->duration != 0.0) { $div .= '<span class="video_duration">' . $feature->duration . '</span>'; } $div .= '</div>'; $div .= '<div class="side_video_info"><a title="' . $feature->name . '" class="videoHname" href="' . $guid . '">'; if ($name > 25) { $div .= substr($feature->name, 0, 25) . '..'; } else { $div .= $feature->name; } $div .= '</a>'; $div .= '<div class="clear"></div>'; if ($settings_result->view_visible == 1) { if ($feature->hitcount > 1) { $viewlanguage = $viewslang; } else { $viewlanguage = $viewlang; } $div .= '<span class="views">' . $feature->hitcount . ' ' . $viewlanguage . '</span>'; } // Rating starts here if ($settings_result->ratingscontrol == 1) { if (isset($feature->ratecount) && $feature->ratecount != 0) { $ratestar = round($feature->rate / $feature->ratecount); } else { $ratestar = 0; } $div .= '<span class="ratethis1 ' . $ratearray[$ratestar] . '"></span>'; } // Rating ends here $div .= '<div class="clear"></div>'; $div .= '<div class="clear"></div>'; $div .= '</div>'; $div .= '</li>'; } } else { $div .= "<li>" . __('No Featured Videos', 'video_gallery') . "</li>"; } // end list if ($show < $countF || $show == $countF) { $div .= '<li><div class="video-more"><a href="' . $more_videos_link . '">' . __('More Videos', 'video_gallery') . ' »</a></div>'; $div .= '<div class="clear"></div></li>'; } else { $div .= '<li><div align="right"> </div></li>'; } $div .= '</ul></div>'; echo $div; // echo widget closing tag echo $after_widget; }
/** * Front end widget show function */ function widget($args, $instance) { // and after_title are the array keys." - These are set up by the theme extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); $show = 3; global $wpdb; // These are our own options $site_url = get_site_url(); $dir = dirname(plugin_basename(__FILE__)); $dirExp = explode('/', $dir); $dirPage = $dirExp[0]; ?> <!-- For Getting The Page Id More and Video--> <?php $moreName = $wpdb->get_var('SELECT ID FROM ' . $wpdb->prefix . 'posts WHERE post_content LIKE "%[videomore]%" AND post_status="publish" AND post_type="page" LIMIT 1'); $settings_result = $wpdb->get_row('SELECT ratingscontrol,view_visible FROM ' . $wpdb->prefix . 'hdflvvideoshare_settings WHERE settings_id=1'); $more_videos_link = get_morepage_permalink($moreName, 'random'); ?> <!-- Random videos --> <?php $fetched = ''; $ratearray = array('nopos1', 'onepos1', 'twopos1', 'threepos1', 'fourpos1', 'fivepos1'); $viewslang = __('Views', 'video_gallery'); $viewlang = __('View', 'video_gallery'); echo $before_widget; $div = '<div id="random-videos" class="sidebar-wrap "><h3 class="widget-title"><a href="' . $more_videos_link . '">' . $title . '</a></h3>'; //show no of video show if ($instance['show']) { if (absint($instance['show'])) { $show = $instance['show']; } } $sql = 'SELECT DISTINCT a.*,s.guid,b.playlist_id,p.playlist_name FROM ' . $wpdb->prefix . 'hdflvvideoshare a LEFT JOIN ' . $wpdb->prefix . 'hdflvvideoshare_med2play b ON a.vid=b.media_id LEFT JOIN ' . $wpdb->prefix . 'hdflvvideoshare_playlist p ON p.pid=b.playlist_id LEFT JOIN ' . $wpdb->prefix . 'posts s ON s.ID=a.slug WHERE a.publish=1 AND p.is_publish=1 GROUP BY a.vid ORDER BY RAND() LIMIT ' . $show; $posts = $wpdb->get_results($sql); if (!empty($posts)) { $fetched = $posts[0]->playlist_name; } $moreR = $wpdb->get_results('SELECT count(a.vid) as contus from ' . $wpdb->prefix . 'hdflvvideoshare a LEFT JOIN ' . $wpdb->prefix . 'hdflvvideoshare_med2play b ON a.vid=b.media_id LEFT JOIN ' . $wpdb->prefix . 'hdflvvideoshare_playlist p ON p.pid=b.playlist_id WHERE a.publish=1 AND p.is_publish=1 ORDER BY a.vid DESC'); $countR = $moreR[0]->contus; $div .= '<ul class="ulwidget">'; // were there any posts found? if (!empty($posts)) { // posts were found, loop through them $image_path = str_replace('plugins/' . $dirPage . '/', 'uploads/videogallery/', APPTHA_VGALLERY_BASEURL); $_imagePath = APPTHA_VGALLERY_BASEURL . 'images' . DS; foreach ($posts as $post) { $file_type = $post->file_type; // Video Type $image = $post->image; $guid = get_video_permalink($post->slug); // guid if ($image == '') { // If there is no thumb image for video $image = $_imagePath . 'nothumbimage.jpg'; } else { if ($file_type == 2 || $file_type == 5) { // For uploaded image if ($file_type == 2 && strpos($image, '/')) { $image = $image; } else { $image = $image_path . $image; } } if ($file_type == 3) { $image = $image; } } $name = strlen($post->name); // output to screen $div .= '<li class="clearfix sideThumb">'; $div .= '<div class="imgBorder"><a href="' . $guid . '" title="' . $post->name . '"><img src="' . $image . '" alt="' . $post->name . '" class="img" width="120" height="80" style="width: 120px; height: 80px;" /></a>'; if ($post->duration != 0.0) { $div .= '<span class="video_duration">' . $post->duration . '</span>'; } $div .= '</div>'; $div .= '<div class="side_video_info"><a title="' . $post->name . '" class="videoHname" href="' . $guid . '">'; if ($name > 25) { $div .= substr($post->name, 0, 25) . '..'; } else { $div .= $post->name; } $div .= '</a><div class="clear"></div>'; if ($settings_result->view_visible == 1) { if ($post->hitcount > 1) { $viewlanguage = $viewslang; } else { $viewlanguage = $viewlang; } $div .= '<span class="views">' . $post->hitcount . ' ' . $viewlanguage; $div .= '</span>'; } // Rating starts here if ($settings_result->ratingscontrol == 1) { if (isset($post->ratecount) && $post->ratecount != 0) { $ratestar = round($post->rate / $post->ratecount); } else { $ratestar = 0; } $div .= '<span class="ratethis1 ' . $ratearray[$ratestar] . '"></span>'; } // Rating ends here $div .= '<div class="clear"></div>'; $div .= '</div>'; $div .= '</li>'; } } else { $div .= '<li>' . __('No Random Videos', 'video_gallery') . '</li>'; } // end list if ($show < $countR || $show == $countR) { $more_videos_link = get_morepage_permalink($moreName, 'random'); $div .= '<li><div class="right video-more"><a href="' . $more_videos_link . '">' . __('More Videos', 'video_gallery') . ' »</a></div>'; $div .= '<div class="clear"></div></li>'; } $div .= '</ul></div>'; echo balanceTags($div); echo $after_widget; }
/** * function for show recent ,feature ,category and popular video in home page after player */ function home_thumb($type) { $recent_video_order = $this->_setting_related_video_count; if (function_exists('homeVideo') != true) { $TypeSet = $recent_video_order = ''; $recent_video_order = $this->_settingsData; switch ($type) { case 'popular': // GETTING POPULAR VIDEOS STARTS $TypeSet = $this->_settingsData->popular; // Popular Videos $rowF = $this->_settingsData->rowsPop; // get row of popular videos $colF = $this->_settingsData->colPop; // get column of popular videos $dataLimit = $rowF * $colF; $thumImageorder = 'w.hitcount DESC'; $where = ''; $TypeOFvideos = $this->home_thumbdata($thumImageorder, $where, $dataLimit); $CountOFVideos = $this->countof_home_thumbdata($thumImageorder, $where); $typename = __('Popular', 'video_gallery'); $type_name = 'popular'; $morePage = 'popular'; break; // Getting recent videoS // Getting recent videoS case 'recent': $TypeSet = $this->_settingsData->recent; // Recent Videos $rowF = $this->_settingsData->rowsRec; // get row of Recent videos $colF = $this->_settingsData->colRec; $dataLimit = $rowF * $colF; $where = ''; $thumImageorder = 'w.vid DESC'; $TypeOFvideos = $this->home_thumbdata($thumImageorder, $where, $dataLimit); $CountOFVideos = $this->countof_home_thumbdata($thumImageorder, $where); $typename = __('Recent', 'video_gallery'); $type_name = 'recent'; $morePage = 'recent'; break; case 'featured': $thumImageorder = 'w.ordering ASC'; $where = 'AND w.featured=1'; $TypeSet = $this->_settingsData->feature; // feature Videos $rowF = $this->_settingsData->rowsFea; // get row of feature videos $colF = $this->_settingsData->colFea; // get column of feature videos $dataLimit = $rowF * $colF; if ($recent_video_order == 'id') { $thumImageorder = 'w.vid ASC'; } elseif ($recent_video_order == 'hitcount') { $thumImageorder = 'w.' . $recent_video_order . ' DESC'; } elseif ($recent_video_order == 'default') { $thumImageorder = 'w.ordering ASC'; } else { $thumImageorder = 'w.ordering ASC'; } $player_color = unserialize($this->_settingsData->player_colors); $TypeOFvideos = $this->home_thumbdata($thumImageorder, $where, $dataLimit); $CountOFVideos = $this->countof_home_thumbdata($thumImageorder, $where); $typename = __('Featured', 'video_gallery'); $type_name = 'featured'; $morePage = 'featured'; break; case 'cat': if ($this->_settingsData->homecategory == 1) { $rowF = $this->_settingsData->rowCat; // category Videos $colF = $this->_settingsData->colCat; // get row of category videos $category_page = $this->_settingsData->category_page; // get column of category videos $dataLimit = $rowF * $colF; $player_color = unserialize($this->_settingsData->player_colors); $recent_video_order = $player_color['recentvideo_order']; if ($recent_video_order == 'id') { $thumImageorder = 'w.vid ASC'; } elseif ($recent_video_order == 'hitcount') { $thumImageorder = 'w.' . $recent_video_order . ' DESC'; } elseif ($recent_video_order == 'default') { $thumImageorder = 'w.ordering ASC'; } else { $thumImageorder = 'w.ordering ASC'; } $TypeOFvideos = $this->home_categoriesthumbdata($this->_pagenum, $category_page); $CountOFVideos = $this->countof_videocategories(); $typename = __('Video Categories', 'video_gallery'); return $this->categorylist($CountOFVideos, $TypeOFvideos, $this->_pagenum, $dataLimit, $category_page); } break; } $class = $div = ''; $ratearray = array('nopos1', 'onepos1', 'twopos1', 'threepos1', 'fourpos1', 'fivepos1'); $image_path = str_replace('plugins/' . $this->_plugin_name . '/', 'uploads/videogallery/', APPTHA_VGALLERY_BASEURL); if ($TypeSet) { // CHECKING FAETURED VIDEOS ENABLE STARTS $div = '<div class="video_wrapper" id="' . $type_name . '_video">'; $div .= '<style type="text/css" scoped> .video-block {margin-left:' . $this->_settingsData->gutterspace . 'px !important;float:left;} </style>'; if (!empty($TypeOFvideos)) { $div .= '<h2 class="video_header">' . $typename . ' ' . __('Videos', 'video_gallery') . '</h2>'; $videolist = 0; foreach ($TypeOFvideos as $video) { $duration[$videolist] = $video->duration; // VIDEO DURATION $imageFea[$videolist] = $video->image; // VIDEO IMAGE $file_type = $video->file_type; // Video Type $playlist_id[$videolist] = $video->pid; // VIDEO CATEGORY ID $fetched[$videolist] = $video->playlist_name; // CATEOGORY NAME $fetched_pslug[$videolist] = $video->playlist_slugname; // CATEOGORY slug NAME $guid[$videolist] = get_video_permalink($video->slug); // guid if ($imageFea[$videolist] == '') { // If there is no thumb image for video $imageFea[$videolist] = $this->_imagePath . 'nothumbimage.jpg'; } else { if ($file_type == 2 || $file_type == 5) { if (strpos($imageFea[$videolist], '/')) { $imageFea[$videolist] = $imageFea[$videolist]; } else { $imageFea[$videolist] = $image_path . $imageFea[$videolist]; } } elseif ($file_type == 3) { $imageFea[$videolist] = $imageFea[$videolist]; } } $vidF[$videolist] = $video->vid; // VIDEO ID $nameF[$videolist] = $video->name; // VIDEI NAME $hitcount[$videolist] = $video->hitcount; // VIDEO HITCOUNT $ratecount[$videolist] = $video->ratecount; // VIDEO RATECOUNT $rate[$videolist] = $video->rate; // VIDEO RATE $videolist++; } $div .= '<div class="video_thumb_content">'; $div .= '<ul class="video-block-container">'; for ($videolist = 0; $videolist < count($TypeOFvideos); $videolist++) { $class = '<div class="clear"></div>'; if ($videolist % $colF == 0 && $videolist != 0) { // COLUMN COUNT $div .= '</ul><div class="clear"></div><ul class="video-block-container">'; } $div .= '<li class="video-block">'; $div .= '<div class="video-thumbimg"><a href="' . $guid[$videolist] . '"><img src="' . $imageFea[$videolist] . '" alt="' . $nameF[$videolist] . '" class="imgHome" title="' . $nameF[$videolist] . '" /></a>'; if ($duration[$videolist] != '0:00') { $div .= '<span class="video_duration">' . $duration[$videolist] . '</span>'; } $div .= '</div>'; $div .= '<div class="vid_info"><a title="' . $nameF[$videolist] . '" href="' . $guid[$videolist] . '" class="videoHname"><span>'; if (strlen($nameF[$videolist]) > 30) { $div .= substr($nameF[$videolist], 0, 30) . '..'; } else { $div .= $nameF[$videolist]; } $div .= '</span></a>'; $div .= ''; if ($fetched[$videolist] != '' && $this->_settingsData->categorydisplay == 1) { $playlist_url = get_playlist_permalink($this->_mPageid, $playlist_id[$videolist], $fetched_pslug[$videolist]); $div .= '<a class="playlistName" href="' . $playlist_url . '"><span>' . $fetched[$videolist] . '</span></a>'; } if ($this->_settingsData->ratingscontrol == 1) { if (isset($ratecount[$videolist]) && $ratecount[$videolist] != 0) { $ratestar = round($rate[$videolist] / $ratecount[$videolist]); } else { $ratestar = 0; } $div .= '<span class="ratethis1 ' . $ratearray[$ratestar] . '"></span>'; } if ($this->_settingsData->view_visible == 1) { if ($hitcount[$videolist] > 1) { $viewlang = $this->_viewslang; } else { $viewlang = $this->_viewlang; } $div .= '<span class="video_views">' . $hitcount[$videolist] . ' ' . $viewlang; $div .= '</span>'; } $div .= '</div>'; $div .= '</li>'; } // FOR EACH ENDS $div .= '</ul>'; $div .= '</div>'; $div .= '<div class="clear"></div>'; if ($dataLimit < $CountOFVideos) { // PAGINATION STARTS $more_videos_link = get_morepage_permalink($this->_mPageid, $morePage); $div .= '<span class="more_title" ><a class="video-more" href="' . $more_videos_link . '">' . __('More Videos', 'video_gallery') . ' »</a></span>'; $div .= '<div class="clear"></div>'; } else { if ($dataLimit == $CountOFVideos) { $div .= '<div style="float:right"></div>'; } } // PAGINATION ENDS } else { $div .= __('No', 'video_gallery') . ' ' . $typename . ' ' . __('Videos', 'video_gallery'); } $div .= '</div>'; } // CHECKING FAETURED VIDEOS ENABLE ENDS return $div; } }
/** * Function to display recent ,feature ,category and popular video in home page after player * * @param unknown $type * @return Ambigous <$category_videos, string>|string */ function home_thumb($type) { global $playlistElement; /** Check homeVideo function is exists */ if (!function_exists('homeVideo')) { $TypeSet = $recent_video_order = $class = $divOutput = ''; $player_colors = $this->_player_colors; $recent_video_order = $player_colors['recentvideo_order']; /** Get popular, recent, featured video settings status and row, column values * Get home page category video settings status and row, column values * Call function to display home page category videos */ $where = ''; switch ($type) { case 'popular': $TypeSet = $this->_settingsData->popular; $rowF = $this->_settingsData->rowsPop; $colF = $this->_settingsData->colPop; $dataLimit = $rowF * $colF; $thumImageorder = 'w.hitcount DESC'; $typename = __('Popular', APPTHA_VGALLERY); $type_name = $morePage = 'popular'; break; case 'recent': $TypeSet = $this->_settingsData->recent; $rowF = $this->_settingsData->rowsRec; $colF = $this->_settingsData->colRec; $dataLimit = $rowF * $colF; $thumImageorder = 'w.vid DESC'; $typename = __('Recent', APPTHA_VGALLERY); $type_name = $morePage = 'recent'; break; case 'featured': $TypeSet = $this->_settingsData->feature; $rowF = $this->_settingsData->rowsFea; $colF = $this->_settingsData->colFea; $dataLimit = $rowF * $colF; $where = ' AND w.featured=1 '; $thumImageorder = getVideoOrder($recent_video_order); $typename = __('Featured', APPTHA_VGALLERY); $type_name = $morePage = 'featured'; break; case 'cat': if ($this->_settingsData->homecategory == 1) { $category_page = $this->_settingsData->category_page; $rowF = $this->_settingsData->rowCat; $colF = $this->_settingsData->colCat; $dataLimit = $rowF * $colF; $thumImageorder = getVideoOrder($recent_video_order); $typename = __('Video Categories', APPTHA_VGALLERY); } break; default: break; } if ($type == 'popular' || $type == 'recent' || $type == 'featured') { /** Get home page thumb data and get count of videos */ $TypeOFvideos = $this->home_thumbdata($thumImageorder, $where, $dataLimit); $CountOFVideos = $this->countof_home_thumbdata($thumImageorder, $where); } if ($type == 'cat') { /** Get home page category thumb data and get count of videos */ $TypeOFvideos = $this->home_categoriesthumbdata($this->_pagenum, $category_page); $CountOFVideos = getPlaylistCount(); /** Call function to display category videos in home page */ return $this->categorylist($CountOFVideos, $TypeOFvideos, $this->_pagenum, $dataLimit, $category_page, $thumImageorder); } if ($TypeSet) { /** Display thumbnail block strats */ $divOutput = '<div class="video_wrapper" id="' . $type_name . '_video">'; $divOutput .= '<style type="text/css" scoped> .video-block {margin-left:' . $this->_settingsData->gutterspace . 'px !important;float:left;} </style>'; if (!empty($TypeOFvideos)) { $userId = get_current_user_id(); $watchLaterVideoIds = getWatchLaterVideoIds($userId, $this->watchDetailsTable); /** Display videos title in home page */ $divOutput .= '<h2 class="video_header">' . $typename . ' ' . __('Videos', APPTHA_VGALLERY) . '</h2>'; $videolist = 0; foreach ($TypeOFvideos as $video) { /** Get video duration, image, filetype, slug, video id, * video name, view and rate count */ $videoId = $video->vid; $duration[$videolist] = $video->duration; $file_type = $video->file_type; $guid[$videolist] = get_video_permalink($video->slug); $imageFea[$videolist] = getImagesValue($video->image, $file_type, $video->amazon_buckets, ''); $nameF[$videolist] = $video->name; $ratecount[$videolist] = $video->ratecount; $rate[$videolist] = $video->rate; $hitcount[$videolist] = $video->hitcount; /** Get playlist id, name and slugname */ $playlist_id[$videolist] = $video->pid; $fetched[$videolist] = $video->playlist_name; $fetched_pslug[$videolist] = $video->playlist_slugname; $videolist++; } /** Code to display thumbs for popular / recent and featured videos */ $divOutput .= '<div class="video_thumb_content">'; $divOutput .= '<ul class="video-block-container">'; $playlistImg = APPTHA_VGALLERY_BASEURL . 'images/playlist.png'; $playlistCreateImg = APPTHA_VGALLERY_BASEURL . 'images/playlist_create.png'; $playlistSearchImg = APPTHA_VGALLERY_BASEURL . 'images/playlist_search.png'; /** Display video list container */ for ($videolist = 0; $videolist < count($TypeOFvideos); $videolist++) { $videoId = $TypeOFvideos[$videolist]->vid; if (in_array($videoId, $watchLaterVideoIds)) { $watchLaterImg = APPTHA_VGALLERY_BASEURL . 'images/accepted.png'; $watchLaterTitle = 'Added to Watch Later'; } else { $watchLaterImg = APPTHA_VGALLERY_BASEURL . 'images/watchlater2.png'; $watchLaterTitle = 'Add to Watch Later'; $clickEvent = 'onclick="watchLater(' . $videoId . ',this)"'; } $class = '<div class="clear"></div>'; if ($videolist % $colF == 0 && $videolist != 0) { $divOutput .= '</ul><div class="clear"></div><ul class="video-block-container">'; } $divOutput .= '<li class="video-block">'; /** Video thumb image display block starts */ $divOutput .= '<div class="video-thumbimg"><a href="' . $guid[$videolist] . '"><img src="' . $imageFea[$videolist] . '" alt="' . $nameF[$videolist] . '" class="imgHome" title="' . $nameF[$videolist] . '" /></a>'; if ($duration[$videolist]) { $divOutput .= '<span class="video_duration" >' . $duration[$videolist] . '</span>'; } $divOutput .= ' <span class="watchlaterIcon" ' . $clickEvent . ' ><img class="watchlaterImg" style="width:24px !important;height:24px !important;" src="' . $watchLaterImg . '" title="' . $watchLaterTitle . '"></span> <span class="playlistIcon" data-vid = ' . $videoId . '><img class="playlistIconImg" style="width:24px !important;height:24px !important;" src="' . $playlistImg . '" title="Add to playlist"></span>'; /** Display video details block starts */ $divOutput .= '</div><div class="vid_info"><a title="' . $nameF[$videolist] . '" href="' . $guid[$videolist] . '" class="videoHname"><span>' . limitTitle($nameF[$videolist]) . '</span></a>'; $divOutput .= ''; if ($fetched[$videolist] != '' && $this->_settingsData->categorydisplay == 1) { $playlist_url = get_playlist_permalink($this->_mPageid, $playlist_id[$videolist], $fetched_pslug[$videolist]); /** Display output videos */ $divOutput .= '<a class="playlistName" href="' . $playlist_url . '"><span>' . $fetched[$videolist] . '</span></a>'; } /** Display rating for video home page */ if ($this->_settingsData->ratingscontrol == 1) { $divOutput .= getRatingValue($rate[$videolist], $ratecount[$videolist], ''); } /** Display views for video home page */ if ($this->_settingsData->view_visible == 1) { $divOutput .= displayViews($hitcount[$videolist]); } /** Display video details block ends */ $divOutput .= '</div> </li>'; } $divOutput .= '</ul></div> <div class="clear"></div>'; /** Code to display more videos link for featured / popular/ recent videos */ if ($dataLimit < $CountOFVideos) { $more_videos_link = get_morepage_permalink($this->_mPageid, $morePage); /** Display more title for category */ $divOutput .= '<span class="more_title" ><a class="video-more" href="' . $more_videos_link . '">' . __('More Videos', APPTHA_VGALLERY) . ' »</a></span>'; $divOutput .= '<div class="clear"></div>'; } /** View more to the right */ if ($dataLimit == $CountOFVideos) { $divOutput .= '<div style="float:right"></div>'; } } else { $divOutput .= __('No', APPTHA_VGALLERY) . ' ' . $typename . ' ' . __('Videos', APPTHA_VGALLERY); } $divOutput .= '</div>'; } return $divOutput; } }
/** * Function to display popular / recent / featured / random widget videos * * @param unknown $title * @param unknown $type * @param unknown $videosData * @param unknown $show * @param unknown $pID * @param unknown $playlist_slugname * @return string */ function displayWidgetVideos($title, $type, $videosData, $show, $pID, $playlist_slugname, $watchLaterVideoIds) { global $wpdb; /** Get more page id , videos link for featured videos and plugin settings value */ $moreName = morePageID(); $more_videos_link = get_morepage_permalink($moreName, $type); $settings_result = getPluginSettings(); if ($type == 'watch history') { $postShortcodeContent = '[watch_history]'; } if ($type == 'watch later') { $postShortcodeContent = '[watch_later]'; } $watch_history_page = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_content=%s AND post_status=%s", "[watch_history]", "publish")); if (get_option('permalink_structure')) { $watchlink = get_site_url() . '/' . $watch_history_page[0]->post_name; } else { $watchlink = $watch_history_page[0]->guid; } $watch_later_page = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_content=%s AND post_status=%s", "[watch_later]", "publish")); if (get_option('permalink_structure')) { $watchLaterlink = get_site_url() . '/' . $watch_later_page[0]->post_name; } else { $watchLaterlink = $watch_later_page[0]->guid; } if ($type == 'watch history') { $more_videos_link = $watchlink; } if ($type == 'watch later') { $more_videos_link = $watchLaterlink; } /** Display widget tilte */ $div = '<div id="' . $type . '-videos" class="sidebar-wrap "> <h3 class="widget-title">'; /** Check type is realted */ if ($type == 'related') { /** Set title for widgets */ $link = $title; if (!empty($pID)) { /** Set link for related vidos title */ $link = '<a href=' . home_url() . '/?page_id=' . $moreName . '&playid=' . $pID . '>' . $title . '</a>'; } $div .= $link; } else { $div .= '<a href="' . $more_videos_link . '">' . $title . '</a>'; } $div .= ' </h3>'; /** Get count of videos */ $videosCount = getWidgetVideosCount($type, $pID); /** Display video thumbs */ $div .= '<ul class="ulwidget">'; /** Check videos are exist */ if (!empty($videosData)) { /** Looping widget video detials */ foreach ($videosData as $videodata) { $videoId = $videodata->vid; if (in_array($videoId, $watchLaterVideoIds)) { $watchLaterImg = APPTHA_VGALLERY_BASEURL . 'images/accepted.png'; $watchLaterTitle = 'Added to Watch Later'; $clickEvent = ''; } else { $watchLaterImg = APPTHA_VGALLERY_BASEURL . 'images/watchlater2.png'; $watchLaterTitle = 'Add to Watch Later'; $clickEvent = 'onclick="watchLater(' . $videoId . ',this)"'; } /** Get video file type */ $file_type = $videodata->file_type; /** Get video permalink */ $guid = get_video_permalink($videodata->slug); /** Get video name */ $name = limitTitle($videodata->name); /** Get thumb image url based on file type from helper */ $imageFea = $videodata->image; $imageFea = getImagesValue($videodata->image, $file_type, $videodata->amazon_buckets, ''); /** Output to screen */ $div .= '<li class="clearfix sideThumb">'; /** Display video thumb */ $div .= '<div class="imgBorder"> <a href="' . $guid . '" title="' . $videodata->name . '"> <img src="' . $imageFea . '" alt="' . $videodata->name . '" class="img" width="120" height="80" style="width: 120px; height: 80px;" /> </a>'; /** Display video duration */ if (!empty($videodata->duration) && $videodata->duration != 0.0) { $div .= '<span class="video_duration">' . $videodata->duration . '</span>'; } if ($type != 'watch history' && $type != 'watch later') { $div .= '<span class="watchlaterIcon" ' . $clickEvent . ' ><img class="watchlaterImg" style="width:24px !important;height:24px !important;" src="' . $watchLaterImg . '" title="' . $watchLaterTitle . '"></span>'; } $div .= '</div>'; /** Display video title */ $div .= '<div class="side_video_info"> <a title="' . $videodata->name . '" class="videoHname" href="' . $guid . '">' . $name . '</a> <div class="clear"></div>'; /** Check view is enabled in settings page */ if ($settings_result->view_visible == 1) { /** Display views count */ $div .= displayViews($videodata->hitcount); } /** Check rating is enabled in settings page */ if ($settings_result->ratingscontrol == 1) { /** Display ratingss count */ $div .= getRatingValue($videodata->rate, $videodata->ratecount, ''); } $div .= '<div class="clear"></div> <div class="clear"></div> </div></li>'; } } else { /** Display no videos link */ $div .= "<li>" . __('No', APPTHA_VGALLERY) . ' ' . ucfirst($type) . ' ' . __('Videos', APPTHA_VGALLERY) . "</li>"; } /** * Check number of videos to be shown count is less than or equal to total count */ $totalVideoCount = count($videosData); if ($show < $videosCount || $show == $videosCount) { /** If type is realted video, then display playlist URL as a link */ if ($type == 'related') { $playlist_url = get_playlist_permalink($moreName, $pID, $playlist_slugname); $div .= '<li><div class="right video-more"><a href="' . $playlist_url . '">'; } else { /** Else display more pages URL as a link */ $div .= '<li><div class="video-more"><a href="' . $more_videos_link . '">'; } $div .= __('More Videos', APPTHA_VGALLERY) . ' » </a> </div> <div class="clear"></div> </li>'; } else { $div .= '<li> <div align="right"></div> </li>'; } /** Return widget content */ return $div . '</ul></div>'; }
/** * Fucntion to display the catgoery list as a link * * @param unknown $args * @param unknown $instance */ function widget($args, $instanceCat) { /** Set default limit as 3 */ $show = 3; /** Get catgoery widget title */ $title = empty($instanceCat['title']) ? ' ' : apply_filters('widget_title', $instanceCat['title']); /** Catgoery Widget code starts here */ global $wpdb; /** These are our own options * Get "number of playlist" from backend option */ if ($instanceCat['show'] && absint($instanceCat['show'])) { $show = $instanceCat['show']; } /** Get playlist from db */ $features = getPlaylist(' playlist_order ASC ', $show); /** Count selected playlist */ $countCategories = getPlaylistCount(); /** Call function to get more page id */ $moreName = morePageID(); /** Get more categories link from helper */ $more_videos_link = get_morepage_permalink($moreName, 'categories'); /** Before widget functions category */ echo $args['before_widget']; /** Set category widget output */ $div = ''; $div .= '<div id="videos-category" class="widget widget_categories sidebar-wrap "> <h3 class="widget-title"><a href="' . $more_videos_link . '">' . $title . '</a></h3> <ul class="ulwidget clearfix">'; /** Check if playlist is exist */ if (!empty($features)) { /** If found, loop through them */ foreach ($features as $feature) { /** Get playlist name */ $fetched = $feature->playlist_name; /** Get playlist seo name */ $playlist_slugname = $feature->playlist_slugname; /** Get playlist id */ $playlist_id = $feature->pid; /** Get playlist page url */ $playlist_url = get_playlist_permalink($moreName, $playlist_id, $playlist_slugname); /** Display playlist name */ $div .= '<li>'; $div .= '<a class="videoHname " href="' . $playlist_url . '">' . $fetched . '</a>'; $div .= '</li>'; } } else { /** If no data, then display no categories message */ $div .= '<li>' . __('No Categories', APPTHA_VGALLERY) . '</li>'; } /** End category list */ if ($show < $countCategories) { $div .= '<li><div class="right video-more"><a href="' . $more_videos_link . '">' . __('More Categories', APPTHA_VGALLERY) . ' »</a></div></li>'; } $div .= '</ul></div>'; /** Display category widget */ echo $div; /** Display widget closing tag */ /** After widget functions category */ echo $args['after_widget']; }