summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-24 04:22:22 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-24 04:22:22 +0000
commitc7193f9b2ede6ed913d16a9a8047b6867b8afada (patch)
treecd7bf045bb8f6a971eda11de9b91b4c61d52f4f6 /core
parentb2c9a59d1b80cfe651c740c2eabbc0862a7a867e (diff)
Normalize our Admin controllers so that functions always print out
their results, as opposed to having them return their view back upstream. This is a little more code in every controller, but it's much less magical and more consistent. Look up the active_theme and active_admin_theme inside the view itself, no need to do that in the controllers. This makes view initialization easier in the controllers.
Diffstat (limited to 'core')
-rw-r--r--core/controllers/admin.php11
-rw-r--r--core/controllers/admin_dashboard.php4
-rw-r--r--core/controllers/admin_modules.php7
-rw-r--r--core/controllers/albums.php3
-rw-r--r--core/controllers/photos.php5
-rw-r--r--core/libraries/Admin_View.php5
-rw-r--r--core/libraries/Theme_View.php5
7 files changed, 16 insertions, 24 deletions
diff --git a/core/controllers/admin.php b/core/controllers/admin.php
index 6e44c54e..6f4ec47a 100644
--- a/core/controllers/admin.php
+++ b/core/controllers/admin.php
@@ -24,14 +24,9 @@ class Admin_Controller extends Controller {
if (!(user::active()->admin)) {
throw new Exception("@todo UNAUTHORIZED", 401);
}
- $this->theme = $theme;
parent::__construct();
}
- public function theme() {
- return $this->theme;
- }
-
public function __call($controller_name, $args) {
if (request::method() == "post") {
access::verify_csrf();
@@ -48,11 +43,7 @@ class Admin_Controller extends Controller {
$method = "index";
}
- $theme_name = module::get_var("core", "active_admin_theme", "admin_default");
- $this->template = $template = new Admin_View("admin.html", $theme_name);
- $template->content = call_user_func_array(
- array(new $controller_name($template), $method), $args);
- print $template;
+ call_user_func_array(array(new $controller_name, $method), $args);
}
}
diff --git a/core/controllers/admin_dashboard.php b/core/controllers/admin_dashboard.php
index 13ec5d82..bd295b84 100644
--- a/core/controllers/admin_dashboard.php
+++ b/core/controllers/admin_dashboard.php
@@ -19,7 +19,9 @@
*/
class Admin_Dashboard_Controller extends Admin_Controller {
public function index() {
- return $this->theme()->admin_dashboard_blocks();
+ $view = new Admin_View("admin.html");
+ $view->content = $view->admin_dashboard_blocks();
+ print $view;
}
}
diff --git a/core/controllers/admin_modules.php b/core/controllers/admin_modules.php
index ada7dcfd..152e49c3 100644
--- a/core/controllers/admin_modules.php
+++ b/core/controllers/admin_modules.php
@@ -19,9 +19,10 @@
*/
class Admin_Modules_Controller extends Admin_Controller {
public function index() {
- $view = new View("admin_modules.html");
- $view->available = module::available();
- return $view;
+ $view = new Admin_View("admin.html");
+ $view->content = new View("admin_modules.html");
+ $view->content->available = module::available();
+ print $view;
}
public function save() {
diff --git a/core/controllers/albums.php b/core/controllers/albums.php
index 8d2b5b77..08b61058 100644
--- a/core/controllers/albums.php
+++ b/core/controllers/albums.php
@@ -25,7 +25,6 @@ class Albums_Controller extends Items_Controller {
public function _show($album) {
access::required("view", $album);
- $theme_name = module::get_var("core", "active_theme", "default");
$page_size = module::get_var("core", "page_size", 9);
$page = $this->input->get("page", "1");
$children_count = $album->viewable()->children_count();
@@ -36,7 +35,7 @@ class Albums_Controller extends Items_Controller {
Kohana::show_404();
}
- $template = new Theme_View("page.html", "album", $theme_name);
+ $template = new Theme_View("page.html", "album");
$template->set_global("page_size", $page_size);
$template->set_global("item", $album);
$template->set_global("children", $album->viewable()->children($page_size, $offset));
diff --git a/core/controllers/photos.php b/core/controllers/photos.php
index 730cfd2c..4690bf58 100644
--- a/core/controllers/photos.php
+++ b/core/controllers/photos.php
@@ -25,10 +25,7 @@ class Photos_Controller extends Items_Controller {
public function _show($photo) {
access::required("view", $photo);
- $theme_name = module::get_var("core", "active_theme", "default");
-
- $template = new Theme_View("page.html", "photo", $theme_name);
-
+ $template = new Theme_View("page.html", "photo");
$template->set_global('item', $photo);
$template->set_global('children', array());
$template->set_global('children_count', $photo->children_count());
diff --git a/core/libraries/Admin_View.php b/core/libraries/Admin_View.php
index e9ff9791..3255f04d 100644
--- a/core/libraries/Admin_View.php
+++ b/core/libraries/Admin_View.php
@@ -28,9 +28,10 @@ class Admin_View_Core extends View {
* @param string $theme_name view name
* @return void
*/
- public function __construct($name, $theme_name="default") {
+ public function __construct($name) {
parent::__construct($name);
- $this->theme_name = $theme_name;
+
+ $this->theme_name = module::get_var("core", "active_admin_theme");
$this->set_global('theme', $this);
$this->set_global('user', user::active());
}
diff --git a/core/libraries/Theme_View.php b/core/libraries/Theme_View.php
index 030e564d..37507a70 100644
--- a/core/libraries/Theme_View.php
+++ b/core/libraries/Theme_View.php
@@ -29,9 +29,10 @@ class Theme_View_Core extends View {
* @param string $theme_name view name
* @return void
*/
- public function __construct($name, $page_type, $theme_name="default") {
+ public function __construct($name, $page_type) {
parent::__construct($name);
- $this->theme_name = $theme_name;
+
+ $this->theme_name = module::get_var("core", "active_theme");
$this->set_global('theme', $this);
$this->set_global('user', user::active());
$this->set_global("page_type", $page_type);