From ab57198a565f87fced9fe902c895d23cdde4a019 Mon Sep 17 00:00:00 2001 From: e107steved Date: Tue, 21 Oct 2008 19:03:20 +0000 Subject: [PATCH] Bugtracker #4547 - reduce query count (thanks Fanat1k) plus a bit of XHTML compliance while there --- e107_plugins/blogcalendar_menu/archive.php | 71 ++++++++++++---------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/e107_plugins/blogcalendar_menu/archive.php b/e107_plugins/blogcalendar_menu/archive.php index 3061d4081..39eff788c 100644 --- a/e107_plugins/blogcalendar_menu/archive.php +++ b/e107_plugins/blogcalendar_menu/archive.php @@ -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 = "
"; -$year_selector .= "".BLOGCAL_ARCHIV1.": \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 .= ""; + $year_selector .= ">".$i."\n"; } -$year_selector .= ""; +$year_selector .= "\n
"; // -------------------------- @@ -108,9 +109,11 @@ $year_selector .= ""; // -------------------------- $newline = 0; $archive = "
"; -$archive .= ""; -for($i = 1; $i <= 12; $i++) { - if (++$newline == $months_per_row+1) { +$archive .= ""; +for($i = 1; $i <= 12; $i++) +{ + if (++$newline == $months_per_row+1) + { $archive .= ""; $newline = 1; } @@ -118,16 +121,22 @@ for($i = 1; $i <= 12; $i++) { $archive .= "
"; // 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 .= "".$marray[$i-1].""; - } else { + } + else + { $archive .= $marray[$i-1]; } $archive .= "
"; - 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 .= "
".calendar($req_day, $i, $req_year, $day_links[$i], $pref['blogcal_ws'])."
\n";
$year_selector
{$year_selector}