Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
/mod/wiki/ -> index.php (source)

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   1  <?php
   2  
   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.
  14  //
  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/>.
  17  
  18  /**
  19   * This page lists all the instances of wiki in a particular course
  20   *
  21   * @package mod_wiki
  22   * @copyright 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
  23   * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
  24   *
  25   * @author Jordi Piguillem
  26   * @author Marc Alier
  27   * @author David Jimenez
  28   * @author Josep Arus
  29   * @author Kenneth Riba
  30   *
  31   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  32   */
  33  
  34  require_once('../../config.php');
  35  require_once ('lib.php');
  36  
  37  $id = required_param('id', PARAM_INT); // course
  38  $PAGE->set_url('/mod/wiki/index.php', array('id' => $id));
  39  
  40  if (!$course = $DB->get_record('course', array('id' => $id))) {
  41      throw new \moodle_exception('invalidcourseid');
  42  }
  43  
  44  require_login($course, true);
  45  $PAGE->set_pagelayout('incourse');
  46  $context = context_course::instance($course->id);
  47  
  48  $event = \mod_wiki\event\course_module_instance_list_viewed::create(array('context' => $context));
  49  $event->add_record_snapshot('course', $course);
  50  $event->trigger();
  51  
  52  /// Get all required stringswiki
  53  $strwikis = get_string("modulenameplural", "wiki");
  54  $strwiki = get_string("modulename", "wiki");
  55  
  56  /// Print the header
  57  $PAGE->navbar->add($strwikis, "index.php?id=$course->id");
  58  $PAGE->set_title($strwikis);
  59  $PAGE->set_heading($course->fullname);
  60  echo $OUTPUT->header();
  61  echo $OUTPUT->heading($strwikis);
  62  
  63  /// Get all the appropriate data
  64  if (!$wikis = get_all_instances_in_course("wiki", $course)) {
  65      notice("There are no wikis", "../../course/view.php?id=$course->id");
  66      die;
  67  }
  68  
  69  $usesections = course_format_uses_sections($course->format);
  70  
  71  /// Print the list of instances (your module will probably extend this)
  72  
  73  $timenow = time();
  74  $strname = get_string("name");
  75  $table = new html_table();
  76  
  77  if ($usesections) {
  78      $strsectionname = get_string('sectionname', 'format_' . $course->format);
  79      $table->head = array($strsectionname, $strname);
  80  } else {
  81      $table->head = array($strname);
  82  }
  83  
  84  foreach ($wikis as $wiki) {
  85      $linkcss = null;
  86      if (!$wiki->visible) {
  87          $linkcss = array('class' => 'dimmed');
  88      }
  89      $link = html_writer::link(new moodle_url('/mod/wiki/view.php', array('id' => $wiki->coursemodule)), $wiki->name, $linkcss);
  90  
  91      if ($usesections) {
  92          $table->data[] = array(get_section_name($course, $wiki->section), $link);
  93      } else {
  94          $table->data[] = array($link);
  95      }
  96  }
  97  
  98  echo html_writer::table($table);
  99  
 100  /// Finish the page
 101  echo $OUTPUT->footer();