Ejemplo n.º 1
0
/**
* Compiles a list of frontpage items
*/
function viewFrontPage($option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0);
    $search = $mainframe->getUserStateFromRequest("search{$option}", 'search', '');
    $search = $database->getEscaped(trim(strtolower($search)));
    $where = array("c.state >= 0");
    if ($search) {
        $where[] = "LOWER(c.title) LIKE '%{$search}%'";
    }
    // get the total number of records
    $database->setQuery("SELECT count(*)" . "\nFROM #__content AS c" . "\nINNER JOIN #__categories AS cc ON cc.id = c.catid" . "\nINNER JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" . "\nINNER JOIN #__content_frontpage AS f ON f.content_id = c.id" . (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);
    $database->setQuery("SELECT c.*, g.name AS groupname, cc.name, u.name AS editor, f.ordering AS fpordering" . "\nFROM #__content AS c" . "\nINNER JOIN #__categories AS cc ON cc.id = c.catid" . "\nINNER JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" . "\nINNER JOIN #__content_frontpage AS f ON f.content_id = c.id" . "\nINNER JOIN #__groups AS g ON g.id = c.access" . "\nLEFT JOIN #__users AS u ON u.id = c.checked_out" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY f.ordering" . "\nLIMIT {$pageNav->limitstart},{$pageNav->limit}");
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    HTML_content::showList($rows, $search, $pageNav, $option);
}
Ejemplo n.º 2
0
/**
* Compiles a list of frontpage items
*/
function viewFrontPage($option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $catid = intval($mainframe->getUserStateFromRequest("catid{$option}", 'catid', 0));
    $filter_authorid = intval($mainframe->getUserStateFromRequest("filter_authorid{$option}", 'filter_authorid', 0));
    $filter_sectionid = intval($mainframe->getUserStateFromRequest("filter_sectionid{$option}", 'filter_sectionid', 0));
    $limit = intval($mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit));
    $limitstart = intval($mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0));
    $search = $mainframe->getUserStateFromRequest("search{$option}", 'search', '');
    if (get_magic_quotes_gpc()) {
        $search = stripslashes($search);
    }
    $where = array("c.state >= 0");
    // 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 INNER JOIN #__categories AS cc ON cc.id = c.catid" . "\n INNER JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = c.id" . (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, s.name AS sect_name, u.name AS editor, f.ordering AS fpordering, v.name AS author" . "\n FROM #__content AS c" . "\n INNER JOIN #__categories AS cc ON cc.id = c.catid" . "\n INNER JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = c.id" . "\n INNER 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" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\n ORDER BY f.ordering";
    $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 " . "\n ORDER BY s.ordering, cc.ordering";
    $categories[] = mosHTML::makeOption('0', _SEL_CATEGORY);
    $database->setQuery($query);
    $categories = array_merge($categories, $database->loadObjectList());
    $lists['catid'] = mosHTML::selectList($categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $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::showList($rows, $search, $pageNav, $option, $lists);
}