<?php
/*
 * Copyright (c) 2014-2015 Aimy Extensions, Lingua-Systems Software GmbH
 *
 * http://www.aimy-extensions.com/
 *
 * License: GNU GPLv2, see LICENSE.txt within distribution and/or
 *          http://www.aimy-extensions.com/software-license.html
 */
 defined( '_JEXEC' ) or die(); class AimySitemapModelUrls extends JModelList { private $stats = null; public function __construct( $config = array() ) { if ( empty( $config[ 'filter_fields' ] ) ) { $config[ 'filter_fields' ] = array( 'id', 'a.id', 'url', 'a.url', 'title', 'a.title', 'priority', 'a.priority', 'mtime', 'a.mtime', 'lang', 'a.lang', 'state', 'a.state', 'lock', 'a.lock', 'changefreq', 'a.changefreq' ); } parent::__construct( $config ); } protected function getListQuery() { $db = $this->getDbo(); $q = $db->getQuery( true ); $order = $this->getState( 'list.ordering', 'a.url' ); $dir = $this->getState( 'list.direction', 'ASC' ); $state = $this->getState( 'filter.state', '' ); $search = $this->getState( 'filter.search', '' ); $lang = $this->getState( 'filter.lang', '' ); $lock = $this->getState( 'filter.lock', '' ); $q->select( $this->getState( 'list.select', 'a.id, a.url, a.title, a.priority, a.mtime, a.lang, ' . 'a.state, a.lock, a.changefreq' ) ) ->from( $db->quoteName( '#__aimysitemap' ) . ' AS a' ) ->order( $db->escape( $order . ' ' . $dir ) ); if ( is_numeric( $state ) ) { $q->where( $db->quoteName( 'a.state' ) . ' = ' . (int) $state ); } if ( ! empty( $search ) ) { $like = $db->quote( '%' . $db->escape( $search ) . '%' ); $q->where( '(' . $db->quoteName( 'a.url' ) . ' LIKE ' . $like . ' OR ' . $db->quoteName( 'a.title' ) . ' LIKE ' . $like . ')' ); } if ( ! empty( $lang ) ) { $q->where( $db->quoteName( 'a.lang' ) . ' = ' . $db->quote( $lang ) ); } if ( is_numeric( $lock ) ) { $q->where( $db->quoteName( 'a.lock' ) . ' = ' . (int) $lock ); } return $q; } protected function populateState( $order = null, $dir = null ) { $this->setState( 'filter.search', $this->getUserStateFromRequest( $this->context . '.filter.search', 'filter_search', '', 'string' ) ); $this->setState( 'filter.state', $this->getUserStateFromRequest( $this->context . '.filter.state', 'filter_state', '', 'string' ) ); parent::populateState( 'a.url', 'ASC' ); } public function reset_index() { return JFactory::getDbo()->truncateTable( '#__aimysitemap' ); } } 
