Location: PHPKode > projects > Gnew > Gnew-2013.1/news/browse.php
<?php
// -----------------------------------------------------------------------------
// $Id: browse.php 642 2013-03-22 11:52:04Z raoul $
//
// Copyright (C) 2013 Raoul Proença
// License: GNU GPL version 3 (see copying.txt file)
// Website: http://www.gnew.fr/
// -----------------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------------

include('./../includes/common.php');

page_header($lang['NEWS_BROWSE']);

$category_name_options = '<option></option>';
$sql->query('SELECT DISTINCT ' . TABLE_CATEGORIES . '.category_id, ' . TABLE_CATEGORIES . '.category_name
             FROM ' . TABLE_CATEGORIES . ', ' . TABLE_NEWS . '
             WHERE ' . TABLE_CATEGORIES . '.category_id = ' . TABLE_NEWS . '.category_id
             AND ' . TABLE_CATEGORIES . '.category_level IN (\'2\', \'4\')
             AND ' . TABLE_NEWS . '.news_active = \'1\'
             ORDER BY ' . TABLE_CATEGORIES . '.category_name');
while ($table_categories = $sql->fetch())
{
    $category_name_options .= '<option value="' . $table_categories['category_id'] . '">' . $table_categories['category_name'] . '</option>';
}

$month_list = array('01' => $lang['JANUARY'],
                    '02' => $lang['FEBRUARY'],
                    '03' => $lang['MARCH'],
                    '04' => $lang['APRIL'],
                    '05' => $lang['MAY'],
                    '06' => $lang['JUNE'],
                    '07' => $lang['JULY'],
                    '08' => $lang['AUGUST'],
                    '09' => $lang['SEPTEMBER'],
                    '10' => $lang['OCTOBER'],
                    '11' => $lang['NOVEMBER'],
                    '12' => $lang['DECEMBER']);
$news_month_options = '<option></option>';
$sql->query('SELECT DISTINCT news_month
             FROM ' . TABLE_NEWS . '
             WHERE news_active = \'1\'
             ORDER BY news_month');
while ($table_news = $sql->fetch())
{
    $news_month_options .= '<option value="' . $table_news['news_month'] . '">' . $month_list[$table_news['news_month']] . '</option>';
}

$news_year_options = '<option></option>';
$sql->query('SELECT DISTINCT news_year
             FROM ' . TABLE_NEWS . '
             WHERE news_active = \'1\'
             ORDER BY news_year');
while ($table_news = $sql->fetch())
{
    $news_year_options .= '<option>' . $table_news['news_year'] . '</option>';
}

$template->set_file('browse', 'news/browse.htpl');
$template->set_var(array('CATEGORY_NAME_OPTIONS' => $category_name_options,
                         'NEWS_MONTH_OPTIONS' => $news_month_options,
                         'NEWS_YEAR_OPTIONS' => $news_year_options));
$template->parse('browse', null, false, array(TABLE_CATEGORIES, TABLE_NEWS));

page_footer();

?>
Return current item: Gnew