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/components/com_allvideoshare/models/ |
<?php
/*
* @version $Id: search.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 AllVideoShareModelSearch extends AllVideoShareModel {
public function getItems( $limit ) {
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$limit = $app->getUserStateFromRequest( 'global.list.limit', 'limit', $limit, 'int' );
$limitstart = $app->input->get( 'limitstart', '0', 'INT' );
$limitstart = ( $limit != 0 ? ( floor( $limitstart / $limit ) * $limit ) : 0 );
$this->setState( 'limit', $limit );
$this->setState( 'limitstart', $limitstart );
$q = $app->getUserStateFromRequest( 'com_allvideoshare.search', 'q', '', 'string' );
$q = JString::strtolower( $q );
$searchWord = $db->Quote( '%' . $db->escape( $q, true ) . '%', false );
$query = "SELECT v.* FROM #__allvideoshare_videos AS v";
$query .= " LEFT JOIN #__allvideoshare_categories AS c ON v.catid=c.id";
$query .= " WHERE v.published=1 AND (v.title LIKE $searchWord OR v.tags LIKE $searchWord OR c.name LIKE $searchWord)";
$query .= " ORDER BY v.ordering";
$db->setQuery( $query, $limitstart, $limit );
$items = $db->loadObjectList();
return $items;
}
public function getTotal() {
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$q = $app->getUserStateFromRequest( 'com_allvideoshare.search', 'q', '', 'string' );
$q = JString::strtolower( $q );
$searchWord = $db->Quote( '%' . $db->escape( $q, true ) . '%', false );
$query = "SELECT COUNT(v.id) FROM #__allvideoshare_videos AS v";
$query .= " LEFT JOIN #__allvideoshare_categories AS c ON v.catid=c.id";
$query .= " WHERE v.published=1 AND (v.title LIKE $searchWord OR v.tags LIKE $searchWord OR c.name LIKE $searchWord)";
$db->setQuery( $query );
$total = $db->loadResult();
return $total;
}
public function getVideosPagination() {
jimport( 'joomla.html.pagination' );
$pagination = new JPagination( $this->getTotal(), $this->getState( 'limitstart' ), $this->getState( 'limit' ) );
return $pagination;
}
}