diff --git a/admin/pagelib.php b/admin/pagelib.php deleted file mode 100644 index 62c76cd7674..00000000000 --- a/admin/pagelib.php +++ /dev/null @@ -1,67 +0,0 @@ -libdir.'/pagelib.php'); - -define('PAGE_ADMIN', 'admin'); - -// Bounds for block widths -// more flexible for theme designers taken from theme config.php -$lmin = (empty($THEME->block_l_min_width)) ? 0 : $THEME->block_l_min_width; -$lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width; -$rmin = (empty($THEME->block_r_min_width)) ? 0 : $THEME->block_r_min_width; -$rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width; - -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 { - var $extrabutton = ''; - - /** - * Use this to pass extra HTML that is added after the turn blocks editing on/off button. - * - * @param string $extrabutton HTML code. - */ - function set_extra_button($extrabutton) { - $this->extrabutton = $extrabutton; - } - - function print_header($focus='') { - global $USER, $CFG, $SITE; - - $adminroot = admin_get_root(false, false); //settings not required - only pages - - // fetch the path parameter - $section = $this->url->param('section'); - $current = $adminroot->locate($section, true); - $visiblepathtosection = array_reverse($current->visiblepath); - - // The search page currently doesn't handle block editing - if ($this->user_allowed_editing()) { - $options = $this->url->params(); - if ($this->user_is_editing()) { - $caption = get_string('blockseditoff'); - $options['adminedit'] = 'off'; - } else { - $caption = get_string('blocksediton'); - $options['adminedit'] = 'on'; - } - $buttons = print_single_button($this->url->out(false), $options, $caption, 'get', '', true); - } - $buttons .= $this->extrabutton; - - $navlinks = array(); - foreach ($visiblepathtosection as $element) { - $navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc'); - } - $navigation = build_navigation($navlinks); - - print_header("$SITE->shortname: " . implode(": ",$visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, ''); - } -} - -?> diff --git a/admin/settings.php b/admin/settings.php index 1e9d4a7e23a..da6ca837c3a 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -5,24 +5,25 @@ require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/blocklib.php'); require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php'); -$section = required_param('section', PARAM_SAFEDIR); -$return = optional_param('return','', PARAM_ALPHA); +$section = required_param('section', PARAM_SAFEDIR); +$return = optional_param('return','', PARAM_ALPHA); $adminediting = optional_param('adminedit', -1, PARAM_BOOL); /// no guest autologin require_login(0, false); $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); $PAGE->set_url($CFG->admin . '/settings.php', array('section' => $section)); +$PAGE->set_pagetype('admin-setting-' . $section); $adminroot = admin_get_root(); // need all settings -$page = $adminroot->locate($section); +$settingspage = $adminroot->locate($section, true); -if (empty($page) or !($page instanceof admin_settingpage)) { +if (empty($settingspage) or !($settingspage instanceof admin_settingpage)) { print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/"); die; } -if (!($page->check_access())) { +if (!($settingspage->check_access())) { print_error('accessdenied', 'admin'); die; } @@ -40,7 +41,7 @@ if ($data = data_submitted() and confirm_sesskey()) { if (empty($adminroot->errors)) { switch ($return) { - case 'site': redirect("$CFG->wwwroot/"); + case 'site': redirect("$CFG->wwwroot/"); case 'admin': redirect("$CFG->wwwroot/$CFG->admin/"); } } else { @@ -48,25 +49,17 @@ if ($data = data_submitted() and confirm_sesskey()) { $firsterror = reset($adminroot->errors); $focus = $firsterror->id; } - $adminroot =& admin_get_root(true); //reload tree - $page =& $adminroot->locate($section); + $adminroot = admin_get_root(true); //reload tree + $settingspage = $adminroot->locate($section); } -/// very hacky page setup -page_map_class(PAGE_ADMIN, 'page_admin'); -$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number -$PAGE->set_pagetype('admin-setting-' . $section); -$PAGE->init_extra($section); - if ($PAGE->user_allowed_editing() && $adminediting != -1) { $USER->editing = $adminediting; } - /// print header stuff ------------------------------------------------------------ - if (empty($SITE->fullname)) { - print_header($page->visiblename, $page->visiblename, '', $focus); + print_header($settingspage->visiblename, $settingspage->visiblename, '', $focus); print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%'); if ($errormsg !== '') { @@ -80,11 +73,11 @@ if (empty($SITE->fullname)) { echo '