mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
fixes for new admin blocks
This commit is contained in:
parent
623942afff
commit
02cc05a708
@ -325,7 +325,7 @@
|
||||
/// 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 = "";
|
||||
@ -358,6 +358,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 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));
|
||||
@ -612,4 +622,4 @@
|
||||
|
||||
|
||||
|
||||
?>
|
||||
?>
|
@ -2,7 +2,7 @@
|
||||
|
||||
require_once($CFG->libdir.'/pagelib.php');
|
||||
|
||||
define('PAGE_ADMIN', 'admin-index');
|
||||
define('PAGE_ADMIN', 'admin');
|
||||
|
||||
page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
|
||||
@ -12,7 +12,10 @@ class page_admin extends page_base {
|
||||
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) {
|
||||
@ -39,9 +42,9 @@ class page_admin extends page_base {
|
||||
// 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
|
||||
|
@ -2,27 +2,23 @@
|
||||
|
||||
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);
|
||||
|
@ -45,7 +45,7 @@ class block_activity_modules extends block_list {
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('all' => true, 'mod' => false, 'my' => false);
|
||||
return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ class block_admin extends block_list {
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('all' => true, 'mod' => false, 'my' => false);
|
||||
return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,12 @@
|
||||
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() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php // $Id$
|
||||
|
||||
class block_admin_2 extends block_base {
|
||||
class block_admin_tree extends block_base {
|
||||
|
||||
var $currentdepth;
|
||||
var $spancounter;
|
||||
@ -11,8 +11,8 @@ class block_admin_2 extends block_base {
|
||||
|
||||
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 = '';
|
||||
@ -21,6 +21,10 @@ class block_admin_2 extends block_base {
|
||||
$this->expandjavascript = '';
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('site' => true, 'admin' => true);
|
||||
}
|
||||
|
||||
function preferred_width() {
|
||||
return 210;
|
||||
}
|
||||
@ -31,7 +35,7 @@ class block_admin_2 extends block_base {
|
||||
$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++;
|
||||
@ -54,11 +58,11 @@ class block_admin_2 extends block_base {
|
||||
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()) {
|
||||
@ -131,11 +135,11 @@ class block_admin_2 extends block_base {
|
||||
$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";
|
||||
|
||||
@ -143,13 +147,13 @@ class block_admin_2 extends block_base {
|
||||
$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";
|
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 76 B |
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 68 B |
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 79 B |
@ -289,7 +289,7 @@ class block_base {
|
||||
*/
|
||||
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);
|
||||
@ -340,7 +340,11 @@ class block_base {
|
||||
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
|
||||
|
@ -2181,20 +2181,16 @@ function admin_externalpage_setup($section, $adminroot) {
|
||||
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);
|
||||
|
||||
|
@ -682,7 +682,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
|
||||
|
||||
// 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user