Breadcrumbs: mod/lesson changes

- Modified to use build_navigation() for breadcrumb generation.


Author: Matt Clarkson <mattc@catalyst.net.nz>
This commit is contained in:
mattc-catalyst 2007-04-16 21:20:20 +00:00
parent f3c8392617
commit f8513eca8d
5 changed files with 34 additions and 51 deletions

View File

@ -35,8 +35,13 @@
$strimportquestions = get_string("importquestions", "lesson"); $strimportquestions = get_string("importquestions", "lesson");
$strlessons = get_string("modulenameplural", "lesson"); $strlessons = get_string("modulenameplural", "lesson");
print_header_simple("$strimportquestions", " $strimportquestions", $crumbs[] = array('name' => $strlesson, 'link' => "index.php?id=$course->id", 'type' => 'activity');
"<a href=\"index.php?id=$course->id\">$strlessons</a> -> <a href=\"view.php?id=$cm->id\">".format_string($lesson->name,true)."</a>-> $strimportquestions"); $crumbs[] = array('name' => format_string($lesson->name,true), 'link' => "view.php?id=$cm->id", 'type' => 'activityinstance');
$crumbs[] = array('name' => $strimportquestions, 'link' => '', 'type' => 'title');
$navigation = build_navigation($crumbs, $course);
print_header_simple("$strimportquestions", " $strimportquestions", $navigation);
if ($form = data_submitted()) { /// Filename if ($form = data_submitted()) { /// Filename

View File

@ -44,8 +44,13 @@
$strimportppt = get_string("importppt", "lesson"); $strimportppt = get_string("importppt", "lesson");
$strlessons = get_string("modulenameplural", "lesson"); $strlessons = get_string("modulenameplural", "lesson");
print_header_simple("$strimportppt", " $strimportppt", $crumbs[] = array('name' => $strlessons, 'link' => "index.php?id=$course->id", 'type' => 'activity');
"<a href=\"index.php?id=$course->id\">$strlessons</a> -> <a href=\"$CFG->wwwroot/mod/$modname/view.php?id=$cm->id\">".format_string($mod->name,true)."</a>-> $strimportppt"); $crumbs[] = array('name' => format_string($mod->name,true), 'link' => "$CFG->wwwroot/mod/$modname/view.php?id=$cm->id", 'type' => 'activityinstance');
$crumbs[] = array('name' => $strimportppt, 'link' => '', 'type' => 'title');
$navigation = build_navigation($crumbs, $course);
print_header_simple("$strimportppt", " $strimportppt", $navigation);
if ($form = data_submitted()) { /// Filename if ($form = data_submitted()) { /// Filename

View File

@ -30,13 +30,11 @@
/// Print the header /// Print the header
if ($course->id != SITEID) { $crumbs[] = array('name' => $strlessons, 'link' => '', 'type' => 'activity');
$navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->";
} else { $navigation = build_navigation($crumbs, $course);
$navigation = '';
}
print_header("$course->shortname: $strlessons", $course->fullname, "$navigation $strlessons", "", "", true, "", navmenu($course)); print_header("$course->shortname: $strlessons", $course->fullname, $navigation, "", "", true, "", navmenu($course));
/// Get all the appropriate data /// Get all the appropriate data

View File

@ -239,25 +239,14 @@ function lesson_print_header($cm, $course, $lesson, $currenttab = '') {
} }
/// Header setup /// Header setup
$navigation = array();
if ($course->id != SITEID) { $crumbs[] = array('name' => $strlessons, 'link' => "$CFG->wwwroot/mod/lesson/index.php?id=$course->id", 'type' => 'activity');
$navigation[$course->shortname] = "$CFG->wwwroot/course/view.php?id=$course->id"; $crumbs[] = array('name' => $strname, 'link' => '', 'type' => 'activityinstance');
}
$navigation[$strlessons] = "$CFG->wwwroot/mod/lesson/index.php?id=$course->id"; $navigation = build_navigation($crumbs, $course);
$navigation[$strname] = '';
$urls = array();
foreach($navigation as $text => $href) {
if (empty($href)) {
$urls[] = $text;
} else {
$urls[] = '<a href="'.$href.'">'.$text.'</a>';
}
}
$breadcrumb = implode(' -> ', $urls);
/// Print header, heading, tabs and messages /// Print header, heading, tabs and messages
print_header("$course->shortname: $strname", $course->fullname, $breadcrumb, print_header("$course->shortname: $strname", $course->fullname, $navigation,
'', '', true, $button, navmenu($course, $cm)); '', '', true, $button, navmenu($course, $cm));
if (has_capability('mod/lesson:manage', $context)) { if (has_capability('mod/lesson:manage', $context)) {

View File

@ -76,29 +76,13 @@ class page_lesson extends page_generic_activity {
$title = "{$this->courserecord->shortname}: $activityname"; $title = "{$this->courserecord->shortname}: $activityname";
} }
/// Build the breadcrumb $crumbs[] = array('name' => get_string('modulenameplural', $this->activityname), 'link' => $CFG->wwwroot."/mod/{$this->activityname}/index.php?id={$this->courserecord->id}", 'type' => 'activity');
$breadcrumbs = array(); $crumbs[] = array('name' => format_string($this->activityrecord->name), 'link' => $CFG->wwwroot."/mod/{$this->activityname}/view.php?id={$this->modulerecord->id}", 'type' => 'activityinstance');
if ($this->courserecord->id != SITEID) {
$breadcrumbs[$this->courserecord->shortname] = "$CFG->wwwroot/course/view.php?id={$this->courserecord->id}"; if (!empty($morebreadcrumbs)) {
$breadcrumbs = array_merge($crumbs, $morebreadcrumbs);
} }
$breadcrumbs[get_string('modulenameplural', 'lesson')] = "$CFG->wwwroot/mod/lesson/index.php?id={$this->courserecord->id}";
if (empty($morebreadcrumbs)) {
$breadcrumbs[$activityname] = '';
} else {
$breadcrumbs[$activityname] = "$CFG->wwwroot/mod/lesson/view.php?id={$this->modulerecord->id}&amp;pageid=$this->lessonpageid";
$breadcrumbs = array_merge($breadcrumbs, $morebreadcrumbs);
}
// Convert to breadcrumb string
$urls = array();
foreach($breadcrumbs as $text => $href) {
if (empty($href)) {
$urls[] = $text;
} else {
$urls[] = '<a href="'.$href.'">'.$text.'</a>';
}
}
$breadcrumb = implode(' -> ', $urls);
/// Build the buttons /// Build the buttons
if (has_capability('mod/lesson:edit', $context)) { if (has_capability('mod/lesson:edit', $context)) {
@ -148,7 +132,9 @@ class page_lesson extends page_generic_activity {
$meta = ''; $meta = '';
// } // }
print_header($title, $this->courserecord->fullname, $breadcrumb, '', $meta, true, $buttons, navmenu($this->courserecord, $this->modulerecord)); $navigation = build_navigation($crumbs, $this->courserecord);
print_header($title, $this->courserecord->fullname, $navigation, '', $meta, true, $buttons, navmenu($this->courserecord, $this->modulerecord));
if (has_capability('mod/lesson:manage', $context)) { if (has_capability('mod/lesson:manage', $context)) {
print_heading_with_help($activityname, 'overview', 'lesson'); print_heading_with_help($activityname, 'overview', 'lesson');