]> git.mjollnir.org Git - moodle.git/commitdiff
Breadcrumbs: mod/resource changes
authormattc-catalyst <mattc-catalyst>
Mon, 16 Apr 2007 21:57:09 +0000 (21:57 +0000)
committermattc-catalyst <mattc-catalyst>
Mon, 16 Apr 2007 21:57:09 +0000 (21:57 +0000)
- Modified to use build_navigation() for breadcrumb generation.

Author: Matt Clarkson <mattc@catalyst.net.nz>

mod/resource/index.php
mod/resource/lib.php
mod/resource/type/directory/resource.class.php
mod/resource/type/html/resource.class.php
mod/resource/type/ims/deploy.php
mod/resource/type/ims/resource.class.php
mod/resource/type/text/resource.class.php

index 7f3ae9c29cfb8a231b5638c6336bc921ed4dc415..f7de1287e3ee2259ae5bb575a0fa8f1cfc74d65c 100644 (file)
     $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)) {
index bb9c25f542e5d9c1a3ba364ea463be9e1ed9ae31..f7241cbed70281f8f154e5a6c79301bad3078a06 100644 (file)
@@ -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 = "<a $CFG->frametarget onclick=\"this.target='$CFG->framename'\" href=\"$CFG->wwwroot/course/view.php?id={$this->course->id}\">{$this->course->shortname}</a> -> ".
-                                "<a $CFG->frametarget onclick=\"this.target='$CFG->framename'\" href=\"index.php?id={$this->course->id}\">$this->strresources</a> ->";
-        } else {
-            $this->navigation = "<a $CFG->frametarget onclick=\"this.target='$CFG->framename'\" href=\"index.php?id={$this->course->id}\">$this->strresources</a> ->";
-        }
+        $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;
     }
index b96c9e38885acca33735221421b13132681a46f1..7133efc690fe65c5a33f76a4f3be931b7f72234a 100644 (file)
@@ -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 = "<a href=\"view.php?id={$cm->id}\">".format_string($resource->name,true)."</a>";
         $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  .= " -> <a href=\"view.php?id={$cm->id}&amp;subdir=$backsub\">$sub</a>";
+                
+                $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);
+
+}
+
 
 }
 
index 08d10f2176f8fd41823331bbf64b63783de423e0..2610257176251ce00070ab34539a28b9a88e4606 100644 (file)
@@ -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));
 
index 086899dec3ed662ee5e34cd2bcbe70317933ed3c..8f26e2dcc3d2bc2c3c22be5b014308f8373d9cf1 100644 (file)
 
 /// Instantiate a resource_ims object and modify its navigation
     $resource_obj = new resource_ims ($cmid);
-    if ($resource_obj->course->id != SITEID) {
-        $resource_obj->navigation = "<a $CFG->frametarget href=\"$CFG->wwwroot/course/view.php?id={$course->id}\">{$course->shortname}</a> -> ".
-                                    "<a $CFG->frametarget href=\"$CFG->wwwroot/mod/resource/index.php?id={$course->id}\">$resource_obj->strresources</a> -> ";
-    } else {
-        $resource_obj->navigation = "<a $CFG->frametarget href=\"$CFG->wwwroot/mod/resource/index.php?id={$course->id}\">$resource_obj->strresources</a> -> ";
-    }
-
+    
 /// Print the header of the page
     $pagetitle = strip_tags($course->shortname.': '.
                      format_string($resource->name)).': '.
     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));
     }
index 47e19f5c7e61b010babac2ead7e9b99c0b3b2fd8..2cee64a7aa3609091b5d910d07e5b135bcc3b250 100644 (file)
@@ -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 '<p align="center">'.$errortext.'</p>';
@@ -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);
index 5a1f032de0df5b071b46c614fc1a882e0f110246..baef7b1b5c1f50923e87ad20c8dcebb91300efb0 100644 (file)
@@ -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));