1
<?php // $Id: pagelib.php,v 1.5.2.4 2008/01/18 14:37:29 nicolasconnault Exp $
3
* Page class for lesson
6
* @version $Id: pagelib.php,v 1.5.2.4 2008/01/18 14:37:29 nicolasconnault Exp $
7
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
11
require_once($CFG->libdir.'/pagelib.php');
12
require_once($CFG->dirroot.'/course/lib.php'); // needed for some blocks
15
* Define the page types
18
define('PAGE_LESSON_VIEW', 'mod-lesson-view');
21
* Map the classes to the page types
24
page_map_class(PAGE_LESSON_VIEW, 'page_lesson');
27
* Add the page types defined in this file
30
$DEFINEDPAGES = array(PAGE_LESSON_VIEW);
33
* Class that models the behavior of a lesson
35
* @author Mark Nielsen (lesson extention only)
38
class page_lesson extends page_generic_activity {
45
var $activityname = 'lesson';
47
* Current lesson page ID
51
var $lessonpageid = NULL;
54
* Print a standard lesson heading.
56
* This will also print up to three
57
* buttons in the breadcrumb, lesson heading
58
* lesson tabs, lesson notifications and perhaps
59
* a popup with a media file.
63
function print_header($title = '', $morenavlinks = array()) {
68
/// Variable setup/check
69
$context = get_context_instance(CONTEXT_MODULE, $this->modulerecord->id);
70
$activityname = format_string($this->activityrecord->name);
72
if ($this->lessonpageid === NULL) {
73
error('Programmer error: must set the lesson page ID');
76
$title = "{$this->courserecord->shortname}: $activityname";
80
if (has_capability('mod/lesson:edit', $context)) {
81
$buttons = '<span class="edit_buttons">'.update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'lesson'));
83
if (!empty($this->lessonpageid) and $this->lessonpageid != LESSON_EOL) {
84
$buttons .= '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/mod/lesson/lesson.php">'.
85
'<input type="hidden" name="id" value="'.$this->modulerecord->id.'" />'.
86
'<input type="hidden" name="action" value="editpage" />'.
87
'<input type="hidden" name="redirect" value="navigation" />'.
88
'<input type="hidden" name="pageid" value="'.$this->lessonpageid.'" />'.
89
'<input type="submit" value="'.get_string('editpagecontent', 'lesson').'" />'.
92
if (!empty($CFG->showblocksonmodpages) and $this->user_allowed_editing()) {
93
if ($this->user_is_editing()) {
98
$buttons .= '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/mod/lesson/view.php">'.
99
'<input type="hidden" name="id" value="'.$this->modulerecord->id.'" />'.
100
'<input type="hidden" name="pageid" value="'.$this->lessonpageid.'" />'.
101
'<input type="hidden" name="edit" value="'.$onoff.'" />'.
102
'<input type="submit" value="'.get_string("blocksedit$onoff").'" />
106
$buttons .= '</span>';
112
/// Currently broken because the $meta is printed before the JavaScript is printed
113
// if (!optional_param('pageid', 0, PARAM_INT) and !empty($this->activityrecord->mediafile)) {
114
// // open our pop-up
115
// $url = '/mod/lesson/mediafile.php?id='.$this->modulerecord->id;
116
// $name = 'lessonmediafile';
117
// $options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. $this->activityrecord->mediawidth .',height='. $this->activityrecord->mediaheight;
118
// $meta = "\n<script type=\"text/javascript\">";
119
// $meta .= "\n<!--\n";
120
// $meta .= " openpopup('$url', '$name', '$options', 0);";
121
// $meta .= "\n// -->\n";
122
// $meta .= '</script>';
127
$navigation = build_navigation($morenavlinks, $this->modulerecord);
128
print_header($title, $this->courserecord->fullname, $navigation, '', $meta, true, $buttons, navmenu($this->courserecord, $this->modulerecord));
130
if (has_capability('mod/lesson:manage', $context)) {
131
print_heading_with_help($activityname, 'overview', 'lesson');
133
// Rename our objects for the sake of the tab code
134
list($cm, $course, $lesson, $currenttab) = array(&$this->modulerecord, &$this->courserecord, &$this->activityrecord, 'view');
135
include($CFG->dirroot.'/mod/lesson/tabs.php');
137
print_heading($activityname);
140
lesson_print_messages();
143
function get_type() {
144
return PAGE_LESSON_VIEW;
147
function blocks_get_positions() {
148
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
151
function blocks_default_position() {
152
return BLOCK_POS_RIGHT;
155
function blocks_move_position(&$instance, $move) {
156
if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
157
return BLOCK_POS_RIGHT;
158
} else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
159
return BLOCK_POS_LEFT;
161
return $instance->position;
165
* Needed to add the ID of the current lesson page
169
function url_get_parameters() {
171
return array('id' => $this->modulerecord->id, 'pageid' => $this->lessonpageid);;
175
* Set the current lesson page ID
179
function set_lessonpageid($pageid) {
180
$this->lessonpageid = $pageid;