diff options
-rw-r--r-- | core/SimpleUploader.swf | bin | 0 -> 301016 bytes | |||
-rw-r--r-- | core/controllers/simple_uploader.php | 55 | ||||
-rw-r--r-- | core/helpers/core_menu.php | 4 | ||||
-rw-r--r-- | core/hooks/init_gallery.php | 11 | ||||
-rw-r--r-- | core/views/simple_uploader.html.php | 30 |
5 files changed, 98 insertions, 2 deletions
diff --git a/core/SimpleUploader.swf b/core/SimpleUploader.swf Binary files differnew file mode 100644 index 00000000..7b030809 --- /dev/null +++ b/core/SimpleUploader.swf diff --git a/core/controllers/simple_uploader.php b/core/controllers/simple_uploader.php new file mode 100644 index 00000000..e3ed84ec --- /dev/null +++ b/core/controllers/simple_uploader.php @@ -0,0 +1,55 @@ +<?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 Simple_Uploader_Controller extends Controller { + public function app($id) { + $item = ORM::factory("item", $id); + access::required("edit", $item); + + $v = new View("simple_uploader.html"); + $v->item = $item; + $v->flash_vars = + "uploadUrl=" . urlencode( + url::site("simple_uploader/add_photo/$item->id" . + "?csrf=" . access::csrf_token() . + "&g3sid=" . Session::instance()->id() . + "&user_agent=" . Input::instance()->server("HTTP_USER_AGENT"))) . + "&title=" . urlencode(t("Add photos")) . + "&addLabel=" . urlencode(t("Choose photos to add...")); + print $v; + } + + public function add_photo($id) { + $album = ORM::factory("item", $id); + access::required("edit", $album); + access::verify_csrf(); + + $file_validation = new Validation($_FILES); + $file_validation->add_rules("file", "upload::valid", "upload::type[gif,jpg,png]"); + if ($file_validation->validate()) { + $temp_filename = upload::save("file"); + $photo = photo::create( + $album, + $temp_filename, + basename($temp_filename), + basename($temp_filename)); + log::success("content", "Added a photo", html::anchor("photos/$photo->id", "view photo")); + } + } +} diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php index c1472001..2ec8e073 100644 --- a/core/helpers/core_menu.php +++ b/core/helpers/core_menu.php @@ -43,7 +43,7 @@ class core_menu_Core { ->id("edit_item") ->label($item->is_album() ? t("Edit album") : t("Edit photo")) ->url(url::site("form/edit/{$item->type}s/$item->id"))); - + // @todo Move album options menu to the album quick edit pane // @todo Create resized item quick edit pane menu if ($item->is_album()) { @@ -51,7 +51,7 @@ class core_menu_Core { ->append(Menu::factory("dialog") ->id("add_item") ->label(t("Add a photo")) - ->url(url::site("form/add/albums/$item->id?type=photo"))) + ->url(url::site("simple_uploader/app/$item->id"))) ->append(Menu::factory("dialog") ->id("add_album") ->label(t("Add an album")) diff --git a/core/hooks/init_gallery.php b/core/hooks/init_gallery.php index 27a4d8a4..89f97ef9 100644 --- a/core/hooks/init_gallery.php +++ b/core/hooks/init_gallery.php @@ -21,3 +21,14 @@ Event::add("system.ready", array("I18n", "instance")); Event::add("system.post_routing", array("theme", "load_themes")); Event::add("system.ready", array("module", "load_modules")); Event::add("system.post_routing", array("url", "parse_url")); + +// Override the cookie if we have a session id in the URL. +// @todo This should probably be an event callback +$input = Input::instance(); +if ($g3sid = $input->post("g3sid", $input->get("g3sid"))) { + $_COOKIE["g3sid"] = $g3sid; +} + +if ($user_agent = $input->post("user_agent", $input->get("user_agent"))) { + Kohana::$user_agent = $user_agent; +} diff --git a/core/views/simple_uploader.html.php b/core/views/simple_uploader.html.php new file mode 100644 index 00000000..c9389a13 --- /dev/null +++ b/core/views/simple_uploader.html.php @@ -0,0 +1,30 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<!-- hack to get this string into the dialog's titlebar --> +<fieldset> + <legend> <?= t("Add photos to %album_title", array("album_title" => $item->title)) ?> </legend> +</fieldset> + +<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" + id="SimpleUploader" + width="470px" + height="400px" + codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> + <param name="movie" value="UploaderShell.swf" /> + <param name="flashVars" value="<?= $flash_vars ?>" /> + <param name="quality" value="high" /> + <param name="bgcolor" value="#ffffff" /> + <param name="allowScriptAccess" value="sameDomain" /> + <embed src="<?= url::file("core/SimpleUploader.swf") ?>" + quality="high" + bgcolor="#ffffff" + flashVars="<?= $flash_vars ?>" + width="470" height="400" name="<?= url::file("core/SimpleUploader.swf") ?>" + align="middle" + play="true" + loop="false" + quality="high" + allowScriptAccess="sameDomain" + type="application/x-shockwave-flash" + pluginspage="http://www.adobe.com/go/getflashplayer"> + </embed> +</object> |