From c74af0688f7f958a2eaf2c7e020646fd6d7a660a Mon Sep 17 00:00:00 2001 From: vinkmar Date: Fri, 18 Aug 2006 08:24:07 +0000 Subject: [PATCH] adding admin page cleanup blocks (new ones!) --- blocks/admin_2/block_admin_2.php | 175 +++++++++++++++++++++++++++++++ blocks/admin_2/closed.gif | Bin 0 -> 76 bytes blocks/admin_2/item.gif | Bin 0 -> 68 bytes blocks/admin_2/open.gif | Bin 0 -> 79 bytes 4 files changed, 175 insertions(+) create mode 100644 blocks/admin_2/block_admin_2.php create mode 100644 blocks/admin_2/closed.gif create mode 100644 blocks/admin_2/item.gif create mode 100644 blocks/admin_2/open.gif 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 0000000000000000000000000000000000000000..43024ee37027e793946bf19d005290629608db22 GIT binary patch literal 76 zcmZ?wbhEHb6lCCMn8*ME|G@yrQ2fcl$iTqFpaT*G$uls?PU&BH`YuDG@Wxvz@?}52 Vd=0#_Oi}S=hp literal 0 HcmV?d00001 diff --git a/blocks/admin_2/item.gif b/blocks/admin_2/item.gif new file mode 100644 index 0000000000000000000000000000000000000000..8828bd8b8f2d25560ad480b086d9c03e4c2aa7ca GIT binary patch literal 68 zcmZ?wbhEHb6lCCMn8*ME|G@yrQ2fcl$iTqFpaT*G$ulsCPU&BH`Yr!rn+0JR?@u$N N=leeLFk)q}1^|g76d?cr literal 0 HcmV?d00001 diff --git a/blocks/admin_2/open.gif b/blocks/admin_2/open.gif new file mode 100644 index 0000000000000000000000000000000000000000..9efbec93267b1aa20a39598b42f2970f69763eb9 GIT binary patch literal 79 zcmZ?wbhEHb6lCCMn8*ME|G@yrQ2fcl$iTqFpaT*G$ulr1OzB^F`YuDGu)xt7PfkCp Y@+s|8%j}8Fb+3w=Z+`UC91#X<0GL4