From: <tna...@us...> - 2009-02-26 16:27:37
|
Revision: 20206 http://gallery.svn.sourceforge.net/gallery/?rev=20206&view=rev Author: tnalmdal Date: 2009-02-26 16:27:23 +0000 (Thu, 26 Feb 2009) Log Message: ----------- Fix up add from server: 1) Upload requests are serialized so we don't over load the server or get race conditions occurring. 2) new albums are created based on the file structure of the authorized path that is the source directory. Modified Paths: -------------- gallery3/trunk/modules/local_import/controllers/local_import.php gallery3/trunk/modules/local_import/helpers/local_import_theme.php gallery3/trunk/modules/local_import/js/local_import.js gallery3/trunk/modules/local_import/views/local_import_tree_dialog.html.php Modified: gallery3/trunk/modules/local_import/controllers/local_import.php =================================================================== --- gallery3/trunk/modules/local_import/controllers/local_import.php 2009-02-26 16:12:09 UTC (rev 20205) +++ gallery3/trunk/modules/local_import/controllers/local_import.php 2009-02-26 16:27:23 UTC (rev 20206) @@ -60,16 +60,14 @@ $parent = ORM::factory("item", $id); access::can("local_import", $item); - if (!$parent->loaded) { + if (!$parent->is_album() && !$parent->loaded ) { throw new Exception("@todo BAD_ALBUM"); } $path = $this->input->post("path"); - $base_path = $parent->file_path(); $source_path = $path[0]; for ($i = 1; $i < count($path); $i++) { // skip the first path - $base_path .= "/$path[$i]"; $source_path .= "/$path[$i]"; $pathinfo = pathinfo($source_path); set_time_limit(30); @@ -79,25 +77,15 @@ ->where("parent_id", $parent->id) ->find(); if (!$album->loaded) { - $parent = album::create($parent, $path[$i], $path[$i]); - log::success("content", t("Added album"), - html::anchor("albums/{$parent->id}", t("view album"))); - message::success(t("Added album %album_title", array("album_title" => $parent->title))); - } else { - $parent = $album; + $album = album::create($parent, $path[$i], $path[$i], null, user::active()->id); } + $parent = $album; } else if (in_array($pathinfo["extension"], array("flv", "mp4"))) { - $movie = - movie::create($parent, $source_path, basename($source_path), basename($source_path)); - log::success("content", t("Added a movie"), - html::anchor("movies/{$movie->id}", t("view movie"))); - message::success(t("Added movie %movie_title", array("movie_title" => $movie->title))); + $movie = movie::create($parent, $source_path, basename($source_path), + basename($source_path), null, user::active()->id); } else { - $photo = - photo::create($parent, $source_path, basename($source_path), basename($source_path)); - log::success("content", t("Added a photo"), - html::anchor("photos/{$photo->id}", t("view photo"))); - message::success(t("Added photo %photo_title", array("photo_title" => $photo->title))); + $photo = photo::create($parent, $source_path, basename($source_path), + basename($source_path), null, user::active()->id); } } } Modified: gallery3/trunk/modules/local_import/helpers/local_import_theme.php =================================================================== --- gallery3/trunk/modules/local_import/helpers/local_import_theme.php 2009-02-26 16:12:09 UTC (rev 20205) +++ gallery3/trunk/modules/local_import/helpers/local_import_theme.php 2009-02-26 16:27:23 UTC (rev 20206) @@ -33,12 +33,12 @@ return implode("\n", $head); } - static function head($theme) { - $head[] = "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" . - url::file("modules/local_import/css/local_import.css") . "\" />"; + //static function head($theme) { + //$head[] = "<link media=\"screen, projection\" rel=\"stylesheet\" type=\"text/css\" href=\"" . + // url::file("modules/local_import/css/local_import.css") . "\" />"; - $head[] = html::script("modules/local_import/js/local_import.js"); + //$head[] = html::script("modules/local_import/js/local_import.js"); - return implode("\n", $head); - } + //return implode("\n", $head); + //} } \ No newline at end of file Modified: gallery3/trunk/modules/local_import/js/local_import.js =================================================================== --- gallery3/trunk/modules/local_import/js/local_import.js 2009-02-26 16:12:09 UTC (rev 20205) +++ gallery3/trunk/modules/local_import/js/local_import.js 2009-02-26 16:27:23 UTC (rev 20206) @@ -1,3 +1,11 @@ +$("#gLocalImport").ready(function() { + $("#gLocalImport :submit").click(function(event) { + do_import(this, event); + }); + $("#gProgressBar").progressbar(); + $("#gLocalImport ul").css("display", "block"); +}); + function open_close_branch(icon, event) { var parent = icon.parentNode; var children = $(parent).find(".gCheckboxTree"); @@ -15,8 +23,8 @@ } else { $(icon).addClass("ui-icon-minus"); $(icon).removeClass("ui-icon-plus"); - $(parent).children("ul").slideDown("fast"); } + $(parent).children("ul").slideDown("fast"); } else { $(icon).addClass("ui-icon-plus"); $(icon).removeClass("ui-icon-minus"); @@ -96,8 +104,13 @@ } function process_file(li_element, parms) { - var url = $("#gLocalImport form").attr("action"); - $.post(url, parms, function(data, status) { + $.ajax({async: false, + success: function(data, status) { + }, + data: parms, + dataType: "html", + type: "POST", + url: $("#gLocalImport form").attr("action") }); current++; $("#gProgressBar").progressbar('value', current / process_length * 100); Modified: gallery3/trunk/modules/local_import/views/local_import_tree_dialog.html.php =================================================================== --- gallery3/trunk/modules/local_import/views/local_import_tree_dialog.html.php 2009-02-26 16:12:09 UTC (rev 20205) +++ gallery3/trunk/modules/local_import/views/local_import_tree_dialog.html.php 2009-02-26 16:27:23 UTC (rev 20206) @@ -1,12 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<script type="text/javascript"> -$("#gLocalImport").ready(function() { - $("#gLocalImport :submit").click(function(event) { - do_import(this, event); - }); - $("#gProgressBar").progressbar(); - $("#gLocalImport ul").css("display", "block"); -});</script> +<link media="screen, projection" rel="stylesheet" type="text/css" href="<?= url::file("modules/local_import/css/local_import.css") ?>" /> +<?= html::script("modules/local_import/js/local_import.js"); ?> + <div id="gLocalImport"> <h1 style="display: none;"><?= sprintf(t("Import Photos to '%s'"), $album_title) ?></h1> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |