summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-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
5 files changed, 41 insertions, 40 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(); ?>