\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: $firstcolumn = mktime(0, 0, 0, 3, 20 + $weekstart, 1994); $output .= " "; for ($i = 0; $i < 7; $i++) { $output .= ""; } $output .= "\n"; // Initialize temporary variables: $nday = 1; $sday = $first; // Loop through all the days of the month: while ($nday <= $last) { // Set up blank days for first week of the month: if ($first != $weekstart) { $blankdays = ($first - $weekstart + 7) % 7; $output .= " \n"; $first = $weekstart; } // Start every week on a new line: if ($sday == $weekstart) { $output .= " \n"; } // Print one cell: $date = mktime(0, 0, 0, $month, $nday, $year); if ($date == $requested) { $output .= " \n"; } else if ($date > $today) { $output .= " \n"; } else { $output .= " \n"; } // Start every week on a new line: if ($sday == $lastday) { $output .= " \n"; } // Update temporary variables: $sday++; $sday = $sday % 7; $nday++; } // Complete the calendar: if ($sday != $weekstart) { $end = (7 - $sday + $weekstart) % 7; $output .= " \n \n"; } $output .= "
". 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", $firstcolumn + $i * 86400))), 0, 1) ."
 
$nday$nday". l($nday, "archive/$year/$month/$nday", array("style" => "text-decoration: none;")) ."
 
\n\n"; return $output; } function archive_block($op = "list", $delta = 0) { global $date; if ($op == "list") { $blocks[0]["info"] = t("Calendar to browse archives"); return $blocks; } else { switch ($delta) { case 0: $block["subject"] = t("Browse archives"); $block["content"] = archive_calendar(); return $block; } } } function archive_link($type) { if ($type == "page" && user_access("access content")) { $links[] = l(t("archives"), "archive", array("title" => t("Read the older content in our archive."))); } return $links ? $links : array(); } function archive_page() { global $date, $edit, $theme, $op, $month, $year, $meta; $theme->header(); if (user_access("access content")) { if ($op == t("Show")) { $year = $edit["year"]; $month = $edit["month"]; $day = $edit["day"]; } else { $year = arg(1); $month = arg(2); $day = arg(3); } $date = mktime(0, 0, 0, $month, $day, $year); /* ** Prepare the values of the form fields: */ $years = array(2000 => "2000", 2001 => "2001", 2002 => "2002", 2003 => "2003", 2004 => "2004", 2005 => "2005"); $months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December")); for ($i = 1; $i <= 31; $i++) $days[$i] = $i; $start = form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show")); $start = ereg_replace("<[/]?p>", "", $start); $theme->box(t("Archives"), form($start)); /* ** Fetch nodes for the selected date, or current date if none ** selected. */ if ($year && $month && $day) { $result = db_query("SELECT nid FROM node WHERE status = '1' AND created > %d ORDER BY created LIMIT 20", $date); while ($nid = db_fetch_object($result)) { node_view(node_load(array("nid" => $nid->nid)), 1); } } } else { message_access(); } $theme->footer(); } function archive_settings() { $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; } ?>