/** * Produces the content for the three months block (pretend block) * * This includes the previous month, the current month, and the next month * * @param calendar_information $calendar * @return string */ public function fake_block_threemonths(calendar_information $calendar) { // Get the calendar type we are using. $calendartype = \core_calendar\type_factory::get_calendar_instance(); $date = $calendartype->timestamp_to_date_array($calendar->time); $prevmonth = calendar_sub_month($date['mon'], $date['year']); $prevmonthtime = $calendartype->convert_to_gregorian($prevmonth[1], $prevmonth[0], 1); $prevmonthtime = make_timestamp($prevmonthtime['year'], $prevmonthtime['month'], $prevmonthtime['day'], $prevmonthtime['hour'], $prevmonthtime['minute']); $nextmonth = calendar_add_month($date['mon'], $date['year']); $nextmonthtime = $calendartype->convert_to_gregorian($nextmonth[1], $nextmonth[0], 1); $nextmonthtime = make_timestamp($nextmonthtime['year'], $nextmonthtime['month'], $nextmonthtime['day'], $nextmonthtime['hour'], $nextmonthtime['minute']); $content = html_writer::start_tag('div', array('class' => 'minicalendarblock')); $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, false, false, 'display', $calendar->courseid, $prevmonthtime); $content .= html_writer::end_tag('div'); $content .= html_writer::start_tag('div', array('class' => 'minicalendarblock')); $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, false, false, 'display', $calendar->courseid, $calendar->time); $content .= html_writer::end_tag('div'); $content .= html_writer::start_tag('div', array('class' => 'minicalendarblock')); $content .= calendar_get_mini($calendar->courses, $calendar->groups, $calendar->users, false, false, 'display', $calendar->courseid, $nextmonthtime); $content .= html_writer::end_tag('div'); return $content; }
function calendar_top_controls($type, $data) { global $CFG, $CALENDARDAYS, $THEME; $content = ''; if (!isset($data['d'])) { $data['d'] = 1; } // Ensure course id passed if relevant // Required due to changes in view/lib.php mainly (calendar_session_vars()) $courseid = ''; if (!empty($data['id'])) { $courseid = '&course=' . $data['id']; } if (!checkdate($data['m'], $data['d'], $data['y'])) { $time = time(); } else { $time = make_timestamp($data['y'], $data['m'], $data['d']); } $date = usergetdate($time); $data['m'] = $date['mon']; $data['y'] = $date['year']; //Accessibility: calendar block controls, replaced <table> with <div>. //$nexttext = link_arrow_right(get_string('monthnext', 'access'), $url='', $accesshide=true); //$prevtext = link_arrow_left(get_string('monthprev', 'access'), $url='', $accesshide=true); switch ($type) { case 'frontpage': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), 'index.php?', 0, $nextmonth, $nextyear, $accesshide = true); $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), 'index.php?', 0, $prevmonth, $prevyear, true); $content .= "\n" . '<div class="calendar-controls">' . $prevlink; $content .= '<span class="hide"> | </span><span class="current"><a href="' . calendar_get_link_href(CALENDAR_URL . 'view.php?view=month' . $courseid . '&', 1, $data['m'], $data['y']) . '">' . userdate($time, get_string('strftimemonthyear')) . '</a></span>'; $content .= '<span class="hide"> | </span>' . $nextlink . "\n"; $content .= "<span class=\"clearer\"><!-- --></span></div>\n"; break; case 'course': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), 'view.php?id=' . $data['id'] . '&', 0, $nextmonth, $nextyear, $accesshide = true); $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), 'view.php?id=' . $data['id'] . '&', 0, $prevmonth, $prevyear, true); $content .= "\n" . '<div class="calendar-controls">' . $prevlink; $content .= '<span class="hide"> | </span><span class="current"><a href="' . calendar_get_link_href(CALENDAR_URL . 'view.php?view=month' . $courseid . '&', 1, $data['m'], $data['y']) . '">' . userdate($time, get_string('strftimemonthyear')) . '</a></span>'; $content .= '<span class="hide"> | </span>' . $nextlink . "\n"; $content .= "<span class=\"clearer\"><!-- --></span></div>\n"; break; case 'upcoming': $content .= '<div style="text-align: center;"><a href="' . CALENDAR_URL . 'view.php?view=upcoming"' . $courseid . '>' . userdate($time, get_string('strftimemonthyear')) . "</a></div>\n"; break; case 'display': $content .= '<div style="text-align: center;"><a href="' . calendar_get_link_href(CALENDAR_URL . 'view.php?view=month' . $courseid . '&', 1, $data['m'], $data['y']) . '">' . userdate($time, get_string('strftimemonthyear')) . "</a></div>\n"; break; case 'month': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $prevdate = make_timestamp($prevyear, $prevmonth, 1); $nextdate = make_timestamp($nextyear, $nextmonth, 1); $content .= "\n" . '<div class="calendar-controls">'; $content .= calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), 'view.php?view=month' . $courseid . '&', 1, $prevmonth, $prevyear); $content .= '<span class="hide"> | </span><span class="current">' . userdate($time, get_string('strftimemonthyear')) . "</span>\n"; $content .= '<span class="hide"> | </span>' . calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month' . $courseid . '&', 1, $nextmonth, $nextyear); $content .= "<span class=\"clearer\"><!-- --></span></div>\n"; break; case 'day': $data['d'] = $date['mday']; // Just for convenience $prevdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] - 1)); $nextdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] + 1)); $prevname = calendar_wday_name($CALENDARDAYS[$prevdate['wday']]); $nextname = calendar_wday_name($CALENDARDAYS[$nextdate['wday']]); $content .= "\n" . '<div class="calendar-controls">'; $content .= calendar_get_link_previous($prevname, 'view.php?view=day' . $courseid . '&', $prevdate['mday'], $prevdate['mon'], $prevdate['year']); // Get the format string $text = get_string('strftimedaydate'); /* // Regexp hackery to make a link out of the month/year part $text = ereg_replace('(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&', 1, $data['m'], $data['y']).'">\\1</a>', $text); $text = ereg_replace('(F.+Y|Y.+F|Y.+m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&', 1, $data['m'], $data['y']).'">\\1</a>', $text); */ // Replace with actual values and lose any day leading zero $text = userdate($time, $text); // Print the actual thing $content .= '<span class="hide"> | </span><span class="current">' . $text . '</span>'; $content .= '<span class="hide"> | </span>' . calendar_get_link_next($nextname, 'view.php?view=day' . $courseid . '&', $nextdate['mday'], $nextdate['mon'], $nextdate['year']); $content .= "<span class=\"clearer\"><!-- --></span></div>\n"; break; } return $content; }
/** * Test all the core functions that use the calendar type system. * * @param string $type the calendar type we want to test */ private function core_functions_test($type) { $this->set_calendar_type($type); // Get the calendar. $calendar = \core_calendar\type_factory::get_calendar_instance(); // Test the userdate function. $this->assertEquals($calendar->timestamp_to_date_string($this->user->timecreated, '', 99, true, true), userdate($this->user->timecreated)); // Test the calendar/lib.php functions. $this->assertEquals($calendar->get_weekdays(), calendar_get_days()); $this->assertEquals($calendar->get_starting_weekday(), calendar_get_starting_weekday()); $this->assertEquals($calendar->get_num_days_in_month('1986', '9'), calendar_days_in_month('9', '1986')); $this->assertEquals($calendar->get_next_month('1986', '9'), calendar_add_month('9', '1986')); $this->assertEquals($calendar->get_prev_month('1986', '9'), calendar_sub_month('9', '1986')); // Test the lib/moodle.php functions. $this->assertEquals($calendar->get_num_days_in_month('1986', '9'), days_in_month('9', '1986')); $this->assertEquals($calendar->get_weekday('1986', '9', '16'), dayofweek('16', '9', '1986')); }
/** * Get control options for Calendar * * @param string $type of calendar * @param array $data calendar information * @return string $content return available control for the calender in html */ function calendar_top_controls($type, $data) { global $PAGE; // Get the calendar type we are using. $calendartype = \core_calendar\type_factory::get_calendar_instance(); $content = ''; // Ensure course id passed if relevant. $courseid = ''; if (!empty($data['id'])) { $courseid = '&course=' . $data['id']; } // If we are passing a month and year then we need to convert this to a timestamp to // support multiple calendars. No where in core should these be passed, this logic // here is for third party plugins that may use this function. if (!empty($data['m']) && !empty($date['y'])) { if (!isset($data['d'])) { $data['d'] = 1; } if (!checkdate($data['m'], $data['d'], $data['y'])) { $time = time(); } else { $time = make_timestamp($data['y'], $data['m'], $data['d']); } } else { if (!empty($data['time'])) { $time = $data['time']; } else { $time = time(); } } // Get the date for the calendar type. $date = $calendartype->timestamp_to_date_array($time); $urlbase = $PAGE->url; // We need to get the previous and next months in certain cases. if ($type == 'frontpage' || $type == 'course' || $type == 'month') { $prevmonth = calendar_sub_month($date['mon'], $date['year']); $prevmonthtime = $calendartype->convert_to_gregorian($prevmonth[1], $prevmonth[0], 1); $prevmonthtime = make_timestamp($prevmonthtime['year'], $prevmonthtime['month'], $prevmonthtime['day'], $prevmonthtime['hour'], $prevmonthtime['minute']); $nextmonth = calendar_add_month($date['mon'], $date['year']); $nextmonthtime = $calendartype->convert_to_gregorian($nextmonth[1], $nextmonth[0], 1); $nextmonthtime = make_timestamp($nextmonthtime['year'], $nextmonthtime['month'], $nextmonthtime['day'], $nextmonthtime['hour'], $nextmonthtime['minute']); } switch ($type) { case 'frontpage': $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), $urlbase, false, false, false, true, $prevmonthtime); $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), $urlbase, false, false, false, true, $nextmonthtime); $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'month')), false, false, false, $time); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left . '<span class="hide"> | </span>'; $content .= html_writer::tag('span', html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear')), array('title' => get_string('monththis', 'calendar'))), array('class' => 'current')); $content .= '<span class="hide"> | </span>' . $right; $content .= "<span class=\"clearer\"><!-- --></span>\n"; $content .= html_writer::end_tag('div'); break; case 'course': $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), $urlbase, false, false, false, true, $prevmonthtime); $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), $urlbase, false, false, false, true, $nextmonthtime); $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'month')), false, false, false, $time); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left . '<span class="hide"> | </span>'; $content .= html_writer::tag('span', html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear')), array('title' => get_string('monththis', 'calendar'))), array('class' => 'current')); $content .= '<span class="hide"> | </span>' . $right; $content .= "<span class=\"clearer\"><!-- --></span>"; $content .= html_writer::end_tag('div'); break; case 'upcoming': $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'upcoming')), false, false, false, $time); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } $calendarlink = html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear'))); $content .= html_writer::tag('div', $calendarlink, array('class' => 'centered')); break; case 'display': $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'month')), false, false, false, $time); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } $calendarlink = html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear'))); $content .= html_writer::tag('h3', $calendarlink); break; case 'month': $prevlink = calendar_get_link_previous(userdate($prevmonthtime, get_string('strftimemonthyear')), 'view.php?view=month' . $courseid . '&', false, false, false, false, $prevmonthtime); $nextlink = calendar_get_link_next(userdate($nextmonthtime, get_string('strftimemonthyear')), 'view.php?view=month' . $courseid . '&', false, false, false, false, $nextmonthtime); if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left . '<span class="hide"> | </span><h1 class="current">' . userdate($time, get_string('strftimemonthyear')) . "</h1>"; $content .= '<span class="hide"> | </span>' . $right; $content .= '<span class="clearer"><!-- --></span>'; $content .= html_writer::end_tag('div') . "\n"; break; case 'day': $days = calendar_get_days(); $prevtimestamp = $time - DAYSECS; $nexttimestamp = $time + DAYSECS; $prevdate = $calendartype->timestamp_to_date_array($prevtimestamp); $nextdate = $calendartype->timestamp_to_date_array($nexttimestamp); $prevname = $days[$prevdate['wday']]['fullname']; $nextname = $days[$nextdate['wday']]['fullname']; $prevlink = calendar_get_link_previous($prevname, 'view.php?view=day' . $courseid . '&', false, false, false, false, $prevtimestamp); $nextlink = calendar_get_link_next($nextname, 'view.php?view=day' . $courseid . '&', false, false, false, false, $nexttimestamp); if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left; $content .= '<span class="hide"> | </span><span class="current">' . userdate($time, get_string('strftimedaydate')) . '</span>'; $content .= '<span class="hide"> | </span>' . $right; $content .= "<span class=\"clearer\"><!-- --></span>"; $content .= html_writer::end_tag('div') . "\n"; break; } return $content; }
include 'event_new.html'; if ($usehtmleditor) { use_html_editor("description"); } } break; } echo '</td>'; // START: Last column (3-month display) $defaultcourses = calendar_get_default_courses(); //calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); // when adding an event you can not be a guest, so I think it's reasonalbe to ignore defaultcourses // MDL-10353 calendar_set_filters($courses, $groups, $users); list($prevmon, $prevyr) = calendar_sub_month($mon, $yr); list($nextmon, $nextyr) = calendar_add_month($mon, $yr); echo '<td class="sidecalendar">'; echo '<div class="sideblock">'; echo '<div class="header"><h2>' . get_string('eventskey', 'calendar') . '</h2></div>'; echo '<div class="filters">'; echo calendar_filter_controls('event', 'action=' . $action . '&type=' . $eventtype . '&id=' . $eventid); echo '</div>'; echo '</div>'; echo '<div class="sideblock">'; echo '<div class="header"><h2>' . get_string('monthlyview', 'calendar') . '</h2></div>'; echo '<div class="minicalendarblock minicalendartop">'; echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $prevmon, 'y' => $prevyr)); echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr); echo '</div><div class="minicalendarblock">'; echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $mon, 'y' => $yr)); echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
$timestart = make_timestamp($startyear, $startmonth, $startmonthday); $endmonthday = $startmonthday + 7; $endmonth = $startmonth; $endyear = $startyear; if ($endmonthday > calendar_days_in_month($endmonth, $endyear)) { list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear); $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear); } $timeend = make_timestamp($endyear, $endmonth, $endmonthday) - 1; break; case 'monthnow': $timestart = make_timestamp($now['year'], $now['mon'], 1); $timeend = make_timestamp($now['year'], $now['mon'], calendar_days_in_month($now['mon'], $now['year']), 23, 59, 59); break; case 'monthnext': list($nextmonth, $nextyear) = calendar_add_month($now['mon'], $now['year']); $timestart = make_timestamp($nextyear, $nextmonth, 1); $timeend = make_timestamp($nextyear, $nextmonth, calendar_days_in_month($nextmonth, $nextyear), 23, 59, 59); break; case 'recentupcoming': //Events in the last 5 or next 60 days $timestart = time() - 432000; $timeend = time() + 5184000; break; } } else { // Parameters given but incorrect, redirect back to export page redirect($CFG->wwwroot . '/calendar/export.php'); die; } }
/** * Get control options for Calendar * * @param string $type of calendar * @param array $data calendar information * @return string $content return available control for the calender in html */ function calendar_top_controls($type, $data) { global $CFG; $content = ''; if (!isset($data['d'])) { $data['d'] = 1; } // Ensure course id passed if relevant // Required due to changes in view/lib.php mainly (calendar_session_vars()) $courseid = ''; if (!empty($data['id'])) { $courseid = '&course=' . $data['id']; } if (!checkdate($data['m'], $data['d'], $data['y'])) { $time = time(); } else { $time = make_timestamp($data['y'], $data['m'], $data['d']); } $date = usergetdate($time); $data['m'] = $date['mon']; $data['y'] = $date['year']; //Accessibility: calendar block controls, replaced <table> with <div>. //$nexttext = link_arrow_right(get_string('monthnext', 'access'), $url='', $accesshide=true); //$prevtext = link_arrow_left(get_string('monthprev', 'access'), $url='', $accesshide=true); switch ($type) { case 'frontpage': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), 'index.php?', 0, $nextmonth, $nextyear, $accesshide = true); $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), 'index.php?', 0, $prevmonth, $prevyear, true); $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'month')), 1, $data['m'], $data['y']); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left . '<span class="hide"> | </span>'; $content .= html_writer::tag('span', html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear')), array('title' => get_string('monththis', 'calendar'))), array('class' => 'current')); $content .= '<span class="hide"> | </span>' . $right; $content .= "<span class=\"clearer\"><!-- --></span>\n"; $content .= html_writer::end_tag('div'); break; case 'course': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), 'view.php?id=' . $data['id'] . '&', 0, $nextmonth, $nextyear, $accesshide = true); $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), 'view.php?id=' . $data['id'] . '&', 0, $prevmonth, $prevyear, true); $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'month')), 1, $data['m'], $data['y']); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left . '<span class="hide"> | </span>'; $content .= html_writer::tag('span', html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear')), array('title' => get_string('monththis', 'calendar'))), array('class' => 'current')); $content .= '<span class="hide"> | </span>' . $right; $content .= "<span class=\"clearer\"><!-- --></span>"; $content .= html_writer::end_tag('div'); break; case 'upcoming': $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'upcoming')), 1, $data['m'], $data['y']); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } $calendarlink = html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear'))); $content .= html_writer::tag('div', $calendarlink, array('class' => 'centered')); break; case 'display': $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'month')), 1, $data['m'], $data['y']); if (!empty($data['id'])) { $calendarlink->param('course', $data['id']); } $calendarlink = html_writer::link($calendarlink, userdate($time, get_string('strftimemonthyear'))); $content .= html_writer::tag('h3', $calendarlink); break; case 'month': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $prevdate = make_timestamp($prevyear, $prevmonth, 1); $nextdate = make_timestamp($nextyear, $nextmonth, 1); $prevlink = calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), 'view.php?view=month' . $courseid . '&', 1, $prevmonth, $prevyear); $nextlink = calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month' . $courseid . '&', 1, $nextmonth, $nextyear); if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left . '<span class="hide"> | </span><h1 class="current">' . userdate($time, get_string('strftimemonthyear')) . "</h1>"; $content .= '<span class="hide"> | </span>' . $right; $content .= '<span class="clearer"><!-- --></span>'; $content .= html_writer::end_tag('div') . "\n"; break; case 'day': $days = calendar_get_days(); $data['d'] = $date['mday']; // Just for convenience $prevdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] - 1)); $nextdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] + 1)); $prevname = calendar_wday_name($days[$prevdate['wday']]); $nextname = calendar_wday_name($days[$nextdate['wday']]); $prevlink = calendar_get_link_previous($prevname, 'view.php?view=day' . $courseid . '&', $prevdate['mday'], $prevdate['mon'], $prevdate['year']); $nextlink = calendar_get_link_next($nextname, 'view.php?view=day' . $courseid . '&', $nextdate['mday'], $nextdate['mon'], $nextdate['year']); if (right_to_left()) { $left = $nextlink; $right = $prevlink; } else { $left = $prevlink; $right = $nextlink; } $content .= html_writer::start_tag('div', array('class' => 'calendar-controls')); $content .= $left; $content .= '<span class="hide"> | </span><span class="current">' . userdate($time, get_string('strftimedaydate')) . '</span>'; $content .= '<span class="hide"> | </span>' . $right; $content .= "<span class=\"clearer\"><!-- --></span>"; $content .= html_writer::end_tag('div') . "\n"; break; } return $content; }
/** * Produces the content for the three months block (pretend block) * * This includes the previous month, the current month, and the next month * * @param calendar_information $calendar * @return string */ public function fake_block_threemonths(calendar_information $calendar) { list($prevmon, $prevyr) = calendar_sub_month($calendar->month, $calendar->year); 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 .= 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 .= 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 .= html_writer::end_tag('div'); return $content; }
function top_controls($month, $year) { global $OUTPUT, $currenttab; $content = ''; $time = make_timestamp($year, $month, 1); $date = usergetdate($time); $data['m'] = $date['mon']; $data['y'] = $date['year']; list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $prevdate = make_timestamp($prevyear, $prevmonth, 1); $nextdate = make_timestamp($nextyear, $nextmonth, 1); $content .= $OUTPUT->container_start('calendar-controls'); $content .= html_writer::start_tag('table', array('summary' => '')) . html_writer::start_tag('tr') . html_writer::start_tag('td'); $content .= calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), "calendar.php?tab=$currenttab&", 1, $prevmonth, $prevyear); $content .= html_writer::end_tag('td') . html_writer::tag('td', html_writer::tag('span', '|', array('class' => 'hide')) . html_writer::tag('span', userdate($time, get_string('strftimemonthyear')), array('class' => 'current')), array('align' => 'center')); $content .= html_writer::tag('td', html_writer::tag('span', '|', array('class' => 'hide')) . calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), "calendar.php?tab=$currenttab&", 1, $nextmonth, $nextyear) . html_writer::tag('span', '<!-- -->', array('class' => 'clearer')), array('align' => 'right')); $content .= html_writer::end_tag('tr') . html_writer::end_tag('table'); $content .= $OUTPUT->container_end() . "\n"; return $content; }