diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-18 14:37:49 -0800 | 
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-18 14:37:49 -0800 | 
| commit | 1692ee130887a6ad1ba68aa34a96ad36161600f9 (patch) | |
| tree | 2901fee570d5ee8aa6a0ada01c1d92980be11e03 /modules/gallery/controllers/admin_theme_options.php | |
| parent | 372f589f66436c5b5bb8ed8a98532842c1e01a71 (diff) | |
Currently Admin_Theme_Options controller assumes that all the themes will provide the same values. This change corrects that assumption and moves the management of the theme options, including creating the form and updating the theme options into the theme.
Diffstat (limited to 'modules/gallery/controllers/admin_theme_options.php')
| -rw-r--r-- | modules/gallery/controllers/admin_theme_options.php | 52 | 
1 files changed, 24 insertions, 28 deletions
| diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 27a67bdb..dc421ee1 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -21,48 +21,44 @@ class Admin_Theme_Options_Controller extends Admin_Controller {    public function index() {      $view = new Admin_View("admin.html");      $view->content = new View("admin_theme_options.html"); -    $view->content->form = theme::get_edit_form_admin(); + +    $theme_name = theme::$site; +    $info = theme::get_info($theme_name); + +    // Don't use the Kohana cascading file system because we don't want to mess up the admin theme +    $theme_helper = THEMEPATH . "$theme_name/helpers/{$theme_name}.php"; +    @require_once($theme_helper); +    $view->content->form = call_user_func_array(array(theme::$site, "get_admin_form"), +                                                array("admin/theme_options/save/")); + +    $view->content->title = t("%name options", array("name" => $info->name)); +      print $view;    }    public function save() {      access::verify_csrf(); -    $form = theme::get_edit_form_admin(); -    if ($form->validate()) { -      module::set_var("gallery", "page_size", $form->edit_theme->page_size->value); +    // Don't use the Kohana cascading file system because we don't want to mess up the admin theme +    $theme_name = theme::$site; +    $theme_helper = THEMEPATH . "$theme_name/helpers/{$theme_name}.php"; +    @require_once($theme_helper); -      $thumb_size = $form->edit_theme->thumb_size->value; -      $thumb_dirty = false; -      if (module::get_var("gallery", "thumb_size") != $thumb_size) { -        graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize"); -        graphics::add_rule( -          "gallery", "thumb", "gallery_graphics::resize", -          array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), -          100); -        module::set_var("gallery", "thumb_size", $thumb_size); -      } +    $info = theme::get_info($theme_name); -      $resize_size = $form->edit_theme->resize_size->value; -      $resize_dirty = false; -      if (module::get_var("gallery", "resize_size") != $resize_size) { -        graphics::remove_rule("gallery", "resize", "gallery_graphics::resize"); -        graphics::add_rule( -          "gallery", "resize", "gallery_graphics::resize", -          array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), -          100); -        module::set_var("gallery", "resize_size", $resize_size); -      } +    $form = call_user_func_array(array(theme::$site, "get_admin_form"), +                                 array("admin/theme_options/save/")); +    if ($form->validate()) { -      module::set_var("gallery", "header_text", $form->edit_theme->header_text->value); -      module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); -      module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); +      $view->content->form = call_user_func_array(array(theme::$site, "update_options"), +                                                  array($form)); -      message::success(t("Updated theme details")); +      message::success(t("Updated %name options", array("name" => $info->name)));        url::redirect("admin/theme_options");      } else {        $view = new Admin_View("admin.html");        $view->content = $form; +      $view->content->title = t("%name options", array("name" => $info->name));        print $view;      }    } | 
