/
renderers.php
184 lines (166 loc) · 8.71 KB
/
renderers.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
class theme_skillbox_core_renderer extends theme_bootstrapbase_core_renderer {
}
require_once('renderers/grid_renderer.php');
include_once($CFG->dirroot . "/blocks/course_overview/renderer.php");
class theme_skillbox_block_course_overview_renderer extends block_course_overview_renderer {
/**
* Construct contents of course_overview block
*
* @param array $courses list of courses in sorted order
* @param array $overviews list of course overviews
* @return string html to be displayed in course_overview block
*/
public function course_overview($courses, $overviews) {
global $CFG;
$html = '';
$config = get_config('block_course_overview');
$ismovingcourse = false;
$courseordernumber = 0;
$maxcourses = count($courses);
$userediting = false;
// Intialise string/icon etc if user is editing and courses > 1
if ($this->page->user_is_editing() && (count($courses) > 1)) {
$userediting = true;
$this->page->requires->js_init_call('M.block_course_overview.add_handles');
// Check if course is moving
$ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
$movingcourseid = optional_param('courseid', 0, PARAM_INT);
}
// Render first movehere icon.
if ($ismovingcourse) {
// Remove movecourse param from url.
$this->page->ensure_param_not_in_url('movecourse');
// Show moving course notice, so user knows what is being moved.
$html .= $this->output->box_start('notice');
$a = new stdClass();
$a->fullname = $courses[$movingcourseid]->fullname;
$a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
$html .= get_string('movingcourse', 'block_course_overview', $a);
$html .= $this->output->box_end();
$moveurl = new moodle_url('/blocks/course_overview/move.php',
array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
// Create move icon, so it can be used.
$movetofirsticon = html_writer::empty_tag('img',
array('src' => $this->output->pix_url('movehere'),
'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname),
'title' => get_string('movehere')));
$moveurl = html_writer::link($moveurl, $movetofirsticon);
$html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
}
foreach ($courses as $key => $course) {
// If moving course, then don't show course which needs to be moved.
if ($ismovingcourse && ($course->id == $movingcourseid)) {
continue;
}
$html .= $this->output->box_start('span6', "course-{$course->id}");
$html .= html_writer::start_tag('div', array('class' => 'coursebox'));
$html .= html_writer::start_tag('div', array('class' => 'course_title'));
// If user is editing, then add move icons.
if ($userediting && !$ismovingcourse) {
$moveicon = html_writer::empty_tag('img',
array('src' => $this->pix_url('t/move')->out(false),
'alt' => get_string('movecourse', 'block_course_overview', $course->fullname),
'title' => get_string('move')));
$moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
$moveurl = html_writer::link($moveurl, $moveicon);
$html .= html_writer::tag('div', $moveurl, array('class' => 'move'));
}
// No need to pass title through s() here as it will be done automatically by html_writer.
$attributes = array('title' => $course->fullname);
if ($course->id > 0) {
if (empty($course->visible)) {
$attributes['class'] = 'dimmed';
}
$courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
$coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
$link = html_writer::link($courseurl, $coursefullname, $attributes);
$html .= $this->output->heading($link, 2, 'title');
} else {
$html .= $this->output->heading(html_writer::link(
new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id='.$course->remoteid)),
format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
}
$html .= $this->output->box('', 'flush');
$html .= html_writer::end_tag('div');
if (!empty($config->showchildren) && ($course->id > 0)) {
// List children here.
if ($children = block_course_overview_get_child_shortnames($course->id)) {
$html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
}
}
// show summary and image
require_once($CFG->libdir. '/coursecatlib.php');
global $DB;
$coursesummary = $DB->get_field("course", "summary", array("id"=>$course->id));
$html .= html_writer::tag('p', $coursesummary, array('class'=>'summary'));
// If user is moving courses, then down't show overview.
if (isset($overviews[$course->id]) && !$ismovingcourse) {
$html .= $this->activity_display($course->id, $overviews[$course->id]);
}
$html .= $this->output->box('', 'flush');
$courseordernumber++;
if ($ismovingcourse) {
$moveurl = new moodle_url('/blocks/course_overview/move.php',
array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid));
$a = new stdClass();
$a->movingcoursename = $courses[$movingcourseid]->fullname;
$a->currentcoursename = $course->fullname;
$movehereicon = html_writer::empty_tag('img',
array('src' => $this->output->pix_url('movehere'),
'alt' => get_string('moveafterhere', 'block_course_overview', $a),
'title' => get_string('movehere')));
$moveurl = html_writer::link($moveurl, $movehereicon);
$html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
}
//show image
$contentimages = '';
$thiscourse = new course_in_list($course);
foreach ($thiscourse->get_course_overviewfiles() as $courseimage) {
$isimage = $courseimage->is_valid_image();
$url = file_encode_url("$CFG->wwwroot/pluginfile.php",
'/'. $courseimage->get_contextid(). '/'. $courseimage->get_component(). '/'.
$courseimage->get_filearea(). $courseimage->get_filepath(). $courseimage->get_filename() );
if ($isimage) {
$contentimages .= html_writer::tag('div',
html_writer::empty_tag('img', array('src' => $url)),
array('class' => 'courseimage'));
}
}
$html .= $contentimages;
$html .= html_writer::end_tag('div');
$html .= $this->output->box_end();
}
// Wrap course list in a div and return.
return html_writer::tag('div', $html, array('class' => 'course_list'));
}
}
include_once($CFG->dirroot . "/blocks/navigation/renderer.php");
class theme_skillbox_block_navigation_renderer extends block_navigation_renderer {
// public function navigation_node($items, $attrs=array(), $expansionlimit=null, array $options = array(), $depth=1) {
// global $USER, $CFG;
//
// // remove the 'Site home' link from the list
// foreach ($items as $item) {
//
// if ($item->type == navigation_node::TYPE_SETTING && $item->title == get_string('home')) {
// $item->remove();
// }
// }
//
// return parent::navigation_node($items, $attrs, $expansionlimit, $options, $depth);
// }
public function navigation_tree(global_navigation $navigation, $expansionlimit, array $options = array()) {
$homenode=$navigation->find('home', navigation_node::TYPE_SETTING);
//$myhomenode=$navigation->find('myhome', navigation_node::TYPE_SETTING);
if($homenode){
$homenode->remove();
$navigation=$homenode->parent;
}
//if($myhomenode){
// $myhomenode->remove();
// $navigation=$myhomenode->parent;
// }
return parent::navigation_tree($navigation, $expansionlimit,$options);
}
}