diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-15 01:48:34 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-15 01:48:34 +0000 |
commit | c02d2554cfdf23a91b6b756ada91ab1ce1018280 (patch) | |
tree | 73cc4f8bfef0254e253a8724a74711e04392a83a /core | |
parent | 19e75b1e2ed73521b3cad01e55d546d3a6b55587 (diff) |
Refactor admin dashboard.
o Copy all the assets from default to default_admin so that they're
totally separate
o Get rid of $item_theme
o Rename list_users.html.php to users.html.php
o use __call in admin controller to allow us to load any admin page
Diffstat (limited to 'core')
-rw-r--r-- | core/controllers/admin.php | 39 | ||||
-rw-r--r-- | core/libraries/Theme_View.php | 2 |
2 files changed, 22 insertions, 19 deletions
diff --git a/core/controllers/admin.php b/core/controllers/admin.php index f00d3fdf..97f29cbb 100644 --- a/core/controllers/admin.php +++ b/core/controllers/admin.php @@ -18,36 +18,39 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Admin_Controller extends Controller { - public $theme_name = null; - public function __construct() { if (!(user::active()->admin)) { throw new Exception("@todo 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); - - $template = new Theme_View("admin.html", "admin", $this->theme_name); - $template->item_theme = $item_theme; - $template->subpage = "dashboard.html"; + $theme_name = module::get_var("core", "active_admin_theme", "default_admin"); + $template = new Admin_View("admin.html", $theme_name); + $template->content = new View("dashboard.html"); print $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()); + public function __call($page_name, $args) { + $theme_name = module::get_var("core", "active_admin_theme", "default_admin"); + // For now, we have only two legal pages. + // @todo get these pages from the modules + switch($page_name) { + case "users": + $view = new Admin_View("users.html", $theme_name); + $view->users = ORM::factory("user")->find_all(); + break; + + case "dashboard": + $view = new Admin_View("dashboard.html", $theme_name); + break; + + default: + Kohana::show_404(); } - print $template; + + print $view; } } diff --git a/core/libraries/Theme_View.php b/core/libraries/Theme_View.php index 51d7c545..7fc400ce 100644 --- a/core/libraries/Theme_View.php +++ b/core/libraries/Theme_View.php @@ -25,7 +25,7 @@ class Theme_View_Core extends View { * * @throws Kohana_Exception if the requested view cannot be found * @param string $name view name - * @param string $page_type page type: album, photo, tags, admin, etc + * @param string $page_type page type: album, photo, tags, etc * @param string $theme_name view name * @return void */ |