From: tjhunt Date: Wed, 6 May 2009 09:31:08 +0000 (+0000) Subject: pagelib: MDL-12212 eliminate data_lesson X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=40d6de1af6f1b3a60e46ec0d62355a43204be27e;p=moodle.git pagelib: MDL-12212 eliminate data_lesson --- diff --git a/mod/lesson/action/continue.php b/mod/lesson/action/continue.php index 098d65a6df..ee0b10e836 100644 --- a/mod/lesson/action/continue.php +++ b/mod/lesson/action/continue.php @@ -8,8 +8,6 @@ **/ 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)) { @@ -789,16 +787,15 @@ 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'); ?> diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index 138fe5bb34..83f6d16df3 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -109,12 +109,6 @@ function lesson_delete_instance($id) { 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); diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index c5b714d52a..cedadc60fe 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -215,48 +215,82 @@ if (!defined("LESSON_RESPONSE_EDITOR")) { /** * 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 .= '
frametarget.' method="get" action="'.$CFG->wwwroot.'/mod/lesson/lesson.php">'. + ''. + ''. + ''. + ''. + ''. + '
'; + + if (!empty($CFG->showblocksonmodpages) and $PAGE->user_allowed_editing()) { + if ($PAGE->user_is_editing()) { + $onoff = 'off'; + } else { + $onoff = 'on'; + } + $buttons .= '
frametarget.' method="get" action="'.$CFG->wwwroot.'/mod/lesson/view.php">'. + ''. + ''. + ''. + ' +
'; + } + } + $buttons = '' . $buttons .''; + } } 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; } /** @@ -436,10 +470,10 @@ function lesson_print_time_remaining($starttime, $maxtime, $return = false) { **/ 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[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&action=move&pageid=$page->id\"> @@ -450,10 +484,10 @@ function lesson_print_page_actions($cmid, $page, $printmove, $printaddpage = fal $actions[] = "wwwroot/mod/lesson/view.php?id=$cmid&pageid=$page->id\"> pixpath/t/preview.gif\" class=\"iconsmall\" alt=\"".get_string('preview')."\" />\n"; - + $actions[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=confirmdelete&pageid=$page->id\"> pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"".get_string('delete')."\" />\n"; - + if ($printaddpage) { // Add page drop-down $options = array(); @@ -464,13 +498,13 @@ function lesson_print_page_actions($cmid, $page, $printmove, $printaddpage = fal $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 { diff --git a/mod/lesson/pagelib.php b/mod/lesson/pagelib.php deleted file mode 100644 index b1975b6cd1..0000000000 --- a/mod/lesson/pagelib.php +++ /dev/null @@ -1,152 +0,0 @@ -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 = ''.update_module_button($this->modulerecord->id, $this->course->id, get_string('modulename', 'lesson')); - - if (!empty($this->lessonpageid) and $this->lessonpageid != LESSON_EOL) { - $buttons .= '
frametarget.' method="get" action="'.$CFG->wwwroot.'/mod/lesson/lesson.php">'. - ''. - ''. - ''. - ''. - ''. - '
'; - - if (!empty($CFG->showblocksonmodpages) and $this->user_allowed_editing()) { - if ($this->user_is_editing()) { - $onoff = 'off'; - } else { - $onoff = 'on'; - } - $buttons .= '
frametarget.' method="get" action="'.$CFG->wwwroot.'/mod/lesson/view.php">'. - ''. - ''. - ''. - ' -
'; - } - } - $buttons .= '
'; - } 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'; - // } 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; - } -} -?> diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 44898e72e3..e3a81dcd33 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -7,10 +7,9 @@ * @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 @@ -499,9 +498,8 @@ } } - $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); @@ -512,7 +510,7 @@ } /// 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));