-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfullpage.php
109 lines (94 loc) · 3.68 KB
/
fullpage.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
<?php
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net)
*
* 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 3 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package block_elisdashboard
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2008-2014 Remote-Learner.net Inc (http://www.remote-learner.net)
*
*/
/*
* This page shows a single elis dashboard block on a page, specified by instance (block instance id) GET parameter.
*/
require_once(__DIR__.'/../../config.php');
require_login();
$instanceid = required_param('instance', PARAM_INT);
$urlparams = ['instance' => $instanceid];
$PAGE->set_url('/blocks/elisdashboard/fullpage.php', $urlparams);
$usercontext = \context_user::instance($USER->id);
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('mydashboard');
$PAGE->set_pagetype('elis-dashboard');
$PAGE->blocks->add_region('content');
$USER->editing = false;
$params = ['id' => $instanceid, 'blockname' => 'elisdashboard'];
$instance = $DB->get_record('block_instances', $params);
if (!empty($instance)) {
$blockcontext = context_block::instance($instance->id);
require_capability('moodle/block:view', $blockcontext);
$instance->visible = 1;
$instance->blockpositionid = 0;
$block = block_instance('elisdashboard', $instance);
$block->enablefullscreen();
$widget = (isset($block->config->widget)) ? $block->config->widget : 'help';
$widget = \local_elisprogram\lib\widgetbase::instance($widget);
// Require capabilities.
$requiredcaps = $widget->get_required_capabilities();
if (!empty($requiredcaps)) {
$systemcontext = \context_system::instance();
foreach ($requiredcaps as $requiredcap) {
require_capability($requiredcap, $systemcontext);
}
}
// Add additional page parameters based on selected widget.
$PAGE->navbar->add($widget->get_name(), $PAGE->url);
$PAGE->set_title($widget->get_name());
$PAGE->set_heading($widget->get_name());
$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('ui');
$PAGE->requires->jquery_plugin('ui-css');
// Add required head JS files.
$requiredjs = $widget->get_js_dependencies_head();
if (!empty($requiredjs)) {
foreach ($requiredjs as $file) {
$PAGE->requires->js($file, true);
}
}
// Add required JS files.
$requiredjs = $widget->get_js_dependencies();
if (!empty($requiredjs)) {
foreach ($requiredjs as $file) {
$PAGE->requires->js($file);
}
}
// Add required CSS files.
$requiredcss = $widget->get_css_dependencies();
if (!empty($requiredcss)) {
foreach ($requiredcss as $file) {
$PAGE->requires->css($file);
}
}
$content = $block->get_content_for_output($OUTPUT);
echo $OUTPUT->header();
echo $OUTPUT->block($content, 'content');
echo $OUTPUT->footer();
} else {
echo $OUTPUT->header();
echo get_string('instance_not_found', 'block_elisdashboard');
echo $OUTPUT->footer();
}