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

@ -15,7 +15,7 @@ define('BLOCK_L_MIN_WIDTH', $lmin);
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 {
@ -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) {
@ -40,7 +40,7 @@ class page_admin extends page_base {
$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)) {
@ -54,24 +54,24 @@ class page_admin extends page_base {
// 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();
@ -88,11 +88,11 @@ class page_admin extends page_base {
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;
}
@ -116,7 +116,7 @@ class page_admin extends page_base {
$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').'" />'.
@ -126,8 +126,13 @@ class page_admin extends page_base {
$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() {