| Current Path : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_poll/models/ |
| Current File : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_poll/models/questions.php |
<?php
// No direct access
defined( '_JEXEC' ) or die;
/**
* @author kirdinyuri
*/
class PollModelQuestions extends JModelList
{
/**
* Конструктор класса
* @param Array $config
*/
public function __construct( $config = array() )
{
if ( empty( $config['filter_fields'] ) ) {
$config['filter_fields'] = array(
'id', 'id',
'state', 'state',
'question', 'question',
'answers', 'answers',
'ordering', 'ordering'
);
}
parent::__construct( $config );
}
/**
* @param String $ordering
* @param String $direction
*/
protected function populateState( $ordering = null, $direction = null )
{
if ( $layout = JFactory::getApplication()->input->get( 'layout' ) ) {
$this->context .= '.' . $layout;
}
/*$search = $this->getUserStateFromRequest( $this->context . '.filter.search', 'filter_search' );
$this->setState( 'filter.search', $search );
$published = $this->getUserStateFromRequest( $this->context . '.filter.published', 'filter_published', '' );
$this->setState( 'filter.published', $published );*/
/*$authorId = $this->getUserStateFromRequest( $this->context . '.filter.author_id', 'filter_author_id' );
$this->setState( 'filter.author_id', $authorId );*/
/*$pos = $this->getUserStateFromRequest($this->context . '.filter.pos', 'filter_pos');
$this->setState('filter.pos', $pos);
$pr = $this->getUserStateFromRequest($this->context . '.filter.pr', 'filter_pr');
$this->setState('filter.pr', $pr);*/
parent::populateState( 'id', 'desc' );
}
/**
* @param string $id
* @return string
*/
protected function getStoreId( $id = '' )
{
$id .= ':' . $this->getState( 'filter.search' );
$id .= ':' . $this->getState( 'filter.published' );
/*$id .= ':' . $this->getState( 'filter.author_id' );*/
return parent::getStoreId( $id );
}
/**
* Составление запроса для получения списка записей
* @return JDatabaseQuery
*/
protected function getListQuery()
{
$query = $this->getDbo()->getQuery( true );
$query->select('*');
$query->from( '#__pollquestions' );
/*$pos = $this->getState('filter.pos');
if ($pr<>'')
{
$query->where('pos = "'.$pos.'"');
}*/
/*$authorId = $this->getState( 'filter.author_id' );
if ( is_numeric( $authorId ) ) {
$query->where( 'u.id=' . $authorId );
}*/
/*$search = $this->getState( 'filter.search' );
if ( !empty( $search ) ) {
$search = $this->getDbo()->Quote( '%' . $this->getDbo()->escape( $search, true ) . '%' );
$query->where( '(t1.title LIKE ' . $search . ' OR t1.alias LIKE ' . $search . ')' );
}*/
/*$method = $this->getState('filter.method');
if (!empty($method))
{
if ($method=="null") $method='';
$query->where('method = "'.$method.'"');
}*/
$orderCol = $this->state->get( 'list.ordering' );
$orderDirn = $this->state->get( 'list.direction' );
$query->order( $this->getDbo()->escape( $orderCol . ' ' . $orderDirn ) );
return $query;
}
/**
* Авторы записей
* @return JDatabaseQuery
*/
public function getAuthors()
{
$query = $this->getDbo()->getQuery( true );
$query->select( 'u.id AS value, u.name AS text' );
$query->from( '#__users AS u' );
$query->join( 'INNER', '#__payment AS c ON c.created_by = u.id' );
$query->group( 'u.id, u.name' );
$query->order( 'u.name' );
return $this->getDbo()->setQuery( $query )->loadObjectList();
}
}