2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Contains event class for displaying the day on month view.
20 * @package core_calendar
21 * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core_calendar\external;
27 defined('MOODLE_INTERNAL') || die();
33 * Class for displaying the day on month view.
35 * @package core_calendar
36 * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 class week_day_exporter extends day_exporter {
44 * @param \calendar_information $calendar The calendar information for the period being displayed
45 * @param mixed $data Either an stdClass or an array of values.
46 * @param array $related Related objects.
48 public function __construct(\calendar_information $calendar, $data, $related) {
49 parent::__construct($calendar, $data, $related);
50 // Fix the url for today to be based on the today timestamp
51 // rather than the calendar_information time set in the parent
53 $this->url->param('time', $this->data[0]);
57 * Return the list of properties.
61 protected static function define_properties() {
62 $return = parent::define_properties();
63 $return = array_merge($return, [
64 // These are additional params.
78 * Return the list of additional properties.
82 protected static function define_other_properties() {
83 $return = parent::define_other_properties();
84 $return = array_merge($return, [
95 * Get the additional values to inject while exporting.
97 * @param renderer_base $output The renderer.
98 * @return array Keys are the property names, values are their values.
100 protected function get_other_values(renderer_base $output) {
101 $return = parent::get_other_values($output);
103 if ($popovertitle = $this->get_popover_title()) {
104 $return['popovertitle'] = $popovertitle;
111 * Returns a list of objects that are related.
115 protected static function define_related() {
117 'events' => '\core_calendar\local\event\entities\event_interface[]',
118 'cache' => '\core_calendar\external\events_related_objects_cache',
119 'type' => '\core_calendar\type_base',
124 * Get the title for this popover.
128 protected function get_popover_title() {
131 $userdate = userdate($this->data[0], get_string('strftimedayshort'));
132 if (count($this->related['events'])) {
133 $title = get_string('eventsfor', 'calendar', $userdate);
134 } else if ($this->data['istoday']) {
138 if ($this->data['istoday']) {
139 $title = get_string('todayplustitle', 'calendar', $userdate);