Ejemplo n.º 1
0
Archivo: content.php Proyecto: cwcw/cms
function showArchiveCategory($id = 0, $gid, &$access, $pop, $option, $now)
{
    global $database, $mainframe, $mosConfig_offset;
    global $Itemid;
    // Parameters
    $noauth = !$mainframe->getCfg('shownoauth');
    $year = mosGetParam($_REQUEST, 'year', date('Y'));
    $month = mosGetParam($_REQUEST, 'month', date('m'));
    $module = trim(mosGetParam($_REQUEST, 'module', ''));
    // used by archive module
    if ($module) {
        $check = '';
    } else {
        $check = 'AND a.catid = ' . $id;
    }
    if ($Itemid) {
        $menu = new mosMenu($database);
        $menu->load($Itemid);
        $params =& new mosParameters($menu->params);
    } else {
        $menu = "";
        $params =& new mosParameters('');
    }
    $params->set('year', $year);
    $params->set('month', $month);
    // Ordering control
    $orderby_sec = $params->def('orderby', 'rdate');
    $order_sec = _orderby_sec($orderby_sec);
    // used in query
    $where = _where(-2, $access, $noauth, $gid, $id, NULL, $year, $month);
    // query to determine if there are any archived entries for the category
    $query = "SELECT a.id" . "\n FROM #__content as a" . "\n WHERE a.state = '-1'" . "\n " . $check;
    $database->setQuery($query);
    $items = $database->loadObjectList();
    $archives = count($items);
    $query = "SELECT a.*, ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count, u.name AS author, u.usertype, s.name AS section, g.name AS groups" . "\n FROM #__content AS a" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . (count($where) ? "\n WHERE " . implode("\n AND ", $where) : '') . "\n AND s.access <= " . $gid . "\n ORDER BY " . $order_sec;
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    // initiate form
    echo '<form action="' . sefRelToAbs('index.php?option=' . $option . '&amp;task=archivecategory&amp;id=' . $id . '&amp;Itemid=' . $Itemid) . '" method="post">';
    // Page Title
    $mainframe->SetPageTitle($menu->name);
    if (!$archives) {
        // if no archives for category, hides search and outputs empty message
        echo '<br /><div align="center">' . _CATEGORY_ARCHIVE_EMPTY . '</div>';
    } else {
        BlogOutput($rows, $params, $gid, $access, $pop, $menu, 1);
    }
    echo '</form>';
}
Ejemplo n.º 2
0
function showArchiveCategory($id = 0, $gid, &$access, $pop, $option, $year, $month, $module, $limit, $limitstart)
{
    global $database, $mainframe;
    global $Itemid;
    $now = _CURRENT_SERVER_TIME;
    $noauth = !$mainframe->getCfg('shownoauth');
    // needed for check whether section & category is published
    $catID = $id ? $id : 0;
    // used by archive module
    if ($module) {
        $check = '';
    } else {
        $check = "\n AND a.catid = " . (int) $id;
    }
    if ($Itemid) {
        $menu = $mainframe->get('menu');
        $params = new mosParameters($menu->params);
    } else {
        $menu = '';
        $params = new mosParameters('');
    }
    $params->set('year', $year);
    $params->set('month', $month);
    // Ordering control
    $orderby_sec = $params->def('orderby', 'rdate');
    $order_sec = _orderby_sec($orderby_sec);
    // used in query
    $where = _where(-2, $access, $noauth, $gid, $id, NULL, $year, $month);
    $where = count($where) ? "\n WHERE " . implode("\n AND ", $where) : '';
    // query to determine if there are any archived entries for the category
    $query = "SELECT a.id" . "\n FROM #__content as a" . "\n WHERE a.state = -1" . $check;
    $database->setQuery($query);
    $items = $database->loadObjectList();
    $archives = count($items);
    // voting control
    $voting = $params->def('rating', '');
    $voting = votingQuery($voting);
    // Limit & limitstart
    $intro = $params->def('intro', 4);
    $leading = $params->def('leading', 1);
    $links = $params->def('link', 4);
    $limit = $limit ? $limit : $intro + $leading + $links;
    // query to determine total number of records
    $query = "SELECT COUNT(a.id)" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . $where;
    $database->setQuery($query);
    $total = $database->loadResult();
    if ($total <= $limit) {
        $limitstart = 0;
    }
    // main query
    $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by," . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access," . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups" . $voting['select'] . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . $voting['join'] . $where . "\n ORDER BY {$order_sec}";
    $database->setQuery($query, $limitstart, $limit);
    $rows = $database->loadObjectList();
    // check whether section & category is published
    if (!count($rows) && $catID != 0) {
        $catCheck = new mosCategory($database);
        $catCheck->load((int) $catID);
        /*
         * check whether category is published
         */
        if (!$catCheck->published) {
            mosNotAuth();
            return;
        }
        /*
         * check whether category access level allows access
         */
        if ($catCheck->access > $gid) {
            mosNotAuth();
            return;
        }
        $secCheck = new mosSection($database);
        $secCheck->load($catCheck->section);
        /*
         * check whether section is published
         */
        if (!$secCheck->published) {
            mosNotAuth();
            return;
        }
        /*
         * check whether category access level allows access
         */
        if ($secCheck->access > $gid) {
            mosNotAuth();
            return;
        }
    }
    // initiate form
    $link = ampReplace('index.php?option=com_content&task=archivecategory&id=' . $id . '&Itemid=' . $Itemid);
    echo '<form action="' . sefRelToAbs($link) . '" method="post">';
    // Page Title
    $mainframe->SetPageTitle($menu->name);
    if (!$archives) {
        // if no archives for category, hides search and outputs empty message
        echo '<br />';
        echo '<div align="center">' . _CATEGORY_ARCHIVE_EMPTY . '</div>';
    } else {
        // if coming from the Archive Module, the Archive Dropdown selector is not shown
        if ($id) {
            BlogOutput($rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 1, 1);
        } else {
            BlogOutput($rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 0, 1);
        }
    }
    echo '<input type="hidden" name="id" value="' . $id . '" />';
    echo '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
    echo '<input type="hidden" name="task" value="archivecategory" />';
    echo '<input type="hidden" name="option" value="com_content" />';
    echo '</form>';
}