From 0440482f1d110712d25c8f1de3cb79633ce062a3 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 14 Aug 2005 05:34:56 +0000 Subject: [PATCH] Two methods added to allow resources to be displayed with the course blocks. Uses the outstanding Page class code by Jon P. (SE) --- mod/resource/lib.php | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/mod/resource/lib.php b/mod/resource/lib.php index badb2d11961..bb3a69cfe3b 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -129,6 +129,78 @@ function display() { } +/** +* Display the resource with the course blocks. +*/ +function display_course_blocks_start() { + + global $CFG; + global $USER; + + require_once($CFG->libdir.'/blocklib.php'); + require_once($CFG->libdir.'/pagelib.php'); + + $PAGE = page_create_object(PAGE_COURSE_VIEW, $this->course->id); + $this->PAGE = $PAGE; + $pageblocks = blocks_setup($PAGE); + + $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210); + +/// Print the page header + + if (!empty($edit) && $PAGE->user_allowed_editing()) { + if ($edit == 'on') { + $USER->editing = true; + } else if ($edit == 'off') { + $USER->editing = false; + } + } + $morebreadcrumbs = array($this->strresources => 'index.php?id='.$this->course->id, + $this->resource->name => ''); + + $PAGE->print_header($this->course->shortname.': %fullname%', $morebreadcrumbs); + + echo ''; + + if((blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) { + echo ''; + } + + echo ''; + + if((blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing())) { + echo ''; + } + + echo '
'; + blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); + echo ''; + echo '
'; + +} + + +/** + * Finish displaying the resource with the course blocks + */ +function display_course_blocks_end() { + + global $CFG; + + $PAGE = $this->PAGE; + $pageblocks = blocks_setup($PAGE); + $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210); + + echo '
'; + echo '
'; + blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); + echo '
'; + + print_footer($this->course); + +} + + function setup(&$form) { global $CFG, $usehtmleditor;