diff options
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r-- | modules/gallery/controllers/admin_theme_options.php | 52 | ||||
-rw-r--r-- | modules/gallery/controllers/admin_themes.php | 21 | ||||
-rw-r--r-- | modules/gallery/controllers/albums.php | 2 |
3 files changed, 31 insertions, 44 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; } } diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php index 24f91aba..23685c90 100644 --- a/modules/gallery/controllers/admin_themes.php +++ b/modules/gallery/controllers/admin_themes.php @@ -34,22 +34,15 @@ class Admin_Themes_Controller extends Admin_Controller { continue; } - $file = THEMEPATH . "$theme_name/theme.info"; - $theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS); - $theme_info->description = t($theme_info->description); - $theme_info->name = t($theme_info->name); - - $themes[$theme_name] = $theme_info; + $themes[$theme_name] = theme::get_info($theme_name); } return $themes; } public function preview($type, $theme_name) { $view = new View("admin_themes_preview.html"); - $theme_name = preg_replace("/[^\w]/", "", $theme_name); - $view->info = new ArrayObject( - parse_ini_file(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS); - $view->theme_name = $theme_name; + $view->info = theme::get_info($theme_name); + $view->theme_name = t($theme_name); $view->type = $type; if ($type == "admin") { $view->url = url::site("admin?theme=$theme_name"); @@ -62,18 +55,16 @@ class Admin_Themes_Controller extends Admin_Controller { public function choose($type, $theme_name) { access::verify_csrf(); - $theme_name = preg_replace("/[^\w]/", "", $theme_name); - $info = new ArrayObject( - parse_ini_file(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS); + $info = theme::get_info($theme_name); if ($type == "admin" && $info->admin) { module::set_var("gallery", "active_admin_theme", $theme_name); message::success(t("Successfully changed your admin theme to <b>%theme_name</b>", - array("theme_name" => t($info->name)))); + array("theme_name" => $info->name))); } else if ($type == "site" && $info->site) { module::set_var("gallery", "active_site_theme", $theme_name); message::success(t("Successfully changed your Gallery theme to <b>%theme_name</b>", - array("theme_name" => t($info->name)))); + array("theme_name" => $info->name))); } url::redirect("admin/themes"); diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index e67df6f6..749fb520 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -23,7 +23,7 @@ class Albums_Controller extends Items_Controller { * @see REST_Controller::_show($resource) */ public function _show($album) { - $page_size = module::get_var("gallery", "page_size", 9); + $page_size = theme::get_var("page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { $view = new Theme_View("page.html", "other", "login"); |