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.sqlexcelsections.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'; } } // 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.'%'); } $where[] = 'b.id = a.access'; $where = ' WHERE ' . implode(' AND ', $where); // Assemble it all to a SQL query $query = ' SELECT a.*, b.name as groupname ' . ' FROM #__sql2excel_sections a, #__groups b ' . $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; } }