Esempio n. 1
0
/**
* List the records
* @param string The current GET/POST option
*/
function showNewsFeeds($option)
{
    global $database, $mainframe, $mosConfig_list_limit;
    $catid = intval($mainframe->getUserStateFromRequest("catid{$option}", 'catid', 0));
    $limit = intval($mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit));
    $limitstart = intval($mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0));
    // get the total number of records
    $query = "SELECT COUNT(*)" . "\n FROM #__newsfeeds" . ($catid ? "\n WHERE catid = " . (int) $catid : '');
    $database->setQuery($query);
    $total = $database->loadResult();
    require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php';
    $pageNav = new mosPageNav($total, $limitstart, $limit);
    // get the subset (based on limits) of required records
    $query = "SELECT a.*, c.name AS catname, u.name AS editor" . "\n FROM #__newsfeeds AS a" . "\n LEFT JOIN #__categories AS c ON c.id = a.catid" . "\n LEFT JOIN #__users AS u ON u.id = a.checked_out" . ($catid ? "\n WHERE a.catid = " . (int) $catid : '') . "\n ORDER BY a.ordering";
    $database->setQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    // build list of categories
    $javascript = 'onchange="document.adminForm.submit();"';
    $lists['category'] = mosAdminMenus::ComponentCategory('catid', $option, $catid, $javascript);
    HTML_newsfeeds::showNewsFeeds($rows, $lists, $pageNav, $option);
}
Esempio n. 2
0
/**
* List the records
*/
function showNewsFeeds()
{
    global $mainframe, $option;
    $db =& JFactory::getDBO();
    $filter_order = $mainframe->getUserStateFromRequest("{$option}.filter_order", 'filter_order', 'a.ordering', 'cmd');
    $filter_order_Dir = $mainframe->getUserStateFromRequest("{$option}.filter_order_Dir", 'filter_order_Dir', '', 'word');
    $filter_state = $mainframe->getUserStateFromRequest("{$option}.filter_state", 'filter_state', '', 'word');
    $filter_catid = $mainframe->getUserStateFromRequest("{$option}.filter_catid", 'filter_catid', 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');
    $where = array();
    if ($filter_catid) {
        $where[] = 'a.catid = ' . (int) $filter_catid;
    }
    if ($search) {
        $where[] = 'LOWER(a.name) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false);
    }
    if ($filter_state) {
        if ($filter_state == 'P') {
            $where[] = 'a.published = 1';
        } else {
            if ($filter_state == 'U') {
                $where[] = 'a.published = 0';
            }
        }
    }
    $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
    if ($filter_order == 'a.ordering') {
        $orderby = ' ORDER BY catname, a.ordering';
    } else {
        $orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir . ', catname, a.ordering';
    }
    // get the total number of records
    $query = 'SELECT COUNT(*) ' . ' FROM #__newsfeeds AS a' . $where;
    $db->setQuery($query);
    $total = $db->loadResult();
    jimport('joomla.html.pagination');
    $pageNav = new JPagination($total, $limitstart, $limit);
    // get the subset (based on limits) of required records
    $query = 'SELECT a.*, c.title AS catname, u.name AS editor' . ' FROM #__newsfeeds AS a' . ' LEFT JOIN #__categories AS c ON c.id = a.catid' . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' . $where . $orderby;
    $db->setQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $db->loadObjectList();
    if ($db->getErrorNum()) {
        echo $db->stderr();
        return false;
    }
    // build list of categories
    $javascript = 'onchange="document.adminForm.submit();"';
    $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_newsfeeds', $filter_catid, $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;
    HTML_newsfeeds::showNewsFeeds($rows, $lists, $pageNav, $option);
}