From 06dfa0cc3335842962af954d556ecced0de8102d Mon Sep 17 00:00:00 2001 From: mattc-catalyst Date: Mon, 16 Apr 2007 21:57:09 +0000 Subject: [PATCH] Breadcrumbs: mod/resource changes - Modified to use build_navigation() for breadcrumb generation. Author: Matt Clarkson --- mod/resource/index.php | 6 ++- mod/resource/lib.php | 13 +++---- .../type/directory/resource.class.php | 37 ++++++++++++++----- mod/resource/type/html/resource.class.php | 10 ++++- mod/resource/type/ims/deploy.php | 15 +++----- mod/resource/type/ims/resource.class.php | 10 ++++- mod/resource/type/text/resource.class.php | 5 ++- 7 files changed, 65 insertions(+), 31 deletions(-) diff --git a/mod/resource/index.php b/mod/resource/index.php index 7f3ae9c29c..f7de1287e3 100644 --- a/mod/resource/index.php +++ b/mod/resource/index.php @@ -26,8 +26,12 @@ $strname = get_string("name"); $strsummary = get_string("summary"); $strlastmodified = get_string("lastmodified"); + + + $crumbs[] = array('name' => $strresources, 'link' => '', 'type' => 'activityinstance'); + $navigation = build_navigation($crumbs, $course); - print_header("$course->shortname: $strresources", $course->fullname, "$navigation $strresources", + print_header("$course->shortname: $strresources", $course->fullname, $navigation, "", "", true, "", navmenu($course)); if (! $resources = get_all_instances_in_course("resource", $course)) { diff --git a/mod/resource/lib.php b/mod/resource/lib.php index bb9c25f542..f7241cbed7 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -108,18 +108,17 @@ function resource_base($cmid=0) { $this->strresource = get_string("modulename", "resource"); $this->strresources = get_string("modulenameplural", "resource"); - if ($this->course->id != SITEID) { - $this->navigation = "frametarget onclick=\"this.target='$CFG->framename'\" href=\"$CFG->wwwroot/course/view.php?id={$this->course->id}\">{$this->course->shortname} -> ". - "frametarget onclick=\"this.target='$CFG->framename'\" href=\"index.php?id={$this->course->id}\">$this->strresources ->"; - } else { - $this->navigation = "frametarget onclick=\"this.target='$CFG->framename'\" href=\"index.php?id={$this->course->id}\">$this->strresources ->"; - } + $this->crumbs[] = array('name' => $this->strresources, 'link' => "index.php?id={$this->course->id}", 'type' => 'activity'); if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $this->cm->id))) { $pagetitle = strip_tags($this->course->shortname.': '.$this->strresource); - print_header($pagetitle, $this->course->fullname, "$this->navigation $this->strresource", "", "", true, '', navmenu($this->course, $this->cm)); + $this->crumbs[] = array('name' => $this->strresource, 'link' => '', 'type' => 'activityinstance'); + $this->navigation = build_navigation($this->crumbs, $this->course); + + print_header($pagetitle, $this->course->fullname, $this->navigation, "", "", true, '', navmenu($this->course, $this->cm)); notice(get_string("activityiscurrentlyhidden"), "$CFG->wwwroot/course/view.php?id={$this->course->id}"); } + } else { $this->course = $COURSE; } diff --git a/mod/resource/type/directory/resource.class.php b/mod/resource/type/directory/resource.class.php index b96c9e3888..7133efc690 100644 --- a/mod/resource/type/directory/resource.class.php +++ b/mod/resource/type/directory/resource.class.php @@ -14,13 +14,13 @@ function display() { parent::display(); /// Set up some shorthand variables - $cm = $this->cm; + $cm = $this->cm; $course = $this->course; - $resource = $this->resource; + $resource = $this->resource; require_once($CFG->libdir.'/filelib.php'); - $subdir = optional_param('subdir','', PARAM_PATH); + $subdir = optional_param('subdir','', PARAM_PATH); $resource->reference = clean_param($resource->reference, PARAM_PATH); $formatoptions = new object(); @@ -46,17 +46,20 @@ function display() { $count = 0; $subnav = "id}\">".format_string($resource->name,true).""; $backsub = ''; + $this->crumbs[] = array('name' => format_string($resource->name,true), 'link' => "view.php?id={$cm->id}", 'type' => 'activity'); + foreach ($subs as $sub) { $count++; if ($count < $countsubs) { $backsub .= "/$sub"; - $subnav .= " -> id}&subdir=$backsub\">$sub"; + + $this->crumbs[] = array('name' => $sub, 'link' => "view.php?id={$cm->id}", 'type' => 'title'); } else { - $subnav .= " -> $sub"; + $this->crumbs[] = array('name' => $sub, 'link' => '', 'type' => 'title'); } } } else { - $subnav = format_string($resource->name); + $this->crumbs[] = array('name' => format_string($resource->name), 'link' => '', 'type' => 'activity'); } $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name)); @@ -67,7 +70,8 @@ function display() { $editfiles = print_single_button("$CFG->wwwroot/files/index.php", $options, get_string("editfiles"), 'get', '', true); $update = $editfiles.$update; } - print_header($pagetitle, $course->fullname, "$this->navigation $subnav", + $this->navigation = build_navigation($this->crumbs, $this->course); + print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, $update, navmenu($course, $cm)); @@ -150,18 +154,33 @@ function setup($form) { global $CFG; parent::setup($form); - + $rawdirs = get_directory_list("$CFG->dataroot/{$this->course->id}", array($CFG->moddata, 'backupdata'), true, true, false); $dirs = array(); foreach ($rawdirs as $rawdir) { $dirs[$rawdir] = $rawdir; } - + include("$CFG->dirroot/mod/resource/type/directory/directory.html"); parent::setup_end(); } +function setup_elements(&$mform) { + global $CFG; + + $rawdirs = get_directory_list($CFG->dataroot.'/'.$this->course->id, array($CFG->moddata, 'backupdata'), true, true, false); + $dirs = array(); + $dirs[0]=get_string('maindirectory', 'resource'); + foreach ($rawdirs as $rawdir) { + $dirs[$rawdir] = $rawdir; + } + + $mform->addElement('select', 'reference', get_string('resourcetypedirectory', 'resource'), $dirs); + $mform->setDefault('windowpopup', 0); + +} + } diff --git a/mod/resource/type/html/resource.class.php b/mod/resource/type/html/resource.class.php index 08d10f2176..2610257176 100644 --- a/mod/resource/type/html/resource.class.php +++ b/mod/resource/type/html/resource.class.php @@ -84,7 +84,10 @@ function display() { print_footer($course); } else { /// Make a page and a pop-up window - print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), + $this->crumbs[] = array('name' => format_string($resource->name), 'link' => '', 'type' => 'activityinstance'); + $this->navigation = build_navigation($this->crumbs, $this->course); + + print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm)); @@ -110,7 +113,10 @@ function display() { } } else { /// not a popup at all - print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), + $this->crumbs[] = array('name' => format_string($resource->name), 'link' => '', 'type' => 'activityinstance'); + $this->navigation = build_navigation($this->crumbs, $this->course); + + print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm)); diff --git a/mod/resource/type/ims/deploy.php b/mod/resource/type/ims/deploy.php index 086899dec3..8f26e2dcc3 100644 --- a/mod/resource/type/ims/deploy.php +++ b/mod/resource/type/ims/deploy.php @@ -54,13 +54,7 @@ /// Instantiate a resource_ims object and modify its navigation $resource_obj = new resource_ims ($cmid); - if ($resource_obj->course->id != SITEID) { - $resource_obj->navigation = "frametarget href=\"$CFG->wwwroot/course/view.php?id={$course->id}\">{$course->shortname} -> ". - "frametarget href=\"$CFG->wwwroot/mod/resource/index.php?id={$course->id}\">$resource_obj->strresources -> "; - } else { - $resource_obj->navigation = "frametarget href=\"$CFG->wwwroot/mod/resource/index.php?id={$course->id}\">$resource_obj->strresources -> "; - } - + /// Print the header of the page $pagetitle = strip_tags($course->shortname.': '. format_string($resource->name)).': '. @@ -69,8 +63,11 @@ if ($inpopup) { print_header($pagetitle, $course->fullname); } else { - print_header($pagetitle, $course->fullname, - $resource_obj->navigation.format_string($resource->name).' -> '.$strdeploy, + + $resource_obj->crumbs[] = array('name' => format_string($resource->name), 'link' => '', 'type' => 'activityinstance'); + $resource_obj->crumbs[] = array('name' => $strdeploy, 'link' => '', 'type' => 'action'); + $navigation = build_navigation($resource_obj->crumbs, $resource_obj->course); + print_header($pagetitle, $course->fullname, $navigation, '', '', true, update_module_button($cm->id, $course->id, $resource_obj->strresource)); } diff --git a/mod/resource/type/ims/resource.class.php b/mod/resource/type/ims/resource.class.php index 47e19f5c7e..2cee64a7aa 100644 --- a/mod/resource/type/ims/resource.class.php +++ b/mod/resource/type/ims/resource.class.php @@ -371,7 +371,11 @@ class resource_ims extends resource_base { if ($inpopup) { print_header($pagetitle, $course->fullname.' : '.$resource->name); } else { - print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm)); + + $this->crumbs[] = array('name' => format_string($resource->name), 'link' => '', 'type' => 'activityinstance'); + $this->navigation = build_navigation($this->crumbs, $this->course); + + print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm)); } print_simple_box_start('center', '60%'); echo '

'.$errortext.'

'; @@ -469,7 +473,9 @@ class resource_ims extends resource_base { //print_header($pagetitle, $course->fullname.' : '.$resource->name); print_header(); } else { - print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent")); + $this->crumbs[] = array('name' => format_string($resource->name), 'link' => '', 'type' => 'activityinstance'); + $this->navigation = build_navigation($this->crumbs, $this->course); + print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent")); } /// content - this produces everything else $this->print_ims($cm, $course, $items, $resource, $page); diff --git a/mod/resource/type/text/resource.class.php b/mod/resource/type/text/resource.class.php index 5a1f032de0..baef7b1b5c 100644 --- a/mod/resource/type/text/resource.class.php +++ b/mod/resource/type/text/resource.class.php @@ -110,7 +110,10 @@ function display() { } else { /// not a popup at all add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id); - print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), + $this->crumbs[] = array('name' => format_string($resource->name), 'link' => '', 'type' => 'title'); + $this->navigation = build_navigation($this->crumbs, $this->course); + + print_header($pagetitle, $course->fullname, $this->navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm)); -- 2.39.5