| Current Path : /home/s/u/n/sunflowe/www2/j15/administrator/components/com_easycaptcha/models/ |
| Current File : /home/s/u/n/sunflowe/www2/j15/administrator/components/com_easycaptcha/models/easycaptcha.php |
<?php
/**
* @version $Id: easycaptcha.php 636 2008-03-18 09:01:06Z snipersister $
* @package EasyCaptcha
* @link http://www.easy-joomla.org
* @license GNU/GPL
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.model' );
class EasyCaptchaModelEasyCaptcha extends JModel
{
var $_total;
var $_pagination;
var $_version;
function __construct()
{
parent::__construct();
global $mainframe;
$config = JFactory::getConfig();
// Get the pagination request variables
$limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest( 'easycaptcha.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()
{
$query = "SELECT * FROM #__easycaptchas"
. "\nORDER BY name DESC";
return $query;
}
/**
* Retrieves the captchas
* @return array Array of objects containing the data from the database
*/
function getData()
{
// Lets load the data if it doesn't already exist
if (empty( $this->_data ))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList( $query, $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_data;
}
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;
}
/**
* Retrieves the count of captcha
* @return array Array of objects containing the data from the database
*/
function getTotal()
{
if (empty($this->_total))
{
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
function getVersion()
{
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'version.php' );
if (empty($this->_version))
{
$this->_version = new EasyCaptchaHelperVersion();
}
return $this->_version;
}
}