MDL-10870 All files updated to new build_navigation() method.

This commit is contained in:
nicolasconnault 2007-08-16 15:01:25 +00:00
parent 5bf243d131
commit 73c24ef80b
12 changed files with 161 additions and 98 deletions

View file

@ -80,8 +80,6 @@
$title = $strlanguage; $title = $strlanguage;
break; break;
} }
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $title";
$crumbs[] = array('name' => $strlanguage, 'link' => "$CFG->wwwroot/admin/lang.php"); $crumbs[] = array('name' => $strlanguage, 'link' => "$CFG->wwwroot/admin/lang.php");
$navigation = build_navigation($crumbs); $navigation = build_navigation($crumbs);

View file

@ -126,8 +126,13 @@ class page_admin extends page_base {
$buttons = '&nbsp;'; $buttons = '&nbsp;';
} }
print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navlinks = array();
implode(" -> ",$this->visiblepathtosection),'', '', true, $buttons, ''); foreach ($this->visiblepathtosection as $element) {
$navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
}
$navigation = build_navigation($navlinks);
print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navigation,'', '', true, $buttons, '');
} }
function get_type() { function get_type() {

View file

@ -7,6 +7,7 @@ if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
} }
$navlinks = array();
if ($currenttab != 'update') { if ($currenttab != 'update') {
switch ($context->contextlevel) { switch ($context->contextlevel) {
@ -27,8 +28,16 @@ if ($currenttab != 'update') {
$strcategories = get_string("categories"); $strcategories = get_string("categories");
$strcategory = get_string("category"); $strcategory = get_string("category");
$strcourses = get_string("courses"); $strcourses = get_string("courses");
print_header("$SITE->shortname: $category->name", "$SITE->fullname: $strcourses",
"<a href=\"$CFG->wwwroot/course/index.php\">$strcategories</a> -> <a href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a> -> $straction", "", "", true); $navlinks[] = array('name' => $strcategories,
'link' => "$CFG->wwwroot/course/index.php",
'type' => 'misc');
$navlinks[] = array('name' => $category->name,
'link' => "$CFG->wwwroot/course/category.php?id=$category->id",
'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$SITE->shortname: $category->name", "$SITE->fullname: $strcourses", $navigation, "", "", true);
break; break;
case CONTEXT_COURSE: case CONTEXT_COURSE:
@ -38,9 +47,11 @@ if ($currenttab != 'update') {
$course = get_record('course', 'id', $context->instanceid); $course = get_record('course', 'id', $context->instanceid);
require_login($course); require_login($course);
$navlinks[] = array('name' => $course->shortname,
print_header($streditcoursesettings, $course->fullname, 'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $straction"); 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header($streditcoursesettings, $course->fullname, $navigation);
} }
break; break;
@ -64,9 +75,8 @@ if ($currenttab != 'update') {
require_login($course); require_login($course);
$strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">$instance->name</a> ->"; $fullmodulename = get_string("modulename", $module->name);
$fullmodulename = get_string("modulename", $module->name); $streditinga = get_string("editinga", "moodle", $fullmodulename);
$streditinga = get_string("editinga", "moodle", $fullmodulename);
$strmodulenameplural = get_string("modulenameplural", $module->name); $strmodulenameplural = get_string("modulenameplural", $module->name);
if ($module->name == "label") { if ($module->name == "label") {
@ -75,9 +85,21 @@ if ($currenttab != 'update') {
$focuscursor = "form.name"; $focuscursor = "form.name";
} }
print_header_simple($streditinga, '', $navlinks[] = array('name' => $strmodulenameplural,
"<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> -> 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id",
$strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&amp;sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false); 'type' => 'misc');
$navlinks[] = array('name' => $instance->name,
'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id";
'type' => 'misc');
$navlinks[] = array('name' => $streditinga,
'link' => "$CFG->wwwroot/course/mod.php?update=$cm->id&amp;sesskey=".sesskey(),
'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header_simple($streditinga, '', $navigation, $focuscursor, "", false);
break; break;
@ -85,7 +107,10 @@ if ($currenttab != 'update') {
if ($blockinstance = get_record('block_instance', 'id', $context->instanceid)) { if ($blockinstance = get_record('block_instance', 'id', $context->instanceid)) {
if ($block = get_record('block', 'id', $blockinstance->blockid)) { if ($block = get_record('block', 'id', $blockinstance->blockid)) {
$blockname = print_context_name($context); $blockname = print_context_name($context);
$navigation = $blockname. ' -> '.$straction;
// Prepare the last part of the breadcrumbs first
$navlinks[98] = array('name' => $blockname, 'link' => null, 'type' => 'misc');
$navlinks[99] = array('name' => $straction, 'link' => null, 'type' => 'misc');
switch ($blockinstance->pagetype) { switch ($blockinstance->pagetype) {
case 'course-view': case 'course-view':
@ -94,16 +119,21 @@ if ($currenttab != 'update') {
require_login($course); require_login($course);
if ($course->id != SITEID) { if ($course->id != SITEID) {
$navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $navigation"; $navlinks[0] = array('name' => $course->shortname,
'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
'type' => 'misc');
} }
$navigation = build_navigation($navlinks);
print_header("$straction: $blockname", $course->fullname, $navigation); print_header("$straction: $blockname", $course->fullname, $navigation);
} }
break; break;
case 'blog-view': case 'blog-view':
$strblogs = get_string('blogs','blog'); $strblogs = get_string('blogs','blog');
$navigation = '<a href="'.$CFG->wwwroot.'/blog/index.php">'. $navlinks[0] = array('name' => $strblogs,
$strblogs.'</a> -> '.$navigation; 'link' => $CFG->wwwroot.'/blog/index.php',
'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$straction: $strblogs", $SITE->fullname, $navigation); print_header("$straction: $strblogs", $SITE->fullname, $navigation);
break; break;

View file

@ -68,13 +68,12 @@ if (!empty($id)) {
$straddedit = get_string('feedsaddedit', 'block_rss_client'); $straddedit = get_string('feedsaddedit', 'block_rss_client');
$link = $CFG->wwwroot.'/course/view.php?id='.$id;
if (!empty($course)) { if (empty($course)) {
$navigation = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$id.'">'.$course->shortname.'</a> -> '.$straddedit; $link = '';
} else {
$navigation = $straddedit;
} }
// $navlinks = array(array('name' => $course->shortname, 'link' => $link, 'type' => 'misc'));
$navigation = build_navigation($navlinks);
print_header($straddedit, $straddedit, $navigation); print_header($straddedit, $straddedit, $navigation);

View file

@ -42,8 +42,9 @@
$strpreferences = get_string('preferences'); $strpreferences = get_string('preferences');
$strblogs = get_string('blogs', 'blog'); $strblogs = get_string('blogs', 'blog');
$navlinks = array(array('name' => $strblogs, 'link' => "$CFG->wwwroot/blog/", 'type' => 'misc'));
$navigation = "<a href='".$CFG->wwwroot."/blog/'>$strblogs</a> -> $strpreferences"; $navlinks[] = array('name' => $strpreferences, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$site->shortname: $strblogs : $strpreferences", $strblogs, $navigation); print_header("$site->shortname: $strblogs : $strpreferences", $strblogs, $navigation);
print_heading($strpreferences); print_heading($strpreferences);

View file

@ -58,13 +58,14 @@
$strcalendar = get_string('calendar', 'calendar'); $strcalendar = get_string('calendar', 'calendar');
$strpreferences = get_string('preferences', 'calendar'); $strpreferences = get_string('preferences', 'calendar');
$navlinks = array();
if ($course->id != SITEID) { if ($course->id != SITEID) {
$navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $navlinks[] = array('name' => $course->shortname,
<a href=\"view.php\">$strcalendar</a> -> $strpreferences"; 'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
} else { 'type' => 'misc');
$navigation = "<a href=\"view.php\">$strcalendar</a> -> $strpreferences";
} }
$navlinks[] = array('name' => $strpreferences, 'link' => 'view.php', 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$site->shortname: $strcalendar: $strpreferences", $strcalendar, $navigation, print_header("$site->shortname: $strcalendar: $strpreferences", $strcalendar, $navigation,
'', '', true, '', user_login_string($site)); '', '', true, '', user_login_string($site));

View file

@ -127,17 +127,30 @@
$straddnewcourse = get_string("addnewcourse"); $straddnewcourse = get_string("addnewcourse");
$stradministration = get_string("administration"); $stradministration = get_string("administration");
$strcategories = get_string("categories"); $strcategories = get_string("categories");
$navlinks = array();
if (!empty($course)) { if (!empty($course)) {
print_header($streditcoursesettings, $course->fullname, $navlinks[] = array('name' => $streditcoursesettings,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> 'link' => null,
-> $streditcoursesettings", $editform->focus()); 'type' => 'misc');
$title = $streditcoursesettings;
$fullname = $course->fullname;
} else { } else {
print_header("$site->shortname: $straddnewcourse", $site->fullname, $navlinks[] = array('name' => $stradministration,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> ". 'link' => "$CFG->wwwroot/$CFG->admin/index.php",
"<a href=\"index.php\">$strcategories</a> -> $straddnewcourse", $editform->focus()); 'type' => 'misc');
$navlinks[] = array('name' => $strcategories,
'link' => 'index.php',
'type' => 'misc');
$navlinks[] = array('name' => $straddnewcourse,
'link' => null,
'type' => 'misc');
$title = "$site->shortname: $straddnewcourse";
$fullname = $site->fullname;
} }
$navigation = build_navigation($navlinks);
print_header($title, $fullname, $navigation, $editform->focus());
print_heading($streditcoursesettings); print_heading($streditcoursesettings);
$editform->display(); $editform->display();

View file

@ -49,6 +49,9 @@
function html_header($course, $wdir, $formfield=""){ function html_header($course, $wdir, $formfield=""){
global $CFG, $ME, $choose; global $CFG, $ME, $choose;
$navlinks = array();
// $navlinks[] = array('name' => $course->shortname, 'link' => "../course/view.php?id=$course->id", 'type' => 'misc');
if ($course->id == SITEID) { if ($course->id == SITEID) {
$strfiles = get_string("sitefiles"); $strfiles = get_string("sitefiles");
} else { } else {
@ -56,18 +59,22 @@
} }
if ($wdir == "/") { if ($wdir == "/") {
$fullnav = "$strfiles"; $navlinks[] = array('name' => $strfiles, 'link' => null, 'type' => 'misc');
} else { } else {
$dirs = explode("/", $wdir); $dirs = explode("/", $wdir);
$numdirs = count($dirs); $numdirs = count($dirs);
$link = ""; $link = "";
$navigation = ""; $navlinks[] = array('name' => $strfiles,
'link' => $ME."?id=$course->id&amp;wdir=/&amp;choose=$choose",
'type' => 'misc');
for ($i=1; $i<$numdirs-1; $i++) { for ($i=1; $i<$numdirs-1; $i++) {
$navigation .= " -> "; $link .= "/".urlencode($dirs[$i]);
$link .= "/".urlencode($dirs[$i]); $navlinks[] = array('name' => $dirs[$i],
$navigation .= "<a href=\"".$ME."?id=$course->id&amp;wdir=$link&amp;choose=$choose\">".$dirs[$i]."</a>"; 'link' => $ME."?id=$course->id&amp;wdir=$link&amp;choose=$choose",
'type' => 'misc');
} }
$fullnav = "<a href=\"".$ME."?id=$course->id&amp;wdir=/&amp;choose=$choose\">$strfiles</a> $navigation -> ".$dirs[$numdirs-1]; $navlinks[] = array('name' => $dirs[$numdirs-1], 'link' => null, 'type' => 'misc');
} }
@ -124,9 +131,8 @@
} }
} else { } else {
print_header("$course->shortname: $strfiles", $course->fullname, $navigation = build_navigation($navlinks);
"<a href=\"../course/view.php?id=$course->id\">$course->shortname". print_header("$course->shortname: $strfiles", $course->fullname, $navigation, $formfield);
"</a> -> $fullnav", $formfield);
} }
} }

View file

@ -7090,14 +7090,18 @@ function build_navigation($extranavlinks) {
//Site name //Site name
if ($site = get_site()) { if ($site = get_site()) {
$navlinks[] = array('name' => format_string($site->shortname), 'link' => "$CFG->wwwroot/", 'type' => 'home'); $navlinks[] = array('name' => format_string($site->shortname),
'link' => "$CFG->wwwroot/",
'type' => 'home');
} }
if ($COURSE) { if ($COURSE) {
if ($COURSE->id != SITEID) { if ($COURSE->id != SITEID) {
//Course //Course
$navlinks[] = array('name' => format_string($COURSE->shortname), 'link' => "$CFG->wwwroot/course/view.php?id=$COURSE->id",'type' => 'course'); $navlinks[] = array('name' => format_string($COURSE->shortname),
'link' => "$CFG->wwwroot/course/view.php?id=$COURSE->id",
'type' => 'course');
} }
} }
@ -7108,26 +7112,35 @@ function build_navigation($extranavlinks) {
//Accessibility: heading hidden from visual browsers by default. //Accessibility: heading hidden from visual browsers by default.
$navigation = '<h2 class="accesshide">'.get_string('youarehere','access')."</h2> <ul>\n"; $navigation = '<h2 class="accesshide">'.get_string('youarehere','access')."</h2> <ul>\n";
$countlinks = count($navlinks); $countlinks = count($navlinks);
$i = 0;
for($i=0;$i<$countlinks;$i++) { foreach ($navlinks as $navlink) {
if ($i >= $countlinks || !is_array($navlink)) {
continue;
}
// Check the link type to see if this link should appear in the trail // Check the link type to see if this link should appear in the trail
if ($navlinks[$i]['type'] == 'activity' && $i+1 < $countlinks && ($CFG->hideactivitytypenavlink == 2 || ($CFG->hideactivitytypenavlink == 1 && !has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))))) { $cap = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $COURSE->id));
$hidetype_is2 = $CFG->hideactivitytypenavlink == 2;
$hidetype_is1 = $CFG->hideactivitytypenavlink == 1;
if ($navlink['type'] == 'activity' &&
$i+1 < $countlinks &&
($hidetype_is2 || ($hidetype_is1 && !$cap))) {
continue; continue;
} }
$navigation .= '<li class="first">'; $navigation .= '<li class="first">';
if ($i > 0) { if ($i > 0) {
$navigation .= get_separator(); $navigation .= get_separator();
} }
if ($navlinks[$i]['link'] && $i+1 < $countlinks) { if ($navlink['link'] && $i+1 < $countlinks) {
$navigation .= "<a onclick=\"this.target='$CFG->framename'\" href=\"{$navlinks[$i]['link']}\">"; $navigation .= "<a onclick=\"this.target='$CFG->framename'\" href=\"{$navlink['link']}\">";
} }
$navigation .= "{$navlinks[$i]['name']}"; $navigation .= "{$navlink['name']}";
if ($navlinks[$i]['link'] && $i+1 < $countlinks) { if ($navlink['link'] && $i+1 < $countlinks) {
$navigation .= "</a>"; $navigation .= "</a>";
} }
$navigation .= "</li>"; $navigation .= "</li>";
$i++;
} }
$navigation .= "</ul>"; $navigation .= "</ul>";
@ -7150,8 +7163,7 @@ function is_newnav($navigation) {
* @param object $object The object to check * @param object $object The object to check
* @return boolean * @return boolean
*/ */
function in_object_vars($var, $object) function in_object_vars($var, $object) {
{
$class_vars = get_class_vars(get_class($object)); $class_vars = get_class_vars(get_class($object));
$class_vars = array_keys($class_vars); $class_vars = array_keys($class_vars);
return in_array($var, $class_vars); return in_array($var, $class_vars);

View file

@ -64,10 +64,9 @@
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// If it's hidden then it's don't show anything. :) /// If it's hidden then it doesn't show anything. :)
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) { if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
$strdatabases = get_string("modulenameplural", "data"); $strdatabases = get_string("modulenameplural", "data");
$navigation = "<a href=\"index.php?id=$course->id\">$strdatabases</a> ->";
$navlinks = array(); $navlinks = array();
$navlinks[] = array('name' => $strdatabases, 'link' => "index.php?id=$course->id", 'type' => 'activity'); $navlinks[] = array('name' => $strdatabases, 'link' => "index.php?id=$course->id", 'type' => 'activity');

View file

@ -37,8 +37,8 @@ if (!isset($form->create_sequence_url)) {
<center> <center>
<span id="message"><p>Please wait .......</p></span> <span id="message"><p>Please wait .......</p></span>
<table cellpadding="5"> <table cellpadding="5">
<tr valign=top> <tr valign="top">
<td align=right><b><?php print_string("workspace", "lams") ?>:</b></td> <td align="right"><b><?php print_string("workspace", "lams") ?>:</b></td>
<td> <td>
<select id="workspace" name="workspace"></select> <select id="workspace" name="workspace"></select>
</td> </td>
@ -55,7 +55,8 @@ if (!isset($form->create_sequence_url)) {
<input type="text" id="name" name="name" size="30" /> <input type="text" id="name" name="name" size="30" />
</td> </td>
</tr> </tr>
<td align=right><p><b><?php print_string("introduction", "lams") ?>:</b></p> <tr>
<td align="right"><p><b><?php print_string("introduction", "lams") ?>:</b></p>
<br /> <br />
<font size="1"> <font size="1">
<?php <?php
@ -87,8 +88,10 @@ print_textarea($usehtmleditor, 20, 50, 680, 400, "introduction", $form->introduc
<input type="hidden" name="learning_session_id"/> <input type="hidden" name="learning_session_id"/>
<input type="hidden" name="create_sequence_url" id="create_sequence_url"/> <input type="hidden" name="create_sequence_url" id="create_sequence_url"/>
<input type="submit" id="save" name="save" value="<?php print_string("useSequence","lams") ?>" onClick="return validate();"> <input type="submit" id="save" name="save" value="<?php print_string("useSequence","lams") ?>" onClick="return validate();">
<input type="button" id="edit" name"edit" value="<?php print_string("editSequence","lams") ?>" onClick="openAuthor(<?php echo "'".$form->create_sequence_url."&".$LAMSCONSTANTS->param_ldid."=".$form->sequence."'";?>);"> <input type="button" id="edit" name="edit" value="<?php print_string("editSequence","lams") ?>" onClick="openAuthor(<?php
<input type="button" id="create" name="create" value="<?php print_string("createSequence","lams") ?>" onClick="openAuthor(<?php echo "'".$form->create_sequence_url."'";?>);"> echo "'".$form->create_sequence_url."&".$LAMSCONSTANTS->param_ldid."=".$form->sequence."'";?>);">
<input type="button" id="create" name="create" value="<?php print_string("createSequence","lams") ?>" onClick="openAuthor(<?php
echo "'".$form->create_sequence_url."'";?>);">
<input type="button" id="refresh" name="refresh" value="<?php print_string("refreshSequenceList","lams")?>" onclick="refreshLists();"> <input type="button" id="refresh" name="refresh" value="<?php print_string("refreshSequenceList","lams")?>" onclick="refreshLists();">
<input type="submit" id="cancel" name=cancel value="<?php print_string("cancel") ?>"> <input type="submit" id="cancel" name=cancel value="<?php print_string("cancel") ?>">

View file

@ -12,11 +12,7 @@
if ($course->id != SITEID) { if ($course->id != SITEID) {
require_login($course->id); require_login($course->id);
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
} else {
$navigation = '';
} }
add_to_log($course->id, "resource", "view all", "index.php?id=$course->id", ""); add_to_log($course->id, "resource", "view all", "index.php?id=$course->id", "");
$strresource = get_string("modulename", "resource"); $strresource = get_string("modulename", "resource");