[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/imscp/ -> index.php (source)

   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   * List of file imscps in course
  20   *
  21   * @package mod_imscp
  22   * @copyright  2009 onwards Martin Dougiamas (http://dougiamas.com)
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  require('../../config.php');
  27  
  28  $id = required_param('id', PARAM_INT); // course id
  29  
  30  $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
  31  
  32  require_course_login($course, true);
  33  $PAGE->set_pagelayout('incourse');
  34  
  35  $params = array(
  36      'context' => context_course::instance($course->id)
  37  );
  38  $event = \mod_imscp\event\course_module_instance_list_viewed::create($params);
  39  $event->trigger();
  40  
  41  $strimscp       = get_string('modulename', 'imscp');
  42  $strimscps      = get_string('modulenameplural', 'imscp');
  43  $strname         = get_string('name');
  44  $strintro        = get_string('moduleintro');
  45  $strlastmodified = get_string('lastmodified');
  46  
  47  $PAGE->set_url('/mod/imscp/index.php', array('id' => $course->id));
  48  $PAGE->set_title($course->shortname.': '.$strimscps);
  49  $PAGE->set_heading($course->fullname);
  50  $PAGE->navbar->add($strimscps);
  51  echo $OUTPUT->header();
  52  echo $OUTPUT->heading($strimscps);
  53  
  54  if (!$imscps = get_all_instances_in_course('imscp', $course)) {
  55      notice(get_string('thereareno', 'moodle', $strimscps), "$CFG->wwwroot/course/view.php?id=$course->id");
  56      exit;
  57  }
  58  
  59  $usesections = course_format_uses_sections($course->format);
  60  
  61  $table = new html_table();
  62  $table->attributes['class'] = 'generaltable mod_index';
  63  
  64  if ($usesections) {
  65      $strsectionname = get_string('sectionname', 'format_'.$course->format);
  66      $table->head  = array ($strsectionname, $strname, $strintro);
  67      $table->align = array ('center', 'left', 'left');
  68  } else {
  69      $table->head  = array ($strlastmodified, $strname, $strintro);
  70      $table->align = array ('left', 'left', 'left');
  71  }
  72  
  73  $modinfo = get_fast_modinfo($course);
  74  $currentsection = '';
  75  foreach ($imscps as $imscp) {
  76      $cm = $modinfo->cms[$imscp->coursemodule];
  77      if ($usesections) {
  78          $printsection = '';
  79          if ($imscp->section !== $currentsection) {
  80              if ($imscp->section) {
  81                  $printsection = get_section_name($course, $imscp->section);
  82              }
  83              if ($currentsection !== '') {
  84                  $table->data[] = 'hr';
  85              }
  86              $currentsection = $imscp->section;
  87          }
  88      } else {
  89          $printsection = '<span class="smallinfo">'.userdate($imscp->timemodified)."</span>";
  90      }
  91  
  92      $class = $imscp->visible ? '' : 'class="dimmed"'; // hidden modules are dimmed
  93      $table->data[] = array (
  94          $printsection,
  95          "<a $class href=\"view.php?id=$cm->id\">".format_string($imscp->name)."</a>",
  96          format_module_intro('imscp', $imscp, $cm->id));
  97  }
  98  
  99  echo html_writer::table($table);
 100  
 101  echo $OUTPUT->footer();


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1