mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-05-19 19:09:13 -04:00
Squashed commit of the following: commit13dbd3515bMerge:f0f094c97400b7Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 20:33:02 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commitf0f094c3f7Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 20:22:49 2011 -0600 Explain the conditional rename in item::save() with a comment. commit1b3a6b85c1Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 18:29:34 2011 -0600 Improve the comment explaining why the data_file extension is important. commitc3e8c1e3b5Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 18:12:56 2011 -0600 The data_file field is public, so we don't need to supply an accessor method. commit2375a02e2cAuthor: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 16:40:55 2011 -0600 Change the signature of system::tempnam to something more appropriate for Gallery. commita8ca9dcf9eAuthor: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 16:10:06 2011 -0600 Change the name of the extensions helper to legal_file. commit7e61a01a96Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 30 16:08:49 2011 -0600 Change the name of the extensions helper to legal_file. commit4c2b2ebd3fAuthor: Chad Parry <github@chad.parry.org> Date: Wed Apr 27 20:52:35 2011 -0600 Remove a newline at the end of the file that I accidentally introduced. commit6d564f185eMerge:7ff485f4060640Author: Chad Parry <github@chad.parry.org> Date: Wed Apr 27 20:35:58 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit7ff485fa48Author: Chad Parry <github@chad.parry.org> Date: Wed Apr 27 20:29:06 2011 -0600 Move the extensions helpers out of the Kohana system directory and into their own Gallery Extensions class. commit26585fed03Merge:809567fc8f90e8Author: Chad Parry <github@chad.parry.org> Date: Sun Apr 24 08:28:39 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit809567f128Author: Chad Parry <github@chad.parry.org> Date: Sun Apr 24 08:10:04 2011 -0600 Expose the data file field. commitfcb06bf175Author: Chad Parry <github@chad.parry.org> Date: Sun Apr 24 00:45:12 2011 -0600 Don't assign to the item->name field if the name is unchanged, because the save method will crash. commitc6ef706d70Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 22:55:59 2011 -0600 Preserve old data files long enough for them to be available to event handlers. commit0d6a3a3cfcAuthor: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 21:19:47 2011 -0600 Create a tempnam substitute that safely creates files with a given extension. commite149cf7238Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 16:39:25 2011 -0600 Support data files that change their extension and MIME type. commit6702104f57Author: Chad Parry <github@chad.parry.org> Date: Sat Apr 23 16:35:00 2011 -0600 Resolve an infinite recursion that happens when the path caches are updated during saving. commit944cb72eeaMerge:567522b5af74d4Author: Chad Parry <github@chad.parry.org> Date: Fri Apr 22 14:10:42 2011 -0600 Merge remote branch 'origin/master' into rawphoto commit567522bfa0Author: Chad Parry <github@chad.parry.org> Date: Thu Apr 21 20:12:32 2011 -0600 Add an event for when a new graphics toolkit is chosen. commit31ba081b79Author: Chad Parry <github@chad.parry.org> Date: Thu Apr 21 02:06:53 2011 -0600 Add an event that will collect all valid filename extensions.
146 lines
4.4 KiB
PHP
146 lines
4.4 KiB
PHP
<?php defined("SYSPATH") or die("No direct script access.");
|
|
/**
|
|
* Gallery - a web based photo album viewer and editor
|
|
* Copyright (C) 2000-2011 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 rotate($id, $dir) {
|
|
access::verify_csrf();
|
|
$item = model_cache::get("item", $id);
|
|
access::required("view", $item);
|
|
access::required("edit", $item);
|
|
|
|
$degrees = 0;
|
|
switch($dir) {
|
|
case "ccw":
|
|
$degrees = -90;
|
|
break;
|
|
|
|
case "cw":
|
|
$degrees = 90;
|
|
break;
|
|
}
|
|
|
|
if ($degrees) {
|
|
$tmpfile = system::temp_filename("rotate",
|
|
pathinfo($item->file_path(), PATHINFO_EXTENSION));
|
|
gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item);
|
|
$item->set_data_file($tmpfile);
|
|
$item->save();
|
|
unlink($tmpfile);
|
|
}
|
|
|
|
if (Input::instance()->get("page_type") == "collection") {
|
|
json::reply(
|
|
array("src" => $item->thumb_url(),
|
|
"width" => $item->thumb_width,
|
|
"height" => $item->thumb_height));
|
|
} else {
|
|
json::reply(
|
|
array("src" => $item->resize_url(),
|
|
"width" => $item->resize_width,
|
|
"height" => $item->resize_height));
|
|
}
|
|
}
|
|
|
|
public function make_album_cover($id) {
|
|
access::verify_csrf();
|
|
|
|
$item = model_cache::get("item", $id);
|
|
access::required("view", $item);
|
|
access::required("view", $item->parent());
|
|
access::required("edit", $item->parent());
|
|
|
|
$msg = t("Made <b>%title</b> this album's cover", array("title" => html::purify($item->title)));
|
|
|
|
item::make_album_cover($item);
|
|
message::success($msg);
|
|
|
|
json::reply(array("result" => "success", "reload" => 1));
|
|
}
|
|
|
|
public function form_delete($id) {
|
|
$item = model_cache::get("item", $id);
|
|
access::required("view", $item);
|
|
access::required("edit", $item);
|
|
|
|
$v = new View("quick_delete_confirm.html");
|
|
$v->item = $item;
|
|
$v->form = item::get_delete_form($item);
|
|
print $v;
|
|
}
|
|
|
|
public function delete($id) {
|
|
access::verify_csrf();
|
|
$item = model_cache::get("item", $id);
|
|
access::required("view", $item);
|
|
access::required("edit", $item);
|
|
|
|
if ($item->is_album()) {
|
|
$msg = t("Deleted album <b>%title</b>", array("title" => html::purify($item->title)));
|
|
} else {
|
|
$msg = t("Deleted photo <b>%title</b>", array("title" => html::purify($item->title)));
|
|
}
|
|
|
|
$parent = $item->parent();
|
|
|
|
if ($item->is_album()) {
|
|
// Album delete will trigger deletes for all children. Do this in a batch so that we can be
|
|
// smart about notifications, album cover updates, etc.
|
|
batch::start();
|
|
$item->delete();
|
|
batch::stop();
|
|
} else {
|
|
$item->delete();
|
|
}
|
|
message::success($msg);
|
|
|
|
$from_id = Input::instance()->get("from_id");
|
|
if (Input::instance()->get("page_type") == "collection" &&
|
|
$from_id != $id /* deleted the item we were viewing */) {
|
|
json::reply(array("result" => "success", "reload" => 1));
|
|
} else {
|
|
json::reply(array("result" => "success", "location" => $parent->url()));
|
|
}
|
|
}
|
|
|
|
public function form_edit($id) {
|
|
$item = model_cache::get("item", $id);
|
|
access::required("view", $item);
|
|
access::required("edit", $item);
|
|
|
|
switch ($item->type) {
|
|
case "album":
|
|
$form = album::get_edit_form($item);
|
|
break;
|
|
|
|
case "photo":
|
|
$form = photo::get_edit_form($item);
|
|
break;
|
|
|
|
case "movie":
|
|
$form = movie::get_edit_form($item);
|
|
break;
|
|
}
|
|
|
|
// Pass on the source item where this form was generated, so we have an idea where to return to.
|
|
$form->hidden("from_id")->value((int)Input::instance()->get("from_id", 0));
|
|
|
|
print $form;
|
|
}
|
|
}
|