diff options
-rw-r--r-- | core/controllers/admin_dashboard.php | 25 | ||||
-rw-r--r-- | core/helpers/block_manager.php (renamed from core/helpers/dashboard.php) | 32 | ||||
-rw-r--r-- | core/helpers/core_block.php (renamed from core/helpers/core_dashboard.php) | 4 | ||||
-rw-r--r-- | core/helpers/core_installer.php | 12 | ||||
-rw-r--r-- | core/views/welcome.html.php | 4 | ||||
-rw-r--r-- | modules/comment/helpers/comment_block.php (renamed from modules/comment/helpers/comment_dashboard.php) | 4 | ||||
-rw-r--r-- | modules/comment/helpers/comment_installer.php | 2 |
7 files changed, 43 insertions, 40 deletions
diff --git a/core/controllers/admin_dashboard.php b/core/controllers/admin_dashboard.php index 15701417..aeac75d8 100644 --- a/core/controllers/admin_dashboard.php +++ b/core/controllers/admin_dashboard.php @@ -27,8 +27,8 @@ class Admin_Dashboard_Controller extends Admin_Controller { $block_adder->content = $this->get_add_block_form(); $view = new Admin_View("admin.html"); - $view->content = dashboard::get_blocks($blocks["main"]); - $view->sidebar = $block_adder . dashboard::get_blocks($blocks["sidebar"]); + $view->content = block_manager::get_html("dashboard_center"); + $view->sidebar = $block_adder . block_manager::get_html("dashboard_sidebar"); print $view; } @@ -36,16 +36,16 @@ class Admin_Dashboard_Controller extends Admin_Controller { $form = $this->get_add_block_form(); if ($form->validate()) { list ($module_name, $block_id) = explode(":", $form->add_block->id->value); - $blocks = dashboard::get_active(); - $available = dashboard::get_available(); + $blocks = block_manager::get_active(); + $available = block_manager::get_available(); if ($form->add_block->center->value) { - dashboard::add_block("main", $module_name, $block_id); + block_manager::add("dashboard_center", $module_name, $block_id); message::success( - t("Added <b>%title</b> block to the main dashboard area", + t("Added <b>%title</b> block to the dashboard center", array("title" => $available["$module_name:$id"]))); } else { - dashboard::add_block("sidebar", $module_name, $block_id); + block_manager::add("dashboard_sidebar", $module_name, $block_id); message::success( t("Added <b>%title</b> to the dashboard sidebar", array("title" => $available["$module_name:$id"]))); @@ -56,17 +56,17 @@ class Admin_Dashboard_Controller extends Admin_Controller { public function remove_block($id) { access::verify_csrf(); - $blocks = dashboard::get_active(); + $blocks = block_manager::get_active(); if (array_key_exists($id, $blocks["sidebar"])) { $deleted = $blocks["sidebar"][$id]; - dashboard::remove_block("sidebar", $id); + block_manager::remove("dashboard_sidebar", $id); } else if (array_key_exists($id, $blocks["main"])) { $deleted = $blocks["main"][$id]; - dashboard::remove_block("main", $id); + block_manager::remove("dashboard_main", $id); } if (!empty($deleted)) { - $available = dashboard::get_available(); + $available = block_manager::get_available(); $title = $available[join(":", $deleted)]; message::success(t("Removed <b>%title</b> block", array("title" => $title))); } @@ -77,10 +77,9 @@ class Admin_Dashboard_Controller extends Admin_Controller { 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(dashboard::get_available()); + $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; } } - diff --git a/core/helpers/dashboard.php b/core/helpers/block_manager.php index 8e6f6aaa..d7a2aca9 100644 --- a/core/helpers/dashboard.php +++ b/core/helpers/block_manager.php @@ -17,30 +17,30 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class dashboard_Core { +class block_manager_Core { static function get_active() { - return unserialize(module::get_var("core", "dashboard_blocks", "a:0:{}")); + return unserialize(module::get_var("core", "blocks", "a:0:{}")); } - static function add_block($location, $module_name, $block_id) { + static function add($location, $module_name, $block_id) { $blocks = self::get_active(); $blocks[$location][rand()] = array($module_name, $block_id); - module::set_var("core", "dashboard_blocks", serialize($blocks)); + module::set_var("core", "blocks", serialize($blocks)); } - static function remove_block($location, $block_id) { + static function remove($location, $block_id) { $blocks = self::get_active(); unset($blocks[$location][$block_id]); - unset($blocks[$location][$block_id]); - module::set_var("core", "dashboard_blocks", serialize($blocks)); + module::set_var("core", "blocks", serialize($blocks)); } static function get_available() { $blocks = array(); foreach (module::installed() as $module) { - if (method_exists("{$module->name}_dashboard", "get_list")) { - foreach (call_user_func(array("{$module->name}_dashboard", "get_list")) as $id => $title) { + $class_name = "{$module->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; } } @@ -48,11 +48,15 @@ class dashboard_Core { 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]); + 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; } diff --git a/core/helpers/core_dashboard.php b/core/helpers/core_block.php index 8efba3ea..74b81d52 100644 --- a/core/helpers/core_dashboard.php +++ b/core/helpers/core_block.php @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class core_dashboard_Core { +class core_block_Core { static function get_list() { return array( "welcome" => t("Welcome to Gallery 3!"), @@ -28,7 +28,7 @@ class core_dashboard_Core { "project_news" => t("Gallery Project News")); } - static function get_block($block_id) { + static function get($block_id) { $block = new Block(); switch($block_id) { case "welcome": 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/views/welcome.html.php b/core/views/welcome.html.php index 73deedb9..4ab61b80 100644 --- a/core/views/welcome.html.php +++ b/core/views/welcome.html.php @@ -166,7 +166,7 @@ <?= html::script("lib/jquery.cookie.js") ?> <?= html::script("lib/jquery.MultiFile.js") ?> <? if (module::is_installed("rearrange")): ?> - <?= rearrange_block::head(null) ?> + <?= rearrange_theme::head(null) ?> <? endif ?> </head> <body> @@ -485,7 +485,7 @@ </li> </ul> </div> - + <div id="package" class="activity"> <?= $package ?> </div> diff --git a/modules/comment/helpers/comment_dashboard.php b/modules/comment/helpers/comment_block.php index 984c4cea..9a8e83ec 100644 --- a/modules/comment/helpers/comment_dashboard.php +++ b/modules/comment/helpers/comment_block.php @@ -17,12 +17,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class comment_dashboard_Core { +class comment_block_Core { static function get_list() { return array("recent_comments" => t("Recent Comments")); } - static function get_block($block_id) { + static function get($block_id) { $block = new Block(); switch ($block_id) { case "recent_comments": diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 651065f7..12caa547 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -50,7 +50,7 @@ class comment_installer { ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - dashboard::add_block("main", "comment", "recent_comments"); + block_manager::add("dashboard_center", "comment", "recent_comments"); module::set_var("comment", "spam_caught", 0); module::set_version("comment", 1); } |