%PDF- %PDF-
Direktori : /home1/lightco1/luminero.com.au/administrator/components/com_cmc/models/ |
Current File : //home1/lightco1/luminero.com.au/administrator/components/com_cmc/models/ecommerce.php |
<?php /** * @package CMC * @author Compojoom <contact-us@compojoom.com> * @date 2016-04-15 * * @copyright Copyright (C) 2008 - 2016 compojoom.com - Daniel Dimitrov, Yves Hoppe. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('_JEXEC') or die(); jimport('joomla.application.component.modellist'); /** * Class CmcModelEcommerce * * @since __DEPLOY_VERSION__ */ class CmcModelEcommerce extends JModelList { /** * Method to auto-populate the model state. * * This method should only be called once per instantiation and is designed * to be called on the first call to the getState() method unless the model * configuration flag to ignore the request is set. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void */ protected function populateState($ordering = null, $direction = null) { $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); parent::populateState('s.name', 'asc'); } /** * Method to get a JDatabaseQuery object for retrieving the data set from a database. * * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set. */ public function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*')->from('#__cmc_shops AS s'); // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('s.id = ' . (int) substr($search, 3)); } else { $search = $db->q('%' . $db->escape($search, true) . '%'); $query->where('(s.name LIKE ' . $search . ')'); } } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); $query->order($db->escape($orderCol . ' ' . $orderDirn)); return $query; } /** * Method to get a table object, load it if necessary. * * @param string $type The table name. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * * @return JTable A JTable object * * @throws Exception */ public function getTable($type = 'Shops', $prefix = 'CmcTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } }