From c52a3feafeab874cab7c8304b08cf3dd4887792b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 21 Jan 2003 22:50:03 +0000 Subject: - Applied David's calendar patch: you can now configure at what day a week start. --- modules/archive/archive.module | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'modules/archive/archive.module') diff --git a/modules/archive/archive.module b/modules/archive/archive.module index fb21d06e3..daeb9f4fc 100644 --- a/modules/archive/archive.module +++ b/modules/archive/archive.module @@ -42,14 +42,20 @@ function archive_calendar($original = 0) { // Generate calendar header: $output .= "\n\n"; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; + + // First day of week (0 => Sunday, 1 => Monday, ...) + $weekstart = variable_get("default_firstday", 0); + + // Last day of week + ($weekstart - 1 == -1 ) ? $lastday = 6 : $lastday = $weekstart - 1; // Generate the days of the week: - $somesunday = mktime(0, 0, 0, 3, 20, 1994); + $firstcolumn = mktime(0, 0, 0, 3, 20 + $weekstart, 1994); $output .= " "; for ($i = 0; $i < 7; $i++) { - $output .= ""; + $output .= ""; } $output .= "\n"; @@ -60,13 +66,14 @@ function archive_calendar($original = 0) { // Loop through all the days of the month: while ($nday <= $last) { // Set up blank days for first week of the month: - if ($first) { - $output .= " \n"; - $first = 0; + if ($first != $weekstart) { + $blankdays = ($first - $weekstart + 7) % 7; + $output .= " \n"; + $first = $weekstart; } // Start every week on a new line: - if ($sday == 0) { + if ($sday == $weekstart) { $output .= " \n"; } @@ -84,7 +91,7 @@ function archive_calendar($original = 0) { } // Start every week on a new line: - if ($sday == 6) { + if ($sday == $lastday) { $output .= " \n"; } @@ -95,8 +102,8 @@ function archive_calendar($original = 0) { } // Complete the calendar: - if ($sday) { - $end = 7 - $sday; + if ($sday != $weekstart) { + $end = (7 - $sday + $weekstart) % 7; $output .= " \n \n"; } @@ -181,4 +188,11 @@ function archive_page() { $theme->footer(); } -?> \ No newline at end of file +function archive_conf_options() { + + $output .= form_select( t("First day of week"), "default_firstday", variable_get("default_firstday", 0), array(0 => t("Sunday"), 1 => t("Monday"), 2 => t("Tuesday"), 3 => t("Wednesday"), 4 => t("Thursday"), 5 => t("Friday"), 6 => t("Saturday")), t("The first day of the week. By changing this value you choose how the calendar block is rendered.")); + + return $output; +} + +?> -- cgit v1.2.3
". l("<", "archive/". date("Y/m/d", $prev)) ." ". date("F Y", $requested) ." ". ($next <= time() ? l(">", "archive/". date("Y/m/d", $next)) : ">") ."
". l("<", "archive/". date("Y/m/d", $prev)) ." ". date("F Y", $requested) ." ". ($nextmonth <= time() ? l(">", "archive/". date("Y/m/d", $next)) : ">") ."
". substr(ucfirst(t(date("l", $somesunday + $i * 86400))), 0, 1) ."". substr(ucfirst(t(date("l", $firstcolumn + $i * 86400))), 0, 1) ."