Пример #1
0
 function display($cachable = false, $urlparams = array())
 {
     $mainframe = JFactory::getApplication();
     $option = JRequest::getCmd('option');
     $section = JRequest::getVar('section');
     $db = JFactory::getDBO();
     $filter_order = $mainframe->getUserStateFromRequest("{$option}.filter_order", 'filter_order', 'a.id', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest("{$option}.filter_order_Dir", 'filter_order_Dir', '', 'word');
     $filter_state = $mainframe->getUserStateFromRequest("{$option}.filter_state", 'filter_state', '', 'word');
     $filter_sid = $mainframe->getUserStateFromRequest("{$option}.filter_sid", 'filter_sid', 0, 'int');
     $search = $mainframe->getUserStateFromRequest("{$option}.search", 'search', '', 'string');
     $search = JString::strtolower($search);
     $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
     $limitstart = $mainframe->getUserStateFromRequest($option . '.limitstart', 'limitstart', 0, 'int');
     $filter_vid = $mainframe->getUserStateFromRequest("{$option}.filter_vid", 'filter_vid', 0, 'var');
     $where = array();
     $where[] = ' c.archiv = 0';
     if ($filter_sid) {
         $where[] = 'a.sid = ' . (int) $filter_sid;
     }
     if ($search) {
         $where[] = 'LOWER(a.name) LIKE "' . $db->escape('%' . $search . '%') . '"';
     }
     if ($filter_state) {
         if ($filter_state == 'P') {
             $where[] = 'a.published = 1';
         } else {
             if ($filter_state == 'U') {
                 $where[] = 'a.published = 0';
             }
         }
     }
     $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
     if ($filter_order == 'a.id') {
         $orderby = ' ORDER BY ordering';
     } else {
         if ($filter_order == 'a.name' or $filter_order == 'a.zps' or $filter_order == 'a.homepage' or $filter_order == 'c.name' or $filter_order == 'a.published' or $filter_order == 'a.ordering') {
             $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', a.id';
         } else {
             $filter_order = 'a.id';
             $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir;
         }
     }
     // get the total number of records
     $query = 'SELECT COUNT(*) ' . ' FROM #__clm_vereine AS a' . ' LEFT JOIN #__clm_saison AS c ON c.id = a.sid' . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     jimport('joomla.html.pagination');
     $pageNav = new JPagination($total, $limitstart, $limit);
     // get the subset (based on limits) of required records
     $query = 'SELECT a.*,u.name AS editor ' . ', c.name AS saison ' . ' FROM #__clm_vereine AS a' . ' LEFT JOIN #__clm_saison AS c ON c.id = a.sid' . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' . $where . $orderby;
     $db->setQuery($query, $pageNav->limitstart, $pageNav->limit);
     $rows = $db->loadObjectList();
     if ($db->getErrorNum()) {
         echo $db->stderr();
         return false;
     }
     // state filter
     $lists['state'] = JHTML::_('grid.state', $filter_state);
     // Saisonfilter
     $sql = 'SELECT id, name FROM #__clm_saison WHERE archiv =0';
     $db->setQuery($sql);
     $saisonlist[] = JHTML::_('select.option', '0', JText::_('VEREINE_SAISON'), 'id', 'name');
     $saisonlist = array_merge($saisonlist, $db->loadObjectList());
     $lists['sid'] = JHTML::_('select.genericlist', $saisonlist, 'filter_sid', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'name', intval($filter_sid));
     // table ordering
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     // search filter
     $lists['search'] = $search;
     require_once JPATH_COMPONENT . DS . 'views' . DS . 'vereine.php';
     CLMViewVereine::vereine($rows, $lists, $pageNav, $option);
 }