diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-19 11:44:09 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-19 11:44:09 -0800 |
commit | f5b0ce1f4729e36f17b49ee7e6291d99070f1b99 (patch) | |
tree | 8557bc99c9193122b00f822e0bc8d03f058b99ef /modules/gallery/helpers | |
parent | 57adefc5baa7a2b0dfcd3e736e80c2fa86d3bfa2 (diff) |
Revert "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."
This reverts commit 1692ee130887a6ad1ba68aa34a96ad36161600f9.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 21 | ||||
-rw-r--r-- | modules/gallery/helpers/theme.php | 33 |
2 files changed, 32 insertions, 22 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 88f4a67b..3139951f 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -245,7 +245,11 @@ class gallery_event_Core { ->id("themes") ->label(t("Theme choice")) ->url(url::site("admin/themes"))) - ->append(Menu::factory("link") + ->append(Menu::factory("link") + ->id("theme_options") + ->label(t("Theme options")) + ->url(url::site("admin/theme_options"))) + ->append(Menu::factory("link") ->id("sidebar") ->label(t("Manage sidebar")) ->url(url::site("admin/sidebar")))) @@ -256,21 +260,6 @@ class gallery_event_Core { ->id("maintenance") ->label(t("Maintenance")) ->url(url::site("admin/maintenance"))); - - $theme_name = theme::$site; - $theme_helper = THEMEPATH . "$theme_name/helpers/{$theme_name}.php"; - if (file_exists($theme_helper)) { - require_once($theme_helper); - - if (method_exists($theme_name, "get_admin_form")) { - $info = theme::get_info($theme_name); - $menu->get("appearance_menu") - ->add_after("themes", Menu::factory("link") - ->id("theme_options") - ->label(t("%name options", array("name" => $info->name))) - ->url(url::site("admin/theme_options"))); - } - } return $menu; } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 6e8943b3..16ed104e 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -24,9 +24,6 @@ * Note: by design, this class does not do any permission checking. */ class theme_Core { - public static $site; - public static $admin; - /** * Load the active theme. This is called at bootstrap time. We will only ever have one theme * active for any given request. @@ -38,16 +35,39 @@ class theme_Core { $path = "/" . $input->get("kohana_uri"); } - self::$site = module::get_var("gallery", "active_site_theme"); - self::$admin = module::get_var("gallery", "active_admin_theme"); if (!(identity::active_user()->admin && $theme_name = $input->get("theme"))) { - $theme_name = $path == "/admin" || !strncmp($path, "/admin/", 7) ? self::$admin : self::$site; + $theme_name = module::get_var( + "gallery", + $path == "/admin" || !strncmp($path, "/admin/", 7) ? + "active_admin_theme" : "active_site_theme"); } $modules = Kohana::config("core.modules"); array_unshift($modules, THEMEPATH . $theme_name); Kohana::config_set("core.modules", $modules); } + static function get_edit_form_admin() { + $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form")); + $group = $form->group("edit_theme"); + $group->input("page_size")->label(t("Items per page"))->id("g-page-size") + ->rules("required|valid_digit") + ->value(module::get_var("gallery", "page_size")); + $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size") + ->rules("required|valid_digit") + ->value(module::get_var("gallery", "thumb_size")); + $group->input("resize_size")->label(t("Resized image size (in pixels)"))->id("g-resize-size") + ->rules("required|valid_digit") + ->value(module::get_var("gallery", "resize_size")); + $group->textarea("header_text")->label(t("Header text"))->id("g-header-text") + ->value(module::get_var("gallery", "header_text")); + $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text") + ->value(module::get_var("gallery", "footer_text")); + $group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text") + ->checked(module::get_var("gallery", "show_credits")); + $group->submit("")->value(t("Save")); + return $form; + } + static function get_info($theme_name) { $theme_name = preg_replace("/[^\w]/", "", $theme_name); $file = THEMEPATH . "$theme_name/theme.info"; @@ -58,3 +78,4 @@ class theme_Core { return $theme_info; } } + |