diff options
-rw-r--r-- | modules/gallery/controllers/admin_sidebar.php | 39 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 6 | ||||
-rw-r--r-- | modules/gallery/views/admin_sidebar.html.php | 47 | ||||
-rw-r--r-- | modules/gallery/views/admin_sidebar_blocks.html.php | 5 | ||||
-rw-r--r-- | themes/admin_wind/css/screen.css | 28 |
5 files changed, 119 insertions, 6 deletions
diff --git a/modules/gallery/controllers/admin_sidebar.php b/modules/gallery/controllers/admin_sidebar.php index 7e71426a..f029d259 100644 --- a/modules/gallery/controllers/admin_sidebar.php +++ b/modules/gallery/controllers/admin_sidebar.php @@ -21,8 +21,47 @@ class Admin_Sidebar_Controller extends Admin_Controller { public function index() { $view = new Admin_View("admin.html"); $view->content = new View("admin_sidebar.html"); + $view->content->csrf = access::csrf_token(); + $view->content->available = new View("admin_sidebar_blocks.html"); + $view->content->active = new View("admin_sidebar_blocks.html"); + list($view->content->available->blocks, $view->content->active->blocks) = $this->_get_blocks(); print $view; } + public function update() { + access::verify_csrf(); + + $available_blocks = block_manager::get_available_site_blocks(); + + $active_blocks = array(); + foreach ($this->input->get("block", array()) as $block_id) { + $active_blocks[] = explode(":", (string) $block_id); + } + block_manager::set_active("site.sidebar", $active_blocks); + + $result = array("result" => "success"); + list($available, $active) = $this->_get_blocks(); + $v = new View("admin_sidebar_blocks.html"); + $v->blocks = $available; + $result["available"] = $v->render(); + $v = new View("admin_sidebar_blocks.html"); + $v->blocks = $active; + $result["active"] = $v->render(); + + print json_encode($result); + } + + private function _get_blocks() { + $active_blocks = array(); + $available_blocks = block_manager::get_available_site_blocks(); + foreach (block_manager::get_active("site.sidebar") as $block) { + $id = "{$block[0]}:{$block[1]}"; + if (!empty($available_blocks[$id])) { + $active_blocks[$id] = $available_blocks[$id]; + unset($available_blocks[$id]); + } + } + return array($available_blocks, $active_blocks); + } } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 9305580f..69458e74 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -171,7 +171,11 @@ class gallery_event_Core { ->append(Menu::factory("link") ->id("theme_options") ->label(t("Theme Options")) - ->url(url::site("admin/theme_options")))) + ->url(url::site("admin/theme_options"))) + ->append(Menu::factory("link") + ->id("sidebar") + ->label(t("Manage Sidebar")) + ->url(url::site("admin/sidebar")))) ->append(Menu::factory("submenu") ->id("statistics_menu") ->label(t("Statistics"))) diff --git a/modules/gallery/views/admin_sidebar.html.php b/modules/gallery/views/admin_sidebar.html.php index 32386f5d..62b59ac1 100644 --- a/modules/gallery/views/admin_sidebar.html.php +++ b/modules/gallery/views/admin_sidebar.html.php @@ -1,9 +1,46 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> - -<h1> <?= t("Arrange Sidebar") ?> </h1> +<script type="text/javascript"> + $(function() { + $(".gAdminBlocksList ul").sortable({ + connectWith: ".sortableBlocks", + opacity: .7, + placeholder: "ui-state-highlight", + update: function(event,ui) { + if ($(this).attr("id") == "gActiveBlocks") { + var active_blocks = ""; + $("ul#gActiveBlocks li").each(function(i) { + active_blocks += "&block["+i+"]="+$(this).attr("ref"); + }); + $.getJSON($("#gSiteBlocks").attr("ref").replace("__ACTIVE__", active_blocks), function(data) { + if (data.result == "success") { + $("ul#gAvailableBlocks").html(data.available); + $("ul#gActiveBlocks").html(data.active); + } + }); + } + }, + }).disableSelection(); + }); +</script> +<h1> <?= t("Manage Sidebar") ?> </h1> <p> <?= t("Select and drag blocks from the available column to the active column to add to the sidebar; remove by dragging the other way.") ?> </p> - -<div id="gSiteBlocks"> -</div>
\ No newline at end of file + <div id="gSiteBlocks" ref="<?= url::site("admin/sidebar/update?csrf={$csrf}__ACTIVE__") ?>"> + <div class="gAdminBlocksList"> + <div><h3><?= t("Available Blocks") ?></h3></div> + <div> + <ul id="gAvailableBlocks" class="sortableBlocks"> + <?= $available ?> + </ul> + </div> + </div> + <div class="gAdminBlocksList"> + <div><h3><?= t("Active Blocks") ?></h3></div> + <div> + <ul id="gActiveBlocks" class="sortableBlocks"> + <?= $active ?> + </ul> + </div> + </div> +</div> diff --git a/modules/gallery/views/admin_sidebar_blocks.html.php b/modules/gallery/views/admin_sidebar_blocks.html.php new file mode 100644 index 00000000..a1a71743 --- /dev/null +++ b/modules/gallery/views/admin_sidebar_blocks.html.php @@ -0,0 +1,5 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> + +<? foreach ($blocks as $ref => $text): ?> +<li class="gDraggable" ref="<?= $ref ?>"><?= $text ?></li> +<? endforeach ?> diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index 737c5939..c733b482 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -656,6 +656,34 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { background: #ffc; } +/* admin/sidebar ~~~~~~~~~~~~~~~~~~~~~~~~~ */ +.gAdminBlocksList { + float: left; + height: 300px; + margin-left: 20px; + width: 30%; +} + +.gAdminBlocksList div:last-child { + border: .1em solid; + height: 100%; + overflow-y: auto; +} + +.gAdminBlocksList ul { + margin: .1em .1em; + padding: .1em; +} + +.gAdminBlocksList ul li { + background-color: #e8e8e8; + font-size: 1em; + font-weight: bold; + margin: .5em; + padding: .3em .8em; +} + + /** ******************************************************************* * 5) Navigation and menus *********************************************************************/ |