function showBooks() { global $mainframe, $option; $db =& JFactory::getDBO(); $filter_order = $mainframe->getUserStateFromRequest("{$option}.filter_order_books", 'filter_order', 'b.title', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest("{$option}.filter_order_Dir_books", 'filter_order_Dir', '', 'word'); $filter_state = $mainframe->getUserStateFromRequest("{$option}.filter_state_books", 'filter_state', '', 'word'); $filter_category = $mainframe->getUserStateFromRequest("{$option}.filter_category_books", 'filter_category', '-1', 'string'); $search = $mainframe->getUserStateFromRequest("{$option}.search_books", 'search', '', 'string'); $search = JString::strtolower($search); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest($option . 'limitstart_page', 'limitstart', 0, 'int'); $where = array(); if ($filter_state) { if ($filter_state == 'P') { $where[] = 'm.published = 1'; } else { if ($filter_state == 'U') { $where[] = 'm.published = 0'; } } } if ($filter_category > -1) { $where[] = '(m.category_id = ' . $filter_category . ')'; } if ($search) { $where[] = '(LOWER(m.title) LIKE ' . $db->Quote('%' . $search . '%') . ' OR LOWER(m.description) LIKE ' . $db->Quote('%' . $search . '%') . ')'; } $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : ''; $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', m.ordering'; $query = 'SELECT COUNT(m.id)' . ' FROM #__flippingbook_books AS m' . $where; $db->setQuery($query); $total = $db->loadResult(); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $query = 'SELECT m.*, m.title AS book_title, b.title AS category_title' . ' FROM #__flippingbook_books AS m' . ' LEFT JOIN #__flippingbook_categories AS b ON m.category_id=b.id' . $where . $orderby; $db->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $lists['state'] = JHTML::_('grid.state', $filter_state); $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; $query = 'SELECT id, title FROM #__flippingbook_categories ORDER BY title'; $db->setQuery($query); $rows2 = $db->loadObjectList(); $book_filter[] = JHTML::_('select.option', -1, '- ' . JText::_('Select Category') . ' -'); foreach ($rows2 as $row) { $book_filter[] = JHTML::_('select.option', $row->id, $row->title); } $lists['category'] = JHTML::_('select.genericlist', $book_filter, 'filter_category', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_category); $lists['search'] = $search; require_once JPATH_COMPONENT . DS . 'views' . DS . 'book_manager.php'; BookManager::showBooks($rows, $pageNav, $option, $lists); }