/// Set up the blank site - to be customized later at the end of install.
if (! $site = get_site()) {
// We are about to create the site "course"
- require_once($CFG->dirroot.'/lib/blocklib.php');
+ require_once($CFG->libdir.'/blocklib.php');
$newsite = new Object();
$newsite->fullname = "";
}
}
+ // initialise default blocks on admin page if needed
+ if (empty($CFG->adminblocks_initialised)) {
+ require_once("$CFG->dirroot/$CFG->admin/pagelib.php");
+ require_once($CFG->libdir.'/blocklib.php');
+ page_map_class(PAGE_ADMIN, 'page_admin');
+ $page = page_create_object(PAGE_ADMIN, 0); // there must be some id number
+ blocks_repopulate_page($page);
+ set_config('adminblocks_initialised', 1);
+ }
+
/// Define the unique site ID code if it isn't already
if (empty($CFG->siteidentifier)) { // Unique site identification code
set_config('siteidentifier', random_string(32));
-?>
+?>
\ No newline at end of file
require_once($CFG->libdir.'/pagelib.php');
-define('PAGE_ADMIN', 'admin-index');
+define('PAGE_ADMIN', 'admin');
page_map_class(PAGE_ADMIN, 'page_admin');
var $pathtosection;
var $visiblepathtosection;
- function init_full($section) {
+ // 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) {
global $CFG;
if($this->full_init_done) {
// all done
$this->full_init_done = true;
}
-
+
function blocks_get_default() {
- return 'admin_2,admin_bookmarks';
+ return 'admin_tree,admin_bookmarks';
}
// seems reasonable that the only people that can edit blocks on the admin pages
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir . '/blocklib.php');
-require_once($CFG->dirroot . '/admin/pagelib.php');
+require_once($CFG->libdir.'/blocklib.php');
+require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
if ($site = get_site()) {
require_login();
}
-define('TEMPORARY_ADMIN_PAGE_ID',26);
-
define('BLOCK_L_MIN_WIDTH',160);
define('BLOCK_L_MAX_WIDTH',210);
-$pagetype = PAGE_ADMIN;
-$pageclass = 'page_admin';
-page_map_class($pagetype, $pageclass);
+page_map_class(PAGE_ADMIN, 'page_admin');
-$PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID);
+$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be some id number
$section = optional_param('section', '', PARAM_ALPHAEXT);
-$PAGE->init_full($section);
+$PAGE->init_extra($section); // hack alert!
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
$return = optional_param('return','', PARAM_ALPHA);
}
function applicable_formats() {
- return array('all' => true, 'mod' => false, 'my' => false);
+ return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false);
}
}
}
function applicable_formats() {
- return array('all' => true, 'mod' => false, 'my' => false);
+ return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false);
}
}
class block_admin_bookmarks extends block_base {
function init() {
- $this->title = "Admin Bookmarks";
- $this->version = 2006081800;
+ $this->title = get_string('adminbookmarks');
+ $this->version = 2006090300;
+ }
+
+ function applicable_formats() {
+ return array('site' => true, 'admin' => true);
}
function preferred_width() {
<?php // $Id$
-class block_admin_2 extends block_base {
+class block_admin_tree extends block_base {
var $currentdepth;
var $spancounter;
function init() {
global $PAGE;
- $this->title = "Administration (Beta)";
- $this->version = 2006081800;
+ $this->title = get_string('admintree');
+ $this->version = 2006090300;
$this->currentdepth = 0;
$this->spancounter = 1;
$this->tempcontent = '';
$this->expandjavascript = '';
}
+ function applicable_formats() {
+ return array('site' => true, 'admin' => true);
+ }
+
function preferred_width() {
return 210;
}
$this->tempcontent .= " ";
}
$this->tempcontent .= '<a href="javascript:toggle(\'vh_span' . $this->spancounter . '\');">';
- $this->tempcontent .= '<span id="vh_span' . $this->spancounter . 'indicator"><img src="' . $CFG->wwwroot . '/blocks/admin_2/open.gif" border="0" alt="[open folder]" /></span> ';
+ $this->tempcontent .= '<span id="vh_span' . $this->spancounter . 'indicator"><img src="' . $CFG->wwwroot . '/blocks/admin_tree/open.gif" border="0" alt="[open folder]" /></span> ';
$this->tempcontent .= $visiblename . '</a><br /><span id="vh_span' . $this->spancounter . '">' . "\n";
$this->currentdepth++;
$this->spancounter++;
global $CFG;
if (is_a($content, 'admin_settingpage')) {
if ($content->check_access()) {
- $this->create_item($content->visiblename,$CFG->wwwroot.'/admin/settings.php?section=' . $content->name,$CFG->wwwroot .'/blocks/admin_2/item.gif');
+ $this->create_item($content->visiblename,$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=' . $content->name,$CFG->wwwroot .'/blocks/admin_tree/item.gif');
}
} else if (is_a($content, 'admin_externalpage')) {
if ($content->check_access()) {
- $this->create_item($content->visiblename, $content->url, $CFG->wwwroot . '/blocks/admin_2/item.gif');
+ $this->create_item($content->visiblename, $content->url, $CFG->wwwroot . '/blocks/admin_tree/item.gif');
}
} else if (is_a($content, 'admin_category')) {
if ($content->check_access()) {
$this->content->text .= 'function toggle(spanid) {' . "\n";
$this->content->text .= ' if (getspan(spanid).innerHTML == "") {' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_tree/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
$this->content->text .= ' } else {' . "\n";
$this->content->text .= ' vh_content[spanid] = getspan(spanid).innerHTML;' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = "";' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_tree/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
$this->content->text .= ' }' . "\n";
$this->content->text .= '}' . "\n";
$this->content->text .= ' if (getspan(spanid).innerHTML !== "") {' . "\n";
$this->content->text .= ' vh_content[spanid] = getspan(spanid).innerHTML;' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = "";' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_tree/closed.gif\" border=\"0\" alt=\"[closed folder]\" />";' . "\n";
$this->content->text .= ' }' . "\n";
$this->content->text .= '}' . "\n";
$this->content->text .= 'function expand(spanid) {' . "\n";
$this->content->text .= ' getspan(spanid).innerHTML = vh_content[spanid];' . "\n";
- $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_2/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
+ $this->content->text .= ' getspan(spanid + "indicator").innerHTML = "<img src=\"' . $CFG->wwwroot . '/blocks/admin_tree/open.gif\" border=\"0\" alt=\"[open folder]\" />";' . "\n";
$this->content->text .= '}' . "\n";
$this->content->text .= 'function expandall() {' . "\n";
*/
function _add_edit_controls($options) {
- global $CFG, $USER;
+ global $CFG, $USER, $PAGE;
// this is the context relevant to this particular block instance
$blockcontext = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
if (empty($this->instance->pageid)) {
$this->instance->pageid = 0;
}
- $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
+ if (!empty($PAGE->type) and ($this->instance->pagetype == $PAGE->type) and $this->instance->pageid == $PAGE->id) {
+ $page = $PAGE;
+ } else {
+ $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
+ }
$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey));
// place holder for roles button
global $CFG, $PAGE, $USER;
require_once($CFG->libdir . '/blocklib.php');
- require_once($CFG->dirroot . '/admin/pagelib.php');
+ require_once($CFG->dirroot . '/'.$CFG->admin.'/pagelib.php');
- define('TEMPORARY_ADMIN_PAGE_ID',26);
-
define('BLOCK_L_MIN_WIDTH',160);
define('BLOCK_L_MAX_WIDTH',210);
- $pagetype = PAGE_ADMIN;
- $pageclass = 'page_admin';
- page_map_class($pagetype, $pageclass);
+ page_map_class(PAGE_ADMIN, 'page_admin');
- $PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID);
+ $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be some id number
- $PAGE->init_full($section);
+ $PAGE->init_extra($section); // hack alert!
$root = $adminroot->locate($PAGE->section);
// You can use this to get the blocks to respond to URL actions without much hassle
function blocks_execute_url_action(&$PAGE, &$pageblocks,$pinned=false) {
- $blockaction = optional_param('blockaction');
+ $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
if (empty($blockaction) || !$PAGE->user_allowed_editing() || !confirm_sesskey()) {
return;