Permalink
Browse files

Move theme::get_edit_form_admin into admin_theme_options since that's

the only place where it's used and the theme helper is loaded on every
page view.
  • Loading branch information...
1 parent de93507 commit 24b511b44a0f2a7bce575a6dad9c88f9ef257648 @bharat bharat committed Aug 29, 2010
Showing with 35 additions and 35 deletions.
  1. +35 −2 modules/gallery/controllers/admin_theme_options.php
  2. +0 −33 modules/gallery/helpers/theme.php
@@ -22,14 +22,14 @@ public function index() {
$view = new Admin_View("admin.html");
$view->page_title = t("Theme options");
$view->content = new View("admin_theme_options.html");
- $view->content->form = theme::get_edit_form_admin();
+ $view->content->form = $this->_get_edit_form_admin();
print $view;
}
public function save() {
access::verify_csrf();
- $form = theme::get_edit_form_admin();
+ $form = $this->_get_edit_form_admin();
if ($form->validate()) {
module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
@@ -70,5 +70,38 @@ public function save() {
print $view;
}
}
+
+ private function _get_edit_form_admin() {
+ $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form"));
+ $group = $form->group("edit_theme")->label(t("Theme layout"));
+ $group->input("page_size")->label(t("Items per page"))->id("g-page-size")
+ ->rules("required|valid_digit")
+ ->error_messages("required", t("You must enter a number"))
+ ->error_messages("valid_digit", t("You must enter a number"))
+ ->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")
+ ->error_messages("required", t("You must enter a number"))
+ ->error_messages("valid_digit", t("You must enter a number"))
+ ->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")
+ ->error_messages("required", t("You must enter a number"))
+ ->error_messages("valid_digit", t("You must enter a number"))
+ ->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"));
+
+ module::event("theme_edit_form", $form);
+
+ $group = $form->group("buttons")
+ ->set_attr("style","border: none");
+ $group->submit("")->value(t("Save"));
+ return $form;
+ }
}
@@ -77,39 +77,6 @@ static function load_themes() {
$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")->label(t("Theme layout"));
- $group->input("page_size")->label(t("Items per page"))->id("g-page-size")
- ->rules("required|valid_digit")
- ->error_messages("required", t("You must enter a number"))
- ->error_messages("valid_digit", t("You must enter a number"))
- ->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")
- ->error_messages("required", t("You must enter a number"))
- ->error_messages("valid_digit", t("You must enter a number"))
- ->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")
- ->error_messages("required", t("You must enter a number"))
- ->error_messages("valid_digit", t("You must enter a number"))
- ->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"));
-
- module::event("theme_edit_form", $form);
-
- $group = $form->group("buttons")
- ->set_attr("style","border: none");
- $group->submit("")->value(t("Save"));
- return $form;
- }
-
static function get_info($theme_name) {
$theme_name = preg_replace("/[^a-zA-Z0-9\._-]/", "", $theme_name);
$file = THEMEPATH . "$theme_name/theme.info";

0 comments on commit 24b511b

Please sign in to comment.