summaryrefslogtreecommitdiff
path: root/modules/archive
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2003-01-21 22:50:03 +0000
committerDries Buytaert <dries@buytaert.net>2003-01-21 22:50:03 +0000
commitc52a3feafeab874cab7c8304b08cf3dd4887792b (patch)
treebd74b91c7d2c6cd9eb49c9fe853653be6c81583e /modules/archive
parent9a23223e253d95377123a9b4b49a54cc8cdbe744 (diff)
downloadbrdo-c52a3feafeab874cab7c8304b08cf3dd4887792b.tar.gz
brdo-c52a3feafeab874cab7c8304b08cf3dd4887792b.tar.bz2
- Applied David's calendar patch: you can now configure at what day a week
start.
Diffstat (limited to 'modules/archive')
-rw-r--r--modules/archive/archive.module36
1 files changed, 25 insertions, 11 deletions
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<!-- calendar -->\n";
$output .= "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"1\">\n";
- $output .= " <tr><td align=\"center\" colspan=\"7\"><small>". l("&lt;", "archive/". date("Y/m/d", $prev)) ." ". date("F Y", $requested) ." ". ($next <= time() ? l("&gt;", "archive/". date("Y/m/d", $next)) : "&gt;") ."</small></td></tr>\n";
+ $output .= " <tr><td align=\"center\" colspan=\"7\"><small>". l("&lt;", "archive/". date("Y/m/d", $prev)) ." ". date("F Y", $requested) ." ". ($nextmonth <= time() ? l("&gt;", "archive/". date("Y/m/d", $next)) : "&gt;") ."</small></td></tr>\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 .= " <tr>";
for ($i = 0; $i < 7; $i++) {
- $output .= "<td align=\"center\"><small>". substr(ucfirst(t(date("l", $somesunday + $i * 86400))), 0, 1) ."</small></td>";
+ $output .= "<td align=\"center\"><small>". substr(ucfirst(t(date("l", $firstcolumn + $i * 86400))), 0, 1) ."</small></td>";
}
$output .= "</tr>\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 .= " <tr><td colspan=\"$first\">&nbsp;</td>\n";
- $first = 0;
+ if ($first != $weekstart) {
+ $blankdays = ($first - $weekstart + 7) % 7;
+ $output .= " <tr><td colspan=\"$blankdays\">&nbsp;</td>\n";
+ $first = $weekstart;
}
// Start every week on a new line:
- if ($sday == 0) {
+ if ($sday == $weekstart) {
$output .= " <tr>\n";
}
@@ -84,7 +91,7 @@ function archive_calendar($original = 0) {
}
// Start every week on a new line:
- if ($sday == 6) {
+ if ($sday == $lastday) {
$output .= " </tr>\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 .= " <td colspan=\"$end\">&nbsp;</td>\n </tr>\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;
+}
+
+?>