mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
Bugtracker #4547 - reduce query count (thanks Fanat1k) plus a bit of XHTML compliance while there
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/blogcalendar_menu/archive.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2007-12-03 20:38:01 $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-10-21 19:03:16 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
| Based on code by: Thomas Bouve (crahan@gmx.net)
|
||||
@@ -21,12 +21,7 @@
|
||||
require_once("../../class2.php");
|
||||
require_once(e_HANDLER."userclass_class.php");
|
||||
|
||||
$lan_file = e_PLUGIN."blogcalendar_menu/languages/".e_LANGUAGE.".php";
|
||||
if (file_exists($lan_file)) {
|
||||
require_once($lan_file);
|
||||
} else {
|
||||
require_once(e_PLUGIN."blogcalendar_menu/languages/English.php");
|
||||
};
|
||||
include_lan(e_PLUGIN."blogcalendar_menu/languages/".e_LANGUAGE.".php");
|
||||
require_once("calendar.php");
|
||||
require_once("functions.php");
|
||||
require_once(HEADERF);
|
||||
@@ -34,7 +29,7 @@ require_once(HEADERF);
|
||||
// ---------------------
|
||||
// initialize some cruft
|
||||
// ---------------------
|
||||
$sql = new db;
|
||||
$bcSql = new db;
|
||||
$prefix = e_PLUGIN."blogcalendar_menu";
|
||||
$marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4,
|
||||
BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8,
|
||||
@@ -66,8 +61,8 @@ if (!isset($req_year)) $req_year = $cur_year;
|
||||
// --------------------------------
|
||||
// look for the first and last year
|
||||
// --------------------------------
|
||||
$sql->db_Select_gen("SELECT news_id, news_datestamp from #news ORDER BY news_datestamp LIMIT 0,1");
|
||||
$first_post = $sql->db_Fetch();
|
||||
$bcSql->db_Select_gen("SELECT news_id, news_datestamp from #news ORDER BY news_datestamp LIMIT 0,1");
|
||||
$first_post = $bcSql->db_Fetch();
|
||||
$start_year = date("Y", $first_post['news_datestamp']);
|
||||
$end_year = $cur_year;
|
||||
|
||||
@@ -76,31 +71,37 @@ $end_year = $cur_year;
|
||||
// build the yearselector
|
||||
// ----------------------
|
||||
$year_selector = "<div class='forumheader' style='text-align: center; margin-bottom: 2px;'>";
|
||||
$year_selector .= "".BLOGCAL_ARCHIV1.": <select name='activate' onChange='urljump(this.options[selectedIndex].value)' class='tbox'>";
|
||||
$year_selector .= "".BLOGCAL_ARCHIV1.": <select name='activate' onchange='urljump(this.options[selectedIndex].value)' class='tbox'>\n";
|
||||
|
||||
for($i = $start_year; $i <= $end_year; $i++) {
|
||||
for($i = $start_year; $i <= $end_year; $i++)
|
||||
{
|
||||
$start = mktime(0, 0, 0, 1, 1, intval($req_year));
|
||||
$end = mktime(23, 59, 59, 12, 31, intval($req_year));
|
||||
// create the option entry
|
||||
$year_link = $prefix."/archive.php?year.".$i;
|
||||
$year_selector .= "<option value='".$year_link."'";
|
||||
if ($i == $req_year) {
|
||||
$year_selector .= " selected";
|
||||
}
|
||||
if ($sql->db_Select("news", "news_id, news_datestamp, news_class", "news_datestamp > $start AND news_datestamp < $end")) {
|
||||
while ($news = $sql->db_Fetch()) {
|
||||
if (check_class($news['news_class'])) {
|
||||
list($xmonth, $xday) = explode(" ", date("n j", $news['news_datestamp']));
|
||||
if (!$day_links[$xmonth][$xday]) {
|
||||
$day_links[$xmonth][$xday] = e_BASE."news.php?day.".formatdate($req_year, $xmonth, $xday);
|
||||
if ($i == $req_year)
|
||||
{
|
||||
$year_selector .= " selected='selected'";
|
||||
if ($bcSql->db_Select("news", "news_id, news_datestamp, news_class", "news_datestamp > {$start} AND news_datestamp < {$end}"))
|
||||
{
|
||||
while ($news = $bcSql->db_Fetch())
|
||||
{
|
||||
if (check_class($news['news_class']))
|
||||
{
|
||||
list($xmonth, $xday) = explode(" ", date("n j", $news['news_datestamp']));
|
||||
if (!$day_links[$xmonth][$xday])
|
||||
{
|
||||
$day_links[$xmonth][$xday] = e_BASE."news.php?day.".formatdate($req_year, $xmonth, $xday);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$year_selector .= ">".$i."</option>";
|
||||
$year_selector .= ">".$i."</option>\n";
|
||||
}
|
||||
|
||||
$year_selector .= "</select>";
|
||||
$year_selector .= "</select>\n</div>";
|
||||
|
||||
|
||||
// --------------------------
|
||||
@@ -108,9 +109,11 @@ $year_selector .= "</select>";
|
||||
// --------------------------
|
||||
$newline = 0;
|
||||
$archive = "<div style='text-align:center'><table border='0' cellspacing='7'><tr>";
|
||||
$archive .= "<td colspan='$months_per_row'><div>$year_selector</div></td></tr><tr>";
|
||||
for($i = 1; $i <= 12; $i++) {
|
||||
if (++$newline == $months_per_row+1) {
|
||||
$archive .= "<td colspan='{$months_per_row}'>{$year_selector}</td></tr><tr>";
|
||||
for($i = 1; $i <= 12; $i++)
|
||||
{
|
||||
if (++$newline == $months_per_row+1)
|
||||
{
|
||||
$archive .= "</tr><tr>";
|
||||
$newline = 1;
|
||||
}
|
||||
@@ -118,16 +121,22 @@ for($i = 1; $i <= 12; $i++) {
|
||||
$archive .= "<div class='fcaption' style='text-align:center; margin-bottom:2px;'>";
|
||||
|
||||
// href the current month regardless of newsposts or any month with news
|
||||
if (($req_year == $cur_year && $i == $cur_month) || $day_links[$i]) {
|
||||
if (($req_year == $cur_year && $i == $cur_month) || $day_links[$i])
|
||||
{
|
||||
$archive .= "<a class='forumlink' href='".e_BASE."news.php?month.".formatDate($req_year, $i)."'>".$marray[$i-1]."</a>";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$archive .= $marray[$i-1];
|
||||
}
|
||||
|
||||
$archive .= "</div>";
|
||||
if (($req_year == $cur_year) && ($i == $cur_month)) {
|
||||
if (($req_year == $cur_year) && ($i == $cur_month))
|
||||
{
|
||||
$req_day = $cur_day;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$req_day = "";
|
||||
}
|
||||
$archive .= "<div>".calendar($req_day, $i, $req_year, $day_links[$i], $pref['blogcal_ws'])."</div></td>\n";
|
||||
|
Reference in New Issue
Block a user