mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-59388 core_calendar: fix cibot complains
This commit is contained in:
parent
644b2e982e
commit
a4af4c9633
6
calendar/amd/build/calendar.min.js
vendored
6
calendar/amd/build/calendar.min.js
vendored
@ -1,5 +1 @@
|
||||
<<<<<<< d92c4aa6682300fc7cf86db748a9d1826c115e50
|
||||
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_events","core/modal_factory","core_calendar/modal_event_form","core_calendar/summary_modal","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']",NEW_EVENT_BUTTON:"[data-action='new-event-button']"},n=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a})},o=function(a){return c.get_string("subsource","core_calendar",a).then(function(b){return a.url?'<a href="'+a.url+'">'+b+"</a>":b})},p=function(b){k.getEventById(b).then(function(c){if(!c.event)throw new Error("Error encountered while trying to fetch calendar event with ID: "+b);var d=c.event,e=n(d.eventtype);if(d.displayeventsource){d.subscription=JSON.parse(d.subscription);var f={url:d.subscription.url,name:d.subscription.name},g=o(f);return a.when(e,g).then(function(a,b){return d.eventtype=a,d.source=b,d})}return e.then(function(a){return d.eventtype=a,d})}).then(function(a){var b={title:a.name,type:j.TYPE,body:d.render("core_calendar/event_summary_body",a),templateContext:{canedit:a.canedit,candelete:a.candelete}};return h.create(b)}).done(function(a){a.getRoot().on(g.hidden,function(){a.destroy()}),a.show()}).fail(e.exception)},q=function(a){var b=a.find(m.NEW_EVENT_BUTTON),c=b.attr("data-context-id");return h.create({type:i.TYPE,large:!0,templateContext:{contextid:c}},b)},r=function(b,c){var d=a("body");d.on(l.created,function(){window.location.reload()}),d.on(l.deleted,function(){window.location.reload()}),d.on(l.updated,function(){window.location.reload()}),d.on(l.editActionEvent,function(a,b){window.location.assign(b)}),c.then(function(a){d.on(l.editEvent,function(b,c){a.setEventId(c),a.show()})})},s=function(){var b=a(m.ROOT);a(m.EVENT_LINK).click(function(b){b.preventDefault();var c=a(this).attr("data-event-id");p(c)});var c=q(b);r(b,c)};return{init:function(){s()}}});
|
||||
=======
|
||||
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_events","core/modal_factory","core_calendar/modal_event_form","core_calendar/summary_modal","core_calendar/repository","core_calendar/events","core_calendar/view_manager"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']",NEW_EVENT_BUTTON:"[data-action='new-event-button']"},o=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a})},p=function(a){return c.get_string("subsource","core_calendar",a).then(function(b){return a.url?'<a href="'+a.url+'">'+b+"</a>":b})},q=function(b){k.getEventById(b).then(function(c){if(!c.event)throw new Error("Error encountered while trying to fetch calendar event with ID: "+b);var d=c.event,e=o(d.eventtype);if(d.displayeventsource){d.subscription=JSON.parse(d.subscription);var f={url:d.subscription.url,name:d.subscription.name},g=p(f);return a.when(e,g).then(function(a,b){return d.eventtype=a,d.source=b,d})}return e.then(function(a){return d.eventtype=a,d})}).then(function(a){var b={title:a.name,type:j.TYPE,body:d.render("core_calendar/event_summary_body",a)};return a.caneditevent||(b.footer=""),h.create(b)}).done(function(a){a.getRoot().on(g.hidden,function(){a.destroy()}),a.show()}).fail(e.exception)},r=function(a){var b=a.find(n.NEW_EVENT_BUTTON),c=b.attr("data-context-id");return h.create({type:i.TYPE,large:!0,templateContext:{contextid:c}},b)},s=function(b,c){var d=a("body");d.on(l.created,function(){window.location.reload()}),d.on(l.deleted,function(){window.location.reload()}),d.on(l.updated,function(){window.location.reload()}),c.then(function(a){d.on(l.editEvent,function(b,c){a.setEventId(c),a.show()})})},t=function(){var b=a(n.ROOT);a(n.EVENT_LINK).click(function(b){b.preventDefault();var c=a(this).attr("data-event-id");q(c)});var c=r(b);s(b,c)};return{init:function(){m.init(),t()}}});
|
||||
>>>>>>> MDL-59388 calendar: Add AJAX Monthly navigation
|
||||
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_events","core/modal_factory","core_calendar/modal_event_form","core_calendar/summary_modal","core_calendar/repository","core_calendar/events","core_calendar/view_manager"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']",NEW_EVENT_BUTTON:"[data-action='new-event-button']"},o=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a})},p=function(a){return c.get_string("subsource","core_calendar",a).then(function(b){return a.url?'<a href="'+a.url+'">'+b+"</a>":b})},q=function(b){k.getEventById(b).then(function(c){if(!c.event)throw new Error("Error encountered while trying to fetch calendar event with ID: "+b);var d=c.event,e=o(d.eventtype);if(d.displayeventsource){d.subscription=JSON.parse(d.subscription);var f={url:d.subscription.url,name:d.subscription.name},g=p(f);return a.when(e,g).then(function(a,b){return d.eventtype=a,d.source=b,d})}return e.then(function(a){return d.eventtype=a,d})}).then(function(a){var b={title:a.name,type:j.TYPE,body:d.render("core_calendar/event_summary_body",a),templateContext:{canedit:a.canedit,candelete:a.candelete}};return h.create(b)}).done(function(a){a.getRoot().on(g.hidden,function(){a.destroy()}),a.show()}).fail(e.exception)},r=function(a){var b=a.find(n.NEW_EVENT_BUTTON),c=b.attr("data-context-id");return h.create({type:i.TYPE,large:!0,templateContext:{contextid:c}},b)},s=function(b,c){var d=a("body");d.on(l.created,function(){window.location.reload()}),d.on(l.deleted,function(){window.location.reload()}),d.on(l.updated,function(){window.location.reload()}),d.on(l.editActionEvent,function(a,b){window.location.assign(b)}),c.then(function(a){d.on(l.editEvent,function(b,c){a.setEventId(c),a.show()})})},t=function(){var b=a(n.ROOT);a(n.EVENT_LINK).click(function(b){b.preventDefault();var c=a(this).attr("data-event-id");q(c)});var c=r(b);s(b,c)};return{init:function(){m.init(),t()}}});
|
2
calendar/amd/build/events.min.js
vendored
2
calendar/amd/build/events.min.js
vendored
@ -1 +1 @@
|
||||
define([],function(){return{created:"calendar-events:created",deleted:"calendar-events:deleted",updated:"calendar-events:updated",editEvent:"calendar-events:edit_event",editActionEvent:"calendar-events:edit_action_event"}});
|
||||
define([],function(){return{created:"calendar-events:created",deleted:"calendar-events:deleted",updated:"calendar-events:updated",editEvent:"calendar-events:edit_event",editActionEvent:"calendar-events:edit_action_event",monthChanged:"calendar-events:month_changed"}});
|
2
calendar/amd/build/view_manager.min.js
vendored
2
calendar/amd/build/view_manager.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/notification","core_calendar/repository"],function(a,b,c,d){var e={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:"span.calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper"},f=function(b){b=a(b),a(b).on("click",e.CALENDAR_NAV_LINK,function(c){var d=a(b).find(e.CALENDAR_MONTH_WRAPPER).data("courseid"),f=a(c.currentTarget);g(f.attr("href"),f.data("time"),d),c.preventDefault()})},g=function(f,g,h){d.getCalendarMonthData(g,h).then(function(a){return window.history.pushState({},"Some new title",f),b.render("core_calendar/month_detailed",a)}).then(function(c,d){return a(e.CALENDAR_MONTH_WRAPPER).replaceWith(c),b.runTemplateJS(d)}).then(function(){}).fail(c.exception)};return{init:function(){f(e.ROOT)}}});
|
||||
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:"span.calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper"},g=function(b){b=a(b),a(b).on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);h(e.attr("href"),e.data("time"),d),c.preventDefault()})},h=function(g,h,i){d.getCalendarMonthData(h,i).then(function(a){return window.history.pushState({},"",g),b.render("core_calendar/month_detailed",a)}).then(function(c,d){return a(f.CALENDAR_MONTH_WRAPPER).replaceWith(c),b.runTemplateJS(d)}).done(function(){a("body").trigger(e.monthChanged,[])}).fail(c.exception)};return{init:function(){g(f.ROOT)}}});
|
@ -249,7 +249,7 @@ define(['jquery', 'core/templates'], function($, Templates) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise all of the form enhancementds.
|
||||
* Initialise all of the form enhancements.
|
||||
*
|
||||
* @method init
|
||||
* @param {string} formId The value of the form's id attribute
|
||||
|
@ -28,6 +28,7 @@ define([], function() {
|
||||
deleted: 'calendar-events:deleted',
|
||||
updated: 'calendar-events:updated',
|
||||
editEvent: 'calendar-events:edit_event',
|
||||
editActionEvent: 'calendar-events:edit_action_event'
|
||||
editActionEvent: 'calendar-events:edit_action_event',
|
||||
monthChanged: 'calendar-events:month_changed'
|
||||
};
|
||||
});
|
||||
|
@ -91,12 +91,12 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
|
||||
* @param {Number} courseid The course id.
|
||||
* @return {promise} Resolved with the month view data.
|
||||
*/
|
||||
var getCalendarMonthData = function (time, courseid) {
|
||||
var getCalendarMonthData = function(time, courseid) {
|
||||
var request = {
|
||||
methodname: 'core_calendar_get_calendar_monthly_view',
|
||||
args: {
|
||||
time: time,
|
||||
courseid: courseid,
|
||||
courseid: courseid
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
* @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/templates', 'core/notification', 'core_calendar/repository'],
|
||||
function($, Templates, Notification, CalendarRepository) {
|
||||
define(['jquery', 'core/templates', 'core/notification', 'core_calendar/repository', 'core_calendar/events'],
|
||||
function($, Templates, Notification, CalendarRepository, CalendarEvents) {
|
||||
|
||||
var SELECTORS = {
|
||||
ROOT: "[data-region='calendar']",
|
||||
@ -47,18 +47,17 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle changes to the current calendar view.
|
||||
*
|
||||
* @param {String} url The calendar url to be shown
|
||||
* @param {Number} time The calendar time to be shown
|
||||
* @param {Number} courseid The id of the course whose events are shown
|
||||
*/
|
||||
var changeMonth = function(url, time, courseid) {
|
||||
CalendarRepository.getCalendarMonthData(time, courseid)
|
||||
.then(function(context) {
|
||||
// TODO Fetch the page title from somewhere..?
|
||||
window.history.pushState({}, 'Some new title', url);
|
||||
window.history.pushState({}, '', url);
|
||||
|
||||
return Templates.render('core_calendar/month_detailed', context);
|
||||
})
|
||||
@ -67,8 +66,8 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
|
||||
|
||||
return Templates.runTemplateJS(js);
|
||||
})
|
||||
.then(function() {
|
||||
// TODO Fire an event to say the month changed.
|
||||
.done(function() {
|
||||
$('body').trigger(CalendarEvents.monthChanged, []);
|
||||
})
|
||||
.fail(Notification.exception);
|
||||
};
|
||||
|
68
calendar/classes/external/day_exporter.php
vendored
68
calendar/classes/external/day_exporter.php
vendored
@ -1,13 +1,49 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Contains event class for displaying the day view.
|
||||
*
|
||||
* @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 displaying the day view.
|
||||
*
|
||||
* @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 day_exporter extends exporter {
|
||||
|
||||
/**
|
||||
* Return the list of properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_properties() {
|
||||
// These are the default properties as returned by getuserdate()
|
||||
// but without the formatted month and week names.
|
||||
@ -36,6 +72,11 @@ class day_exporter extends exporter {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of additional properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_other_properties() {
|
||||
return [
|
||||
'timestamp' => [
|
||||
@ -56,24 +97,17 @@ class day_exporter extends exporter {
|
||||
'events' => [
|
||||
'type' => event_exporter::read_properties_definition(),
|
||||
'multiple' => true,
|
||||
],
|
||||
'viewdaylink' => [
|
||||
'type' => PARAM_URL,
|
||||
],
|
||||
|
||||
//'viewdaylink' => $this->viewdaylink->out(false),
|
||||
//'createeventlink' => $this->createeventlink,
|
||||
//'viewdaylinktitle' => $this->get_title($renderer),
|
||||
//'events' => $this->get_events($renderer),
|
||||
//'hasevents' => !empty($this->events),
|
||||
//'eventtypes' => array_unique($this->eventtypes),
|
||||
//'eventcount' => count($this->events),
|
||||
//'durationevents' => array_unique($this->durationevents),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the additional values to inject while exporting.
|
||||
*
|
||||
* @param renderer_base $output The renderer.
|
||||
* @return array Keys are the property names, values are their values.
|
||||
*/
|
||||
protected function get_other_values(renderer_base $output) {
|
||||
//$events = new events_exporter($this->related['events'], $this->related);
|
||||
$return = [
|
||||
'timestamp' => $this->data[0],
|
||||
];
|
||||
@ -84,7 +118,6 @@ class day_exporter extends exporter {
|
||||
]);
|
||||
$return['viewdaylink'] = $url->out(false);
|
||||
|
||||
|
||||
$cache = $this->related['cache'];
|
||||
$return['events'] = array_map(function($event) use ($cache, $output, $url) {
|
||||
$context = $cache->get_context($event);
|
||||
@ -101,6 +134,11 @@ class day_exporter extends exporter {
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of objects that are related.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_related() {
|
||||
return [
|
||||
'events' => '\core_calendar\local\event\entities\event_interface[]',
|
||||
|
42
calendar/classes/external/day_name_exporter.php
vendored
42
calendar/classes/external/day_name_exporter.php
vendored
@ -1,11 +1,42 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Contains event class for displaying the day name.
|
||||
*
|
||||
* @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 displaying the day view.
|
||||
*
|
||||
* @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 day_name_exporter extends exporter {
|
||||
|
||||
/**
|
||||
@ -23,12 +54,23 @@ class day_name_exporter extends exporter {
|
||||
*/
|
||||
protected $fullname;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $dayno The day number.
|
||||
* @param array $names The list of names.
|
||||
*/
|
||||
public function __construct($dayno, $names) {
|
||||
$data = $names + ['dayno' => $dayno];
|
||||
|
||||
parent::__construct($data, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_properties() {
|
||||
return [
|
||||
'dayno' => [
|
||||
|
@ -57,6 +57,8 @@ class footer_options_exporter extends exporter {
|
||||
* Constructor for month_exporter.
|
||||
*
|
||||
* @param \calendar_information $calendar The calendar being represented
|
||||
* @param int $userid The user id
|
||||
* @param string $token The user sha1 token.
|
||||
*/
|
||||
public function __construct(\calendar_information $calendar, $userid, $token) {
|
||||
$this->calendar = $calendar;
|
||||
@ -82,7 +84,7 @@ class footer_options_exporter extends exporter {
|
||||
*/
|
||||
protected function get_ical_url() {
|
||||
return new moodle_url('/calendar/export_execute.php', ['preset_what' => 'all',
|
||||
'preset_time' => 'recentupcoming', 'userid' => $this->userid, 'authtoken'=> $this->token]);
|
||||
'preset_time' => 'recentupcoming', 'userid' => $this->userid, 'authtoken' => $this->token]);
|
||||
|
||||
}
|
||||
|
||||
|
77
calendar/classes/external/month_exporter.php
vendored
77
calendar/classes/external/month_exporter.php
vendored
@ -1,11 +1,42 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Contains event class for displaying the month view.
|
||||
*
|
||||
* @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 displaying the month view.
|
||||
*
|
||||
* @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 month_exporter extends exporter {
|
||||
|
||||
/**
|
||||
@ -48,6 +79,11 @@ class month_exporter extends exporter {
|
||||
parent::__construct([], $related);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of additional properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_other_properties() {
|
||||
return [
|
||||
'courseid' => [
|
||||
@ -79,6 +115,12 @@ class month_exporter extends exporter {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the additional values to inject while exporting.
|
||||
*
|
||||
* @param renderer_base $output The renderer.
|
||||
* @return array Keys are the property names, values are their values.
|
||||
*/
|
||||
protected function get_other_values(renderer_base $output) {
|
||||
return [
|
||||
'courseid' => $this->calendar->courseid,
|
||||
@ -94,10 +136,9 @@ class month_exporter extends exporter {
|
||||
|
||||
/**
|
||||
* Get the course filter selector.
|
||||
* TODO Convert to new exporter?
|
||||
*
|
||||
* @param renderer_base $output
|
||||
* return string
|
||||
* @param renderer_base $output
|
||||
* @return string The html code for the course filter selector.
|
||||
*/
|
||||
protected function get_course_filter_selector(renderer_base $output) {
|
||||
$content = '';
|
||||
@ -110,11 +151,10 @@ class month_exporter extends exporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the course filter selector.
|
||||
* TODO Convert to new exporter?
|
||||
* Get the calendar navigation controls.
|
||||
*
|
||||
* @param renderer_base $output
|
||||
* return string
|
||||
* @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', [
|
||||
@ -149,8 +189,8 @@ class month_exporter extends exporter {
|
||||
* Get the list of week days, ordered into weeks and padded according
|
||||
* to the value of the first day of the week.
|
||||
*
|
||||
* @param renderer_base $output
|
||||
* @return array
|
||||
* @param renderer_base $output
|
||||
* @return array The list of weeks.
|
||||
*/
|
||||
protected function get_weeks(renderer_base $output) {
|
||||
$weeks = [];
|
||||
@ -185,7 +225,7 @@ class month_exporter extends exporter {
|
||||
/**
|
||||
* Get the list of days with the matching date array.
|
||||
*
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
protected function get_days() {
|
||||
$date = $this->related['type']->timestamp_to_date_array($this->calendar->time);
|
||||
@ -202,6 +242,11 @@ class month_exporter extends exporter {
|
||||
return $days;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of objects that are related.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_related() {
|
||||
return [
|
||||
'events' => '\core_calendar\local\event\entities\event_interface[]',
|
||||
@ -210,17 +255,29 @@ class month_exporter extends exporter {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
return make_timestamp($monthtime['year'], $monthtime['month'], $monthtime['day'], $monthtime['hour'], $monthtime['minute']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next month timestamp.
|
||||
*
|
||||
* @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_sub_month($date['mon'], $date['year']);
|
||||
$monthtime = $this->related['type']->convert_to_gregorian($month[1], $month[0], 1);
|
||||
|
||||
return make_timestamp($monthtime['year'], $monthtime['month'], $monthtime['day'], $monthtime['hour'], $monthtime['minute']);
|
||||
}
|
||||
}
|
||||
|
64
calendar/classes/external/week_exporter.php
vendored
64
calendar/classes/external/week_exporter.php
vendored
@ -1,11 +1,42 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Contains event class for displaying the week view.
|
||||
*
|
||||
* @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 displaying the week view.
|
||||
*
|
||||
* @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 week_exporter extends exporter {
|
||||
|
||||
/**
|
||||
@ -14,17 +45,23 @@ class week_exporter extends exporter {
|
||||
protected $days = [];
|
||||
|
||||
/**
|
||||
* @var int $prepadding The number of pre-padding days at the start of
|
||||
* the week.
|
||||
* @var int $prepadding The number of pre-padding days at the start of the week.
|
||||
*/
|
||||
protected $prepadding = 0;
|
||||
|
||||
/**
|
||||
* @var int $postpadding The number of post-padding days at the start of
|
||||
* the week.
|
||||
* @var int $postpadding The number of post-padding days at the start of the week.
|
||||
*/
|
||||
protected $postpadding = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $days An array of day_exporter objects.
|
||||
* @param int $prepadding The number of pre-padding days at the start of the week.
|
||||
* @param int $postpadding The number of post-padding days at the start of the week.
|
||||
* @param array $related Related objects.
|
||||
*/
|
||||
public function __construct($days, $prepadding, $postpadding, $related) {
|
||||
$this->days = $days;
|
||||
$this->prepadding = $prepadding;
|
||||
@ -33,6 +70,11 @@ class week_exporter extends exporter {
|
||||
parent::__construct([], $related);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of additional properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_other_properties() {
|
||||
return [
|
||||
'prepadding' => [
|
||||
@ -50,6 +92,12 @@ class week_exporter extends exporter {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the additional values to inject while exporting.
|
||||
*
|
||||
* @param renderer_base $output The renderer.
|
||||
* @return array Keys are the property names, values are their values.
|
||||
*/
|
||||
protected function get_other_values(renderer_base $output) {
|
||||
$return = [
|
||||
'prepadding' => [],
|
||||
@ -82,22 +130,26 @@ class week_exporter extends exporter {
|
||||
// Ends before today.
|
||||
continue;
|
||||
}
|
||||
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
|
||||
$day = new day_exporter($daydata, [
|
||||
'events' => $events,
|
||||
'cache' => $this->related['cache'],
|
||||
'type' => $this->related['type'],
|
||||
]);
|
||||
|
||||
$return['days'][] = $day->export($output);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of objects that are related.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_related() {
|
||||
return [
|
||||
'events' => '\core_calendar\local\event\entities\event_interface[]',
|
||||
|
@ -3431,7 +3431,7 @@ function calendar_get_legacy_events($tstart, $tend, $users, $groups, $courses, $
|
||||
* @return array[array, string]
|
||||
*/
|
||||
function calendar_get_view(\calendar_information $calendar, $view) {
|
||||
global $PAGE, $DB, $OUTPUT;
|
||||
global $PAGE, $CFG;
|
||||
|
||||
$renderer = $PAGE->get_renderer('core_calendar');
|
||||
$type = \core_calendar\type_factory::get_calendar_instance();
|
||||
@ -3444,7 +3444,11 @@ function calendar_get_view(\calendar_information $calendar, $view) {
|
||||
$tend = $tstart + DAYSECS - 1;
|
||||
$selectortitle = get_string('dayviewfor', 'calendar');
|
||||
} else if ($view === 'upcoming') {
|
||||
$defaultlookahead = isset($CFG->calendar_lookahead) ? intval($CFG->calendar_lookahead) : CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
|
||||
if (isset($CFG->calendar_lookahead)) {
|
||||
$defaultlookahead = intval($CFG->calendar_lookahead);
|
||||
} else {
|
||||
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
|
||||
}
|
||||
$tend = $tstart + get_user_preferences('calendar_lookahead', $defaultlookahead);
|
||||
$selectortitle = get_string('upcomingeventsfor', 'calendar');
|
||||
} else {
|
||||
@ -3503,9 +3507,7 @@ function calendar_get_view(\calendar_information $calendar, $view) {
|
||||
'cache' => new \core_calendar\external\events_related_objects_cache($events),
|
||||
];
|
||||
|
||||
if ($view === 'day') {
|
||||
// TODO: Export the days events in a new exporter.
|
||||
} else if ($view === 'upcoming') {
|
||||
if ($view === 'upcoming') {
|
||||
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
|
||||
if (isset($CFG->calendar_lookahead)) {
|
||||
$defaultlookahead = intval($CFG->calendar_lookahead);
|
||||
@ -3517,7 +3519,6 @@ function calendar_get_view(\calendar_information $calendar, $view) {
|
||||
$defaultmaxevents = intval($CFG->calendar_maxevents);
|
||||
}
|
||||
$maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
|
||||
// TODO: Export the upcoming events in a new exporter.
|
||||
} else {
|
||||
$month = new \core_calendar\external\month_exporter($calendar, $type, $related);
|
||||
$data = $month->export($renderer);
|
||||
|
@ -1,3 +1,36 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template calendar/month_detailed
|
||||
|
||||
Calendar month view.
|
||||
|
||||
The purpose of this template is to render the month view.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
}
|
||||
}}
|
||||
<span class="calendarwrapper" data-courseid="{{courseid}}">
|
||||
{{> core_calendar/month_header }}
|
||||
{{> core_calendar/month_navigation }}
|
||||
|
@ -1,3 +1,36 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template calendar/month_header
|
||||
|
||||
Calendar month header.
|
||||
|
||||
The purpose of this template is to render the month header.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
}
|
||||
}}
|
||||
{{#filter_selector}}
|
||||
<div class="header">
|
||||
{{{filter_selector}}}
|
||||
|
@ -1,3 +1,36 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template calendar/month_navigation
|
||||
|
||||
Calendar month navigation.
|
||||
|
||||
The purpose of this template is to render the navigation to switch to previous and next months.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
}
|
||||
}}
|
||||
{{#navigation}}
|
||||
<div class="controls" data-view="{{view}}">
|
||||
{{{navigation}}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user