diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-09-30 17:30:01 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-09-30 17:30:01 -0700 |
commit | 81eaf1e46cb1646bf6b5d5c2f86ea3b3c7a0bd06 (patch) | |
tree | 55c08dfa432a20eae6bb99a8723e65239d4a4d34 /modules/gallery/helpers/block_manager.php | |
parent | e197e4017daa0833cec84d8392e4d05cdf81503d (diff) |
Add functionality to activate sidebar blocks when the module is activated and deactivate the sidebar blocks when the module is deactivated.
Diffstat (limited to 'modules/gallery/helpers/block_manager.php')
-rw-r--r-- | modules/gallery/helpers/block_manager.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php index 233e4f2e..906a251d 100644 --- a/modules/gallery/helpers/block_manager.php +++ b/modules/gallery/helpers/block_manager.php @@ -32,12 +32,35 @@ class block_manager_Core { self::set_active($location, $blocks); } + static function activate_sidebar_blocks($module_name) { + $block_class = "{$module_name}_block"; + if (method_exists($block_class, "get_site_list")) { + $blocks = call_user_func(array($block_class, "get_site_list")); + Kohana::log("error", Kohana::debug($blocks)); + foreach (array_keys($blocks) as $id) { + list ($unused, $block_id) = explode(":", $id); + self::add("site.sidebar", $module_name, $block_id); + } + } + } + static function remove($location, $block_id) { $blocks = self::get_active($location); unset($blocks[$block_id]); self::set_active($location, $blocks); } + static function deactivate_sidebar_blocks($module_name) { + $block_class = "{$module_name}_block"; + if (method_exists($block_class, "get_site_list")) { + $blocks = call_user_func(array($block_class, "get_site_list")); + foreach (array_keys($blocks) as $id) { + list ($unused, $block_id) = explode(":", $id); + self::remove("site.sidebar", $module_name, $block_id); + } + } + } + static function get_available_admin_blocks() { return self::_get_blocks("get_admin_list"); } |