Skip to content
Browse files

MDL-35826 - Calendar - Creating a caption containing the month name f…

…or mini-calendars
  • Loading branch information...
1 parent a5ec499 commit 512edd65d86c82cbe60c28cb8cc55a1ef1102e07 @jsnfwlr jsnfwlr committed
Showing with 16 additions and 12 deletions.
  1. +2 −4 blocks/calendar_month/block_calendar_month.php
  2. +7 −2 calendar/lib.php
  3. +3 −6 calendar/renderer.php
  4. +4 −0 calendar/upgrade.txt
View
6 blocks/calendar_month/block_calendar_month.php
@@ -42,13 +42,11 @@ function get_content() {
list($courses, $group, $user) = calendar_set_filters($filtercourse);
if ($issite) {
// For the front page
- $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseid, 'm' => $cal_m, 'y' => $cal_y));
- $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
+ $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'frontpage', $courseid);
// No filters for now
} else {
// For any other course
- $this->content->text .= calendar_top_controls('course', array('id' => $courseid, 'm' => $cal_m, 'y' => $cal_y));
- $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
+ $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'course', $courseid);
$this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
$this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
}
View
9 calendar/lib.php
@@ -145,14 +145,16 @@ function calendar_get_starting_weekday() {
/**
* Generates the HTML for a miniature calendar
*
- * @param array $courses list of course
+ * @param array $courses list of course to list events from
* @param array $groups list of group
* @param array $users user's info
* @param int $cal_month calendar month in numeric, default is set to false
* @param int $cal_year calendar month in numeric, default is set to false
+ * @param string $placement the place/page the calendar is set to appear - passed on the the controls function
+ * @param int $courseid id of the course the calendar is displayed on - passed on the the controls function
* @return string $content return html table for mini calendar
*/
-function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_year = false) {
+function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_year = false, $placement, $courseid = false ) {
global $CFG, $USER, $OUTPUT;
$display = new stdClass;
@@ -259,6 +261,9 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
$summary = get_string('calendarheading', 'calendar', userdate(make_timestamp($y, $m), get_string('strftimemonthyear')));
$content .= '<table class="minicalendar calendartable" summary="'.$summary.'">'; // Begin table
+ if (($placement !== false) && ($courseid !== false)) {
+ $content .= '<caption>'. calendar_top_controls($placement, array('id' => $courseid, 'm' => $m, 'y' => $y)) .'</caption>';
+ }
$content .= '<tr class="weekdays">'; // Header row: day names
// Print out the names of the weekdays
View
9 calendar/renderer.php
@@ -171,16 +171,13 @@ public function fake_block_threemonths(calendar_information $calendar) {
list($nextmon, $nextyr) = calendar_add_month($calendar->month, $calendar->year);
$content = html_writer::start_tag('div', array('class'=>'minicalendarblock'));
- $content .= calendar_top_controls('display', array('id' => $calendar->courseid, 'm' => $prevmon, 'y' => $prevyr));
- $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $prevmon, $prevyr);
+ $content .= calendar_get_mini( $calendar->courses, $calendar->groups, $calendar->users, $prevmon, $prevyr, 'display', $calendar->courseid);
$content .= html_writer::end_tag('div');
$content .= html_writer::start_tag('div', array('class'=>'minicalendarblock'));
- $content .= calendar_top_controls('display', array('id' => $calendar->courseid, 'm' => $calendar->month, 'y' => $calendar->year));
- $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $calendar->month, $calendar->year);
+ $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $calendar->month, $calendar->year, 'display', $calendar->courseid);
$content .= html_writer::end_tag('div');
$content .= html_writer::start_tag('div', array('class'=>'minicalendarblock'));
- $content .= calendar_top_controls('display', array('id' => $calendar->courseid, 'm' => $nextmon, 'y' => $nextyr));
- $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $nextmon, $nextyr);
+ $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, $nextmon, $nextyr, 'display', $calendar->courseid);
$content .= html_writer::end_tag('div');
return $content;
}
View
4 calendar/upgrade.txt
@@ -1,7 +1,11 @@
This files describes API changes in /calendar/* ,
information provided here is intended especially for developers.
+=== 2.5 ===
+required changes in code:
+
+* calendar_get_mini() function now has optional $placement and $courseid paramaters.
=== 2.4 ===
required changes in code:

0 comments on commit 512edd6

Please sign in to comment.
Something went wrong with that request. Please try again.