Your IP : 216.73.216.240
<?php
/*------------------------------------------------------------------------
# com_zhgooglemap - Zh GoogleMap
# ------------------------------------------------------------------------
# author: Dmitry Zhuk
# copyright: Copyright (C) 2011 zhuk.cc. All Rights Reserved.
# license: http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
# website: http://zhuk.cc
# Technical Support Forum: http://forum.zhuk.cc/
-------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
// import the Joomla modellist library
jimport('joomla.application.component.modellist');
/**
* ZhGoogleBufmrks Model
*/
class ZhGoogleMapModelMapBufmrklogs extends JModelList
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'h.id',
'kind', 'h.kind',
'title', 'h.title'
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Initialise variables.
parent::populateState('h.id','asc');
$app = JFactory::getApplication();
$search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
// Load the parameters.
$params = JComponentHelper::getParams('com_zhgooglemap');
$this->setState('params', $params);
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$user = JFactory::getUser();
$query->select('h.*'.
'');
$query->from('#__zhgooglemaps_log as h');
$query->where('h.extension=\'csv_file_marker\'');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search)) {
$search = $db->Quote('%'.$db->escape($search, true).'%', false);
$query->where('(h.title LIKE '.$search.' OR h.kind LIKE '.$search.')');
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if ($orderCol == 'ordering' || $orderCol == 'category_title') {
$orderCol = 'c.id';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
return $query;
}
}