forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
135 lines (109 loc) · 5.59 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/////////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Calendar extension //
// //
// Copyright (C) 2003-2004 Greek School Network www.sch.gr //
// //
// Designed by: //
// Avgoustos Tsinakos ([email protected]) //
// Jon Papaioannou ([email protected]) //
// //
// Programming and development: //
// Jon Papaioannou ([email protected]) //
// //
// For bugs, suggestions, etc contact: //
// Jon Papaioannou ([email protected]) //
// //
// The current module was developed at the University of Macedonia //
// (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) //
// The aim of this project is to provide additional and improved //
// functionality to the Asynchronous Distance Education service that the //
// Greek School Network deploys. //
// //
// This program 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 2 of the License, or //
// (at your option) any later version. //
// //
// This program 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: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
/////////////////////////////////////////////////////////////////////////////
/**
* Display the calendar page.
* @copyright 2003 Jon Papaioannou
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_calendar
*/
require_once('../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/calendar/lib.php');
$categoryid = optional_param('category', null, PARAM_INT);
$courseid = optional_param('course', SITEID, PARAM_INT);
$view = optional_param('view', 'upcoming', PARAM_ALPHA);
$time = optional_param('time', 0, PARAM_INT);
$url = new moodle_url('/calendar/view.php');
if (empty($time)) {
$time = time();
}
if ($courseid != SITEID) {
$url->param('course', $courseid);
}
if ($categoryid) {
$url->param('categoryid', $categoryid);
}
if ($view !== 'upcoming') {
$time = usergetmidnight($time);
$url->param('view', $view);
}
$url->param('time', $time);
$PAGE->set_url($url);
$course = get_course($courseid);
if ($courseid != SITEID && !empty($courseid)) {
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
} else if (!empty($categoryid)) {
$PAGE->set_category_by_id($categoryid);
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
} else {
$PAGE->set_context(context_system::instance());
}
require_login($course, false);
$calendar = calendar_information::create($time, $courseid, $categoryid);
$pagetitle = '';
$strcalendar = get_string('calendar', 'calendar');
switch($view) {
case 'day':
$PAGE->navbar->add(userdate($time, get_string('strftimedate')));
$pagetitle = get_string('dayviewtitle', 'calendar', userdate($time, get_string('strftimedaydate')));
break;
case 'month':
$PAGE->navbar->add(userdate($time, get_string('strftimemonthyear')));
$pagetitle = get_string('detailedmonthviewtitle', 'calendar', userdate($time, get_string('strftimemonthyear')));
break;
case 'upcoming':
$pagetitle = get_string('upcomingevents', 'calendar');
break;
}
// Print title and header
$PAGE->set_pagelayout('standard');
$PAGE->set_title("$course->shortname: $strcalendar: $pagetitle");
$PAGE->set_heading($COURSE->fullname);
$renderer = $PAGE->get_renderer('core_calendar');
$calendar->add_sidecalendar_blocks($renderer, true, $view);
echo $OUTPUT->header();
echo $renderer->start_layout();
echo html_writer::start_tag('div', array('class'=>'heightcontainer'));
echo $OUTPUT->heading(get_string('calendar', 'calendar'));
list($data, $template) = calendar_get_view($calendar, $view);
echo $renderer->render_from_template($template, $data);
echo html_writer::end_tag('div');
list($data, $template) = calendar_get_footer_options($calendar);
echo $renderer->render_from_template($template, $data);
echo $OUTPUT->footer();