summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/config/log_file.php11
-rw-r--r--modules/gallery/controllers/admin_maintenance.php8
-rw-r--r--modules/gallery/controllers/albums.php3
-rw-r--r--modules/gallery/controllers/file_proxy.php6
-rw-r--r--modules/gallery/controllers/l10n_client.php14
-rw-r--r--modules/gallery/controllers/permissions.php2
-rw-r--r--modules/gallery/controllers/simple_uploader.php2
-rw-r--r--modules/gallery/helpers/MY_url.php4
-rw-r--r--modules/gallery/helpers/access.php18
-rw-r--r--modules/gallery/helpers/album.php2
-rw-r--r--modules/gallery/helpers/auth.php2
-rw-r--r--modules/gallery/helpers/gallery_graphics.php2
-rw-r--r--modules/gallery/helpers/gallery_task.php2
-rw-r--r--modules/gallery/helpers/graphics.php2
-rw-r--r--modules/gallery/helpers/identity.php4
-rw-r--r--modules/gallery/helpers/item.php18
-rw-r--r--modules/gallery/helpers/l10n_client.php2
-rw-r--r--modules/gallery/helpers/l10n_scanner.php4
-rw-r--r--modules/gallery/helpers/locales.php6
-rw-r--r--modules/gallery/helpers/model_cache.php4
-rw-r--r--modules/gallery/helpers/module.php35
-rw-r--r--modules/gallery/helpers/movie.php2
-rw-r--r--modules/gallery/helpers/photo.php2
-rw-r--r--modules/gallery/helpers/site_status.php4
-rw-r--r--modules/gallery/helpers/task.php8
-rw-r--r--modules/gallery/helpers/theme.php2
-rw-r--r--modules/gallery/hooks/init_gallery.php2
-rw-r--r--modules/gallery/libraries/Admin_View.php2
-rw-r--r--modules/gallery/libraries/Gallery_I18n.php (renamed from modules/gallery/libraries/I18n.php)16
-rw-r--r--modules/gallery/libraries/Gallery_View.php6
-rw-r--r--modules/gallery/libraries/IdentityProvider.php4
-rw-r--r--modules/gallery/libraries/MY_Database.php38
-rw-r--r--modules/gallery/libraries/MY_ORM.php10
-rw-r--r--modules/gallery/libraries/MY_View.php27
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php56
-rw-r--r--modules/gallery/libraries/SafeString.php2
-rw-r--r--modules/gallery/libraries/Sendmail.php4
-rw-r--r--modules/gallery/libraries/Theme_View.php2
-rw-r--r--modules/gallery/libraries/drivers/Cache/Database.php95
-rw-r--r--modules/gallery/models/item.php6
-rw-r--r--modules/gallery/models/log.php2
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php8
-rw-r--r--modules/gallery/tests/I18n_Test.php6
-rw-r--r--modules/gallery/views/kohana_error_page.php2
44 files changed, 232 insertions, 225 deletions
diff --git a/modules/gallery/config/log_file.php b/modules/gallery/config/log_file.php
new file mode 100644
index 00000000..3d3f8edd
--- /dev/null
+++ b/modules/gallery/config/log_file.php
@@ -0,0 +1,11 @@
+<?php defined('SYSPATH') OR die('No direct access allowed.');
+
+/**
+ * Message logging directory.
+ */
+$config['log_directory'] = VARPATH.'logs';
+
+/**
+ * Permissions of the log file
+ */
+$config['posix_permissions'] = 0644; \ No newline at end of file
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 66bcce55..fe5059e7 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -75,7 +75,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
access::verify_csrf();
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
$view = new View("admin_maintenance_task.html");
@@ -97,7 +97,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
access::verify_csrf();
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
$view = new View("admin_maintenance_show_log.html");
@@ -114,7 +114,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
access::verify_csrf();
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
@@ -184,7 +184,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
try {
$task = task::run($task_id);
} catch (Exception $e) {
- Kohana::log(
+ Kohana_Log::add(
"error",
sprintf(
"%s in %s at line %s:\n%s", $e->getMessage(), $e->getFile(),
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 43040b67..19140891 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -62,6 +62,7 @@ class Albums_Controller extends Items_Controller {
$template = new Theme_View("page.html", "collection", "album");
$template->set_global("page", $page);
+ $template->set_global("page_title", null);
$template->set_global("max_pages", $max_pages);
$template->set_global("page_size", $page_size);
$template->set_global("item", $album);
@@ -72,7 +73,7 @@ class Albums_Controller extends Items_Controller {
// We can't use math in ORM or the query builder, so do this by hand. It's important
// that we do this with math, otherwise concurrent accesses will damage accuracy.
- Database::instance()->query(
+ db::query(
"UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id");
print $template;
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index acfd6eb9..11d858c0 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -58,7 +58,7 @@ class File_Proxy_Controller extends Controller {
// We now have the relative path to the item. Search for it in the path cache
$item = ORM::factory("item")->where("relative_path_cache", $path)->find();
- if (!$item->loaded) {
+ if (!$item->loaded()) {
// We didn't turn it up. It's possible that the relative_path_cache is out of date here.
// There was fallback code, but bharat deleted it in 8f1bca74. If it turns out to be
// necessary, it's easily resurrected.
@@ -70,14 +70,14 @@ class File_Proxy_Controller extends Controller {
foreach (array("flv", "mp4") as $ext) {
$movie_path = preg_replace('/.jpg$/', ".$ext", $path);
$item = ORM::factory("item")->where("relative_path_cache", $movie_path)->find();
- if ($item->loaded) {
+ if ($item->loaded()) {
break;
}
}
}
}
- if (!$item->loaded) {
+ if (!$item->loaded()) {
kohana::show_404();
}
diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php
index 6db67d3b..2eda741c 100644
--- a/modules/gallery/controllers/l10n_client.php
+++ b/modules/gallery/controllers/l10n_client.php
@@ -24,7 +24,7 @@ class L10n_Client_Controller extends Controller {
access::forbidden();
}
- $locale = I18n::instance()->locale();
+ $locale = Gallery_I18n::instance()->locale();
$input = Input::instance();
$key = $input->post("l10n-message-key");
@@ -33,10 +33,10 @@ class L10n_Client_Controller extends Controller {
"locale" => "root"))
->find();
- if (!$root_message->loaded) {
+ if (!$root_message->loaded()) {
throw new Exception("@todo bad request data / illegal state");
}
- $is_plural = I18n::is_plural_message(unserialize($root_message->message));
+ $is_plural = Gallery_I18n::is_plural_message(unserialize($root_message->message));
if ($is_plural) {
$plural_forms = l10n_client::plural_forms($locale);
@@ -60,7 +60,7 @@ class L10n_Client_Controller extends Controller {
"locale" => $locale))
->find();
- if (!$entry->loaded) {
+ if (!$entry->loaded()) {
$entry->key = $key;
$entry->locale = $locale;
$entry->message = $root_message->message;
@@ -74,7 +74,7 @@ class L10n_Client_Controller extends Controller {
"locale" => $locale))
->find();
- if (!$entry_from_incoming->loaded) {
+ if (!$entry_from_incoming->loaded()) {
$entry->base_revision = $entry_from_incoming->revision;
}
@@ -122,9 +122,9 @@ class L10n_Client_Controller extends Controller {
$calls[$row->key] = array(unserialize($row->message), array());
}
} else {
- $calls = I18n::instance()->call_log();
+ $calls = Gallery_I18n::instance()->call_log();
}
- $locale = I18n::instance()->locale();
+ $locale = Gallery_I18n::instance()->locale();
if ($calls) {
$translations = array();
diff --git a/modules/gallery/controllers/permissions.php b/modules/gallery/controllers/permissions.php
index 99943fbb..e03f41a9 100644
--- a/modules/gallery/controllers/permissions.php
+++ b/modules/gallery/controllers/permissions.php
@@ -57,7 +57,7 @@ class Permissions_Controller extends Controller {
access::required("view", $item);
access::required("edit", $item);
- if (!empty($group) && $perm->loaded && $item->loaded) {
+ if (!empty($group) && $perm->loaded() && $item->loaded()) {
switch($command) {
case "allow":
access::allow($group, $perm->name, $item);
diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php
index 37753ff3..5d32e35f 100644
--- a/modules/gallery/controllers/simple_uploader.php
+++ b/modules/gallery/controllers/simple_uploader.php
@@ -72,7 +72,7 @@ class Simple_Uploader_Controller extends Controller {
module::event("add_photos_form_completed", $item, $form);
}
} catch (Exception $e) {
- Kohana::log("alert", $e->__toString());
+ Kohana_Log::add("alert", $e->__toString());
if (file_exists($temp_filename)) {
unlink($temp_filename);
}
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php
index 368c947e..e5eefad7 100644
--- a/modules/gallery/helpers/MY_url.php
+++ b/modules/gallery/helpers/MY_url.php
@@ -32,7 +32,7 @@ class url extends url_Core {
}
$item = self::get_item_from_uri(Router::$current_uri);
- if ($item && $item->loaded) {
+ if ($item && $item->loaded()) {
Router::$controller = "{$item->type}s";
Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
Router::$method = $item->id;
@@ -51,7 +51,7 @@ class url extends url_Core {
// but failing that, walk down the tree until we find it. The fallback code will fix caches
// as it goes, so it'll never be run frequently.
$item = ORM::factory("item")->where("relative_url_cache", $current_uri)->find();
- if (!$item->loaded) {
+ if (!$item->loaded()) {
$count = count(Router::$segments);
foreach (ORM::factory("item")
->where("slug", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES))
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index c1c1f9d1..9d27181a 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -91,7 +91,7 @@ class access_Core {
* @return boolean
*/
static function user_can($user, $perm_name, $item) {
- if (!$item->loaded) {
+ if (!$item->loaded()) {
return false;
}
@@ -101,7 +101,7 @@ class access_Core {
$resource = $perm_name == "view" ?
$item : model_cache::get("access_cache", $item->id, "item_id");
- foreach ($user->groups as $group) {
+ foreach ($user->groups->find_all() as $group) {
if ($resource->__get("{$perm_name}_{$group->id}") === self::ALLOW) {
return true;
}
@@ -175,7 +175,7 @@ class access_Core {
->limit(1)
->find();
- if ($lock->loaded) {
+ if ($lock->loaded()) {
return $lock;
} else {
return null;
@@ -201,7 +201,7 @@ class access_Core {
if (!($group instanceof Group_Definition)) {
throw new Exception("@todo PERMISSIONS_ONLY_WORK_ON_GROUPS");
}
- if (!$album->loaded) {
+ if (!$album->loaded()) {
throw new Exception("@todo INVALID_ALBUM $album->id");
}
if (!$album->is_album()) {
@@ -282,7 +282,7 @@ class access_Core {
*/
static function register_permission($name, $display_name) {
$permission = ORM::factory("permission", $name);
- if ($permission->loaded) {
+ if ($permission->loaded()) {
throw new Exception("@todo PERMISSION_ALREADY_EXISTS $name");
}
$permission->name = $name;
@@ -305,7 +305,7 @@ class access_Core {
self::_drop_columns($name, $group);
}
$permission = ORM::factory("permission")->where("name", $name)->find();
- if ($permission->loaded) {
+ if ($permission->loaded()) {
$permission->delete();
}
}
@@ -342,7 +342,7 @@ class access_Core {
*/
static function add_item($item) {
$access_intent = ORM::factory("access_intent", $item->id);
- if ($access_intent->loaded) {
+ if ($access_intent->loaded()) {
throw new Exception("@todo ITEM_ALREADY_ADDED $item->id");
}
$access_intent = ORM::factory("access_intent");
@@ -497,7 +497,7 @@ class access_Core {
->orderby("left_ptr", "DESC")
->limit(1)
->find();
- if ($tmp_item->loaded) {
+ if ($tmp_item->loaded()) {
$item = $tmp_item;
}
}
@@ -568,7 +568,7 @@ class access_Core {
->orderby("left_ptr", "DESC")
->limit(1)
->find();
- if ($tmp_item->loaded) {
+ if ($tmp_item->loaded()) {
$item = $tmp_item;
}
}
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index e9a0f6ec..84a60f83 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -34,7 +34,7 @@ class album_Core {
* @return Item_Model
*/
static function create($parent, $name, $title, $description=null, $owner_id=null, $slug=null) {
- if (!$parent->loaded || !$parent->is_album()) {
+ if (!$parent->loaded() || !$parent->is_album()) {
throw new Exception("@todo INVALID_PARENT");
}
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index 9c69cecd..21a39bfb 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -46,7 +46,7 @@ class auth_Core {
try {
Session::instance()->destroy();
} catch (Exception $e) {
- Kohana::log("error", $e);
+ Kohana_Log::add("error", $e);
}
module::event("user_logout", $user);
}
diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php
index c24d2bde..ce08bbd7 100644
--- a/modules/gallery/helpers/gallery_graphics.php
+++ b/modules/gallery/helpers/gallery_graphics.php
@@ -123,7 +123,7 @@ class gallery_graphics_Core {
module::event("graphics_composite_completed", $input_file, $output_file, $options);
} catch (ErrorException $e) {
- Kohana::log("error", $e->get_message());
+ Kohana_Log::add("error", $e->get_message());
}
}
}
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index e0b03682..4d6de3ba 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -66,7 +66,7 @@ class gallery_task_Core {
}
$item = ORM::factory("item", $row->id);
- if ($item->loaded) {
+ if ($item->loaded()) {
try {
graphics::generate($item);
$completed++;
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index d6a2f00c..a78cadd0 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -171,7 +171,7 @@ class graphics_Core {
} 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" .
+ Kohana_Log::add("error", "Caught exception rebuilding image: {$item->title}\n" .
$e->getMessage() . "\n" . $e->getTraceAsString());
throw $e;
}
diff --git a/modules/gallery/helpers/identity.php b/modules/gallery/helpers/identity.php
index 72e3312d..05614559 100644
--- a/modules/gallery/helpers/identity.php
+++ b/modules/gallery/helpers/identity.php
@@ -75,14 +75,14 @@ class identity_Core {
if (!$session->get("group_ids")) {
$ids = array();
- foreach ($user->groups as $group) {
+ foreach ($user->groups->find_all() as $group) {
$ids[] = $group->id;
}
$session->set("group_ids", $ids);
}
} catch (Exception $e) {
// Log it, so we at least have so notification that we swallowed the exception.
- Kohana::log("error", "Load_user Exception: " . $e->__toString());
+ Kohana_Log::add("error", "Load_user Exception: " . $e->__toString());
try {
Session::instance()->destroy();
} catch (Exception $e) {
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 8f96c3d9..109fa6f8 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -156,13 +156,7 @@ class item_Core {
$view_restrictions = array();
if (!identity::active_user()->admin) {
foreach (identity::group_ids_for_active_user() as $id) {
- // Separate the first restriction from the rest to make it easier for us to formulate
- // our where clause below
- if (empty($view_restrictions)) {
- $view_restrictions[0] = "items.view_$id";
- } else {
- $view_restrictions[1]["items.view_$id"] = access::ALLOW;
- }
+ $view_restrictions[] = "items.view_$id";
}
}
switch (count($view_restrictions)) {
@@ -170,14 +164,14 @@ class item_Core {
break;
case 1:
- $model->where($view_restrictions[0], access::ALLOW);
+ $model->where($view_restrictions[0], "=", access::ALLOW);
break;
default:
- $model->open_paren();
- $model->where($view_restrictions[0], access::ALLOW);
- $model->orwhere($view_restrictions[1]);
- $model->close_paren();
+ $model
+ ->and_open()
+ ->or_where($view_restrictions, "=", access::ALLOW)
+ ->close();
break;
}
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index 3460cc65..aaf6ff46 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -136,7 +136,7 @@ class l10n_client_Core {
$entry = ORM::factory("incoming_translation")
->where(array("key" => $key, "locale" => $locale))
->find();
- if (!$entry->loaded) {
+ if (!$entry->loaded()) {
// @todo Load a message key -> message (text) dict into memory outside of this loop
$root_entry = ORM::factory("incoming_translation")
->where(array("key" => $key, "locale" => "root"))
diff --git a/modules/gallery/helpers/l10n_scanner.php b/modules/gallery/helpers/l10n_scanner.php
index a8059b3a..6c09a686 100644
--- a/modules/gallery/helpers/l10n_scanner.php
+++ b/modules/gallery/helpers/l10n_scanner.php
@@ -37,13 +37,13 @@ class l10n_scanner_Core {
}
}
- $key = I18n::get_message_key($message);
+ $key = Gallery_I18n::get_message_key($message);
if (array_key_exists($key, $cache)) {
return $cache[$key];
}
$entry = ORM::factory("incoming_translation", array("key" => $key));
- if (!$entry->loaded) {
+ if (!$entry->loaded()) {
$entry->key = $key;
$entry->message = serialize($message);
$entry->locale = "root";
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 2de029ff..8d76e333 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -125,13 +125,13 @@ class locales_Core {
if (empty(self::$locales)) {
self::_init_language_data();
}
- $locale or $locale = I18n::instance()->locale();
+ $locale or $locale = Gallery_I18n::instance()->locale();
return self::$locales["$locale"];
}
static function is_rtl($locale=null) {
- $locale or $locale = I18n::instance()->locale();
+ $locale or $locale = Gallery_I18n::instance()->locale();
list ($language, $territory) = explode('_', $locale . "_");
return in_array($language, array("he", "fa", "ar"));
}
@@ -233,7 +233,7 @@ class locales_Core {
}
// If we have any preference, override the site's default locale
if ($locale) {
- I18n::instance()->locale($locale);
+ Gallery_I18n::instance()->locale($locale);
}
}
diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php
index a3e09862..302e42d9 100644
--- a/modules/gallery/helpers/model_cache.php
+++ b/modules/gallery/helpers/model_cache.php
@@ -22,8 +22,8 @@ class model_cache_Core {
static function get($model_name, $id, $field_name="id") {
if (TEST_MODE || empty(self::$cache->$model_name->$field_name->$id)) {
- $model = ORM::factory($model_name)->where($field_name, $id)->find();
- if (!$model->loaded) {
+ $model = ORM::factory($model_name)->where($field_name, "=", $id)->find();
+ if (!$model->loaded()) {
throw new Exception("@todo MISSING_MODEL $model_name:$id");
}
self::$cache->$model_name->$field_name->$id = $model;
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index e6c196ce..e54a4352 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -36,13 +36,13 @@ class module_Core {
*/
static function set_version($module_name, $version) {
$module = self::get($module_name);
- if (!$module->loaded) {
+ if (!$module->loaded()) {
$module->name = $module_name;
$module->active = $module_name == "gallery"; // only gallery is active by default
}
$module->version = $version;
$module->save();
- Kohana::log("debug", "$module_name: version is now $version");
+ Kohana_Log::add("debug", "$module_name: version is now $version");
}
/**
@@ -126,9 +126,10 @@ class module_Core {
* @param string $module_name
*/
static function install($module_name) {
- $kohana_modules = Kohana::config("core.modules");
+ $config = Kohana_Config::instance();
+ $kohana_modules = $config->get("core.modules");
array_unshift($kohana_modules, MODPATH . $module_name);
- Kohana::config_set("core.modules", $kohana_modules);
+ $config->set("core.modules", $kohana_modules);
// Rebuild the include path so the module installer can benefit from auto loading
Kohana::include_paths(true);
@@ -142,7 +143,7 @@ class module_Core {
// Now the module is installed but inactive, so don't leave it in the active path
array_shift($kohana_modules);
- Kohana::config_set("core.modules", $kohana_modules);
+ $config->set("core.modules", $kohana_modules);
log::success(
"module", t("Installed module %module_name", array("module_name" => $module_name)));
@@ -193,9 +194,10 @@ class module_Core {
* @param string $module_name
*/
static function activate($module_name) {
- $kohana_modules = Kohana::config("core.modules");
+ $config = Kohana_Config::instance();
+ $kohana_modules = $config->get("core.modules");
array_unshift($kohana_modules, MODPATH . $module_name);
- Kohana::config_set("core.modules", $kohana_modules);
+ $config->set("core.modules", $kohana_modules);
$installer_class = "{$module_name}_installer";
if (method_exists($installer_class, "activate")) {
@@ -203,7 +205,7 @@ class module_Core {
}
$module = self::get($module_name);
- if ($module->loaded) {
+ if ($module->loaded()) {
$module->active = true;
$module->save();
}
@@ -230,7 +232,7 @@ class module_Core {
}
$module = self::get($module_name);
- if ($module->loaded) {
+ if ($module->loaded()) {
$module->active = false;
$module->save();
}
@@ -257,7 +259,7 @@ class module_Core {
graphics::remove_rules($module_name);
$module = self::get($module_name);
- if ($module->loaded) {
+ if ($module->loaded()) {
$module->delete();
}
module::load_modules();
@@ -290,8 +292,9 @@ class module_Core {
}
}
self::$active[] = $gallery; // put gallery last in the module list to match core.modules
- Kohana::config_set(
- "core.modules", array_merge($kohana_modules, Kohana::config("core.modules")));
+ $config = Kohana_Config::instance();
+ $config->set(
+ "core.modules", array_merge($kohana_modules, $config->get("core.modules")));
}
/**
@@ -348,11 +351,11 @@ class module_Core {
// We cache all vars in gallery._cache so that we can load all vars at once for
// performance.
if (empty(self::$var_cache)) {
- $row = Database::instance()
+ $row = db::build()
->select("value")
->from("vars")
->where(array("module_name" => "gallery", "name" => "_cache"))
- ->get()
+ ->execute()
->current();
if ($row) {
self::$var_cache = unserialize($row->value);
@@ -395,7 +398,7 @@ class module_Core {
->where("module_name", $module_name)
->where("name", $name)
->find();
- if (!$var->loaded) {
+ if (!$var->loaded()) {
$var->module_name = $module_name;
$var->name = $name;
}
@@ -432,7 +435,7 @@ class module_Core {
->where("module_name", $module_name)
->where("name", $name)
->find();
- if ($var->loaded) {
+ if ($var->loaded()) {
$var->delete();
}
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 536d5143..ff86403a 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -36,7 +36,7 @@ class movie_Core {
*/
static function create($parent, $filename, $name, $title,
$description=null, $owner_id=null, $slug=null) {
- if (!$parent->loaded || !$parent->is_album()) {
+ if (!$parent->loaded() || !$parent->is_album()) {
throw new Exception("@todo INVALID_PARENT");
}
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index 4188e192..21cb13a0 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -36,7 +36,7 @@ class photo_Core {
*/
static function create($parent, $filename, $name, $title,
$description=null, $owner_id=null, $slug=null) {
- if (!$parent->loaded || !$parent->is_album()) {
+ if (!$parent->loaded() || !$parent->is_album()) {
throw new Exception("@todo INVALID_PARENT");
}
diff --git a/modules/gallery/helpers/site_status.php b/modules/gallery/helpers/site_status.php
index 2b090776..d58b935d 100644
--- a/modules/gallery/helpers/site_status.php
+++ b/modules/gallery/helpers/site_status.php
@@ -69,7 +69,7 @@ class site_status_Core {
$message = ORM::factory("message")
->where("key", $permanent_key)
->find();
- if (!$message->loaded) {
+ if (!$message->loaded()) {
$message->key = $permanent_key;
}
$message->severity = $severity;
@@ -83,7 +83,7 @@ class site_status_Core {
*/
static function clear($permanent_key) {
$message = ORM::factory("message")->where("key", $permanent_key)->find();
- if ($message->loaded) {
+ if ($message->loaded()) {
$message->delete();
}
}
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index dac5f9d3..4aa95f33 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -51,7 +51,7 @@ class task_Core {
static function cancel($task_id) {
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
$task->done = 1;
@@ -65,14 +65,14 @@ class task_Core {
static function remove($task_id) {
$task = ORM::factory("task", $task_id);
- if ($task->loaded) {
+ if ($task->loaded()) {
$task->delete();
}
}
static function run($task_id) {
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
@@ -84,7 +84,7 @@ class task_Core {
}
$task->save();
} catch (Exception $e) {
- Kohana::log("error", $e->__toString());
+ Kohana_Log::add("error", $e->__toString());
$task->log($e->__toString());
$task->state = "error";
$task->done = true;
diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php
index 16ed104e..c7a9b49a 100644
--- a/modules/gallery/helpers/theme.php
+++ b/modules/gallery/helpers/theme.php
@@ -43,7 +43,7 @@ class theme_Core {
}
$modules = Kohana::config("core.modules");
array_unshift($modules, THEMEPATH . $theme_name);
- Kohana::config_set("core.modules", $modules);
+ Kohana_Config::instance()->set("core.modules", $modules);
}
static function get_edit_form_admin() {
diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php
index b2d9c4de..4ce9bab4 100644
--- a/modules/gallery/hooks/init_gallery.php
+++ b/modules/gallery/hooks/init_gallery.php
@@ -24,7 +24,7 @@ if (!file_exists(VARPATH . "database.php")) {
url::redirect(url::abs_file("installer"));
}
-Event::add("system.ready", array("I18n", "instance"));
+Event::add("system.ready", array("Gallery_I18n", "instance"));
Event::add("system.ready", array("module", "load_modules"));
Event::add("system.ready", array("gallery", "ready"));
Event::add("system.post_routing", array("url", "parse_url"));
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index cbb781a1..c190f110 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -31,7 +31,7 @@ class Admin_View_Core extends Gallery_View {
if (!file_exists(THEMEPATH . $theme_name)) {
module::set_var("gallery", "active_admin_theme", "admin_wind");
theme::load_themes();
- Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme.");
+ Kohana_Log::add("error", "Unable to locate theme '$theme_name', switching to default theme.");
}
parent::__construct($name);
diff --git a/modules/gallery/libraries/I18n.php b/modules/gallery/libraries/Gallery_I18n.php
index c3336052..42fae266 100644
--- a/modules/gallery/libraries/I18n.php
+++ b/modules/gallery/libraries/Gallery_I18n.php
@@ -27,7 +27,7 @@
* @return String The translated message string.
*/
function t($message, $options=array()) {
- return I18n::instance()->translate($message, $options);
+ return Gallery_I18n::instance()->translate($message, $options);
}
/**
@@ -43,11 +43,11 @@ function t($message, $options=array()) {
* @return String The translated message string.
*/
function t2($singular, $plural, $count, $options=array()) {
- return I18n::instance()->translate(array("one" => $singular, "other" => $plural),
+ return Gallery_I18n::instance()->translate(array("one" => $singular, "other" => $plural),
array_merge($options, array("count" => $count)));
}
-class I18n_Core {
+class Gallery_I18n_Core {
private static $_instance;
private $_config = array();
private $_call_log = array();
@@ -64,7 +64,7 @@ class I18n_Core {
if (empty($config['default_locale'])) {
$config['default_locale'] = module::get_var('gallery', 'default_locale');
}
- self::$_instance = new I18n_Core($config);
+ self::$_instance = new Gallery_I18n_Core($config);
}
return self::$_instance;
@@ -128,21 +128,21 @@ class I18n_Core {
if (!isset($this->_cache[$locale])) {
$this->_cache[$locale] = array();
// TODO: Load data from locale file instead of the DB.
- foreach (Database::instance()
+ foreach (db::build()
->select("key", "translation")
->from("incoming_translations")
->where(array("locale" => $locale))
- ->get()
+ ->execute()
->as_array() as $row) {
$this->_cache[$locale][$row->key] = unserialize($row->translation);
}
// Override incoming with outgoing...
- foreach (Database::instance()
+ foreach (db::build()
->select("key", "translation")
->from("outgoing_translations")
->where(array("locale" => $locale))
- ->get()
+ ->execute()
->as_array() as $row) {
$this->_cache[$locale][$row->key] = unserialize($row->translation);
}
diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php
index 3bf56d0f..940c5321 100644
--- a/modules/gallery/libraries/Gallery_View.php
+++ b/modules/gallery/libraries/Gallery_View.php
@@ -32,7 +32,7 @@ class Gallery_View_Core extends View {
if (($path = gallery::find_file("js", $file, false))) {
$this->scripts[$path] = 1;
} else {
- Kohana::log("error", "Can't find script file: $file");
+ Kohana_Log::add("error", "Can't find script file: $file");
}
}
@@ -55,7 +55,7 @@ class Gallery_View_Core extends View {
if (($path = gallery::find_file("css", $file, false))) {
$this->css[$path] = 1;
} else {
- Kohana::log("error", "Can't find css file: $file");
+ Kohana_Log::add("error", "Can't find css file: $file");
}
}
@@ -130,7 +130,7 @@ class Gallery_View_Core extends View {
$search[] = $match[0];
$replace[] = "url('" . url::abs_file($relative) . "')";
} else {
- Kohana::log("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'");
+ Kohana_Log::add("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'");
}
}
$replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace);
diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php
index e213ae97..bcb3056a 100644
--- a/modules/gallery/libraries/IdentityProvider.php
+++ b/modules/gallery/libraries/IdentityProvider.php
@@ -54,7 +54,7 @@ class IdentityProvider_Core {
*/
static function reset() {
self::$instance = null;
- Kohana::config_clear("identity");
+ Kohana_Config::instance()->clear("identity");
}
/**
@@ -90,7 +90,7 @@ class IdentityProvider_Core {
get_class($this), "IdentityProvider_Driver");
}
- Kohana::log("debug", "Identity Library initialized");
+ Kohana_Log::add("debug", "Identity Library initialized");
}
/**
diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php
index c56f16e8..0f29c09b 100644
--- a/modules/gallery/libraries/MY_Database.php
+++ b/modules/gallery/libraries/MY_Database.php
@@ -17,45 +17,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Database extends Database_Core {
+abstract class Database extends Database_Core {
protected $_table_names;
- public function open_paren() {
- $this->where[] = "(";
- return $this;
- }
-
- public function close_paren() {
- // Search backwards for the last opening paren and resolve it
- $i = count($this->where) - 1;
- $this->where[$i] .= ")";
- while (--$i >= 0) {
- if ($this->where[$i] == "(") {
- // Remove the paren from the where clauses, and add it to the right of the operator of the
- // next where clause. If removing the paren makes the next where clause the first element
- // in the where list, then the operator shouldn't be there. It's there because we
- // calculate whether or not we need an operator based on the number of where clauses, and
- // the open paren seems like a where clause even though it isn't.
- array_splice($this->where, $i, 1);
- $this->where[$i] = preg_replace("/^(AND|OR) /", $i ? "\\1 (" : "(", $this->where[$i]);
- return $this;
- }
- }
-
- throw new Kohana_Database_Exception('database.missing_open_paren');
- }
-
- /**
- * Parse the query string and convert any strings of the form `\([a-zA-Z0-9_]*?)\]
- * table prefix . $1
- */
- public function query($sql = '') {
- if (!empty($sql)) {
- $sql = $this->add_table_prefixes($sql);
- }
- return parent::query($sql);
- }
-
public function add_table_prefixes($sql) {
$prefix = $this->config["table_prefix"];
if (strpos($sql, "SHOW TABLES") === 0) {
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php
index 2c9ad1d7..56c776aa 100644
--- a/modules/gallery/libraries/MY_ORM.php
+++ b/modules/gallery/libraries/MY_ORM.php
@@ -21,16 +21,6 @@ class ORM extends ORM_Core {
// Track the original value of this ORM so that we can look it up in ORM::original()
protected $original = null;
- public function open_paren() {
- $this->db->open_paren();
- return $this;
- }
-
- public function close_paren() {
- $this->db->close_paren();
- return $this;
- }
-
public function save() {
model_cache::clear();
$result = parent::save();
diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php
index eb55aca6..0311f2dd 100644
--- a/modules/gallery/libraries/MY_View.php
+++ b/modules/gallery/libraries/MY_View.php
@@ -18,6 +18,31 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class View extends View_Core {
+ static $global_data;
+
+ /**
+ * Reimplement Kohana 2.3's View::set_global() functionality.
+ */
+ public function set_global($key, $value) {
+ View::$global_data->$key = $value;
+ $this->$key = $value;
+ }
+
+ public function __isset($key) {
+ if (isset(View::$global_data->$key)) {
+ return true;
+ }
+ return parent::__isset($key);
+ }
+
+ public function &__get($key) {
+ Kohana_Log::add("error",print_r("__get($key)",1));
+ if (isset(View::$global_data->$key)) {
+ return View::$global_data->$key;
+ }
+ return parent::__get($key);
+ }
+
/**
* Override View_Core::__construct so that we can set the csrf value into all views.
*
@@ -38,7 +63,7 @@ class View extends View_Core {
try {
return parent::render($print, $renderer);
} catch (Exception $e) {
- Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
+ Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
return "";
}
}
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index 83d2445c..01b2d7b7 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -133,10 +133,10 @@ class ORM_MPTT_Core extends ORM {
*/
function parents() {
return $this
- ->where("`left_ptr` <= {$this->left_ptr}")
- ->where("`right_ptr` >= {$this->right_ptr}")
- ->where("id <> {$this->id}")
- ->orderby("left_ptr", "ASC")
+ ->where("left_ptr", "<=", $this->left_ptr)
+ ->where("right_ptr", ">=", $this->right_ptr)
+ ->where("id", "<>", $this->id)
+ ->order_by("left_ptr", "ASC")
->find_all();
}
@@ -147,14 +147,17 @@ class ORM_MPTT_Core extends ORM {
* @param integer SQL limit
* @param integer SQL offset
* @param array additional where clauses
- * @param array orderby
+ * @param array order_by
* @return array ORM
*/
- function children($limit=null, $offset=0, $where=array(), $orderby=array("id" => "ASC")) {
+ function children($limit=null, $offset=0, $where=null, $order_by=array("id" => "ASC")) {
+ if ($where) {
+ $this->where($where);
+ }
+
return $this
- ->where("parent_id", $this->id)
- ->where($where)
- ->orderby($orderby)
+ ->where("parent_id", "=", $this->id)
+ ->order_by($order_by)
->find_all($limit, $offset);
}
@@ -165,10 +168,13 @@ class ORM_MPTT_Core extends ORM {
* @param array additional where clauses
* @return array ORM
*/
- function children_count($where=array()) {
+ function children_count($where=null) {
+ if ($where) {
+ $this->where($where);
+ }
+
return $this
- ->where($where)
- ->where("parent_id", $this->id)
+ ->where("parent_id", "=", $this->id)
->count_all();
}
@@ -178,15 +184,18 @@ class ORM_MPTT_Core extends ORM {
* @param integer SQL limit
* @param integer SQL offset
* @param array additional where clauses
- * @param array orderby
+ * @param array order_by
* @return object ORM_Iterator
*/
- function descendants($limit=null, $offset=0, $where=array(), $orderby=array("id" => "ASC")) {
+ function descendants($limit=null, $offset=0, $where=null, $order_by=array("id" => "ASC")) {
+ if ($where) {
+ $this->where($where);
+ }
+
return $this
- ->where("left_ptr >", $this->left_ptr)
- ->where("right_ptr <=", $this->right_ptr)
- ->where($where)
- ->orderby($orderby)
+ ->where("left_ptr", ">", $this->left_ptr)
+ ->where("right_ptr", "<=", $this->right_ptr)
+ ->order_by($order_by)
->find_all($limit, $offset);
}
@@ -196,11 +205,14 @@ class ORM_MPTT_Core extends ORM {
* @param array additional where clauses
* @return integer child count
*/
- function descendants_count($where=array()) {
+ function descendants_count($where=null) {
+ if ($where) {
+ $this->where($where);
+ }
+
return $this
- ->where("left_ptr >", $this->left_ptr)
- ->where("right_ptr <=", $this->right_ptr)
- ->where($where)
+ ->where("left_ptr", ">", $this->left_ptr)
+ ->where("right_ptr", "<=", $this->right_ptr)
->count_all();
}
diff --git a/modules/gallery/libraries/SafeString.php b/modules/gallery/libraries/SafeString.php
index ba3a8ffd..cc63f3a7 100644
--- a/modules/gallery/libraries/SafeString.php
+++ b/modules/gallery/libraries/SafeString.php
@@ -146,7 +146,7 @@ class SafeString_Core {
* Escape special HTML chars ("<", ">", "&", etc.) to HTML entities.
*/
private static function _escape_for_html($dirty_html) {
- return html::specialchars($dirty_html);
+ return html::chars($dirty_html);
}
/**
diff --git a/modules/gallery/libraries/Sendmail.php b/modules/gallery/libraries/Sendmail.php
index 7bc21a67..aa2b51a9 100644
--- a/modules/gallery/libraries/Sendmail.php
+++ b/modules/gallery/libraries/Sendmail.php
@@ -52,7 +52,7 @@ class Sendmail_Core {
break;
case "header":
if (count($value) != 2) {
- Kohana::log("error", wordwrap("Invalid header parameters\n" . Kohana::debug($value)));
+ Kohana_Log::add("error", wordwrap("Invalid header parameters\n" . Kohana::debug($value)));
throw new Exception("@todo INVALID_HEADER_PARAMETERS");
}
$this->headers[$value[0]] = $value[1];
@@ -71,7 +71,7 @@ class Sendmail_Core {
public function send() {
if (empty($this->to)) {
- Kohana::log("error", wordwrap("Sending mail failed:\nNo to address specified"));
+ Kohana_Log::add("error", wordwrap("Sending mail failed:\nNo to address specified"));
throw new Exception("@todo TO_IS_REQUIRED_FOR_MAIL");
}
$to = implode(", ", $this->to);
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index b64deab9..03f67671 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -33,7 +33,7 @@ class Theme_View_Core extends Gallery_View {
if (!file_exists(THEMEPATH . $theme_name)) {
module::set_var("gallery", "active_site_theme", "wind");
theme::load_themes();
- Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme.");
+ Kohana_Log::add("error", "Unable to locate theme '$theme_name', switching to default theme.");
}
parent::__construct($name);
diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php
index 7e2aeabc..d27bcc32 100644
--- a/modules/gallery/libraries/drivers/Cache/Database.php
+++ b/modules/gallery/libraries/drivers/Cache/Database.php
@@ -20,43 +20,33 @@
/*
* Based on the Cache_Sqlite_Driver developed by the Kohana Team
*/
-class Cache_Database_Driver implements Cache_Driver {
+class Cache_Database_Driver extends Cache_Driver {
// Kohana database instance
protected $db;
/**
- * Tests that the storage location is a directory and is writable.
- */
- public function __construct() {
- // Open up an instance of the database
- $this->db = Database::instance();
-
- if (!$this->db->table_exists("caches")) {
- throw new Exception("@todo Cache table is not defined");
- }
- }
-
- /**
* Checks if a cache id is already set.
*
* @param string cache id
* @return boolean
*/
public function exists($id) {
- $count = $this->db->count_records("caches", array("key" => $id, "expiration >=" => time()));
+ $count = db::build()
+ ->where("key", "=", $id)
+ ->where("expiration", ">=", "time()")
+ ->count_records("caches");
return $count > 0;
}
/**
* Sets a cache item to the given data, tags, and lifetime.
*
- * @param string cache id to set
- * @param string data in the cache
+ * @param array assoc array of key => value pairs
* @param array cache tags
* @param integer lifetime
* @return bool
*/
- public function set($id, $data, array $tags = NULL, $lifetime) {
+ public function set($items, $tags=null, $lifetime=null) {
if (!empty($tags)) {
// Escape the tags, adding brackets so the tag can be explicitly matched
$tags = "<" . implode(">,<", $tags) . ">";
@@ -69,46 +59,46 @@ class Cache_Database_Driver implements Cache_Driver {
$lifetime += time();
}
- if ($this->exists($id)) {
- $status = $this->db->update(
- "caches",
- array("tags" => $tags, "expiration" => $lifetime, "cache" => serialize($data)), array("key" => $id));
- } else {
- $status = $this->db->insert(
- "caches",
- array("key" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => serialize($data)));
+ foreach ($items as $id => $data) {
+ if ($this->exists($id)) {
+ $status = db::build()->update(
+ "caches",
+ array("tags" => $tags, "expiration" => $lifetime, "cache" => serialize($data)),
+ array("key", "=", $id));
+ } else {
+ $status = db::build()->insert(
+ "caches",
+ array("key" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => serialize($data)));
+ }
}
- return count($status) > 0;
+ return true;
}
/**
- * Finds an array of ids for a given tag.
- *
- * @param string tag name
- * @return array of ids that match the tag
+ * Get cache items by tag
+ * @param array cache tags
+ * @return array cached data
*/
- public function find($tag) {
- $db_result = $this->db->from("caches")
- ->like("tags", "<$tag>")
- ->get()
- ->result(true);
+ public function get_tag($tags) {
+ $db = db::build()->from("caches");
+ foreach ($tags as $tag) {
+ $db->where("tags", "like", "<$tag>");
+ }
+ $db_result = $db->execute()->as_array();
// An array will always be returned
$result = array();
+ // Disable notices for unserializing
+ $ER = error_reporting(~E_NOTICE);
if ($db_result->count() > 0) {
- // Disable notices for unserializing
- $ER = error_reporting(~E_NOTICE);
-
foreach ($db_result as $row) {
// Add each cache to the array
$result[$row->key] = unserialize($row->cache);
}
-
- // Turn notices back on
- error_reporting($ER);
}
+ error_reporting($ER);
return $result;
}
@@ -120,9 +110,13 @@ class Cache_Database_Driver implements Cache_Driver {
* @param string cache id
* @return mixed|NULL
*/
- public function get($id) {
+ public function get($keys, $single=false) {
$data = null;
- $result = $this->db->getwhere("caches", array("key" => $id));
+ $result = db::build()
+ ->from("caches")
+ ->where("key", "IN", $keys)
+ ->select()
+ ->execute();
if (count($result) > 0) {
$cache = $result->current();
@@ -169,6 +163,13 @@ class Cache_Database_Driver implements Cache_Driver {
}
/**
+ * Delete cache items by tag
+ */
+ public function delete_tag($tags) {
+ return $this->delete($tags, true);
+ }
+
+ /**
* Deletes all cache files that are older than the current time.
*/
public function delete_expired() {
@@ -180,4 +181,10 @@ class Cache_Database_Driver implements Cache_Driver {
return count($status) > 0;
}
-} // End Cache Database Driver \ No newline at end of file
+ /**
+ * Empty the cache
+ */
+ public function delete_all() {
+ db::build()->query("TRUNCATE {caches}");
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index d27e331b..bd1f9af5 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -309,7 +309,7 @@ class Item_Model extends ORM_MPTT {
* @return string
*/
public function relative_path() {
- if (!$this->loaded) {
+ if (!$this->loaded()) {
return;
}
@@ -324,7 +324,7 @@ class Item_Model extends ORM_MPTT {
* @return string
*/
public function relative_url() {
- if (!$this->loaded) {
+ if (!$this->loaded()) {
return;
}
@@ -383,7 +383,7 @@ class Item_Model extends ORM_MPTT {
if (!empty($this->changed) && $significant_changes) {
$this->updated = time();
- if (!$this->loaded) {
+ if (!$this->loaded()) {
$this->created = $this->updated;
$this->weight = item::get_max_weight();
} else {
diff --git a/modules/gallery/models/log.php b/modules/gallery/models/log.php
index c816a4a7..a2044325 100644
--- a/modules/gallery/models/log.php
+++ b/modules/gallery/models/log.php
@@ -28,7 +28,7 @@ class Log_Model extends ORM {
try {
return identity::lookup_user($this->user_id);
} catch (Exception $e) {
- Kohana::log("alert", "Unable to load user with id $this->user_id");
+ Kohana_Log::add("alert", "Unable to load user with id $this->user_id");
return null;
}
} else {
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index e9e5cb26..d90d7ed6 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -106,15 +106,15 @@ class Access_Helper_Test extends Unit_Test_Case {
$item = album::create($root, rand(), "test album");
// New rows exist
- $this->assert_true(ORM::factory("access_cache")->where("item_id", $item->id)->find()->loaded);
- $this->assert_true(ORM::factory("access_intent")->where("item_id", $item->id)->find()->loaded);
+ $this->assert_true(ORM::factory("access_cache")->where("item_id", $item->id)->find()->loaded());
+ $this->assert_true(ORM::factory("access_intent")->where("item_id", $item->id)->find()->loaded());
// Delete the item
$item->delete();
// Rows are gone
- $this->assert_false(ORM::factory("access_cache")->where("item_id", $item->id)->find()->loaded);
- $this->assert_false(ORM::factory("access_intent")->where("item_id", $item->id)->find()->loaded);
+ $this->assert_false(ORM::factory("access_cache")->where("item_id", $item->id)->find()->loaded());
+ $this->assert_false(ORM::factory("access_intent")->where("item_id", $item->id)->find()->loaded());
}
public function new_photos_inherit_parent_permissions_test() {
diff --git a/modules/gallery/tests/I18n_Test.php b/modules/gallery/tests/I18n_Test.php
index 9010606a..d0555cbf 100644
--- a/modules/gallery/tests/I18n_Test.php
+++ b/modules/gallery/tests/I18n_Test.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class I18n_Test extends Unit_Test_Case {
+class Gallery_I18n_Test extends Unit_Test_Case {
private $i18n;
public function setup() {
@@ -26,7 +26,7 @@ class I18n_Test extends Unit_Test_Case {
'root_locale' => 'en',
'default_locale' => 'te_ST',
'locale_dir' => VARPATH . 'locale/');
- $this->i18n = I18n::instance($config);
+ $this->i18n = Gallery_I18n::instance($config);
ORM::factory("incoming_translation")
->where("locale", "te_ST")
@@ -43,7 +43,7 @@ class I18n_Test extends Unit_Test_Case {
foreach ($messages_te_ST as $data) {
list ($message, $translation) = $data;
$entry = ORM::factory("incoming_translation");
- $entry->key = I18n::get_message_key($message);
+ $entry->key = Gallery_I18n::get_message_key($message);
$entry->message = serialize($message);
$entry->translation = serialize($translation);
$entry->locale = 'te_ST';
diff --git a/modules/gallery/views/kohana_error_page.php b/modules/gallery/views/kohana_error_page.php
index 0d8801e5..b9fdcc19 100644
--- a/modules/gallery/views/kohana_error_page.php
+++ b/modules/gallery/views/kohana_error_page.php
@@ -120,7 +120,7 @@
<? else: ?>
<? $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTraceAsString(); ?>
<? if (!empty($trace)): ?>
- <? Kohana::Log("error", print_r($trace, 1)); ?>
+ <? Kohana_Log::add("error", print_r($trace, 1)); ?>
<? endif ?>
<? endif ?>
</body>