summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-01-18 06:55:04 +0000
committerBharat Mediratta <bharat@menalto.com>2009-01-18 06:55:04 +0000
commit7b68ca9946772fdb8fa2db756e934cc7883ea52d (patch)
tree93631ccca65b29ed42ccc901aa12f79b3395ca70 /core/helpers
parent3d1ea2904d982422ce24c43b25d0d4bca6f29aa3 (diff)
Refactor dashboard -> block_manager since it'll manage blocks site
wide, not just in the dashboard.
Diffstat (limited to 'core/helpers')
-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.php12
3 files changed, 26 insertions, 22 deletions
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");