Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/page/index.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00027 require('../../config.php');
00028 
00029 $id = required_param('id', PARAM_INT); // course id
00030 
00031 $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
00032 
00033 require_course_login($course, true);
00034 $PAGE->set_pagelayout('incourse');
00035 
00036 add_to_log($course->id, 'page', 'view all', "index.php?id=$course->id", '');
00037 
00038 $strpage         = get_string('modulename', 'page');
00039 $strpages        = get_string('modulenameplural', 'page');
00040 $strsectionname  = get_string('sectionname', 'format_'.$course->format);
00041 $strname         = get_string('name');
00042 $strintro        = get_string('moduleintro');
00043 $strlastmodified = get_string('lastmodified');
00044 
00045 $PAGE->set_url('/mod/page/index.php', array('id' => $course->id));
00046 $PAGE->set_title($course->shortname.': '.$strpages);
00047 $PAGE->set_heading($course->fullname);
00048 $PAGE->navbar->add($strpages);
00049 echo $OUTPUT->header();
00050 
00051 if (!$pages = get_all_instances_in_course('page', $course)) {
00052     notice(get_string('thereareno', 'moodle', $strpages), "$CFG->wwwroot/course/view.php?id=$course->id");
00053     exit;
00054 }
00055 
00056 $usesections = course_format_uses_sections($course->format);
00057 if ($usesections) {
00058     $sections = get_all_sections($course->id);
00059 }
00060 
00061 $table = new html_table();
00062 $table->attributes['class'] = 'generaltable mod_index';
00063 
00064 if ($usesections) {
00065     $table->head  = array ($strsectionname, $strname, $strintro);
00066     $table->align = array ('center', 'left', 'left');
00067 } else {
00068     $table->head  = array ($strlastmodified, $strname, $strintro);
00069     $table->align = array ('left', 'left', 'left');
00070 }
00071 
00072 $modinfo = get_fast_modinfo($course);
00073 $currentsection = '';
00074 foreach ($pages as $page) {
00075     $cm = $modinfo->cms[$page->coursemodule];
00076     if ($usesections) {
00077         $printsection = '';
00078         if ($page->section !== $currentsection) {
00079             if ($page->section) {
00080                 $printsection = get_section_name($course, $sections[$page->section]);
00081             }
00082             if ($currentsection !== '') {
00083                 $table->data[] = 'hr';
00084             }
00085             $currentsection = $page->section;
00086         }
00087     } else {
00088         $printsection = '<span class="smallinfo">'.userdate($page->timemodified)."</span>";
00089     }
00090 
00091     $class = $page->visible ? '' : 'class="dimmed"'; // hidden modules are dimmed
00092 
00093     $table->data[] = array (
00094         $printsection,
00095         "<a $class href=\"view.php?id=$cm->id\">".format_string($page->name)."</a>",
00096         format_module_intro('page', $page, $cm->id));
00097 }
00098 
00099 echo html_writer::table($table);
00100 
00101 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations