Your IP : 10.10.0.253


Current Path : /var/www/modules/mod_yendifvideoshare_videos/
Upload File :
Current File : /var/www/modules/mod_yendifvideoshare_videos/helper.php

<?php
/**
 * @version    1.2.9
 * @package    Com_YendifVideoShare
 * @author     PluginsWare Interactive Pvt. Ltd <admin@yendifplayer.com>
 * @copyright  Copyright (c) 2012 - 2021 PluginsWare Interactive Pvt. Ltd. All Rights Reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
 
// Prevent direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

class YendifVideoShareVideosHelper {
	
	public static function getItems( $params, $check_publishing_options, $limit ) {	
		$db = JFactory::getDbo();

		$query  = 'SELECT v.*, c.name as category, c.alias as catalias FROM #__yendifvideoshare_videos AS v';	
		$query .= ' LEFT JOIN #__yendifvideoshare_categories AS c ON v.catid = c.id';		
			
		$where = array();
		
		$where[] = 'v.published=1';
		
		if ( $check_publishing_options ) {
			$date = JFactory::getDate();			
			
			$nowDate  = $db->quote( $date->toSql() );
			$nullDate = $db->quote( $db->getNullDate() );
				 
		 	$where[] = "(v.published_up = " . $nullDate . " OR v.published_up <= " . $nowDate . ')';
			$where[] = "(v.published_down = " . $nullDate . " OR v.published_down >= " . $nowDate . ')';											 			
		}				
		
		$catid = $params->get( 'catid', 0 );
		if ( $catid > 0 ) {
			$where[] = 'v.catid=' . $catid;
		}
			
		if ( $params->get( 'filterby' ) == 'featured' ) {
			$where[] = 'v.featured=1';
		}
		
		$where = count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '';		 
		$query .= $where;			
		
		switch ( $params->get('orderby') ) {	
			case 'latest':
				$query .= ' ORDER BY v.created_date DESC';
				break;	 	
			case 'most_viewed':
				$query .= ' ORDER BY v.views DESC';
				break;
			case 'most_rated':
				$query .= ' ORDER BY v.rating DESC';
				break;
			case 'date_added':
				$query .= ' ORDER BY v.created_date ASC';
				break;
			case 'a_z':
				$query .= ' ORDER BY v.title ASC';
				break;
			case 'z_a':
				$query .= ' ORDER BY v.title DESC';
				break;
			case 'random':
				$query .= ' ORDER BY RAND()';
				break;
			case 'ordering':
				$query .= ' ORDER BY v.catid, v.ordering';
				break;
			default:
				$query .= ' ORDER BY v.id DESC';
		}
		
		$query .= ' LIMIT ' . $limit;

		$db->setQuery( $query );
       	$items = $db->loadObjectList();
			
        return $items;		
    }
	
	public static function getCategory( $catid ) {	
		$db = JFactory::getDbo();

		$query = 'SELECT * FROM #__yendifvideoshare_categories WHERE id=' . (int) $catid;

	 	$db->setQuery( $query );
       	$item = $db->loadObject();
			
        return $item;	
	}
		
}