summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/block_manager.php29
-rw-r--r--core/helpers/core_block.php14
-rw-r--r--core/helpers/core_installer.php1
3 files changed, 29 insertions, 15 deletions
diff --git a/core/helpers/block_manager.php b/core/helpers/block_manager.php
index d7a2aca9..724f1927 100644
--- a/core/helpers/block_manager.php
+++ b/core/helpers/block_manager.php
@@ -18,20 +18,24 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class block_manager_Core {
- static function get_active() {
- return unserialize(module::get_var("core", "blocks", "a:0:{}"));
+ static function get_active($location) {
+ return unserialize(module::get_var("core", "blocks_$location", "a:0:{}"));
+ }
+
+ static function set_active($location, $blocks) {
+ module::set_var("core", "blocks_$location", serialize($blocks));
}
static function add($location, $module_name, $block_id) {
- $blocks = self::get_active();
- $blocks[$location][rand()] = array($module_name, $block_id);
- module::set_var("core", "blocks", serialize($blocks));
+ $blocks = self::get_active($location);
+ $blocks[rand()] = array($module_name, $block_id);
+ self::set_active($location, $blocks);
}
static function remove($location, $block_id) {
- $blocks = self::get_active();
- unset($blocks[$location][$block_id]);
- module::set_var("core", "blocks", serialize($blocks));
+ $blocks = self::get_active($location);
+ unset($blocks[$block_id]);
+ self::set_active($location, $blocks);
}
static function get_available() {
@@ -49,12 +53,8 @@ class block_manager_Core {
}
static function get_html($location) {
- $active = self::get_active();
- if (empty($active[$location])) {
- return;
- }
-
- foreach ($active[$location] as $id => $desc) {
+ $active = self::get_active($location);
+ foreach ($active as $id => $desc) {
if (method_exists("$desc[0]_block", "get")) {
$block = call_user_func(array("$desc[0]_block", "get"), $desc[1]);
$block->id = $id;
@@ -64,4 +64,3 @@ class block_manager_Core {
return $result;
}
}
-
diff --git a/core/helpers/core_block.php b/core/helpers/core_block.php
index 74b81d52..bfc55f09 100644
--- a/core/helpers/core_block.php
+++ b/core/helpers/core_block.php
@@ -72,8 +72,22 @@ class core_block_Core {
$block->content = new View("admin_block_news.html");
$block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3);
break;
+
+ case "block_adder":
+ $block->css_id = "gBlockAdder";
+ $block->title = t("Dashboard Content");
+ $block->content = self::get_add_block_form();
}
return $block;
}
+
+ public function get_add_block_form() {
+ $form = new Forge("admin/dashboard/add_block", "", "post");
+ $group = $form->group("add_block")->label(t("Add Block"));
+ $group->dropdown("id")->label("Available Blocks")->options(block_manager::get_available());
+ $group->submit("center")->value(t("Add to center"));
+ $group->submit("sidebar")->value(t("Add to sidebar"));
+ return $form;
+ }
} \ No newline at end of file
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index c7d32963..bf56ca55 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -234,6 +234,7 @@ class core_installer {
$theme->save();
}
+ block_manager::add("dashboard_sidebar", "core", "block_adder");
block_manager::add("dashboard_sidebar", "core", "stats");
block_manager::add("dashboard_sidebar", "core", "platform_info");
block_manager::add("dashboard_sidebar", "core", "project_news");