summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r--modules/gallery/controllers/admin_graphics.php39
-rw-r--r--modules/gallery/controllers/admin_languages.php52
-rw-r--r--modules/gallery/controllers/combined.php9
-rw-r--r--modules/gallery/controllers/file_proxy.php2
-rw-r--r--modules/gallery/controllers/l10n_client.php13
-rw-r--r--modules/gallery/controllers/packager.php4
-rw-r--r--modules/gallery/controllers/quick.php14
-rw-r--r--modules/gallery/controllers/simple_uploader.php2
8 files changed, 50 insertions, 85 deletions
diff --git a/modules/gallery/controllers/admin_graphics.php b/modules/gallery/controllers/admin_graphics.php
index 72f8d8e1..c59dd38e 100644
--- a/modules/gallery/controllers/admin_graphics.php
+++ b/modules/gallery/controllers/admin_graphics.php
@@ -21,41 +21,24 @@ class Admin_Graphics_Controller extends Admin_Controller {
public function index() {
$view = new Admin_View("admin.html");
$view->content = new View("admin_graphics.html");
- $view->content->available = "";
-
- $tk = new ArrayObject(graphics::detect_toolkits(), ArrayObject::ARRAY_AS_PROPS);
- $active = module::get_var("gallery", "graphics_toolkit", "none");
- foreach (array("gd", "imagemagick", "graphicsmagick", "none") as $id) {
- if ($id == $active) {
- $view->content->active = new View("admin_graphics_$id.html");
- $view->content->active->tk = $tk;
- $view->content->active->is_active = true;
- } else if ($id != "none") {
- $v = new View("admin_graphics_$id.html");
- $v->tk = $tk;
- $v->is_active = false;
- $view->content->available .= $v;
- }
- }
-
+ $view->content->tk = graphics::detect_toolkits();
+ $view->content->active = module::get_var("gallery", "graphics_toolkit", "none");
print $view;
}
- public function choose($toolkit) {
+ public function choose($toolkit_id) {
access::verify_csrf();
- if ($toolkit != module::get_var("gallery", "graphics_toolkit")) {
- module::set_var("gallery", "graphics_toolkit", $toolkit);
-
- $toolkit_info = graphics::detect_toolkits();
- if ($toolkit == "graphicsmagick" || $toolkit == "imagemagick") {
- module::set_var("gallery", "graphics_toolkit_path", $toolkit_info[$toolkit]);
- }
+ if ($toolkit_id != module::get_var("gallery", "graphics_toolkit")) {
+ $tk = graphics::detect_toolkits();
+ module::set_var("gallery", "graphics_toolkit", $toolkit_id);
+ module::set_var("gallery", "graphics_toolkit_path", $tk->$toolkit_id->dir);
site_status::clear("missing_graphics_toolkit");
- message::success(t("Updated Graphics Toolkit"));
- log::success("graphics", t("Changed graphics toolkit to: %toolkit",
- array("toolkit" => $toolkit)));
+
+ $msg = t("Changed graphics toolkit to: %toolkit", array("toolkit" => $tk->$toolkit_id->name));
+ message::success($msg);
+ log::success("graphics", $msg);
}
url::redirect("admin/graphics");
diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php
index ae90ad07..6dc242c6 100644
--- a/modules/gallery/controllers/admin_languages.php
+++ b/modules/gallery/controllers/admin_languages.php
@@ -21,7 +21,10 @@ class Admin_Languages_Controller extends Admin_Controller {
public function index($share_translations_form=null) {
$v = new Admin_View("admin.html");
$v->content = new View("admin_languages.html");
- $v->content->settings_form = $this->_languages_form();
+ $v->content->available_locales = locales::available();
+ $v->content->installed_locales = locales::installed();
+ $v->content->default_locale = module::get_var("gallery", "default_locale");
+
if (empty($share_translations_form)) {
$share_translations_form = $this->_share_translations_form();
}
@@ -32,14 +35,21 @@ class Admin_Languages_Controller extends Admin_Controller {
public function save() {
access::verify_csrf();
-
- $form = $this->_languages_form();
- if ($form->validate()) {
- module::set_var("gallery", "default_locale", $form->choose_language->locale->value);
- locales::update_installed($form->choose_language->installed_locales->value);
- message::success(t("Settings saved"));
- }
- url::redirect("admin/languages");
+
+ locales::update_installed($this->input->post("installed_locales"));
+
+ $installed_locales = array_keys(locales::installed());
+ $new_default_locale = $this->input->post("default_locale");
+ if (!in_array($new_default_locale, $installed_locales)) {
+ if (!empty($installed_locales)) {
+ $new_default_locale = $installed_locales[0];
+ } else {
+ $new_default_locale = "en_US";
+ }
+ }
+ module::set_var("gallery", "default_locale", $new_default_locale);
+
+ print json_encode(array("result" => "success"));
}
public function share() {
@@ -88,30 +98,6 @@ class Admin_Languages_Controller extends Admin_Controller {
}
}
- private function _languages_form() {
- $all_locales = locales::available();
- $installed_locales = locales::installed();
- $form = new Forge("admin/languages/save", "", "post", array("id" => "gLanguageSettingsForm"));
- $group = $form->group("choose_language")
- ->label(t("Language settings"));
- $group->dropdown("locale")
- ->options($installed_locales)
- ->selected(module::get_var("gallery", "default_locale"))
- ->label(t("Default language"))
- ->rules('required');
-
- $installation_options = array();
- foreach ($all_locales as $code => $display_name) {
- $installation_options[$code] = array($display_name, isset($installed_locales->$code));
- }
- $group->checklist("installed_locales")
- ->label(t("Installed Languages"))
- ->options($installation_options)
- ->rules("required");
- $group->submit("save")->value(t("Save settings"));
- return $form;
- }
-
private function _outgoing_translations_count() {
return ORM::factory("outgoing_translation")->count_all();
}
diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php
index 9a790fdf..c1f42bfe 100644
--- a/modules/gallery/controllers/combined.php
+++ b/modules/gallery/controllers/combined.php
@@ -42,22 +42,23 @@ class Combined_Controller extends Controller {
private function _emit($type, $key) {
$input = Input::instance();
+ // We don't need to save the session for this request
+ Session::abort_save();
+
// Our data is immutable, so if they already have a copy then it needs no updating.
if ($input->server("HTTP_IF_MODIFIED_SINCE")) {
header('HTTP/1.0 304 Not Modified');
header("Expires: Tue, 19 Jan 2038 00:00:00 GMT");
header("Cache-Control: max-age=2678400");
header('Pragma: public');
- return;
+ Kohana::close_buffers(false);
+ return "";
}
if (empty($key)) {
Kohana::show_404();
}
- // We don't need to save the session for this request
- Session::abort_save();
-
$cache = Cache::instance();
$use_gzip = function_exists("gzencode") &&
stripos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false &&
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index a85f0a85..8cb90c50 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -119,7 +119,7 @@ class File_Proxy_Controller extends Controller {
if (in_array($item->mime_type, array("video/x-flv", "video/mp4"))) {
header("Content-type: image/jpeg");
} else {
- print("Content-Type: $item->mime_type");
+ header("Content-Type: $item->mime_type");
}
Kohana::close_buffers(false);
diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php
index 831c79c1..0775791e 100644
--- a/modules/gallery/controllers/l10n_client.php
+++ b/modules/gallery/controllers/l10n_client.php
@@ -90,10 +90,15 @@ class L10n_Client_Controller extends Controller {
}
$session = Session::instance();
- $session->set("l10n_mode",
- !$session->get("l10n_mode", false));
-
- url::redirect("albums/1");
+ $l10n_mode = $session->get("l10n_mode", false);
+ $session->set("l10n_mode", !$l10n_mode);
+
+ $redirect_url = "admin/languages";
+ if (!$l10n_mode) {
+ $redirect_url .= "#l10n-client";
+ }
+
+ url::redirect($redirect_url);
}
private static function _l10n_client_search_form() {
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index 7b4d68f6..fbb1d07d 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -123,6 +123,10 @@ class Packager_Controller extends Controller {
// Normalize dates
$line = preg_replace("/,$root_created_timestamp,/", ",UNIX_TIMESTAMP(),", $line);
$line = preg_replace("/,$root_updated_timestamp,/", ",UNIX_TIMESTAMP(),", $line);
+
+ // Remove ENGINE= specifications
+ $line = preg_replace("/ENGINE=\S+ /", "", $line);
+
$buf .= $line;
}
$fd = fopen($sql_file, "wb");
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php
index 98a5bf9f..8fddb563 100644
--- a/modules/gallery/controllers/quick.php
+++ b/modules/gallery/controllers/quick.php
@@ -18,20 +18,6 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Quick_Controller extends Controller {
- public function pane($id) {
- $item = model_cache::get("item", $id);
- if (!access::can("view", $item) || !access::can("edit", $item)) {
- return "";
- }
-
- $view = new View("quick_pane.html");
- $page_type = Input::instance()->get("page_type");
- $view->button_list = gallery_quick::get_quick_buttons($item, $page_type);
- $view->item = $item;
- $view->page_type = $page_type;
- print $view;
- }
-
public function rotate($id, $dir) {
access::verify_csrf();
$item = model_cache::get("item", $id);
diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php
index e7c0bd6f..156d18ac 100644
--- a/modules/gallery/controllers/simple_uploader.php
+++ b/modules/gallery/controllers/simple_uploader.php
@@ -71,7 +71,7 @@ class Simple_Uploader_Controller extends Controller {
unlink($temp_filename);
}
header("HTTP/1.1 500 Internal Server Error");
- print "ERROR:" . $e->getMessage();
+ print "ERROR: " . $e->getMessage();
return;
}
unlink($temp_filename);