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 * This file contains the Activity modules block.
20 * @package block_activity_modules
21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
26 require_once($CFG->libdir
. '/filelib.php');
28 class block_activity_modules
extends block_list
{
30 $this->title
= get_string('pluginname', 'block_activity_modules');
33 function get_content() {
34 global $CFG, $DB, $OUTPUT;
36 if($this->content
!== NULL) {
37 return $this->content
;
40 $this->content
= new stdClass
;
41 $this->content
->items
= array();
42 $this->content
->icons
= array();
43 $this->content
->footer
= '';
45 $course = $this->page
->course
;
47 require_once($CFG->dirroot
.'/course/lib.php');
49 $modinfo = get_fast_modinfo($course);
50 $modfullnames = array();
52 $archetypes = array();
54 foreach($modinfo->cms
as $cm) {
55 // Exclude activities that aren't visible or have no view link (e.g. label). Account for folder being displayed inline.
56 if (!$cm->uservisible ||
(!$cm->has_view() && strcmp($cm->modname
, 'folder') !== 0)) {
59 if (array_key_exists($cm->modname
, $modfullnames)) {
62 if (!array_key_exists($cm->modname
, $archetypes)) {
63 $archetypes[$cm->modname
] = plugin_supports('mod', $cm->modname
, FEATURE_MOD_ARCHETYPE
, MOD_ARCHETYPE_OTHER
);
65 if ($archetypes[$cm->modname
] == MOD_ARCHETYPE_RESOURCE
) {
66 if (!array_key_exists('resources', $modfullnames)) {
67 $modfullnames['resources'] = get_string('resources');
70 $modfullnames[$cm->modname
] = $cm->modplural
;
74 core_collator
::asort($modfullnames);
76 foreach ($modfullnames as $modname => $modfullname) {
77 if ($modname === 'resources') {
78 $icon = $OUTPUT->pix_icon('icon', '', 'mod_page', array('class' => 'icon'));
79 $this->content
->items
[] = '<a href="'.$CFG->wwwroot
.'/course/resources.php?id='.$course->id
.'">'.$icon.$modfullname.'</a>';
81 $icon = $OUTPUT->image_icon('icon', get_string('pluginname', $modname), $modname);
82 $this->content
->items
[] = '<a href="'.$CFG->wwwroot
.'/mod/'.$modname.'/index.php?id='.$course->id
.'">'.$icon.$modfullname.'</a>';
86 return $this->content
;
90 * Returns the role that best describes this blocks contents.
92 * This returns 'navigation' as the blocks contents is a list of links to activities and resources.
94 * @return string 'navigation'
96 public function get_aria_role() {
100 function applicable_formats() {
101 return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false,