summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Rabinovich <virshu@users.sourceforge.net>2008-12-14 21:50:10 +0000
committerFelix Rabinovich <virshu@users.sourceforge.net>2008-12-14 21:50:10 +0000
commitc46bd97407e2eef500fa224ef7593193e3da6d18 (patch)
treef454c2528371b91fbfaac642933025c64c87a4b8
parentb7487e384d47b4ca444844c972be83c77ad4ea74 (diff)
load admin subpages AJAXy way
-rw-r--r--core/controllers/admin.php34
-rw-r--r--core/helpers/core_menu.php2
-rw-r--r--themes/default_admin/views/admin.html.php12
3 files changed, 27 insertions, 21 deletions
diff --git a/core/controllers/admin.php b/core/controllers/admin.php
index 44848028..b082d779 100644
--- a/core/controllers/admin.php
+++ b/core/controllers/admin.php
@@ -18,34 +18,36 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Controller extends Controller {
- public $template = null;
+ public $theme_name = null;
public function __construct() {
if (!(user::active()->admin)) {
throw new Exception("Unauthorized", 401);
}
+ // giving default is probably overkill
+ $this->theme_name = module::get_var("core", "active_admin_theme", "default_admin");
+ parent::__construct();
+ }
+
+ public function index() {
// For now, in order not to duplicate js and css, keep the regular ("item")
// theme in addition to admin theme.
$item_theme_name = module::get_var("core", "active_theme", "default");
$item_theme = new Theme_View("album.html", "album", $item_theme_name);
- // giving default is probably overkill
- $theme_name = module::get_var("core", "active_admin_theme", "default_admin");
- $this->template = new Theme_View("admin.html", "admin", $theme_name);
- $this->template->item_theme = $item_theme;
- parent::__construct();
+ $template = new Theme_View("admin.html", "admin", $this->theme_name);
+ $template->item_theme = $item_theme;
+ $template->subpage = "dashboard.html";
+ print $template;
}
- public function dashboard() {
- $this->template->subpage = "dashboard.html";
- print $this->template;
- }
-
- public function list_users() {
- $this->template->set_global("users", ORM::factory("user")->find_all());
-
- $this->template->subpage = "list_users.html";
- print $this->template;
+ public function subpage() {
+ $template = new Theme_View($_REQUEST["name"] . ".html", "admin", $this->theme_name);
+ switch ($_REQUEST["name"]) {
+ case "list_users":
+ $template->set_global("users", ORM::factory("user")->find_all());
+ }
+ print $template;
}
}
diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php
index ecf4c184..69398302 100644
--- a/core/helpers/core_menu.php
+++ b/core/helpers/core_menu.php
@@ -66,7 +66,7 @@ class core_menu_Core {
Menu::factory("link")
->id("site_admin")
->label(_("Site Admin"))
- ->url(url::site("admin/dashboard")));
+ ->url(url::site("admin")));
}
}
}
diff --git a/themes/default_admin/views/admin.html.php b/themes/default_admin/views/admin.html.php
index e37ddbe4..0d1f8e28 100644
--- a/themes/default_admin/views/admin.html.php
+++ b/themes/default_admin/views/admin.html.php
@@ -13,10 +13,14 @@
<link rel="stylesheet" href="<?= $item_theme->url("jquery/superfish-navbar.css") ?>" type="text/css" media="screen,projection">
<script src="<?= $item_theme->url("jquery/superfish.js") ?>"></script>
<script type="text/javascript">
- $(document).ready(function(){
+ $(document).ready(function(){
$("ul.sf-menu").superfish({
pathClass: 'current'
- });
+ });
+ $("#gSiteAdminMenu li[id]").click(function(event) {
+ $("#gContent").load("admin/subpage", {name: this.id});
+ return false;
+ });
});
</script>
@@ -70,7 +74,7 @@
</ul>
<img src="<?= $item_theme->url("images/logo.png") ?>" id="gLogo" alt="Gallery 3: Your Photos on Your Web Site" />
<ul id="gSiteAdminMenu" class="sf-menu sf-navbar">
- <li><?= html::anchor("admin/dashboard", "Dashboard") ?><li>
+ <li id="dashboard"><a href="#">Dashboard</a><li>
<li><a href="#">General Settings</a><li>
<li class="current"><a href="#">Content</a>
<ul>
@@ -91,7 +95,7 @@
</li>
<li><a href="#">Users/Groups</a>
<ul>
- <li><?= html::anchor("admin/list_users", "List Users") ?></li>
+ <li id="list_users"><a href="#">List Users</a></li>
<li><a href="#">Create new user</a><li>
<li><a href="#">Edit Profile</a></li>
</ul>