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)); + } +} diff --git a/core/css/quickedit.css b/core/css/quickedit.css new file mode 100644 index 00000000..1ab00de5 --- /dev/null +++ b/core/css/quickedit.css @@ -0,0 +1,45 @@ +div.gQuickEdit { + margin: 0px !important; + padding: 0px !important; + border: none !important; +} + +#gQuickEditPane { + background: white; + opacity: 0.8; + border-bottom: 1px dashed black; +} + +#gQuickEditPane div { + background: red; + float: right; + display: inline; + cursor: pointer; + margin: 8px; +} + +#gQuickEditPane div.rotate-clockwise { + background: url(../images/arrow_rotate_clockwise.png); + width: 16px; + height: 16px; + position: absolute; + top: 0px; + right: 0px; +} + +#gQuickEditPane div.rotate-clockwise span { + display: none; +} + +#gQuickEditPane div.rotate-counter-clockwise { + background: url(../images/arrow_rotate_anticlockwise.png); + width: 16px; + height: 16px; + position: absolute; + top: 0px; + left: 0px; +} + +#gQuickEditPane div.rotate-counter-clockwise span { + display: none; +} diff --git a/core/helpers/core_block.php b/core/helpers/core_block.php index c82ca53d..d161d9b4 100644 --- a/core/helpers/core_block.php +++ b/core/helpers/core_block.php @@ -20,10 +20,30 @@ class core_block_Core { public static function head($theme) { + $buf = ""; if (Session::instance()->get("debug")) { - return ""; } + if ($theme->page_type == "album" && access::can("edit", $theme->item())) { + $buf .= ""; + $buf .= html::script("core/js/quickedit.js"); + } + return $buf; + } + + public static function thumb_top($theme, $child) { + if (access::can("edit", $child)) { + $edit_link = url::site("quick/edit/$child->id"); + return "