From 2953ad13bb9736bb6eb8cff767c402434c4d0a65 Mon Sep 17 00:00:00 2001 From: Jason Ilicic Date: Mon, 15 Aug 2011 12:34:24 +0930 Subject: [PATCH 1/2] MDL-28935 Add days of week to monthly calendar view --- calendar/renderer.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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(' '); From 043c7cb8637a78fb70b3f134750c209e08401ebc Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sat, 20 Aug 2011 13:45:37 +0200 Subject: [PATCH 2/2] MDL-28935 use weekdays as calendar table headings --- calendar/renderer.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/calendar/renderer.php b/calendar/renderer.php index 101b0a9561c..e9ba82d892d 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -432,8 +432,6 @@ class core_calendar_renderer extends plugin_renderer_base { $week = 1; $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'). '', @@ -452,9 +450,8 @@ class core_calendar_renderer extends plugin_renderer_base { array_push($wdays, $wdays_end); } - // Now we set the (modified) array to the table cells to be displayed. - $row->cells = $wdays; - $table->data[] = $row; + // Now we set the (modified) array to the table header to be displayed. + $table->head = $wdays; $row = new html_table_row(array());