Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/page/view.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 require_once($CFG->dirroot.'/mod/page/locallib.php');
00029 require_once($CFG->libdir.'/completionlib.php');
00030 
00031 $id      = optional_param('id', 0, PARAM_INT); // Course Module ID
00032 $p       = optional_param('p', 0, PARAM_INT);  // Page instance ID
00033 $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
00034 
00035 if ($p) {
00036     if (!$page = $DB->get_record('page', array('id'=>$p))) {
00037         print_error('invalidaccessparameter');
00038     }
00039     $cm = get_coursemodule_from_instance('page', $page->id, $page->course, false, MUST_EXIST);
00040 
00041 } else {
00042     if (!$cm = get_coursemodule_from_id('page', $id)) {
00043         print_error('invalidcoursemodule');
00044     }
00045     $page = $DB->get_record('page', array('id'=>$cm->instance), '*', MUST_EXIST);
00046 }
00047 
00048 $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
00049 
00050 require_course_login($course, true, $cm);
00051 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00052 require_capability('mod/page:view', $context);
00053 
00054 add_to_log($course->id, 'page', 'view', 'view.php?id='.$cm->id, $page->id, $cm->id);
00055 
00056 // Update 'viewed' state if required by completion system
00057 require_once($CFG->libdir . '/completionlib.php');
00058 $completion = new completion_info($course);
00059 $completion->set_module_viewed($cm);
00060 
00061 $PAGE->set_url('/mod/page/view.php', array('id' => $cm->id));
00062 
00063 $options = empty($page->displayoptions) ? array() : unserialize($page->displayoptions);
00064 
00065 if ($inpopup and $page->display == RESOURCELIB_DISPLAY_POPUP) {
00066     $PAGE->set_pagelayout('popup');
00067     $PAGE->set_title($course->shortname.': '.$page->name);
00068     if (!empty($options['printheading'])) {
00069         $PAGE->set_heading($page->name);
00070     } else {
00071         $PAGE->set_heading('');
00072     }
00073     echo $OUTPUT->header();
00074 
00075 } else {
00076     $PAGE->set_title($course->shortname.': '.$page->name);
00077     $PAGE->set_heading($course->fullname);
00078     $PAGE->set_activity_record($page);
00079     echo $OUTPUT->header();
00080 
00081     if (!empty($options['printheading'])) {
00082         echo $OUTPUT->heading(format_string($page->name), 2, 'main', 'pageheading');
00083     }
00084 }
00085 
00086 if (!empty($options['printintro'])) {
00087     if (trim(strip_tags($page->intro))) {
00088         echo $OUTPUT->box_start('mod_introbox', 'pageintro');
00089         echo format_module_intro('page', $page, $cm->id);
00090         echo $OUTPUT->box_end();
00091     }
00092 }
00093 
00094 $content = file_rewrite_pluginfile_urls($page->content, 'pluginfile.php', $context->id, 'mod_page', 'content', $page->revision);
00095 $formatoptions = new stdClass;
00096 $formatoptions->noclean = true;
00097 $formatoptions->overflowdiv = true;
00098 $formatoptions->context = $context;
00099 $content = format_text($content, $page->contentformat, $formatoptions);
00100 echo $OUTPUT->box($content, "generalbox center clearfix");
00101 
00102 $strlastmodified = get_string("lastmodified");
00103 echo "<div class=\"modified\">$strlastmodified: ".userdate($page->timemodified)."</div>";
00104 
00105 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations