**/
confirm_sesskey();
- require_once($CFG->dirroot.'/mod/lesson/pagelib.php');
-
// left menu code
// check to see if the user can see the left menu
if (!has_capability('mod/lesson:manage', $context)) {
lesson_set_message('('.get_string("maximumnumberofattemptsreached", "lesson").')');
}
- $PAGE = page_create_object('mod-lesson-view', $lesson->id);
$PAGE->set_url('mod/lesson/view.php', array('id' => $cm->id, 'pageid' => $page->id));
- $PAGE->set_lessonpageid($page->id);
+ $PAGE->set_subpage($page->id);
$pageblocks = blocks_setup($PAGE);
$leftcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
$rightcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
/// Print the header, heading and tabs
- $PAGE->print_header();
+ lesson_print_header($cm, $course, $lesson, 'view', true, $page->id);
include(dirname(__FILE__).'/continue.html');
?>
delete_event($event->id);
}
}
- $pagetypes = page_import_types('mod/lesson/');
- foreach ($pagetypes as $pagetype) {
- if (!blocks_delete_all_on_page($pagetype, $lesson->id)) {
- $result = false;
- }
- }
lesson_grade_item_delete($lesson);
/**
* Print the standard header for lesson module
*
- * @uses $CFG
- * @uses $USER
+ * 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 Couse record object
- * @param object $lesson Lesson module record object
+ * @param object $course Course record object
+ * @param object $lesson Lesson record object
* @param string $currenttab Current tab for the lesson tabs
- * @return boolean
+ * @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 = '') {
- global $CFG, $USER;
+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');
- $strname = format_string($lesson->name, true, $course->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ if (empty($title)) {
+ $title = "{$course->shortname}: $activityname";
+ }
+/// Build the buttons
if (has_capability('mod/lesson:edit', $context)) {
- $button = update_module_button($cm->id, $course->id, $strlesson);
+ $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 {
- $button = '';
+ $buttons = ' ';
}
/// Header setup
- $navigation = build_navigation('', $cm);
-
-/// Print header, heading, tabs and messages
- print_header("$course->shortname: $strname", $course->fullname, $navigation,
- '', '', true, $button, navmenu($course, $cm));
+ $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($strname, "overview", "lesson");
+ print_heading_with_help($activityname, 'overview', 'lesson');
if (!empty($currenttab)) {
include($CFG->dirroot.'/mod/lesson/tabs.php');
}
} else {
- print_heading($strname);
+ print_heading($activityname);
}
lesson_print_messages();
-
- return true;
}
/**
**/
function lesson_print_page_actions($cmid, $page, $printmove, $printaddpage = false, $return = false) {
global $CFG;
-
+
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$actions = array();
-
+
if (has_capability('mod/lesson:edit', $context)) {
if ($printmove) {
$actions[] = "<a title=\"".get_string('move')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&action=move&pageid=$page->id\">
$actions[] = "<a title=\"".get_string('preview')."\" href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&pageid=$page->id\">
<img src=\"$CFG->pixpath/t/preview.gif\" class=\"iconsmall\" alt=\"".get_string('preview')."\" /></a>\n";
-
+
$actions[] = "<a title=\"".get_string('delete')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=confirmdelete&pageid=$page->id\">
<img src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"".get_string('delete')."\" /></a>\n";
-
+
if ($printaddpage) {
// Add page drop-down
$options = array();
$options['addpage'] = get_string('question', 'lesson');
// Base url
$common = "$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&pageid=$page->id&action=";
-
+
$actions[] = popup_form($common, $options, "addpage_$page->id", '', get_string('addpage', 'lesson').'...', '', '', true);
}
}
-
+
$actions = implode(' ', $actions);
-
+
if ($return) {
return $actions;
} else {
+++ /dev/null
-<?php // $Id$
-/**
- * Page class for lesson
- *
- * @author Mark Nielsen
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package lesson
- **/
-
-require_once($CFG->libdir.'/pagelib.php');
-require_once($CFG->dirroot.'/course/lib.php'); // needed for some blocks
-
-/**
- * Define the page types
- *
- **/
-define('PAGE_LESSON_VIEW', 'mod-lesson-view');
-
-/**
- * Map the classes to the page types
- *
- **/
-page_map_class(PAGE_LESSON_VIEW, 'page_lesson');
-
-/**
- * Add the page types defined in this file
- *
- **/
-$DEFINEDPAGES = array(PAGE_LESSON_VIEW);
-
-/**
- * Class that models the behavior of a lesson
- *
- * @author Mark Nielsen (lesson extention only)
- * @package lesson
- **/
-class page_lesson extends page_generic_activity {
-
- /**
- * Module name
- *
- * @var string
- **/
- var $activityname = 'lesson';
- /**
- * Current lesson page ID
- *
- * @var string
- **/
- var $lessonpageid = NULL;
-
- /**
- * 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) {
- print_error('invalidpageid', 'lesson');
- }
- if (empty($title)) {
- $title = "{$this->course->shortname}: $activityname";
- }
-
- /// Build the buttons
- if (has_capability('mod/lesson:edit', $context)) {
- $buttons = '<span class="edit_buttons">'.update_module_button($this->modulerecord->id, $this->course->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->course->fullname, $navigation, '', $meta, true, $buttons, navmenu($this->course, $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->course, &$this->activityrecord, 'view');
- include($CFG->dirroot.'/mod/lesson/tabs.php');
- } else {
- print_heading($activityname);
- }
-
- lesson_print_messages();
- }
-
- /**
- * Set the current lesson page ID
- *
- * @return void
- **/
- function set_lessonpageid($pageid) {
- $this->lessonpageid = $pageid;
- }
-}
-?>
* @package lesson
**/
- require_once('../../config.php');
+ require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot.'/mod/lesson/locallib.php');
require_once($CFG->dirroot.'/mod/lesson/lib.php');
- require_once($CFG->dirroot.'/mod/lesson/pagelib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
$pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID
}
}
- $PAGE = page_create_instance($lesson->id);
$PAGE->set_url('mod/lesson/view.php', array('id' => $cm->id, 'pageid' => $page->id));
- $PAGE->set_lessonpageid($page->id);
+ $PAGE->set_subpage($page->id);
$pageblocks = blocks_setup($PAGE);
$leftcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
}
/// Print the page header, heading and tabs
- $PAGE->print_header();
+ lesson_print_header($cm, $course, $lesson, 'view', 'true', $page->id);
if ($attemptflag) {
print_heading(get_string('attempt', 'lesson', $retries + 1));