| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: pagelib.php,v 1.5.2.4 2008/01/18 14:37:29 nicolasconnault Exp $ 2 /** 3 * Page class for lesson 4 * 5 * @author Mark Nielsen 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 8 * @package lesson 9 **/ 10 11 require_once($CFG->libdir.'/pagelib.php'); 12 require_once($CFG->dirroot.'/course/lib.php'); // needed for some blocks 13 14 /** 15 * Define the page types 16 * 17 **/ 18 define('PAGE_LESSON_VIEW', 'mod-lesson-view'); 19 20 /** 21 * Map the classes to the page types 22 * 23 **/ 24 page_map_class(PAGE_LESSON_VIEW, 'page_lesson'); 25 26 /** 27 * Add the page types defined in this file 28 * 29 **/ 30 $DEFINEDPAGES = array(PAGE_LESSON_VIEW); 31 32 /** 33 * Class that models the behavior of a lesson 34 * 35 * @author Mark Nielsen (lesson extention only) 36 * @package lesson 37 **/ 38 class page_lesson extends page_generic_activity { 39 40 /** 41 * Module name 42 * 43 * @var string 44 **/ 45 var $activityname = 'lesson'; 46 /** 47 * Current lesson page ID 48 * 49 * @var string 50 **/ 51 var $lessonpageid = NULL; 52 53 /** 54 * Print a standard lesson heading. 55 * 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. 60 * 61 * @return void 62 **/ 63 function print_header($title = '', $morenavlinks = array()) { 64 global $CFG; 65 66 $this->init_full(); 67 68 /// Variable setup/check 69 $context = get_context_instance(CONTEXT_MODULE, $this->modulerecord->id); 70 $activityname = format_string($this->activityrecord->name); 71 72 if ($this->lessonpageid === NULL) { 73 error('Programmer error: must set the lesson page ID'); 74 } 75 if (empty($title)) { 76 $title = "{$this->courserecord->shortname}: $activityname"; 77 } 78 79 /// Build the buttons 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')); 82 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').'" />'. 90 '</form>'; 91 92 if (!empty($CFG->showblocksonmodpages) and $this->user_allowed_editing()) { 93 if ($this->user_is_editing()) { 94 $onoff = 'off'; 95 } else { 96 $onoff = 'on'; 97 } 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").'" /> 103 </form>'; 104 } 105 } 106 $buttons .= '</span>'; 107 } else { 108 $buttons = ' '; 109 } 110 111 /// Build the meta 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>'; 123 // } else { 124 $meta = ''; 125 // } 126 127 $navigation = build_navigation($morenavlinks, $this->modulerecord); 128 print_header($title, $this->courserecord->fullname, $navigation, '', $meta, true, $buttons, navmenu($this->courserecord, $this->modulerecord)); 129 130 if (has_capability('mod/lesson:manage', $context)) { 131 print_heading_with_help($activityname, 'overview', 'lesson'); 132 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'); 136 } else { 137 print_heading($activityname); 138 } 139 140 lesson_print_messages(); 141 } 142 143 function get_type() { 144 return PAGE_LESSON_VIEW; 145 } 146 147 function blocks_get_positions() { 148 return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT); 149 } 150 151 function blocks_default_position() { 152 return BLOCK_POS_RIGHT; 153 } 154 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; 160 } 161 return $instance->position; 162 } 163 164 /** 165 * Needed to add the ID of the current lesson page 166 * 167 * @return array 168 **/ 169 function url_get_parameters() { 170 $this->init_full(); 171 return array('id' => $this->modulerecord->id, 'pageid' => $this->lessonpageid);; 172 } 173 174 /** 175 * Set the current lesson page ID 176 * 177 * @return void 178 **/ 179 function set_lessonpageid($pageid) { 180 $this->lessonpageid = $pageid; 181 } 182 } 183 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |