From 630099364515fd0fd0453b4b548048c8a32c831c Mon Sep 17 00:00:00 2001
From: Tim Almdal <tnalmdal@shaw.ca>
Date: Thu, 19 Nov 2009 11:52:57 -0800
Subject: Revert "Use call_user_func instead of call_user_func_array as we
 don't need to pass the parameters by reference." This reverts commit
 75cc4962a2c945e3e3ad37fda3b5de32d512b929.

Revert "Make sure that calls to the theme::get_var() have sane defaults in the event that the theme does not supply them."
This reverts commit 51f2b547672ab69a7a04d37b723c6afbeb584a59.

Revert "Update the installer to reflect the new location of the theme related options."
This reverts commit 678e22996d73b96833c48d94751344a6bd8f2899.

Revert "Create theme::get_var(), theme::set_var() methods to set the options of the active site theme.  Change all refrences to theme options to use these methods.  Update the version number of Gallery to 20 and move any them related options to the be stored under the active theme."
This reverts commit 26114972c3388f065220b94a0d5962f20a6ccd0c.

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.
---
 installer/install.sql | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'installer/install.sql')

diff --git a/installer/install.sql b/installer/install.sql
index af54c1eb..38851eff 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -228,7 +228,7 @@ CREATE TABLE {modules} (
   UNIQUE KEY `name` (`name`)
 ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
 SET character_set_client = @saved_cs_client;
-INSERT INTO {modules} VALUES (1,1,'gallery',20);
+INSERT INTO {modules} VALUES (1,1,'gallery',19);
 INSERT INTO {modules} VALUES (2,1,'user',2);
 INSERT INTO {modules} VALUES (3,1,'comment',2);
 INSERT INTO {modules} VALUES (4,1,'organize',1);
@@ -370,14 +370,14 @@ CREATE TABLE {vars} (
 SET character_set_client = @saved_cs_client;
 INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','wind');
 INSERT INTO {vars} VALUES (2,'gallery','active_admin_theme','admin_wind');
-INSERT INTO {vars} VALUES (3,'wind','page_size','9');
-INSERT INTO {vars} VALUES (4,'wind','thumb_size','200');
-INSERT INTO {vars} VALUES (5,'wind','resize_size','640');
+INSERT INTO {vars} VALUES (3,'gallery','page_size','9');
+INSERT INTO {vars} VALUES (4,'gallery','thumb_size','200');
+INSERT INTO {vars} VALUES (5,'gallery','resize_size','640');
 INSERT INTO {vars} VALUES (6,'gallery','default_locale','en_US');
 INSERT INTO {vars} VALUES (7,'gallery','image_quality','75');
 INSERT INTO {vars} VALUES (8,'gallery','image_sharpen','15');
 INSERT INTO {vars} VALUES (21,'gallery','time_format','H:i:s');
-INSERT INTO {vars} VALUES (22,'wind','show_credits','1');
+INSERT INTO {vars} VALUES (22,'gallery','show_credits','1');
 INSERT INTO {vars} VALUES (23,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>');
 INSERT INTO {vars} VALUES (10,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}');
 INSERT INTO {vars} VALUES (20,'gallery','date_time_format','Y-M-d H:i:s');
-- 
cgit v1.2.3


From 05b5a2c9ed9e5c3ed05eec8748f4bebc381993c4 Mon Sep 17 00:00:00 2001
From: Tim Almdal <tnalmdal@shaw.ca>
Date: Thu, 19 Nov 2009 11:56:05 -0800
Subject: Revert "Revert "Use call_user_func instead of call_user_func_array as
 we don't need to pass the parameters by reference.""

This reverts commit 630099364515fd0fd0453b4b548048c8a32c831c.
---
 installer/install.sql                              | 10 +--
 modules/g2_import/controllers/admin_g2_import.php  |  4 +-
 modules/g2_import/helpers/g2_import.php            |  4 +-
 .../gallery/controllers/admin_theme_options.php    | 51 +++++++--------
 modules/gallery/controllers/albums.php             |  2 +-
 modules/gallery/helpers/gallery_event.php          | 21 +++++--
 modules/gallery/helpers/gallery_installer.php      | 21 +++++--
 modules/gallery/helpers/theme.php                  | 62 ++++++++++--------
 modules/gallery/libraries/Theme_View.php           |  2 +-
 modules/gallery/module.info                        |  2 +-
 modules/gallery/views/admin_theme_options.html.php |  2 +-
 modules/search/controllers/search.php              |  2 +-
 modules/tag/controllers/tags.php                   |  2 +-
 themes/wind/helpers/wind.php                       | 73 ++++++++++++++++++++++
 themes/wind/views/page.html.php                    |  6 +-
 15 files changed, 180 insertions(+), 84 deletions(-)
 create mode 100644 themes/wind/helpers/wind.php

(limited to 'installer/install.sql')

diff --git a/installer/install.sql b/installer/install.sql
index 38851eff..af54c1eb 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -228,7 +228,7 @@ CREATE TABLE {modules} (
   UNIQUE KEY `name` (`name`)
 ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
 SET character_set_client = @saved_cs_client;
-INSERT INTO {modules} VALUES (1,1,'gallery',19);
+INSERT INTO {modules} VALUES (1,1,'gallery',20);
 INSERT INTO {modules} VALUES (2,1,'user',2);
 INSERT INTO {modules} VALUES (3,1,'comment',2);
 INSERT INTO {modules} VALUES (4,1,'organize',1);
@@ -370,14 +370,14 @@ CREATE TABLE {vars} (
 SET character_set_client = @saved_cs_client;
 INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','wind');
 INSERT INTO {vars} VALUES (2,'gallery','active_admin_theme','admin_wind');
-INSERT INTO {vars} VALUES (3,'gallery','page_size','9');
-INSERT INTO {vars} VALUES (4,'gallery','thumb_size','200');
-INSERT INTO {vars} VALUES (5,'gallery','resize_size','640');
+INSERT INTO {vars} VALUES (3,'wind','page_size','9');
+INSERT INTO {vars} VALUES (4,'wind','thumb_size','200');
+INSERT INTO {vars} VALUES (5,'wind','resize_size','640');
 INSERT INTO {vars} VALUES (6,'gallery','default_locale','en_US');
 INSERT INTO {vars} VALUES (7,'gallery','image_quality','75');
 INSERT INTO {vars} VALUES (8,'gallery','image_sharpen','15');
 INSERT INTO {vars} VALUES (21,'gallery','time_format','H:i:s');
-INSERT INTO {vars} VALUES (22,'gallery','show_credits','1');
+INSERT INTO {vars} VALUES (22,'wind','show_credits','1');
 INSERT INTO {vars} VALUES (23,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>');
 INSERT INTO {vars} VALUES (10,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}');
 INSERT INTO {vars} VALUES (20,'gallery','date_time_format','Y-M-d H:i:s');
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index 1c65f482..99d28fd7 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -35,8 +35,8 @@ class Admin_g2_import_Controller extends Admin_Controller {
     if (g2_import::is_initialized()) {
       $view->content->g2_stats = $g2_stats;
       $view->content->g2_sizes = $g2_sizes;
-      $view->content->thumb_size = module::get_var("gallery", "thumb_size");
-      $view->content->resize_size = module::get_var("gallery", "resize_size");
+      $view->content->thumb_size = theme::get_var("thumb_size", 200);
+      $view->content->resize_size = theme::get_var("resize_size", 640);
     }
     print $view;
   }
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 202a0e92..519da40f 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -671,8 +671,8 @@ class g2_import_Core {
     $g2_item_id = self::$current_g2_item->getId();
     $derivatives = g2(GalleryCoreApi::fetchDerivativesByItemIds(array($g2_item_id)));
 
-    $target_thumb_size = module::get_var("gallery", "thumb_size");
-    $target_resize_size = module::get_var("gallery", "resize_size");
+    $target_thumb_size = theme::get_var("thumb_size", 200);
+    $target_resize_size = theme::get_var("resize_size", 640);
     if (!empty($derivatives[$g2_item_id])) {
       foreach ($derivatives[$g2_item_id] as $derivative) {
         if ($derivative->getPostFilterOperations()) {
diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php
index 27a67bdb..c75aebaa 100644
--- a/modules/gallery/controllers/admin_theme_options.php
+++ b/modules/gallery/controllers/admin_theme_options.php
@@ -21,48 +21,41 @@ 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("{$theme_name}::get_admin_form", "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);
-
-      $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);
-      }
+    // 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);
 
-      $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);
-      }
+    $info = theme::get_info($theme_name);
 
-      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);
+    $form = call_user_func("{$theme_name}::get_admin_form", "admin/theme_options/save/");
+    if ($form->validate()) {
+      call_user_func("{$theme_name}::update_options", $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/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");
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 3139951f..88f4a67b 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -245,11 +245,7 @@ class gallery_event_Core {
                         ->id("themes")
                         ->label(t("Theme choice"))
                         ->url(url::site("admin/themes")))
-               ->append(Menu::factory("link")
-                        ->id("theme_options")
-                        ->label(t("Theme options"))
-                        ->url(url::site("admin/theme_options")))
-               ->append(Menu::factory("link")
+              ->append(Menu::factory("link")
                         ->id("sidebar")
                         ->label(t("Manage sidebar"))
                         ->url(url::site("admin/sidebar"))))
@@ -260,6 +256,21 @@ 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/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 57a5ee9f..4051c6e9 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -226,9 +226,9 @@ class gallery_installer {
 
     module::set_var("gallery", "active_site_theme", "wind");
     module::set_var("gallery", "active_admin_theme", "admin_wind");
-    module::set_var("gallery", "page_size", 9);
-    module::set_var("gallery", "thumb_size", 200);
-    module::set_var("gallery", "resize_size", 640);
+    module::set_var("wind", "page_size", 9);
+    module::set_var("wind", "thumb_size", 200);
+    module::set_var("wind", "resize_size", 640);
     module::set_var("gallery", "default_locale", "en_US");
     module::set_var("gallery", "image_quality", 75);
     module::set_var("gallery", "image_sharpen", 15);
@@ -265,10 +265,10 @@ class gallery_installer {
     module::set_var("gallery", "date_format", "Y-M-d");
     module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
     module::set_var("gallery", "time_format", "H:i:s");
-    module::set_var("gallery", "show_credits", 1);
+    module::set_var("wind", "show_credits", 1);
     // @todo this string needs to be picked up by l10n_scanner
     module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
-    module::set_version("gallery", 19);
+    module::set_version("gallery", 20);
   }
 
   static function upgrade($version) {
@@ -432,6 +432,17 @@ class gallery_installer {
       module::clear_var("gallery", "blocks_site.sidebar");
       module::set_version("gallery", $version = 19);
     }
+
+    // Move the theme related variables into the current theme
+    if ($version == 19) {
+      foreach (array("page_size", "thumb_size", "resize_size", "header_text",
+                     "footer_text", "show_credits") as $var) {
+        $value = module::get_var("gallery", $var);
+        theme::set_var($var, $value);
+        module::clear_var("gallery", $var);
+      }
+      module::set_version("gallery", $version = 20);
+    }
   }
 
   static function uninstall() {
diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php
index 16ed104e..c7b773d1 100644
--- a/modules/gallery/helpers/theme.php
+++ b/modules/gallery/helpers/theme.php
@@ -24,6 +24,9 @@
  * 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.
@@ -35,39 +38,16 @@ 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 = module::get_var(
-        "gallery",
-        $path == "/admin" || !strncmp($path, "/admin/", 7) ?
-          "active_admin_theme" : "active_site_theme");
+      $theme_name = $path == "/admin" || !strncmp($path, "/admin/", 7) ? self::$admin : self::$site;
     }
     $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";
@@ -77,5 +57,33 @@ class theme_Core {
 
     return $theme_info;
   }
-}
 
+  /**
+   * Get a variable from the active theme
+   * @param string $name
+   * @param string $default_value
+   * @return the value
+   */
+  static function get_var($name, $default_value=null) {
+    return module::get_var(self::$site, $name, $default_value);
+  }
+
+  /**
+   * Store a variable for active theme
+   * @param string $module_name
+   * @param string $name
+   * @param string $value
+   */
+  static function set_var($name, $value) {
+    module::set_var(self::$site, $name, $value);
+  }
+
+ /**
+   * Remove a variable for this module.
+   * @param string $module_name
+   * @param string $name
+   */
+  static function clear_var($name) {
+    module::clear_var(self::$site, $name);
+  }
+}
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index b1167d0e..87d8de56 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -65,7 +65,7 @@ class Theme_View_Core extends Gallery_View {
   public function thumb_proportion() {
     // @TODO change the 200 to a theme supplied value when and if we come up with an
     // API to allow the theme to set defaults.
-    return module::get_var("gallery", "thumb_size", 200) / 200;
+    return theme::get_var("thumb_size", 200) / 200;
   }
 
   public function item() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 2dc62ecd..ecce9118 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
 name = "Gallery 3"
 description = "Gallery core application"
-version = 19
+version = 20
diff --git a/modules/gallery/views/admin_theme_options.html.php b/modules/gallery/views/admin_theme_options.html.php
index a4bf1c4e..9f28e055 100644
--- a/modules/gallery/views/admin_theme_options.html.php
+++ b/modules/gallery/views/admin_theme_options.html.php
@@ -1,6 +1,6 @@
 <?php defined("SYSPATH") or die("No direct script access.") ?>
 <div class="g-block">
-  <h1> <?= t("Theme Options") ?> </h1>
+  <h1> <?= t($title) ?> </h1>
 
   <div class="g-block-content">
   <?= $form ?>
diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php
index 539e063f..fcee5233 100644
--- a/modules/search/controllers/search.php
+++ b/modules/search/controllers/search.php
@@ -19,7 +19,7 @@
  */
 class Search_Controller extends Controller {
   public function index() {
-    $page_size = module::get_var("gallery", "page_size", 9);
+    $page_size = theme::get_var("page_size", 9);
     $q = $this->input->get("q");
     $page = $this->input->get("page", 1);
     $offset = ($page - 1) * $page_size;
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 52001719..6dc77d56 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -21,7 +21,7 @@ class Tags_Controller extends REST_Controller {
   protected $resource_type = "tag";
 
   public function _show($tag) {
-    $page_size = module::get_var("gallery", "page_size", 9);
+    $page_size = theme::get_var("page_size", 9);
     $page = (int) $this->input->get("page", "1");
     $children_count = $tag->items_count();
     $offset = ($page-1) * $page_size;
diff --git a/themes/wind/helpers/wind.php b/themes/wind/helpers/wind.php
new file mode 100644
index 00000000..beef3d41
--- /dev/null
+++ b/themes/wind/helpers/wind.php
@@ -0,0 +1,73 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+class wind {
+  static function get_admin_form($action) {
+    $form = new Forge($action, "", null, array("id" =>"g-wind-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("wind", "page_size"));
+    $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size")
+      ->rules("required|valid_digit")
+      ->value(module::get_var("wind", "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("wind", "resize_size"));
+    $group->textarea("header_text")->label(t("Header text"))->id("g-header-text")
+      ->value(module::get_var("wind", "header_text"));
+    $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text")
+      ->value(module::get_var("wind", "footer_text"));
+    $group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text")
+      ->checked(module::get_var("wind", "show_credits"));
+    $group->submit("")->value(t("Save"));
+    return $form;
+  }
+
+  static function update_options($form) {
+    module::set_var("wind", "page_size", $form->edit_theme->page_size->value);
+
+    $thumb_size = $form->edit_theme->thumb_size->value;
+    $thumb_dirty = false;
+    if (module::get_var("wind", "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("wind", "thumb_size", $thumb_size);
+    }
+
+    $resize_size = $form->edit_theme->resize_size->value;
+    $resize_dirty = false;
+    if (module::get_var("wind", "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("wind", "resize_size", $resize_size);
+    }
+
+    module::set_var("wind", "header_text", $form->edit_theme->header_text->value);
+    module::set_var("wind", "footer_text", $form->edit_theme->footer_text->value);
+    module::set_var("wind", "show_credits", $form->edit_theme->show_credits->value);
+  }
+}
diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php
index 03d43918..ddaf33d0 100644
--- a/themes/wind/views/page.html.php
+++ b/themes/wind/views/page.html.php
@@ -77,7 +77,7 @@
       <?= $theme->site_status() ?>
       <div id="g-header" class="ui-helper-clearfix">
         <div id="g-banner">
-          <? if ($header_text = module::get_var("gallery", "header_text")): ?>
+          <? if ($header_text = theme::get_var("header_text")): ?>
           <?= $header_text ?>
           <? else: ?>
           <a id="g-logo" class="g-left" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>">
@@ -129,11 +129,11 @@
       </div>
       <div id="g-footer" class="ui-helper-clearfix">
         <?= $theme->footer() ?>
-        <? if ($footer_text = module::get_var("gallery", "footer_text")): ?>
+        <? if ($footer_text = theme::get_var("footer_text")): ?>
         <?= $footer_text ?>
         <? endif ?>
 
-        <? if (module::get_var("gallery", "show_credits")): ?>
+        <? if (theme::get_var("show_credits")): ?>
         <ul id="g-credits" class="g-inline">
           <?= $theme->credits() ?>
         </ul>
-- 
cgit v1.2.3


From 9b16537e2c7c2319670af02b7e4755d1b29d80a2 Mon Sep 17 00:00:00 2001
From: Tim Almdal <tnalmdal@shaw.ca>
Date: Thu, 19 Nov 2009 15:18:15 -0800
Subject: Revert "Revert "Revert "Use call_user_func instead of
 call_user_func_array as we don't need to pass the parameters by reference."""

This reverts commit 05b5a2c9ed9e5c3ed05eec8748f4bebc381993c4.
---
 installer/install.sql                              | 10 +--
 modules/g2_import/controllers/admin_g2_import.php  |  4 +-
 modules/g2_import/helpers/g2_import.php            |  4 +-
 .../gallery/controllers/admin_theme_options.php    | 51 ++++++++-------
 modules/gallery/controllers/albums.php             |  2 +-
 modules/gallery/helpers/gallery_event.php          | 21 ++-----
 modules/gallery/helpers/gallery_installer.php      | 21 ++-----
 modules/gallery/helpers/theme.php                  | 62 ++++++++----------
 modules/gallery/libraries/Theme_View.php           |  2 +-
 modules/gallery/module.info                        |  2 +-
 modules/gallery/views/admin_theme_options.html.php |  2 +-
 modules/search/controllers/search.php              |  2 +-
 modules/tag/controllers/tags.php                   |  2 +-
 themes/wind/helpers/wind.php                       | 73 ----------------------
 themes/wind/views/page.html.php                    |  6 +-
 15 files changed, 84 insertions(+), 180 deletions(-)
 delete mode 100644 themes/wind/helpers/wind.php

(limited to 'installer/install.sql')

diff --git a/installer/install.sql b/installer/install.sql
index af54c1eb..38851eff 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -228,7 +228,7 @@ CREATE TABLE {modules} (
   UNIQUE KEY `name` (`name`)
 ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
 SET character_set_client = @saved_cs_client;
-INSERT INTO {modules} VALUES (1,1,'gallery',20);
+INSERT INTO {modules} VALUES (1,1,'gallery',19);
 INSERT INTO {modules} VALUES (2,1,'user',2);
 INSERT INTO {modules} VALUES (3,1,'comment',2);
 INSERT INTO {modules} VALUES (4,1,'organize',1);
@@ -370,14 +370,14 @@ CREATE TABLE {vars} (
 SET character_set_client = @saved_cs_client;
 INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','wind');
 INSERT INTO {vars} VALUES (2,'gallery','active_admin_theme','admin_wind');
-INSERT INTO {vars} VALUES (3,'wind','page_size','9');
-INSERT INTO {vars} VALUES (4,'wind','thumb_size','200');
-INSERT INTO {vars} VALUES (5,'wind','resize_size','640');
+INSERT INTO {vars} VALUES (3,'gallery','page_size','9');
+INSERT INTO {vars} VALUES (4,'gallery','thumb_size','200');
+INSERT INTO {vars} VALUES (5,'gallery','resize_size','640');
 INSERT INTO {vars} VALUES (6,'gallery','default_locale','en_US');
 INSERT INTO {vars} VALUES (7,'gallery','image_quality','75');
 INSERT INTO {vars} VALUES (8,'gallery','image_sharpen','15');
 INSERT INTO {vars} VALUES (21,'gallery','time_format','H:i:s');
-INSERT INTO {vars} VALUES (22,'wind','show_credits','1');
+INSERT INTO {vars} VALUES (22,'gallery','show_credits','1');
 INSERT INTO {vars} VALUES (23,'gallery','credits','Powered by <a href=\"%url\">Gallery %version</a>');
 INSERT INTO {vars} VALUES (10,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}');
 INSERT INTO {vars} VALUES (20,'gallery','date_time_format','Y-M-d H:i:s');
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index 99d28fd7..1c65f482 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -35,8 +35,8 @@ class Admin_g2_import_Controller extends Admin_Controller {
     if (g2_import::is_initialized()) {
       $view->content->g2_stats = $g2_stats;
       $view->content->g2_sizes = $g2_sizes;
-      $view->content->thumb_size = theme::get_var("thumb_size", 200);
-      $view->content->resize_size = theme::get_var("resize_size", 640);
+      $view->content->thumb_size = module::get_var("gallery", "thumb_size");
+      $view->content->resize_size = module::get_var("gallery", "resize_size");
     }
     print $view;
   }
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 519da40f..202a0e92 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -671,8 +671,8 @@ class g2_import_Core {
     $g2_item_id = self::$current_g2_item->getId();
     $derivatives = g2(GalleryCoreApi::fetchDerivativesByItemIds(array($g2_item_id)));
 
-    $target_thumb_size = theme::get_var("thumb_size", 200);
-    $target_resize_size = theme::get_var("resize_size", 640);
+    $target_thumb_size = module::get_var("gallery", "thumb_size");
+    $target_resize_size = module::get_var("gallery", "resize_size");
     if (!empty($derivatives[$g2_item_id])) {
       foreach ($derivatives[$g2_item_id] as $derivative) {
         if ($derivative->getPostFilterOperations()) {
diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php
index c75aebaa..27a67bdb 100644
--- a/modules/gallery/controllers/admin_theme_options.php
+++ b/modules/gallery/controllers/admin_theme_options.php
@@ -21,41 +21,48 @@ 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");
-
-    $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("{$theme_name}::get_admin_form", "admin/theme_options/save/");
-
-    $view->content->title = t("%name options", array("name" => $info->name));
-
+    $view->content->form = theme::get_edit_form_admin();
     print $view;
   }
 
   public function save() {
     access::verify_csrf();
 
-    // 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);
+    $form = theme::get_edit_form_admin();
+    if ($form->validate()) {
+      module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
 
-    $info = theme::get_info($theme_name);
+      $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);
+      }
 
-    $form = call_user_func("{$theme_name}::get_admin_form", "admin/theme_options/save/");
-    if ($form->validate()) {
-      call_user_func("{$theme_name}::update_options", $form);
+      $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);
+      }
+
+      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);
 
-      message::success(t("Updated %name options", array("name" => $info->name)));
+      message::success(t("Updated theme details"));
       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/albums.php b/modules/gallery/controllers/albums.php
index 749fb520..e67df6f6 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 = theme::get_var("page_size", 9);
+    $page_size = module::get_var("gallery", "page_size", 9);
     if (!access::can("view", $album)) {
       if ($album->id == 1) {
         $view = new Theme_View("page.html", "other", "login");
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/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 4051c6e9..57a5ee9f 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -226,9 +226,9 @@ class gallery_installer {
 
     module::set_var("gallery", "active_site_theme", "wind");
     module::set_var("gallery", "active_admin_theme", "admin_wind");
-    module::set_var("wind", "page_size", 9);
-    module::set_var("wind", "thumb_size", 200);
-    module::set_var("wind", "resize_size", 640);
+    module::set_var("gallery", "page_size", 9);
+    module::set_var("gallery", "thumb_size", 200);
+    module::set_var("gallery", "resize_size", 640);
     module::set_var("gallery", "default_locale", "en_US");
     module::set_var("gallery", "image_quality", 75);
     module::set_var("gallery", "image_sharpen", 15);
@@ -265,10 +265,10 @@ class gallery_installer {
     module::set_var("gallery", "date_format", "Y-M-d");
     module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
     module::set_var("gallery", "time_format", "H:i:s");
-    module::set_var("wind", "show_credits", 1);
+    module::set_var("gallery", "show_credits", 1);
     // @todo this string needs to be picked up by l10n_scanner
     module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
-    module::set_version("gallery", 20);
+    module::set_version("gallery", 19);
   }
 
   static function upgrade($version) {
@@ -432,17 +432,6 @@ class gallery_installer {
       module::clear_var("gallery", "blocks_site.sidebar");
       module::set_version("gallery", $version = 19);
     }
-
-    // Move the theme related variables into the current theme
-    if ($version == 19) {
-      foreach (array("page_size", "thumb_size", "resize_size", "header_text",
-                     "footer_text", "show_credits") as $var) {
-        $value = module::get_var("gallery", $var);
-        theme::set_var($var, $value);
-        module::clear_var("gallery", $var);
-      }
-      module::set_version("gallery", $version = 20);
-    }
   }
 
   static function uninstall() {
diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php
index c7b773d1..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";
@@ -57,33 +77,5 @@ class theme_Core {
 
     return $theme_info;
   }
-
-  /**
-   * Get a variable from the active theme
-   * @param string $name
-   * @param string $default_value
-   * @return the value
-   */
-  static function get_var($name, $default_value=null) {
-    return module::get_var(self::$site, $name, $default_value);
-  }
-
-  /**
-   * Store a variable for active theme
-   * @param string $module_name
-   * @param string $name
-   * @param string $value
-   */
-  static function set_var($name, $value) {
-    module::set_var(self::$site, $name, $value);
-  }
-
- /**
-   * Remove a variable for this module.
-   * @param string $module_name
-   * @param string $name
-   */
-  static function clear_var($name) {
-    module::clear_var(self::$site, $name);
-  }
 }
+
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 87d8de56..b1167d0e 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -65,7 +65,7 @@ class Theme_View_Core extends Gallery_View {
   public function thumb_proportion() {
     // @TODO change the 200 to a theme supplied value when and if we come up with an
     // API to allow the theme to set defaults.
-    return theme::get_var("thumb_size", 200) / 200;
+    return module::get_var("gallery", "thumb_size", 200) / 200;
   }
 
   public function item() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index ecce9118..2dc62ecd 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
 name = "Gallery 3"
 description = "Gallery core application"
-version = 20
+version = 19
diff --git a/modules/gallery/views/admin_theme_options.html.php b/modules/gallery/views/admin_theme_options.html.php
index 9f28e055..a4bf1c4e 100644
--- a/modules/gallery/views/admin_theme_options.html.php
+++ b/modules/gallery/views/admin_theme_options.html.php
@@ -1,6 +1,6 @@
 <?php defined("SYSPATH") or die("No direct script access.") ?>
 <div class="g-block">
-  <h1> <?= t($title) ?> </h1>
+  <h1> <?= t("Theme Options") ?> </h1>
 
   <div class="g-block-content">
   <?= $form ?>
diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php
index fcee5233..539e063f 100644
--- a/modules/search/controllers/search.php
+++ b/modules/search/controllers/search.php
@@ -19,7 +19,7 @@
  */
 class Search_Controller extends Controller {
   public function index() {
-    $page_size = theme::get_var("page_size", 9);
+    $page_size = module::get_var("gallery", "page_size", 9);
     $q = $this->input->get("q");
     $page = $this->input->get("page", 1);
     $offset = ($page - 1) * $page_size;
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 6dc77d56..52001719 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -21,7 +21,7 @@ class Tags_Controller extends REST_Controller {
   protected $resource_type = "tag";
 
   public function _show($tag) {
-    $page_size = theme::get_var("page_size", 9);
+    $page_size = module::get_var("gallery", "page_size", 9);
     $page = (int) $this->input->get("page", "1");
     $children_count = $tag->items_count();
     $offset = ($page-1) * $page_size;
diff --git a/themes/wind/helpers/wind.php b/themes/wind/helpers/wind.php
deleted file mode 100644
index beef3d41..00000000
--- a/themes/wind/helpers/wind.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-class wind {
-  static function get_admin_form($action) {
-    $form = new Forge($action, "", null, array("id" =>"g-wind-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("wind", "page_size"));
-    $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size")
-      ->rules("required|valid_digit")
-      ->value(module::get_var("wind", "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("wind", "resize_size"));
-    $group->textarea("header_text")->label(t("Header text"))->id("g-header-text")
-      ->value(module::get_var("wind", "header_text"));
-    $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text")
-      ->value(module::get_var("wind", "footer_text"));
-    $group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text")
-      ->checked(module::get_var("wind", "show_credits"));
-    $group->submit("")->value(t("Save"));
-    return $form;
-  }
-
-  static function update_options($form) {
-    module::set_var("wind", "page_size", $form->edit_theme->page_size->value);
-
-    $thumb_size = $form->edit_theme->thumb_size->value;
-    $thumb_dirty = false;
-    if (module::get_var("wind", "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("wind", "thumb_size", $thumb_size);
-    }
-
-    $resize_size = $form->edit_theme->resize_size->value;
-    $resize_dirty = false;
-    if (module::get_var("wind", "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("wind", "resize_size", $resize_size);
-    }
-
-    module::set_var("wind", "header_text", $form->edit_theme->header_text->value);
-    module::set_var("wind", "footer_text", $form->edit_theme->footer_text->value);
-    module::set_var("wind", "show_credits", $form->edit_theme->show_credits->value);
-  }
-}
diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php
index ddaf33d0..03d43918 100644
--- a/themes/wind/views/page.html.php
+++ b/themes/wind/views/page.html.php
@@ -77,7 +77,7 @@
       <?= $theme->site_status() ?>
       <div id="g-header" class="ui-helper-clearfix">
         <div id="g-banner">
-          <? if ($header_text = theme::get_var("header_text")): ?>
+          <? if ($header_text = module::get_var("gallery", "header_text")): ?>
           <?= $header_text ?>
           <? else: ?>
           <a id="g-logo" class="g-left" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>">
@@ -129,11 +129,11 @@
       </div>
       <div id="g-footer" class="ui-helper-clearfix">
         <?= $theme->footer() ?>
-        <? if ($footer_text = theme::get_var("footer_text")): ?>
+        <? if ($footer_text = module::get_var("gallery", "footer_text")): ?>
         <?= $footer_text ?>
         <? endif ?>
 
-        <? if (theme::get_var("show_credits")): ?>
+        <? if (module::get_var("gallery", "show_credits")): ?>
         <ul id="g-credits" class="g-inline">
           <?= $theme->credits() ?>
         </ul>
-- 
cgit v1.2.3


From 1d42d5533a6f7ace5e2288d78f3fa55952e23ef8 Mon Sep 17 00:00:00 2001
From: Tim Almdal <tnalmdal@shaw.ca>
Date: Fri, 1 Jan 2010 09:55:06 -0800
Subject: Change the installer so that the rest module is automatically
 installed in new installations.

---
 installer/install.sql | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

(limited to 'installer/install.sql')

diff --git a/installer/install.sql b/installer/install.sql
index 916cb3e3..920972db 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -226,17 +226,18 @@ CREATE TABLE {modules} (
   `version` int(9) default NULL,
   PRIMARY KEY  (`id`),
   UNIQUE KEY `name` (`name`)
-) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
 SET character_set_client = @saved_cs_client;
 INSERT INTO {modules} VALUES (1,1,'gallery',21);
 INSERT INTO {modules} VALUES (2,1,'user',2);
 INSERT INTO {modules} VALUES (3,1,'comment',2);
 INSERT INTO {modules} VALUES (4,1,'organize',1);
 INSERT INTO {modules} VALUES (5,1,'info',1);
-INSERT INTO {modules} VALUES (6,1,'rss',1);
-INSERT INTO {modules} VALUES (7,1,'search',1);
-INSERT INTO {modules} VALUES (8,1,'slideshow',1);
-INSERT INTO {modules} VALUES (9,1,'tag',1);
+INSERT INTO {modules} VALUES (6,1,'rest',1);
+INSERT INTO {modules} VALUES (7,1,'rss',1);
+INSERT INTO {modules} VALUES (8,1,'search',1);
+INSERT INTO {modules} VALUES (9,1,'slideshow',2);
+INSERT INTO {modules} VALUES (10,1,'tag',1);
 DROP TABLE IF EXISTS {outgoing_translations};
 SET @saved_cs_client     = @@character_set_client;
 SET character_set_client = utf8;
@@ -333,6 +334,18 @@ CREATE TABLE {themes} (
 SET character_set_client = @saved_cs_client;
 INSERT INTO {themes} VALUES (1,'wind',1);
 INSERT INTO {themes} VALUES (2,'admin_wind',1);
+DROP TABLE IF EXISTS {user_access_tokens};
+SET @saved_cs_client     = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE {user_access_tokens} (
+  `id` int(9) NOT NULL auto_increment,
+  `user_id` int(9) NOT NULL,
+  `access_key` char(32) NOT NULL,
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `access_key` (`access_key`),
+  UNIQUE KEY `user_id` (`user_id`)
+) DEFAULT CHARSET=utf8;
+SET character_set_client = @saved_cs_client;
 DROP TABLE IF EXISTS {users};
 SET @saved_cs_client     = @@character_set_client;
 SET character_set_client = utf8;
@@ -366,7 +379,7 @@ CREATE TABLE {vars} (
   `value` text,
   PRIMARY KEY  (`id`),
   UNIQUE KEY `module_name` (`module_name`,`name`)
-) AUTO_INCREMENT=36 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
 SET character_set_client = @saved_cs_client;
 INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind');
 INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind');
@@ -389,3 +402,4 @@ INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5');
 INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0');
 INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user');
 INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:3:{i:9;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:10;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:11;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}');
+INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0');
-- 
cgit v1.2.3


From df001700dd071c59c47afd07d2c756487d20684e Mon Sep 17 00:00:00 2001
From: Bharat Mediratta <bharat@menalto.com>
Date: Fri, 1 Jan 2010 12:17:04 -0800
Subject: Don't enable the rest module by default yet; we should make sure that
 we do a more thorough security audit on it first.

---
 installer/install.sql                    | 23 +++++------------------
 modules/gallery/controllers/packager.php |  2 +-
 2 files changed, 6 insertions(+), 19 deletions(-)

(limited to 'installer/install.sql')

diff --git a/installer/install.sql b/installer/install.sql
index 920972db..6e7c06a2 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -226,18 +226,17 @@ CREATE TABLE {modules} (
   `version` int(9) default NULL,
   PRIMARY KEY  (`id`),
   UNIQUE KEY `name` (`name`)
-) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
 SET character_set_client = @saved_cs_client;
 INSERT INTO {modules} VALUES (1,1,'gallery',21);
 INSERT INTO {modules} VALUES (2,1,'user',2);
 INSERT INTO {modules} VALUES (3,1,'comment',2);
 INSERT INTO {modules} VALUES (4,1,'organize',1);
 INSERT INTO {modules} VALUES (5,1,'info',1);
-INSERT INTO {modules} VALUES (6,1,'rest',1);
-INSERT INTO {modules} VALUES (7,1,'rss',1);
-INSERT INTO {modules} VALUES (8,1,'search',1);
-INSERT INTO {modules} VALUES (9,1,'slideshow',2);
-INSERT INTO {modules} VALUES (10,1,'tag',1);
+INSERT INTO {modules} VALUES (6,1,'rss',1);
+INSERT INTO {modules} VALUES (7,1,'search',1);
+INSERT INTO {modules} VALUES (8,1,'slideshow',2);
+INSERT INTO {modules} VALUES (9,1,'tag',1);
 DROP TABLE IF EXISTS {outgoing_translations};
 SET @saved_cs_client     = @@character_set_client;
 SET character_set_client = utf8;
@@ -334,18 +333,6 @@ CREATE TABLE {themes} (
 SET character_set_client = @saved_cs_client;
 INSERT INTO {themes} VALUES (1,'wind',1);
 INSERT INTO {themes} VALUES (2,'admin_wind',1);
-DROP TABLE IF EXISTS {user_access_tokens};
-SET @saved_cs_client     = @@character_set_client;
-SET character_set_client = utf8;
-CREATE TABLE {user_access_tokens} (
-  `id` int(9) NOT NULL auto_increment,
-  `user_id` int(9) NOT NULL,
-  `access_key` char(32) NOT NULL,
-  PRIMARY KEY  (`id`),
-  UNIQUE KEY `access_key` (`access_key`),
-  UNIQUE KEY `user_id` (`user_id`)
-) DEFAULT CHARSET=utf8;
-SET character_set_client = @saved_cs_client;
 DROP TABLE IF EXISTS {users};
 SET @saved_cs_client     = @@character_set_client;
 SET character_set_client = utf8;
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index 03d56fff..cb64f1bf 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -63,7 +63,7 @@ class Packager_Controller extends Controller {
 
     module::load_modules();
 
-    foreach (array("user", "comment", "organize", "info", "rest", "rss",
+    foreach (array("user", "comment", "organize", "info", "rss",
                    "search", "slideshow", "tag") as $module_name) {
       module::install($module_name);
       module::activate($module_name);
-- 
cgit v1.2.3

