diff --git a/calendar/amd/build/repository.min.js b/calendar/amd/build/repository.min.js index a33feeda93f..b9a54860cb4 100644 --- a/calendar/amd/build/repository.min.js +++ b/calendar/amd/build/repository.min.js @@ -1 +1 @@ -define(["jquery","core/ajax"],function(a,b){var c=function(a){var c={methodname:"core_calendar_delete_calendar_events",args:{events:[{eventid:a,repeat:1}]}};return b.call([c])[0]},d=function(a){var c={methodname:"core_calendar_get_calendar_event_by_id",args:{eventid:a}};return b.call([c])[0]},e=function(a){var c={methodname:"core_calendar_submit_create_update_form",args:{formdata:a}};return b.call([c])[0]},f=function(a,c){var d={methodname:"core_calendar_get_calendar_monthly_view",args:{time:a,courseid:c}};return b.call([d])[0]},g=function(a,c){var d={methodname:"core_calendar_update_event_start_day",args:{eventid:a,daytimestamp:c}};return b.call([d])[0]};return{getEventById:d,deleteEvent:c,updateEventStartDay:g,submitCreateUpdateForm:e,getCalendarMonthData:f}}); \ No newline at end of file +define(["jquery","core/ajax"],function(a,b){var c=function(a){var c={methodname:"core_calendar_delete_calendar_events",args:{events:[{eventid:a,repeat:1}]}};return b.call([c])[0]},d=function(a){var c={methodname:"core_calendar_get_calendar_event_by_id",args:{eventid:a}};return b.call([c])[0]},e=function(a){var c={methodname:"core_calendar_submit_create_update_form",args:{formdata:a}};return b.call([c])[0]},f=function(a,c,d){var e={methodname:"core_calendar_get_calendar_monthly_view",args:{year:a,month:c,courseid:d}};return b.call([e])[0]},g=function(a,c){var d={methodname:"core_calendar_update_event_start_day",args:{eventid:a,daytimestamp:c}};return b.call([d])[0]};return{getEventById:d,deleteEvent:c,updateEventStartDay:g,submitCreateUpdateForm:e,getCalendarMonthData:f}}); \ No newline at end of file diff --git a/calendar/amd/build/view_manager.min.js b/calendar/amd/build/view_manager.min.js index 301ef420904..2258f31954c 100644 --- a/calendar/amd/build/view_manager.min.js +++ b/calendar/amd/build/view_manager.min.js @@ -1 +1 @@ -define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);i(b,e.attr("href"),e.data("time"),d),c.preventDefault()})},h=function(g,h,i){return k(g),d.getCalendarMonthData(h,i).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return b.replaceNode(g.find(f.CALENDAR_MONTH_WRAPPER),a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return l(g)}).fail(c.exception)},i=function(b,c,d,f){return h(b,d,f).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f]),arguments})},j=function(a,b){var c=a.find(f.CALENDAR_MONTH_WRAPPER).data("current-time");return b||(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),h(a,c,b)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h}}); \ No newline at end of file +define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);i(b,e.attr("href"),e.data("year"),e.data("month"),d),c.preventDefault()})},h=function(g,h,i,j){return k(g),d.getCalendarMonthData(h,i,j).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return b.replaceNode(g.find(f.CALENDAR_MONTH_WRAPPER),a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return l(g)}).fail(c.exception)},i=function(b,c,d,f,g){return h(b,d,f,g).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f,g]),arguments})},j=function(a,b){var c=a.find(f.CALENDAR_MONTH_WRAPPER).data("year"),d=a.find(f.CALENDAR_MONTH_WRAPPER).data("month");return b||(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),h(a,c,d,b)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h}}); \ No newline at end of file diff --git a/calendar/amd/src/repository.js b/calendar/amd/src/repository.js index 55c9db927cc..ef35f4f6099 100644 --- a/calendar/amd/src/repository.js +++ b/calendar/amd/src/repository.js @@ -87,16 +87,18 @@ define(['jquery', 'core/ajax'], function($, Ajax) { * Get calendar data for the month view. * * @method getCalendarMonthData - * @param {Number} time Timestamp. + * @param {Number} year Year + * @param {Number} month Month * @param {Number} courseid The course id. * @return {promise} Resolved with the month view data. */ - var getCalendarMonthData = function(time, courseid) { + var getCalendarMonthData = function(year, month, courseid) { var request = { methodname: 'core_calendar_get_calendar_monthly_view', args: { - time: time, - courseid: courseid + year: year, + month: month, + courseid: courseid, } }; diff --git a/calendar/amd/src/view_manager.js b/calendar/amd/src/view_manager.js index f8636ef6049..a9e3eafa8a9 100644 --- a/calendar/amd/src/view_manager.js +++ b/calendar/amd/src/view_manager.js @@ -42,7 +42,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito root.on('click', SELECTORS.CALENDAR_NAV_LINK, function(e) { var courseId = $(root).find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid'); var link = $(e.currentTarget); - changeMonth(root, link.attr('href'), link.data('time'), courseId); + changeMonth(root, link.attr('href'), link.data('year'), link.data('month'), courseId); e.preventDefault(); }); @@ -51,14 +51,16 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito /** * Refresh the month content. * - * @param {Number} time The calendar time to be shown + * @param {object} root The root element. + * @param {Number} year Year + * @param {Number} month Month * @param {Number} courseid The id of the course whose events are shown * @return {promise} */ - var refreshMonthContent = function(root, time, courseid) { + var refreshMonthContent = function(root, year, month, courseid) { startLoading(root); - return CalendarRepository.getCalendarMonthData(time, courseid) + return CalendarRepository.getCalendarMonthData(year, month, courseid) .then(function(context) { return Templates.render(root.attr('data-template'), context); }) @@ -78,13 +80,15 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito /** * Handle changes to the current calendar view. * + * @param {object} root The root element. * @param {String} url The calendar url to be shown - * @param {Number} time The calendar time to be shown + * @param {Number} year Year + * @param {Number} month Month * @param {Number} courseid The id of the course whose events are shown * @return {promise} */ - var changeMonth = function(root, url, time, courseid) { - return refreshMonthContent(root, time, courseid) + var changeMonth = function(root, url, year, month, courseid) { + return refreshMonthContent(root, year, month, courseid) .then(function() { if (url.length && url !== '#') { window.history.pushState({}, '', url); @@ -92,7 +96,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito return arguments; }) .then(function() { - $('body').trigger(CalendarEvents.monthChanged, [time, courseid]); + $('body').trigger(CalendarEvents.monthChanged, [year, month, courseid]); return arguments; }); }; @@ -105,12 +109,13 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito * @return {promise} */ var reloadCurrentMonth = function(root, courseId) { - var time = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('current-time'); + var year = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('year'); + var month = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('month'); if (!courseId) { courseId = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid'); } - return refreshMonthContent(root, time, courseId); + return refreshMonthContent(root, year, month, courseId); }; /** diff --git a/calendar/classes/external/date_exporter.php b/calendar/classes/external/date_exporter.php new file mode 100644 index 00000000000..4615b6c6265 --- /dev/null +++ b/calendar/classes/external/date_exporter.php @@ -0,0 +1,92 @@ +<?php +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. + +/** + * Class for normalising the date data. + * + * @package core_calendar + * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk> + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace core_calendar\external; + +defined('MOODLE_INTERNAL') || die(); + +use core\external\exporter; +use renderer_base; +use moodle_url; + +/** + * Class for normalising the date data. + * + * @package core_calendar + * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk> + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class date_exporter extends exporter { + + /** + * Constructor for date_exporter. + * + * @param array $data + * @param array $related The related information + */ + public function __construct($data, $related = []) { + $data['timestamp'] = $data[0]; + unset($data[0]); + + parent::__construct($data, $related); + } + + protected static function define_properties() { + return [ + 'seconds' => [ + 'type' => PARAM_INT, + ], + 'minutes' => [ + 'type' => PARAM_INT, + ], + 'hours' => [ + 'type' => PARAM_INT, + ], + 'mday' => [ + 'type' => PARAM_INT, + ], + 'wday' => [ + 'type' => PARAM_INT, + ], + 'mon' => [ + 'type' => PARAM_INT, + ], + 'year' => [ + 'type' => PARAM_INT, + ], + 'yday' => [ + 'type' => PARAM_INT, + ], + 'weekday' => [ + 'type' => PARAM_RAW, + ], + 'month' => [ + 'type' => PARAM_RAW, + ], + 'timestamp' => [ + 'type' => PARAM_INT, + ], + ]; + } +} diff --git a/calendar/classes/external/month_exporter.php b/calendar/classes/external/month_exporter.php index 6d180aa4ee1..94298bf2bec 100644 --- a/calendar/classes/external/month_exporter.php +++ b/calendar/classes/external/month_exporter.php @@ -104,9 +104,6 @@ class month_exporter extends exporter { 'filter_selector' => [ 'type' => PARAM_RAW, ], - 'navigation' => [ - 'type' => PARAM_RAW, - ], 'weeks' => [ 'type' => week_exporter::read_properties_definition(), 'multiple' => true, @@ -118,8 +115,8 @@ class month_exporter extends exporter { 'view' => [ 'type' => PARAM_ALPHA, ], - 'time' => [ - 'type' => PARAM_INT, + 'date' => [ + 'type' => date_exporter::read_properties_definition(), ], 'periodname' => [ // Note: We must use RAW here because the calendar type returns the formatted month name based on a @@ -127,7 +124,10 @@ class month_exporter extends exporter { 'type' => PARAM_RAW, ], 'previousperiod' => [ - 'type' => PARAM_INT, + 'type' => date_exporter::read_properties_definition(), + ], + 'previousperiodlink' => [ + 'type' => PARAM_URL, ], 'previousperiodname' => [ // Note: We must use RAW here because the calendar type returns the formatted month name based on a @@ -135,13 +135,16 @@ class month_exporter extends exporter { 'type' => PARAM_RAW, ], 'nextperiod' => [ - 'type' => PARAM_INT, + 'type' => date_exporter::read_properties_definition(), ], 'nextperiodname' => [ // Note: We must use RAW here because the calendar type returns the formatted month name based on a // calendar format. 'type' => PARAM_RAW, ], + 'nextperiodlink' => [ + 'type' => PARAM_URL, + ], 'larrow' => [ // The left arrow defined by the theme. 'type' => PARAM_RAW, @@ -160,22 +163,30 @@ class month_exporter extends exporter { * @return array Keys are the property names, values are their values. */ protected function get_other_values(renderer_base $output) { - $previousperiod = $this->get_previous_month_timestamp(); - $nextperiod = $this->get_next_month_timestamp(); + $previousperiod = $this->get_previous_month_data(); + $nextperiod = $this->get_next_month_data(); + $date = $this->related['type']->timestamp_to_date_array($this->calendar->time); + + $nextperiodlink = new moodle_url($this->url); + $nextperiodlink->param('time', $nextperiod[0]); + + $previousperiodlink = new moodle_url($this->url); + $previousperiodlink->param('time', $previousperiod[0]); return [ 'courseid' => $this->calendar->courseid, 'filter_selector' => $this->get_course_filter_selector($output), - 'navigation' => $this->get_navigation($output), 'weeks' => $this->get_weeks($output), 'daynames' => $this->get_day_names($output), 'view' => 'month', - 'time' => $this->calendar->time, + 'date' => (new date_exporter($date))->export($output), 'periodname' => userdate($this->calendar->time, get_string('strftimemonthyear')), - 'previousperiod' => $previousperiod, - 'previousperiodname' => userdate($previousperiod, get_string('strftimemonthyear')), - 'nextperiod' => $nextperiod, - 'nextperiodname' => userdate($nextperiod, get_string('strftimemonthyear')), + 'previousperiod' => (new date_exporter($previousperiod))->export($output), + 'previousperiodname' => userdate($previousperiod[0], get_string('strftimemonthyear')), + 'previousperiodlink' => $previousperiodlink->out(false), + 'nextperiod' => (new date_exporter($nextperiod))->export($output), + 'nextperiodname' => userdate($nextperiod[0], get_string('strftimemonthyear')), + 'nextperiodlink' => $nextperiodlink->out(false), 'larrow' => $output->larrow(), 'rarrow' => $output->rarrow(), ]; @@ -197,19 +208,6 @@ class month_exporter extends exporter { return $content; } - /** - * Get the calendar navigation controls. - * - * @param renderer_base $output - * @return string The html code to the calendar top navigation. - */ - protected function get_navigation(renderer_base $output) { - return calendar_top_controls('month', [ - 'id' => $this->calendar->courseid, - 'time' => $this->calendar->time, - ]); - } - /** * Get the list of day names for display, re-ordered from the first day * of the week. @@ -302,17 +300,30 @@ class month_exporter extends exporter { ]; } + /** + * Get the current month timestamp. + * + * @return int The month timestamp. + */ + protected function get_month_data() { + $date = $this->related['type']->timestamp_to_date_array($this->calendar->time); + $monthtime = $this->related['type']->convert_to_gregorian($date['year'], $date['month'], 1); + + return make_timestamp($monthtime['year'], $monthtime['month']); + } + /** * Get the previous month timestamp. * * @return int The previous month timestamp. */ - protected function get_previous_month_timestamp() { - $date = $this->related['type']->timestamp_to_date_array($this->calendar->time); - $month = calendar_sub_month($date['mon'], $date['year']); - $monthtime = $this->related['type']->convert_to_gregorian($month[1], $month[0], 1); + protected function get_previous_month_data() { + $type = $this->related['type']; + $date = $type->timestamp_to_date_array($this->calendar->time); + list($date['mon'], $date['year']) = $type->get_prev_month($date['year'], $date['mon']); + $time = $type->convert_to_timestamp($date['year'], $date['mon'], 1); - return make_timestamp($monthtime['year'], $monthtime['month'], $monthtime['day'], $monthtime['hour'], $monthtime['minute']); + return $type->timestamp_to_date_array($time); } /** @@ -320,11 +331,12 @@ class month_exporter extends exporter { * * @return int The next month timestamp. */ - protected function get_next_month_timestamp() { - $date = $this->related['type']->timestamp_to_date_array($this->calendar->time); - $month = calendar_add_month($date['mon'], $date['year']); - $monthtime = $this->related['type']->convert_to_gregorian($month[1], $month[0], 1); + protected function get_next_month_data() { + $type = $this->related['type']; + $date = $type->timestamp_to_date_array($this->calendar->time); + list($date['mon'], $date['year']) = $type->get_next_month($date['year'], $date['mon']); + $time = $type->convert_to_timestamp($date['year'], $date['mon'], 1); - return make_timestamp($monthtime['year'], $monthtime['month'], $monthtime['day'], $monthtime['hour'], $monthtime['minute']); + return $type->timestamp_to_date_array($time); } } diff --git a/calendar/externallib.php b/calendar/externallib.php index afad7dd85bc..8f6d44b5712 100644 --- a/calendar/externallib.php +++ b/calendar/externallib.php @@ -879,17 +879,19 @@ class core_calendar_external extends external_api { /** * Get data for the monthly calendar view. * - * @param int $time The time to be shown + * @param int $year The year to be shown + * @param int $month The month to be shown * @param int $courseid The course to be included * @return array */ - public static function get_calendar_monthly_view($time, $courseid) { + public static function get_calendar_monthly_view($year, $month, $courseid) { global $CFG, $DB, $USER, $PAGE; require_once($CFG->dirroot."/calendar/lib.php"); // Parameter validation. $params = self::validate_parameters(self::get_calendar_monthly_view_parameters(), [ - 'time' => $time, + 'year' => $year, + 'month' => $month, 'courseid' => $courseid, ]); @@ -906,6 +908,9 @@ class core_calendar_external extends external_api { $context = \context_user::instance($USER->id); self::validate_context($context); + $type = \core_calendar\type_factory::get_calendar_instance(); + + $time = $type->convert_to_timestamp($year, $month, 1); $calendar = new calendar_information(0, 0, 0, $time); $calendar->prepare_for_view($course, $courses); @@ -922,7 +927,8 @@ class core_calendar_external extends external_api { public static function get_calendar_monthly_view_parameters() { return new external_function_parameters( [ - 'time' => new external_value(PARAM_INT, 'Time to be viewed', VALUE_REQUIRED, '', NULL_NOT_ALLOWED), + 'year' => new external_value(PARAM_INT, 'Month to be viewed', VALUE_REQUIRED), + 'month' => new external_value(PARAM_INT, 'Year to be viewed', VALUE_REQUIRED), 'courseid' => new external_value(PARAM_INT, 'Course being viewed', VALUE_DEFAULT, SITEID, NULL_ALLOWED), ] ); diff --git a/calendar/templates/calendar_mini.mustache b/calendar/templates/calendar_mini.mustache index 6e28cbfab57..4ae79e4bafa 100644 --- a/calendar/templates/calendar_mini.mustache +++ b/calendar/templates/calendar_mini.mustache @@ -32,14 +32,13 @@ } }} <div{{! - }} id="calendar-month-{{uniqid}}-{{time}}" {{! + }} id="calendar-month-{{date.year}}-{{date.month}}-{{uniqid}}" {{! }} data-template="core_calendar/month_mini" {{! - }} data-includenavigation="{{#includenavigation}}true{{/includenavigation}}{{^includenavigation}}false{{/includenavigation}}"{{! }}> {{> core_calendar/month_mini}} </div> {{#js}} require(['jquery', 'core_calendar/calendar_mini'], function($, CalendarMini) { - CalendarMini.init($("#calendar-month-{{uniqid}}-{{time}}")); + CalendarMini.init($("#calendar-month-{{date.year}}-{{date.month}}-{{uniqid}}")); }); {{/js}} diff --git a/calendar/templates/month_detailed.mustache b/calendar/templates/month_detailed.mustache index 463b687216b..79925c416f9 100644 --- a/calendar/templates/month_detailed.mustache +++ b/calendar/templates/month_detailed.mustache @@ -31,7 +31,7 @@ { } }} -<div class="calendarwrapper" data-courseid="{{courseid}}" data-current-time="{{time}}"> +<div class="calendarwrapper" data-courseid="{{courseid}}" data-month="{{date.mon}}" data-year="{{date.year}}"> {{> core_calendar/month_header }} {{> core_calendar/month_navigation }} {{> core/overlay_loading}} diff --git a/calendar/templates/month_mini.mustache b/calendar/templates/month_mini.mustache index b14afc906c0..ae738bae2df 100644 --- a/calendar/templates/month_mini.mustache +++ b/calendar/templates/month_mini.mustache @@ -31,17 +31,39 @@ { } }} -<div id="month-mini-{{uniqid}}-{{time}}" class="calendarwrapper" data-courseid="{{courseid}}" data-current-time="{{time}}"> +<div{{! + }} id="month-mini-{{date.year}}-{{date.month}}-{{uniqid}}"{{! + }} class="calendarwrapper"{{! + }} data-courseid="{{courseid}}"{{! + }} data-month="{{date.mon}}"{{! + }} data-year="{{date.year}}"{{! + }}> {{> core/overlay_loading}} <table class="minicalendar calendartable"> <caption class="calendar-controls"> - <a href="#" class="arrow_link previous" title="{{#str}}monthprev, calendar{{/str}}" data-time="{{previousperiod}}"><span class="arrow">{{{larrow}}}</span></a> + <a{{! + }} href="#"{{! + }} class="arrow_link previous"{{! + }} title="{{#str}}monthprev, calendar{{/str}}"{{! + }} data-year="{{previousperiod.year}}"{{! + }} data-month="{{previousperiod.mon}}"{{! + }}> + <span class="arrow">{{{larrow}}}</span> + </a> <span class="hide"> | </span> <span class="current"> - <a href="{{{url}}}" title="{{#str}}monththis, calendar{{/str}}" data-time="">{{periodname}}</a> + <a href="{{{url}}}" title="{{#str}}monththis, calendar{{/str}}">{{periodname}}</a> </span> <span class="hide"> | </span> - <a href="#" class="arrow_link next" title="{{#str}}monthnext, calendar{{/str}}" data-time="{{nextperiod}}"><span class="arrow">{{{rarrow}}}</span></a> + <a{{! + }} href="#"{{! + }} class="arrow_link next"{{! + }} title="{{#str}}monthprev, calendar{{/str}}"{{! + }} data-year="{{nextperiod.year}}"{{! + }} data-month="{{nextperiod.mon}}"{{! + }}> + <span class="arrow">{{{rarrow}}}</span> + </a> </caption> <thead> <tr> @@ -145,7 +167,7 @@ require([ M.util.js_pending("month-mini-{{uniqid}}-filterChanged"); // A filter value has been changed. // Find all matching cells in the popover data, and hide them. - $("#month-mini-{{uniqid}}-{{time}}") + $("#month-mini-{{date.year}}-{{date.month}}-{{uniqid}}") .find(CalendarSelectors.popoverType[data.type]) .toggleClass('hidden', !!data.hidden); M.util.js_complete("month-mini-{{uniqid}}-filterChanged"); diff --git a/calendar/templates/month_navigation.mustache b/calendar/templates/month_navigation.mustache index f0f67ddcc68..68180c266d7 100644 --- a/calendar/templates/month_navigation.mustache +++ b/calendar/templates/month_navigation.mustache @@ -31,11 +31,37 @@ { } }} -{{#navigation}} <div id="month-navigation-{{uniqid}}" class="controls" data-view="{{view}}"> - {{{navigation}}} + <div class="calendar-controls"> + <a{{! + }} href="{{previousperiodlink}}"{{! + }} class="arrow_link previous"{{! + }} title="{{#str}}monthprev, calendar{{/str}}"{{! + }} data-year="{{previousperiod.year}}"{{! + }} data-month="{{previousperiod.mon}}"{{! + }} data-drop-zone="nav-link" {{! + }}> + <span class="arrow">{{{larrow}}}</span> + + <span class="arrow_text">{{previousperiodname}}</span> + </a> + <span class="hide"> | </span> + <h2 class="current">{{periodname}}</h2> + <span class="hide"> | </span> + <a{{! + }} href="{{nextperiodlink}}"{{! + }} class="arrow_link next"{{! + }} title="{{#str}}monthnext, calendar{{/str}}"{{! + }} data-year="{{nextperiod.year}}"{{! + }} data-month="{{nextperiod.mon}}"{{! + }} data-drop-zone="nav-link" {{! + }}> + <span class="arrow_text">{{nextperiodname}}</span> + + <span class="arrow">{{{rarrow}}}</span> + </a> + </div> </div> -{{/navigation}} {{#js}} require(['jquery', 'core_calendar/month_navigation_drag_drop'], function($, DragDrop) { var root = $('#month-navigation-{{uniqid}}'); diff --git a/calendar/view.php b/calendar/view.php index 6447c8d906a..8124af09a5e 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -51,22 +51,10 @@ require_once($CFG->dirroot.'/calendar/lib.php'); $courseid = optional_param('course', SITEID, PARAM_INT); $view = optional_param('view', 'upcoming', PARAM_ALPHA); -$day = optional_param('cal_d', 0, PARAM_INT); -$mon = optional_param('cal_m', 0, PARAM_INT); -$year = optional_param('cal_y', 0, PARAM_INT); $time = optional_param('time', 0, PARAM_INT); $url = new moodle_url('/calendar/view.php'); -// If a day, month and year were passed then convert it to a timestamp. If these were passed -// then we can assume the day, month and year are passed as Gregorian, as no where in core -// should we be passing these values rather than the time. This is done for BC. -if (!empty($day) && !empty($mon) && !empty($year)) { - if (checkdate($mon, $day, $year)) { - $time = make_timestamp($year, $mon, $day); - } -} - if (empty($time)) { $time = time(); }