summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r--modules/gallery/controllers/admin_maintenance.php6
-rw-r--r--modules/gallery/controllers/admin_theme_options.php40
-rw-r--r--modules/gallery/controllers/admin_themes.php7
-rw-r--r--modules/gallery/controllers/albums.php6
-rw-r--r--modules/gallery/controllers/file_proxy.php4
-rw-r--r--modules/gallery/controllers/maintenance.php24
-rw-r--r--modules/gallery/controllers/move.php71
-rw-r--r--modules/gallery/controllers/movies.php2
-rw-r--r--modules/gallery/controllers/packager.php6
-rw-r--r--modules/gallery/controllers/photos.php2
-rw-r--r--modules/gallery/controllers/quick.php22
-rw-r--r--modules/gallery/controllers/uploader.php11
-rw-r--r--modules/gallery/controllers/user_profile.php2
13 files changed, 73 insertions, 130 deletions
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 3567b4f0..a9cc933c 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -226,4 +226,10 @@ class Admin_Maintenance_Controller extends Admin_Controller {
"done" => (bool) $task->done)));
}
}
+
+ public function maintenance_mode($value) {
+ access::verify_csrf();
+ module::set_var("gallery", "maintenance_mode", $value);
+ url::redirect("admin/maintenance");
+ }
}
diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php
index 15a42ee5..57f32f96 100644
--- a/modules/gallery/controllers/admin_theme_options.php
+++ b/modules/gallery/controllers/admin_theme_options.php
@@ -22,14 +22,14 @@ class Admin_Theme_Options_Controller extends Admin_Controller {
$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);
@@ -58,6 +58,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller {
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);
+ module::set_var("gallery", "favicon_url", $form->edit_theme->favicon_url->value);
module::event("theme_edit_form_completed", $form);
@@ -70,5 +71,40 @@ class Admin_Theme_Options_Controller extends Admin_Controller {
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->input("favicon_url")->label(t("URL (or relative path) to your favicon.ico"))
+ ->id("g-favicon")
+ ->value(module::get_var("gallery", "favicon_url"));
+ $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");
+ $group->submit("")->value(t("Save"));
+ return $form;
+ }
}
diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php
index e59eadaf..a88e1e89 100644
--- a/modules/gallery/controllers/admin_themes.php
+++ b/modules/gallery/controllers/admin_themes.php
@@ -31,10 +31,11 @@ class Admin_Themes_Controller extends Admin_Controller {
private function _get_themes() {
$themes = array();
foreach (scandir(THEMEPATH) as $theme_name) {
+ if ($theme_name[0] == ".") {
+ continue;
+ }
+ $theme_name = preg_replace("/[^a-zA-Z0-9\._-]/", "", $theme_name);
if (file_exists(THEMEPATH . "$theme_name/theme.info")) {
- if ($theme_name[0] == ".") {
- continue;
- }
$themes[$theme_name] = theme::get_info($theme_name);
}
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index f3f5dee3..b0887195 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -68,7 +68,7 @@ class Albums_Controller extends Items_Controller {
$template->set_global("item", $album);
$template->set_global("children", $album->viewable()->children($page_size, $offset));
$template->set_global("children_count", $children_count);
- $template->set_global("parents", $album->parents());
+ $template->set_global("parents", $album->parents()->as_array()); // view calls empty() on this
$template->content = new View("album.html");
// We can't use math in ORM or the query builder, so do this by hand. It's important
@@ -132,7 +132,9 @@ class Albums_Controller extends Items_Controller {
$album->description = $form->edit_item->description->value;
$album->sort_column = $form->edit_item->sort_order->column->value;
$album->sort_order = $form->edit_item->sort_order->direction->value;
- $album->name = $form->edit_item->inputs["name"]->value;
+ if (array_key_exists("name", $form->edit_item->inputs)) {
+ $album->name = $form->edit_item->inputs["name"]->value;
+ }
$album->slug = $form->edit_item->slug->value;
$album->validate();
} catch (ORM_Validation_Exception $e) {
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index 15b4279f..b17310c4 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -116,6 +116,8 @@ class File_Proxy_Controller extends Controller {
throw new Kohana_404_Exception();
}
+ header("Content-Length: " . filesize($file));
+
header("Pragma:");
// Check that the content hasn't expired or it wasn't changed since cached
expires::check(2592000, $item->updated);
@@ -127,7 +129,7 @@ class File_Proxy_Controller extends Controller {
// Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
if ($item->is_movie() && $type != "albums") {
- header("Content-type: image/jpeg");
+ header("Content-Type: image/jpeg");
} else {
header("Content-Type: $item->mime_type");
}
diff --git a/modules/gallery/controllers/maintenance.php b/modules/gallery/controllers/maintenance.php
deleted file mode 100644
index 27673ff0..00000000
--- a/modules/gallery/controllers/maintenance.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 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 Maintenance_Controller extends Controller {
- function index() {
- print new View("maintenance.html");
- }
-} \ No newline at end of file
diff --git a/modules/gallery/controllers/move.php b/modules/gallery/controllers/move.php
deleted file mode 100644
index 7b2d6165..00000000
--- a/modules/gallery/controllers/move.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 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 Move_Controller extends Controller {
- public function browse($source_id) {
- $source = ORM::factory("item", $source_id);
- access::required("view", $source);
- access::required("edit", $source);
-
- $view = new View("move_browse.html");
- $view->source = $source;
- $view->tree = $this->_get_tree_html($source, ORM::factory("item", 1));
- print $view;
- }
-
- public function save($source_id) {
- access::verify_csrf();
- $source = ORM::factory("item", $source_id);
- $target = ORM::factory("item", Input::instance()->post("target_id"));
-
- access::required("view", $source);
- access::required("edit", $source);
- access::required("view", $target);
- access::required("edit", $target);
-
- item::move($source, $target);
-
- json::reply(array("result" => "success", "location" => $target->url()));
- }
-
- public function show_sub_tree($source_id, $target_id) {
- $source = ORM::factory("item", $source_id);
- $target = ORM::factory("item", $target_id);
- access::required("view", $source);
- access::required("edit", $source);
- access::required("view", $target);
- // show targets even if they're not editable because they may contain children which *are*
- // editable
-
- print $this->_get_tree_html($source, $target);
- }
-
- private function _get_tree_html($source, $target) {
- $view = new View("move_tree.html");
- $view->source = $source;
- $view->parent = $target;
- $view->children = ORM::factory("item")
- ->viewable()
- ->where("type", "=", "album")
- ->where("parent_id", "=", $target->id)
- ->find_all();
- return $view;
- }
-
-}
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 02d2a497..717eb8aa 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -41,7 +41,7 @@ class Movies_Controller extends Items_Controller {
$template->set_global("item", $movie);
$template->set_global("children", array());
$template->set_global("children_count", 0);
- $template->set_global("parents", $movie->parents());
+ $template->set_global("parents", $movie->parents()->as_array());
$template->set_global("next_item", $next_item);
$template->set_global("previous_item", $previous_item);
$template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where));
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index 835cb903..f463d0de 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -59,11 +59,7 @@ class Packager_Controller extends Controller {
// numbers, keeping our install.sql file more stable.
srand(0);
- gallery_installer::install(true);
-
- module::load_modules();
-
- foreach (array("user", "comment", "organize", "info", "rest",
+ foreach (array("gallery", "user", "comment", "organize", "info", "rest",
"rss", "search", "slideshow", "tag") as $module_name) {
module::install($module_name);
module::activate($module_name);
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 8377e6c7..b22ac8e5 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -41,7 +41,7 @@ class Photos_Controller extends Items_Controller {
$template->set_global("item", $photo);
$template->set_global("children", array());
$template->set_global("children_count", 0);
- $template->set_global("parents", $photo->parents());
+ $template->set_global("parents", $photo->parents()->as_array());
$template->set_global("next_item", $next_item);
$template->set_global("previous_item", $previous_item);
$template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where));
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php
index fee601d9..c34209da 100644
--- a/modules/gallery/controllers/quick.php
+++ b/modules/gallery/controllers/quick.php
@@ -36,25 +36,11 @@ class Quick_Controller extends Controller {
}
if ($degrees) {
- gallery_graphics::rotate($item->file_path(), $item->file_path(),
- array("degrees" => $degrees));
-
- list($item->width, $item->height) = getimagesize($item->file_path());
- $item->resize_dirty= 1;
- $item->thumb_dirty= 1;
+ $tmpfile = tempnam(TMPPATH, "rotate");
+ gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees));
+ $item->set_data_file($tmpfile);
$item->save();
-
- graphics::generate($item);
-
- // @todo: this is an inadequate way to regenerate album cover thumbnails after rotation.
- foreach (ORM::factory("item")
- ->where("album_cover_item_id", "=", $item->id)
- ->find_all() as $target) {
- copy($item->thumb_path(), $target->thumb_path());
- $target->thumb_width = $item->thumb_width;
- $target->thumb_height = $item->thumb_height;
- $target->save();
- }
+ unlink($tmpfile);
}
if (Input::instance()->get("page_type") == "collection") {
diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php
index 87520032..fb496f60 100644
--- a/modules/gallery/controllers/uploader.php
+++ b/modules/gallery/controllers/uploader.php
@@ -50,7 +50,8 @@ class Uploader_Controller extends Controller {
// Uploadify adds its own field to the form, so validate that separately.
$file_validation = new Validation($_FILES);
$file_validation->add_rules(
- "Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4,m4v]");
+ "Filedata", "upload::valid", "upload::required",
+ "upload::type[gif,jpg,jpeg,png,flv,mp4,m4v]");
if ($form->validate() && $file_validation->validate()) {
$temp_filename = upload::save("Filedata");
@@ -101,6 +102,14 @@ class Uploader_Controller extends Controller {
}
}
+ public function status($success_count, $error_count) {
+ // The "errors" won't be properly pluralized :-/
+ print t2("Uploaded %count photo (%error errors)",
+ "Uploaded %count photos (%error errors)",
+ $success_count,
+ array("error" => $error_count));
+ }
+
public function finish() {
access::verify_csrf();
diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php
index 726d3e51..e992655b 100644
--- a/modules/gallery/controllers/user_profile.php
+++ b/modules/gallery/controllers/user_profile.php
@@ -56,7 +56,7 @@ class User_Profile_Controller extends Controller {
->to($user->email)
->subject(html::clean($form->message->subject->value))
->header("Mime-Version", "1.0")
- ->header("Content-type", "text/html; charset=iso-8859-1")
+ ->header("Content-type", "text/html; charset=UTF-8")
->reply_to($form->message->reply_to->value)
->message(html::purify($form->message->message->value))
->send();