Server : LiteSpeed System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : alsaif ( 1057) PHP Version : 7.4.33 Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/alsaif/domains/alsaif.group/private_html/modules/mod_allvideosharegallery/ |
<?php
/*
* @version $Id: helper.php 3.5.0 2020-01-25 $
* @package All Video Share
* @copyright Copyright (C) 2012-2020 MrVinoth
* @license GNU/GPL http://www.gnu.org/licenses/gpl-2.0.html
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
class AllVideoShareGalleryHelper {
public static function getItems( $params ) {
$app = JFactory::getApplication();
$db = JFactory::getDBO();
if ( $params->get( 'type' ) == 'videos' ) {
$query = "SELECT * FROM #__allvideoshare_videos WHERE published=1";
$catid = self::getCatid( $params->get( 'category' ) );
if ( $catid ) {
$query .= ' AND (catid=' . $catid .' OR catids LIKE ' . $db->Quote( '% ' . $catid . ' %' ) . ')';
}
$slug = AllVideoShareUtils::getSlug();
if ( ! empty( $slug ) ) {
$query .= " AND slug!=" . $db->Quote( $slug );
}
if ( 'featured' == $params->get( 'orderby' ) || 1 == $params->get( 'featured', 0 ) ) {
$query .= " AND featured=1";
}
switch ( $params->get( 'orderby' ) ) {
case 'latest':
$query .= " ORDER BY id DESC";
break;
case 'latest_by_date':
$query .= " ORDER BY created_date DESC";
break;
case 'popular':
$query .= " ORDER BY views DESC";
break;
case 'random':
$query .= " ORDER BY RAND()";
break;
default:
$query .= " ORDER BY ordering";
}
} else {
$query = "SELECT * FROM #__allvideoshare_categories WHERE published=1 AND parent=0";
switch ( $params->get( 'orderby' ) ) {
case 'latest':
$query .= " ORDER BY id DESC";
break;
case 'random':
$query .= " ORDER BY RAND()";
break;
default:
$query .= " ORDER BY ordering";
}
}
$limit = (int) $params->get( 'rows' ) * (int) $params->get( 'columns' );
$query .= " LIMIT $limit";
$db->setQuery( $query );
$items = $db->loadObjectList();
return $items;
}
public static function hasMore( $params ) {
$hasMore = 0;
if ( (int) $params->get( 'more' ) ) {
$db = JFactory::getDBO();
$limit = (int) $params->get( 'rows' ) * (int) $params->get( 'columns' );
if ( $params->get( 'type' ) == 'videos' ) {
$query = "SELECT COUNT(id) FROM #__allvideoshare_videos WHERE published=1";
$catid = self::getCatid( $params->get( 'category' ) );
if ( $catid ) {
$query .= ' AND (catid=' . $catid .' OR catids LIKE ' . $db->Quote( '% ' . $catid . ' %' ) . ')';
}
$slug = AllVideoShareUtils::getSlug();
if ( ! empty( $slug ) ) {
$query .= " AND slug!=" . $db->Quote( $slug );
}
if ( 'featured' == $params->get( 'orderby' ) || 1 == $params->get( 'featured', 0 ) ) {
$query .= " AND featured=1";
}
} else {
$query = "SELECT COUNT(id) FROM #__allvideoshare_categories WHERE published=1 AND parent=0";
}
$query .= " LIMIT " . ( $limit + 1 );
$db->setQuery( $query );
$count = $db->loadResult();
$hasMore = ( $count > $limit ) ? 1 : 0;
}
return $hasMore;
}
public static function getCatid( $slug ) {
$name = '';
if ( ! empty( $slug ) ) {
$db = JFactory::getDBO();
$query = "SELECT id FROM #__allvideoshare_categories WHERE slug=" . $db->quote( $slug );
$db->setQuery( $query );
$name = $db->loadResult();
}
return $name;
}
}