/** * ContusVideoShortcodeView constructor function */ public function __construct() { parent::__construct(); /** Get current video id * and report send response */ $this->_vId = absint(filter_input(INPUT_GET, 'vid')); $this->_reportsent = filter_input(INPUT_POST, 'report_send'); /** Get post type, page post type * and video more page id */ $this->_post_type = filter_input(INPUT_GET, 'post_type'); $this->_page_post_type = get_post_type(get_the_ID()); $this->_mPageid = morePageID(); /** Get plugin site URL, * plugin images directory URL, * upload directory URL * and swf file URL */ $this->_site_url = get_site_url(); $this->_imagePath = getImagesDirURL(); $this->_uploadPath = getUploadDirURL(); $this->_swfPath = APPTHA_VGALLERY_BASEURL . 'hdflvplayer' . DS . 'hdplayer.swf'; /** Function to check * whether the SSL is enabled in site */ $this->_protocolURL = getPluginProtocol(); /** Object for home page controller */ $this->_contOBJ = new ContusVideoController(); }
/** * ContusHomeVideoView constructor starts */ public function __construct() { parent::__construct(); /** * Call plugin helper function * to get plugin settings * and more page id */ $this->_settingsData = getPluginSettings(); $this->_player_colors = unserialize($this->_settingsData->player_colors); $this->_mPageid = morePageID(); /** Get video id from request URL for home page */ $this->_vId = absint(filter_input(INPUT_GET, 'vid')); /** Get pid from request URL for home page */ $this->_pId = absint(filter_input(INPUT_GET, 'pid')); /** Get pagenum from request URL for home page */ $this->_pagenum = filter_input(INPUT_GET, 'pagenum'); /** Get Category column count from settings */ $this->_colCat = $this->_settingsData->colCat; /** Get featured videos data */ $this->_featuredvideodata = $this->home_featuredvideodata(); /** Get WordPress admin URL */ $this->_site_url = get_site_url(); /** Get WordPress site URL */ $this->_siteURL = home_url(); /** Set banner player swf path */ $this->_bannerswfPath = APPTHA_VGALLERY_BASEURL . 'hdflvplayer' . DS . 'hdplayer_banner.swf'; /** Set plugin player swf path */ $this->_swfPath = APPTHA_VGALLERY_BASEURL . 'hdflvplayer' . DS . 'hdplayer.swf'; /** * Get protocol URL, * uploads / videogallery * and plugin images directory path * from plugin helper */ $this->_imagePath = getImagesDirURL(); $this->_pluginProtocol = getPluginProtocol(); $this->_uploadPath = getUploadDirURL(); }
/** * This function is used to create search box for site * * @param unknown $args * @param unknown $instance */ function widget($args, $instance) { $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); /** Call helper function to get more page id from db */ $moreName = morePageID(); /** Search Widget starts and set title */ /** Before widget functions search */ echo $args['before_widget']; $searchVal = __('Video Search …', APPTHA_VGALLERY); /** Search form to search videos */ $div = '<div id="videos-search" class="widget_search sidebar-wrap search-form-container "><h3 class="widget-title">' . $title . '</h3> <form role="search" method="get" id="search-form" class="search-form searchform clearfix" action="' . home_url('/') . '" > <label class="screen-reader-text" >' . __('Search for:') . '</label> <input type="hidden" value="' . $moreName . '" name="page_id" id="page_id" /> <input type="text" class="s field search-field" placeholder="' . $searchVal . '" value="" name="video_search" id="s video_search" /> <input type="submit" class="search-submit submit" id="videosearchsubmit" value="' . __('Search', APPTHA_VGALLERY) . '" /> </form> </div>'; /** Display search videos widget */ echo $div; /** Search videos widget ends */ /** After widget functions search */ echo $args['after_widget']; }
/** * Fucntion to add permalink rules for plugin pages */ function add_my_rule() { global $wp; /** Get more page id */ $morepage_id = morePageID(); /** Set more pages URL */ $morepageURL = 'index.php?page_id=' . $morepage_id; /** If more parameter is exist, then rewrite URL */ $wp->add_query_var('more'); add_rewrite_rule('(.*)_videos', $morepageURL . '&more=$matches[1]', 'top'); /** If playlist_name parameter is exist, then rewrite URL for category page */ $wp->add_query_var('playlist_name'); add_rewrite_rule('categoryvideos\\/(.*)', $morepageURL . '&playlist_name=$matches[1]', 'top'); /** If user_name parameter is exist, then rewrite URL for user page */ $wp->add_query_var('user_name'); add_rewrite_rule('user\\/(.*)', $morepageURL . '&user_name=$matches[1]', 'top'); /** If video_search parameter is exist, then rewrite URL for video search results page */ $wp->add_query_var('video_search'); add_rewrite_rule('search/(.*)', $morepageURL . '&video_search=$matches[1]', 'top'); }
/** * 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>'; }
/** * Function to display category thumbs * * @param unknown $CountOfCatVideos * @param unknown $TypeOfCatvideos * @param unknown $pagenum * @param unknown $dataLimit * @param unknown $default_order * @return string */ function categorylist($CountOfCatVideos, $TypeOfCatvideos, $pagenum, $dataLimit, $default_order) { global $wpdb; $userId = get_current_user_id(); $watchLaterVideoIds = getWatchLaterVideoIds($userId, $this->watchDetailsTable); $div = ''; /** Calculating page number for category videos */ $pagenum = absint($pagenum) ? absint($pagenum) : 1; $div .= '<style> .video-block { margin-left:' . $this->_settingsData->gutterspace . 'px !important; } </style>'; foreach ($TypeOfCatvideos as $catList) { /** Fetch videos for every category * Get more page id */ $playLists = getCatVideos($catList->pid, $dataLimit, $default_order); $moreName = morePageID(); $playlistCount = count($playLists); $div .= '<div class="titleouter"> <h4 class="clear more_title">' . $catList->playlist_name . '</h4></div>'; if (!empty($playlistCount)) { $i = 0; $inc = 1; $div .= '<ul class="video-block-container">'; foreach ($playLists as $playList) { $this->watchLaterHelper($playList, $watchLaterVideoIds); /** To display the category videos thumb image and video duration */ $div .= '<li class="video-block"><div class="video-thumbimg"><a href="' . $this->guid . '" title="' . $playList->name . '" ><img src="' . $this->imageFea . '" alt="" class="imgHome" title="" /></a>'; if (!empty($this->duration) && $this->duration != '0:00') { $div .= '<span class="video_duration">' . $this->duration . '</span>'; } $div .= '<span class="watchlaterIcon" ' . $this->clickEvent . ' ><img class="watchlaterImg" style="width:24px !important;height:24px !important;" src="' . $this->watchLaterImg . '" title="' . $this->watchLaterTitle . '"></span> <span class="playlistIcon" data-vid = ' . $this->videoId . '><img class="playlistIconImg" style="width:24px !important;height:24px !important;" src="' . $this->playlistImg . '" title="Add to playlist"></span>'; /** To display playlist name as linkable */ $div .= '</div><div class="vid_info"><h5><a href="' . $this->guid . '" class="videoHname" title="' . $playList->name . '">' . limitTitle($playList->name) . '</a></h5>'; if ($this->_settingsData->categorydisplay == 1) { $div .= '<a class="playlistName" href="' . $playlist_more_link . '"><span>' . $catList->playlist_name . '</span></a>'; } if ($this->_settingsData->ratingscontrol == 1) { /** Rating starts here * for category videos */ $div .= getRatingValue($playList->rate, $playList->ratecount, ''); } /** Views starts here for category videos */ if ($this->_settingsData->view_visible == 1) { $div .= displayViews($playList->hitcount); } $div .= '</div></li>'; if ($i > $this->_perCat - 2) { break; } else { $i = $i + 1; } if ($inc % $this->_colCat == 0 && $inc != 0) { $div .= '</ul><div class="clear"></div><ul class="video-block-container">'; } $inc++; } $div .= '</ul>'; /** Calculate datalimit for video more page */ if ($this->_rowCat && $this->_colCat) { $dataLimit = $this->_perCat; } else { if ($this->_rowCat || $this->_colCat) { $dataLimit = ''; } else { $dataLimit = 8; } } /** Display more videos link for category thumbs */ if ($playlistCount > $dataLimit) { $div .= '<a class="video-more" href="' . $playlist_more_link . '">' . __('More Videos', APPTHA_VGALLERY) . '</a>'; } else { $div .= '<div align="clear"> </div>'; } } else { /** If there is no video for category */ $div .= '<div class="titleouter">' . __('No Videos for this Category', APPTHA_VGALLERY) . '</div>'; } } $div .= '<div class="clear"></div>'; /** Pagination starts - Call helper function to get pagination values for categories */ if ($dataLimit != 0) { $div .= paginateLinks($CountOfCatVideos, $dataLimit, $pagenum, '', ''); } /** Pagination ends */ /** Display videmore page content */ echo $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']; }