FundacionLQDVI_WebCongresos/www/administrator/components/com_sql2excel/models/sqlexcelschedules.php

183 lines
4.7 KiB
PHP

<?php
/*
* @component SQL 2 Excel Component
* @copyright Copyright (C) Joomla-R-Us, joomla-r-us.com
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
*/
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.model' );
class Sql2excelModelSqlexcelschedules extends JModel
{
var $_data = null;
var $_pagination = null;
function __construct()
{
parent::__construct();
global $mainframe, $option;
// Get the pagination request variables
$limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
// In case limit has been changed, adjust limitstart accordingly
$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Returns the query
* @return string The query to be used to retrieve the rows from the database
*/
function _buildQuery()
{
global $mainframe;
$where = array();
$context = 'com_sql2excel.sqlexcelschedules.list.';
// Get sort order
$filter_Column = $mainframe->getUserStateFromRequest(
$context.'filter_order',
'filter_order',
'a.ordering',
'cmd' );
$sort_Order = $mainframe->getUserStateFromRequest(
$context.'filter_order_Dir',
'filter_order_Dir',
'',
'word' );
if ( $filter_Column == '' ) { $filter_Column = 'a.ordering'; }
// Published / Unpublished State
$filter_state = $mainframe->getUserStateFromRequest(
$context.'filter_state',
'filter_state',
'',
'word' );
if ( $filter_state ) {
if ( $filter_state == 'P' ) {
$where[] = 'a.published = 1';
} else if ($filter_state == 'U' ) {
$where[] = 'a.published = 0';
}
}
// Action Filter
$filter_action = $mainframe->getUserStateFromRequest(
$context.'filter_action',
'filter_action',
'',
'word' );
// Get search string
$searchStr = $mainframe->getUserStateFromRequest(
$context.'search',
'search',
'',
'string' );
$searchStr = JString::strtolower( $searchStr );
if ($searchStr) {
$where[] = 'LOWER(a.title) LIKE '.$this->_db->Quote('%'.$searchStr.'%');
}
if ( $where ) {
$where = ' WHERE ' . implode(' AND ', $where);
} else {
$where = '';
}
$sectionName = "CONCAT('<a href=\"/administrator/index.php?option=com_sql2excel&controller=sqlexcelsection&task=edit&cid[]=',c.id,'\">', c.title, '</a>') AS sectionname ";
$categoryName = "CONCAT('<a href=\"/administrator/index.php?option=com_sql2excel&controller=sqlexcelcategory&task=edit&cid[]=',d.id,'\">', d.title, '</a>') AS categoryname ";
$query = " SELECT a.* "
. " FROM #__sql2excel_schedules a "
. $where
. " ORDER BY " . $filter_Column . " " . $sort_Order;
return $query;
}
/**
* @return array Array of objects containing the data from the database
*/
function getData()
{
if (empty($this->_data)){
$query = $this->_buildQuery();
$this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
}
return $this->_data;
}
/**
* @return number of objects
*/
function getTotal()
{
if (empty($this->_total)) {
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
/**
* @return pagination for the recordset
*/
function getPagination()
{
if (empty($this->_pagination)) {
jimport('joomla.html.pagination');
$this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
/**
* Method to get list of action types
* @return select list (html)
*/
function getActionFilter($selected)
{
$mytypes[] = JHTML::_('select.option', '0', JText::_( '-- Select Action --'));
$mytypes[] = JHTML::_('select.option', '20', JText::_( 'Update Cache for All Workbooks'));
$mytypes[] = JHTML::_('select.option', '10', JText::_( 'Update Cache for Selected Workbooks'));
$mytypes[] = JHTML::_('select.option', '30', JText::_( 'Send Email with Links to Workbooks'));
$mytypes[] = JHTML::_('select.option', '40', JText::_( 'Send Email with Attached Workbooks'));
$mytypes[] = JHTML::_('select.option', '50', JText::_( 'Run SQL'));
$typesOpt = JHTML::_( 'select.genericlist',
$mytypes,
'filter_action',
'class="inputbox" size="1" onchange="document.adminForm.submit();"' ,
'value',
'text',
$selected );
return $typesOpt;
}
}