| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: pagelib.php,v 1.23.2.2 2008/05/02 04:07:28 dongsheng Exp $ 2 3 require_once($CFG->libdir.'/pagelib.php'); 4 5 define('PAGE_ADMIN', 'admin'); 6 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; 13 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); 18 19 page_map_class(PAGE_ADMIN, 'page_admin'); 20 21 class page_admin extends page_base { 22 23 var $section; 24 var $visiblepathtosection; 25 26 // hack alert! 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) { 30 global $CFG; 31 32 if($this->full_init_done) { 33 return; 34 } 35 36 $adminroot =& admin_get_root(false, false); //settings not required - only pages 37 38 // fetch the path parameter 39 $this->section = $section; 40 $current =& $adminroot->locate($section, true); 41 $this->visiblepathtosection = array_reverse($current->visiblepath); 42 43 // all done 44 $this->full_init_done = true; 45 } 46 47 function blocks_get_default() { 48 return 'admin_tree,admin_bookmarks'; 49 } 50 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)); 55 } 56 57 // has to be fixed. i know there's a "proper" way to do this 58 function user_is_editing() { 59 global $USER; 60 return $USER->adminediting; 61 } 62 63 function url_get_path() { 64 global $CFG; 65 66 $adminroot =& admin_get_root(false, false); //settings not required - only pages 67 68 $root =& $adminroot->locate($this->section); 69 if (is_a($root, 'admin_externalpage')) { 70 return $root->url; 71 } else { 72 return ($CFG->wwwroot . '/' . $CFG->admin . '/settings.php'); 73 } 74 } 75 76 function url_get_parameters() { // only handles parameters relevant to the admin pagetype 77 return array('section' => (isset($this->section) ? $this->section : '')); 78 } 79 80 function blocks_get_positions() { 81 return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT); 82 } 83 84 function blocks_default_position() { 85 return BLOCK_POS_LEFT; 86 } 87 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; 93 } 94 return $instance->position; 95 } 96 97 // does anything need to be done here? 98 function init_quick($data) { 99 parent::init_quick($data); 100 } 101 102 function print_header($section = '', $focus='') { 103 global $USER, $CFG, $SITE; 104 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 107 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>'; 114 } else { 115 $buttons = ' '; 116 } 117 118 $navlinks = array(); 119 foreach ($this->visiblepathtosection as $element) { 120 $navlinks[] = array('name' => $element, 'link' => null, 'type' => 'misc'); 121 } 122 $navigation = build_navigation($navlinks); 123 124 print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, $navigation, $focus, '', true, $buttons, ''); 125 } 126 127 function get_type() { 128 return PAGE_ADMIN; 129 } 130 } 131 132 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |