diff --git a/blocks/admin_2/block_admin_2.php b/blocks/admin_2/block_admin_2.php new file mode 100644 index 00000000000..ed4045cf8a6 --- /dev/null +++ b/blocks/admin_2/block_admin_2.php @@ -0,0 +1,175 @@ +title = "Administration (Beta)"; + $this->version = 2006081800; + $this->currentdepth = 0; + $this->spancounter = 1; + $this->tempcontent = ''; + $this->section = optional_param("section","",PARAM_PATH); + $this->pathtosection = array(); + $this->expandjavascript = ''; + } + + function preferred_width() { + return 210; + } + + function open_folder($visiblename) { + global $CFG; + for ($i = 0; $i < $this->currentdepth; $i++) { + $this->tempcontent .= "   "; + } + $this->tempcontent .= ''; + $this->tempcontent .= '[open folder] '; + $this->tempcontent .= $visiblename . '
' . "\n"; + $this->currentdepth++; + $this->spancounter++; + } + + function close_folder() { + $this->currentdepth--; + $this->tempcontent .= "\n"; + } + + function create_item($visiblename,$link,$icon) { + global $CFG; + for ($i = 0; $i < $this->currentdepth; $i++) { + $this->tempcontent .= "   "; + } + $this->tempcontent .= '[item] ' . $visiblename . '
' . "\n"; + } + + function build_tree (&$content) { + global $CFG; + if ($content instanceof 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'); + } + } else if ($content instanceof admin_externalpage) { + if ($content->check_access()) { + $this->create_item($content->visiblename, $content->url, $CFG->wwwroot . '/blocks/admin_2/item.gif'); + } + } else if ($content instanceof admin_category) { + if ($content->check_access()) { + + // check if the category we're currently printing is a parent category for the current page; if it is, we + // make a note (in the javascript) that it has to be expanded after the page has loaded + if ($this->pathtosection[count($this->pathtosection) - 1] == $content->name) { + $this->expandjavascript .= 'expand("vh_span' . ($this->spancounter) . '");' . "\n"; + array_pop($this->pathtosection); + } + + $this->open_folder($content->visiblename); + + foreach ($content->children as &$child) { + $this->build_tree($child); + } + + $this->close_folder(); + } + } + } + + function get_content() { + + global $CFG, $ADMIN; + + // better place to require this? + if (!$ADMIN) { + require_once($CFG->dirroot . '/admin/adminlib.php'); + } + + if ($this->content !== NULL) { + return $this->content; + } + + if ($this->pathtosection = $ADMIN->path($this->section)) { + $this->pathtosection = array_reverse($this->pathtosection); + array_pop($this->pathtosection); + } + + // we need to do this instead of $this->build_tree($ADMIN) because the top-level folder + // is redundant (and ideally ignored). (the top-level folder is "administration".) + ksort($ADMIN->children); + foreach ($ADMIN->children as &$child) { + $this->build_tree($child); + } + + if ($this->tempcontent !== '') { + $this->content = new stdClass; + $this->content->text = '' . "\n"; + $this->content->text .= '
' . "\n"; + + $this->content->text .= $this->tempcontent; + + $this->content->text .= '
' . "\n"; + $this->content->text .= '' . "\n"; + } + return $this->content; + + } +} + +?> diff --git a/blocks/admin_2/closed.gif b/blocks/admin_2/closed.gif new file mode 100644 index 00000000000..43024ee3702 Binary files /dev/null and b/blocks/admin_2/closed.gif differ diff --git a/blocks/admin_2/item.gif b/blocks/admin_2/item.gif new file mode 100644 index 00000000000..8828bd8b8f2 Binary files /dev/null and b/blocks/admin_2/item.gif differ diff --git a/blocks/admin_2/open.gif b/blocks/admin_2/open.gif new file mode 100644 index 00000000000..9efbec93267 Binary files /dev/null and b/blocks/admin_2/open.gif differ