/** * Compiles a list of categories for a section * @param string The name of the category section * @param string The name of the current user */ function showCategories($section, $option) { global $database, $my, $mainframe, $mosConfig_list_limit; global $adminLanguage; $sectionid = $mainframe->getUserStateFromRequest("sectionid{$option}{$section}", 'sectionid', 0); $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$section}limitstart", 'limitstart', 0); $section_name = ''; if (intval($section) > 0) { $table = 'content'; $database->setQuery("SELECT name FROM #__sections WHERE id='{$section}'"); $section_name = $database->loadResult(); $section_name .= ' Section'; $where = "\n WHERE c.section='{$section}'"; $type = 'content'; } else { if (strpos($section, 'com_') === 0) { $table = substr($section, 4); $database->setQuery("SELECT name FROM #__components WHERE link='option={$section}'"); $section_name = $database->loadResult(); $where = "\n WHERE c.section='{$section}'"; $type = 'other'; } else { $table = $section; $where = "\n WHERE c.section='{$section}'"; $type = 'other'; } } $content_add = ''; $content_join = ''; $order = "\n ORDER BY c.ordering, c.name"; // get the total number of records $database->setQuery("SELECT count(*) FROM #__categories WHERE section='{$section}'"); $total = $database->loadResult(); // allows for viweing of all content categories if ($section == 'content') { $table = 'content'; $content_add = "\n , z.title AS section_name"; $content_join = "\n LEFT JOIN #__sections AS z ON z.id = c.section"; //$where = "\n WHERE s1.catid = c.id"; $where = "\n WHERE c.section NOT LIKE '%com_%'"; $order = "\n ORDER BY c.section, c.ordering, c.name"; $section_name = 'All Content'; // get the total number of records $database->setQuery("SELECT count(*) FROM #__categories INNER JOIN #__sections AS s ON s.id = section"); $total = $database->loadResult(); $type = 'content'; } // used by filter if ($sectionid > 0) { $filter = "\n AND c.section = '{$sectionid}'"; } else { $filter = ''; } require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $query = "SELECT c.*, c.checked_out as checked_out_contact_category, g.name AS groupname, u.name AS editor," . "COUNT(DISTINCT s2.checked_out) AS checked_out" . $content_add . "\n FROM #__categories AS c" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n LEFT JOIN #__{$table} AS s2 ON s2.catid = c.id AND s2.checked_out > 0" . $content_join . $where . $filter . "\n AND c.published != -2" . "\n GROUP BY c.id" . $order . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}"; $database->setQuery($query); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } $count = count($rows); // number of Active Items for ($i = 0; $i < $count; $i++) { $query = "SELECT COUNT( a.id )" . "\n FROM #__content AS a" . "\n WHERE a.catid = " . $rows[$i]->id . "\n AND a.state <> '-2'"; $database->setQuery($query); $active = $database->loadResult(); $rows[$i]->active = $active; } // number of Trashed Items for ($i = 0; $i < $count; $i++) { $query = "SELECT COUNT( a.id )" . "\n FROM #__content AS a" . "\n WHERE a.catid = " . $rows[$i]->id . "\n AND a.state = '-2'"; $database->setQuery($query); $trash = $database->loadResult(); $rows[$i]->trash = $trash; } // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = mosAdminMenus::SelectSection('sectionid', $sectionid, $javascript); categories_html::show($rows, $section, $section_name, $my->id, $pageNav, $lists, $type); }
/** * Compiles a list of categories for a section * @param string The name of the category section */ function showCategories($section, $option) { global $mainframe; $db =& JFactory::getDBO(); $filter_order = $mainframe->getUserStateFromRequest($option . '.filter_order', 'filter_order', 'c.ordering', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . '.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_state = $mainframe->getUserStateFromRequest($option . '.' . $section . '.filter_state', 'filter_state', '', 'word'); $sectionid = $mainframe->getUserStateFromRequest($option . '.' . $section . '.sectionid', 'sectionid', 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'); $section_name = ''; $content_add = ''; $content_join = ''; $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', c.ordering'; if (intval($section) > 0) { $table = 'content'; $query = 'SELECT title' . ' FROM #__sections' . ' WHERE id = ' . (int) $section; $db->setQuery($query); $section_name = $db->loadResult(); $section_name = JText::sprintf('Content:', JText::_($section_name)); $where = ' WHERE c.section = ' . $db->Quote($section); $type = 'content'; } else { if (strpos($section, 'com_') === 0) { $table = substr($section, 4); $query = 'SELECT name' . ' FROM #__components' . ' WHERE link = ' . $db->Quote('option=' . $section); $db->setQuery($query); $section_name = $db->loadResult(); $where = ' WHERE c.section = ' . $db->Quote($section); $type = 'other'; // special handling for contact component if ($section == 'com_contact_details') { $section_name = JText::_('Contact'); } $section_name = JText::sprintf('Component:', $section_name); } else { $table = $section; $where = ' WHERE c.section = ' . $db->Quote($section); $type = 'other'; } } // get the total number of records $query = 'SELECT COUNT(*)' . ' FROM #__categories'; if ($section == 'com_content') { $query .= ' WHERE section > 0'; } else { $query .= ' WHERE section = ' . $db->quote($section); } $db->setQuery($query); $total = $db->loadResult(); // allows for viweing of all content categories if ($section == 'com_content') { $table = 'content'; $content_add = ' , z.title AS section_name'; $content_join = ' LEFT JOIN #__sections AS z ON z.id = c.section'; $where = ' WHERE c.section NOT LIKE "%com_%"'; if ($filter_order == 'c.ordering') { $order = ' ORDER BY z.title, c.ordering'; } else { $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', z.title, c.ordering'; } $section_name = JText::_('All Content:'); $type = 'content'; } // used by filter if ($sectionid > 0) { $filter = ' AND c.section = ' . $db->Quote($sectionid); } else { $filter = ''; } if ($filter_state) { if ($filter_state == 'P') { $filter .= ' AND c.published = 1'; } else { if ($filter_state == 'U') { $filter .= ' AND c.published = 0'; } } } if ($search) { $filter .= ' AND LOWER(c.title) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false); } jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); $tablesAllowed = $db->getTableList(); if (!in_array($db->getPrefix() . $table, $tablesAllowed)) { $table = 'content'; } $query = 'SELECT c.*, c.checked_out as checked_out_contact_category, g.name AS groupname, u.name AS editor, COUNT( DISTINCT s2.checked_out ) AS checked_out_count' . $content_add . ' FROM #__categories AS c' . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . ' LEFT JOIN #__groups AS g ON g.id = c.access' . ' LEFT JOIN #__' . $table . ' AS s2 ON s2.catid = c.id AND s2.checked_out > 0' . $content_join . $where . $filter . ' AND c.published != -2' . ' GROUP BY c.id' . $order; $db->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return; } $count = count($rows); // number of Active Items for ($i = 0; $i < $count; $i++) { $query = 'SELECT COUNT( a.id )' . ' FROM #__content AS a' . ' WHERE a.catid = ' . (int) $rows[$i]->id . ' AND a.state <> -2'; $db->setQuery($query); $active = $db->loadResult(); $rows[$i]->active = $active; } // number of Trashed Items for ($i = 0; $i < $count; $i++) { $query = 'SELECT COUNT( a.id )' . ' FROM #__content AS a' . ' WHERE a.catid = ' . (int) $rows[$i]->id . ' AND a.state = -2'; $db->setQuery($query); $trash = $db->loadResult(); $rows[$i]->trash = $trash; } // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = JHTML::_('list.section', 'sectionid', $sectionid, $javascript); // state filter $lists['state'] = JHTML::_('grid.state', $filter_state); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['search'] = $search; categories_html::show($rows, $section, $section_name, $pageNav, $lists, $type); }
/** * Compiles a list of categories for a section * @param string The name of the category section */ function showCategories($section, $option) { global $database, $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path, $mosConfig_dbprefix; $sectionid = intval($mainframe->getUserStateFromRequest("sectionid{$option}{$section}", 'sectionid', 0)); $limit = intval($mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit)); $limitstart = intval($mainframe->getUserStateFromRequest("view{$section}limitstart", 'limitstart', 0)); $section_name = ''; $content_add = ''; $content_join = ''; $order = "\n ORDER BY c.ordering, c.name"; if (intval($section) > 0) { $table = 'content'; $query = "SELECT name" . "\n FROM #__sections" . "\n WHERE id = " . (int) $section; $database->setQuery($query); $section_name = $database->loadResult(); $section_name = 'Conteúdo: ' . $section_name; $where = "\n WHERE c.section = " . $database->Quote($section); $type = 'content'; } else { if (strpos($section, 'com_') === 0) { $table = substr($section, 4); $query = "SELECT name" . "\n FROM #__components" . "\n WHERE link = 'option=" . $database->getEscaped($section) . "'"; $database->setQuery($query); $section_name = $database->loadResult(); $where = "\n WHERE c.section = " . $database->Quote($section); $type = 'other'; // special handling for contact component if ($section == 'com_contact_details') { $section_name = 'Contato'; } $section_name = 'Component: ' . $section_name; } else { $table = $section; $where = "\n WHERE c.section = " . $database->Quote($section); $type = 'other'; } } // get the total number of records $query = "SELECT COUNT(*)" . "\n FROM #__categories" . "\n WHERE section = " . $database->Quote($section); $database->setQuery($query); $total = $database->loadResult(); // allows for viweing of all content categories if ($section == 'content') { $table = 'content'; $content_add = "\n , z.title AS section_name"; $content_join = "\n LEFT JOIN #__sections AS z ON z.id = c.section"; //$where = "\n WHERE s1.catid = c.id"; $where = "\n WHERE c.section NOT LIKE '%com_%'"; $order = "\n ORDER BY c.section, c.ordering, c.name"; $section_name = 'Todo o Conteúdo'; // get the total number of records $query = "SELECT COUNT(*)" . "\n FROM #__categories" . "\n INNER JOIN #__sections AS s ON s.id = section"; if ($sectionid > 0) { $query .= "\n WHERE section = " . $database->Quote($sectionid); } $database->setQuery($query); $total = $database->loadResult(); $type = 'content'; } // used by filter if ($sectionid > 0) { $filter = "\n AND c.section = " . $database->Quote($sectionid); } else { $filter = ''; } require_once $mosConfig_absolute_path . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $tablesAllowed = $database->getTableList(); if (!in_array($mosConfig_dbprefix . $table, $tablesAllowed)) { $table = 'content'; } $query = "SELECT c.*, c.checked_out as checked_out_contact_category, g.name AS groupname, u.name AS editor," . "COUNT( DISTINCT s2.checked_out ) AS checked_out" . $content_add . "\n FROM #__categories AS c" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n LEFT JOIN `#__{$table}` AS s2 ON s2.catid = c.id AND s2.checked_out > 0" . $content_join . $where . $filter . "\n AND c.published != -2" . "\n GROUP BY c.id" . $order; $database->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return; } $count = count($rows); // number of Active Items for ($i = 0; $i < $count; $i++) { $query = "SELECT COUNT( a.id )" . "\n FROM #__content AS a" . "\n WHERE a.catid = " . (int) $rows[$i]->id . "\n AND a.state != -2"; $database->setQuery($query); $active = $database->loadResult(); $rows[$i]->active = $active; } // number of Trashed Items for ($i = 0; $i < $count; $i++) { $query = "SELECT COUNT( a.id )" . "\n FROM #__content AS a" . "\n WHERE a.catid = " . (int) $rows[$i]->id . "\n AND a.state = -2"; $database->setQuery($query); $trash = $database->loadResult(); $rows[$i]->trash = $trash; } // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = mosAdminMenus::SelectSection('sectionid', $sectionid, $javascript); categories_html::show($rows, $section, $section_name, $pageNav, $lists, $type); }