/** * Compiles a list of installed or defined modules */ function view() { $mainframe =& JFactory::getApplication(); // Initialize some variables $db =& JFactory::getDBO(); $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); $option = 'com_advancedmodules_' . $client->id; $filters = new stdClass(); $filters->search = $mainframe->getUserStateFromRequest($option . 'search', 'search', '', 'string'); $filters->search = JString::strtolower($filters->search); $filters->order = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', 'm.position', 'cmd'); $filters->order_Dir = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word'); $filters->state = $mainframe->getUserStateFromRequest($option . 'filter_state', 'filter_state', '', 'word'); $filters->type = $mainframe->getUserStateFromRequest($option . 'filter_type', 'filter_type', '', 'cmd'); $filters->position = $mainframe->getUserStateFromRequest($option . 'filter_position', 'filter_position', '', 'cmd'); $filters->template = $mainframe->getUserStateFromRequest($option . 'filter_template', 'filter_template', '', 'cmd'); $filters->access = $mainframe->getUserStateFromRequest($option . 'filter_access', 'filter_access', '', 'cmd'); $filters->access_adv = $mainframe->getUserStateFromRequest($option . 'filter_access_adv', 'filter_access_adv', '', 'cmd'); $filters->menuitems = $mainframe->getUserStateFromRequest($option . 'filter_menuitems', 'filter_menuitems', '', 'cmd'); $filters->limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $filters->limitstart = $mainframe->getUserStateFromRequest($option . '.limitstart', 'limitstart', 0, 'int'); if ($filters->order == 'm.ordering') { $orderby = ' ORDER BY m.position, m.ordering ' . $filters->order_Dir; } else { if ($filters->order == 'color') { $orderby = ' ORDER BY m.id ' . $filters->order_Dir; } else { $orderby = ' ORDER BY ' . $filters->order . ' ' . $filters->order_Dir . ', m.ordering ASC'; } } $lists = $this->getListsAdmin($filters); $sql = $this->getSqlAdmin($filters); // get the total number of records $query = 'SELECT COUNT( DISTINCT m.id )' . ' FROM #__modules AS m' . $sql; $db->setQuery($query); $total = $db->loadResult(); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $filters->limitstart, $filters->limit); $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, a.params as adv_params, mm.menuid as assignment' . ' FROM #__modules AS m' . $sql . ' GROUP BY m.id' . $orderby; if ($filters->order == 'color') { $db->setQuery($query); $rows = $db->loadObjectList(); $newrows = array(); foreach ($rows as $i => $row) { $color = 'FFFFFF'; if (!(strpos($row->adv_params, 'color=') === false)) { $color = preg_replace('#^.*?color=([\\#a-z0-9]*).*$#si', '\\1', $row->adv_params); $color = preg_replace('#[^a-z0-9]#si', '', $row->adv_params); } $newrows[strtoupper(preg_replace('#[^a-z0-9_]#si', '', $color . '_' . ($i + 1) / 10000))] = $row; } if (strtolower($filters->order_Dir) == 'desc') { krsort($newrows); } else { ksort($newrows); } $rows = array_slice(array_values($newrows), $pageNav->limitstart, $pageNav->limit); unset($newrows); } else { $db->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); } if ($db->getErrorNum()) { echo $db->stderr(); return false; } require_once JApplicationHelper::getPath('admin_html'); HTML_modules::view($rows, $client, $pageNav, $lists); }
/** * Compiles a list of installed or defined modules */ function view() { global $mainframe; // Initialize some variables $db =& JFactory::getDBO(); $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); $option = 'com_modules'; $filter_order = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', 'm.position', '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_position = $mainframe->getUserStateFromRequest($option . 'filter_position', 'filter_position', '', 'cmd'); $filter_type = $mainframe->getUserStateFromRequest($option . 'filter_type', 'filter_type', '', 'cmd'); $filter_assigned = $mainframe->getUserStateFromRequest($option . 'filter_assigned', 'filter_assigned', '', 'cmd'); $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'); $where[] = 'm.client_id = ' . (int) $client->id; $joins[] = 'LEFT JOIN #__users AS u ON u.id = m.checked_out'; $joins[] = 'LEFT JOIN #__groups AS g ON g.id = m.access'; $joins[] = 'LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'; // used by filter if ($filter_assigned) { $joins[] = 'LEFT JOIN #__templates_menu AS t ON t.menuid = mm.menuid'; $where[] = 't.template = ' . $db->Quote($filter_assigned); } if ($filter_position) { $where[] = 'm.position = ' . $db->Quote($filter_position); } if ($filter_type) { $where[] = 'm.module = ' . $db->Quote($filter_type); } if ($search) { $where[] = 'LOWER( m.title ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false); } if ($filter_state) { if ($filter_state == 'P') { $where[] = 'm.published = 1'; } else { if ($filter_state == 'U') { $where[] = 'm.published = 0'; } } } $where = ' WHERE ' . implode(' AND ', $where); $join = ' ' . implode(' ', $joins); if ($filter_order == 'm.ordering') { $orderby = ' ORDER BY m.position, m.ordering ' . $filter_order_Dir; } else { $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', m.ordering ASC'; } // get the total number of records $query = 'SELECT COUNT(DISTINCT m.id)' . ' FROM #__modules AS m' . $join . $where; $db->setQuery($query); $total = $db->loadResult(); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages' . ' FROM #__modules AS m' . $join . $where . ' GROUP BY m.id' . $orderby; $db->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } // get list of Positions for dropdown filter $query = 'SELECT m.position AS value, m.position AS text' . ' FROM #__modules as m' . ' WHERE m.client_id = ' . (int) $client->id . ' GROUP BY m.position' . ' ORDER BY m.position'; $positions[] = JHTML::_('select.option', '0', '- ' . JText::_('Select Position') . ' -'); $db->setQuery($query); $positions = array_merge($positions, $db->loadObjectList()); $lists['position'] = JHTML::_('select.genericlist', $positions, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filter_position}"); // get list of Positions for dropdown filter $query = 'SELECT module AS value, module AS text' . ' FROM #__modules' . ' WHERE client_id = ' . (int) $client->id . ' GROUP BY module' . ' ORDER BY module'; $db->setQuery($query); $types[] = JHTML::_('select.option', '0', '- ' . JText::_('Select Type') . ' -'); $types = array_merge($types, $db->loadObjectList()); $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filter_type}"); // state filter $lists['state'] = JHTML::_('grid.state', $filter_state); // template assignment filter $query = 'SELECT DISTINCT(template) AS text, template AS value' . ' FROM #__templates_menu' . ' WHERE client_id = ' . (int) $client->id; $db->setQuery($query); $assigned[] = JHTML::_('select.option', '0', '- ' . JText::_('Select Template') . ' -'); $assigned = array_merge($assigned, $db->loadObjectList()); $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filter_assigned}"); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['search'] = $search; require_once JApplicationHelper::getPath('admin_html'); HTML_modules::view($rows, $client, $pageNav, $lists); }