Merge branch 'w27_MDL-39754_m23_evn26' of https://github.com/skodak/moodle into MOODL...
[moodle.git] / mod / wiki / index.php
blob3b566836739f8c870e1e7308c7270a49fa54d7cc
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * This page lists all the instances of wiki in a particular course
21 * @package mod-wiki-2.0
22 * @copyrigth 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
23 * @copyrigth 2009 Universitat Politecnica de Catalunya http://www.upc.edu
25 * @author Jordi Piguillem
26 * @author Marc Alier
27 * @author David Jimenez
28 * @author Josep Arus
29 * @author Kenneth Riba
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 require_once('../../config.php');
35 require_once('lib.php');
37 $id = required_param('id', PARAM_INT); // course
38 $PAGE->set_url('/mod/wiki/index.php', array('id' => $id));
40 if (!$course = $DB->get_record('course', array('id' => $id))) {
41 print_error('invalidcourseid');
44 require_login($course, true);
45 $PAGE->set_pagelayout('incourse');
46 $context = get_context_instance(CONTEXT_COURSE, $course->id);
48 add_to_log($course->id, 'wiki', 'view', "index.php?id=".$id, "");
50 /// Get all required stringswiki
51 $strwikis = get_string("modulenameplural", "wiki");
52 $strwiki = get_string("modulename", "wiki");
54 /// Print the header
55 $PAGE->navbar->add($strwikis, "index.php?id=$course->id");
56 $PAGE->set_title($strwikis);
57 $PAGE->set_heading($course->fullname);
58 echo $OUTPUT->header();
60 /// Get all the appropriate data
61 if (!$wikis = get_all_instances_in_course("wiki", $course)) {
62 notice("There are no wikis", "../../course/view.php?id=$course->id");
63 die;
66 $usesections = course_format_uses_sections($course->format);
67 if ($usesections) {
68 $sections = get_all_sections($course->id);
71 /// Print the list of instances (your module will probably extend this)
73 $timenow = time();
74 $strsectionname = get_string('sectionname', 'format_' . $course->format);
75 $strname = get_string("name");
76 $table = new html_table();
78 if ($usesections) {
79 $table->head = array($strsectionname, $strname);
80 } else {
81 $table->head = array($strname);
84 foreach ($wikis as $wiki) {
85 $linkcss = null;
86 if (!$wiki->visible) {
87 $linkcss = array('class' => 'dimmed');
89 $link = html_writer::link(new moodle_url('/mod/wiki/view.php', array('id' => $wiki->coursemodule)), $wiki->name, $linkcss);
91 if ($usesections) {
92 $table->data[] = array(get_section_name($course, $sections[$wiki->section]), $link);
93 } else {
94 $table->data[] = array($link);
98 echo html_writer::table($table);
100 /// Finish the page
101 echo $OUTPUT->footer();