$select_year = $today['year']; $select_month = $today['mon']; } echo '<div class="actions">'; if (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) { display_student_links(); display_courseadmin_links(); } echo '</div><br /><br />'; echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'; // THE LEFT PART if (empty($_GET['origin']) or $_GET['origin'] != 'learnpath') { echo '<td width="220" height="19" valign="top">'; // the small calendar $MonthName = $MonthsLong[$select_month - 1]; $agenda_items = get_calendar_items($select_month, $select_year); if (api_get_setting('display_mini_month_calendar') == 'true') { display_minimonthcalendar($agenda_items, $select_month, $select_year, $MonthName); } if (api_get_setting('display_upcoming_events') == 'true') { display_upcoming_events(); } echo '</td>'; echo '<td width="20" background="../img/verticalruler.gif"> </td>'; } // THE RIGHT PART echo '<td valign="top">'; echo '<div class="sort" style="float:right">'; echo '</div>'; if (api_is_allowed_to_edit(false, true)) { switch ($_GET['action']) {
function display_monthcalendar($month, $year) { global $MonthsLong; global $DaysShort; global $origin; // grabbing all the calendar items for this year and storing it in a array $data = get_calendar_items($month, $year); //Handle leap year $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if ($year % 400 == 0 or $year % 4 == 0 and $year % 100 != 0) { $numberofdays[2] = 29; } //Get the first day of the month $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); //Start the week on monday $startdayofweek = $dayone['wday'] != 0 ? $dayone['wday'] - 1 : 6; $backwardsURL = api_get_self() . "?" . api_get_cidreq() . "&origin={$origin}&month=" . ($month == 1 ? 12 : $month - 1) . "&year=" . ($month == 1 ? $year - 1 : $year); $forewardsURL = api_get_self() . "?" . api_get_cidreq() . "&origin={$origin}&month=" . ($month == 12 ? 1 : $month + 1) . "&year=" . ($month == 12 ? $year + 1 : $year); $maand_array_maandnummer = $month - 1; echo "<table class=\"data_table\">", "<tr>", "<th width=\"10%\"><a href=\"", $backwardsURL, "\"> " . Display::return_icon('action_prev.png', get_lang('Previous')) . "</a></th>", "<th width=\"80%\" colspan=\"5\">", $MonthsLong[$maand_array_maandnummer], " ", $year, "</th>", "<th width=\"10%\"><a href=\"", $forewardsURL, "\"> " . Display::return_icon('action_next.png', get_lang('Next')) . "</a></th>", "</tr>"; echo "<tr>"; for ($ii = 1; $ii < 8; $ii++) { echo "<td class=\"weekdays\" width=\"14%\">", $DaysShort[$ii % 7], "</td>"; } echo "</tr>"; $curday = -1; $today = getdate(); while ($curday <= $numberofdays[$month]) { echo "<tr>"; for ($ii = 0; $ii < 7; $ii++) { if ($curday == -1 && $ii == $startdayofweek) { $curday = 1; } if ($curday > 0 && $curday <= $numberofdays[$month]) { $bgcolor = $ii < 5 ? "class=\"row_odd\"" : "class=\"row_even\""; $dayheader = "{$curday}"; if (array_key_exists($curday, $data)) { $dayheader = "<a href='" . api_get_self() . "?" . api_get_cidreq() . "&view=list&origin={$origin}&month={$month}&year={$year}&day={$curday}#{$curday}'>" . $curday . "</a>"; foreach ($data[$curday] as $key => $agenda_item) { foreach ($agenda_item as $key => $value) { $start_time = api_convert_and_format_date($value['start_date'], TIME_NO_SEC_FORMAT); $end_time = api_convert_and_format_date($value['end_date'], TIME_NO_SEC_FORMAT); $dayheader .= '<br /><b>' . $start_time . ' - ' . $end_time . '</b>'; $dayheader .= ' - '; $dayheader .= $value['title']; } } } if ($curday == $today['mday'] && $year == $today['year'] && $month == $today['mon']) { echo "<td id=\"today\" ", $bgcolor, "\">" . $dayheader . " "; } else { echo "<td id=\"days\" ", $bgcolor, "\">" . $dayheader . " "; } echo "</td>"; $curday++; } else { echo "<td> </td>"; } } echo "</tr>"; } echo "</table>"; }