Ejemplo n.º 1
0
function showSlides($option)
{
    global $mainframe;
    $db =& JFactory::getDBO();
    // limit
    $limit = JRequest::getVar('limit', $mainframe->getCfg('list_limit'));
    $limitstart = JRequest::getVar('limitstart', 0);
    $filter_catid = JRequest::getVar('filter_catid', '');
    // where
    $where = array();
    if ($filter_catid) {
        $where[] = 's.catid = ' . (int) $filter_catid;
    }
    $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
    $orderby = ' ORDER BY s.catid, s.ordering';
    // query count
    $query = 'SELECT COUNT(s.id)' . ' FROM ' . _FPSS_TABLE_SLIDES . ' AS s';
    $db->setQuery($query);
    $total = $db->loadResult();
    // pagination
    jimport('joomla.html.pagination');
    $pagination = new JPagination($total, $limitstart, $limit);
    // main query
    $query = 'SELECT s.*, g.name as groupname ' . ' FROM ' . _FPSS_TABLE_SLIDES . ' AS s' . ' LEFT JOIN #__groups AS g ON g.id = s.registers' . $where . $orderby;
    //echo $query;
    $db->setQuery($query, $pagination->limitstart, $pagination->limit);
    $slides = $db->loadObjectList();
    // build list of categories
    $query = 'SELECT c.id, c.name' . ' FROM ' . _FPSS_TABLE_CATEGORIES . ' AS c' . ' ORDER BY c.name';
    $categories[] = JHTML::_('select.option', '0', '- ' . _FPSS_SEL_CATEGORIES . ' -', 'id', 'name');
    $db->setQuery($query);
    $categories = array_merge($categories, $db->loadObjectList());
    $lists['categories'] = JHTML::_('select.genericlist', $categories, 'filter_catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'id', 'name', $filter_catid);
    HTML_FPSlideShow::showSlides($slides, $lists, $pagination, $option);
}