Skip to content

Commit

Permalink
MDL-10870 All files updated to new build_navigation() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Aug 16, 2007
1 parent 5bf243d commit 73c24ef
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 98 deletions.
2 changes: 0 additions & 2 deletions admin/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@
$title = $strlanguage;
break;
}
$navigation = "<a href=\"lang.php\">$strlanguage</a> -> $title";

$crumbs[] = array('name' => $strlanguage, 'link' => "$CFG->wwwroot/admin/lang.php");
$navigation = build_navigation($crumbs);

Expand Down
29 changes: 17 additions & 12 deletions admin/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
define('BLOCK_L_MAX_WIDTH', $lmax);
define('BLOCK_R_MIN_WIDTH', $rmin);
define('BLOCK_R_MAX_WIDTH', $rmax);

page_map_class(PAGE_ADMIN, 'page_admin');

class page_admin extends page_base {
Expand All @@ -27,7 +27,7 @@ class page_admin extends page_base {
// hack alert!
// this function works around the inability to store the section name
// in default block, maybe we should "improve" the blocks a bit?
function init_extra($section) {
function init_extra($section) {
global $CFG;

if($this->full_init_done) {
Expand All @@ -40,7 +40,7 @@ function init_extra($section) {
$this->section = $section;

$this->visiblepathtosection = array();

// this part is (potentially) processor-intensive... there's gotta be a better way
// of handling this
if ($this->pathtosection = $adminroot->path($this->section)) {
Expand All @@ -54,24 +54,24 @@ function init_extra($section) {
// all done
$this->full_init_done = true;
}

function blocks_get_default() {
return 'admin_tree,admin_bookmarks';
}

// seems reasonable that the only people that can edit blocks on the admin pages
// are the admins... but maybe we want a role for this?
function user_allowed_editing() {
function user_allowed_editing() {
return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID));
}

// has to be fixed. i know there's a "proper" way to do this
function user_is_editing() {
function user_is_editing() {
global $USER;
return $USER->adminediting;
}

function url_get_path() {
function url_get_path() {
global $CFG;

$adminroot = admin_get_root();
Expand All @@ -88,11 +88,11 @@ function url_get_parameters() { // only handles parameters relevant to the admi
return array('section' => (isset($this->section) ? $this->section : ''));
}

function blocks_get_positions() {
function blocks_get_positions() {
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
}

function blocks_default_position() {
function blocks_default_position() {
return BLOCK_POS_LEFT;
}

Expand All @@ -116,7 +116,7 @@ function print_header($section = '') {
$this->init_full($section); // we're trusting that init_full() has already been called by now; it should have.
// if not, print_header() has to be called with a $section parameter

// The search page currently doesn't handle block editing
// The search page currently doesn't handle block editing
if ($this->section != 'search' and $this->user_allowed_editing()) {
$buttons = '<div><form '.$CFG->frametarget.' method="get" action="' . $this->url_get_path() . '">'.
'<div><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
Expand All @@ -126,8 +126,13 @@ function print_header($section = '') {
$buttons = '&nbsp;';
}

print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname,
implode(" -> ",$this->visiblepathtosection),'', '', true, $buttons, '');
$navlinks = array();
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() {
Expand Down
60 changes: 45 additions & 15 deletions admin/roles/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

$navlinks = array();
if ($currenttab != 'update') {
switch ($context->contextlevel) {

Expand All @@ -27,8 +28,16 @@
$strcategories = get_string("categories");
$strcategory = get_string("category");
$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;

case CONTEXT_COURSE:
Expand All @@ -38,9 +47,11 @@
$course = get_record('course', 'id', $context->instanceid);

require_login($course);

print_header($streditcoursesettings, $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $straction");
$navlinks[] = array('name' => $course->shortname,
'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header($streditcoursesettings, $course->fullname, $navigation);
}
break;

Expand All @@ -64,9 +75,8 @@

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);
$streditinga = get_string("editinga", "moodle", $fullmodulename);
$fullmodulename = get_string("modulename", $module->name);
$streditinga = get_string("editinga", "moodle", $fullmodulename);
$strmodulenameplural = get_string("modulenameplural", $module->name);

if ($module->name == "label") {
Expand All @@ -75,17 +85,32 @@
$focuscursor = "form.name";
}

print_header_simple($streditinga, '',
"<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
$strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&amp;sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false);
$navlinks[] = array('name' => $strmodulenameplural,
'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id",
'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;

case CONTEXT_BLOCK:
if ($blockinstance = get_record('block_instance', 'id', $context->instanceid)) {
if ($block = get_record('block', 'id', $blockinstance->blockid)) {
$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) {
case 'course-view':
Expand All @@ -94,16 +119,21 @@
require_login($course);

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);
}
break;

case 'blog-view':
$strblogs = get_string('blogs','blog');
$navigation = '<a href="'.$CFG->wwwroot.'/blog/index.php">'.
$strblogs.'</a> -> '.$navigation;
$navlinks[0] = array('name' => $strblogs,
'link' => $CFG->wwwroot.'/blog/index.php',
'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("$straction: $strblogs", $SITE->fullname, $navigation);
break;

Expand Down
13 changes: 6 additions & 7 deletions blocks/rss_client/block_rss_client_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@


if (!empty($id)) {
// we get the complete $course object here because print_header assumes this is
// we get the complete $course object here because print_header assumes this is
// a complete object (needed for proper course theme settings)
if ($course = get_record('course', 'id', $id)) {
$context = get_context_instance(CONTEXT_COURSE, $id);
Expand All @@ -68,13 +68,12 @@


$straddedit = get_string('feedsaddedit', 'block_rss_client');

if (!empty($course)) {
$navigation = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$id.'">'.$course->shortname.'</a> -> '.$straddedit;
} else {
$navigation = $straddedit;
$link = $CFG->wwwroot.'/course/view.php?id='.$id;
if (empty($course)) {
$link = '';
}

// $navlinks = array(array('name' => $course->shortname, 'link' => $link, 'type' => 'misc'));
$navigation = build_navigation($navlinks);
print_header($straddedit, $straddedit, $navigation);


Expand Down
5 changes: 3 additions & 2 deletions blog/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@

$strpreferences = get_string('preferences');
$strblogs = get_string('blogs', 'blog');

$navigation = "<a href='".$CFG->wwwroot."/blog/'>$strblogs</a> -> $strpreferences";
$navlinks = array(array('name' => $strblogs, 'link' => "$CFG->wwwroot/blog/", 'type' => 'misc'));
$navlinks[] = array('name' => $strpreferences, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);

print_header("$site->shortname: $strblogs : $strpreferences", $strblogs, $navigation);
print_heading($strpreferences);
Expand Down
13 changes: 7 additions & 6 deletions calendar/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
// Initialize the session variables
calendar_session_vars();

/// If data submitted, then process and store.

if ($form = data_submitted()) {
Expand Down Expand Up @@ -58,13 +58,14 @@
$strcalendar = get_string('calendar', 'calendar');
$strpreferences = get_string('preferences', 'calendar');

$navlinks = array();
if ($course->id != SITEID) {
$navigation = "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
<a href=\"view.php\">$strcalendar</a> -> $strpreferences";
} else {
$navigation = "<a href=\"view.php\">$strcalendar</a> -> $strpreferences";
$navlinks[] = array('name' => $course->shortname,
'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
'type' => 'misc');
}

$navlinks[] = array('name' => $strpreferences, 'link' => 'view.php', 'type' => 'misc');
$navigation = build_navigation($navlinks);

print_header("$site->shortname: $strcalendar: $strpreferences", $strcalendar, $navigation,
'', '', true, '', user_login_string($site));
Expand Down
35 changes: 24 additions & 11 deletions course/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
} // it'll be greyed out but we want these by default anyway.
}
$course->allowedmods = $allowedmods;

if ($course->enrolstartdate){
$course->enrolstartdisabled = 0;
}

if ($course->enrolenddate) {
$course->enrolenddisabled = 0;
}
Expand Down Expand Up @@ -98,7 +98,7 @@
// assign default role to creator if not already having permission to manage course assignments
if (!has_capability('moodle/course:view', $context) or !has_capability('moodle/role:assign', $context)) {
role_assign($CFG->creatornewroleid, $USER->id, 0, $context->id);
}
}

if ($data->metacourse and has_capability('moodle/course:managemetacourse', $context)) {
// Redirect users with metacourse capability to student import
Expand All @@ -107,8 +107,8 @@
// Redirect to roles assignment
redirect($CFG->wwwroot."/$CFG->admin/roles/assign.php?contextid=$context->id");
}
} else {

} else {
if (!update_course($data)) {
print_error('coursenotupdated');
}
Expand All @@ -127,17 +127,30 @@
$straddnewcourse = get_string("addnewcourse");
$stradministration = get_string("administration");
$strcategories = get_string("categories");
$navlinks = array();

if (!empty($course)) {
print_header($streditcoursesettings, $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
-> $streditcoursesettings", $editform->focus());
$navlinks[] = array('name' => $streditcoursesettings,
'link' => null,
'type' => 'misc');
$title = $streditcoursesettings;
$fullname = $course->fullname;
} else {
print_header("$site->shortname: $straddnewcourse", $site->fullname,
"<a href=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</a> -> ".
"<a href=\"index.php\">$strcategories</a> -> $straddnewcourse", $editform->focus());
$navlinks[] = array('name' => $stradministration,
'link' => "$CFG->wwwroot/$CFG->admin/index.php",
'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);

$editform->display();
Expand Down
Loading

0 comments on commit 73c24ef

Please sign in to comment.