/** * Compiles a list of installed or defined modules * @param database A database connector object */ function viewContent($sectionid, $option) { global $database, $mainframe, $mosConfig_list_limit, $adminLanguage; $catid = $mainframe->getUserStateFromRequest("catid{$option}{$sectionid}", 'catid', 0); $filter_sectionid = $mainframe->getUserStateFromRequest("filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0); $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}{$sectionid}limitstart", 'limitstart', 0); $search = $mainframe->getUserStateFromRequest("search{$option}{$sectionid}", 'search', ''); $search = $database->getEscaped(trim(strtolower($search))); $redirect = $sectionid; $filter = ''; //getting a undefined variable error if ($sectionid == 0) { // used to show All content items $where = array("c.state >= 0", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'"); $order = "\n ORDER BY s.title, c.catid, cc.ordering, cc.title, c.ordering"; $all = 1; //$filter = "\n , #__sections AS s WHERE s.id = c.section"; if ($filter_sectionid > 0) { $filter = "\nWHERE cc.section={$filter_sectionid}"; } $section->title = $adminLanguage->A_COMP_CONTENT_ALL_ITEMS; $section->id = 0; } else { $where = array("c.state >= 0", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'", "c.sectionid='{$sectionid}'"); $order = "\n ORDER BY cc.ordering, cc.title, c.ordering"; $all = NULL; $filter = "\n WHERE cc.section = '{$sectionid}'"; $section = new mosSection($database); $section->load($sectionid); } // used by filter if ($filter_sectionid > 0) { $where[] = "c.sectionid = '{$filter_sectionid}'"; } if ($catid > 0) { $where[] = "c.catid='{$catid}'"; } if ($search) { $where[] = "LOWER( c.title ) LIKE '%{$search}%'"; } // get the total number of records $database->setQuery("SELECT count(*) FROM #__content AS c, #__categories AS cc, #__sections AS s" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "")); $total = $database->loadResult(); require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $where[] = "f.content_id = c.id"; $query = "SELECT c.*, g.name AS groupname, cc.name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name" . "\n FROM #__content_frontpage AS f, #__content AS c, #__categories AS cc, #__sections AS s" . "\n LEFT JOIN #__groups AS g ON g.id = access" . "\n LEFT JOIN #__users AS u ON u.id = checked_out" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : '') . $order . "\n LIMIT {$pageNav->limitstart},{$pageNav->limit}"; $database->setQuery($query); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // get list of categories for dropdown filter $query = "SELECT cc.id AS value, cc.title AS text, section" . "\n FROM #__categories AS cc" . "\n INNER JOIN #__sections AS s ON s.id=cc.section " . $filter . "\n ORDER BY s.ordering, cc.ordering"; $lists['catid'] = filterCategory($query, $catid); // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = mosAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript); HTML_content::showContent($rows, $section, $lists, $search, $pageNav, $option, $all, $redirect); }
/** * Compiles a list of installed or defined modules * @param database A database connector object */ function viewContent($sectionid, $option) { global $database, $mainframe, $mosConfig_list_limit; $catid = intval($mainframe->getUserStateFromRequest("catid{$option}{$sectionid}", 'catid', 0)); $filter_authorid = intval($mainframe->getUserStateFromRequest("filter_authorid{$option}{$sectionid}", 'filter_authorid', 0)); $filter_sectionid = intval($mainframe->getUserStateFromRequest("filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0)); $limit = intval($mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit)); $limitstart = intval($mainframe->getUserStateFromRequest("view{$option}{$sectionid}limitstart", 'limitstart', 0)); $search = $mainframe->getUserStateFromRequest("search{$option}{$sectionid}", 'search', ''); if (get_magic_quotes_gpc()) { $search = stripslashes($search); } $redirect = $sectionid; $filter = ''; //getting a undefined variable error if ($sectionid == 0) { // used to show All content items $where = array("c.state \t>= 0", "c.catid \t= cc.id", "cc.section = s.id", "s.scope\t= 'content'"); $order = "\n ORDER BY s.title, c.catid, cc.ordering, cc.title, c.ordering"; $all = 1; //$filter = "\n , #__sections AS s WHERE s.id = c.section"; if ($filter_sectionid > 0) { $filter = "\n WHERE cc.section = '" . (int) $filter_sectionid . "'"; } if (!isset($section)) { $section = new stdClass(); } $section->title = 'All Content Items'; $section->id = 0; } else { $where = array("c.state \t>= 0", "c.catid \t= cc.id", "cc.section = s.id", "s.scope \t= 'content'", "c.sectionid = " . (int) $sectionid); $order = "\n ORDER BY cc.ordering, cc.title, c.ordering"; $all = NULL; $filter = "\n WHERE cc.section = '" . (int) $sectionid . "'"; $section = new mosSection($database); $section->load((int) $sectionid); } // used by filter if ($filter_sectionid > 0) { $where[] = "c.sectionid = " . (int) $filter_sectionid; } if ($catid > 0) { $where[] = "c.catid = " . (int) $catid; } if ($filter_authorid > 0) { $where[] = "c.created_by = " . (int) $filter_authorid; } if ($search) { $where[] = "LOWER( c.title ) LIKE '%" . $database->getEscaped(trim(strtolower($search))) . "%'"; } // get the total number of records $query = "SELECT COUNT(*)" . "\n FROM #__content AS c" . "\n LEFT JOIN #__categories AS cc ON cc.id = c.catid" . "\n LEFT JOIN #__sections AS s ON s.id = c.sectionid" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ""); $database->setQuery($query); $total = $database->loadResult(); require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); $query = "SELECT c.*, g.name AS groupname, cc.name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author" . "\n FROM #__content AS c" . "\n LEFT JOIN #__categories AS cc ON cc.id = c.catid" . "\n LEFT JOIN #__sections AS s ON s.id = c.sectionid" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n LEFT JOIN #__users AS v ON v.id = c.created_by" . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '') . $order; $database->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { echo $database->stderr(); return false; } // get list of categories for dropdown filter $query = "SELECT cc.id AS value, cc.title AS text, section" . "\n FROM #__categories AS cc" . "\n INNER JOIN #__sections AS s ON s.id = cc.section " . $filter . "\n ORDER BY s.ordering, cc.ordering"; $lists['catid'] = filterCategory($query, $catid); // get list of sections for dropdown filter $javascript = 'onchange="document.adminForm.submit();"'; $lists['sectionid'] = mosAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript); // get list of Authors for dropdown filter $query = "SELECT c.created_by, u.name" . "\n FROM #__content AS c" . "\n INNER JOIN #__sections AS s ON s.id = c.sectionid" . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" . "\n WHERE c.state != -1" . "\n AND c.state != -2" . "\n GROUP BY u.name" . "\n ORDER BY u.name"; $authors[] = mosHTML::makeOption('0', _SEL_AUTHOR, 'created_by', 'name'); $database->setQuery($query); $authors = array_merge($authors, $database->loadObjectList()); $lists['authorid'] = mosHTML::selectList($authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid); HTML_content::showContent($rows, $section, $lists, $search, $pageNav, $all, $redirect); }