summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/MY_url.php21
-rw-r--r--modules/gallery/helpers/graphics.php7
-rw-r--r--modules/gallery/helpers/l10n_client.php7
-rw-r--r--modules/gallery/helpers/module.php36
-rw-r--r--modules/gallery/helpers/movie.php8
-rw-r--r--modules/gallery/helpers/photo.php4
6 files changed, 53 insertions, 30 deletions
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php
index c8645c4d..7bee70ca 100644
--- a/modules/gallery/helpers/MY_url.php
+++ b/modules/gallery/helpers/MY_url.php
@@ -46,7 +46,19 @@ class url extends url_Core {
return;
}
- $current_uri = html_entity_decode(Router::$current_uri, ENT_QUOTES);
+ $item = self::get_item_from_uri(Router::$current_uri);
+ if ($item && $item->loaded) {
+ Router::$controller = "{$item->type}s";
+ Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
+ Router::$method = $item->id;
+ }
+ }
+
+ /**
+ * Return the item that the uri is referencing
+ */
+ static function get_item_from_uri($uri) {
+ $current_uri = html_entity_decode($uri);
$item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find();
if (!$item->loaded) {
// It's possible that the relative path cache for the item we're looking for is out of date,
@@ -61,12 +73,7 @@ class url extends url_Core {
}
}
}
-
- if ($item && $item->loaded) {
- Router::$controller = "{$item->type}s";
- Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
- Router::$method = $item->id;
- }
+ return $item;
}
/**
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 4846fa8a..25eb0891 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -166,12 +166,11 @@ class graphics_Core {
$item->resize_dirty = 0;
}
$item->save();
- } catch (Kohana_Exception $e) {
+ } catch (Exception $e) {
// Something went wrong rebuilding the image. Leave it dirty and move on.
// @todo we should handle this better.
Kohana::log("error", "Caught exception rebuilding image: {$item->title}\n" .
- $e->getMessage() . "\n" .
- $e->getTraceAsString());
+ $e->getMessage() . "\n" . $e->getTraceAsString());
return false;
}
@@ -192,7 +191,7 @@ class graphics_Core {
}
if (filesize($input_file) == 0) {
- throw new Exception("@todo MALFORMED_INPUT_FILE");
+ throw new Exception("@todo EMPTY_INPUT_FILE");
}
$dims = getimagesize($input_file);
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index 33f23857..20f81ecc 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -123,7 +123,12 @@ class l10n_client_Core {
$key = $message_data->key;
$locale = $message_data->locale;
$revision = $message_data->rev;
- $translation = serialize(json_decode($message_data->translation));
+ $translation = json_decode($message_data->translation);
+ if (!is_string($translation)) {
+ // Normalize stdclass to array
+ $translation = (array) $translation;
+ }
+ $translation = serialize($translation);
// @todo Should we normalize the incoming_translations table into messages(id, key, message)
// and incoming_translations(id, translation, locale, revision)? Or just allow
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 2fd5be6c..dea8e22c 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -27,6 +27,7 @@ class module_Core {
public static $active = array();
public static $modules = array();
public static $var_cache = null;
+ public static $available = array();
/**
* Set the version of the corresponding Module_Model
@@ -39,7 +40,7 @@ class module_Core {
$module->name = $module_name;
$module->active = $module_name == "gallery"; // only gallery is active by default
}
- $module->version = 1;
+ $module->version = $version;
$module->save();
Kohana::log("debug", "$module_name: version is now $version");
}
@@ -74,22 +75,27 @@ class module_Core {
* Return the list of available modules, including uninstalled modules.
*/
static function available() {
- $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
- foreach (glob(MODPATH . "*/module.info") as $file) {
- $module_name = basename(dirname($file));
- $modules->$module_name = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
- $modules->$module_name->installed = self::is_installed($module_name);
- $modules->$module_name->active = self::is_active($module_name);
- $modules->$module_name->version = self::get_version($module_name);
- $modules->$module_name->locked = false;
- }
+ if (empty(self::$available)) {
+ $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
+ foreach (glob(MODPATH . "*/module.info") as $file) {
+ $module_name = basename(dirname($file));
+ $modules->$module_name = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
+ $m =& $modules->$module_name;
+ $m->installed = self::is_installed($module_name);
+ $m->active = self::is_active($module_name);
+ $m->code_version = $m->version;
+ $m->version = self::get_version($module_name);
+ $m->locked = false;
+ }
- // Lock certain modules
- $modules->gallery->locked = true;
- $modules->user->locked = true;
- $modules->ksort();
+ // Lock certain modules
+ $modules->gallery->locked = true;
+ $modules->user->locked = true;
+ $modules->ksort();
+ self::$available = $modules;
+ }
- return $modules;
+ return self::$available;
}
/**
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 3aa40dc9..986d5f62 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -142,10 +142,12 @@ class movie_Core {
if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) {
if (function_exists("exec")) {
$ffmpeg_path = exec("which ffmpeg");
- if ($ffmpeg_path) {
- module::set_var("gallery", "ffmpeg_path", $ffmpeg_path);
- }
}
+
+ if (empty($ffmpeg) && @file_exists("/usr/local/bin/ffmpeg")) {
+ $ffmpeg_path = "/usr/local/bin/ffmpeg";
+ }
+ module::set_var("gallery", "ffmpeg_path", $ffmpeg_path);
}
return $ffmpeg_path;
}
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index c1c005f5..a4bc853b 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -53,6 +53,10 @@ class photo_Core {
throw new Exception("@todo NAME_CANNOT_END_IN_PERIOD");
}
+ if (filesize($filename) == 0) {
+ throw new Exception("@todo EMPTY_INPUT_FILE");
+ }
+
$image_info = getimagesize($filename);
// Force an extension onto the name