3 require_once($CFG->libdir
.'/pagelib.php');
5 define('PAGE_ADMIN', 'admin');
7 // Bounds for block widths
8 // more flexible for theme designers taken from theme config.php
9 $lmin = (empty($THEME->block_l_min_width
)) ?
0 : $THEME->block_l_min_width
;
10 $lmax = (empty($THEME->block_l_max_width
)) ?
210 : $THEME->block_l_max_width
;
11 $rmin = (empty($THEME->block_r_min_width
)) ?
0 : $THEME->block_r_min_width
;
12 $rmax = (empty($THEME->block_r_max_width
)) ?
210 : $THEME->block_r_max_width
;
14 define('BLOCK_L_MIN_WIDTH', $lmin);
15 define('BLOCK_L_MAX_WIDTH', $lmax);
16 define('BLOCK_R_MIN_WIDTH', $rmin);
17 define('BLOCK_R_MAX_WIDTH', $rmax);
19 page_map_class(PAGE_ADMIN
, 'page_admin');
21 class page_admin
extends page_base
{
24 var $visiblepathtosection;
27 // this function works around the inability to store the section name
28 // in default block, maybe we should "improve" the blocks a bit?
29 function init_extra($section) {
32 if($this->full_init_done
) {
36 $adminroot =& admin_get_root(false, false); //settings not required - only pages
38 // fetch the path parameter
39 $this->section
= $section;
40 $current =& $adminroot->locate($section, true);
41 $this->visiblepathtosection
= array_reverse($current->visiblepath
);
44 $this->full_init_done
= true;
47 function blocks_get_default() {
48 return 'admin_tree,admin_bookmarks';
51 // seems reasonable that the only people that can edit blocks on the admin pages
52 // are the admins... but maybe we want a role for this?
53 function user_allowed_editing() {
54 return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM
));
57 // has to be fixed. i know there's a "proper" way to do this
58 function user_is_editing() {
60 return $USER->adminediting
;
63 function url_get_path() {
66 $adminroot =& admin_get_root(false, false); //settings not required - only pages
68 $root =& $adminroot->locate($this->section
);
69 if (is_a($root, 'admin_externalpage')) {
72 return ($CFG->wwwroot
. '/' . $CFG->admin
. '/settings.php');
76 function url_get_parameters() { // only handles parameters relevant to the admin pagetype
77 return array('section' => (isset($this->section
) ?
$this->section
: ''));
80 function blocks_get_positions() {
81 return array(BLOCK_POS_LEFT
, BLOCK_POS_RIGHT
);
84 function blocks_default_position() {
85 return BLOCK_POS_LEFT
;
88 function blocks_move_position(&$instance, $move) {
89 if($instance->position
== BLOCK_POS_LEFT
&& $move == BLOCK_MOVE_RIGHT
) {
90 return BLOCK_POS_RIGHT
;
91 } else if ($instance->position
== BLOCK_POS_RIGHT
&& $move == BLOCK_MOVE_LEFT
) {
92 return BLOCK_POS_LEFT
;
94 return $instance->position
;
97 // does anything need to be done here?
98 function init_quick($data) {
99 parent
::init_quick($data);
102 function print_header($section = '', $focus='') {
103 global $USER, $CFG, $SITE;
105 $this->init_full($section); // we're trusting that init_full() has already been called by now; it should have.
106 // if not, print_header() has to be called with a $section parameter
108 // The search page currently doesn't handle block editing
109 if ($this->section
!= 'search' and $this->user_allowed_editing()) {
110 $buttons = '<div><form '.$CFG->frametarget
.' method="get" action="' . $this->url_get_path() . '">'.
111 '<div><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?
'off':'on').'" />'.
112 '<input type="hidden" name="section" value="'.$this->section
.'" />'.
113 '<input type="submit" value="'.get_string($this->user_is_editing()?
'blockseditoff':'blocksediton').'" /></div></form></div>';
119 foreach ($this->visiblepathtosection
as $element) {
120 $navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc');
122 $navigation = build_navigation($navlinks);
124 print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection
), $SITE->fullname
, $navigation, $focus, '', true, $buttons, '');
127 function get_type() {