From e8f1ff580c6290060d1de8f3e9eceae9028fd1fa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 3 Jan 2009 05:36:16 +0000 Subject: Add a new quick-edit mode for editing photos when viewing albums. Implement image rotation this way. --- core/controllers/quick.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 core/controllers/quick.php (limited to 'core/controllers/quick.php') diff --git a/core/controllers/quick.php b/core/controllers/quick.php new file mode 100644 index 00000000..6a9ed0f8 --- /dev/null +++ b/core/controllers/quick.php @@ -0,0 +1,68 @@ +loaded) { + return ""; + } + + if ($item->type == "photo") { + $view = new View("quick_edit.html"); + $view->item = $item; + print $view; + } + } + + public function rotate($id, $dir) { + access::verify_csrf(); + $item = ORM::factory("item", $id); + if (!$item->loaded) { + return ""; + } + + $degrees = 0; + switch($dir) { + case "ccw": + $degrees = -90; + break; + + case "cw": + $degrees = 90; + break; + } + + if ($degrees) { + 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; + $item->save(); + + graphics::generate($item); + } + + print json_encode( + array("src" => $item->thumb_url() . "?rnd=" . rand(), + "width" => $item->thumb_width, + "height" => $item->thumb_height)); + } +} -- cgit v1.2.3