/** * Print a standard lesson heading. * * This will also print up to three * buttons in the breadcrumb, lesson heading * lesson tabs, lesson notifications and perhaps * a popup with a media file. * * @return void **/ function print_header($title = '', $morenavlinks = array()) { global $CFG; $this->init_full(); /// Variable setup/check $context = get_context_instance(CONTEXT_MODULE, $this->modulerecord->id); $activityname = format_string($this->activityrecord->name); if ($this->lessonpageid === NULL) { error('Programmer error: must set the lesson page ID'); } if (empty($title)) { $title = "{$this->courserecord->shortname}: {$activityname}"; } /// Build the buttons if (has_capability('mod/lesson:edit', $context)) { $buttons = '<span class="edit_buttons">' . update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'lesson')); if (!empty($this->lessonpageid) and $this->lessonpageid != LESSON_EOL) { $buttons .= '<form ' . $CFG->frametarget . ' method="get" action="' . $CFG->wwwroot . '/mod/lesson/lesson.php">' . '<input type="hidden" name="id" value="' . $this->modulerecord->id . '" />' . '<input type="hidden" name="action" value="editpage" />' . '<input type="hidden" name="redirect" value="navigation" />' . '<input type="hidden" name="pageid" value="' . $this->lessonpageid . '" />' . '<input type="submit" value="' . get_string('editpagecontent', 'lesson') . '" />' . '</form>'; if (!empty($CFG->showblocksonmodpages) and $this->user_allowed_editing()) { if ($this->user_is_editing()) { $onoff = 'off'; } else { $onoff = 'on'; } $buttons .= '<form ' . $CFG->frametarget . ' method="get" action="' . $CFG->wwwroot . '/mod/lesson/view.php">' . '<input type="hidden" name="id" value="' . $this->modulerecord->id . '" />' . '<input type="hidden" name="pageid" value="' . $this->lessonpageid . '" />' . '<input type="hidden" name="edit" value="' . $onoff . '" />' . '<input type="submit" value="' . get_string("blocksedit{$onoff}") . '" /> </form>'; } } $buttons .= '</span>'; } else { $buttons = ' '; } /// Build the meta /// Currently broken because the $meta is printed before the JavaScript is printed // if (!optional_param('pageid', 0, PARAM_INT) and !empty($this->activityrecord->mediafile)) { // // open our pop-up // $url = '/mod/lesson/mediafile.php?id='.$this->modulerecord->id; // $name = 'lessonmediafile'; // $options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. $this->activityrecord->mediawidth .',height='. $this->activityrecord->mediaheight; // $meta = "\n<script type=\"text/javascript\">"; // $meta .= "\n<!--\n"; // $meta .= " openpopup('$url', '$name', '$options', 0);"; // $meta .= "\n// -->\n"; // $meta .= '</script>'; // } else { $meta = ''; // } $navigation = build_navigation($morenavlinks, $this->modulerecord); print_header($title, $this->courserecord->fullname, $navigation, '', $meta, true, $buttons, user_login_string($this->courserecord) . '<hr style="width:95%">' . navmenu($this->courserecord, $this->modulerecord)); if (has_capability('mod/lesson:manage', $context)) { print_heading_with_help($activityname, 'overview', 'lesson'); // Rename our objects for the sake of the tab code list($cm, $course, $lesson, $currenttab) = array(&$this->modulerecord, &$this->courserecord, &$this->activityrecord, 'view'); include $CFG->dirroot . '/mod/lesson/tabs.php'; } else { print_heading($activityname); } lesson_print_messages(); }
/** * Print the standard header for lesson module * * This will also print up to three * buttons in the breadcrumb, lesson heading * lesson tabs, lesson notifications and perhaps * a popup with a media file. * * @param object $cm Course module record object * @param object $course Course record object * @param object $lesson Lesson record object * @param string $currenttab Current tab for the lesson tabs * @param boolean $extraeditbuttons Show the extra edit buttons next to the 'Update this lesson' button. * @param integer $lessonpageid if $extraeditbuttons is true then you must pass the page id here. **/ function lesson_print_header($cm, $course, $lesson, $currenttab = '', $extraeditbuttons = false, $lessonpageid = NULL) { global $CFG, $PAGE, $OUTPUT; $activityname = format_string($lesson->name, true, $course->id); if (empty($title)) { $title = "{$course->shortname}: {$activityname}"; } /// Build the buttons $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (has_capability('mod/lesson:edit', $context)) { $buttons = update_module_button($cm->id, $course->id, get_string('modulename', 'lesson')); if ($extraeditbuttons) { if ($lessonpageid === NULL) { print_error('invalidpageid', 'lesson'); } if (!empty($lessonpageid) and $lessonpageid != LESSON_EOL) { $buttons .= '<form ' . $CFG->frametarget . ' method="get" action="' . $CFG->wwwroot . '/mod/lesson/lesson.php">' . '<input type="hidden" name="id" value="' . $cm->id . '" />' . '<input type="hidden" name="action" value="editpage" />' . '<input type="hidden" name="redirect" value="navigation" />' . '<input type="hidden" name="pageid" value="' . $lessonpageid . '" />' . '<input type="submit" value="' . get_string('editpagecontent', 'lesson') . '" />' . '</form>'; } $buttons = '<span class="edit_buttons">' . $buttons . '</span>'; } } else { $buttons = ' '; } /// Header setup $navigation = build_navigation(array(), $cm); print_header($title, $course->fullname, $navigation, '', '', true, $buttons, navmenu($course, $cm)); if (has_capability('mod/lesson:manage', $context)) { print_heading_with_help($activityname, 'overview', 'lesson'); if (!empty($currenttab)) { include $CFG->dirroot . '/mod/lesson/tabs.php'; } } else { echo $OUTPUT->heading($activityname); } lesson_print_messages(); }
/** * Print the standard header for lesson module * * @uses $CFG * @uses $USER * @param object $cm Course module record object * @param object $course Couse record object * @param object $lesson Lesson module record object * @param string $currenttab Current tab for the lesson tabs * @return boolean **/ function lesson_print_header($cm, $course, $lesson, $currenttab = '') { global $CFG, $USER; $strlesson = get_string('modulename', 'lesson'); $strname = format_string($lesson->name, true, $course->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (has_capability('mod/lesson:edit', $context)) { $button = update_module_button($cm->id, $course->id, $strlesson); } else { $button = ''; } /// Header setup $navigation = build_navigation('', $cm); /// Print header, heading, tabs and messages print_header("{$course->shortname}: {$strname}", $course->fullname, $navigation, '', '', true, $button, user_login_string($course) . '<hr style="width:95%">' . navmenu($course, $cm)); if (has_capability('mod/lesson:manage', $context)) { print_heading_with_help($strname, "overview", "lesson"); if (!empty($currenttab)) { include $CFG->dirroot . '/mod/lesson/tabs.php'; } } else { print_heading($strname); } lesson_print_messages(); return true; }
/** * Print the standard header for lesson module * * This will also print up to three * buttons in the breadcrumb, lesson heading * lesson tabs, lesson notifications and perhaps * a popup with a media file. * * @param object $cm Course module record object * @param object $course Course record object * @param object $lesson Lesson record object * @param string $currenttab Current tab for the lesson tabs * @param boolean $extraeditbuttons Show the extra edit buttons next to the 'Update this lesson' button. * @param integer $lessonpageid if $extraeditbuttons is true then you must pass the page id here. **/ function lesson_print_header($cm, $course, $lesson, $currenttab = '', $extraeditbuttons = false, $lessonpageid = NULL) { global $CFG, $PAGE; // Note: MDL-19010 there will be further changes to printing header and blocks. // The code will be much nicer than this eventually. $context = get_context_instance(CONTEXT_MODULE, $cm->id); $activityname = format_string($lesson->name, true, $course->id); $strlesson = get_string('modulename', 'lesson'); if (empty($title)) { $title = "{$course->shortname}: {$activityname}"; } /// Build the buttons if (has_capability('mod/lesson:edit', $context)) { $buttons = update_module_button($cm->id, $course->id, $strlesson); if ($extraeditbuttons) { if ($lessonpageid === NULL) { print_error('invalidpageid', 'lesson'); } if (!empty($lessonpageid) and $lessonpageid != LESSON_EOL) { $buttons .= '<form ' . $CFG->frametarget . ' method="get" action="' . $CFG->wwwroot . '/mod/lesson/lesson.php">' . '<input type="hidden" name="id" value="' . $cm->id . '" />' . '<input type="hidden" name="action" value="editpage" />' . '<input type="hidden" name="redirect" value="navigation" />' . '<input type="hidden" name="pageid" value="' . $lessonpageid . '" />' . '<input type="submit" value="' . get_string('editpagecontent', 'lesson') . '" />' . '</form>'; if (!empty($CFG->showblocksonmodpages) and $PAGE->user_allowed_editing()) { if ($PAGE->user_is_editing()) { $onoff = 'off'; } else { $onoff = 'on'; } $buttons .= '<form ' . $CFG->frametarget . ' method="get" action="' . $CFG->wwwroot . '/mod/lesson/view.php">' . '<input type="hidden" name="id" value="' . $cm->id . '" />' . '<input type="hidden" name="pageid" value="' . $lessonpageid . '" />' . '<input type="hidden" name="edit" value="' . $onoff . '" />' . '<input type="submit" value="' . get_string("blocksedit{$onoff}") . '" /> </form>'; } } $buttons = '<span class="edit_buttons">' . $buttons . '</span>'; } } else { $buttons = ' '; } /// Header setup $navigation = build_navigation(array(), $cm); print_header($title, $course->fullname, $navigation, '', '', true, $buttons, navmenu($course, $cm)); if (has_capability('mod/lesson:manage', $context)) { print_heading_with_help($activityname, 'overview', 'lesson'); if (!empty($currenttab)) { include $CFG->dirroot . '/mod/lesson/tabs.php'; } } else { print_heading($activityname); } lesson_print_messages(); }
/** * Print the standard header for lesson module * * @uses $CFG * @uses $USER * @param object $cm Course module record object * @param object $course Couse record object * @param object $lesson Lesson module record object * @param string $currenttab Current tab for the lesson tabs * @return boolean **/ function lesson_print_header($cm, $course, $lesson, $currenttab = '') { global $CFG, $USER; $strlessons = get_string('modulenameplural', 'lesson'); $strlesson = get_string('modulename', 'lesson'); $strname = format_string($lesson->name, true, $course->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); // Changed the update_module_button and added another button when a teacher is checking the navigation of the lesson if (has_capability('mod/lesson:edit', $context)) { $button = '<span class="edit_buttons">'; $button .= update_module_button($cm->id, $course->id, $strlesson); if ($currenttab == 'view') { if (!($pageid = optional_param('pageid', 0, PARAM_INT))) { $pageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0); } if (!empty($pageid) and $pageid != LESSON_EOL) { $button .= '<form ' . $CFG->frametarget . ' method="get" action="' . $CFG->wwwroot . '/mod/lesson/lesson.php">' . '<div>' . '<input type="hidden" name="id" value="' . $cm->id . '" />' . '<input type="hidden" name="action" value="editpage" />' . '<input type="hidden" name="redirect" value="navigation" />' . '<input type="hidden" name="pageid" value="' . $pageid . '" />' . '<input type="submit" value="' . get_string('editpagecontent', 'lesson') . '" />' . '</div>' . '</form>'; } } $button .= '</span>'; } else { $button = ''; } if (!optional_param('pageid', 0, PARAM_INT) and !empty($lesson->mediafile)) { // open our pop-up $url = '/mod/lesson/mediafile.php?id=' . $cm->id; $name = 'lessonmediafile'; $options = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width=' . $lesson->mediawidth . ',height=' . $lesson->mediaheight; $meta = "\n<script type=\"text/javascript\">"; $meta .= "\n<!--\n"; $meta .= " openpopup('{$url}', '{$name}', '{$options}', 0);"; $meta .= "\n-->\n"; $meta .= '</script>'; } else { $meta = ''; } /// Header setup $navigation = array(); if ($course->id != SITEID) { $navigation[$course->shortname] = "{$CFG->wwwroot}/course/view.php?id={$course->id}"; } $navigation[$strlessons] = "{$CFG->wwwroot}/mod/lesson/index.php?id={$course->id}"; $navigation[$strname] = ''; $urls = array(); foreach ($navigation as $text => $href) { if (empty($href)) { $urls[] = $text; } else { $urls[] = '<a href="' . $href . '">' . $text . '</a>'; } } $breadcrumb = implode(' -> ', $urls); /// Print header, heading, tabs and messages print_header("{$course->shortname}: {$strname}", $course->fullname, $breadcrumb, '', $meta, true, $button, navmenu($course, $cm)); if (has_capability('mod/lesson:manage', $context)) { print_heading_with_help($strname, "overview", "lesson"); } else { print_heading($strname); } if (!empty($currenttab) and has_capability('mod/lesson:manage', $context)) { include $CFG->dirroot . '/mod/lesson/tabs.php'; } lesson_print_messages(); return true; }
/** * Print the standard header for lesson module * * @uses $CFG * @uses $USER * @param object $cm Course module record object * @param object $course Couse record object * @param object $lesson Lesson module record object * @param string $currenttab Current tab for the lesson tabs * @return boolean **/ function lesson_print_header($cm, $course, $lesson, $currenttab = '') { global $CFG, $USER; $strlessons = get_string('modulenameplural', 'lesson'); $strlesson = get_string('modulename', 'lesson'); $strname = format_string($lesson->name, true); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (has_capability('mod/lesson:edit', $context)) { $button = update_module_button($cm->id, $course->id, $strlesson); } else { $button = ''; } /// Header setup $navlinks = array(); $navlinks[] = array('name' => $strlessons, 'link' => "{$CFG->wwwroot}/mod/lesson/index.php?id={$course->id}", 'type' => 'activity'); $navlinks[] = array('name' => $strname, 'link' => '', 'type' => 'activityinstance'); $navigation = build_navigation($navlinks); /// Print header, heading, tabs and messages print_header("{$course->shortname}: {$strname}", $course->fullname, $navigation, '', '', true, $button, navmenu($course, $cm)); if (has_capability('mod/lesson:manage', $context)) { print_heading_with_help(format_string($lesson->name, true), "overview", "lesson"); if (!empty($currenttab)) { include $CFG->dirroot . '/mod/lesson/tabs.php'; } } else { print_heading(format_string($lesson->name, true)); } lesson_print_messages(); return true; }