summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/controllers/quick.php68
-rw-r--r--core/css/quickedit.css45
-rw-r--r--core/helpers/core_block.php22
-rw-r--r--core/images/arrow_rotate_anticlockwise.pngbin0 -> 608 bytes
-rw-r--r--core/images/arrow_rotate_clockwise.pngbin0 -> 602 bytes
-rw-r--r--core/js/quickedit.js45
-rw-r--r--core/views/quick_edit.html.php14
-rw-r--r--themes/default/views/album.html.php2
8 files changed, 194 insertions, 2 deletions
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 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Quick_Controller extends Controller {
+ public function edit($id) {
+ $item = ORM::factory("item", $id);
+ if (!$item->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 "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
+ $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
url::file("core/css/debug.css") . "\" />";
}
+ if ($theme->page_type == "album" && access::can("edit", $theme->item())) {
+ $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .
+ url::file("core/css/quickedit.css") . "\" />";
+ $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 "<div class=\"gQuickEdit\" quickedit_link=\"$edit_link\">";
+ }
+ }
+
+ public static function thumb_bottom($theme, $child) {
+ if (access::can("edit", $child)) {
+ return "</div>";
+ }
}
public static function admin_head($theme) {
diff --git a/core/images/arrow_rotate_anticlockwise.png b/core/images/arrow_rotate_anticlockwise.png
new file mode 100644
index 00000000..46c75aa8
--- /dev/null
+++ b/core/images/arrow_rotate_anticlockwise.png
Binary files differ
diff --git a/core/images/arrow_rotate_clockwise.png b/core/images/arrow_rotate_clockwise.png
new file mode 100644
index 00000000..aa65210e
--- /dev/null
+++ b/core/images/arrow_rotate_clockwise.png
Binary files differ
diff --git a/core/js/quickedit.js b/core/js/quickedit.js
new file mode 100644
index 00000000..5dad5e1f
--- /dev/null
+++ b/core/js/quickedit.js
@@ -0,0 +1,45 @@
+$(document).ready(function() {
+ $("div.gQuickEdit").hover(show_quickedit, function() { });
+});
+
+var show_quickedit = function() {
+ $("#gQuickEditPane").remove();
+ $(this).append("<div id=\"gQuickEditPane\"></div>");
+ var img = $(this).find("img");
+ var pos = img.position();
+ $("#gQuickEditPane").css({
+ "position": "absolute",
+ "top": pos.top,
+ "left": pos.left,
+ "width": img.innerWidth() + 1,
+ "height": 32
+ });
+ $(this).hover(function() { }, hide_quickedit);
+ $.get(
+ $(this).attr("quickedit_link"),
+ {},
+ function(data, textStatus) {
+ $("#gQuickEditPane").html(data);
+ $("#gQuickEditPane div").click(function() {
+ quickedit($(this).attr("quickedit_link"), img);
+ });
+ }
+ );
+};
+
+var quickedit = function(url, img) {
+ $.ajax({
+ type: "GET",
+ url: url,
+ dataType: "json",
+ success: function(data) {
+ img.attr("width", data.width);
+ img.attr("height", data.height);
+ img.attr("src", data.src);
+ }
+ });
+};
+
+var hide_quickedit = function() {
+ $("#gQuickEditPane").remove();
+};
diff --git a/core/views/quick_edit.html.php b/core/views/quick_edit.html.php
new file mode 100644
index 00000000..30baf4f8
--- /dev/null
+++ b/core/views/quick_edit.html.php
@@ -0,0 +1,14 @@
+<? if ($item->type == "photo"): ?>
+<div class="rotate-counter-clockwise"
+ quickedit_link="<?= url::site("quick/rotate/$item->id/ccw?csrf=" . access::csrf_token()) ?>">
+ <span>
+ <?= _("Rotate CCW") ?>
+ </span>
+</div>
+<div class="rotate-clockwise"
+ quickedit_link="<?= url::site("quick/rotate/$item->id/cw?csrf=" . access::csrf_token()) ?>">
+ <span>
+ <?= _("Rotate CCW") ?>
+ </span>
+</div>
+<? endif ?>
diff --git a/themes/default/views/album.html.php b/themes/default/views/album.html.php
index beab0ab0..c5415a39 100644
--- a/themes/default/views/album.html.php
+++ b/themes/default/views/album.html.php
@@ -16,7 +16,7 @@
<a href="<?= $child->url() ?>">
<img class="gThumbnail"
src="<?= $child->thumb_url() ?>"
- alt="<?= $child->title ?>"
+ alt="<?= $child->title ?>"
width="<?= $child->thumb_width ?>"
height="<?= $child->thumb_height ?>" />
</a>