/**
* Compiles a list of installed or defined modules
* @param database A database connector object
*/
function view($option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $filter_authorid = intval($mainframe->getUserStateFromRequest("filter_authorid{$option}", 'filter_authorid', 0));
    $order = $mainframe->getUserStateFromRequest("zorder", 'zorder', 'c.ordering DESC');
    $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);
    }
    // used by filter
    if ($search) {
        $searchEscaped = $database->getEscaped(trim(strtolower($search)));
        $search_query = "\n AND ( LOWER( c.title ) LIKE '%{$searchEscaped}%' OR LOWER( c.title_alias ) LIKE '%{$searchEscaped}%' )";
    } else {
        $search_query = '';
    }
    $filter = '';
    if ($filter_authorid > 0) {
        $filter = "\n AND c.created_by = " . (int) $filter_authorid;
    }
    $orderAllowed = array('c.ordering ASC', 'c.ordering DESC', 'c.id ASC', 'c.id DESC', 'c.title ASC', 'c.title DESC', 'c.created ASC', 'c.created DESC', 'z.name ASC', 'z.name DESC', 'c.state ASC', 'c.state DESC', 'c.access ASC', 'c.access DESC');
    if (!in_array($order, $orderAllowed)) {
        $order = 'c.ordering DESC';
    }
    // get the total number of records
    $query = "SELECT count(*)" . "\n FROM #__content AS c" . "\n WHERE c.sectionid = 0" . "\n AND c.catid = 0" . "\n AND c.state != -2" . $search_query . $filter;
    $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, u.name AS editor, z.name AS creator" . "\n FROM #__content AS c" . "\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 z ON z.id = c.created_by" . "\n WHERE c.sectionid = 0" . "\n AND c.catid = 0" . "\n AND c.state != -2" . $search_query . $filter . "\n ORDER BY " . $order;
    $database->setQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    $count = count($rows);
    for ($i = 0; $i < $count; $i++) {
        $query = "SELECT COUNT( id )" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $rows[$i]->id . "\n AND type = 'content_typed'" . "\n AND published != -2";
        $database->setQuery($query);
        $rows[$i]->links = $database->loadResult();
    }
    $ordering[] = mosHTML::makeOption('c.ordering ASC', 'Ordering asc');
    $ordering[] = mosHTML::makeOption('c.ordering DESC', 'Ordering desc');
    $ordering[] = mosHTML::makeOption('c.id ASC', 'ID asc');
    $ordering[] = mosHTML::makeOption('c.id DESC', 'ID desc');
    $ordering[] = mosHTML::makeOption('c.title ASC', 'Title asc');
    $ordering[] = mosHTML::makeOption('c.title DESC', 'Title desc');
    $ordering[] = mosHTML::makeOption('c.created ASC', 'Date asc');
    $ordering[] = mosHTML::makeOption('c.created DESC', 'Date desc');
    $ordering[] = mosHTML::makeOption('z.name ASC', 'Author asc');
    $ordering[] = mosHTML::makeOption('z.name DESC', 'Author desc');
    $ordering[] = mosHTML::makeOption('c.state ASC', 'Published asc');
    $ordering[] = mosHTML::makeOption('c.state DESC', 'Published desc');
    $ordering[] = mosHTML::makeOption('c.access ASC', 'Access asc');
    $ordering[] = mosHTML::makeOption('c.access DESC', 'Access desc');
    $javascript = 'onchange="document.adminForm.submit();"';
    $lists['order'] = mosHTML::selectList($ordering, 'zorder', 'class="inputbox" size="1"' . $javascript, 'value', 'text', $order);
    // get list of Authors for dropdown filter
    $query = "SELECT c.created_by AS value, u.name AS text" . "\n FROM #__content AS c" . "\n LEFT JOIN #__users AS u ON u.id = c.created_by" . "\n WHERE c.sectionid = 0" . "\n GROUP BY u.name" . "\n ORDER BY u.name";
    $authors[] = mosHTML::makeOption('0', _SEL_AUTHOR);
    $database->setQuery($query);
    $authors = array_merge($authors, $database->loadObjectList());
    $lists['authorid'] = mosHTML::selectList($authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_authorid);
    HTML_typedcontent::showContent($rows, $pageNav, $option, $search, $lists);
}
Exemple #2
0
/**
* Compiles a list of installed or defined modules
* @param database A database connector object
*/
function view($option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $order = $mainframe->getUserStateFromRequest("order", 'order', 'c.id DESC');
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0);
    //$limitstart = 0;
    $search = $mainframe->getUserStateFromRequest("search{$option}", 'search', '');
    $search = $database->getEscaped(trim(strtolower($search)));
    // used by filter
    if ($search) {
        $search_query = "\n AND ( LOWER( c.title ) LIKE '%{$search}%' OR LOWER( c.title_alias ) LIKE '%{$search}%' )";
    } else {
        $search_query = '';
    }
    // get the total number of records
    $query = "SELECT count(*)" . "\n FROM #__content AS c" . "\n WHERE c.sectionid = '0'" . "\n AND c.catid = '0'" . "\n AND c.state <> '-2'";
    $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, u.name AS editor, z.name AS creator" . "\n FROM #__content AS c" . "\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 z ON z.id = c.created_by" . "\n WHERE c.sectionid = '0'" . "\n AND c.catid = '0'" . "\n AND c.state <> '-2'" . $search_query . "\n ORDER BY " . $order . "\n LIMIT {$pageNav->limitstart},{$pageNav->limit}";
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    $count = count($rows);
    for ($i = 0; $i < $count; $i++) {
        $query = "SELECT COUNT( id )" . "\n FROM #__menu" . "\n WHERE componentid = " . $rows[$i]->id . "\n AND type = 'content_typed'";
        $database->setQuery($query);
        $rows[$i]->links = $database->loadResult();
    }
    $ordering[] = mosHTML::makeOption('c.id ASC', 'ID asc');
    $ordering[] = mosHTML::makeOption('c.id DESC', 'ID desc');
    $ordering[] = mosHTML::makeOption('c.title ASC', 'Title asc');
    $ordering[] = mosHTML::makeOption('c.title DESC', 'Title desc');
    $ordering[] = mosHTML::makeOption('c.created ASC', 'Date asc');
    $ordering[] = mosHTML::makeOption('c.created DESC', 'Date desc');
    $ordering[] = mosHTML::makeOption('z.name ASC', 'Author asc');
    $ordering[] = mosHTML::makeOption('z.name DESC', 'Author desc');
    $ordering[] = mosHTML::makeOption('c.state ASC', 'Published asc');
    $ordering[] = mosHTML::makeOption('c.state DESC', 'Published desc');
    $ordering[] = mosHTML::makeOption('c.access ASC', 'Access asc');
    $ordering[] = mosHTML::makeOption('c.access DESC', 'Access desc');
    $javascript = 'onchange="document.adminForm.submit();"';
    $lists['order'] = mosHTML::selectList($ordering, 'order', 'class="inputbox" size="1"' . $javascript, 'value', 'text', $order);
    HTML_typedcontent::showContent($rows, $pageNav, $option, $search, $lists);
}