示例#1
0
文件: content.php 项目: cwcw/cms
function showArchiveSection($id = NULL, $gid, &$access, $pop, $option)
{
    global $database, $mainframe, $mosConfig_offset;
    global $Itemid;
    $noauth = !$mainframe->getCfg('shownoauth');
    // Paramters
    $year = mosGetParam($_REQUEST, 'year', date('Y'));
    $month = mosGetParam($_REQUEST, 'month', date('m'));
    $params = new stdClass();
    if ($Itemid) {
        $menu = new mosMenu($database);
        $menu->load($Itemid);
        $params =& new mosParameters($menu->params);
    } else {
        $menu = "";
        $params =& new mosParameters('');
    }
    $params->set('intro_only', 1);
    $params->set('year', $year);
    $params->set('month', $month);
    // Ordering control
    $orderby_sec = $params->def('orderby_sec', 'rdate');
    $orderby_pri = $params->def('orderby_pri', '');
    $order_sec = _orderby_sec($orderby_sec);
    $order_pri = _orderby_pri($orderby_pri);
    // used in query
    $where = _where(-1, $access, $noauth, $gid, $id, NULL, $year, $month);
    // checks to see if 'All Sections' options used
    if ($id == 0) {
        $check = '';
    } else {
        $check = 'AND a.sectionid = ' . $id;
    }
    // query to determine if there are any archived entries for the section
    $query = "SELECT a.id" . "\n FROM #__content as a" . "\n WHERE a.state = '-1'" . $check;
    $database->setQuery($query);
    $items = $database->loadObjectList();
    $archives = count($items);
    // Main Query
    $query = "SELECT a.*, ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, u.name AS author, u.usertype, cc.name AS category, g.name AS groups" . "\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 #__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_pri . $order_sec;
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    // initiate form
    echo '<form action="' . sefRelToAbs('index.php?option=' . $option . '&amp;task=archivesection&amp;id=' . $id . '&amp;Itemid=' . $Itemid) . '" method="post">';
    // Dynamic 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>';
}
示例#2
0
function showArchiveSection($id = NULL, $gid, &$access, $pop, $option, $year, $month, $limit, $limitstart)
{
    global $database, $mainframe;
    global $Itemid;
    $secID = $id ? $id : 0;
    $noauth = !$mainframe->getCfg('shownoauth');
    $params = new stdClass();
    if ($Itemid) {
        $menu = $mainframe->get('menu');
        $params = new mosParameters($menu->params);
    } else {
        $menu = "";
        $params = new mosParameters('');
    }
    $params->set('intro_only', 1);
    $params->set('year', $year);
    $params->set('month', $month);
    // Ordering control
    $orderby_sec = $params->def('orderby_sec', 'rdate');
    $orderby_pri = $params->def('orderby_pri', '');
    $order_sec = _orderby_sec($orderby_sec);
    $order_pri = _orderby_pri($orderby_pri);
    // used in query
    $where = _where(-1, $access, $noauth, $gid, $id, NULL, $year, $month);
    $where = count($where) ? "\n WHERE " . implode("\n AND ", $where) : '';
    // checks to see if 'All Sections' options used
    if ($id == 0) {
        $check = '';
    } else {
        $check = "\n AND a.sectionid = " . (int) $id;
    }
    // query to determine if there are any archived entries for the section
    $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_pri} {$order_sec}";
    $database->setQuery($query, $limitstart, $limit);
    $rows = $database->loadObjectList();
    // check whether section is published
    if (!count($rows) && $secID != 0) {
        $secCheck = new mosSection($database);
        $secCheck->load((int) $secID);
        /*
         * check whether section is published
         */
        if (!$secCheck->published) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section access level allows access
         */
        if ($secCheck->access > $gid) {
            mosNotAuth();
            return;
        }
    }
    // initiate form
    $link = 'index.php?option=com_content&task=archivesection&id=' . $id . '&Itemid=' . $Itemid;
    echo '<form action="' . sefRelToAbs($link) . '" method="post">';
    // Dynamic 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, $limitstart, $limit, $total, 1, 1);
    }
    echo '<input type="hidden" name="id" value="' . $id . '" />';
    echo '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
    echo '<input type="hidden" name="task" value="archivesection" />';
    echo '<input type="hidden" name="option" value="com_content" />';
    echo '</form>';
}