From bb844c1139c84090b446e50234f64063365affc3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 8 Jun 2009 08:48:42 +0800 Subject: Improve error handling support for corrupt images and report them appropriately in g2_import. Signed-off-by: Tim Almdal --- modules/g2_import/helpers/g2_import.php | 38 ++++++++++++++++++++++----------- modules/gallery/helpers/graphics.php | 7 +++--- modules/gallery/helpers/photo.php | 4 ++++ 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 51dc8705..a6c21489 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -407,13 +407,19 @@ class g2_import_Core { Kohana::log("alert", "$g2_path unsupported image type; using a placeholder gif"); $corrupt = 1; } - $item = photo::create( - $parent, - $g2_path, - $g2_item->getPathComponent(), - $g2_item->getTitle(), - self::extract_description($g2_item), - self::map($g2_item->getOwnerId())); + try { + $item = photo::create( + $parent, + $g2_path, + $g2_item->getPathComponent(), + $g2_item->getTitle(), + self::extract_description($g2_item), + self::map($g2_item->getOwnerId())); + } catch (Exception $e) { + Kohana::log("alert", "Corrupt image $g2_path\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + $corrupt = 1; + } break; case "GalleryMovieItem": @@ -449,12 +455,18 @@ class g2_import_Core { // Why oh why did I ever approve the session id placeholder idea in G2? $g2_item_url = str_replace('&g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT', '', $g2_item_url); - $warning = - t("%title from Gallery 2 could not be processed; " . - "(imported as %title)", - array("g2_url" => $g2_item_url, - "g3_url" => $item->url(), - "title" => $g2_item->getTitle())); + if (!empty($item)) { + $warning = + t("%title from Gallery 2 could not be processed; " . + "(imported as %title)", + array("g2_url" => $g2_item_url, + "g3_url" => $item->url(), + "title" => $g2_item->getTitle())); + } else { + $warning = + t("%title from Gallery 2 could not be processed", + array("g2_url" => $g2_item_url, "title" => $g2_item->getTitle())); + } message::warning($warning); log::warning("g2_import", $warning); Kohana::log("alert", $warning); diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 4846fa8a..25eb0891 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -166,12 +166,11 @@ class graphics_Core { $item->resize_dirty = 0; } $item->save(); - } catch (Kohana_Exception $e) { + } catch (Exception $e) { // Something went wrong rebuilding the image. Leave it dirty and move on. // @todo we should handle this better. Kohana::log("error", "Caught exception rebuilding image: {$item->title}\n" . - $e->getMessage() . "\n" . - $e->getTraceAsString()); + $e->getMessage() . "\n" . $e->getTraceAsString()); return false; } @@ -192,7 +191,7 @@ class graphics_Core { } if (filesize($input_file) == 0) { - throw new Exception("@todo MALFORMED_INPUT_FILE"); + throw new Exception("@todo EMPTY_INPUT_FILE"); } $dims = getimagesize($input_file); diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index c1c005f5..a4bc853b 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -53,6 +53,10 @@ class photo_Core { throw new Exception("@todo NAME_CANNOT_END_IN_PERIOD"); } + if (filesize($filename) == 0) { + throw new Exception("@todo EMPTY_INPUT_FILE"); + } + $image_info = getimagesize($filename); // Force an extension onto the name -- cgit v1.2.3 From 56f00333cdaa7f7716f35398a7a7a8082248d9be Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 9 Jun 2009 12:31:50 +0800 Subject: Fix the admin/themes url. Signed-off-by: Tim Almdal --- modules/gallery/views/admin_block_welcome.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/views/admin_block_welcome.html.php b/modules/gallery/views/admin_block_welcome.html.php index 488fa908..a453b006 100644 --- a/modules/gallery/views/admin_block_welcome.html.php +++ b/modules/gallery/views/admin_block_welcome.html.php @@ -10,7 +10,7 @@
  • choose a theme, or customize the way it looks.", - array("theme_url" => url::site("admin/theme"), + array("theme_url" => url::site("admin/themes"), "theme_details_url" => url::site("admin/theme_details"))) ?>
  • -- cgit v1.2.3 From cb7e375f6cc639b72c7e7ee43b2e2b9bab815697 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 9 Jun 2009 14:02:16 +0800 Subject: Try again to properly detect the base url, taking into account the sites that mangle SCRIPT_NAME Signed-off-by: Tim Almdal --- application/config/config.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index d274a31b..2d66d1c0 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -22,9 +22,25 @@ * Base path of the web site. If this includes a domain, eg: localhost/kohana/ * then a full URL will be used, eg: http://localhost/kohana/. If it only includes * the path, and a site_protocol is specified, the domain will be auto-detected. + * + * Here we do our best to autodetect the base path to Gallery. If your url is something like: + * http://example.com/gallery3/index.php/album73/photo5.jpg?param=value + * + * We want the site_domain to be: + * /gallery3 + * + * In the above example, $_SERVER["SCRIPT_NAME"] contains "/gallery3/index.php" so + * dirname($_SERVER["SCRIPT_NAME"]) is what we need. Except some low end hosts (namely 1and1.com) + * break SCRIPT_NAME and it contains the extra path info, so in the above example it'd be: + * /gallery3/index.php/album73/photo5.jpg + * + * So dirname doesn't work. So we do a tricky workaround where we look up the SCRIPT_FILENAME (in + * this case it'd be "index.php" and we delete from that part onwards. If you work at 1and1 and + * you're reading this, please fix this bug! */ -$config["site_domain"] = dirname( - empty($_SERVER["ORIG_SCRIPT_NAME"]) ? $_SERVER["SCRIPT_NAME"] : $_SERVER["ORIG_SCRIPT_NAME"]); +$config["site_domain"] = + substr($_SERVER["SCRIPT_NAME"], 0, + strpos($_SERVER["SCRIPT_NAME"], basename($_SERVER["SCRIPT_FILENAME"]))); /** * Force a default protocol to be used by the site. If no site_protocol is -- cgit v1.2.3 From 1fc79046568a5fe0c75c520ae643d0c7279ad64b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 06:35:35 -0700 Subject: Create a new method in MY_url.php "get_item_from_uri" which loads the item based on the uri. Then use this helper method in logout.php to insure that the guest user has access to the "continue" uri. If they don't redirect to the root album and let it deal with access issues. --- modules/gallery/helpers/MY_url.php | 21 ++++++++++++++------- modules/user/controllers/logout.php | 7 ++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index c8645c4d..e9a5f860 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -46,7 +46,19 @@ class url extends url_Core { return; } - $current_uri = html_entity_decode(Router::$current_uri, ENT_QUOTES); + $item = self:: get_item_from_uri(Router::$current_uri); + if ($item && $item->loaded) { + Router::$controller = "{$item->type}s"; + Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php"; + Router::$method = $item->id; + } + } + + /** + * Return the item that the uri is referencing + */ + static function get_item_from_uri($uri) { + $current_uri = html_entity_decode($uri); $item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find(); if (!$item->loaded) { // It's possible that the relative path cache for the item we're looking for is out of date, @@ -61,12 +73,7 @@ class url extends url_Core { } } } - - if ($item && $item->loaded) { - Router::$controller = "{$item->type}s"; - Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php"; - Router::$method = $item->id; - } + return $item; } /** diff --git a/modules/user/controllers/logout.php b/modules/user/controllers/logout.php index 6ceb7192..a541ed9b 100644 --- a/modules/user/controllers/logout.php +++ b/modules/user/controllers/logout.php @@ -26,7 +26,12 @@ class Logout_Controller extends Controller { log::info("user", t("User %name logged out", array("name" => $user->name)), html::anchor("user/$user->id", $user->name)); if ($this->input->get("continue")) { - url::redirect($this->input->get("continue")); + $item = url::get_item_from_uri($this->input->get("continue")); + if (access::can("view", $item)) { + url::redirect($this->input->get("continue")); + } else { + url::redirect(""); + } } } } \ No newline at end of file -- cgit v1.2.3 From 2f2fdb1a8f8c55022ed3b5a7157b803a38c291d3 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Tue, 9 Jun 2009 14:25:49 +0800 Subject: Show status message when album cover is set (#257) Signed-off-by: Tim Almdal --- modules/gallery/controllers/quick.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 6efcb9de..d6f5213f 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -87,9 +87,12 @@ class Quick_Controller extends Controller { access::required("view", $item->parent()); access::required("edit", $item->parent()); + $msg = t("Made %title this album's cover", array("title" => $item->title)); + item::make_album_cover($item); + message::success($msg); - print json_encode(array("result" => "success")); + print json_encode(array("result" => "success", "reload" => 1)); } public function delete($id) { -- cgit v1.2.3 From 01042b6d8528a396df1cfa145a43ca589f51ec7c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 06:44:08 -0700 Subject: Removed extra whitespace --- modules/gallery/helpers/MY_url.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index e9a5f860..7bee70ca 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -46,7 +46,7 @@ class url extends url_Core { return; } - $item = self:: get_item_from_uri(Router::$current_uri); + $item = self::get_item_from_uri(Router::$current_uri); if ($item && $item->loaded) { Router::$controller = "{$item->type}s"; Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php"; -- cgit v1.2.3 From b84ef45eb13f218c63cd904386db6bb737ef8bee Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 07:18:41 -0700 Subject: Rather than just displaying the "unformatted" login screen when the root album is not viewable by a guest, display the root album as if it was empty. When the page finishes loading force the login dialog to be displayed. --- modules/gallery/controllers/albums.php | 12 ++++++++++-- themes/default/views/page.html.php | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index efde4f09..0fd89f05 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -23,16 +23,24 @@ class Albums_Controller extends Items_Controller { * @see REST_Controller::_show($resource) */ public function _show($album) { + $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - print new Theme_View("login_page.html", "album"); + $template = new Theme_View("page.html", "album"); + $template->set_global("page_size", $page_size); + $template->set_global("item", $album); + $template->set_global("children", array()); + $template->set_global("children_count", 0); + $template->set_global("parents", $album->parents()); + $template->unauthorized = true; + $template->content = new View("album.html"); + print $template; return; } else { access::forbidden(); } } - $page_size = module::get_var("gallery", "page_size", 9); $show = $this->input->get("show"); if ($show) { diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index 6c77fb72..a17b643d 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -52,6 +52,13 @@ head() ?> + + + main_element_attributes() ?>> -- cgit v1.2.3 From 08d8d320466f676e74a7c04a2fe874fd3a568429 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 16:18:47 -0700 Subject: Changed how directories are processed when the parent directory is selected and the branch was never opened on the client. This should fix some of the issues with the server_add as I was able to select the staging directory and then add over 400 images in a multi-tier structure. --- modules/server_add/controllers/server_add.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 2c6eb5e0..c92b4f7e 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -87,17 +87,20 @@ class Server_Add_Controller extends Controller { foreach (array_keys($paths) as $valid_path) { $path_length = strlen($valid_path); foreach ($input_files as $key => $path) { - if (!empty($path) && $valid_path != $path && strpos($path, $valid_path) === 0) { - $relative_path = substr(dirname($path), $path_length); - $name = basename($path); - $files[$valid_path][] = array("path" => $relative_path, - "parent_id" => $id, "name" => basename($path), + if (!empty($path)) { + if ($valid_path != $path && strpos($path, $valid_path) === 0) { + $relative_path = substr(dirname($path), $path_length); + $name = basename($path); + $files[$valid_path][] = array("path" => $relative_path, + "parent_id" => $id, "name" => basename($path), "type" => is_dir($path) ? "album" : "file"); - $total_count++; + $total_count++; + } if ($collapsed[$key] === "true") { $total_count += $this->_select_children($id, $valid_path, $path, $files[$valid_path]); } unset($input_files[$key]); + unset($collapsed[$key]); } } } -- cgit v1.2.3 From e7a3b6fa55d4eda9140b122bc50681b979229da3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 17:17:27 -0700 Subject: Created not_authorized.html.php which is a prettier login screen if the root album is not publicly browsable. --- modules/gallery/controllers/albums.php | 10 ++-------- themes/default/views/page.html.php | 7 ------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 0fd89f05..9b837442 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,14 +26,8 @@ class Albums_Controller extends Items_Controller { $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - $template = new Theme_View("page.html", "album"); - $template->set_global("page_size", $page_size); - $template->set_global("item", $album); - $template->set_global("children", array()); - $template->set_global("children_count", 0); - $template->set_global("parents", $album->parents()); - $template->unauthorized = true; - $template->content = new View("album.html"); + $template = new Theme_View("not_authorized.html", "album"); + $template->content = new View("login_page.html"); print $template; return; } else { diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index a17b643d..6c77fb72 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -52,13 +52,6 @@ head() ?> - - - main_element_attributes() ?>> -- cgit v1.2.3 From cf86a7b8df9571eef7b507f174ee3f714776d14d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 17:22:35 -0700 Subject: Forgot this on the last commit --- themes/default/views/not_authorized.html.php | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 themes/default/views/not_authorized.html.php diff --git a/themes/default/views/not_authorized.html.php b/themes/default/views/not_authorized.html.php new file mode 100644 index 00000000..d009a4ac --- /dev/null +++ b/themes/default/views/not_authorized.html.php @@ -0,0 +1,69 @@ + + + + + + + <? if (empty($page_title)): ?> + <?= t("Gallery3 Login") ?> + <? if (!empty($item)): ?> + :: <?= p::clean($item->title) ?> + <? endif ?> + <? else: ?> + <?= $page_title ?> + <? endif ?> + <?= $theme->page_type ?> + + " type="image/x-icon" /> + " + media="screen,print,projection" /> + " + media="screen" /> + " + media="screen,print,projection" /> + " + media="screen,print,projection" /> + + + + + + + + + + + + head() ?> + + + main_element_attributes() ?>> + page_top() ?> +
    + site_status() ?> +
    + display("header.html") ?> +
    +
    +
    +
    +
    + messages() ?> + +
    +
    +
    +
    +
    +
    +
    + display("footer.html") ?> +
    +
    + page_bottom() ?> + + -- cgit v1.2.3 From 7e61bcbbecefb6b12343a8c6d3f700d282a3528b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Jun 2009 17:38:21 -0700 Subject: Add some window dressing to login_page.html in order to make it more in line with the overall look of the Gallery3 theme --- modules/gallery/controllers/albums.php | 4 +- themes/default/views/login_page.html.php | 48 ++++++++++++++++++- themes/default/views/not_authorized.html.php | 69 ---------------------------- 3 files changed, 47 insertions(+), 74 deletions(-) delete mode 100644 themes/default/views/not_authorized.html.php diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 9b837442..f37609e6 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,9 +26,7 @@ class Albums_Controller extends Items_Controller { $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - $template = new Theme_View("not_authorized.html", "album"); - $template->content = new View("login_page.html"); - print $template; + print new Theme_View("login_page.html"); return; } else { access::forbidden(); diff --git a/themes/default/views/login_page.html.php b/themes/default/views/login_page.html.php index 27f8571e..c4880727 100644 --- a/themes/default/views/login_page.html.php +++ b/themes/default/views/login_page.html.php @@ -7,11 +7,55 @@ <?= t("Please Login to Gallery") ?> + " type="image/x-icon" /> + " + media="screen,print,projection" /> + " + media="screen" /> + " + media="screen,print,projection" /> " media="screen,print,projection" /> + + + + + + + + + + + + head() ?> - - + main_element_attributes() ?>> + page_top() ?> +
    + site_status() ?> +
    + display("header.html") ?> +
    +
    +
    +
    +
    + messages() ?> + +
    +
    +
    +
    +
    +
    +
    + display("footer.html") ?> +
    +
    + page_bottom() ?> diff --git a/themes/default/views/not_authorized.html.php b/themes/default/views/not_authorized.html.php deleted file mode 100644 index d009a4ac..00000000 --- a/themes/default/views/not_authorized.html.php +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - <? if (empty($page_title)): ?> - <?= t("Gallery3 Login") ?> - <? if (!empty($item)): ?> - :: <?= p::clean($item->title) ?> - <? endif ?> - <? else: ?> - <?= $page_title ?> - <? endif ?> - <?= $theme->page_type ?> - - " type="image/x-icon" /> - " - media="screen,print,projection" /> - " - media="screen" /> - " - media="screen,print,projection" /> - " - media="screen,print,projection" /> - - - - - - - - - - - - head() ?> - - - main_element_attributes() ?>> - page_top() ?> -
    - site_status() ?> -
    - display("header.html") ?> -
    -
    -
    -
    -
    - messages() ?> - -
    -
    -
    -
    -
    -
    -
    - display("footer.html") ?> -
    -
    - page_bottom() ?> - - -- cgit v1.2.3 From 89b6570eccf4d7aa12c730c8115517a5e24fc890 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Tue, 9 Jun 2009 21:33:16 -0600 Subject: Update floats after .rtl addition. Both should work now. --- themes/default/css/screen.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index f306f287..03c13cc1 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -92,11 +92,11 @@ a:hover, margin: .3em 1em; } -.rtl #gDialog .gCancel { +#gForgotPasswordLink, .rtl #gDialog .gCancel { float: right; } -.rtl #gForgotPasswordLink { +#gDialog .gCancel, .rtl #gForgotPasswordLink { float: left; } -- cgit v1.2.3 From 0c5cb026a72c3e894cbb7c6a637267f867cc323a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 10 Jun 2009 08:26:40 -0700 Subject: Only add the comment rss feeds if the comment module is active. fix for #365 --- modules/rss/helpers/rss_theme.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/rss/helpers/rss_theme.php b/modules/rss/helpers/rss_theme.php index d47d3313..54bba210 100644 --- a/modules/rss/helpers/rss_theme.php +++ b/modules/rss/helpers/rss_theme.php @@ -40,12 +40,16 @@ class rss_theme_Core { $block->css_id = "gRss"; $block->title = t("Available RSS Feeds"); $block->content = new View("rss_block.html"); - $block->content->feeds = array( - t("New photos or movies") => url::site("rss/updates"), - t("All new comments") => url::site("rss/comments"), - sprintf(t("Comments on %s"), - $theme->item()->title) => url::site("rss/comments/{$theme->item()->id}") - ); + // @todo consider pushing the code for the feeds back to the associated modules + // and create an event 'generate_rss_feeds' that modules can respond to create + // the list of feeds. + $feeds = array(t("New photos or movies") => url::site("rss/updates")); + if (module::is_active("comment")) { + $feeds[t("All new comments")] = url::site("rss/comments"); + $feeds[sprintf(t("Comments on %s"), $theme->item()->title)] = + url::site("rss/comments/{$theme->item()->id}"); + } + $block->content->feeds = $feeds; return $block; } } -- cgit v1.2.3