示例#1
0
/**
* Display main view (list of years)
*
* Displays an overview of all the years and months, starting with the first
* year for which a story has been posted. Can optionally display a list of
* the stories for the current month at the top of the page.
*
* @param    string  $topic                  current topic
* @param    boolean $list_current_month     true = list stories f. current month
* @return   string                          list of all the years in the db
*
*/
function DIR_displayAll($topic, $list_current_month = false)
{
    global $_TABLES, $LANG_DIR;
    $retval = '';
    if ($list_current_month) {
        $currentyear = date('Y', time());
        $currentmonth = date('n', time());
        $retval .= DIR_displayMonth($topic, $currentyear, $currentmonth);
        $retval .= '<hr' . XHTML . '>' . LB;
    }
    $retval .= '<div><h1 style="display:inline">' . $LANG_DIR['title'] . '</h1> ' . DIR_topicList($topic) . '</div>' . LB;
    $yearsql = array();
    $yearsql['mysql'] = "SELECT DISTINCT YEAR(date) AS year,date FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW())" . COM_getTopicSql('AND') . COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND');
    $yearsql['mssql'] = "SELECT YEAR(date) AS year FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW())" . COM_getTopicSql('AND') . COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND');
    $yearsql['pgsql'] = "SELECT EXTRACT( YEAR from date) AS year FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW())" . COM_getTopicSql('AND') . COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND');
    $ysql = array();
    $ysql['mysql'] = $yearsql['mysql'] . " GROUP BY YEAR(date) ORDER BY date DESC";
    $ysql['mssql'] = $yearsql['mssql'] . " GROUP BY YEAR(date) ORDER BY YEAR(date) DESC";
    $ysql['pgsql'] = $yearsql['pgsql'] . " GROUP BY year,date ORDER BY year DESC";
    $yresult = DB_query($ysql);
    $numyears = DB_numRows($yresult);
    for ($i = 0; $i < $numyears; $i++) {
        $Y = DB_fetchArray($yresult);
        $retval .= DIR_displayYear($topic, $Y['year']);
    }
    return $retval;
}
示例#2
0
/**
 * Display main view (list of years)
 * Displays an overview of all the years and months, starting with the first
 * year for which a story has been posted. Can optionally display a list of
 * the stories for the current month at the top of the page.
 *
 * @param    Template $template  reference of the template
 * @param    string   $dir_topic current topic
 * @return   string                list of all the years in the db
 */
function DIR_displayAll($template, $dir_topic)
{
    global $_TABLES, $LANG_DIR;
    $retval = '';
    $yearsql = array();
    $yearsql['mysql'] = "SELECT DISTINCT YEAR(date) AS year, date\n        FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n        WHERE (draft_flag = 0) AND (date <= NOW())\n        AND ta.type = 'article' AND ta.id = sid\n        " . COM_getTopicSQL('AND', 0, 'ta') . COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND');
    $yearsql['pgsql'] = "SELECT EXTRACT(YEAR from date) AS year\n        FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n        WHERE (draft_flag = 0) AND (date <= NOW())\n        AND ta.type = 'article' AND ta.id = sid\n        " . COM_getTopicSQL('AND', 0, 'ta') . COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND');
    $ySql = array();
    $ySql['mysql'] = $yearsql['mysql'] . " GROUP BY year, date ORDER BY date DESC";
    $ySql['pgsql'] = $yearsql['pgsql'] . " GROUP BY year, date ORDER BY year DESC";
    $yResult = DB_query($ySql);
    $numYears = DB_numRows($yResult);
    if ($numYears > 0) {
        for ($i = 0; $i < $numYears; $i++) {
            $Y = DB_fetchArray($yResult);
            if (TEMPLATE_EXISTS) {
                $template->set_var('section_title', $Y['year']);
                $retval .= $template->parse('title', 'section-title') . LB;
            } else {
                $retval .= '<h3>' . $Y['year'] . '</h3>' . LB;
            }
            $retval .= DIR_displayYear($template, $dir_topic, $Y['year']);
        }
    } else {
        if (TEMPLATE_EXISTS) {
            $retval .= $template->parse('message', 'no-articles') . LB;
        } else {
            $retval .= '<p>' . $LANG_DIR['no_articles'] . '</p>' . LB;
        }
    }
    return $retval;
}
示例#3
0
/**
* Display main view (list of years)
*
* Displays an overview of all the years and months, starting with the first
* year for which a story has been posted. Can optionally display a list of
* the stories for the current month at the top of the page.
*
* @param    ref    &$template  reference of the template
* @param    string  $dir_topic current topic
* @return   string             list of all the years in the db
*
*/
function DIR_displayAll(&$template, $dir_topic)
{
    global $_TABLES, $LANG_DIR;
    $retval = '';
    $yearsql = array();
    $yearsql['mysql'] = "SELECT DISTINCT YEAR(date) AS year,date FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW())" . COM_getTopicSql('AND') . COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND');
    $ysql = array();
    $ysql['mysql'] = $yearsql['mysql'] . " GROUP BY YEAR(date) ORDER BY date DESC";
    $yresult = DB_query($ysql);
    $numyears = DB_numRows($yresult);
    if ($numyears > 0) {
        for ($i = 0; $i < $numyears; $i++) {
            $Y = DB_fetchArray($yresult);
            $template->set_var('section_title', $Y['year']);
            $retval .= $template->parse('title', 'section-title') . LB;
            $retval .= DIR_displayYear($template, $dir_topic, $Y['year']);
        }
    } else {
        $retval .= $template->parse('message', 'no-articles') . LB;
    }
    return $retval;
}