From 7b68ca9946772fdb8fa2db756e934cc7883ea52d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 18 Jan 2009 06:55:04 +0000 Subject: Refactor dashboard -> block_manager since it'll manage blocks site wide, not just in the dashboard. --- core/helpers/block_manager.php | 67 ++++++++++++++++++++++++++++++++++ core/helpers/core_block.php | 79 +++++++++++++++++++++++++++++++++++++++++ core/helpers/core_dashboard.php | 79 ----------------------------------------- core/helpers/core_installer.php | 12 +++---- core/helpers/dashboard.php | 63 -------------------------------- 5 files changed, 152 insertions(+), 148 deletions(-) create mode 100644 core/helpers/block_manager.php create mode 100644 core/helpers/core_block.php delete mode 100644 core/helpers/core_dashboard.php delete mode 100644 core/helpers/dashboard.php (limited to 'core/helpers') diff --git a/core/helpers/block_manager.php b/core/helpers/block_manager.php new file mode 100644 index 00000000..d7a2aca9 --- /dev/null +++ b/core/helpers/block_manager.php @@ -0,0 +1,67 @@ +name}_block"; + if (method_exists($class_name, "get_list")) { + foreach (call_user_func(array($class_name, "get_list")) as $id => $title) { + $blocks["{$module->name}:$id"] = $title; + } + } + } + return $blocks; + } + + static function get_html($location) { + $active = self::get_active(); + if (empty($active[$location])) { + return; + } + + foreach ($active[$location] as $id => $desc) { + if (method_exists("$desc[0]_block", "get")) { + $block = call_user_func(array("$desc[0]_block", "get"), $desc[1]); + $block->id = $id; + $result .= $block; + } + } + return $result; + } +} + diff --git a/core/helpers/core_block.php b/core/helpers/core_block.php new file mode 100644 index 00000000..74b81d52 --- /dev/null +++ b/core/helpers/core_block.php @@ -0,0 +1,79 @@ + t("Welcome to Gallery 3!"), + "photo_stream" => t("Photo Stream"), + "log_entries" => t("Log Entries"), + "stats" => t("Gallery Stats"), + "platform_info" => t("Platform Information"), + "project_news" => t("Gallery Project News")); + } + + static function get($block_id) { + $block = new Block(); + switch($block_id) { + case "welcome": + $block->css_id = "gWelcome"; + $block->title = t("Welcome to Gallery3"); + $block->content = new View("admin_block_welcome.html"); + break; + + case "photo_stream": + $block->css_id = "gPhotoStream"; + $block->title = t("Photo Stream"); + $block->content = new View("admin_block_photo_stream.html"); + $block->content->photos = + ORM::factory("item")->where("type", "photo")->orderby("created", "desc")->find_all(10); + break; + + case "log_entries": + $block->css_id = "gLogEntries"; + $block->title = t("Log Entries"); + $block->content = new View("admin_block_log_entries.html"); + $block->content->entries = ORM::factory("log")->orderby("timestamp", "desc")->find_all(5); + break; + + case "stats": + $block->css_id = "gStats"; + $block->title = t("Gallery Stats"); + $block->content = new View("admin_block_stats.html"); + $block->content->album_count = ORM::factory("item")->where("type", "album")->count_all(); + $block->content->photo_count = ORM::factory("item")->where("type", "photo")->count_all(); + break; + + case "platform_info": + $block->css_id = "gPlatform"; + $block->title = t("Platform Information"); + $block->content = new View("admin_block_platform.html"); + break; + + case "project_news": + $block->css_id = "gProjectNews"; + $block->title = t("Gallery Project News"); + $block->content = new View("admin_block_news.html"); + $block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3); + break; + } + + return $block; + } +} \ No newline at end of file diff --git a/core/helpers/core_dashboard.php b/core/helpers/core_dashboard.php deleted file mode 100644 index 8efba3ea..00000000 --- a/core/helpers/core_dashboard.php +++ /dev/null @@ -1,79 +0,0 @@ - t("Welcome to Gallery 3!"), - "photo_stream" => t("Photo Stream"), - "log_entries" => t("Log Entries"), - "stats" => t("Gallery Stats"), - "platform_info" => t("Platform Information"), - "project_news" => t("Gallery Project News")); - } - - static function get_block($block_id) { - $block = new Block(); - switch($block_id) { - case "welcome": - $block->css_id = "gWelcome"; - $block->title = t("Welcome to Gallery3"); - $block->content = new View("admin_block_welcome.html"); - break; - - case "photo_stream": - $block->css_id = "gPhotoStream"; - $block->title = t("Photo Stream"); - $block->content = new View("admin_block_photo_stream.html"); - $block->content->photos = - ORM::factory("item")->where("type", "photo")->orderby("created", "desc")->find_all(10); - break; - - case "log_entries": - $block->css_id = "gLogEntries"; - $block->title = t("Log Entries"); - $block->content = new View("admin_block_log_entries.html"); - $block->content->entries = ORM::factory("log")->orderby("timestamp", "desc")->find_all(5); - break; - - case "stats": - $block->css_id = "gStats"; - $block->title = t("Gallery Stats"); - $block->content = new View("admin_block_stats.html"); - $block->content->album_count = ORM::factory("item")->where("type", "album")->count_all(); - $block->content->photo_count = ORM::factory("item")->where("type", "photo")->count_all(); - break; - - case "platform_info": - $block->css_id = "gPlatform"; - $block->title = t("Platform Information"); - $block->content = new View("admin_block_platform.html"); - break; - - case "project_news": - $block->css_id = "gProjectNews"; - $block->title = t("Gallery Project News"); - $block->content = new View("admin_block_news.html"); - $block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3); - break; - } - - return $block; - } -} \ No newline at end of file diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index b8f50561..c7d32963 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -234,12 +234,12 @@ class core_installer { $theme->save(); } - dashboard::add_block("sidebar", "core", "stats"); - dashboard::add_block("sidebar", "core", "platform_info"); - dashboard::add_block("sidebar", "core", "project_news"); - dashboard::add_block("main", "core", "welcome"); - dashboard::add_block("main", "core", "photo_stream"); - dashboard::add_block("main", "core", "log_entries"); + block_manager::add("dashboard_sidebar", "core", "stats"); + block_manager::add("dashboard_sidebar", "core", "platform_info"); + block_manager::add("dashboard_sidebar", "core", "project_news"); + block_manager::add("dashboard_center", "core", "welcome"); + block_manager::add("dashboard_center", "core", "photo_stream"); + block_manager::add("dashboard_center", "core", "log_entries"); module::set_version("core", 1); module::set_var("core", "version", "3.0"); diff --git a/core/helpers/dashboard.php b/core/helpers/dashboard.php deleted file mode 100644 index 8e6f6aaa..00000000 --- a/core/helpers/dashboard.php +++ /dev/null @@ -1,63 +0,0 @@ -name}_dashboard", "get_list")) { - foreach (call_user_func(array("{$module->name}_dashboard", "get_list")) as $id => $title) { - $blocks["{$module->name}:$id"] = $title; - } - } - } - return $blocks; - } - - static function get_blocks($blocks) { - $result = ""; - foreach ($blocks as $id => $desc) { - if (method_exists("$desc[0]_dashboard", "get_block")) { - $block = call_user_func(array("$desc[0]_dashboard", "get_block"), $desc[1]); - $block->id = $id; - $result .= $block; - } - } - return $result; - } -} - -- cgit v1.2.3