From: Jason Ilicic Date: Mon, 15 Aug 2011 03:04:24 +0000 (+0930) Subject: MDL-28935 Add days of week to monthly calendar view X-Git-Tag: v2.2.0-beta~505^2~1 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=2953ad13bb9736bb6eb8cff767c402434c4d0a65 MDL-28935 Add days of week to monthly calendar view --- diff --git a/calendar/renderer.php b/calendar/renderer.php index 50a30901f8f..101b0a9561c 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -433,6 +433,31 @@ class core_calendar_renderer extends plugin_renderer_base { $dayweek = $startwday; $row = new html_table_row(array()); + + // Create an array of all the week days. + $wdays = array(0 => ''. get_string('sunday', 'calendar'). '', + 1 => ''. get_string('monday', 'calendar'). '', + 2 => ''. get_string('tuesday', 'calendar'). '', + 3 => ''. get_string('wednesday', 'calendar'). '', + 4 => ''. get_string('thursday', 'calendar'). '', + 5 => ''. get_string('friday', 'calendar'). '', + 6 => ''. get_string('saturday', 'calendar'). ''); + + // Loop only if the day offset is greater than 0. + // This loop involves shifting the days around until the desired start day + // is at the start of the array. + $daycount = 0; + while ($display->minwday > $daycount++) { + $wdays_end = array_shift($wdays); + array_push($wdays, $wdays_end); + } + + // Now we set the (modified) array to the table cells to be displayed. + $row->cells = $wdays; + $table->data[] = $row; + + $row = new html_table_row(array()); + // Paddding (the first week may have blank days in the beginning) for($i = $display->minwday; $i < $startwday; ++$i) { $cell = new html_table_cell(' ');