diff options
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r-- | modules/gallery/controllers/admin_advanced_settings.php | 3 | ||||
-rw-r--r-- | modules/gallery/controllers/admin_maintenance.php | 36 | ||||
-rw-r--r-- | modules/gallery/controllers/albums.php | 15 | ||||
-rw-r--r-- | modules/gallery/controllers/combined.php | 6 | ||||
-rw-r--r-- | modules/gallery/controllers/file_proxy.php | 10 | ||||
-rw-r--r-- | modules/gallery/controllers/items.php | 4 | ||||
-rw-r--r-- | modules/gallery/controllers/l10n_client.php | 20 | ||||
-rw-r--r-- | modules/gallery/controllers/move.php | 4 | ||||
-rw-r--r-- | modules/gallery/controllers/movies.php | 12 | ||||
-rw-r--r-- | modules/gallery/controllers/permissions.php | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/photos.php | 14 | ||||
-rw-r--r-- | modules/gallery/controllers/simple_uploader.php | 2 |
12 files changed, 66 insertions, 62 deletions
diff --git a/modules/gallery/controllers/admin_advanced_settings.php b/modules/gallery/controllers/admin_advanced_settings.php index 79bc1183..391d2598 100644 --- a/modules/gallery/controllers/admin_advanced_settings.php +++ b/modules/gallery/controllers/admin_advanced_settings.php @@ -22,7 +22,8 @@ class Admin_Advanced_Settings_Controller extends Admin_Controller { $view = new Admin_View("admin.html"); $view->content = new View("admin_advanced_settings.html"); $view->content->vars = ORM::factory("var") - ->orderby("module_name", "name") + ->order_by("module_name") + ->order_by("name") ->find_all(); print $view; } diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index 66bcce55..213e4fe2 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -22,11 +22,13 @@ class Admin_Maintenance_Controller extends Admin_Controller { * Show a list of all available, running and finished tasks. */ public function index() { - $query = Database::instance()->query( - "UPDATE {tasks} SET `state` = 'stalled' " . - "WHERE done = 0 " . - "AND state <> 'stalled' " . - "AND unix_timestamp(now()) - updated > 15"); + $query = db::build() + ->update("tasks") + ->set("state", "stalled") + ->where("done", "=", 0) + ->where("state", "<>", "stalled") + ->where(new Database_Expression("UNIX_TIMESTAMP(NOW()) - `updated` > 15")) + ->execute(); $stalled_count = $query->count(); if ($stalled_count) { log::warning("tasks", @@ -41,9 +43,9 @@ class Admin_Maintenance_Controller extends Admin_Controller { $view->content = new View("admin_maintenance.html"); $view->content->task_definitions = task::get_definitions(); $view->content->running_tasks = ORM::factory("task") - ->where("done", 0)->orderby("updated", "DESC")->find_all(); + ->where("done", "=", 0)->order_by("updated", "DESC")->find_all(); $view->content->finished_tasks = ORM::factory("task") - ->where("done", 1)->orderby("updated", "DESC")->find_all(); + ->where("done", "=", 1)->order_by("updated", "DESC")->find_all(); print $view; } @@ -75,7 +77,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 +99,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 +116,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"); } @@ -138,10 +140,12 @@ class Admin_Maintenance_Controller extends Admin_Controller { public function cancel_running_tasks() { access::verify_csrf(); - Database::instance()->update( - "tasks", - array("done" => 1, "state" => "cancelled"), - array("done" => 0)); + db::build() + ->update("tasks") + ->set("done", 1) + ->set("state", "cancelled") + ->where("done", "=", 0) + ->execute(); message::success(t("All running tasks cancelled")); url::redirect("admin/maintenance"); } @@ -164,7 +168,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { // Do it the long way so we can call delete and remove the cache. $finished = ORM::factory("task") - ->where(array("done" => 1)) + ->where("done", "=", 1) ->find_all(); foreach ($finished as $task) { task::remove($task->id); @@ -184,7 +188,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 3c1a0adf..76032655 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -71,6 +71,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); @@ -81,7 +82,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; @@ -134,12 +135,12 @@ class Albums_Controller extends Items_Controller { if ($row = Database::instance() ->select(array("name", "slug")) ->from("items") - ->where("parent_id", $album->parent_id) - ->where("id <>", $album->id) - ->open_paren() - ->where("name", $form->edit_item->dirname->value) - ->orwhere("slug", $form->edit_item->slug->value) - ->close_paren() + ->where("parent_id", "=", $album->parent_id) + ->where("id", "<>", $album->id) + ->and_open() + ->where("name", "=", $form->edit_item->dirname->value) + ->or_where("slug", "=", $form->edit_item->slug->value) + ->close() ->get() ->current()) { if ($row->name == $form->edit_item->dirname->value) { diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index c1f42bfe..e90a2f1a 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -22,7 +22,6 @@ class Combined_Controller extends Controller { * Return the combined Javascript bundle associated with the given key. */ public function javascript($key) { - $key = substr($key, 0, strlen($key) - 3); // strip off the trailing .js return $this->_emit("javascript", $key); } @@ -30,7 +29,6 @@ class Combined_Controller extends Controller { * Return the combined CSS bundle associated with the given key. */ public function css($key) { - $key = substr($key, 0, strlen($key) - 4); // strip off the trailing .css return $this->_emit("css", $key); } @@ -56,7 +54,7 @@ class Combined_Controller extends Controller { } if (empty($key)) { - Kohana::show_404(); + throw new Kohana_404_Exception(); } $cache = Cache::instance(); @@ -71,7 +69,7 @@ class Combined_Controller extends Controller { $content = $cache->get($key); } if (empty($content)) { - Kohana::show_404(); + throw new Kohana_404_Exception(); } // $type is either 'javascript' or 'css' diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 8fde1132..8c46de08 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -57,8 +57,8 @@ class File_Proxy_Controller extends Controller { $path = preg_replace("|/.album.jpg$|", "", $path); // 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) { + $item = ORM::factory("item")->where("relative_path_cache", "=", $path)->find(); + 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. @@ -69,15 +69,15 @@ class File_Proxy_Controller extends Controller { if (preg_match('/.jpg$/', $path)) { 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) { + $item = ORM::factory("item")->where("relative_path_cache", "=", $movie_path)->find(); + if ($item->loaded()) { break; } } } } - if (!$item->loaded) { + if (!$item->loaded()) { kohana::show_404(); } diff --git a/modules/gallery/controllers/items.php b/modules/gallery/controllers/items.php index b350c5a2..f261e3a9 100644 --- a/modules/gallery/controllers/items.php +++ b/modules/gallery/controllers/items.php @@ -20,8 +20,8 @@ class Items_Controller extends Controller { public function __call($function, $args) { $item = ORM::factory("item", (int)$function); - if (!$item->loaded) { - return Kohana::show_404(); + if (!$item->loaded()) { + throw new Kohana_404_Exception(); } // Redirect to the more specific resource type, since it will render diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index 6db67d3b..30a18631 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; } @@ -116,22 +116,22 @@ class L10n_Client_Controller extends Controller { foreach (Database::instance() ->select("key", "message") ->from("incoming_translations") - ->where(array("locale" => 'root')) + ->where("locale", "=", "root")) ->get() ->as_array() as $row) { $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(); foreach (Database::instance() ->select("key", "translation") ->from("incoming_translations") - ->where(array("locale" => $locale)) + ->where("locale", "=", $locale) ->get() ->as_array() as $row) { $translations[$row->key] = unserialize($row->translation); @@ -140,7 +140,7 @@ class L10n_Client_Controller extends Controller { foreach (Database::instance() ->select("key", "translation") ->from("outgoing_translations") - ->where(array("locale" => $locale)) + ->where("locale", "=", $locale) ->get() ->as_array() as $row) { $translations[$row->key] = unserialize($row->translation); diff --git a/modules/gallery/controllers/move.php b/modules/gallery/controllers/move.php index 87b73436..863b13bb 100644 --- a/modules/gallery/controllers/move.php +++ b/modules/gallery/controllers/move.php @@ -64,8 +64,8 @@ class Move_Controller extends Controller { $view->parent = $target; $view->children = ORM::factory("item") ->viewable() - ->where("type", "album") - ->where("parent_id", $target->id) + ->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 575b2b60..6e25e6ea 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -26,7 +26,7 @@ class Movies_Controller extends Items_Controller { } access::required("view", $movie); - $where = array("type != " => "album"); + $where = array(array("type", "!=", "album")); $position = $movie->parent()->get_position($movie, $where); if ($position > 1) { list ($previous_item, $ignore, $next_item) = @@ -79,12 +79,12 @@ class Movies_Controller extends Items_Controller { if ($row = Database::instance() ->select(array("name", "slug")) ->from("items") - ->where("parent_id", $movie->parent_id) + ->where("parent_id", "=", $movie->parent_id) ->where("id <>", $movie->id) - ->open_paren() - ->where("name", $form->edit_item->filename->value) - ->orwhere("slug", $form->edit_item->slug->value) - ->close_paren() + ->and_open() + ->where("name", "=", $form->edit_item->filename->value) + ->or_where("slug", "=", $form->edit_item->slug->value) + ->close() ->get() ->current()) { if ($row->name == $form->edit_item->filename->value) { 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/photos.php b/modules/gallery/controllers/photos.php index ba4cfb83..f7c5039e 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -26,7 +26,7 @@ class Photos_Controller extends Items_Controller { } access::required("view", $photo); - $where = array("type != " => "album"); + $where = array(array("type", "!=", "album")); $position = $photo->parent()->get_position($photo, $where); if ($position > 1) { list ($previous_item, $ignore, $next_item) = @@ -79,12 +79,12 @@ class Photos_Controller extends Items_Controller { if ($row = Database::instance() ->select(array("name", "slug")) ->from("items") - ->where("parent_id", $photo->parent_id) - ->where("id <>", $photo->id) - ->open_paren() - ->where("name", $form->edit_item->filename->value) - ->orwhere("slug", $form->edit_item->slug->value) - ->close_paren() + ->where("parent_id", "=", $photo->parent_id) + ->where("id", "<>", $photo->id) + ->and_open() + ->where("name", "=", $form->edit_item->filename->value) + ->or_where("slug", "=", $form->edit_item->slug->value) + ->close() ->get() ->current()) { if ($row->name == $form->edit_item->filename->value) { 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); } |