From 644b2e982e77a3be99c74038d63a260fcf35a4f5 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 19 Jul 2017 09:04:19 +0800 Subject: [PATCH] MDL-59388 core_calendar: display calendar footer options --- calendar/templates/footer_options.mustache | 33 ++++++++++++++++++++++ calendar/view.php | 26 +++-------------- 2 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 calendar/templates/footer_options.mustache diff --git a/calendar/templates/footer_options.mustache b/calendar/templates/footer_options.mustache new file mode 100644 index 00000000000..d5371505caf --- /dev/null +++ b/calendar/templates/footer_options.mustache @@ -0,0 +1,33 @@ +{{! + 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 . +}} +{{! + @template core_calendar/footer_options + + Displays export options on the calendar footer. + + Example context (json): + { + "exportcalendarbutton": "", + "managesubscriptionbutton": "", + "icalurl": "http://example.com/" + } +}} +
+ {{{exportcalendarbutton}}} + {{{managesubscriptionbutton}}} + iCal +
diff --git a/calendar/view.php b/calendar/view.php index fdf3cb05ff8..ba0bc947c6d 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -152,32 +152,14 @@ if ($view == 'day' || $view == 'upcoming') { echo $renderer->show_upcoming_events($calendar, $lookahead, $maxevents); break; } - - //Link to calendar export page. - echo $OUTPUT->container_start('bottom'); - if (!empty($CFG->enablecalendarexport)) { - echo $OUTPUT->single_button(new moodle_url('export.php', array('course'=>$courseid)), get_string('exportcalendar', 'calendar')); - if (calendar_user_can_add_event($course)) { - $manageurl = new moodle_url('/calendar/managesubscriptions.php', ['course' => $courseid]); - echo $OUTPUT->single_button($manageurl, get_string('managesubscriptions', 'calendar')); - } - if (isloggedin()) { - $authtoken = sha1($USER->id . $DB->get_field('user', 'password', array('id' => $USER->id)) . $CFG->calendar_exportsalt); - $link = new moodle_url( - '/calendar/export_execute.php', - array('preset_what'=>'all', 'preset_time' => 'recentupcoming', 'userid' => $USER->id, 'authtoken'=>$authtoken) - ); - echo html_writer::tag('a', 'iCal', - array('href' => $link, 'title' => get_string('quickdownloadcalendar', 'calendar'), 'class' => 'ical-link m-l-1')); - } - } - - echo $OUTPUT->container_end(); } else if ($view == 'month') { list($data, $template) = calendar_get_view($calendar, $view); echo $renderer->render_from_template($template, $data); } echo html_writer::end_tag('div'); -echo $renderer->complete_layout(); + +list($data, $template) = calendar_get_footer_options($calendar); +echo $renderer->render_from_template($template, $data); + $PAGE->requires->js_call_amd('core_calendar/calendar', 'init'); echo $OUTPUT->footer();