Example #1
0
/**
* Shows a list of archived content items
* @param int The section id
*/
function viewArchive($sectionid, $option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $catid = $mainframe->getUserStateFromRequest("catidarc{$option}{$sectionid}", 'catid', 0);
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("viewarc{$option}{$sectionid}limitstart", 'limitstart', 0);
    $search = $mainframe->getUserStateFromRequest("searcharc{$option}{$sectionid}", 'search', '');
    $filter_sectionid = $mainframe->getUserStateFromRequest("filter_sectionid{$option}{$sectionid}", 'filter_sectionid', 0);
    $search = $database->getEscaped(trim(strtolower($search)));
    $redirect = $sectionid;
    if ($sectionid == 0) {
        $where = array("c.state = -1", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'");
        $filter = "\n , #__sections AS s WHERE s.id = c.section";
        $all = 1;
    } else {
        $where = array("c.state = -1", "c.catid=cc.id", "cc.section=s.id", "s.scope='content'", "c.sectionid='{$sectionid}'");
        $filter = "\n WHERE section = '{$sectionid}'";
        $all = NULL;
    }
    // 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
    $query = "SELECT count(*)" . "FROM #__content AS c, #__categories AS cc, #__sections AS s" . (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" . "\n FROM #__content AS c, #__categories AS cc, #__sections AS s" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : '') . "\n ORDER BY c.catid, c.ordering" . "\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 c.id AS value, c.title AS text" . "\n FROM #__categories AS c" . $filter . "\n ORDER BY c.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);
    $section = new mosSection($database);
    $section->load($sectionid);
    HTML_content::showArchive($rows, $section, $lists, $search, $pageNav, $option, $all, $redirect);
}
Example #2
0
/**
* Shows a list of archived content items
* @param int The section id
*/
function viewArchive($sectionid, $option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $catid = intval($mainframe->getUserStateFromRequest("catidarc{$option}{$sectionid}", 'catid', 0));
    $limit = intval($mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit));
    $limitstart = intval($mainframe->getUserStateFromRequest("viewarc{$option}{$sectionid}limitstart", 'limitstart', 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));
    $search = $mainframe->getUserStateFromRequest("searcharc{$option}{$sectionid}", 'search', '');
    if (get_magic_quotes_gpc()) {
        $search = stripslashes($search);
    }
    $redirect = $sectionid;
    if ($sectionid == 0) {
        $where = array("c.state \t= -1", "c.catid\t= cc.id", "cc.section = s.id", "s.scope  \t= 'content'");
        $filter = "\n , #__sections AS s WHERE s.id = c.section";
        $all = 1;
    } else {
        $where = array("c.state \t= -1", "c.catid\t= cc.id", "cc.section\t= s.id", "s.scope\t= 'content'", "c.sectionid= " . (int) $sectionid);
        $filter = "\n WHERE section = '" . (int) $sectionid . "'";
        $all = NULL;
    }
    // used by filter
    if ($filter_sectionid > 0) {
        $where[] = "c.sectionid = " . (int) $filter_sectionid;
    }
    if ($filter_authorid > 0) {
        $where[] = "c.created_by = " . (int) $filter_authorid;
    }
    if ($catid > 0) {
        $where[] = "c.catid = " . (int) $catid;
    }
    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, 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 v ON v.id = c.created_by" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '') . "\n ORDER BY c.catid, c.ordering";
    $database->setQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return;
    }
    // get list of categories for dropdown filter
    $query = "SELECT c.id AS value, c.title AS text" . "\n FROM #__categories AS c" . $filter . "\n ORDER BY c.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);
    $section = new mosSection($database);
    $section->load((int) $sectionid);
    // 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 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::showArchive($rows, $section, $lists, $search, $pageNav, $option, $all, $redirect);
}