summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/controllers/admin_dashboard.php29
-rw-r--r--core/helpers/core_dashboard.php12
-rw-r--r--core/helpers/core_installer.php12
-rw-r--r--core/libraries/Block.php3
-rw-r--r--core/views/admin_dashboard_blocks.html.php25
-rw-r--r--modules/comment/helpers/comment_block.php2
-rw-r--r--modules/comment/helpers/comment_dashboard.php2
-rw-r--r--modules/comment/helpers/comment_installer.php2
-rw-r--r--modules/gmaps/helpers/gmaps_block.php2
-rw-r--r--modules/info/helpers/info_block.php2
-rw-r--r--modules/tag/helpers/tag_block.php2
-rw-r--r--themes/admin_default/views/block.html.php7
-rw-r--r--themes/default/views/block.html.php2
13 files changed, 52 insertions, 50 deletions
diff --git a/core/controllers/admin_dashboard.php b/core/controllers/admin_dashboard.php
index bd0910a7..1a845e04 100644
--- a/core/controllers/admin_dashboard.php
+++ b/core/controllers/admin_dashboard.php
@@ -22,6 +22,7 @@ class Admin_Dashboard_Controller extends Admin_Controller {
$blocks = unserialize(module::get_var("core", "dashboard_blocks"));
$block_adder = new Block();
+ $block_adder->id = "core:block_adder";
$block_adder->title = t("Dashboard Content");
$block_adder->content = $this->get_add_block_form();
@@ -54,11 +55,35 @@ class Admin_Dashboard_Controller extends Admin_Controller {
url::redirect("admin/dashboard");
}
+ public function remove_block($id) {
+ access::verify_csrf();
+ $blocks = unserialize(module::get_var("core", "dashboard_blocks"));
+
+ if (array_key_exists($id, $blocks["sidebar"])) {
+ $deleted = $blocks["sidebar"][$id];
+ unset($blocks["sidebar"][$id]);
+ } else if (array_key_exists($id, $blocks["main"])) {
+ $deleted = $blocks["main"][$id];
+ unset($blocks["main"][$id]);
+ }
+
+ if (!empty($deleted)) {
+ module::set_var("core", "dashboard_blocks", serialize($blocks));
+ $available = $this->get_block_list();
+ $title = $available[join(":", $deleted)];
+ message::success(t("Removed <b>{{title}}</b> block", array("title" => $title)));
+ }
+
+ url::redirect("admin");
+ }
+
private function get_blocks($blocks) {
$result = "";
- foreach ($blocks as $desc) {
+ foreach ($blocks as $id => $desc) {
if (method_exists("$desc[0]_dashboard", "get_block")) {
- $result .= call_user_func(array("$desc[0]_dashboard", "get_block"), $desc[1]);
+ $block = call_user_func(array("$desc[0]_dashboard", "get_block"), $desc[1]);
+ $block->id = $id;
+ $result .= $block;
}
}
return $result;
diff --git a/core/helpers/core_dashboard.php b/core/helpers/core_dashboard.php
index d27ed01b..2e017351 100644
--- a/core/helpers/core_dashboard.php
+++ b/core/helpers/core_dashboard.php
@@ -32,13 +32,13 @@ class core_dashboard_Core {
$block = new Block();
switch($block_id) {
case "welcome":
- $block->id = "gWelcome";
+ $block->css_id = "gWelcome";
$block->title = t("Welcome to Gallery3");
$block->content = new View("admin_block_welcome.html");
break;
case "photo_stream":
- $block->id = "gPhotoStream";
+ $block->css_id = "gPhotoStream";
$block->title = t("Photo Stream");
$block->content = new View("admin_block_photo_stream.html");
$block->content->photos =
@@ -46,14 +46,14 @@ class core_dashboard_Core {
break;
case "log_entries":
- $block->id = "gLogEntries";
+ $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->id = "gStats";
+ $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();
@@ -61,13 +61,13 @@ class core_dashboard_Core {
break;
case "platform_info":
- $block->id = "gPlatform";
+ $block->css_id = "gPlatform";
$block->title = t("Platform Information");
$block->content = new View("admin_block_platform.html");
break;
case "project_news":
- $block->id = "gProjectNews";
+ $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);
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index 0da8bc3e..e809d687 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -236,12 +236,12 @@ class core_installer {
module::set_var(
"core", "dashboard_blocks", serialize(
- array("sidebar" => array(array("core", "stats"),
- array("core", "platform_info"),
- array("core", "project_news")),
- "main" => array(array("core", "welcome"),
- array("core", "photo_stream"),
- array("core", "log_entries")))));
+ array("sidebar" => array(rand() => array("core", "stats"),
+ rand() => array("core", "platform_info"),
+ rand() => array("core", "project_news")),
+ "main" => array(rand() => array("core", "welcome"),
+ rand() => array("core", "photo_stream"),
+ rand() => array("core", "log_entries")))));
module::set_version("core", 1);
module::set_var("core", "version", "3.0");
diff --git a/core/libraries/Block.php b/core/libraries/Block.php
index b6b77780..3689bff0 100644
--- a/core/libraries/Block.php
+++ b/core/libraries/Block.php
@@ -18,9 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Block_Core {
+ public $content = null;
+ public $css_id = null;
public $id = null;
public $title = null;
- public $content = null;
public function __toString() {
return View::factory("block.html", get_object_vars($this))->__toString();
diff --git a/core/views/admin_dashboard_blocks.html.php b/core/views/admin_dashboard_blocks.html.php
deleted file mode 100644
index 56a6ab07..00000000
--- a/core/views/admin_dashboard_blocks.html.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<div id="gAdminDashboardBlocks">
- <table border="1">
- <tr>
- <th> <?= t("Main") ?> </th>
- <th> <?= t("Sidebar") ?> </th>
- </tr>
-
- <? foreach ($available as $module_name => $block_list): ?>
- <? foreach ($block_list as $id => $title): ?>
- <tr>
- <td>
- <?= $title ?>
- </td>
- <td>
- <option>
- </option>
- </td>
- </tr>
- <? endforeach ?>
- <? endforeach ?>
- </table>
-</div>
-<? printf("<pre>%s</pre>",print_r($available,1));flush(); ?>
-<? printf("<pre>%s</pre>",print_r($displayed,1));flush(); ?>
diff --git a/modules/comment/helpers/comment_block.php b/modules/comment/helpers/comment_block.php
index c9b2dfe8..f24f19b1 100644
--- a/modules/comment/helpers/comment_block.php
+++ b/modules/comment/helpers/comment_block.php
@@ -25,7 +25,7 @@ class comment_block_Core {
public static function photo_bottom($theme) {
$block = new Block;
- $block->id = "gComments";
+ $block->css_id = "gComments";
$block->title = t("Comments");
$view = new View("comments.html");
diff --git a/modules/comment/helpers/comment_dashboard.php b/modules/comment/helpers/comment_dashboard.php
index c53ecb47..7edee2f5 100644
--- a/modules/comment/helpers/comment_dashboard.php
+++ b/modules/comment/helpers/comment_dashboard.php
@@ -26,7 +26,7 @@ class comment_dashboard_Core {
$block = new Block();
switch ($block_id) {
case "recent_comments":
- $block->id = "gRecentComments";
+ $block->css_id = "gRecentComments";
$block->title = t("Recent Comments");
$block->content = new View("admin_block_recent_comments.html");
$block->content->comments =
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php
index 4b3a7259..b54692ec 100644
--- a/modules/comment/helpers/comment_installer.php
+++ b/modules/comment/helpers/comment_installer.php
@@ -51,7 +51,7 @@ class comment_installer {
$dashboard_blocks = unserialize(module::get_var("core", "dashboard_blocks"));
- $dashboard_blocks["main"][] = array("comment", "recent_comments");
+ $dashboard_blocks["main"][rand()] = array("comment", "recent_comments");
module::set_var("core", "dashboard_blocks", serialize($dashboard_blocks));
module::set_var("comment", "spam_caught", 0);
module::set_version("comment", 1);
diff --git a/modules/gmaps/helpers/gmaps_block.php b/modules/gmaps/helpers/gmaps_block.php
index 04d0ae63..4024ec55 100644
--- a/modules/gmaps/helpers/gmaps_block.php
+++ b/modules/gmaps/helpers/gmaps_block.php
@@ -22,7 +22,7 @@ class gmaps_block_Core {
public static function sidebar_blocks($theme) {
if ($theme->item()) {
$block = new Block();
- $block->id = "gMaps";
+ $block->css_id = "gMaps";
$block->title = t("Location");
$block->content = new View("gmaps_block.html");
return $block;
diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php
index 358dd3b8..46e2bd72 100644
--- a/modules/info/helpers/info_block.php
+++ b/modules/info/helpers/info_block.php
@@ -21,7 +21,7 @@ class info_block_Core {
public static function sidebar_blocks($theme) {
if ($theme->item()) {
$block = new Block();
- $block->id = "gMetadata";
+ $block->css_id = "gMetadata";
$block->title = t("Item Info");
$block->content = new View("info_block.html");
return $block;
diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php
index adcc7d40..3d396599 100644
--- a/modules/tag/helpers/tag_block.php
+++ b/modules/tag/helpers/tag_block.php
@@ -25,7 +25,7 @@ class tag_block_Core {
public static function sidebar_blocks($theme) {
$block = new Block();
- $block->id = "gTag";
+ $block->css_id = "gTag";
$block->title = t("Popular Tags");
$block->content = new View("tag_block.html");
$block->content->cloud = tag::cloud(30);
diff --git a/themes/admin_default/views/block.html.php b/themes/admin_default/views/block.html.php
index 7f14353a..b92675e3 100644
--- a/themes/admin_default/views/block.html.php
+++ b/themes/admin_default/views/block.html.php
@@ -1,8 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<div id="<?= $id ?>" class="gBlock ui-widget-dialog">
+<div id="<?= $css_id ?>" class="gBlock ui-widget-dialog">
<div class="ui-dialog-titlebar ui-widget-header">
- <a href="#" class="ui-dialog-titlebar-close">
- <span class="ui-icon ui-icon-closethick">close</span>
+ <a href="<?= url::site("admin/dashboard/remove_block/$id?csrf=" . access::csrf_token()) ?>"
+ class="ui-dialog-titlebar-close">
+ <span class="ui-icon ui-icon-closethick">remove</span>
</a>
<?= $title ?>
</div>
diff --git a/themes/default/views/block.html.php b/themes/default/views/block.html.php
index 42d09196..a2357ab6 100644
--- a/themes/default/views/block.html.php
+++ b/themes/default/views/block.html.php
@@ -1,5 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<div id="<?= $id ?>" class="gBlock">
+<div id="<?= $css_id ?>" class="gBlock">
<h2><?= $title ?></h2>
<div class="gBlockContent">
<?= $content ?>