summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/akismet/controllers/admin_akismet.php2
-rw-r--r--modules/akismet/helpers/akismet.php2
-rw-r--r--modules/akismet/helpers/akismet_event.php2
-rw-r--r--modules/akismet/helpers/akismet_installer.php2
-rw-r--r--modules/akismet/module.info6
-rw-r--r--modules/akismet/tests/Akismet_Helper_Test.php2
-rw-r--r--modules/comment/controllers/admin_comments.php2
-rw-r--r--modules/comment/controllers/admin_manage_comments.php2
-rw-r--r--modules/comment/controllers/comments.php2
-rw-r--r--modules/comment/helpers/comment.php2
-rw-r--r--modules/comment/helpers/comment_block.php2
-rw-r--r--modules/comment/helpers/comment_event.php2
-rw-r--r--modules/comment/helpers/comment_installer.php3
-rw-r--r--modules/comment/helpers/comment_rest.php2
-rw-r--r--modules/comment/helpers/comment_rss.php2
-rw-r--r--modules/comment/helpers/comment_theme.php2
-rw-r--r--modules/comment/helpers/comments_rest.php2
-rw-r--r--modules/comment/helpers/item_comments_rest.php2
-rw-r--r--modules/comment/models/comment.php2
-rw-r--r--modules/comment/module.info6
-rw-r--r--modules/comment/tests/Comment_Event_Test.php2
-rw-r--r--modules/comment/tests/Comment_Helper_Test.php2
-rw-r--r--modules/comment/tests/Comment_Model_Test.php2
-rw-r--r--modules/digibug/config/digibug.php2
-rw-r--r--modules/digibug/controllers/admin_digibug.php2
-rw-r--r--modules/digibug/controllers/digibug.php2
-rw-r--r--modules/digibug/helpers/digibug_event.php2
-rw-r--r--modules/digibug/helpers/digibug_installer.php3
-rw-r--r--modules/digibug/helpers/digibug_theme.php2
-rw-r--r--modules/digibug/models/digibug_proxy.php2
-rw-r--r--modules/digibug/module.info6
-rw-r--r--modules/digibug/tests/Digibug_Controller_Test.php2
-rw-r--r--modules/exif/controllers/exif.php2
-rw-r--r--modules/exif/helpers/exif.php2
-rw-r--r--modules/exif/helpers/exif_event.php2
-rw-r--r--modules/exif/helpers/exif_installer.php3
-rw-r--r--modules/exif/helpers/exif_task.php2
-rw-r--r--modules/exif/helpers/exif_theme.php2
-rw-r--r--modules/exif/models/exif_key.php2
-rw-r--r--modules/exif/models/exif_record.php2
-rw-r--r--modules/exif/module.info6
-rw-r--r--modules/exif/tests/Exif_Test.php2
-rw-r--r--modules/g2_import/controllers/admin_g2_import.php2
-rw-r--r--modules/g2_import/controllers/g2.php39
-rw-r--r--modules/g2_import/helpers/g2_import.php2
-rw-r--r--modules/g2_import/helpers/g2_import_event.php2
-rw-r--r--modules/g2_import/helpers/g2_import_installer.php3
-rw-r--r--modules/g2_import/helpers/g2_import_task.php2
-rw-r--r--modules/g2_import/libraries/G2_Import_Exception.php2
-rw-r--r--modules/g2_import/models/g2_map.php2
-rw-r--r--modules/g2_import/module.info6
-rw-r--r--modules/gallery/config/cache.php2
-rw-r--r--modules/gallery/config/cookie.php2
-rw-r--r--modules/gallery/config/database.php2
-rw-r--r--modules/gallery/config/locale.php2
-rw-r--r--modules/gallery/config/log_file.php2
-rw-r--r--modules/gallery/config/routes.php2
-rw-r--r--modules/gallery/config/session.php2
-rw-r--r--modules/gallery/config/upload.php2
-rw-r--r--modules/gallery/config/user_agents.php2
-rw-r--r--modules/gallery/controllers/admin.php2
-rw-r--r--modules/gallery/controllers/admin_advanced_settings.php2
-rw-r--r--modules/gallery/controllers/admin_dashboard.php2
-rw-r--r--modules/gallery/controllers/admin_graphics.php2
-rw-r--r--modules/gallery/controllers/admin_languages.php2
-rw-r--r--modules/gallery/controllers/admin_maintenance.php2
-rw-r--r--modules/gallery/controllers/admin_modules.php2
-rw-r--r--modules/gallery/controllers/admin_sidebar.php2
-rw-r--r--modules/gallery/controllers/admin_theme_options.php2
-rw-r--r--modules/gallery/controllers/admin_themes.php2
-rw-r--r--modules/gallery/controllers/admin_upgrade_checker.php2
-rw-r--r--modules/gallery/controllers/albums.php8
-rw-r--r--modules/gallery/controllers/combined.php2
-rw-r--r--modules/gallery/controllers/file_proxy.php71
-rw-r--r--modules/gallery/controllers/items.php2
-rw-r--r--modules/gallery/controllers/l10n_client.php2
-rw-r--r--modules/gallery/controllers/login.php2
-rw-r--r--modules/gallery/controllers/logout.php2
-rw-r--r--modules/gallery/controllers/movies.php2
-rw-r--r--modules/gallery/controllers/packager.php11
-rw-r--r--modules/gallery/controllers/permissions.php2
-rw-r--r--modules/gallery/controllers/photos.php2
-rw-r--r--modules/gallery/controllers/quick.php2
-rw-r--r--modules/gallery/controllers/reauthenticate.php2
-rw-r--r--modules/gallery/controllers/upgrader.php8
-rw-r--r--modules/gallery/controllers/uploader.php8
-rw-r--r--modules/gallery/controllers/user_profile.php2
-rw-r--r--modules/gallery/controllers/welcome_message.php2
-rw-r--r--modules/gallery/helpers/MY_html.php2
-rw-r--r--modules/gallery/helpers/MY_num.php2
-rw-r--r--modules/gallery/helpers/MY_remote.php2
-rw-r--r--modules/gallery/helpers/MY_url.php2
-rw-r--r--modules/gallery/helpers/MY_valid.php2
-rw-r--r--modules/gallery/helpers/access.php2
-rw-r--r--modules/gallery/helpers/ajax.php2
-rw-r--r--modules/gallery/helpers/album.php2
-rw-r--r--modules/gallery/helpers/auth.php2
-rw-r--r--modules/gallery/helpers/batch.php2
-rw-r--r--modules/gallery/helpers/block_manager.php2
-rw-r--r--modules/gallery/helpers/data_rest.php74
-rw-r--r--modules/gallery/helpers/dir.php2
-rw-r--r--modules/gallery/helpers/encoding.php2
-rw-r--r--modules/gallery/helpers/gallery.php18
-rw-r--r--modules/gallery/helpers/gallery_block.php4
-rw-r--r--modules/gallery/helpers/gallery_error.php2
-rw-r--r--modules/gallery/helpers/gallery_event.php42
-rw-r--r--modules/gallery/helpers/gallery_graphics.php149
-rw-r--r--modules/gallery/helpers/gallery_installer.php68
-rw-r--r--modules/gallery/helpers/gallery_rss.php2
-rw-r--r--modules/gallery/helpers/gallery_task.php117
-rw-r--r--modules/gallery/helpers/gallery_theme.php8
-rw-r--r--modules/gallery/helpers/graphics.php197
-rw-r--r--modules/gallery/helpers/identity.php2
-rw-r--r--modules/gallery/helpers/item.php109
-rw-r--r--modules/gallery/helpers/item_rest.php4
-rw-r--r--modules/gallery/helpers/items_rest.php2
-rw-r--r--modules/gallery/helpers/json.php2
-rw-r--r--modules/gallery/helpers/l10n_client.php4
-rw-r--r--modules/gallery/helpers/l10n_scanner.php2
-rw-r--r--modules/gallery/helpers/legal_file.php242
-rw-r--r--modules/gallery/helpers/locales.php2
-rw-r--r--modules/gallery/helpers/log.php2
-rw-r--r--modules/gallery/helpers/message.php2
-rw-r--r--modules/gallery/helpers/model_cache.php2
-rw-r--r--modules/gallery/helpers/module.php5
-rw-r--r--modules/gallery/helpers/movie.php154
-rw-r--r--modules/gallery/helpers/photo.php72
-rw-r--r--modules/gallery/helpers/random.php2
-rw-r--r--modules/gallery/helpers/site_status.php2
-rw-r--r--modules/gallery/helpers/system.php38
-rw-r--r--modules/gallery/helpers/task.php2
-rw-r--r--modules/gallery/helpers/theme.php2
-rw-r--r--modules/gallery/helpers/tree_rest.php2
-rw-r--r--modules/gallery/helpers/upgrade_checker.php4
-rw-r--r--modules/gallery/helpers/user_profile.php2
-rw-r--r--modules/gallery/helpers/xml.php2
-rw-r--r--modules/gallery/hooks/init_gallery.php2
-rw-r--r--modules/gallery/images/missing_album_cover.jpgbin0 -> 4453 bytes
-rw-r--r--modules/gallery/images/missing_photo.jpgbin0 -> 2034 bytes
-rw-r--r--modules/gallery/images/missing_photo.pngbin1570 -> 0 bytes
-rw-r--r--modules/gallery/js/l10n_client.js6
-rw-r--r--modules/gallery/libraries/Admin_View.php2
-rw-r--r--modules/gallery/libraries/Block.php2
-rw-r--r--modules/gallery/libraries/Breadcrumb.php2
-rw-r--r--modules/gallery/libraries/Form_Script.php2
-rw-r--r--modules/gallery/libraries/Form_Uploadify.php4
-rw-r--r--modules/gallery/libraries/Form_Uploadify_buttons.php2
-rw-r--r--modules/gallery/libraries/Gallery_I18n.php2
-rw-r--r--modules/gallery/libraries/Gallery_View.php8
-rw-r--r--modules/gallery/libraries/IdentityProvider.php2
-rw-r--r--modules/gallery/libraries/InPlaceEdit.php2
-rw-r--r--modules/gallery/libraries/MY_Database.php15
-rw-r--r--modules/gallery/libraries/MY_Forge.php2
-rw-r--r--modules/gallery/libraries/MY_Input.php2
-rw-r--r--modules/gallery/libraries/MY_Kohana_Exception.php2
-rw-r--r--modules/gallery/libraries/MY_ORM.php2
-rw-r--r--modules/gallery/libraries/MY_View.php2
-rw-r--r--modules/gallery/libraries/Menu.php2
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php7
-rw-r--r--modules/gallery/libraries/SafeString.php2
-rw-r--r--modules/gallery/libraries/Sendmail.php2
-rw-r--r--modules/gallery/libraries/Task_Definition.php2
-rw-r--r--modules/gallery/libraries/Theme_View.php15
-rw-r--r--modules/gallery/libraries/drivers/Cache/Database.php6
-rw-r--r--modules/gallery/libraries/drivers/IdentityProvider.php2
-rw-r--r--modules/gallery/models/access_cache.php2
-rw-r--r--modules/gallery/models/access_intent.php2
-rw-r--r--modules/gallery/models/cache.php2
-rw-r--r--modules/gallery/models/failed_auth.php2
-rw-r--r--modules/gallery/models/graphics_rule.php2
-rw-r--r--modules/gallery/models/incoming_translation.php2
-rw-r--r--modules/gallery/models/item.php331
-rw-r--r--modules/gallery/models/log.php2
-rw-r--r--modules/gallery/models/message.php2
-rw-r--r--modules/gallery/models/module.php2
-rw-r--r--modules/gallery/models/outgoing_translation.php2
-rw-r--r--modules/gallery/models/permission.php2
-rw-r--r--modules/gallery/models/task.php2
-rw-r--r--modules/gallery/models/theme.php2
-rw-r--r--modules/gallery/models/var.php2
-rw-r--r--modules/gallery/module.info8
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Albums_Controller_Test.php2
-rw-r--r--modules/gallery/tests/Breadcrumb_Test.php2
-rw-r--r--modules/gallery/tests/Cache_Test.php2
-rw-r--r--modules/gallery/tests/Controller_Auth_Test.php7
-rw-r--r--modules/gallery/tests/Data_Rest_Helper_Test.php111
-rw-r--r--modules/gallery/tests/Database_Test.php8
-rw-r--r--modules/gallery/tests/Dir_Helper_Test.php2
-rw-r--r--modules/gallery/tests/DrawForm_Test.php2
-rw-r--r--modules/gallery/tests/File_Proxy_Controller_Test.php130
-rw-r--r--modules/gallery/tests/File_Structure_Test.php52
-rw-r--r--modules/gallery/tests/Gallery_Filters.php8
-rw-r--r--modules/gallery/tests/Gallery_Graphics_Helper_Test.php137
-rw-r--r--modules/gallery/tests/Gallery_I18n_Test.php2
-rw-r--r--modules/gallery/tests/Gallery_Installer_Test.php2
-rw-r--r--modules/gallery/tests/Graphics_Helper_Test.php158
-rw-r--r--modules/gallery/tests/Html_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Input_Library_Test.php2
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php20
-rw-r--r--modules/gallery/tests/Item_Model_Test.php385
-rw-r--r--modules/gallery/tests/Item_Rest_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Items_Rest_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Kohana_Exception_Test.php2
-rw-r--r--modules/gallery/tests/Legal_File_Helper_Test.php153
-rw-r--r--modules/gallery/tests/Locales_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Menu_Test.php2
-rw-r--r--modules/gallery/tests/Movie_Helper_Test.php105
-rw-r--r--modules/gallery/tests/Num_Helper_Test.php2
-rw-r--r--modules/gallery/tests/ORM_MPTT_Test.php2
-rw-r--r--modules/gallery/tests/Photo_Helper_Test.php70
-rw-r--r--modules/gallery/tests/Photos_Controller_Test.php2
-rw-r--r--modules/gallery/tests/SafeString_Test.php2
-rw-r--r--modules/gallery/tests/Sendmail_Test.php2
-rw-r--r--modules/gallery/tests/System_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Url_Security_Test.php2
-rw-r--r--modules/gallery/tests/Valid_Test.php2
-rw-r--r--modules/gallery/tests/Var_Test.php2
-rw-r--r--modules/gallery/tests/Xss_Security_Test.php2
-rw-r--r--modules/gallery/tests/controller_auth_data.txt2
-rw-r--r--modules/gallery/tests/xss_data.txt118
-rw-r--r--modules/gallery/views/admin_graphics.html.php2
-rw-r--r--modules/gallery/views/admin_languages.html.php2
-rw-r--r--modules/gallery/views/admin_modules.html.php2
-rw-r--r--modules/gallery/views/admin_themes.html.php6
-rw-r--r--modules/gallery/views/error_admin.html.php2
-rw-r--r--modules/gallery/views/form_uploadify.html.php4
-rw-r--r--modules/gallery/views/movieplayer.html.php2
-rw-r--r--modules/gallery/views/upgrader.html.php4
-rw-r--r--modules/gallery/views/welcome_message.html.php4
-rw-r--r--modules/gallery_unit_test/controllers/gallery_unit_test.php4
-rw-r--r--modules/gallery_unit_test/helpers/MY_request.php2
-rw-r--r--modules/gallery_unit_test/helpers/test.php45
-rw-r--r--modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php2
-rw-r--r--modules/image_block/controllers/image_block.php2
-rw-r--r--modules/image_block/helpers/image_block_block.php2
-rw-r--r--modules/image_block/helpers/image_block_installer.php3
-rw-r--r--modules/image_block/module.info6
-rw-r--r--modules/info/helpers/info_block.php4
-rw-r--r--modules/info/helpers/info_installer.php3
-rw-r--r--modules/info/helpers/info_theme.php2
-rw-r--r--modules/info/module.info6
-rw-r--r--modules/kohana23_compat/config/pagination.php2
-rw-r--r--modules/kohana23_compat/libraries/MY_Database_Builder.php2
-rw-r--r--modules/kohana23_compat/libraries/Pagination.php2
-rw-r--r--modules/notification/controllers/notification.php2
-rw-r--r--modules/notification/helpers/notification.php2
-rw-r--r--modules/notification/helpers/notification_event.php2
-rw-r--r--modules/notification/helpers/notification_installer.php4
-rw-r--r--modules/notification/models/pending_notification.php2
-rw-r--r--modules/notification/models/subscription.php2
-rw-r--r--modules/notification/module.info6
-rw-r--r--modules/organize/controllers/organize.php34
-rw-r--r--modules/organize/helpers/organize_event.php2
-rw-r--r--modules/organize/helpers/organize_installer.php2
-rw-r--r--modules/organize/module.info6
-rw-r--r--modules/organize/views/organize_frame.html.php74
-rw-r--r--modules/recaptcha/controllers/admin_recaptcha.php2
-rw-r--r--modules/recaptcha/helpers/recaptcha.php2
-rw-r--r--modules/recaptcha/helpers/recaptcha_event.php2
-rw-r--r--modules/recaptcha/helpers/recaptcha_installer.php2
-rw-r--r--modules/recaptcha/helpers/recaptcha_theme.php2
-rw-r--r--modules/recaptcha/libraries/Form_Recaptcha.php2
-rw-r--r--modules/recaptcha/module.info6
-rw-r--r--modules/rest/controllers/rest.php2
-rw-r--r--modules/rest/helpers/registry_rest.php2
-rw-r--r--modules/rest/helpers/rest.php4
-rw-r--r--modules/rest/helpers/rest_event.php2
-rw-r--r--modules/rest/helpers/rest_installer.php3
-rw-r--r--modules/rest/libraries/Rest_Exception.php2
-rw-r--r--modules/rest/models/user_access_key.php2
-rw-r--r--modules/rest/module.info6
-rw-r--r--modules/rest/tests/Rest_Controller_Test.php2
-rw-r--r--modules/rss/controllers/rss.php2
-rw-r--r--modules/rss/helpers/rss.php2
-rw-r--r--modules/rss/helpers/rss_block.php2
-rw-r--r--modules/rss/module.info6
-rw-r--r--modules/search/controllers/search.php27
-rw-r--r--modules/search/helpers/search.php12
-rw-r--r--modules/search/helpers/search_event.php2
-rw-r--r--modules/search/helpers/search_installer.php3
-rw-r--r--modules/search/helpers/search_task.php2
-rw-r--r--modules/search/helpers/search_theme.php2
-rw-r--r--modules/search/models/search_record.php2
-rw-r--r--modules/search/module.info6
-rw-r--r--modules/server_add/controllers/admin_server_add.php2
-rw-r--r--modules/server_add/controllers/server_add.php10
-rw-r--r--modules/server_add/helpers/server_add.php2
-rw-r--r--modules/server_add/helpers/server_add_event.php2
-rw-r--r--modules/server_add/helpers/server_add_installer.php3
-rw-r--r--modules/server_add/helpers/server_add_theme.php2
-rw-r--r--modules/server_add/models/server_add_entry.php2
-rw-r--r--modules/server_add/module.info6
-rw-r--r--modules/slideshow/helpers/slideshow_event.php2
-rw-r--r--modules/slideshow/helpers/slideshow_installer.php3
-rw-r--r--modules/slideshow/helpers/slideshow_theme.php2
-rw-r--r--modules/slideshow/module.info6
-rw-r--r--modules/tag/controllers/admin_tags.php2
-rw-r--r--modules/tag/controllers/tag.php3
-rw-r--r--modules/tag/controllers/tag_name.php2
-rw-r--r--modules/tag/controllers/tags.php4
-rw-r--r--modules/tag/helpers/item_tags_rest.php2
-rw-r--r--modules/tag/helpers/tag.php2
-rw-r--r--modules/tag/helpers/tag_block.php2
-rw-r--r--modules/tag/helpers/tag_event.php2
-rw-r--r--modules/tag/helpers/tag_installer.php3
-rw-r--r--modules/tag/helpers/tag_item_rest.php2
-rw-r--r--modules/tag/helpers/tag_items_rest.php2
-rw-r--r--modules/tag/helpers/tag_rest.php2
-rw-r--r--modules/tag/helpers/tag_rss.php2
-rw-r--r--modules/tag/helpers/tag_task.php2
-rw-r--r--modules/tag/helpers/tag_theme.php2
-rw-r--r--modules/tag/helpers/tags_rest.php2
-rw-r--r--modules/tag/models/tag.php2
-rw-r--r--modules/tag/module.info6
-rw-r--r--modules/tag/tests/Tag_Item_Rest_Helper_Test.php2
-rw-r--r--modules/tag/tests/Tag_Rest_Helper_Test.php2
-rw-r--r--modules/tag/tests/Tag_Test.php2
-rw-r--r--modules/tag/tests/Tags_Rest_Helper_Test.php2
-rw-r--r--modules/user/config/identity.php2
-rw-r--r--modules/user/controllers/admin_users.php2
-rw-r--r--modules/user/controllers/password.php2
-rw-r--r--modules/user/controllers/users.php2
-rw-r--r--modules/user/helpers/group.php2
-rw-r--r--modules/user/helpers/user.php2
-rw-r--r--modules/user/helpers/user_event.php2
-rw-r--r--modules/user/helpers/user_installer.php3
-rw-r--r--modules/user/helpers/user_theme.php2
-rw-r--r--modules/user/libraries/drivers/IdentityProvider/Gallery.php2
-rw-r--r--modules/user/models/group.php2
-rw-r--r--modules/user/models/user.php2
-rw-r--r--modules/user/module.info6
-rw-r--r--modules/user/tests/No_Direct_ORM_Access_Test.php2
-rw-r--r--modules/user/tests/User_Groups_Test.php2
-rw-r--r--modules/user/tests/User_Installer_Test.php2
-rw-r--r--modules/watermark/controllers/admin_watermarks.php45
-rw-r--r--modules/watermark/helpers/watermark.php2
-rw-r--r--modules/watermark/helpers/watermark_event.php2
-rw-r--r--modules/watermark/helpers/watermark_installer.php3
-rw-r--r--modules/watermark/module.info6
-rw-r--r--modules/watermark/tests/Admin_Watermarks_Controller_Test.php124
341 files changed, 3252 insertions, 1107 deletions
diff --git a/modules/akismet/controllers/admin_akismet.php b/modules/akismet/controllers/admin_akismet.php
index eb79b0ee..c9079664 100644
--- a/modules/akismet/controllers/admin_akismet.php
+++ b/modules/akismet/controllers/admin_akismet.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/akismet/helpers/akismet.php b/modules/akismet/helpers/akismet.php
index 10ecaaff..a7927d67 100644
--- a/modules/akismet/helpers/akismet.php
+++ b/modules/akismet/helpers/akismet.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/akismet/helpers/akismet_event.php b/modules/akismet/helpers/akismet_event.php
index f8b5ffd6..038e4878 100644
--- a/modules/akismet/helpers/akismet_event.php
+++ b/modules/akismet/helpers/akismet_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/akismet/helpers/akismet_installer.php b/modules/akismet/helpers/akismet_installer.php
index 7e8c1bd2..bd16a15c 100644
--- a/modules/akismet/helpers/akismet_installer.php
+++ b/modules/akismet/helpers/akismet_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/akismet/module.info b/modules/akismet/module.info
index 63473468..263b7b82 100644
--- a/modules/akismet/module.info
+++ b/modules/akismet/module.info
@@ -2,6 +2,6 @@ name = "Akismet"
description = "Filter comments through the Akismet web service to detect and eliminate spam (http://akismet.com). You'll need a WordPress.com API key to use it."
version = 1
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:akismet"
-discuss_url = "http://gallery.menalto.com/forum_module_akismet"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:akismet"
+discuss_url = "http://galleryproject.org/forum_module_akismet"
diff --git a/modules/akismet/tests/Akismet_Helper_Test.php b/modules/akismet/tests/Akismet_Helper_Test.php
index a98d2574..3be91abd 100644
--- a/modules/akismet/tests/Akismet_Helper_Test.php
+++ b/modules/akismet/tests/Akismet_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php
index 00a7a608..30183402 100644
--- a/modules/comment/controllers/admin_comments.php
+++ b/modules/comment/controllers/admin_comments.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/controllers/admin_manage_comments.php b/modules/comment/controllers/admin_manage_comments.php
index bb5745a4..ef31c955 100644
--- a/modules/comment/controllers/admin_manage_comments.php
+++ b/modules/comment/controllers/admin_manage_comments.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php
index fa9ba8c1..64aa0b42 100644
--- a/modules/comment/controllers/comments.php
+++ b/modules/comment/controllers/comments.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php
index 12fbba55..0d922ebd 100644
--- a/modules/comment/helpers/comment.php
+++ b/modules/comment/helpers/comment.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/comment_block.php b/modules/comment/helpers/comment_block.php
index 4eac79e6..b6025957 100644
--- a/modules/comment/helpers/comment_block.php
+++ b/modules/comment/helpers/comment_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php
index 0c22fa67..f73e5451 100644
--- a/modules/comment/helpers/comment_event.php
+++ b/modules/comment/helpers/comment_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php
index f7bebe69..136f96ef 100644
--- a/modules/comment/helpers/comment_installer.php
+++ b/modules/comment/helpers/comment_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -49,7 +49,6 @@ class comment_installer {
module::set_var("comment", "spam_caught", 0);
module::set_var("comment", "access_permissions", "everybody");
module::set_var("comment", "rss_visible", "all");
- module::set_version("comment", 7);
}
static function upgrade($version) {
diff --git a/modules/comment/helpers/comment_rest.php b/modules/comment/helpers/comment_rest.php
index 978d9344..1971edcf 100644
--- a/modules/comment/helpers/comment_rest.php
+++ b/modules/comment/helpers/comment_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php
index 1a7ed53c..924710f5 100644
--- a/modules/comment/helpers/comment_rss.php
+++ b/modules/comment/helpers/comment_rss.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/comment_theme.php b/modules/comment/helpers/comment_theme.php
index a1524579..1c2d7c5d 100644
--- a/modules/comment/helpers/comment_theme.php
+++ b/modules/comment/helpers/comment_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/comments_rest.php b/modules/comment/helpers/comments_rest.php
index bd16e365..6fc86ad8 100644
--- a/modules/comment/helpers/comments_rest.php
+++ b/modules/comment/helpers/comments_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/helpers/item_comments_rest.php b/modules/comment/helpers/item_comments_rest.php
index b203d66c..f6f89301 100644
--- a/modules/comment/helpers/item_comments_rest.php
+++ b/modules/comment/helpers/item_comments_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index c4a9afb3..62ab8bc9 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/module.info b/modules/comment/module.info
index 97e8a73b..b69379fa 100644
--- a/modules/comment/module.info
+++ b/modules/comment/module.info
@@ -2,6 +2,6 @@ name = "Comments"
description = "Allows users and guests to leave comments on photos and albums."
version = 7
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:comment"
-discuss_url = "http://gallery.menalto.com/forum_module_comment"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:comment"
+discuss_url = "http://galleryproject.org/forum_module_comment"
diff --git a/modules/comment/tests/Comment_Event_Test.php b/modules/comment/tests/Comment_Event_Test.php
index 8b8645b3..c66c5b9b 100644
--- a/modules/comment/tests/Comment_Event_Test.php
+++ b/modules/comment/tests/Comment_Event_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/tests/Comment_Helper_Test.php b/modules/comment/tests/Comment_Helper_Test.php
index f34e8878..dc1ff69a 100644
--- a/modules/comment/tests/Comment_Helper_Test.php
+++ b/modules/comment/tests/Comment_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php
index 61bed6cd..8db7df6a 100644
--- a/modules/comment/tests/Comment_Model_Test.php
+++ b/modules/comment/tests/Comment_Model_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/digibug/config/digibug.php b/modules/digibug/config/digibug.php
index fd98fadc..9412ca96 100644
--- a/modules/digibug/config/digibug.php
+++ b/modules/digibug/config/digibug.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/digibug/controllers/admin_digibug.php b/modules/digibug/controllers/admin_digibug.php
index eb6c75f0..50f6f832 100644
--- a/modules/digibug/controllers/admin_digibug.php
+++ b/modules/digibug/controllers/admin_digibug.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
index 64183639..19199188 100644
--- a/modules/digibug/controllers/digibug.php
+++ b/modules/digibug/controllers/digibug.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/digibug/helpers/digibug_event.php b/modules/digibug/helpers/digibug_event.php
index 626d3fa0..eaebc87b 100644
--- a/modules/digibug/helpers/digibug_event.php
+++ b/modules/digibug/helpers/digibug_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/digibug/helpers/digibug_installer.php b/modules/digibug/helpers/digibug_installer.php
index 6b35599f..be88b5ec 100644
--- a/modules/digibug/helpers/digibug_installer.php
+++ b/modules/digibug/helpers/digibug_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -30,7 +30,6 @@ class digibug_installer {
module::set_var("digibug", "company_id", "3153");
module::set_var("digibug", "event_id", "8491");
- module::set_version("digibug", 2);
}
static function upgrade($version) {
diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php
index 93fde761..e3795c3b 100644
--- a/modules/digibug/helpers/digibug_theme.php
+++ b/modules/digibug/helpers/digibug_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/digibug/models/digibug_proxy.php b/modules/digibug/models/digibug_proxy.php
index 96187645..18c77d49 100644
--- a/modules/digibug/models/digibug_proxy.php
+++ b/modules/digibug/models/digibug_proxy.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/digibug/module.info b/modules/digibug/module.info
index 781d5f01..5e5ca10f 100644
--- a/modules/digibug/module.info
+++ b/modules/digibug/module.info
@@ -2,6 +2,6 @@ name = "Digibug"
description = "Digibug Photo Printing Module"
version = 2
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:digibug"
-discuss_url = "http://gallery.menalto.com/forum_module_digibug"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:digibug"
+discuss_url = "http://galleryproject.org/forum_module_digibug"
diff --git a/modules/digibug/tests/Digibug_Controller_Test.php b/modules/digibug/tests/Digibug_Controller_Test.php
index 33831eb5..3b3ceba2 100644
--- a/modules/digibug/tests/Digibug_Controller_Test.php
+++ b/modules/digibug/tests/Digibug_Controller_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/controllers/exif.php b/modules/exif/controllers/exif.php
index 7da58b73..aea80122 100644
--- a/modules/exif/controllers/exif.php
+++ b/modules/exif/controllers/exif.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php
index 5ba91254..b17f4607 100644
--- a/modules/exif/helpers/exif.php
+++ b/modules/exif/helpers/exif.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/helpers/exif_event.php b/modules/exif/helpers/exif_event.php
index bee27eef..cd5068f7 100644
--- a/modules/exif/helpers/exif_event.php
+++ b/modules/exif/helpers/exif_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/helpers/exif_installer.php b/modules/exif/helpers/exif_installer.php
index 6863a8a8..75d0f835 100644
--- a/modules/exif/helpers/exif_installer.php
+++ b/modules/exif/helpers/exif_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -29,7 +29,6 @@ class exif_installer {
PRIMARY KEY (`id`),
KEY(`item_id`))
DEFAULT CHARSET=utf8;");
- module::set_version("exif", 1);
}
static function activate() {
diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php
index 74645c29..f8a108ae 100644
--- a/modules/exif/helpers/exif_task.php
+++ b/modules/exif/helpers/exif_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/helpers/exif_theme.php b/modules/exif/helpers/exif_theme.php
index 106ad56a..df7c6f4e 100644
--- a/modules/exif/helpers/exif_theme.php
+++ b/modules/exif/helpers/exif_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/models/exif_key.php b/modules/exif/models/exif_key.php
index 7e6f1ccc..5c456697 100644
--- a/modules/exif/models/exif_key.php
+++ b/modules/exif/models/exif_key.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/models/exif_record.php b/modules/exif/models/exif_record.php
index 4b8cf19d..1628ae40 100644
--- a/modules/exif/models/exif_record.php
+++ b/modules/exif/models/exif_record.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/exif/module.info b/modules/exif/module.info
index e266e20e..9bbda957 100644
--- a/modules/exif/module.info
+++ b/modules/exif/module.info
@@ -2,6 +2,6 @@ name = "Exif Data"
description = "Extract Exif data and display it on photo pages."
version = 1
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:exif"
-discuss_url = "http://gallery.menalto.com/forum_module_exif"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:exif"
+discuss_url = "http://galleryproject.org/forum_module_exif"
diff --git a/modules/exif/tests/Exif_Test.php b/modules/exif/tests/Exif_Test.php
index 5e99d3d1..2a0e6d56 100644
--- a/modules/exif/tests/Exif_Test.php
+++ b/modules/exif/tests/Exif_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index 2e435321..c4f03907 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 98eb57f1..c24d52e9 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -33,10 +33,30 @@ class G2_Controller extends Controller {
$input = Input::instance();
$path = $input->get("path");
$id = $input->get("g2_itemId");
+ $view = $input->get("g2_view");
- /* Tags are handled specially, since there's no mapping for them */
- if (($path && 0 === strpos($path, "tag/"))) {
- url::redirect("tag_name/" . substr($path, 4));
+ // Tags did not have mappings created, so we need to catch them first. However, if a g2_itemId was
+ // passed, we'll want to show lookup the mapping anyway
+ if (($path && 0 === strpos($path, "tag/")) || $view == "tags.VirtualAlbum") {
+ if (0 === strpos($path, "tag/")) {
+ $tag_name = substr($path, 4);
+ }
+ if ($view == "tags.VirtualAlbum") {
+ $tag_name = $input->get("g2_tagName");
+ }
+
+ if (!$id) {
+ url::redirect("tag_name/$tag_name", 301);
+ }
+
+ $tag = ORM::factory("tag")->where("name", "=", $tag_name)->find();
+ if ($tag->loaded()) {
+ item::set_display_context_callback("Tag_Controller::get_display_context", $tag->id);
+ // We want to show the item as part of the tag virtual album. Most of this code is below; we'll
+ // change $path and $view to let it fall through
+ $view = "";
+ $path = "";
+ }
}
if (($path && $path != 'index.php' && $path != 'main.php') || $id) {
@@ -45,11 +65,10 @@ class G2_Controller extends Controller {
// Gallery 2 don't specify g2_view if it's the default (core.ShowItem). And in some cases
// (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled.
$where = array(array("g2_id", "=", $id));
- $view = $input->get("g2_view");
if ($view == "core.DownloadItem") {
$where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full"));
} else if ($view) {
- $where[] = array("g2_url", "like", "%g2_view=$view%");
+ $where[] = array("g2_url", "LIKE", "%" . Database::escape_for_like("g2_view=$view") . "%");
} // else: Assuming that the first search hit is sufficiently good.
} else if ($path) {
$where = array(array("g2_url", "IN", array($path, str_replace(" ", "+", $path))));
@@ -80,18 +99,18 @@ class G2_Controller extends Controller {
// Redirect the user to the new url
switch ($resource_type) {
case "thumbnail":
- url::redirect($item->thumb_url(true));
+ url::redirect($item->thumb_url(true), 301);
case "resize":
- url::redirect($item->resize_url(true));
+ url::redirect($item->resize_url(true), 301);
case "file":
case "full":
- url::redirect($item->file_url(true));
+ url::redirect($item->file_url(true), 301);
case "item":
case "album":
- url::redirect($item->abs_url());
+ url::redirect($item->abs_url(), 301);
case "group":
case "user":
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 10af7d08..70aac747 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/g2_import/helpers/g2_import_event.php b/modules/g2_import/helpers/g2_import_event.php
index 01f18739..b985281d 100644
--- a/modules/g2_import/helpers/g2_import_event.php
+++ b/modules/g2_import/helpers/g2_import_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/g2_import/helpers/g2_import_installer.php b/modules/g2_import/helpers/g2_import_installer.php
index c16a9cc4..c7569819 100644
--- a/modules/g2_import/helpers/g2_import_installer.php
+++ b/modules/g2_import/helpers/g2_import_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -31,7 +31,6 @@ class g2_import_installer {
KEY `g2_id` (`g2_id`))
DEFAULT CHARSET=utf8;");
- module::set_version("g2_import", 2);
mkdir(VARPATH . "modules/g2_import");
}
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index 01d608af..07eacc40 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/g2_import/libraries/G2_Import_Exception.php b/modules/g2_import/libraries/G2_Import_Exception.php
index a241a7bf..7732cfd4 100644
--- a/modules/g2_import/libraries/G2_Import_Exception.php
+++ b/modules/g2_import/libraries/G2_Import_Exception.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/g2_import/models/g2_map.php b/modules/g2_import/models/g2_map.php
index 0cb27b1f..5fb566ce 100644
--- a/modules/g2_import/models/g2_map.php
+++ b/modules/g2_import/models/g2_map.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info
index 6b03d097..32af27d0 100644
--- a/modules/g2_import/module.info
+++ b/modules/g2_import/module.info
@@ -2,6 +2,6 @@ name = "Gallery 2 Import"
description = "Import your Gallery 2 content into Gallery 3"
version = 2
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:g2_import"
-discuss_url = "http://gallery.menalto.com/forum_module_g2_import"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:g2_import"
+discuss_url = "http://galleryproject.org/forum_module_g2_import"
diff --git a/modules/gallery/config/cache.php b/modules/gallery/config/cache.php
index 707d0355..746e95c6 100644
--- a/modules/gallery/config/cache.php
+++ b/modules/gallery/config/cache.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/cookie.php b/modules/gallery/config/cookie.php
index 6b169a6e..b1647016 100644
--- a/modules/gallery/config/cookie.php
+++ b/modules/gallery/config/cookie.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/database.php b/modules/gallery/config/database.php
index 2ea08664..41487577 100644
--- a/modules/gallery/config/database.php
+++ b/modules/gallery/config/database.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php
index 9529b034..cf37de9d 100644
--- a/modules/gallery/config/locale.php
+++ b/modules/gallery/config/locale.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/log_file.php b/modules/gallery/config/log_file.php
index 7156d384..a79831ee 100644
--- a/modules/gallery/config/log_file.php
+++ b/modules/gallery/config/log_file.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/routes.php b/modules/gallery/config/routes.php
index c5208f38..d1ae8bf8 100644
--- a/modules/gallery/config/routes.php
+++ b/modules/gallery/config/routes.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/session.php b/modules/gallery/config/session.php
index f56c127d..7ecee58e 100644
--- a/modules/gallery/config/session.php
+++ b/modules/gallery/config/session.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/upload.php b/modules/gallery/config/upload.php
index ce82cb1c..a5e87971 100644
--- a/modules/gallery/config/upload.php
+++ b/modules/gallery/config/upload.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/config/user_agents.php b/modules/gallery/config/user_agents.php
index 2152b95c..dcdbb73e 100644
--- a/modules/gallery/config/user_agents.php
+++ b/modules/gallery/config/user_agents.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php
index 3018268f..c9d944cc 100644
--- a/modules/gallery/controllers/admin.php
+++ b/modules/gallery/controllers/admin.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_advanced_settings.php b/modules/gallery/controllers/admin_advanced_settings.php
index 752a2e81..267ff14a 100644
--- a/modules/gallery/controllers/admin_advanced_settings.php
+++ b/modules/gallery/controllers/admin_advanced_settings.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_dashboard.php b/modules/gallery/controllers/admin_dashboard.php
index acf06789..6bd36b07 100644
--- a/modules/gallery/controllers/admin_dashboard.php
+++ b/modules/gallery/controllers/admin_dashboard.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_graphics.php b/modules/gallery/controllers/admin_graphics.php
index bf1563f5..a24486fb 100644
--- a/modules/gallery/controllers/admin_graphics.php
+++ b/modules/gallery/controllers/admin_graphics.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php
index f7f7e204..50ddc676 100644
--- a/modules/gallery/controllers/admin_languages.php
+++ b/modules/gallery/controllers/admin_languages.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index f08282ac..23df33ee 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_modules.php b/modules/gallery/controllers/admin_modules.php
index 5810be06..d13ec1c6 100644
--- a/modules/gallery/controllers/admin_modules.php
+++ b/modules/gallery/controllers/admin_modules.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_sidebar.php b/modules/gallery/controllers/admin_sidebar.php
index ef22abfc..f150f853 100644
--- a/modules/gallery/controllers/admin_sidebar.php
+++ b/modules/gallery/controllers/admin_sidebar.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php
index bb636fae..aead8bae 100644
--- a/modules/gallery/controllers/admin_theme_options.php
+++ b/modules/gallery/controllers/admin_theme_options.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php
index aeed5af7..4ab994f8 100644
--- a/modules/gallery/controllers/admin_themes.php
+++ b/modules/gallery/controllers/admin_themes.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/admin_upgrade_checker.php b/modules/gallery/controllers/admin_upgrade_checker.php
index 16877ed8..3f0bdac1 100644
--- a/modules/gallery/controllers/admin_upgrade_checker.php
+++ b/modules/gallery/controllers/admin_upgrade_checker.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 9b968871..0fb033a8 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -93,10 +93,16 @@ class Albums_Controller extends Items_Controller {
"previous_item" => $previous_item,
"next_item" => $next_item,
"sibling_count" => $item->parent()->viewable()->children_count($where),
+ "siblings_callback" => array("Albums_Controller::get_siblings", array($item)),
"parents" => $item->parents()->as_array(),
"breadcrumbs" => Breadcrumb::array_from_item_parents($item));
}
+ static function get_siblings($item, $limit=null, $offset=null) {
+ // @todo consider creating Item_Model::siblings() if we use this more broadly.
+ return $item->parent()->viewable()->children($limit, $offset);
+ }
+
public function create($parent_id) {
access::verify_csrf();
$album = ORM::factory("item", $parent_id);
diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php
index 80ae1e2d..3cf7f871 100644
--- a/modules/gallery/controllers/combined.php
+++ b/modules/gallery/controllers/combined.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index b9ff7df1..7e5d0038 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -49,7 +49,9 @@ class File_Proxy_Controller extends Controller {
// Make sure that the request is for a file inside var
$offset = strpos(rawurldecode($request_uri), $var_uri);
if ($offset !== 0) {
- throw new Kohana_404_Exception();
+ $e = new Kohana_404_Exception();
+ $e->test_fail_code = 1;
+ throw $e;
}
// file_uri: albums/foo/bar.jpg
@@ -59,7 +61,9 @@ class File_Proxy_Controller extends Controller {
// path: foo/bar.jpg
list ($type, $path) = explode("/", $file_uri, 2);
if ($type != "resizes" && $type != "albums" && $type != "thumbs") {
- throw new Kohana_404_Exception();
+ $e = new Kohana_404_Exception();
+ $e->test_fail_code = 2;
+ throw $e;
}
// If the last element is .album.jpg, pop that off since it's not a real item
@@ -82,24 +86,35 @@ class File_Proxy_Controller extends Controller {
}
if (!$item->loaded()) {
- throw new Kohana_404_Exception();
+ $e = new Kohana_404_Exception();
+ $e->test_fail_code = 3;
+ throw $e;
}
// Make sure we have access to the item
if (!access::can("view", $item)) {
- throw new Kohana_404_Exception();
+ $e = new Kohana_404_Exception();
+ $e->test_fail_code = 4;
+ throw $e;
}
// Make sure we have view_full access to the original
if ($type == "albums" && !access::can("view_full", $item)) {
- throw new Kohana_404_Exception();
+ $e = new Kohana_404_Exception();
+ $e->test_fail_code = 5;
+ throw $e;
}
// Don't try to load a directory
if ($type == "albums" && $item->is_album()) {
- throw new Kohana_404_Exception();
+ $e = new Kohana_404_Exception();
+ $e->test_fail_code = 6;
+ throw $e;
}
+ // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to
+ // see if you should make the same change there as well.
+
if ($type == "albums") {
$file = $item->file_path();
} else if ($type == "resizes") {
@@ -109,7 +124,16 @@ class File_Proxy_Controller extends Controller {
}
if (!file_exists($file)) {
- throw new Kohana_404_Exception();
+ $e = new Kohana_404_Exception();
+ $e->test_fail_code = 7;
+ throw $e;
+ }
+
+ if (gallery::show_profiler()) {
+ Profiler::enable();
+ $profiler = new Profiler();
+ $profiler->render();
+ exit;
}
header("Content-Length: " . filesize($file));
@@ -123,26 +147,29 @@ class File_Proxy_Controller extends Controller {
expires::set(2592000, $item->updated); // 30 days
- // Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
- if ($item->is_movie() && $type != "albums") {
+ // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG.
+ if (($item->is_movie() || $item->is_album()) && $type == "thumbs") {
header("Content-Type: image/jpeg");
} else {
header("Content-Type: $item->mime_type");
}
- // Don't use Kohana::close_buffers(false) here because that only closes all the buffers
- // that Kohana started. We want to close *all* buffers at this point because otherwise we're
- // going to buffer up whatever file we're proxying (and it may be very large). This may
- // affect embedding or systems with PHP's output_buffering enabled.
- while (ob_get_level()) {
- Kohana_Log::add("error","".print_r(ob_get_level(),1));
- if (!@ob_end_clean()) {
- // ob_end_clean() can return false if the buffer can't be removed for some reason
- // (zlib output compression buffers sometimes cause problems).
- break;
+ if (TEST_MODE) {
+ return $file;
+ } else {
+ // Don't use Kohana::close_buffers(false) here because that only closes all the buffers
+ // that Kohana started. We want to close *all* buffers at this point because otherwise we're
+ // going to buffer up whatever file we're proxying (and it may be very large). This may
+ // affect embedding or systems with PHP's output_buffering enabled.
+ while (ob_get_level()) {
+ Kohana_Log::add("error","".print_r(ob_get_level(),1));
+ if (!@ob_end_clean()) {
+ // ob_end_clean() can return false if the buffer can't be removed for some reason
+ // (zlib output compression buffers sometimes cause problems).
+ break;
+ }
}
+ readfile($file);
}
-
- readfile($file);
}
}
diff --git a/modules/gallery/controllers/items.php b/modules/gallery/controllers/items.php
index 318fb431..845df763 100644
--- a/modules/gallery/controllers/items.php
+++ b/modules/gallery/controllers/items.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php
index 2e1f18d3..993dfb35 100644
--- a/modules/gallery/controllers/l10n_client.php
+++ b/modules/gallery/controllers/l10n_client.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php
index 39d2e0f8..9da575b0 100644
--- a/modules/gallery/controllers/login.php
+++ b/modules/gallery/controllers/login.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/logout.php b/modules/gallery/controllers/logout.php
index 34ac4ba7..9a24d1b1 100644
--- a/modules/gallery/controllers/logout.php
+++ b/modules/gallery/controllers/logout.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 26fa537c..ca332f67 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index 2d3249ed..d7e3cf41 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -88,14 +88,17 @@ class Packager_Controller extends Controller {
$dbconfig = Kohana::config('database.default');
$conn = $dbconfig["connection"];
- $pass = $conn["pass"] ? "-p{$conn['pass']}" : "";
$sql_file = DOCROOT . "installer/install.sql";
if (!is_writable($sql_file)) {
print "$sql_file is not writeable";
return;
}
- $command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " .
- "-u{$conn['user']} $pass {$conn['database']} > $sql_file";
+ $command = sprintf(
+ "mysqldump --compact --skip-extended-insert --add-drop-table %s %s %s %s > $sql_file",
+ escapeshellarg("-h{$conn['host']}"),
+ escapeshellarg("-u{$conn['user']}"),
+ $conn['pass'] ? escapeshellarg("-p{$conn['pass']}") : "",
+ escapeshellarg($conn['database']));
exec($command, $output, $status);
if ($status) {
print "<pre>";
diff --git a/modules/gallery/controllers/permissions.php b/modules/gallery/controllers/permissions.php
index 0af247fa..2513f866 100644
--- a/modules/gallery/controllers/permissions.php
+++ b/modules/gallery/controllers/permissions.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index c052f827..96a22c57 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php
index 7a3216c8..2ddf2a4b 100644
--- a/modules/gallery/controllers/quick.php
+++ b/modules/gallery/controllers/quick.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/reauthenticate.php b/modules/gallery/controllers/reauthenticate.php
index 3ea0a41a..c79b76e4 100644
--- a/modules/gallery/controllers/reauthenticate.php
+++ b/modules/gallery/controllers/reauthenticate.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index da23a799..d3c6e2ec 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -107,7 +107,11 @@ class Upgrader_Controller extends Controller {
print "Upgrade complete\n";
}
} else {
- url::redirect("upgrader?failed=" . join(",", $failed));
+ if ($failed) {
+ url::redirect("upgrader?failed=" . join(",", $failed));
+ } else {
+ url::redirect("upgrader");
+ }
}
}
}
diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php
index ecb0ca89..78437071 100644
--- a/modules/gallery/controllers/uploader.php
+++ b/modules/gallery/controllers/uploader.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -63,13 +63,9 @@ class Uploader_Controller extends Controller {
$item->parent_id = $album->id;
$item->set_data_file($temp_filename);
- // Remove double extensions from the filename - they'll be disallowed in the model but if
- // we don't do it here then it'll result in a failed upload.
- $item->name = legal_file::smash_extensions($item->name);
-
$path_info = @pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) &&
- in_array(strtolower($path_info["extension"]), legal_file::get_movie_extensions())) {
+ legal_file::get_movie_extensions($path_info["extension"])) {
$item->type = "movie";
$item->save();
log::success("content", t("Added a movie"),
diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php
index a4d7b289..cf589da1 100644
--- a/modules/gallery/controllers/user_profile.php
+++ b/modules/gallery/controllers/user_profile.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/controllers/welcome_message.php b/modules/gallery/controllers/welcome_message.php
index de338b64..bde5e944 100644
--- a/modules/gallery/controllers/welcome_message.php
+++ b/modules/gallery/controllers/welcome_message.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/MY_html.php b/modules/gallery/helpers/MY_html.php
index edb16ec9..767fe3f7 100644
--- a/modules/gallery/helpers/MY_html.php
+++ b/modules/gallery/helpers/MY_html.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/MY_num.php b/modules/gallery/helpers/MY_num.php
index 88810bda..a550a1a0 100644
--- a/modules/gallery/helpers/MY_num.php
+++ b/modules/gallery/helpers/MY_num.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/MY_remote.php b/modules/gallery/helpers/MY_remote.php
index 5bed2437..59804b95 100644
--- a/modules/gallery/helpers/MY_remote.php
+++ b/modules/gallery/helpers/MY_remote.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php
index aa42ca49..eba08b2b 100644
--- a/modules/gallery/helpers/MY_url.php
+++ b/modules/gallery/helpers/MY_url.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/MY_valid.php b/modules/gallery/helpers/MY_valid.php
index ee17267a..f1dd9c34 100644
--- a/modules/gallery/helpers/MY_valid.php
+++ b/modules/gallery/helpers/MY_valid.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index fbde36c2..a7dca57d 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/ajax.php b/modules/gallery/helpers/ajax.php
index 6d59b6e4..0c69fe7f 100644
--- a/modules/gallery/helpers/ajax.php
+++ b/modules/gallery/helpers/ajax.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 0945e4d9..23aed8ac 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index c86eaa5e..2eb3c252 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/batch.php b/modules/gallery/helpers/batch.php
index 991cad43..bf2425e7 100644
--- a/modules/gallery/helpers/batch.php
+++ b/modules/gallery/helpers/batch.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php
index f59e6d58..bd6ca1c8 100644
--- a/modules/gallery/helpers/block_manager.php
+++ b/modules/gallery/helpers/block_manager.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php
index 343975f6..d4f456d7 100644
--- a/modules/gallery/helpers/data_rest.php
+++ b/modules/gallery/helpers/data_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -32,51 +32,51 @@ class data_rest_Core {
throw new Rest_Exception("Bad Request", 400, array("errors" => array("size" => "invalid")));
}
- switch ($p->size) {
- case "thumb":
- $file = $item->thumb_path();
- break;
-
- case "resize":
- $file = $item->resize_path();
- break;
+ // Note: this code is roughly duplicated in file_proxy, so if you modify this, please look to
+ // see if you should make the same change there as well.
- case "full":
+ if ($p->size == "full") {
$file = $item->file_path();
- break;
+ } else if ($p->size == "resize") {
+ $file = $item->resize_path();
+ } else {
+ $file = $item->thumb_path();
}
if (!file_exists($file)) {
throw new Kohana_404_Exception();
}
- // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to
- // see if you should make the same change there as well.
- //
- // We don't have a cache buster in the url, so don't set cache headers here.
- // We don't need to save the session for this request
- Session::instance()->abort_save();
+ header("Content-Length: " . filesize($file));
- if ($item->is_album() && !$item->album_cover_item_id) {
- // No thumbnail. Return nothing.
- // @todo: what should we do here?
- return;
+ if (isset($p->m)) {
+ header("Pragma:");
+ // Check that the content hasn't expired or it wasn't changed since cached
+ expires::check(2592000, $item->updated);
+
+ expires::set(2592000, $item->updated); // 30 days
}
- // Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
- if ($item->is_movie() && $p->size == "thumb") {
+ // We don't need to save the session for this request
+ Session::instance()->abort_save();
+
+ // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG.
+ if (($item->is_movie() || $item->is_album()) && $p->size == "thumb") {
header("Content-Type: image/jpeg");
- } else if ($item->is_album()) {
- header("Content-Type: " . $item->album_cover()->mime_type);
} else {
- header("Content-Type: {$item->mime_type}");
+ header("Content-Type: $item->mime_type");
}
- Kohana::close_buffers(false);
- if (isset($p->encoding) && $p->encoding == "base64") {
- print base64_encode(file_get_contents($file));
+ if (TEST_MODE) {
+ return $file;
} else {
- readfile($file);
+ Kohana::close_buffers(false);
+
+ if (isset($p->encoding) && $p->encoding == "base64") {
+ print base64_encode(file_get_contents($file));
+ } else {
+ readfile($file);
+ }
}
// We must exit here to keep the regular REST framework reply code from adding more bytes on
@@ -93,6 +93,18 @@ class data_rest_Core {
}
static function url($item, $size) {
- return url::abs_site("rest/data/{$item->id}?size=$size");
+ if ($size == "full") {
+ $file = $item->file_path();
+ } else if ($size == "resize") {
+ $file = $item->resize_path();
+ } else {
+ $file = $item->thumb_path();
+ }
+ if (!file_exists($file)) {
+ throw new Kohana_404_Exception();
+ }
+
+ return url::abs_site("rest/data/{$item->id}?size=$size&m=" . filemtime($file));
}
}
+
diff --git a/modules/gallery/helpers/dir.php b/modules/gallery/helpers/dir.php
index 44a142be..807f7bd3 100644
--- a/modules/gallery/helpers/dir.php
+++ b/modules/gallery/helpers/dir.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/encoding.php b/modules/gallery/helpers/encoding.php
index ce30aa1c..073aef9a 100644
--- a/modules/gallery/helpers/encoding.php
+++ b/modules/gallery/helpers/encoding.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 8b118a80..f1f7190c 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -214,4 +214,20 @@ class gallery_Core {
}
return null;
}
+
+ /**
+ * Return true if we should show the profiler at the bottom of the page. Note that this
+ * function is called at database setup time so it cannot rely on the database.
+ */
+ static function show_profiler() {
+ return file_exists(VARPATH . "PROFILE");
+ }
+
+ /**
+ * Return true if we should allow Javascript and CSS combining for performance reasons.
+ * Typically we want this, but it's convenient for developers to be able to disable it.
+ */
+ static function allow_css_and_js_combining() {
+ return !file_exists(VARPATH . "DONT_COMBINE");
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php
index fe9173c0..5ac4d74d 100644
--- a/modules/gallery/helpers/gallery_block.php
+++ b/modules/gallery/helpers/gallery_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -78,7 +78,7 @@ class gallery_block_Core {
$block->css_id = "g-project-news";
$block->title = t("Gallery project news");
$block->content = new View("admin_block_news.html");
- $block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3);
+ $block->content->feed = feed::parse("http://galleryproject.org/node/feed", 3);
break;
case "block_adder":
diff --git a/modules/gallery/helpers/gallery_error.php b/modules/gallery/helpers/gallery_error.php
index b2515f44..76c8ca99 100644
--- a/modules/gallery/helpers/gallery_error.php
+++ b/modules/gallery/helpers/gallery_error.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 6225633f..aeb1c7eb 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -86,17 +86,17 @@ class gallery_event_Core {
static function item_created($item) {
access::add_item($item);
- if ($item->is_photo() || $item->is_movie()) {
- // Build our thumbnail/resizes.
- try {
- graphics::generate($item);
- } catch (Exception $e) {
- log::error("graphics", t("Couldn't create a thumbnail or resize for %item_title",
- array("item_title" => $item->title)),
- html::anchor($item->abs_url(), t("details")));
- Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
- }
+ // Build our thumbnail/resizes.
+ try {
+ graphics::generate($item);
+ } catch (Exception $e) {
+ log::error("graphics", t("Couldn't create a thumbnail or resize for %item_title",
+ array("item_title" => $item->title)),
+ html::anchor($item->abs_url(), t("details")));
+ Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
+ }
+ if ($item->is_photo() || $item->is_movie()) {
// If the parent has no cover item, make this it.
$parent = $item->parent();
if (access::can("edit", $parent) && $parent->album_cover_item_id == null) {
@@ -141,10 +141,9 @@ class gallery_event_Core {
foreach (ORM::factory("item")
->where("album_cover_item_id", "=", $item->id)
->find_all() as $target) {
- copy($item->thumb_path(), $target->thumb_path());
- $target->thumb_width = $item->thumb_width;
- $target->thumb_height = $item->thumb_height;
+ $target->thumb_dirty = 1;
$target->save();
+ graphics::generate($target);
}
}
@@ -347,9 +346,9 @@ class gallery_event_Core {
if (($item->type == "album" && empty($item->album_cover_item_id)) ||
($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
$parent->album_cover_item_id == $item->id) {
- $disabledState = " ui-state-disabled";
+ $disabledState = "ui-state-disabled";
} else {
- $disabledState = " ";
+ $disabledState = "";
}
if ($item->parent()->id != 1) {
@@ -358,7 +357,7 @@ class gallery_event_Core {
Menu::factory("ajax_link")
->id("make_album_cover")
->label(t("Choose as the album cover"))
- ->css_class("ui-icon-star")
+ ->css_class("ui-icon-star $disabledState")
->ajax_handler("function(data) { window.location.reload() }")
->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf")));
}
@@ -501,16 +500,16 @@ class gallery_event_Core {
if (($item->type == "album" && empty($item->album_cover_item_id)) ||
($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
$parent->album_cover_item_id == $item->id) {
- $disabledState = " ui-state-disabled";
+ $disabledState = "ui-state-disabled";
} else {
- $disabledState = " ";
+ $disabledState = "";
}
if ($item->parent()->id != 1) {
$options_menu
->append(Menu::factory("ajax_link")
->id("make_album_cover")
->label($cover_title)
- ->css_class("ui-icon-star")
+ ->css_class("ui-icon-star $disabledState")
->ajax_handler("function(data) { window.location.reload() }")
->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf")));
}
@@ -519,7 +518,8 @@ class gallery_event_Core {
->id("delete")
->label($delete_title)
->css_class("ui-icon-trash")
- ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&amp;from_id={$theme_item->id}&amp;page_type=$page_type")));
+ ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&amp;" .
+ "from_id={$theme_item->id}&amp;page_type=$page_type")));
}
if ($item->is_album()) {
diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php
index d2b92c87..eb76353f 100644
--- a/modules/gallery/helpers/gallery_graphics.php
+++ b/modules/gallery/helpers/gallery_graphics.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -29,12 +29,28 @@ class gallery_graphics_Core {
static function rotate($input_file, $output_file, $options, $item=null) {
graphics::init_toolkit();
- module::event("graphics_rotate", $input_file, $output_file, $options, $item);
+ $temp_file = system::temp_filename("rotate_", pathinfo($output_file, PATHINFO_EXTENSION));
+ module::event("graphics_rotate", $input_file, $temp_file, $options, $item);
- Image::factory($input_file)
- ->quality(module::get_var("gallery", "image_quality"))
- ->rotate($options["degrees"])
- ->save($output_file);
+ if (@filesize($temp_file) > 0) {
+ // A graphics_rotate event made an image - move it to output_file and use it.
+ @rename($temp_file, $output_file);
+ } else {
+ // No events made an image - proceed with standard process.
+ if (@filesize($input_file) == 0) {
+ throw new Exception("@todo EMPTY_INPUT_FILE");
+ }
+
+ if (!isset($options["degrees"])) {
+ $options["degrees"] = 0;
+ }
+
+ // Rotate the image. This also implicitly converts its format if needed.
+ Image::factory($input_file)
+ ->quality(module::get_var("gallery", "image_quality"))
+ ->rotate($options["degrees"])
+ ->save($output_file);
+ }
module::event("graphics_rotate_completed", $input_file, $output_file, $options, $item);
}
@@ -51,24 +67,46 @@ class gallery_graphics_Core {
static function resize($input_file, $output_file, $options, $item=null) {
graphics::init_toolkit();
- module::event("graphics_resize", $input_file, $output_file, $options, $item);
-
- if (@filesize($input_file) == 0) {
- throw new Exception("@todo EMPTY_INPUT_FILE");
- }
+ $temp_file = system::temp_filename("resize_", pathinfo($output_file, PATHINFO_EXTENSION));
+ module::event("graphics_resize", $input_file, $temp_file, $options, $item);
- $dims = getimagesize($input_file);
- if (max($dims[0], $dims[1]) <= min($options["width"], $options["height"])) {
- // Image would get upscaled; do nothing
- copy($input_file, $output_file);
+ if (@filesize($temp_file) > 0) {
+ // A graphics_resize event made an image - move it to output_file and use it.
+ @rename($temp_file, $output_file);
} else {
- $image = Image::factory($input_file)
- ->resize($options["width"], $options["height"], $options["master"])
- ->quality(module::get_var("gallery", "image_quality"));
- if (graphics::can("sharpen")) {
- $image->sharpen(module::get_var("gallery", "image_sharpen"));
+ // No events made an image - proceed with standard process.
+ if (@filesize($input_file) == 0) {
+ throw new Exception("@todo EMPTY_INPUT_FILE");
+ }
+
+ list ($input_width, $input_height, $input_mime, $input_extension) =
+ photo::get_file_metadata($input_file);
+ if ($input_width && $input_height &&
+ (empty($options["width"]) || empty($options["height"]) || empty($options["master"]) ||
+ (max($input_width, $input_height) <= min($options["width"], $options["height"])))) {
+ // Photo dimensions well-defined, but options not well-defined or would upscale the image.
+ // Do not resize. Check mimes to see if we can copy the file or if we need to convert it.
+ // (checking mimes avoids needlessly converting jpg to jpeg, etc.)
+ $output_mime = legal_file::get_photo_types_by_extension(pathinfo($output_file, PATHINFO_EXTENSION));
+ if ($input_mime && $output_mime && ($input_mime == $output_mime)) {
+ // Mimes well-defined and identical - copy input to output
+ copy($input_file, $output_file);
+ } else {
+ // Mimes not well-defined or not the same - convert input to output
+ $image = Image::factory($input_file)
+ ->quality(module::get_var("gallery", "image_quality"))
+ ->save($output_file);
+ }
+ } else {
+ // Resize the image. This also implicitly converts its format if needed.
+ $image = Image::factory($input_file)
+ ->resize($options["width"], $options["height"], $options["master"])
+ ->quality(module::get_var("gallery", "image_quality"));
+ if (graphics::can("sharpen")) {
+ $image->sharpen(module::get_var("gallery", "image_sharpen"));
+ }
+ $image->save($output_file);
}
- $image->save($output_file);
}
module::event("graphics_resize_completed", $input_file, $output_file, $options, $item);
@@ -94,38 +132,51 @@ class gallery_graphics_Core {
try {
graphics::init_toolkit();
- module::event("graphics_composite", $input_file, $output_file, $options, $item);
-
- list ($width, $height) = getimagesize($input_file);
- list ($w_width, $w_height) = getimagesize($options["file"]);
-
- $pad = isset($options["padding"]) ? $options["padding"] : 10;
- $top = $pad;
- $left = $pad;
- $y_center = max($height / 2 - $w_height / 2, $pad);
- $x_center = max($width / 2 - $w_width / 2, $pad);
- $bottom = max($height - $w_height - $pad, $pad);
- $right = max($width - $w_width - $pad, $pad);
-
- switch ($options["position"]) {
- case "northwest": $x = $left; $y = $top; break;
- case "north": $x = $x_center; $y = $top; break;
- case "northeast": $x = $right; $y = $top; break;
- case "west": $x = $left; $y = $y_center; break;
- case "center": $x = $x_center; $y = $y_center; break;
- case "east": $x = $right; $y = $y_center; break;
- case "southwest": $x = $left; $y = $bottom; break;
- case "south": $x = $x_center; $y = $bottom; break;
- case "southeast": $x = $right; $y = $bottom; break;
- }
+ $temp_file = system::temp_filename("composite_", pathinfo($output_file, PATHINFO_EXTENSION));
+ module::event("graphics_composite", $input_file, $temp_file, $options, $item);
- Image::factory($input_file)
- ->composite($options["file"], $x, $y, $options["transparency"])
- ->quality(module::get_var("gallery", "image_quality"))
- ->save($output_file);
+ if (@filesize($temp_file) > 0) {
+ // A graphics_composite event made an image - move it to output_file and use it.
+ @rename($temp_file, $output_file);
+ } else {
+ // No events made an image - proceed with standard process.
+
+ list ($width, $height) = photo::get_file_metadata($input_file);
+ list ($w_width, $w_height) = photo::get_file_metadata($options["file"]);
+
+ $pad = isset($options["padding"]) ? $options["padding"] : 10;
+ $top = $pad;
+ $left = $pad;
+ $y_center = max($height / 2 - $w_height / 2, $pad);
+ $x_center = max($width / 2 - $w_width / 2, $pad);
+ $bottom = max($height - $w_height - $pad, $pad);
+ $right = max($width - $w_width - $pad, $pad);
+
+ switch ($options["position"]) {
+ case "northwest": $x = $left; $y = $top; break;
+ case "north": $x = $x_center; $y = $top; break;
+ case "northeast": $x = $right; $y = $top; break;
+ case "west": $x = $left; $y = $y_center; break;
+ case "center": $x = $x_center; $y = $y_center; break;
+ case "east": $x = $right; $y = $y_center; break;
+ case "southwest": $x = $left; $y = $bottom; break;
+ case "south": $x = $x_center; $y = $bottom; break;
+ case "southeast": $x = $right; $y = $bottom; break;
+ }
+
+ Image::factory($input_file)
+ ->composite($options["file"], $x, $y, $options["transparency"])
+ ->quality(module::get_var("gallery", "image_quality"))
+ ->save($output_file);
+ }
module::event("graphics_composite_completed", $input_file, $output_file, $options, $item);
} catch (ErrorException $e) {
+ // Unlike rotate and resize, composite catches its exceptions here. This is because
+ // composite is typically called for watermarks. If during thumb/resize generation
+ // the watermark fails, we'd still like the image resized, just without its watermark.
+ // If the exception isn't caught here, graphics::generate will replace it with a
+ // placeholder.
Kohana_Log::add("error", $e->getMessage());
}
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 597771f3..051a66cf 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -116,7 +116,8 @@ class gallery_installer {
KEY `type` (`type`),
KEY `random` (`rand_key`),
KEY `weight` (`weight` DESC),
- KEY `left_ptr` (`left_ptr`))
+ KEY `left_ptr` (`left_ptr`),
+ KEY `relative_path_cache` (`relative_path_cache`))
DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {logs} (
@@ -314,8 +315,7 @@ class gallery_installer {
module::set_var("gallery", "timezone", null);
module::set_var("gallery", "lock_timeout", 1);
module::set_var("gallery", "movie_extract_frame_time", 3);
-
- module::set_version("gallery", 53);
+ module::set_var("gallery", "movie_allow_uploads", "autodetect");
}
static function upgrade($version) {
@@ -718,14 +718,14 @@ class gallery_installer {
if ($version == 50) {
// In v51, we added a lock_timeout variable so that administrators could edit the time out
- // from 1 second to a higher variable if their system runs concurrent parallel uploads for
+ // from 1 second to a higher variable if their system runs concurrent parallel uploads for
// instance.
module::set_var("gallery", "lock_timeout", 1);
module::set_version("gallery", $version = 51);
}
if ($version == 51) {
- // In v52, we added functions to the legal_file helper that map photo and movie file
+ // In v52, we added functions to the legal_file helper that map photo and movie file
// extensions to their mime types (and allow extension of the list by other modules). During
// this process, we correctly mapped m4v files to video/x-m4v, correcting a previous error
// where they were mapped to video/mp4. This corrects the existing items.
@@ -736,13 +736,67 @@ class gallery_installer {
->execute();
module::set_version("gallery", $version = 52);
}
-
+
if ($version == 52) {
// In v53, we added the ability to change the default time used when extracting frames from
// movies. Previously we hard-coded this at 3 seconds, so we use that as the default.
module::set_var("gallery", "movie_extract_frame_time", 3);
module::set_version("gallery", $version = 53);
}
+
+ if ($version == 53) {
+ // In v54, we changed how we check for name and slug conflicts in Item_Model. Previously,
+ // we checked the whole filename. As a result, "foo.jpg" and "foo.png" were not considered
+ // conflicting if their slugs were different (a rare case in practice since server_add and
+ // uploader would give them both the same slug "foo"). Now, we check the filename without its
+ // extension. This upgrade stanza fixes any conflicts where they were previously allowed.
+
+ // This might be slow, but if it times out it can just pick up where it left off.
+
+ // Find and loop through each conflict (e.g. "foo.jpg", "foo.png", and "foo.flv" are one
+ // conflict; "bar.jpg", "bar.png", and "bar.flv" are another)
+ foreach (db::build()
+ ->select_distinct(array("parent_base_name" =>
+ db::expr("CONCAT(`parent_id`, ':', LOWER(SUBSTR(`name`, 1, LOCATE('.', `name`) - 1)))")))
+ ->select(array("C" => "COUNT(\"*\")"))
+ ->from("items")
+ ->where("type", "<>", "album")
+ ->having("C", ">", 1)
+ ->group_by("parent_base_name")
+ ->execute() as $conflict) {
+ list ($parent_id, $base_name) = explode(":", $conflict->parent_base_name, 2);
+ $base_name_escaped = Database::escape_for_like($base_name);
+ // Loop through the items for each conflict
+ foreach (db::build()
+ ->from("items")
+ ->select("id")
+ ->where("type", "<>", "album")
+ ->where("parent_id", "=", $parent_id)
+ ->where("name", "LIKE", "{$base_name_escaped}.%")
+ ->limit(1000000) // required to satisfy SQL syntax (no offset without limit)
+ ->offset(1) // skips the 0th item
+ ->execute() as $row) {
+ set_time_limit(30);
+ $item = ORM::factory("item", $row->id);
+ $item->name = $item->name; // this will force Item_Model to check for conflicts on save
+ $item->save();
+ }
+ }
+ module::set_version("gallery", $version = 54);
+ }
+
+ if ($version == 54) {
+ $db->query("ALTER TABLE {items} ADD KEY `relative_path_cache` (`relative_path_cache`)");
+ module::set_version("gallery", $version = 55);
+ }
+
+ if ($version == 55) {
+ // In v56, we added the ability to change the default behavior regarding movie uploads. It
+ // can be set to "always", "never", or "autodetect" to match the previous behavior where they
+ // are allowed only if FFmpeg is found.
+ module::set_var("gallery", "movie_allow_uploads", "autodetect");
+ module::set_version("gallery", $version = 56);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php
index c952f4b6..d6b33022 100644
--- a/modules/gallery/helpers/gallery_rss.php
+++ b/modules/gallery/helpers/gallery_rss.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index 65a72884..856d2639 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -26,11 +26,13 @@ class gallery_task_Core {
const FIX_STATE_RUN_DUPE_SLUGS = 5;
const FIX_STATE_START_DUPE_NAMES = 6;
const FIX_STATE_RUN_DUPE_NAMES = 7;
- const FIX_STATE_START_REBUILD_ITEM_CACHES = 8;
- const FIX_STATE_RUN_REBUILD_ITEM_CACHES = 9;
- const FIX_STATE_START_MISSING_ACCESS_CACHES = 10;
- const FIX_STATE_RUN_MISSING_ACCESS_CACHES = 11;
- const FIX_STATE_DONE = 12;
+ const FIX_STATE_START_DUPE_BASE_NAMES = 8;
+ const FIX_STATE_RUN_DUPE_BASE_NAMES = 9;
+ const FIX_STATE_START_REBUILD_ITEM_CACHES = 10;
+ const FIX_STATE_RUN_REBUILD_ITEM_CACHES = 11;
+ const FIX_STATE_START_MISSING_ACCESS_CACHES = 12;
+ const FIX_STATE_RUN_MISSING_ACCESS_CACHES = 13;
+ const FIX_STATE_DONE = 14;
static function available_tasks() {
$dirty_count = graphics::find_dirty_images_query()->count_records();
@@ -348,8 +350,9 @@ class gallery_task_Core {
// album audit (permissions and bogus album covers): 1 operation for every album
$total += db::build()->where("type", "=", "album")->count_records("items");
- // one operation for each missing slug, name and access cache
- foreach (array("find_dupe_slugs", "find_dupe_names", "find_missing_access_caches") as $func) {
+ // one operation for each dupe slug, dupe name, dupe base name, and missing access cache
+ foreach (array("find_dupe_slugs", "find_dupe_names", "find_dupe_base_names",
+ "find_missing_access_caches") as $func) {
foreach (self::$func() as $row) {
$total++;
}
@@ -489,11 +492,12 @@ class gallery_task_Core {
$task->set("stack", implode(" ", $stack));
$state = self::FIX_STATE_RUN_DUPE_NAMES;
} else {
- $state = self::FIX_STATE_START_ALBUMS;
+ $state = self::FIX_STATE_START_DUPE_BASE_NAMES;
}
break;
case self::FIX_STATE_RUN_DUPE_NAMES:
+ // NOTE: This does *not* attempt to fix the file system!
$stack = explode(" ", $task->get("stack"));
list ($parent_id, $name) = explode(":", array_pop($stack));
@@ -505,9 +509,16 @@ class gallery_task_Core {
->find_all(1, 1);
if ($conflicts->count() && $conflict = $conflicts->current()) {
$task->log("Fixing conflicting name for item id {$conflict->id}");
+ if (!$conflict->is_album() && preg_match("/^(.*)(\.[^\.\/]*?)$/", $conflict->name, $matches)) {
+ $item_base_name = $matches[1];
+ $item_extension = $matches[2]; // includes a leading dot
+ } else {
+ $item_base_name = $conflict->name;
+ $item_extension = "";
+ }
db::build()
->update("items")
- ->set("name", $name . "-" . (string)rand(1000, 9999))
+ ->set("name", $item_base_name . "-" . (string)rand(1000, 9999) . $item_extension)
->where("id", "=", $conflict->id)
->execute();
@@ -522,6 +533,74 @@ class gallery_task_Core {
$completed++;
if (empty($stack)) {
+ $state = self::FIX_STATE_START_DUPE_BASE_NAMES;
+ }
+ break;
+
+ case self::FIX_STATE_START_DUPE_BASE_NAMES:
+ $stack = array();
+ foreach (self::find_dupe_base_names() as $row) {
+ list ($parent_id, $base_name) = explode(":", $row->parent_base_name, 2);
+ $stack[] = join(":", array($parent_id, $base_name));
+ }
+ if ($stack) {
+ $task->set("stack", implode(" ", $stack));
+ $state = self::FIX_STATE_RUN_DUPE_BASE_NAMES;
+ } else {
+ $state = self::FIX_STATE_START_ALBUMS;
+ }
+ break;
+
+ case self::FIX_STATE_RUN_DUPE_BASE_NAMES:
+ // NOTE: This *does* attempt to fix the file system! So, it must go *after* run_dupe_names.
+ $stack = explode(" ", $task->get("stack"));
+ list ($parent_id, $base_name) = explode(":", array_pop($stack));
+ $base_name_escaped = Database::escape_for_like($base_name);
+
+ $fixed = 0;
+ // We want to leave the first one alone and update all conflicts to be random values.
+ $conflicts = ORM::factory("item")
+ ->where("parent_id", "=", $parent_id)
+ ->where("name", "LIKE", "{$base_name_escaped}.%")
+ ->where("type", "<>", "album")
+ ->find_all(1, 1);
+ if ($conflicts->count() && $conflict = $conflicts->current()) {
+ $task->log("Fixing conflicting name for item id {$conflict->id}");
+ if (preg_match("/^(.*)(\.[^\.\/]*?)$/", $conflict->name, $matches)) {
+ $item_base_name = $matches[1]; // unlike $base_name, this always maintains capitalization
+ $item_extension = $matches[2]; // includes a leading dot
+ } else {
+ $item_base_name = $conflict->name;
+ $item_extension = "";
+ }
+ // Unlike conflicts found in run_dupe_names, these items are likely to have an intact
+ // file system. Let's use the item save logic to rebuild the paths and rename the files
+ // if possible.
+ try {
+ $conflict->name = $item_base_name . "-" . (string)rand(1000, 9999) . $item_extension;
+ $conflict->validate();
+ // If we get here, we're safe to proceed with save
+ $conflict->save();
+ } catch (Exception $e) {
+ // Didn't work. Edit database directly without fixing file system.
+ db::build()
+ ->update("items")
+ ->set("name", $item_base_name . "-" . (string)rand(1000, 9999) . $item_extension)
+ ->where("id", "=", $conflict->id)
+ ->execute();
+ }
+
+ // We fixed one conflict, but there might be more so put this parent back on the stack
+ // and try again. We won't consider it completed when we don't fix a conflict. This
+ // guarantees that we won't spend too long fixing one set of conflicts, and that we
+ // won't stop before all are fixed.
+ $stack[] = "$parent_id:$base_name";
+ break;
+ }
+ $task->set("stack", implode(" ", $stack));
+ $completed++;
+
+ if (empty($stack)) {
$state = self::FIX_STATE_START_ALBUMS;
}
break;
@@ -612,7 +691,7 @@ class gallery_task_Core {
break;
case self::FIX_STATE_RUN_MISSING_ACCESS_CACHES:
- $stack = explode(" ", $task->get("stack"));
+ $stack = array_filter(explode(" ", $task->get("stack"))); // filter removes empty/zero ids
if (!empty($stack)) {
$id = array_pop($stack);
$access_cache = ORM::factory("access_cache");
@@ -669,18 +748,32 @@ class gallery_task_Core {
}
static function find_dupe_names() {
+ // looking for photos, movies, and albums
return db::build()
->select_distinct(
array("parent_name" => db::expr("CONCAT(`parent_id`, ':', LOWER(`name`))")))
->select("id")
->select(array("C" => "COUNT(\"*\")"))
->from("items")
- ->where("type", "<>", "album")
->having("C", ">", 1)
->group_by("parent_name")
->execute();
}
+ static function find_dupe_base_names() {
+ // looking for photos or movies, not albums
+ return db::build()
+ ->select_distinct(
+ array("parent_base_name" => db::expr("CONCAT(`parent_id`, ':', LOWER(SUBSTR(`name`, 1, LOCATE('.', `name`) - 1)))")))
+ ->select("id")
+ ->select(array("C" => "COUNT(\"*\")"))
+ ->from("items")
+ ->where("type", "<>", "album")
+ ->having("C", ">", 1)
+ ->group_by("parent_base_name")
+ ->execute();
+ }
+
static function find_empty_item_caches($limit) {
return db::build()
->select("items.id")
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 2263d8d7..3c6d71e9 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -71,7 +71,7 @@ class gallery_theme_Core {
static function page_bottom($theme) {
$session = Session::instance();
- if ($session->get("profiler", false)) {
+ if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();
@@ -96,7 +96,7 @@ class gallery_theme_Core {
static function admin_page_bottom($theme) {
$session = Session::instance();
- if ($session->get("profiler", false)) {
+ if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();
@@ -134,7 +134,7 @@ class gallery_theme_Core {
'<bdo dir="ltr">Gallery ' . gallery::version_string() . '</bdo>');
return "<li class=\"g-first\">" .
t(module::get_var("gallery", "credits"),
- array("url" => "http://gallery.menalto.com",
+ array("url" => "http://galleryproject.org",
"gallery_version" => $version_string)) .
"</li>";
}
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index e7c5da68..e66908c4 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -115,36 +115,12 @@ class graphics_Core {
* @param Item_Model $item
*/
static function generate($item) {
- if ($item->is_album()) {
- if (!$cover = $item->album_cover()) {
- // This album has no cover; there's nothing to generate. Because of an old bug, it's
- // possible that there's an album cover item id that points to an invalid item. In that
- // case, just null out the album cover item id. It's not optimal to do that at this low
- // level, but it's not trivial to find these cases quickly in an upgrade script and if we
- // don't do this, the album may be permanently marked as "needs rebuilding"
- //
- // ref: http://sourceforge.net/apps/trac/gallery/ticket/1172
- // http://gallery.menalto.com/node/96926
- if ($item->album_cover_item_id) {
- $item->album_cover_item_id = null;
- $item->save();
- }
- return;
- }
- $input_file = $cover->file_path();
- $input_item = $cover;
- } else {
- $input_file = $item->file_path();
- $input_item = $item;
- }
-
if ($item->thumb_dirty) {
$ops["thumb"] = $item->thumb_path();
}
- if ($item->resize_dirty && !$item->is_album() && !$item->is_movie()) {
+ if ($item->resize_dirty && $item->is_photo()) {
$ops["resize"] = $item->resize_path();
}
-
if (empty($ops)) {
$item->thumb_dirty = 0;
$item->resize_dirty = 0;
@@ -154,10 +130,11 @@ class graphics_Core {
try {
foreach ($ops as $target => $output_file) {
- if ($input_item->is_movie()) {
- // Convert the movie filename to a JPG first, delete anything that might already be there
- $output_file = legal_file::change_extension($output_file, "jpg");
- unlink($output_file);
+ $working_file = $item->file_path();
+ // Delete anything that might already be there
+ @unlink($output_file);
+ switch ($item->type) {
+ case "movie":
// Run movie_extract_frame events, which can either:
// - generate an output file, bypassing the ffmpeg-based movie::extract_frame
// - add to the options sent to movie::extract_frame (e.g. change frame extract time,
@@ -165,27 +142,70 @@ class graphics_Core {
// Note that the args are similar to those of the events in gallery_graphics
$movie_options_wrapper = new stdClass();
$movie_options_wrapper->movie_options = array();
- module::event("movie_extract_frame", $input_file, $output_file,
- $movie_options_wrapper, $input_item);
+ module::event("movie_extract_frame", $working_file, $output_file,
+ $movie_options_wrapper, $item);
// If no output_file generated by events, run movie::extract_frame with movie_options
clearstatcache();
if (@filesize($output_file) == 0) {
try {
- movie::extract_frame($input_file, $output_file, $movie_options_wrapper->movie_options);
+ movie::extract_frame($working_file, $output_file, $movie_options_wrapper->movie_options);
+ // If we're here, we know ffmpeg is installed and the movie is valid. Because the
+ // user may not always have had ffmpeg installed, the movie's width, height, and
+ // mime type may need updating. Let's use this opportunity to make sure they're
+ // correct. It's not optimal to do it at this low level, but it's not trivial to find
+ // these cases quickly in an upgrade script.
+ list ($width, $height, $mime_type) = movie::get_file_metadata($working_file);
+ // Only set them if they need updating to avoid marking them as "changed"
+ if (($item->width != $width) || ($item->height != $height) ||
+ ($item->mime_type != $mime_type)) {
+ $item->width = $width;
+ $item->height = $height;
+ $item->mime_type = $mime_type;
+ }
} catch (Exception $e) {
- // Didn't work, likely because of MISSING_FFMPEG - copy missing_movie instead
- copy(MODPATH . "gallery/images/missing_movie.jpg", $output_file);
+ // Didn't work, likely because of MISSING_FFMPEG - use placeholder
+ graphics::_replace_image_with_placeholder($item, $target);
+ break;
}
}
$working_file = $output_file;
- } else {
- $working_file = $input_file;
- }
- foreach (self::_get_rules($target) as $rule) {
- $args = array($working_file, $output_file, unserialize($rule->args), $item);
- call_user_func_array($rule->operation, $args);
- $working_file = $output_file;
+ case "photo":
+ // Run the graphics rules (for both movies and photos)
+ foreach (self::_get_rules($target) as $rule) {
+ $args = array($working_file, $output_file, unserialize($rule->args), $item);
+ call_user_func_array($rule->operation, $args);
+ $working_file = $output_file;
+ }
+ break;
+
+ case "album":
+ if (!$cover = $item->album_cover()) {
+ // This album has no cover; copy its placeholder image. Because of an old bug, it's
+ // possible that there's an album cover item id that points to an invalid item. In that
+ // case, just null out the album cover item id. It's not optimal to do that at this low
+ // level, but it's not trivial to find these cases quickly in an upgrade script and if we
+ // don't do this, the album may be permanently marked as "needs rebuilding"
+ //
+ // ref: http://sourceforge.net/apps/trac/gallery/ticket/1172
+ // http://galleryproject.org/node/96926
+ if ($item->album_cover_item_id) {
+ $item->album_cover_item_id = null;
+ $item->save();
+ }
+ graphics::_replace_image_with_placeholder($item, $target);
+ break;
+ }
+ if ($cover->thumb_dirty) {
+ graphics::generate($cover);
+ }
+ if (!$cover->thumb_dirty) {
+ // Make the album cover from the cover item's thumb. Run gallery_graphics::resize with
+ // null options and it will figure out if this is a direct copy or conversion to jpg.
+ $working_file = $cover->thumb_path();
+ gallery_graphics::resize($working_file, $output_file, null, $item);
+ }
+ break;
}
}
@@ -193,33 +213,93 @@ class graphics_Core {
if (file_exists($item->thumb_path())) {
$item->thumb_dirty = 0;
} else {
- copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path());
+ Kohana_Log::add("error", "Failed to rebuild thumb image: $item->title");
+ graphics::_replace_image_with_placeholder($item, "thumb");
}
- $dims = getimagesize($item->thumb_path());
- $item->thumb_width = $dims[0];
- $item->thumb_height = $dims[1];
}
if (!empty($ops["resize"])) {
if (file_exists($item->resize_path())) {
$item->resize_dirty = 0;
} else {
- copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path());
+ Kohana_Log::add("error", "Failed to rebuild resize image: $item->title");
+ graphics::_replace_image_with_placeholder($item, "resize");
}
- $dims = getimagesize($item->resize_path());
- $item->resize_width = $dims[0];
- $item->resize_height = $dims[1];
}
+ graphics::_update_item_dimensions($item);
$item->save();
} catch (Exception $e) {
- // Something went wrong rebuilding the image. Leave it dirty and move on.
- // @todo we should handle this better.
- Kohana_Log::add("error", "Caught exception rebuilding image: {$item->title}\n" .
+ // Something went wrong rebuilding the image. Replace with the placeholder images,
+ // leave it dirty and move on.
+ Kohana_Log::add("error", "Caught exception rebuilding images: {$item->title}\n" .
$e->getMessage() . "\n" . $e->getTraceAsString());
+ if ($item->is_photo()) {
+ graphics::_replace_image_with_placeholder($item, "resize");
+ }
+ graphics::_replace_image_with_placeholder($item, "thumb");
+ try {
+ graphics::_update_item_dimensions($item);
+ } catch (Exception $e) {
+ // Looks like get_file_metadata couldn't identify our placeholders. We should never get
+ // here, but in the odd case we do, we need to do something. Let's put in hardcoded values.
+ if ($item->is_photo()) {
+ list ($item->resize_width, $item->resize_height) = array(200, 200);
+ }
+ list ($item->thumb_width, $item->thumb_height) = array(200, 200);
+ }
+ $item->save();
throw $e;
}
}
+ private static function _update_item_dimensions($item) {
+ if ($item->is_photo()) {
+ list ($item->resize_width, $item->resize_height) =
+ photo::get_file_metadata($item->resize_path());
+ }
+ list ($item->thumb_width, $item->thumb_height) =
+ photo::get_file_metadata($item->thumb_path());
+ }
+
+ private static function _replace_image_with_placeholder($item, $target) {
+ if ($item->is_album() && !$item->album_cover_item_id) {
+ $input_path = MODPATH . "gallery/images/missing_album_cover.jpg";
+ } else if ($item->is_movie() || ($item->is_album() && $item->album_cover()->is_movie())) {
+ $input_path = MODPATH . "gallery/images/missing_movie.jpg";
+ } else {
+ $input_path = MODPATH . "gallery/images/missing_photo.jpg";
+ }
+
+ if ($target == "thumb") {
+ $output_path = $item->thumb_path();
+ $size = module::get_var("gallery", "thumb_size", 200);
+ } else {
+ $output_path = $item->resize_path();
+ $size = module::get_var("gallery", "resize_size", 640);
+ }
+ $options = array("width" => $size, "height" => $size, "master" => Image::AUTO);
+
+ try {
+ // Copy/convert/resize placeholder as needed.
+ gallery_graphics::resize($input_path, $output_path, $options, null);
+ } catch (Exception $e) {
+ // Copy/convert/resize didn't work. Add to the log and copy the jpg version (which could have
+ // a non-jpg extension). This is less than ideal, but it's better than putting nothing
+ // there and causing theme views to act strangely because a file is missing.
+ // @todo we should handle this better.
+ Kohana_Log::add("error", "Caught exception converting placeholder for missing image: " .
+ $item->title . "\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
+ copy($input_path, $output_path);
+ }
+
+ if (!file_exists($output_path)) {
+ // Copy/convert/resize didn't throw an exception, but still didn't work - do the same as above.
+ // @todo we should handle this better.
+ Kohana_Log::add("error", "Failed to convert placeholder for missing image: $item->title");
+ copy($input_path, $output_path);
+ }
+ }
+
private static function _get_rules($target) {
if (empty(self::$_rules_cache[$target])) {
$rules = array();
@@ -256,12 +336,19 @@ class graphics_Core {
}
/**
- * Mark thumbnails and resizes as dirty. They will have to be rebuilt.
+ * Mark thumbnails and resizes as dirty. They will have to be rebuilt. Optionally, only those of
+ * a specified type and/or mime type can be marked (e.g. $type="movie" to rebuild movies only).
*/
- static function mark_dirty($thumbs, $resizes) {
+ static function mark_dirty($thumbs, $resizes, $type=null, $mime_type=null) {
if ($thumbs || $resizes) {
$db = db::build()
->update("items");
+ if ($type) {
+ $db->where("type", "=", $type);
+ }
+ if ($mime_type) {
+ $db->where("mime_type", "=", $mime_type);
+ }
if ($thumbs) {
$db->set("thumb_dirty", 1);
}
diff --git a/modules/gallery/helpers/identity.php b/modules/gallery/helpers/identity.php
index fcc9c6e8..5fc0f2f6 100644
--- a/modules/gallery/helpers/identity.php
+++ b/modules/gallery/helpers/identity.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index b739e8bd..9882a9c5 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -39,55 +39,28 @@ class item_Core {
}
}
- $source->parent_id = $target->id;
-
- // Moving may result in name or slug conflicts. If that happens, try up to 5 times to pick a
- // random name (or slug) to avoid the conflict.
$orig_name = $source->name;
- $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME);
- $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION);
- $orig_slug = $source->slug;
- for ($i = 0; $i < 5; $i++) {
- try {
- $source->save();
- if ($orig_name != $source->name) {
- switch ($source->type) {
- case "album":
- message::info(
- t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict",
- array("old_name" => $orig_name, "new_name" => $source->name)));
- break;
-
- case "photo":
- message::info(
- t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict",
- array("old_name" => $orig_name, "new_name" => $source->name)));
- break;
+ $source->parent_id = $target->id;
+ $source->save();
+ if ($orig_name != $source->name) {
+ switch ($source->type) {
+ case "album":
+ message::info(
+ t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict",
+ array("old_name" => $orig_name, "new_name" => $source->name)));
+ break;
- case "movie":
- message::info(
- t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict",
- array("old_name" => $orig_name, "new_name" => $source->name)));
- break;
- }
- }
+ case "photo":
+ message::info(
+ t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict",
+ array("old_name" => $orig_name, "new_name" => $source->name)));
break;
- } catch (ORM_Validation_Exception $e) {
- $rand = rand(10, 99);
- $errors = $e->validation->errors();
- if (isset($errors["name"])) {
- $source->name = $orig_name_filename . "-{$rand}." . $orig_name_extension;
- unset($errors["name"]);
- }
- if (isset($errors["slug"])) {
- $source->slug = $orig_slug . "-{$rand}";
- unset($errors["slug"]);
- }
- if ($errors) {
- // There were other validation issues-- we don't know how to handle those
- throw $e;
- }
+ case "movie":
+ message::info(
+ t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict",
+ array("old_name" => $orig_name, "new_name" => $source->name)));
+ break;
}
}
@@ -103,34 +76,42 @@ class item_Core {
access::required("view", $parent);
access::required("edit", $parent);
+ $old_album_cover_id = $parent->album_cover_item_id;
+
model_cache::clear();
$parent->album_cover_item_id = $item->is_album() ? $item->album_cover_item_id : $item->id;
- if ($item->thumb_dirty) {
- $parent->thumb_dirty = 1;
- graphics::generate($parent);
- } else {
- copy($item->thumb_path(), $parent->thumb_path());
- $parent->thumb_width = $item->thumb_width;
- $parent->thumb_height = $item->thumb_height;
- }
$parent->save();
+ graphics::generate($parent);
+
+ // Walk up the parent hierarchy and set album covers if necessary
$grand_parent = $parent->parent();
if ($grand_parent && access::can("edit", $grand_parent) &&
$grand_parent->album_cover_item_id == null) {
item::make_album_cover($parent);
}
+
+ // When albums are album covers themselves, we hotlink directly to the target item. This
+ // means that when we change an album cover, the grandparent may have a deep link to the old
+ // album cover. So find any parent albums that had the old item as their album cover and
+ // switch them over to the new item.
+ if ($old_album_cover_id) {
+ foreach ($item->parents(array(array("album_cover_item_id", "=", $old_album_cover_id)))
+ as $ancestor) {
+ if (access::can("edit", $ancestor)) {
+ $ancestor->album_cover_item_id = $parent->album_cover_item_id;
+ $ancestor->save();
+ graphics::generate($ancestor);
+ }
+ }
+ }
}
static function remove_album_cover($album) {
access::required("view", $album);
access::required("edit", $album);
- @unlink($album->thumb_path());
model_cache::clear();
$album->album_cover_item_id = null;
- $album->thumb_width = 0;
- $album->thumb_height = 0;
- $album->thumb_dirty = 1;
$album->save();
graphics::generate($album);
}
@@ -437,4 +418,16 @@ class item_Core {
}
return call_user_func_array($callback, $args);
}
+
+ /**
+ * Reset all child weights of a given album to a monotonically increasing sequence based on the
+ * current sort order of the album.
+ */
+ static function resequence_child_weights($album) {
+ $weight = 0;
+ foreach ($album->children() as $child) {
+ $child->weight = ++$weight;
+ $child->save();
+ }
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php
index 43fec3ab..efeba2ef 100644
--- a/modules/gallery/helpers/item_rest.php
+++ b/modules/gallery/helpers/item_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -64,7 +64,7 @@ class item_rest_Core {
}
if (isset($p->name)) {
- $orm->where("name", "LIKE", "%{$p->name}%");
+ $orm->where("name", "LIKE", "%" . Database::escape_for_like($p->name) . "%");
}
if (isset($p->type)) {
diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php
index 71d7a59a..7622c534 100644
--- a/modules/gallery/helpers/items_rest.php
+++ b/modules/gallery/helpers/items_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/json.php b/modules/gallery/helpers/json.php
index 0cd78581..b56f2690 100644
--- a/modules/gallery/helpers/json.php
+++ b/modules/gallery/helpers/json.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index a8c36d29..2a1be2f9 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -21,7 +21,7 @@
class l10n_client_Core {
private static function _server_url($path) {
- return "http://gallery.menalto.com/translations/$path";
+ return "http://galleryproject.org/translations/$path";
}
static function server_api_key_url() {
diff --git a/modules/gallery/helpers/l10n_scanner.php b/modules/gallery/helpers/l10n_scanner.php
index 1f184da5..5980ebe0 100644
--- a/modules/gallery/helpers/l10n_scanner.php
+++ b/modules/gallery/helpers/l10n_scanner.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php
index b3622764..eb9c25de 100644
--- a/modules/gallery/helpers/legal_file.php
+++ b/modules/gallery/helpers/legal_file.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -18,24 +18,44 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class legal_file_Core {
+ private static $photo_types_by_extension;
+ private static $movie_types_by_extension;
+ private static $photo_extensions;
+ private static $movie_extensions;
+ private static $photo_types;
+ private static $movie_types;
+ private static $blacklist = array("php", "php3", "php4", "php5", "phtml", "phtm", "shtml", "shtm",
+ "pl", "cgi", "asp", "sh", "py", "c", "js");
+
/**
- * Create a default list of allowed photo MIME types paired with their extensions and then let
+ * Create a default list of allowed photo MIME types paired with their extensions and then let
* modules modify it. This is an ordered map, mapping extensions to their MIME types.
* Extensions cannot be duplicated, but MIMEs can (e.g. jpeg and jpg both map to image/jpeg).
*
* @param string $extension (opt.) - return MIME of extension; if not given, return complete array
*/
- static function get_photo_types_by_extension($extension=NULL) {
- $types_by_extension_wrapper = new stdClass();
- $types_by_extension_wrapper->types_by_extension = array(
- "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png");
- module::event("photo_types_by_extension", $types_by_extension_wrapper);
+ static function get_photo_types_by_extension($extension=null) {
+ if (empty(self::$photo_types_by_extension)) {
+ $types_by_extension_wrapper = new stdClass();
+ $types_by_extension_wrapper->types_by_extension = array(
+ "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png");
+ module::event("photo_types_by_extension", $types_by_extension_wrapper);
+ foreach (self::$blacklist as $key) {
+ unset($types_by_extension_wrapper->types_by_extension[$key]);
+ }
+ self::$photo_types_by_extension = $types_by_extension_wrapper->types_by_extension;
+ }
if ($extension) {
// return matching MIME type
- return $types_by_extension_wrapper->types_by_extension[$extension];
+ $extension = strtolower($extension);
+ if (isset(self::$photo_types_by_extension[$extension])) {
+ return self::$photo_types_by_extension[$extension];
+ } else {
+ return null;
+ }
} else {
// return complete array
- return $types_by_extension_wrapper->types_by_extension;
+ return self::$photo_types_by_extension;
}
}
@@ -46,49 +66,115 @@ class legal_file_Core {
*
* @param string $extension (opt.) - return MIME of extension; if not given, return complete array
*/
- static function get_movie_types_by_extension($extension=NULL) {
- $types_by_extension_wrapper = new stdClass();
- $types_by_extension_wrapper->types_by_extension = array(
- "flv" => "video/x-flv", "mp4" => "video/mp4", "m4v" => "video/x-m4v");
- module::event("movie_types_by_extension", $types_by_extension_wrapper);
+ static function get_movie_types_by_extension($extension=null) {
+ if (empty(self::$movie_types_by_extension)) {
+ $types_by_extension_wrapper = new stdClass();
+ $types_by_extension_wrapper->types_by_extension = array(
+ "flv" => "video/x-flv", "mp4" => "video/mp4", "m4v" => "video/x-m4v");
+ module::event("movie_types_by_extension", $types_by_extension_wrapper);
+ foreach (self::$blacklist as $key) {
+ unset($types_by_extension_wrapper->types_by_extension[$key]);
+ }
+ self::$movie_types_by_extension = $types_by_extension_wrapper->types_by_extension;
+ }
if ($extension) {
// return matching MIME type
- return $types_by_extension_wrapper->types_by_extension[$extension];
+ $extension = strtolower($extension);
+ if (isset(self::$movie_types_by_extension[$extension])) {
+ return self::$movie_types_by_extension[$extension];
+ } else {
+ return null;
+ }
} else {
// return complete array
- return $types_by_extension_wrapper->types_by_extension;
+ return self::$movie_types_by_extension;
+ }
+ }
+
+ /**
+ * Create a merged list of all allowed photo and movie MIME types paired with their extensions.
+ *
+ * @param string $extension (opt.) - return MIME of extension; if not given, return complete array
+ */
+ static function get_types_by_extension($extension=null) {
+ $types_by_extension = legal_file::get_photo_types_by_extension();
+ if (movie::allow_uploads()) {
+ $types_by_extension = array_merge($types_by_extension,
+ legal_file::get_movie_types_by_extension());
+ }
+ if ($extension) {
+ // return matching MIME type
+ $extension = strtolower($extension);
+ if (isset($types_by_extension[$extension])) {
+ return $types_by_extension[$extension];
+ } else {
+ return null;
+ }
+ } else {
+ // return complete array
+ return $types_by_extension;
}
}
/**
* Create a default list of allowed photo extensions and then let modules modify it.
+ *
+ * @param string $extension (opt.) - return true if allowed; if not given, return complete array
*/
- static function get_photo_extensions() {
- $extensions_wrapper = new stdClass();
- $extensions_wrapper->extensions = array_keys(legal_file::get_photo_types_by_extension());
- module::event("legal_photo_extensions", $extensions_wrapper);
- return $extensions_wrapper->extensions;
+ static function get_photo_extensions($extension=null) {
+ if (empty(self::$photo_extensions)) {
+ $extensions_wrapper = new stdClass();
+ $extensions_wrapper->extensions = array_keys(legal_file::get_photo_types_by_extension());
+ module::event("legal_photo_extensions", $extensions_wrapper);
+ self::$photo_extensions = array_diff($extensions_wrapper->extensions, self::$blacklist);
+ }
+ if ($extension) {
+ // return true if in array, false if not
+ return in_array(strtolower($extension), self::$photo_extensions);
+ } else {
+ // return complete array
+ return self::$photo_extensions;
+ }
}
/**
* Create a default list of allowed movie extensions and then let modules modify it.
+ *
+ * @param string $extension (opt.) - return true if allowed; if not given, return complete array
*/
- static function get_movie_extensions() {
- $extensions_wrapper = new stdClass();
- $extensions_wrapper->extensions = array_keys(legal_file::get_movie_types_by_extension());
- module::event("legal_movie_extensions", $extensions_wrapper);
- return $extensions_wrapper->extensions;
+ static function get_movie_extensions($extension=null) {
+ if (empty(self::$movie_extensions)) {
+ $extensions_wrapper = new stdClass();
+ $extensions_wrapper->extensions = array_keys(legal_file::get_movie_types_by_extension());
+ module::event("legal_movie_extensions", $extensions_wrapper);
+ self::$movie_extensions = array_diff($extensions_wrapper->extensions, self::$blacklist);
+ }
+ if ($extension) {
+ // return true if in array, false if not
+ return in_array(strtolower($extension), self::$movie_extensions);
+ } else {
+ // return complete array
+ return self::$movie_extensions;
+ }
}
/**
* Create a merged list of all allowed photo and movie extensions.
+ *
+ * @param string $extension (opt.) - return true if allowed; if not given, return complete array
*/
- static function get_extensions() {
+ static function get_extensions($extension=null) {
$extensions = legal_file::get_photo_extensions();
- if (movie::find_ffmpeg()) {
+ if (movie::allow_uploads()) {
$extensions = array_merge($extensions, legal_file::get_movie_extensions());
}
- return $extensions;
+ if ($extension) {
+ // return true if in array, false if not
+ return in_array(strtolower($extension), $extensions);
+ } else {
+ // return complete array
+ return $extensions;
+ }
}
/**
@@ -109,10 +195,14 @@ class legal_file_Core {
* (e.g. flv maps to video/x-flv by default, but video/flv is still legal).
*/
static function get_photo_types() {
- $types_wrapper = new stdClass();
- $types_wrapper->types = array_values(legal_file::get_photo_types_by_extension());
- module::event("legal_photo_types", $types_wrapper);
- return $types_wrapper->types;
+ if (empty(self::$photo_types)) {
+ $types_wrapper = new stdClass();
+ // Need array_unique since types_by_extension can be many-to-one (e.g. jpeg and jpg).
+ $types_wrapper->types = array_unique(array_values(legal_file::get_photo_types_by_extension()));
+ module::event("legal_photo_types", $types_wrapper);
+ self::$photo_types = $types_wrapper->types;
+ }
+ return self::$photo_types;
}
/**
@@ -121,29 +211,34 @@ class legal_file_Core {
* (e.g. flv maps to video/x-flv by default, but video/flv is still legal).
*/
static function get_movie_types() {
- $types_wrapper = new stdClass();
- $types_wrapper->types = array_values(legal_file::get_movie_types_by_extension());
- $types_wrapper->types[] = "video/flv";
- module::event("legal_movie_types", $types_wrapper);
- return $types_wrapper->types;
+ if (empty(self::$movie_types)) {
+ $types_wrapper = new stdClass();
+ // Need array_unique since types_by_extension can be many-to-one (e.g. jpeg and jpg).
+ $types_wrapper->types = array_unique(array_values(legal_file::get_movie_types_by_extension()));
+ $types_wrapper->types[] = "video/flv";
+ module::event("legal_movie_types", $types_wrapper);
+ self::$movie_types = $types_wrapper->types;
+ }
+ return self::$movie_types;
}
/**
- * Convert the extension of a filename. If the original filename has no
+ * Change the extension of a filename. If the original filename has no
* extension, add the new one to the end.
*/
static function change_extension($filename, $new_ext) {
- if (strpos($filename, ".") === false) {
- return "{$filename}.{$new_ext}";
- } else {
- return preg_replace("/\.[^\.]*?$/", ".{$new_ext}", $filename);
- }
+ $filename_no_ext = preg_replace("/\.[^\.\/]*?$/", "", $filename);
+ return "{$filename_no_ext}.{$new_ext}";
}
/**
* Reduce the given file to having a single extension.
*/
static function smash_extensions($filename) {
+ if (!$filename) {
+ // It's harmless, so return it before it causes issues with pathinfo.
+ return $filename;
+ }
$parts = pathinfo($filename);
$result = "";
if ($parts["dirname"] != ".") {
@@ -152,7 +247,64 @@ class legal_file_Core {
$parts["filename"] = str_replace(".", "_", $parts["filename"]);
$parts["filename"] = preg_replace("/[_]+/", "_", $parts["filename"]);
$parts["filename"] = trim($parts["filename"], "_");
- $result .= "{$parts['filename']}.{$parts['extension']}";
+ $result .= isset($parts["extension"]) ? "{$parts['filename']}.{$parts['extension']}" : $parts["filename"];
return $result;
}
+
+ /**
+ * Sanitize a filename for a given type (given as "photo" or "movie") and a target file format
+ * (given as an extension). This returns a completely legal and valid filename,
+ * or throws an exception if the type or extension given is invalid or illegal. It tries to
+ * maintain the filename's original extension even if it's not identical to the given extension
+ * (e.g. don't change "JPG" or "jpeg" to "jpg").
+ *
+ * Note: it is not okay if the extension given is legal but does not match the type (e.g. if
+ * extension is "mp4" and type is "photo", it will throw an exception)
+ *
+ * @param string $filename (with no directory)
+ * @param string $extension (can be uppercase or lowercase)
+ * @param string $type (as "photo" or "movie")
+ * @return string sanitized filename (or null if bad extension argument)
+ */
+ static function sanitize_filename($filename, $extension, $type) {
+ // Check if the type is valid - if so, get the mime types of the
+ // original and target extensions; if not, throw an exception.
+ $original_extension = pathinfo($filename, PATHINFO_EXTENSION);
+ switch ($type) {
+ case "photo":
+ $mime_type = legal_file::get_photo_types_by_extension($extension);
+ $original_mime_type = legal_file::get_photo_types_by_extension($original_extension);
+ break;
+ case "movie":
+ $mime_type = legal_file::get_movie_types_by_extension($extension);
+ $original_mime_type = legal_file::get_movie_types_by_extension($original_extension);
+ break;
+ default:
+ throw new Exception("@todo INVALID_TYPE");
+ }
+
+ // Check if the target extension is blank or invalid - if so, throw an exception.
+ if (!$extension || !$mime_type) {
+ throw new Exception("@todo ILLEGAL_EXTENSION");
+ }
+
+ // Check if the mime types of the original and target extensions match - if not, fix it.
+ if (!$original_extension || ($mime_type != $original_mime_type)) {
+ $filename = legal_file::change_extension($filename, $extension);
+ }
+
+ // It should be a filename without a directory - remove all slashes (and backslashes).
+ $filename = str_replace("/", "_", $filename);
+ $filename = str_replace("\\", "_", $filename);
+
+ // Remove extra dots from the filename. This will also remove extraneous underscores.
+ $filename = legal_file::smash_extensions($filename);
+
+ // It's possible that the filename has no base (e.g. ".jpg") - if so, give it a generic one.
+ if (empty($filename) || (substr($filename, 0, 1) == ".")) {
+ $filename = $type . $filename; // e.g. "photo.jpg" or "movie.mp4"
+ }
+
+ return $filename;
+ }
}
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index f4837e01..8ca25c39 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/log.php b/modules/gallery/helpers/log.php
index 98a5c7d0..cd554b5c 100644
--- a/modules/gallery/helpers/log.php
+++ b/modules/gallery/helpers/log.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/message.php b/modules/gallery/helpers/message.php
index 277a0fee..d1099953 100644
--- a/modules/gallery/helpers/message.php
+++ b/modules/gallery/helpers/message.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php
index fd56f131..7cff68d7 100644
--- a/modules/gallery/helpers/model_cache.php
+++ b/modules/gallery/helpers/model_cache.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index e4f41d3d..df258e87 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -175,9 +175,8 @@ class module_Core {
$installer_class = "{$module_name}_installer";
if (method_exists($installer_class, "install")) {
call_user_func_array(array($installer_class, "install"), array());
- } else {
- module::set_version($module_name, module::available()->$module_name->code_version);
}
+ module::set_version($module_name, module::available()->$module_name->code_version);
// Set the weight of the new module, which controls the order in which the modules are
// loaded. By default, new modules are installed at the end of the priority list. Since the
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 6d70ab2d..eda478c7 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -24,6 +24,8 @@
* Note: by design, this class does not do any permission checking.
*/
class movie_Core {
+ private static $allow_uploads;
+
static function get_edit_form($movie) {
$form = new Forge("movies/update/$movie->id", "", "post", array("id" => "g-edit-movie-form"));
$form->hidden("from_id")->value($movie->id);
@@ -66,7 +68,7 @@ class movie_Core {
* @param string $output_file
* @param array $movie_options (optional)
*/
- static function extract_frame($input_file, $output_file, $movie_options=NULL) {
+ static function extract_frame($input_file, $output_file, $movie_options=null) {
$ffmpeg = movie::find_ffmpeg();
if (empty($ffmpeg)) {
throw new Exception("@todo MISSING_FFMPEG");
@@ -74,17 +76,17 @@ class movie_Core {
list($width, $height, $mime_type, $extension, $duration) = movie::get_file_metadata($input_file);
- if (is_numeric($movie_options["start_time"])) {
+ if (isset($movie_options["start_time"]) && is_numeric($movie_options["start_time"])) {
$start_time = max(0, $movie_options["start_time"]); // ensure it's non-negative
} else {
$start_time = module::get_var("gallery", "movie_extract_frame_time", 3); // use default
}
// extract frame at start_time, unless movie is too short
$start_time_arg = ($duration >= $start_time + 0.1) ?
- "-ss " . date("H:i:s", mktime(0,0,$start_time,0,0,0,0)) : "";
-
- $input_args = $movie_options["input_args"] ? $movie_options["input_args"] : "";
- $output_args = $movie_options["output_args"] ? $movie_options["output_args"] : "";
+ "-ss " . movie::seconds_to_hhmmssdd($start_time) : "";
+
+ $input_args = isset($movie_options["input_args"]) ? $movie_options["input_args"] : "";
+ $output_args = isset($movie_options["output_args"]) ? $movie_options["output_args"] : "";
$cmd = escapeshellcmd($ffmpeg) . " $input_args -i " . escapeshellarg($input_file) .
" -an $start_time_arg -an -r 1 -vframes 1" .
@@ -110,6 +112,29 @@ class movie_Core {
}
/**
+ * Return true if movie uploads are allowed, false if not. This is based on the
+ * "movie_allow_uploads" Gallery variable as well as whether or not ffmpeg is found.
+ */
+ static function allow_uploads() {
+ if (empty(self::$allow_uploads)) {
+ // Refresh ffmpeg settings
+ $ffmpeg = movie::find_ffmpeg();
+ switch (module::get_var("gallery", "movie_allow_uploads", "autodetect")) {
+ case "always":
+ self::$allow_uploads = true;
+ break;
+ case "never":
+ self::$allow_uploads = false;
+ break;
+ default:
+ self::$allow_uploads = !empty($ffmpeg);
+ break;
+ }
+ }
+ return self::$allow_uploads;
+ }
+
+ /**
* Return the path to the ffmpeg binary if one exists and is executable, or null.
*/
static function find_ffmpeg() {
@@ -123,41 +148,108 @@ class movie_Core {
/**
* Return the width, height, mime_type, extension and duration of the given movie file.
+ * Metadata is first generated using ffmpeg (or set to defaults if it fails),
+ * then can be modified by other modules using movie_get_file_metadata events.
+ *
+ * This function and its use cases are symmetric to those of photo::get_file_metadata.
+ *
+ * @param string $file_path
+ * @return array array($width, $height, $mime_type, $extension, $duration)
+ *
+ * Use cases in detail:
+ * Input is standard movie type (flv/mp4/m4v)
+ * -> return metadata from ffmpeg
+ * Input is *not* standard movie type that is supported by ffmpeg (e.g. avi, mts...)
+ * -> return metadata from ffmpeg
+ * Input is *not* standard movie type that is *not* supported by ffmpeg but is legal
+ * -> return zero width, height, and duration; mime type and extension according to legal_file
+ * Input is *not* standard movie type that is *not* supported by ffmpeg and is *not* legal
+ * -> return zero width, height, and duration; null mime type and extension
+ * Input is not readable or does not exist
+ * -> throw exception
+ * Note: movie_get_file_metadata events can change any of the above cases (except the last one).
*/
static function get_file_metadata($file_path) {
- $ffmpeg = movie::find_ffmpeg();
- if (empty($ffmpeg)) {
- throw new Exception("@todo MISSING_FFMPEG");
+ if (!is_readable($file_path)) {
+ throw new Exception("@todo UNREADABLE_FILE");
}
- $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($file_path) . " 2>&1";
- $result = `$cmd`;
- if (preg_match("/Stream.*?Video:.*?, (\d+)x(\d+)/", $result, $matches_res)) {
- if (preg_match("/Stream.*?Video:.*? \[.*?DAR (\d+):(\d+).*?\]/", $result, $matches_dar) &&
- $matches_dar[1] >= 1 && $matches_dar[2] >= 1) {
- // DAR is defined - determine width based on height and DAR
- // (should always be int, but adding round to be sure)
- $matches_res[1] = round($matches_res[2] * $matches_dar[1] / $matches_dar[2]);
+ $metadata = new stdClass();
+ $ffmpeg = movie::find_ffmpeg();
+ if (!empty($ffmpeg)) {
+ // ffmpeg found - use it to get width, height, and duration.
+ $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($file_path) . " 2>&1";
+ $result = `$cmd`;
+ if (preg_match("/Stream.*?Video:.*?, (\d+)x(\d+)/", $result, $matches_res)) {
+ if (preg_match("/Stream.*?Video:.*? \[.*?DAR (\d+):(\d+).*?\]/", $result, $matches_dar) &&
+ $matches_dar[1] >= 1 && $matches_dar[2] >= 1) {
+ // DAR is defined - determine width based on height and DAR
+ // (should always be int, but adding round to be sure)
+ $matches_res[1] = round($matches_res[2] * $matches_dar[1] / $matches_dar[2]);
+ }
+ list ($metadata->width, $metadata->height) = array($matches_res[1], $matches_res[2]);
+ } else {
+ list ($metadata->width, $metadata->height) = array(0, 0);
+ }
+
+ if (preg_match("/Duration: (\d+:\d+:\d+\.\d+)/", $result, $matches)) {
+ $metadata->duration = movie::hhmmssdd_to_seconds($matches[1]);
+ } else if (preg_match("/duration.*?:.*?(\d+)/", $result, $matches)) {
+ $metadata->duration = $matches[1];
+ } else {
+ $metadata->duration = 0;
}
- list ($width, $height) = array($matches_res[1], $matches_res[2]);
} else {
- list ($width, $height) = array(0, 0);
+ // ffmpeg not found - set width, height, and duration to zero.
+ $metadata->width = 0;
+ $metadata->height = 0;
+ $metadata->duration = 0;
}
- $extension = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
- $extension = $extension ? $extension : "flv"; // No extension? Assume FLV.
- $mime_type = legal_file::get_movie_types_by_extension($extension);
- $mime_type = $mime_type ? $mime_type : "video/x-flv"; // No MIME found? Default to video/x-flv.
-
- if (preg_match("/Duration: (\d+):(\d+):(\d+\.\d+)/", $result, $matches)) {
- $duration = 3600 * $matches[1] + 60 * $matches[2] + $matches[3];
- } else if (preg_match("/duration.*?:.*?(\d+)/", $result, $matches)) {
- $duration = $matches[1];
+ $extension = pathinfo($file_path, PATHINFO_EXTENSION);
+ if (!$extension ||
+ (!$metadata->mime_type = legal_file::get_movie_types_by_extension($extension))) {
+ // Extension is empty or illegal.
+ $metadata->extension = null;
+ $metadata->mime_type = null;
} else {
- $duration = 0;
+ // Extension is legal (and mime is already set above).
+ $metadata->extension = strtolower($extension);
}
- return array($width, $height, $mime_type, $extension, $duration);
+ // Run movie_get_file_metadata events which can modify the class.
+ module::event("movie_get_file_metadata", $file_path, $metadata);
+
+ // If the post-events results are invalid, throw an exception. Note that, unlike photos, having
+ // zero width and height isn't considered invalid (as is the case when FFmpeg isn't installed).
+ if (!$metadata->mime_type || !$metadata->extension ||
+ ($metadata->mime_type != legal_file::get_movie_types_by_extension($metadata->extension))) {
+ throw new Exception("@todo ILLEGAL_OR_UNINDENTIFIABLE_FILE");
+ }
+
+ return array($metadata->width, $metadata->height, $metadata->mime_type,
+ $metadata->extension, $metadata->duration);
+ }
+
+ /**
+ * Return the time/duration formatted in hh:mm:ss.dd from a number of seconds.
+ * Useful for inputs to ffmpeg.
+ *
+ * Note that this is similar to date("H:i:s", mktime(0,0,$seconds,0,0,0,0)), but unlike this
+ * approach avoids potential issues with time zone and DST mismatch and/or using deprecated
+ * features (the last argument of mkdate above, which disables DST, is deprecated as of PHP 5.3).
+ */
+ static function seconds_to_hhmmssdd($seconds) {
+ return sprintf("%02d:%02d:%05.2f", floor($seconds / 3600), floor(($seconds % 3600) / 60),
+ floor(100 * $seconds % 6000) / 100);
}
+ /**
+ * Return the number of seconds from a time/duration formatted in hh:mm:ss.dd.
+ * Useful for outputs from ffmpeg.
+ */
+ static function hhmmssdd_to_seconds($hhmmssdd) {
+ preg_match("/(\d+):(\d+):(\d+\.\d+)/", $hhmmssdd, $matches);
+ return 3600 * $matches[1] + 60 * $matches[2] + $matches[3];
+ }
}
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index c4001bd5..2d32f0d3 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -80,20 +80,68 @@ class photo_Core {
/**
* Return the width, height, mime_type and extension of the given image file.
+ * Metadata is first generated using getimagesize (or the legal_file mapping if it fails),
+ * then can be modified by other modules using photo_get_file_metadata events.
+ *
+ * This function and its use cases are symmetric to those of photo::get_file_metadata.
+ *
+ * @param string $file_path
+ * @return array array($width, $height, $mime_type, $extension)
+ *
+ * Use cases in detail:
+ * Input is standard photo type (jpg/png/gif)
+ * -> return metadata from getimagesize()
+ * Input is *not* standard photo type that is supported by getimagesize (e.g. tif, bmp...)
+ * -> return metadata from getimagesize()
+ * Input is *not* standard photo type that is *not* supported by getimagesize but is legal
+ * -> return zero width and height, mime type and extension according to legal_file
+ * Input is *not* standard photo type that is *not* supported by getimagesize and is *not* legal
+ * -> return zero width and height, null mime type and extension
+ * Input is not readable or does not exist
+ * -> throw exception
+ * Note: photo_get_file_metadata events can change any of the above cases (except the last one).
*/
static function get_file_metadata($file_path) {
- $image_info = getimagesize($file_path);
- if ($image_info) {
- $width = $image_info[0];
- $height = $image_info[1];
- $mime_type = $image_info["mime"];
- $extension = image_type_to_extension($image_info[2], false);
- return array($width, $height, $mime_type, $extension);
+ if (!is_readable($file_path)) {
+ throw new Exception("@todo UNREADABLE_FILE");
+ }
+
+ $metadata = new stdClass();
+ if ($image_info = getimagesize($file_path)) {
+ // getimagesize worked - use its results.
+ $metadata->width = $image_info[0];
+ $metadata->height = $image_info[1];
+ $metadata->mime_type = $image_info["mime"];
+ $metadata->extension = image_type_to_extension($image_info[2], false);
+ // We prefer jpg instead of jpeg (which is returned by image_type_to_extension).
+ if ($metadata->extension == "jpeg") {
+ $metadata->extension = "jpg";
+ }
} else {
- // getimagesize failed - use legal_file mapping instead.
- $extension = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
- $mime_type = legal_file::get_photo_types_by_extension($extension);
- return array(0, 0, $mime_type, $extension);
+ // getimagesize failed - try to use legal_file mapping instead.
+ $extension = pathinfo($file_path, PATHINFO_EXTENSION);
+ if (!$extension ||
+ (!$metadata->mime_type = legal_file::get_photo_types_by_extension($extension))) {
+ // Extension is empty or illegal.
+ $metadata->extension = null;
+ $metadata->mime_type = null;
+ } else {
+ // Extension is legal (and mime is already set above).
+ $metadata->extension = strtolower($extension);
+ }
+ $metadata->width = 0;
+ $metadata->height = 0;
}
+
+ // Run photo_get_file_metadata events which can modify the class.
+ module::event("photo_get_file_metadata", $file_path, $metadata);
+
+ // If the post-events results are invalid, throw an exception.
+ if (!$metadata->width || !$metadata->height || !$metadata->mime_type || !$metadata->extension ||
+ ($metadata->mime_type != legal_file::get_photo_types_by_extension($metadata->extension))) {
+ throw new Exception("@todo ILLEGAL_OR_UNINDENTIFIABLE_FILE");
+ }
+
+ return array($metadata->width, $metadata->height, $metadata->mime_type, $metadata->extension);
}
}
diff --git a/modules/gallery/helpers/random.php b/modules/gallery/helpers/random.php
index ea08815a..d40bfb52 100644
--- a/modules/gallery/helpers/random.php
+++ b/modules/gallery/helpers/random.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/site_status.php b/modules/gallery/helpers/site_status.php
index dc8a6c23..e1a81637 100644
--- a/modules/gallery/helpers/site_status.php
+++ b/modules/gallery/helpers/site_status.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php
index 9293e422..e1398103 100644
--- a/modules/gallery/helpers/system.php
+++ b/modules/gallery/helpers/system.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -20,22 +20,42 @@
class system_Core {
/**
* Return the path to an executable version of the named binary, or null.
- * Traverse the PATH environment variable looking for the given file. If
- * the $priority_path variable is set, check that path first.
+ * The paths are traversed in the following order:
+ * 1. $priority_path (if specified)
+ * 2. Gallery's own bin directory (DOCROOT . "bin")
+ * 3. PATH environment variable
+ * 4. extra_binary_paths Gallery variable (if specified)
+ * In addition, if the file is found inside Gallery's bin directory but
+ * it's not executable, we try to change its permissions to 0755.
+ *
+ * @param string $binary
+ * @param string $priority_path (optional)
+ * @return string path to binary if found; null if not found
*/
static function find_binary($binary, $priority_path=null) {
- $paths = array_merge(
- explode(":", getenv("PATH")),
- explode(":", module::get_var("gallery", "extra_binary_paths")));
+ $bin_path = DOCROOT . "bin";
+
if ($priority_path) {
- array_unshift($paths, $priority_path);
+ $paths = array($priority_path, $bin_path);
+ } else {
+ $paths = array($bin_path);
}
+ $paths = array_merge($paths,
+ explode(":", getenv("PATH")),
+ explode(":", module::get_var("gallery", "extra_binary_paths")));
foreach ($paths as $path) {
$candidate = "$path/$binary";
// @suppress errors below to avoid open_basedir issues
- if (@file_exists($candidate) && @is_executable($candidate)) {
- return $candidate;
+ if (@file_exists($candidate)) {
+ if (!@is_executable($candidate) &&
+ (substr_compare($bin_path, $candidate, 0, strlen($bin_path)) == 0)) {
+ // Binary isn't executable but is in Gallery's bin directory - try fixing permissions.
+ @chmod($candidate, 0755);
+ }
+ if (@is_executable($candidate)) {
+ return $candidate;
+ }
}
}
return null;
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index 6fd6618f..32fd9739 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php
index ea93a44f..072f98a1 100644
--- a/modules/gallery/helpers/theme.php
+++ b/modules/gallery/helpers/theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/tree_rest.php b/modules/gallery/helpers/tree_rest.php
index c2f81d3a..5186cf09 100644
--- a/modules/gallery/helpers/tree_rest.php
+++ b/modules/gallery/helpers/tree_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php
index d92da6e5..492f72e9 100644
--- a/modules/gallery/helpers/upgrade_checker.php
+++ b/modules/gallery/helpers/upgrade_checker.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class upgrade_checker_Core {
- const CHECK_URL = "http://gallery.menalto.com/versioncheck/gallery3";
+ const CHECK_URL = "http://galleryproject.org/versioncheck/gallery3";
const AUTO_CHECK_INTERVAL = 604800; // 7 days in seconds
/**
diff --git a/modules/gallery/helpers/user_profile.php b/modules/gallery/helpers/user_profile.php
index be79d9a8..222d2f57 100644
--- a/modules/gallery/helpers/user_profile.php
+++ b/modules/gallery/helpers/user_profile.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/helpers/xml.php b/modules/gallery/helpers/xml.php
index b57ecafa..e20beb19 100644
--- a/modules/gallery/helpers/xml.php
+++ b/modules/gallery/helpers/xml.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php
index 21db8b9a..fa4f8169 100644
--- a/modules/gallery/hooks/init_gallery.php
+++ b/modules/gallery/hooks/init_gallery.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/images/missing_album_cover.jpg b/modules/gallery/images/missing_album_cover.jpg
new file mode 100644
index 00000000..bdddeec5
--- /dev/null
+++ b/modules/gallery/images/missing_album_cover.jpg
Binary files differ
diff --git a/modules/gallery/images/missing_photo.jpg b/modules/gallery/images/missing_photo.jpg
new file mode 100644
index 00000000..a9d176d8
--- /dev/null
+++ b/modules/gallery/images/missing_photo.jpg
Binary files differ
diff --git a/modules/gallery/images/missing_photo.png b/modules/gallery/images/missing_photo.png
deleted file mode 100644
index 67786275..00000000
--- a/modules/gallery/images/missing_photo.png
+++ /dev/null
Binary files differ
diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js
index a1b970e7..6d919c29 100644
--- a/modules/gallery/js/l10n_client.js
+++ b/modules/gallery/js/l10n_client.js
@@ -140,7 +140,11 @@ jQuery.extend(Gallery, {
} else {
if(search.length > 0) {
$('#l10n-client-string-select li').hide();
- $('#l10n-client-string-select li:contains('+search+')').show();
+ $('#l10n-client-string-select li').each(function() {
+ if ($(this).val().indexOf(search) != -1) {
+ $(this).show();
+ }
+ });
$('#l10n-client #g-l10n-search').val(search);
}
}
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 66b8c20c..83163868 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Block.php b/modules/gallery/libraries/Block.php
index c3a73b57..818af9c0 100644
--- a/modules/gallery/libraries/Block.php
+++ b/modules/gallery/libraries/Block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Breadcrumb.php b/modules/gallery/libraries/Breadcrumb.php
index 8e7c6979..3805c5d0 100644
--- a/modules/gallery/libraries/Breadcrumb.php
+++ b/modules/gallery/libraries/Breadcrumb.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Form_Script.php b/modules/gallery/libraries/Form_Script.php
index dfaa1972..2b5ec3e8 100644
--- a/modules/gallery/libraries/Form_Script.php
+++ b/modules/gallery/libraries/Form_Script.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php
index c7b856f9..1e58018d 100644
--- a/modules/gallery/libraries/Form_Uploadify.php
+++ b/modules/gallery/libraries/Form_Uploadify.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -46,7 +46,7 @@ class Form_Uploadify_Core extends Form_Input {
$v->album = $this->data["album"];
$v->script_data = $this->data["script_data"];
$v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit");
- $v->movies_allowed = (bool) movie::find_ffmpeg();
+ $v->movies_allowed = movie::allow_uploads();
$v->extensions = legal_file::get_filters();
$v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt");
diff --git a/modules/gallery/libraries/Form_Uploadify_buttons.php b/modules/gallery/libraries/Form_Uploadify_buttons.php
index a35b30bc..2e0327e7 100644
--- a/modules/gallery/libraries/Form_Uploadify_buttons.php
+++ b/modules/gallery/libraries/Form_Uploadify_buttons.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php
index 6d78f7e6..6b216a29 100644
--- a/modules/gallery/libraries/Gallery_I18n.php
+++ b/modules/gallery/libraries/Gallery_I18n.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php
index 7e8a5ba0..8f02b53c 100644
--- a/modules/gallery/libraries/Gallery_View.php
+++ b/modules/gallery/libraries/Gallery_View.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -82,8 +82,10 @@ class Gallery_View_Core extends View {
* @param $types a comma separated list of types to combine, eg "script,css"
*/
public function start_combining($types) {
- foreach (explode(",", $types) as $type) {
- $this->combine_queue[$type] = array();
+ if (gallery::allow_css_and_js_combining()) {
+ foreach (explode(",", $types) as $type) {
+ $this->combine_queue[$type] = array();
+ }
}
}
diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php
index c9e8688f..23368a6a 100644
--- a/modules/gallery/libraries/IdentityProvider.php
+++ b/modules/gallery/libraries/IdentityProvider.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php
index 496ad0bc..cd177c25 100644
--- a/modules/gallery/libraries/InPlaceEdit.php
+++ b/modules/gallery/libraries/InPlaceEdit.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php
index 4fbd62fd..33759b67 100644
--- a/modules/gallery/libraries/MY_Database.php
+++ b/modules/gallery/libraries/MY_Database.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -32,6 +32,9 @@ abstract class Database extends Database_Core {
$config["connection"]["params"] = null;
}
parent::__construct($config);
+ if (gallery::show_profiler()) {
+ $this->config['benchmark'] = true;
+ }
}
/**
@@ -85,4 +88,14 @@ abstract class Database extends Database_Core {
static function set_default_instance($db) {
self::$instances["default"] = $db;
}
+
+ /**
+ * Escape LIKE queries, add wildcards. In MySQL queries using LIKE, _ and % characters are
+ * treated as wildcards similar to ? and *, respectively. Therefore, we need to escape _, %,
+ * and \ (the escape character itself).
+ */
+ static function escape_for_like($value) {
+ // backslash must go first to avoid double-escaping
+ return addcslashes($value, '\_%');
+ }
} \ No newline at end of file
diff --git a/modules/gallery/libraries/MY_Forge.php b/modules/gallery/libraries/MY_Forge.php
index d7c666b9..635dc2d6 100644
--- a/modules/gallery/libraries/MY_Forge.php
+++ b/modules/gallery/libraries/MY_Forge.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/MY_Input.php b/modules/gallery/libraries/MY_Input.php
index c28f5f15..2f0a7273 100644
--- a/modules/gallery/libraries/MY_Input.php
+++ b/modules/gallery/libraries/MY_Input.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php
index 0c07ea5e..51490a6c 100644
--- a/modules/gallery/libraries/MY_Kohana_Exception.php
+++ b/modules/gallery/libraries/MY_Kohana_Exception.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php
index 4194162b..6e538d54 100644
--- a/modules/gallery/libraries/MY_ORM.php
+++ b/modules/gallery/libraries/MY_ORM.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php
index aa7fcdea..1e886114 100644
--- a/modules/gallery/libraries/MY_View.php
+++ b/modules/gallery/libraries/MY_View.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index c66a197f..24a05cdb 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index ce0b102c..0ad81331 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -152,8 +152,9 @@ class ORM_MPTT_Core extends ORM {
*
* @return array ORM
*/
- function parents() {
+ function parents($where=null) {
return $this
+ ->merge_where($where)
->where("left_ptr", "<=", $this->left_ptr)
->where("right_ptr", ">=", $this->right_ptr)
->where("id", "<>", $this->id)
@@ -324,7 +325,7 @@ class ORM_MPTT_Core extends ORM {
* Lock the tree to prevent concurrent modification.
*/
protected function lock() {
- $timeout = module::get_var("gallery", "lock_timeout");
+ $timeout = module::get_var("gallery", "lock_timeout", 1);
$result = $this->db->query("SELECT GET_LOCK('{$this->table_name}', $timeout) AS l")->current();
if (empty($result->l)) {
throw new Exception("@todo UNABLE_TO_LOCK_EXCEPTION");
diff --git a/modules/gallery/libraries/SafeString.php b/modules/gallery/libraries/SafeString.php
index 997abd2e..31e9d31b 100644
--- a/modules/gallery/libraries/SafeString.php
+++ b/modules/gallery/libraries/SafeString.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Sendmail.php b/modules/gallery/libraries/Sendmail.php
index d62b3b24..69a7c32e 100644
--- a/modules/gallery/libraries/Sendmail.php
+++ b/modules/gallery/libraries/Sendmail.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Task_Definition.php b/modules/gallery/libraries/Task_Definition.php
index ecb4a0a4..f695fe3e 100644
--- a/modules/gallery/libraries/Task_Definition.php
+++ b/modules/gallery/libraries/Task_Definition.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 78b74cde..986fc8a2 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -63,6 +63,13 @@ class Theme_View_Core extends Gallery_View {
* @return int
*/
public function thumb_proportion($item=null) {
+ // If the item is an album with children, grab the first item in that album instead. We're
+ // interested in the size of the thumbnails in this album, not the thumbnail of the
+ // album itself.
+ if ($item && $item->is_album() && $item->children_count()) {
+ $item = $item->children(1)->current();
+ }
+
// By default we have a globally fixed thumbnail size In core code, we just return a fixed
// proportion based on the global thumbnail size, but since modules can override that, we
// return the actual proportions when we have them.
@@ -79,6 +86,12 @@ class Theme_View_Core extends Gallery_View {
return $this->item;
}
+ public function siblings($limit=null, $offset=null) {
+ return call_user_func_array(
+ $this->siblings_callback[0],
+ array_merge($this->siblings_callback[1], array($offset, $limit)));
+ }
+
public function tag() {
return $this->tag;
}
diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php
index e8902495..8790d0e1 100644
--- a/modules/gallery/libraries/drivers/Cache/Database.php
+++ b/modules/gallery/libraries/drivers/Cache/Database.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -69,7 +69,7 @@ class Cache_Database_Driver extends Cache_Driver {
->select()
->from("caches");
foreach ($tags as $tag) {
- $db->where("tags", "LIKE", "%<$tag>%");
+ $db->where("tags", "LIKE", "%" . Database::escape_for_like("<$tag>") . "%");
}
$db_result = $db->execute();
@@ -139,7 +139,7 @@ class Cache_Database_Driver extends Cache_Driver {
// Delete all caches
} else if ($is_tag === true) {
foreach ($keys as $tag) {
- $db->where("tags", "LIKE", "%<$tag>%");
+ $db->where("tags", "LIKE", "%" . Database::escape_for_like("<$tag>") . "%");
}
} else {
$db->where("key", "IN", $keys);
diff --git a/modules/gallery/libraries/drivers/IdentityProvider.php b/modules/gallery/libraries/drivers/IdentityProvider.php
index cae691c9..52562363 100644
--- a/modules/gallery/libraries/drivers/IdentityProvider.php
+++ b/modules/gallery/libraries/drivers/IdentityProvider.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/access_cache.php b/modules/gallery/models/access_cache.php
index f240b020..b0c0843b 100644
--- a/modules/gallery/models/access_cache.php
+++ b/modules/gallery/models/access_cache.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/access_intent.php b/modules/gallery/models/access_intent.php
index e9660b53..56f96668 100644
--- a/modules/gallery/models/access_intent.php
+++ b/modules/gallery/models/access_intent.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/cache.php b/modules/gallery/models/cache.php
index abc4dd54..37d52656 100644
--- a/modules/gallery/models/cache.php
+++ b/modules/gallery/models/cache.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/failed_auth.php b/modules/gallery/models/failed_auth.php
index 87c20687..85c64921 100644
--- a/modules/gallery/models/failed_auth.php
+++ b/modules/gallery/models/failed_auth.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/graphics_rule.php b/modules/gallery/models/graphics_rule.php
index 79daff4e..241560ea 100644
--- a/modules/gallery/models/graphics_rule.php
+++ b/modules/gallery/models/graphics_rule.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/incoming_translation.php b/modules/gallery/models/incoming_translation.php
index 093dd2e5..f3c9813a 100644
--- a/modules/gallery/models/incoming_translation.php
+++ b/modules/gallery/models/incoming_translation.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 8f127532..43b9a292 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -21,6 +21,7 @@ class Item_Model_Core extends ORM_MPTT {
protected $children = "items";
protected $sorting = array();
public $data_file = null;
+ private $data_file_error = null;
public function __construct($id=null) {
parent::__construct($id);
@@ -129,10 +130,11 @@ class Item_Model_Core extends ORM_MPTT {
/**
* Return the server-relative url to this item, eg:
- * /gallery3/index.php/BobsWedding?page=2
- * /gallery3/index.php/BobsWedding/Eating-Cake.jpg
+ * album: /gallery3/index.php/Bobs%20Wedding?page=2
+ * photo: /gallery3/index.php/Bobs%20Wedding/Eating-Cake
+ * movie: /gallery3/index.php/Bobs%20Wedding/First-Dance
*
- * @param string $query the query string (eg "show=3")
+ * @param string $query the query string (eg "page=2")
*/
public function url($query=null) {
$url = url::site($this->relative_url());
@@ -144,10 +146,11 @@ class Item_Model_Core extends ORM_MPTT {
/**
* Return the full url to this item, eg:
- * http://example.com/gallery3/index.php/BobsWedding?page=2
- * http://example.com/gallery3/index.php/BobsWedding/Eating-Cake.jpg
+ * album: http://example.com/gallery3/index.php/Bobs%20Wedding?page=2
+ * photo: http://example.com/gallery3/index.php/Bobs%20Wedding/Eating-Cake
+ * movie: http://example.com/gallery3/index.php/Bobs%20Wedding/First-Dance
*
- * @param string $query the query string (eg "show=3")
+ * @param string $query the query string (eg "page=2")
*/
public function abs_url($query=null) {
$url = url::abs_site($this->relative_url());
@@ -158,16 +161,24 @@ class Item_Model_Core extends ORM_MPTT {
}
/**
- * album: /var/albums/album1/album2
- * photo: /var/albums/album1/album2/photo.jpg
+ * Return the full path to this item's file, eg:
+ * album: /usr/home/www/gallery3/var/albums/Bobs Wedding
+ * photo: /usr/home/www/gallery3/var/albums/Bobs Wedding/Eating-Cake.jpg
+ * movie: /usr/home/www/gallery3/var/albums/Bobs Wedding/First-Dance.mp4
*/
public function file_path() {
return VARPATH . "albums/" . urldecode($this->relative_path());
}
/**
- * album: http://example.com/gallery3/var/resizes/album1/
- * photo: http://example.com/gallery3/var/albums/album1/photo.jpg
+ * Return the relative url to this item's file, with cache buster, eg:
+ * album: var/albums/Bobs%20Wedding?m=1234567890
+ * photo: var/albums/Bobs%20Wedding/Eating-Cake.jpg?m=1234567890
+ * movie: var/albums/Bobs%20Wedding/First-Dance.mp4?m=1234567890
+ * If $full_uri==true, return the full url to this item's file, with cache buster, eg:
+ * album: http://example.com/gallery3/var/albums/Bobs%20Wedding?m=1234567890
+ * photo: http://example.com/gallery3/var/albums/Bobs%20Wedding/Eating-Cake.jpg?m=1234567890
+ * movie: http://example.com/gallery3/var/albums/Bobs%20Wedding/First-Dance.mp4?m=1234567890
*/
public function file_url($full_uri=false) {
$relative_path = "var/albums/" . $this->relative_path();
@@ -177,8 +188,10 @@ class Item_Model_Core extends ORM_MPTT {
}
/**
- * album: /var/resizes/album1/.thumb.jpg
- * photo: /var/albums/album1/photo.thumb.jpg
+ * Return the full path to this item's thumb, eg:
+ * album: /usr/home/www/gallery3/var/thumbs/Bobs Wedding/.album.jpg
+ * photo: /usr/home/www/gallery3/var/thumbs/Bobs Wedding/Eating-Cake.jpg
+ * movie: /usr/home/www/gallery3/var/thumbs/Bobs Wedding/First-Dance.jpg
*/
public function thumb_path() {
$base = VARPATH . "thumbs/" . urldecode($this->relative_path());
@@ -200,8 +213,14 @@ class Item_Model_Core extends ORM_MPTT {
}
/**
- * album: http://example.com/gallery3/var/resizes/album1/.thumb.jpg
- * photo: http://example.com/gallery3/var/albums/album1/photo.thumb.jpg
+ * Return the relative url to this item's thumb, with cache buster, eg:
+ * album: var/thumbs/Bobs%20Wedding/.album.jpg?m=1234567890
+ * photo: var/thumbs/Bobs%20Wedding/Eating-Cake.jpg?m=1234567890
+ * movie: var/thumbs/Bobs%20Wedding/First-Dance.mp4?m=1234567890
+ * If $full_uri==true, return the full url to this item's file, with cache buster, eg:
+ * album: http://example.com/gallery3/var/thumbs/Bobs%20Wedding/.album.jpg?m=1234567890
+ * photo: http://example.com/gallery3/var/thumbs/Bobs%20Wedding/Eating-Cake.jpg?m=1234567890
+ * movie: http://example.com/gallery3/var/thumbs/Bobs%20Wedding/First-Dance.mp4?m=1234567890
*/
public function thumb_url($full_uri=false) {
$cache_buster = $this->_cache_buster($this->thumb_path());
@@ -219,8 +238,11 @@ class Item_Model_Core extends ORM_MPTT {
}
/**
- * album: /var/resizes/album1/.resize.jpg
- * photo: /var/albums/album1/photo.resize.jpg
+ * Return the full path to this item's resize, eg:
+ * album: /usr/home/www/gallery3/var/resizes/Bobs Wedding/.album.jpg (*)
+ * photo: /usr/home/www/gallery3/var/resizes/Bobs Wedding/Eating-Cake.jpg
+ * movie: /usr/home/www/gallery3/var/resizes/Bobs Wedding/First-Dance.mp4 (*)
+ * (*) Since only photos have resizes, album and movie paths are fictitious.
*/
public function resize_path() {
return VARPATH . "resizes/" . urldecode($this->relative_path()) .
@@ -228,8 +250,15 @@ class Item_Model_Core extends ORM_MPTT {
}
/**
- * album: http://example.com/gallery3/var/resizes/album1/.resize.jpg
- * photo: http://example.com/gallery3/var/albums/album1/photo.resize.jpg
+ * Return the relative url to this item's resize, with cache buster, eg:
+ * album: var/resizes/Bobs%20Wedding/.album.jpg?m=1234567890 (*)
+ * photo: var/resizes/Bobs%20Wedding/Eating-Cake.jpg?m=1234567890
+ * movie: var/resizes/Bobs%20Wedding/First-Dance.mp4?m=1234567890 (*)
+ * If $full_uri==true, return the full url to this item's file, with cache buster, eg:
+ * album: http://example.com/gallery3/var/resizes/Bobs%20Wedding/.album.jpg?m=1234567890 (*)
+ * photo: http://example.com/gallery3/var/resizes/Bobs%20Wedding/Eating-Cake.jpg?m=1234567890
+ * movie: http://example.com/gallery3/var/resizes/Bobs%20Wedding/First-Dance.mp4?m=1234567890 (*)
+ * (*) Since only photos have resizes, album and movie urls are fictitious.
*/
public function resize_url($full_uri=false) {
$relative_path = "var/resizes/" . $this->relative_path();
@@ -318,9 +347,11 @@ class Item_Model_Core extends ORM_MPTT {
*/
public function save() {
$significant_changes = $this->changed;
- unset($significant_changes["view_count"]);
- unset($significant_changes["relative_url_cache"]);
- unset($significant_changes["relative_path_cache"]);
+ foreach (array("view_count", "relative_url_cache", "relative_path_cache",
+ "resize_width", "resize_height", "resize_dirty",
+ "thumb_width", "thumb_height", "thumb_dirty") as $key) {
+ unset($significant_changes[$key]);
+ }
if ((!empty($this->changed) && $significant_changes) || isset($this->data_file)) {
$this->updated = time();
@@ -334,35 +365,27 @@ class Item_Model_Core extends ORM_MPTT {
$this->weight = item::get_max_weight();
}
+ // Process the data file info.
+ if (isset($this->data_file)) {
+ $this->_process_data_file_info();
+ } else if (!$this->is_album()) {
+ // Unless it's an album, new items must have a data file.
+ $this->data_file_error = true;
+ }
+
// Make an url friendly slug from the name, if necessary
if (empty($this->slug)) {
$this->slug = item::convert_filename_to_slug(pathinfo($this->name, PATHINFO_FILENAME));
- // If the filename is all invalid characters, then the slug may be empty here. Pick a
- // random value.
+ // If the filename is all invalid characters, then the slug may be empty here. We set a
+ // generic name ("photo", "movie", or "album") based on its type, then rely on
+ // check_and_fix_conflicts to ensure it doesn't conflict with another name.
if (empty($this->slug)) {
- $this->slug = (string)rand(1000, 9999);
- }
- }
-
- // Get the width, height and mime type from our data file for photos and movies.
- if ($this->is_photo() || $this->is_movie()) {
- if ($this->is_photo()) {
- list ($this->width, $this->height, $this->mime_type, $extension) =
- photo::get_file_metadata($this->data_file);
- } else if ($this->is_movie()) {
- list ($this->width, $this->height, $this->mime_type, $extension) =
- movie::get_file_metadata($this->data_file);
- }
-
- // Force an extension onto the name if necessary
- $pi = pathinfo($this->data_file);
- if (empty($pi["extension"])) {
- $this->name = "{$this->name}.$extension";
+ $this->slug = $this->type;
}
}
- $this->_randomize_name_or_slug_on_conflict();
+ $this->_check_and_fix_conflicts();
parent::save();
@@ -382,16 +405,6 @@ class Item_Model_Core extends ORM_MPTT {
case "photo":
case "movie":
- // The thumb or resize may already exist in the case where a movie and a photo generate
- // a thumbnail of the same name (eg, foo.flv movie and foo.jpg photo will generate
- // foo.jpg thumbnail). If that happens, randomize and save again.
- if (file_exists($this->resize_path()) ||
- file_exists($this->thumb_path())) {
- $pi = pathinfo($this->name);
- $this->name = $pi["filename"] . "-" . random::int() . "." . $pi["extension"];
- parent::save();
- }
-
copy($this->data_file, $this->file_path());
break;
}
@@ -409,24 +422,28 @@ class Item_Model_Core extends ORM_MPTT {
// keep it around.
$original = ORM::factory("item", $this->id);
- // Preserve the extension of the data file. Many helpers, (e.g. ImageMagick), assume
+ // If we have a new data file, process its info. This will get its metadata and
+ // preserve the extension of the data file. Many helpers, (e.g. ImageMagick), assume
// the MIME type from the extension. So when we adopt the new data file, it's important
// to adopt the new extension. That ensures that the item's extension is always
// appropriate for its data. We don't try to preserve the name of the data file, though,
// because the name is typically a temporary randomly-generated name.
if (isset($this->data_file)) {
- $extension = pathinfo($this->data_file, PATHINFO_EXTENSION);
- $new_name = pathinfo($this->name, PATHINFO_FILENAME) . ".$extension";
- if (!empty($extension) && strcmp($this->name, $new_name)) {
- $this->name = $new_name;
- }
- if ($this->is_photo()) {
- list ($this->width, $this->height, $this->mime_type, $extension) =
- photo::get_file_metadata($this->data_file);
- } else if ($this->is_movie()) {
- list ($this->width, $this->height, $this->mime_type, $extension) =
- movie::get_file_metadata($this->data_file);
- }
+ $this->_process_data_file_info();
+ } else if (!$this->is_album() && array_key_exists("name", $this->changed)) {
+ // There's no new data file, but the name changed. If it's a photo or movie,
+ // make sure the new name still agrees with the file type.
+ $this->name = legal_file::sanitize_filename($this->name,
+ pathinfo($original->name, PATHINFO_EXTENSION), $this->type);
+ }
+
+ // If an album's cover has changed (or been removed), delete any existing album cover,
+ // reset the thumb metadata, and mark the thumb as dirty.
+ if (array_key_exists("album_cover_item_id", $this->changed) && $this->is_album()) {
+ @unlink($original->thumb_path());
+ $this->thumb_dirty = 1;
+ $this->thumb_height = 0;
+ $this->thumb_width = 0;
}
if (array_intersect($this->changed, array("parent_id", "name", "slug"))) {
@@ -435,7 +452,7 @@ class Item_Model_Core extends ORM_MPTT {
$this->relative_url_cache = null;
}
- $this->_randomize_name_or_slug_on_conflict();
+ $this->_check_and_fix_conflicts();
parent::save();
@@ -494,13 +511,6 @@ class Item_Model_Core extends ORM_MPTT {
// Replace the data file, if requested.
if ($this->data_file && ($this->is_photo() || $this->is_movie())) {
copy($this->data_file, $this->file_path());
-
- // Get the width, height and mime type from our data file for photos and movies.
- if ($this->is_photo()) {
- list ($this->width, $this->height) = photo::get_file_metadata($this->file_path());
- } else if ($this->is_movie()) {
- list ($this->width, $this->height) = movie::get_file_metadata($this->file_path());
- }
$this->thumb_dirty = 1;
$this->resize_dirty = 1;
}
@@ -528,30 +538,94 @@ class Item_Model_Core extends ORM_MPTT {
/**
* Check to see if there's another item that occupies the same name or slug that this item
- * intends to use, and if so choose a new name/slug while preserving the extension.
- * @todo Improve this. Random numbers are not user friendly
+ * intends to use, and if so choose a new name/slug while preserving the extension. Since this
+ * checks the name without its extension, it covers possible collisions with thumbs and resizes
+ * as well (e.g. between the thumbs of movie "foo.flv" and photo "foo.jpg").
*/
- private function _randomize_name_or_slug_on_conflict() {
- $base_name = pathinfo($this->name, PATHINFO_FILENAME);
- $base_ext = pathinfo($this->name, PATHINFO_EXTENSION);
- $base_slug = $this->slug;
- while (ORM::factory("item")
- ->where("parent_id", "=", $this->parent_id)
- ->where("id", $this->id ? "<>" : "IS NOT", $this->id)
- ->and_open()
- ->where("name", "=", $this->name)
- ->or_where("slug", "=", $this->slug)
- ->close()
- ->find()->id) {
- $rand = random::int();
- if ($base_ext) {
- $this->name = "$base_name-$rand.$base_ext";
+ private function _check_and_fix_conflicts() {
+ $suffix_num = 1;
+ $suffix = "";
+ if ($this->is_album()) {
+ while (db::build()
+ ->from("items")
+ ->where("parent_id", "=", $this->parent_id)
+ ->where("id", $this->id ? "<>" : "IS NOT", $this->id)
+ ->and_open()
+ ->where("name", "=", "{$this->name}{$suffix}")
+ ->or_where("slug", "=", "{$this->slug}{$suffix}")
+ ->close()
+ ->count_records()) {
+ $suffix = "-" . (($suffix_num <= 99) ? sprintf("%02d", $suffix_num++) : random::int());
+ }
+ if ($suffix) {
+ $this->name = "{$this->name}{$suffix}";
+ $this->slug = "{$this->slug}{$suffix}";
+ $this->relative_path_cache = null;
+ $this->relative_url_cache = null;
+ }
+ } else {
+ // Split the filename into its base and extension. This uses a regexp similar to
+ // legal_file::change_extension (which isn't always the same as pathinfo).
+ if (preg_match("/^(.*)(\.[^\.\/]*?)$/", $this->name, $matches)) {
+ $base_name = $matches[1];
+ $extension = $matches[2]; // includes a leading dot
} else {
- $this->name = "$base_name-$rand";
+ $base_name = $this->name;
+ $extension = "";
+ }
+ $base_name_escaped = Database::escape_for_like($base_name);
+ // Note: below query uses LIKE with wildcard % at end, which is still sargable (i.e. quick)
+ while (db::build()
+ ->from("items")
+ ->where("parent_id", "=", $this->parent_id)
+ ->where("id", $this->id ? "<>" : "IS NOT", $this->id)
+ ->and_open()
+ ->where("name", "LIKE", "{$base_name_escaped}{$suffix}.%")
+ ->or_where("slug", "=", "{$this->slug}{$suffix}")
+ ->close()
+ ->count_records()) {
+ $suffix = "-" . (($suffix_num <= 99) ? sprintf("%02d", $suffix_num++) : random::int());
+ }
+ if ($suffix) {
+ $this->name = "{$base_name}{$suffix}{$extension}";
+ $this->slug = "{$this->slug}{$suffix}";
+ $this->relative_path_cache = null;
+ $this->relative_url_cache = null;
}
- $this->slug = "$base_slug-$rand";
- $this->relative_path_cache = null;
- $this->relative_url_cache = null;
+ }
+ }
+
+ /**
+ * Process the data file info. Get its metadata and extension.
+ * If valid, use it to sanitize the item name and update the
+ * width, height, and mime type.
+ */
+ private function _process_data_file_info() {
+ try {
+ if ($this->is_photo()) {
+ list ($this->width, $this->height, $this->mime_type, $extension) =
+ photo::get_file_metadata($this->data_file);
+ } else if ($this->is_movie()) {
+ list ($this->width, $this->height, $this->mime_type, $extension) =
+ movie::get_file_metadata($this->data_file);
+ } else {
+ // Albums don't have data files.
+ $this->data_file = null;
+ return;
+ }
+
+ // Sanitize the name based on the idenified extension, but only set $this->name if different
+ // to ensure it isn't unnecessarily marked as "changed"
+ $name = legal_file::sanitize_filename($this->name, $extension, $this->type);
+ if ($this->name != $name) {
+ $this->name = $name;
+ }
+
+ // Data file valid - make sure the flag is reset to false.
+ $this->data_file_error = false;
+ } catch (Exception $e) {
+ // Data file invalid - set the flag so it's reported during item validation.
+ $this->data_file_error = true;
}
}
@@ -663,7 +737,7 @@ class Item_Model_Core extends ORM_MPTT {
}
/**
- * Return a view for movies. By default this is a Flowplayer v3 <script> tag, but
+ * Return a view for movies. By default this is a Flowplayer v3 <script> tag, but
* movie_img events can override this and provide their own player/view. If no player/view
* is found and the movie is unsupported by Flowplayer v3, this returns a simple download link.
* @param array $extra_attrs
@@ -675,12 +749,12 @@ class Item_Model_Core extends ORM_MPTT {
$height = $this->height;
if ($width == 0 || $height == 0) {
// Not set correctly, likely because ffmpeg isn't available. Making the window 0x0 causes the
- // video to be effectively unviewable. So, let's guess: set width to max_size and guess a
- // height (using 4:3 aspect ratio). Once the video metadata is loaded, js in
+ // video to be effectively unviewable. So, let's guess: set width to max_size and guess a
+ // height (using 4:3 aspect ratio). Once the video metadata is loaded, js in
// movieplayer.html.php will correct these values.
$width = $max_size;
$height = ceil($width * 3/4);
- }
+ }
$attrs = array_merge(array("id" => "g-item-id-{$this->id}"), $extra_attrs,
array("class" => "g-movie"));
@@ -858,27 +932,38 @@ class Item_Model_Core extends ORM_MPTT {
return;
}
- if ($this->is_photo()) {
- if (!in_array(strtolower($ext), legal_file::get_photo_extensions())) {
- $v->add_error("name", "illegal_data_file_extension");
- }
- }
-
- if ($this->is_movie()) {
- if (!in_array(strtolower($ext), legal_file::get_movie_extensions())) {
- $v->add_error("name", "illegal_data_file_extension");
- }
+ if ($this->is_photo() && !legal_file::get_photo_extensions($ext) ||
+ $this->is_movie() && !legal_file::get_movie_extensions($ext)) {
+ $v->add_error("name", "illegal_data_file_extension");
}
}
- if (db::build()
- ->from("items")
- ->where("parent_id", "=", $this->parent_id)
- ->where("name", "=", $this->name)
- ->merge_where($this->id ? array(array("id", "<>", $this->id)) : null)
- ->count_records()) {
- $v->add_error("name", "conflict");
- return;
+ if ($this->is_album()) {
+ if (db::build()
+ ->from("items")
+ ->where("parent_id", "=", $this->parent_id)
+ ->where("name", "=", $this->name)
+ ->merge_where($this->id ? array(array("id", "<>", $this->id)) : null)
+ ->count_records()) {
+ $v->add_error("name", "conflict");
+ return;
+ }
+ } else {
+ if (preg_match("/^(.*)(\.[^\.\/]*?)$/", $this->name, $matches)) {
+ $base_name = $matches[1];
+ } else {
+ $base_name = $this->name;
+ }
+ $base_name_escaped = Database::escape_for_like($base_name);
+ if (db::build()
+ ->from("items")
+ ->where("parent_id", "=", $this->parent_id)
+ ->where("name", "LIKE", "{$base_name_escaped}.%")
+ ->merge_where($this->id ? array(array("id", "<>", $this->id)) : null)
+ ->count_records()) {
+ $v->add_error("name", "conflict");
+ return;
+ }
}
if ($this->parent_id == 1 && Kohana::auto_load("{$this->slug}_Controller")) {
@@ -895,6 +980,8 @@ class Item_Model_Core extends ORM_MPTT {
$v->add_error("name", "bad_data_file_path");
} else if (filesize($this->data_file) == 0) {
$v->add_error("name", "empty_data_file");
+ } else if ($this->data_file_error) {
+ $v->add_error("name", "invalid_data_file");
}
}
@@ -934,10 +1021,12 @@ class Item_Model_Core extends ORM_MPTT {
return;
}
- if ($this->album_cover_item_id && db::build()
+ if ($this->album_cover_item_id && ($this->is_photo() || $this->is_movie() ||
+ db::build()
->from("items")
->where("id", "=", $this->album_cover_item_id)
- ->count_records() != 1) {
+ ->where("type", "<>", "album")
+ ->count_records() != 1)) {
$v->add_error("album_cover_item_id", "invalid_item");
}
}
@@ -1073,6 +1162,10 @@ class Item_Model_Core extends ORM_MPTT {
$data["can_edit"] = access::can("edit", $this);
}
+ if (empty($fields) || isset($fields["can_add"])) {
+ $data["can_add"] = access::can("add", $this);
+ }
+
// Elide some internal-only data that is going to cause confusion in the client.
foreach (array("relative_path_cache", "relative_url_cache", "left_ptr", "right_ptr",
"thumb_dirty", "resize_dirty", "weight") as $key) {
diff --git a/modules/gallery/models/log.php b/modules/gallery/models/log.php
index 013c1870..b01bcd29 100644
--- a/modules/gallery/models/log.php
+++ b/modules/gallery/models/log.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/message.php b/modules/gallery/models/message.php
index 034ddf03..0fa803d8 100644
--- a/modules/gallery/models/message.php
+++ b/modules/gallery/models/message.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/module.php b/modules/gallery/models/module.php
index 354e1568..0b2fb77f 100644
--- a/modules/gallery/models/module.php
+++ b/modules/gallery/models/module.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/outgoing_translation.php b/modules/gallery/models/outgoing_translation.php
index e0674202..66e2091d 100644
--- a/modules/gallery/models/outgoing_translation.php
+++ b/modules/gallery/models/outgoing_translation.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/permission.php b/modules/gallery/models/permission.php
index ca25f90e..26d1ee7c 100644
--- a/modules/gallery/models/permission.php
+++ b/modules/gallery/models/permission.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/task.php b/modules/gallery/models/task.php
index 56d20a8c..31332baa 100644
--- a/modules/gallery/models/task.php
+++ b/modules/gallery/models/task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/theme.php b/modules/gallery/models/theme.php
index 7fc4f99e..2e4d932a 100644
--- a/modules/gallery/models/theme.php
+++ b/modules/gallery/models/theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/models/var.php b/modules/gallery/models/var.php
index 4fef278d..7049e7da 100644
--- a/modules/gallery/models/var.php
+++ b/modules/gallery/models/var.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 64cad0a7..2383ec3c 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,7 +1,7 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 53
+version = 56
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:gallery"
-discuss_url = "http://gallery.menalto.com/forum_module_gallery"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:gallery"
+discuss_url = "http://galleryproject.org/forum_module_gallery"
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index df7de595..ffb62d98 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Albums_Controller_Test.php b/modules/gallery/tests/Albums_Controller_Test.php
index 625d9525..6fdc9df3 100644
--- a/modules/gallery/tests/Albums_Controller_Test.php
+++ b/modules/gallery/tests/Albums_Controller_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Breadcrumb_Test.php b/modules/gallery/tests/Breadcrumb_Test.php
index 65a853a8..b7667594 100644
--- a/modules/gallery/tests/Breadcrumb_Test.php
+++ b/modules/gallery/tests/Breadcrumb_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php
index ce91ebae..b1f56d7f 100644
--- a/modules/gallery/tests/Cache_Test.php
+++ b/modules/gallery/tests/Cache_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Controller_Auth_Test.php b/modules/gallery/tests/Controller_Auth_Test.php
index 5131fae0..e1ca0a7b 100644
--- a/modules/gallery/tests/Controller_Auth_Test.php
+++ b/modules/gallery/tests/Controller_Auth_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -20,8 +20,9 @@
class Controller_Auth_Test extends Gallery_Unit_Test_Case {
public function find_missing_auth_test() {
$found = array();
- $controllers = explode("\n", `git ls-files '*/*/controllers/*.php'`);
- $feeds = explode("\n", `git ls-files '*/*/helpers/*_rss.php'`);
+ $git_ignores = explode("\n", `git ls-files -o -i --exclude-standard`);
+ $controllers = array_diff(glob("*/*/controllers/*.php"), $git_ignores);
+ $feeds = array_diff(glob("*/*/helpers/*_rss.php"), $git_ignores);
foreach (array_merge($controllers, $feeds) as $controller) {
if (preg_match("{modules/(gallery_)?unit_test/}", $controller)) {
continue;
diff --git a/modules/gallery/tests/Data_Rest_Helper_Test.php b/modules/gallery/tests/Data_Rest_Helper_Test.php
new file mode 100644
index 00000000..e6a94864
--- /dev/null
+++ b/modules/gallery/tests/Data_Rest_Helper_Test.php
@@ -0,0 +1,111 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 Data_Rest_Helper_Test extends Gallery_Unit_Test_Case {
+ public function teardown() {
+ identity::set_active_user(identity::admin_user());
+ }
+
+ public function resolve_test() {
+ $photo = test::random_photo();
+ $resolved = rest::resolve(rest::url("data", $photo, 640));
+ $this->assert_equal($photo->id, $resolved->id);
+ }
+
+ public function resolve_needs_permission_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album->reload(); // new photo changed the album in the db
+
+ access::deny(identity::everybody(), "view", $album);
+ identity::set_active_user(identity::guest());
+
+ try {
+ data_rest::resolve($photo->id);
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ // pass
+ }
+ }
+
+ public function basic_get_test() {
+ $photo = test::random_photo();
+
+ $request = new stdClass();
+ $request->url = rest::url("data", $photo, "thumb");
+ $request->params = new stdClass();
+
+ $request->params->size = "thumb";
+ $this->assert_same($photo->thumb_path(), data_rest::get($request));
+
+ $request->params->size = "resize";
+ $this->assert_same($photo->resize_path(), data_rest::get($request));
+
+ $request->params->size = "full";
+ $this->assert_same($photo->file_path(), data_rest::get($request));
+ }
+
+ public function illegal_access_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album->reload();
+
+ access::deny(identity::everybody(), "view", $album);
+ identity::set_active_user(identity::guest());
+
+ $request = new stdClass();
+ $request->url = rest::url("data", $photo, "thumb");
+ $request->params = new stdClass();
+ $request->params->size = "thumb";
+
+ try {
+ data_rest::get($request);
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ // pass
+ }
+ }
+
+ public function missing_file_test() {
+ $photo = test::random_photo();
+
+ $request = new stdClass();
+ $request->url = rest::url("data", $photo, "thumb");
+ $request->params = new stdClass();
+ $request->params->size = "thumb";
+
+ unlink($photo->thumb_path()); // oops!
+
+ try {
+ data_rest::get($request);
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ // pass
+ }
+ }
+
+ public function cache_buster_test() {
+ $photo = test::random_photo();
+
+ $this->assert_same(
+ url::abs_site("rest/data/{$photo->id}?size=thumb&m=" . filemtime($photo->thumb_path())),
+ data_rest::url($photo, "thumb"));
+ }
+}
+
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php
index fa9e5370..106062f5 100644
--- a/modules/gallery/tests/Database_Test.php
+++ b/modules/gallery/tests/Database_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -147,6 +147,12 @@ class Database_Test extends Gallery_Unit_Test_Case {
$sql = str_replace("\n", " ", $sql);
$this->assert_same("UPDATE [test_tables] SET [name] = [Test Name] WHERE [1] = [1]", $sql);
}
+
+ function escape_for_like_test() {
+ // Note: literal double backslash is written as \\\
+ $this->assert_same('basic\_test', Database::escape_for_like("basic_test"));
+ $this->assert_same('\\\100\%\_test/', Database::escape_for_like('\100%_test/'));
+ }
}
class Database_Mock extends Database {
diff --git a/modules/gallery/tests/Dir_Helper_Test.php b/modules/gallery/tests/Dir_Helper_Test.php
index a9decb88..228b5c21 100644
--- a/modules/gallery/tests/Dir_Helper_Test.php
+++ b/modules/gallery/tests/Dir_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/DrawForm_Test.php b/modules/gallery/tests/DrawForm_Test.php
index 04163525..19177a3a 100644
--- a/modules/gallery/tests/DrawForm_Test.php
+++ b/modules/gallery/tests/DrawForm_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/File_Proxy_Controller_Test.php b/modules/gallery/tests/File_Proxy_Controller_Test.php
new file mode 100644
index 00000000..562100e4
--- /dev/null
+++ b/modules/gallery/tests/File_Proxy_Controller_Test.php
@@ -0,0 +1,130 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 File_Proxy_Controller_Test extends Gallery_Unit_Test_Case {
+ public function setup() {
+ $this->_save = array($_SERVER);
+ }
+
+ public function teardown() {
+ list($_SERVER) = $this->_save;
+ identity::set_active_user(identity::admin_user());
+ }
+
+ public function basic_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}");
+ $controller = new File_Proxy_Controller();
+ $this->assert_same($photo->file_path(), $controller->__call("", array()));
+ }
+
+ public function query_params_are_ignored_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}?a=1&b=2");
+ $controller = new File_Proxy_Controller();
+ $this->assert_same($photo->file_path(), $controller->__call("", array()));
+ }
+
+ public function file_must_be_in_var_test() {
+ $_SERVER["REQUEST_URI"] = url::file("index.php");
+ $controller = new File_Proxy_Controller();
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(1, $e->test_fail_code);
+ }
+ }
+
+ public function file_must_be_in_albums_thumbs_or_resizes_test() {
+ $_SERVER["REQUEST_URI"] = url::file("var/test/var/uploads/.htaccess");
+ $controller = new File_Proxy_Controller();
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(2, $e->test_fail_code);
+ }
+ }
+
+ public function movie_thumbnails_are_jpgs_test() {
+ $movie = test::random_movie();
+ $name = legal_file::change_extension($movie->name, "jpg");
+ $_SERVER["REQUEST_URI"] = url::file("var/thumbs/{$movie->name}");
+ $controller = new File_Proxy_Controller();
+ $this->assert_same($movie->thumb_path(), $controller->__call("", array()));
+ }
+
+ public function invalid_item_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/x_{$photo->name}");
+ $controller = new File_Proxy_Controller();
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(3, $e->test_fail_code);
+ }
+ }
+
+ public function need_view_full_permission_to_view_original_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album = $album->reload(); // adding the photo changed the album in the db
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}/{$photo->name}");
+ $controller = new File_Proxy_Controller();
+
+ access::deny(identity::everybody(), "view_full", $album);
+ identity::set_active_user(identity::guest());
+
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(5, $e->test_fail_code);
+ }
+ }
+
+ public function cant_proxy_an_album_test() {
+ $album = test::random_album();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}");
+ $controller = new File_Proxy_Controller();
+
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(6, $e->test_fail_code);
+ }
+ }
+
+ public function missing_file_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}");
+ unlink($photo->file_path());
+ $controller = new File_Proxy_Controller();
+
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(7, $e->test_fail_code);
+ }
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index 3d2079e5..ce75ea13 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -132,7 +132,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case {
"<?php defined(\"SYSPATH\") or die(\"No direct script access.\");",
"/**",
" * Gallery - a web based photo album viewer and editor",
- " * Copyright (C) 2000-2012 Bharat Mediratta",
+ " * Copyright (C) 2000-2013 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",
@@ -283,4 +283,52 @@ class File_Structure_Test extends Gallery_Unit_Test_Case {
$this->assert_true(false, $errors);
}
}
+
+ public function all_public_functions_in_test_files_end_in_test() {
+ // Who tests the tests? :-) (ref: http://www.xkcd.com/1163)
+ $dir = new PhpCodeFilterIterator(
+ new GalleryCodeFilterIterator(
+ new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator(DOCROOT))));
+ foreach ($dir as $file) {
+ $scan = 0;
+ if (basename(dirname($file)) == "tests") {
+ foreach (file($file) as $line) {
+ if (!substr($file, -9, 9) == "_Test.php") {
+ continue;
+ }
+
+ if (preg_match("/class.*extends.*Gallery_Unit_Test_Case/", $line)) {
+ $scan = 1;
+ } else if (preg_match("/class.*extends/", $line)) {
+ $scan = 0;
+ }
+
+ if ($scan) {
+ if (preg_match("/^\s*public\s+function/", $line)) {
+ $this->assert_true(
+ preg_match("/^\s*public\s+function (setup|teardown|.*_test)\(\) {/", $line),
+ "public functions must end in _test:\n$file\n$line\n");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public function no_extra_spaces_at_end_of_line_test() {
+ $dir = new GalleryCodeFilterIterator(
+ new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
+ $errors = "";
+ foreach ($dir as $file) {
+ if (preg_match("/\.(php|css|html|js)$/", $file)) {
+ foreach (file($file) as $line_num => $line) {
+ if ((substr($line, -2) == " \n") || (substr($line, -1) == " ")) {
+ $errors .= "$file at line " . ($line_num + 1) . "\n";
+ }
+ }
+ }
+ }
+ $this->assert_true(empty($errors), "Extra spaces at end of line found at:\n$errors");
+ }
}
diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php
index 73bc6284..6c2a6aa3 100644
--- a/modules/gallery/tests/Gallery_Filters.php
+++ b/modules/gallery/tests/Gallery_Filters.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -26,7 +26,7 @@ class PhpCodeFilterIterator extends FilterIterator {
class GalleryCodeFilterIterator extends FilterIterator {
public function accept() {
- // Skip anything that we didn"t write
+ // Skip anything that we didn't write
$path_name = $this->getInnerIterator()->getPathName();
$file_name = $this->getInnerIterator()->getFileName();
return !(
@@ -47,6 +47,10 @@ class GalleryCodeFilterIterator extends FilterIterator {
strpos($path_name, SYSPATH) !== false ||
strpos($path_name, MODPATH . "gallery/libraries/HTMLPurifier") !== false ||
strpos($path_name, MODPATH . "gallery/vendor/joomla") !== false ||
+ strpos($path_name, MODPATH . "organize/vendor/ext") !== false ||
+ strpos($path_name, DOCROOT . "lib") !== false ||
+ strpos($path_name, DOCROOT . "themes/admin_wind/css/themeroller") !== false ||
+ strpos($path_name, DOCROOT . "themes/wind/css/themeroller") !== false ||
substr($path_name, -1, 1) == "~");
}
}
diff --git a/modules/gallery/tests/Gallery_Graphics_Helper_Test.php b/modules/gallery/tests/Gallery_Graphics_Helper_Test.php
new file mode 100644
index 00000000..20096b23
--- /dev/null
+++ b/modules/gallery/tests/Gallery_Graphics_Helper_Test.php
@@ -0,0 +1,137 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 Gallery_Graphics_Helper_Test extends Gallery_Unit_Test_Case {
+ public function rotate_jpg_test() {
+ // Input is a 1024x768 jpg, output is rotated 90 degrees
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("degrees" => 90);
+ gallery_graphics::rotate($input_file, $output_file, $options, null);
+
+ // Output is rotated to 768x1024 jpg
+ $this->assert_equal(array(768, 1024, "image/jpeg", "jpg"), photo::get_file_metadata($output_file));
+ }
+
+ public function rotate_jpg_without_options_test() {
+ // Input is a 1024x768 jpg, output options undefined
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ gallery_graphics::rotate($input_file, $output_file, null, null);
+
+ // Output is not rotated, still a 1024x768 jpg
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"), photo::get_file_metadata($output_file));
+ }
+
+ public function rotate_bad_jpg_test() {
+ // Input is a garbled jpg, output is jpg autofit to 300x300
+ $input_file = TMPPATH . test::random_name() . ".jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("degrees" => 90);
+ file_put_contents($input_file, test::lorem_ipsum(200));
+
+ // Should get passed to Image library and throw an exception
+ try {
+ gallery_graphics::rotate($input_file, $output_file, $options, null);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function resize_jpg_test() {
+ // Input is a 1024x768 jpg, output is jpg autofit to 300x300
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("width" => 300, "height" => 300, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is resized to 300x225 jpg
+ $this->assert_equal(array(300, 225, "image/jpeg", "jpg"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_jpg_to_png_test() {
+ // Input is a 1024x768 jpg, output is png autofit to 300x300
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ $options = array("width" => 300, "height" => 300, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is resized to 300x225 png
+ $this->assert_equal(array(300, 225, "image/png", "png"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_jpg_with_no_upscale_test() {
+ // Input is a 1024x768 jpg, output is jpg autofit to 1200x1200 - should not upscale
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("width" => 1200, "height" => 1200, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is copied directly from input
+ $this->assert_equal(file_get_contents($input_file), file_get_contents($output_file));
+ }
+
+ public function resize_jpg_to_png_with_no_upscale_test() {
+ // Input is a 1024x768 jpg, output is png autofit to 1200x1200 - should not upscale
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ $options = array("width" => 1200, "height" => 1200, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is converted from input without resize
+ $this->assert_equal(array(1024, 768, "image/png", "png"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_jpg_without_options_test() {
+ // Input is a 1024x768 jpg, output is jpg without options - should not attempt resize
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ gallery_graphics::resize($input_file, $output_file, null, null);
+
+ // Output is copied directly from input
+ $this->assert_equal(file_get_contents($input_file), file_get_contents($output_file));
+ }
+
+ public function resize_jpg_to_png_without_options_test() {
+ // Input is a 1024x768 jpg, output is png without options - should not attempt resize
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ gallery_graphics::resize($input_file, $output_file, null, null);
+
+ // Output is converted from input without resize
+ $this->assert_equal(array(1024, 768, "image/png", "png"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_bad_jpg_test() {
+ // Input is a garbled jpg, output is jpg autofit to 300x300
+ $input_file = TMPPATH . test::random_name() . ".jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("width" => 300, "height" => 300, "master" => Image::AUTO);
+ file_put_contents($input_file, test::lorem_ipsum(200));
+
+ // Should get passed to Image library and throw an exception
+ try {
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/Gallery_I18n_Test.php b/modules/gallery/tests/Gallery_I18n_Test.php
index c54f324f..e255c4b9 100644
--- a/modules/gallery/tests/Gallery_I18n_Test.php
+++ b/modules/gallery/tests/Gallery_I18n_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php
index f5043fb0..0764a4fa 100644
--- a/modules/gallery/tests/Gallery_Installer_Test.php
+++ b/modules/gallery/tests/Gallery_Installer_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Graphics_Helper_Test.php b/modules/gallery/tests/Graphics_Helper_Test.php
new file mode 100644
index 00000000..2cf5caa7
--- /dev/null
+++ b/modules/gallery/tests/Graphics_Helper_Test.php
@@ -0,0 +1,158 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 Graphics_Helper_Test extends Gallery_Unit_Test_Case {
+ public function generate_photo_test() {
+ $photo = test::random_photo();
+ // Check that the images were correctly resized
+ $this->assert_equal(array(640, 480, "image/jpeg", "jpg"),
+ photo::get_file_metadata($photo->resize_path()));
+ $this->assert_equal(array(200, 150, "image/jpeg", "jpg"),
+ photo::get_file_metadata($photo->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(640, 480), array($photo->resize_width, $photo->resize_height));
+ $this->assert_equal(array(200, 150), array($photo->thumb_width, $photo->thumb_height));
+ // Check that the images are not marked dirty
+ $this->assert_equal(0, $photo->resize_dirty);
+ $this->assert_equal(0, $photo->thumb_dirty);
+ }
+
+ public function generate_movie_test() {
+ $movie = test::random_movie();
+ // Check that the image was correctly resized
+ $this->assert_equal(array(200, 160, "image/jpeg", "jpg"),
+ photo::get_file_metadata($movie->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(200, 160), array($movie->thumb_width, $movie->thumb_height));
+ // Check that the image is not marked dirty
+ $this->assert_equal(0, $movie->thumb_dirty);
+ }
+
+ public function generate_album_cover_test() {
+ $album = test::random_album();
+ $photo = test::random_unique_photo($album);
+ $album->reload();
+ // Check that the image was copied directly from item thumb
+ $this->assert_equal(file_get_contents($photo->thumb_path()),
+ file_get_contents($album->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(200, 150), array($album->thumb_width, $album->thumb_height));
+ // Check that the image is not marked dirty
+ $this->assert_equal(0, $album->thumb_dirty);
+ }
+
+ public function generate_album_cover_from_png_test() {
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ gallery_graphics::resize($input_file, $output_file, null, null);
+
+ $album = test::random_album();
+ $photo = test::random_photo_unsaved($album);
+ $photo->set_data_file($output_file);
+ $photo->name = "album_cover_from_png.png";
+ $photo->save();
+ $album->reload();
+ // Check that the image was correctly resized and converted to jpg
+ $this->assert_equal(array(200, 150, "image/jpeg", "jpg"),
+ photo::get_file_metadata($album->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(200, 150), array($album->thumb_width, $album->thumb_height));
+ // Check that the image is not marked dirty
+ $this->assert_equal(0, $album->thumb_dirty);
+ }
+
+ public function generate_album_cover_for_empty_album_test() {
+ $album = test::random_album();
+ // Check that the album cover is the missing image placeholder
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_album_cover.jpg"),
+ file_get_contents($album->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($album->thumb_width, $album->thumb_height));
+ // Check that the image is *not* marked as dirty
+ $this->assert_equal(0, $album->thumb_dirty);
+ }
+
+ public function generate_bad_photo_test() {
+ $photo = test::random_photo();
+ // At this point, the photo is valid and has a valid resize and thumb. Make it garble.
+ file_put_contents($photo->file_path(), test::lorem_ipsum(200));
+ // Regenerate
+ $photo->resize_dirty = 1;
+ $photo->thumb_dirty = 1;
+ try {
+ graphics::generate($photo);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // Exception expected
+ }
+ // Check that the images got replaced with missing image placeholders
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_photo.jpg"),
+ file_get_contents($photo->resize_path()));
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_photo.jpg"),
+ file_get_contents($photo->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($photo->resize_width, $photo->resize_height));
+ $this->assert_equal(array(200, 200), array($photo->thumb_width, $photo->thumb_height));
+ // Check that the images are marked as dirty
+ $this->assert_equal(1, $photo->resize_dirty);
+ $this->assert_equal(1, $photo->thumb_dirty);
+ }
+
+ public function generate_bad_movie_test() {
+ // Unlike photos, its ok to have missing movies - no thrown exceptions, thumb_dirty can be reset.
+ $movie = test::random_movie();
+ // At this point, the movie is valid and has a valid thumb. Make it garble.
+ file_put_contents($movie->file_path(), test::lorem_ipsum(200));
+ // Regenerate
+ $movie->thumb_dirty = 1;
+ graphics::generate($movie);
+ // Check that the image got replaced with a missing image placeholder
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_movie.jpg"),
+ file_get_contents($movie->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($movie->thumb_width, $movie->thumb_height));
+ // Check that the image is *not* marked as dirty
+ $this->assert_equal(0, $movie->thumb_dirty);
+ }
+
+ public function generate_album_cover_from_bad_photo_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album->reload();
+ // At this point, the photo is valid and has a valid resize and thumb. Make it garble.
+ file_put_contents($photo->file_path(), test::lorem_ipsum(200));
+ // Regenerate album from garbled photo.
+ $photo->thumb_dirty = 1;
+ $photo->save();
+ $album->thumb_dirty = 1;
+ try {
+ graphics::generate($album);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // Exception expected
+ }
+ // Check that the image got replaced with a missing image placeholder
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_photo.jpg"),
+ file_get_contents($album->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($album->thumb_width, $album->thumb_height));
+ // Check that the images are marked as dirty
+ $this->assert_equal(1, $album->thumb_dirty);
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/Html_Helper_Test.php b/modules/gallery/tests/Html_Helper_Test.php
index 09168e41..476faa5a 100644
--- a/modules/gallery/tests/Html_Helper_Test.php
+++ b/modules/gallery/tests/Html_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Input_Library_Test.php b/modules/gallery/tests/Input_Library_Test.php
index 135c6647..039644ad 100644
--- a/modules/gallery/tests/Input_Library_Test.php
+++ b/modules/gallery/tests/Input_Library_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 818c9a73..f5b99bec 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -235,4 +235,22 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$level3b->id,
item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
}
+
+ public function resequence_child_weights_test() {
+ $album = test::random_album_unsaved();
+ $album->sort_column = "id";
+ $album->save();
+
+ $photo1 = test::random_photo($album);
+ $photo2 = test::random_photo($album);
+ $this->assert_true($photo2->weight > $photo1->weight);
+
+ $album->reload();
+ $album->sort_order = "DESC";
+ $album->save();
+ item::resequence_child_weights($album);
+
+ $this->assert_equal(2, $photo1->reload()->weight);
+ $this->assert_equal(1, $photo2->reload()->weight);
+ }
}
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 8ae8a5dd..fcb5c2ad 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -66,12 +66,12 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
}
public function rename_photo_test() {
- $item = test::random_photo();
+ $item = test::random_unique_photo();
$original_name = $item->name;
- file_put_contents($item->thumb_path(), "thumb");
- file_put_contents($item->resize_path(), "resize");
- file_put_contents($item->file_path(), "file");
+ $thumb_file = file_get_contents($item->thumb_path());
+ $resize_file = file_get_contents($item->resize_path());
+ $fullsize_file = file_get_contents($item->file_path());
// Now rename it
$item->name = ($new_name = test::random_name($item));
@@ -82,19 +82,19 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_equal($new_name, basename($item->file_path()));
$this->assert_equal($new_name, basename($item->thumb_path()));
$this->assert_equal($new_name, basename($item->resize_path()));
- $this->assert_equal("thumb", file_get_contents($item->thumb_path()));
- $this->assert_equal("resize", file_get_contents($item->resize_path()));
- $this->assert_equal("file", file_get_contents($item->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($item->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($item->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($item->file_path()));
}
public function rename_album_test() {
$album = test::random_album();
- $photo = test::random_photo($album);
+ $photo = test::random_unique_photo($album);
$album->reload();
- file_put_contents($photo->thumb_path(), "thumb");
- file_put_contents($photo->resize_path(), "resize");
- file_put_contents($photo->file_path(), "file");
+ $thumb_file = file_get_contents($photo->thumb_path());
+ $resize_file = file_get_contents($photo->resize_path());
+ $fullsize_file = file_get_contents($photo->file_path());
$original_album_name = $album->name;
$original_photo_name = $photo->name;
@@ -119,44 +119,26 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(test::starts_with($photo->thumb_path(), dirname($album->thumb_path())));
$this->assert_true(test::starts_with($photo->resize_path(), dirname($album->resize_path())));
- $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
- $this->assert_equal("resize", file_get_contents($photo->resize_path()));
- $this->assert_equal("file", file_get_contents($photo->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($photo->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($photo->file_path()));
}
public function item_rename_wont_accept_slash_test() {
$item = test::random_photo();
- try {
- $item->name = test::random_name() . "/";
- $item->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_equal(array("name" => "no_slashes"), $e->validation->errors());
- return;
- }
- $this->assert_true(false, "Shouldn't get here");
- }
-
- public function item_rename_over_existing_name_gets_uniqified_test() {
- // Create a test photo
- $item = test::random_photo();
- $item2 = test::random_photo();
-
- $item->name = $item2->name;
+ $item->name = "/no_slashes/allowed/";
$item->save();
-
- // foo.jpg should become foo-####.jpg
- $this->assert_true(
- preg_match("/" . str_replace(".jpg", "", $item2->name) . "-\d+\.jpg/", $item->name));
+ $this->assert_equal("no_slashes_allowed.jpg", $item->name);
}
public function move_album_test() {
$album2 = test::random_album();
$album1 = test::random_album($album2);
- $photo = test::random_photo($album1);
+ $photo = test::random_unique_photo($album1);
- file_put_contents($photo->thumb_path(), "thumb");
- file_put_contents($photo->resize_path(), "resize");
- file_put_contents($photo->file_path(), "file");
+ $thumb_file = file_get_contents($photo->thumb_path());
+ $resize_file = file_get_contents($photo->resize_path());
+ $fullsize_file = file_get_contents($photo->file_path());
// Now move the album
$album1->parent_id = item::root()->id;
@@ -173,20 +155,20 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(test::starts_with($photo->thumb_path(), dirname($album1->thumb_path())));
$this->assert_true(test::starts_with($photo->resize_path(), dirname($album1->resize_path())));
- $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
- $this->assert_equal("resize", file_get_contents($photo->resize_path()));
- $this->assert_equal("file", file_get_contents($photo->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($photo->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($photo->file_path()));
}
public function move_photo_test() {
$album1 = test::random_album();
- $photo = test::random_photo($album1);
+ $photo = test::random_unique_photo($album1);
$album2 = test::random_album();
- file_put_contents($photo->thumb_path(), "thumb");
- file_put_contents($photo->resize_path(), "resize");
- file_put_contents($photo->file_path(), "file");
+ $thumb_file = file_get_contents($photo->thumb_path());
+ $resize_file = file_get_contents($photo->resize_path());
+ $fullsize_file = file_get_contents($photo->file_path());
// Now move the photo
$photo->parent_id = $album2->id;
@@ -200,12 +182,12 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(test::starts_with($photo->thumb_path(), dirname($album2->thumb_path())));
$this->assert_true(test::starts_with($photo->resize_path(), dirname($album2->resize_path())));
- $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
- $this->assert_equal("resize", file_get_contents($photo->resize_path()));
- $this->assert_equal("file", file_get_contents($photo->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($photo->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($photo->file_path()));
}
- public function move_album_with_conflicting_target_gets_uniqified_test() {
+ public function move_album_with_conflicting_target_gets_uniquified_test() {
$album = test::random_album();
$source = test::random_album_unsaved($album);
$source->name = $album->name;
@@ -217,9 +199,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$source->parent_id = item::root()->id;
$source->save();
- // foo should become foo-####
- $this->assert_true(preg_match("/{$album->name}-\d+/", $source->name));
- $this->assert_true(preg_match("/{$album->slug}-\d+/", $source->slug));
+ // foo should become foo-01
+ $this->assert_same("{$album->name}-01", $source->name);
+ $this->assert_same("{$album->slug}-01", $source->slug);
}
public function move_album_fails_wrong_target_type_test() {
@@ -239,7 +221,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(false, "Shouldn't get here");
}
- public function move_photo_with_conflicting_target_gets_uniqified_test() {
+ public function move_photo_with_conflicting_target_gets_uniquified_test() {
$photo1 = test::random_photo();
$album = test::random_album();
$photo2 = test::random_photo_unsaved($album);
@@ -247,17 +229,16 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$photo2->save();
// $photo1 and $photo2 have the same name, so if we move $photo1 into the root they should
- // conflict and get uniqified.
+ // conflict and get uniquified.
$photo2->parent_id = item::root()->id;
$photo2->save();
- // foo.jpg should become foo-####.jpg
- $this->assert_true(
- preg_match("/" . str_replace(".jpg", "", $photo1->name) . "-\d+\.jpg/", $photo2->name));
+ // foo.jpg should become foo-01.jpg
+ $this->assert_same(pathinfo($photo1->name, PATHINFO_FILENAME) . "-01.jpg", $photo2->name);
- // foo should become foo
- $this->assert_true(preg_match("/{$photo1->slug}/", $photo2->name));
+ // foo should become foo-01
+ $this->assert_same("{$photo1->slug}-01", $photo2->slug);
}
public function move_album_inside_descendent_fails_test() {
@@ -342,30 +323,17 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
}
public function photo_files_must_have_an_extension_test() {
- try {
- $photo = test::random_photo_unsaved();
- $photo->mime_type = "image/jpeg";
- $photo->name = "no_extension";
- $photo->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_same(array("name" => "illegal_data_file_extension"), $e->validation->errors());
- return; // pass
- }
- $this->assert_true(false, "Shouldn't get here");
+ $photo = test::random_photo_unsaved();
+ $photo->name = "no_extension_photo";
+ $photo->save();
+ $this->assert_equal("no_extension_photo.jpg", $photo->name);
}
public function movie_files_must_have_an_extension_test() {
- try {
- $movie = test::random_photo_unsaved();
- $movie->type = "movie";
- $movie->mime_type = "video/x-flv";
- $movie->name = "no_extension";
- $movie->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_same(array("name" => "illegal_data_file_extension"), $e->validation->errors());
- return; // pass
- }
- $this->assert_true(false, "Shouldn't get here");
+ $movie = test::random_movie_unsaved();
+ $movie->name = "no_extension_movie";
+ $movie->save();
+ $this->assert_equal("no_extension_movie.flv", $movie->name);
}
public function cant_delete_root_album_test() {
@@ -399,7 +367,16 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_false($response["can_edit"]);
}
- public function first_photo_becomes_album_cover() {
+ public function as_restful_array_with_add_bit_test() {
+ $response = item::root()->as_restful_array();
+ $this->assert_true($response["can_add"]);
+
+ identity::set_active_user(identity::guest());
+ $response = item::root()->as_restful_array();
+ $this->assert_false($response["can_add"]);
+ }
+
+ public function first_photo_becomes_album_cover_test() {
$album = test::random_album();
$photo = test::random_photo($album);
$album->reload();
@@ -450,8 +427,21 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$photo->set_data_file(MODPATH . "gallery/tests/Item_Model_Test.php");
$photo->save();
} catch (ORM_Validation_Exception $e) {
- $this->assert_same(array("mime_type" => "invalid", "name" => "illegal_data_file_extension"),
- $e->validation->errors());
+ $this->assert_same(array("name" => "invalid_data_file"), $e->validation->errors());
+ return; // pass
+ }
+ $this->assert_true(false, "Shouldn't get here");
+ }
+
+ public function unsafe_data_file_replacement_with_valid_extension_test() {
+ $temp_file = TMPPATH . "masquerading_php.jpg";
+ copy(MODPATH . "gallery/tests/Item_Model_Test.php", $temp_file);
+ try {
+ $photo = test::random_photo();
+ $photo->set_data_file($temp_file);
+ $photo->save();
+ } catch (ORM_Validation_Exception $e) {
+ $this->assert_same(array("name" => "invalid_data_file"), $e->validation->errors());
return; // pass
}
$this->assert_true(false, "Shouldn't get here");
@@ -469,55 +459,72 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
preg_match("|http://./var/albums/name_\w+\.jpg\?m=\d+|", $photo->file_url()),
$photo->file_url() . " is malformed");
- // Albums have special thumbnails. Empty album has cachebuster of 0 since it has no thumbnail
$album = test::random_album();
$this->assert_true(
- preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=0|", $album->thumb_url()),
+ preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=\d+|", $album->thumb_url()),
$album->thumb_url() . " is malformed");
$photo = test::random_photo($album);
$this->assert_true(
preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=\d+|", $album->thumb_url()),
$album->thumb_url() . " is malformed");
+
+ // If the file does not exist, we should return a cache buster of m=0.
+ unlink($album->thumb_path());
+ $this->assert_true(
+ preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=0|", $album->thumb_url()),
+ $album->thumb_url() . " is malformed");
}
- public function legal_extension_test() {
- foreach (array("test.gif", "test.GIF", "test.Gif", "test.jpeg", "test.JPG") as $name) {
+ public function legal_extension_that_does_match_gets_used_test() {
+ foreach (array("jpg", "JPG", "Jpg", "jpeg") as $extension) {
$photo = test::random_photo_unsaved(item::root());
- $photo->name = $name;
+ $photo->name = test::random_name() . ".{$extension}";
$photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal($extension, pathinfo($photo->name, PATHINFO_EXTENSION));
}
}
public function illegal_extension_test() {
foreach (array("test.php", "test.PHP", "test.php5", "test.php4",
"test.pl", "test.php.png") as $name) {
- try {
- $photo = test::random_photo_unsaved(item::root());
- $photo->name = $name;
- $photo->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_equal(array("name" => "illegal_data_file_extension"),
- $e->validation->errors());
- continue;
- }
- $this->assert_true(false, "Shouldn't get here");
+ $photo = test::random_photo_unsaved(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
}
}
public function cant_rename_to_illegal_extension_test() {
foreach (array("test.php.test", "test.php", "test.PHP",
"test.php5", "test.php4", "test.pl") as $name) {
- try {
- $photo = test::random_photo(item::root());
- $photo->name = $name;
- $photo->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_equal(array("name" => "illegal_data_file_extension"),
- $e->validation->errors());
- continue;
- }
- $this->assert_true(false, "Shouldn't get here");
+ $photo = test::random_photo(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
+ }
+ }
+
+ public function legal_extension_that_doesnt_match_gets_fixed_test() {
+ foreach (array("test.png", "test.mp4", "test.GIF") as $name) {
+ $photo = test::random_photo_unsaved(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
+ }
+ }
+
+ public function rename_to_legal_extension_that_doesnt_match_gets_fixed_test() {
+ foreach (array("test.png", "test.mp4", "test.GIF") as $name) {
+ $photo = test::random_photo(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
}
}
@@ -526,4 +533,164 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$album->name = $album->name . ".foo.bar";
$album->save();
}
+
+ public function no_conflict_when_parents_different_test() {
+ $parent1 = test::random_album();
+ $parent2 = test::random_album();
+ $photo1 = test::random_photo($parent1);
+ $photo2 = test::random_photo($parent2);
+
+ $photo2->name = $photo1->name;
+ $photo2->slug = $photo1->slug;
+ $photo2->save();
+
+ // photo2 has same name and slug as photo1 but different parent - no conflict.
+ $this->assert_same($photo1->name, $photo2->name);
+ $this->assert_same($photo1->slug, $photo2->slug);
+ }
+
+ public function fix_conflict_when_names_identical_test() {
+ $parent = test::random_album();
+ $photo1 = test::random_photo($parent);
+ $photo2 = test::random_photo($parent);
+
+ $photo1_orig_base = pathinfo($photo1->name, PATHINFO_FILENAME);
+ $photo2_orig_slug = $photo2->slug;
+
+ $photo2->name = $photo1->name;
+ $photo2->save();
+
+ // photo2 has same name as photo1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo1_orig_base}-01.jpg", $photo2->name);
+ $this->assert_same("{$photo2_orig_slug}-01", $photo2->slug);
+ }
+
+ public function fix_conflict_when_slugs_identical_test() {
+ $parent = test::random_album();
+ $photo1 = test::random_photo($parent);
+ $photo2 = test::random_photo($parent);
+
+ $photo2_orig_base = pathinfo($photo2->name, PATHINFO_FILENAME);
+
+ $photo2->slug = $photo1->slug;
+ $photo2->save();
+
+ // photo2 has same slug as photo1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo2_orig_base}-01.jpg", $photo2->name);
+ $this->assert_same("{$photo1->slug}-01", $photo2->slug);
+ }
+
+ public function no_conflict_when_parents_different_for_albums_test() {
+ $parent1 = test::random_album();
+ $parent2 = test::random_album();
+ $album1 = test::random_album($parent1);
+ $album2 = test::random_album($parent2);
+
+ $album2->name = $album1->name;
+ $album2->slug = $album1->slug;
+ $album2->save();
+
+ // album2 has same name and slug as album1 but different parent - no conflict.
+ $this->assert_same($album1->name, $album2->name);
+ $this->assert_same($album1->slug, $album2->slug);
+ }
+
+ public function fix_conflict_when_names_identical_for_albums_test() {
+ $parent = test::random_album();
+ $album1 = test::random_album($parent);
+ $album2 = test::random_album($parent);
+
+ $album2_orig_slug = $album2->slug;
+
+ $album2->name = $album1->name;
+ $album2->save();
+
+ // album2 has same name as album1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$album1->name}-01", $album2->name);
+ $this->assert_same("{$album2_orig_slug}-01", $album2->slug);
+ }
+
+ public function fix_conflict_when_slugs_identical_for_albums_test() {
+ $parent = test::random_album();
+ $album1 = test::random_album($parent);
+ $album2 = test::random_album($parent);
+
+ $album2_orig_name = $album2->name;
+
+ $album2->slug = $album1->slug;
+ $album2->save();
+
+ // album2 has same slug as album1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$album2_orig_name}-01", $album2->name);
+ $this->assert_same("{$album1->slug}-01", $album2->slug);
+ }
+
+ public function no_conflict_when_base_names_identical_between_album_and_photo_test() {
+ $parent = test::random_album();
+ $album = test::random_album($parent);
+ $photo = test::random_photo($parent);
+
+ $photo_orig_slug = $photo->slug;
+
+ $photo->name = "{$album->name}.jpg";
+ $photo->save();
+
+ // photo has same base name as album - no conflict.
+ $this->assert_same("{$album->name}.jpg", $photo->name);
+ $this->assert_same($photo_orig_slug, $photo->slug);
+ }
+
+ public function fix_conflict_when_full_names_identical_between_album_and_photo_test() {
+ $parent = test::random_album();
+ $photo = test::random_photo($parent);
+ $album = test::random_album($parent);
+
+ $album_orig_slug = $album->slug;
+
+ $album->name = $photo->name;
+ $album->save();
+
+ // album has same full name as album - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo->name}-01", $album->name);
+ $this->assert_same("{$album_orig_slug}-01", $album->slug);
+ }
+
+ public function fix_conflict_when_slugs_identical_between_album_and_photo_test() {
+ $parent = test::random_album();
+ $album = test::random_album($parent);
+ $photo = test::random_photo($parent);
+
+ $photo_orig_base = pathinfo($photo->name, PATHINFO_FILENAME);
+
+ $photo->slug = $album->slug;
+ $photo->save();
+
+ // photo has same slug as album - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo_orig_base}-01.jpg", $photo->name);
+ $this->assert_same("{$album->slug}-01", $photo->slug);
+ }
+
+ public function fix_conflict_when_base_names_identical_between_jpg_png_flv_test() {
+ $parent = test::random_album();
+ $item1 = test::random_photo($parent);
+ $item2 = test::random_photo($parent);
+ $item3 = test::random_movie($parent);
+
+ $item1_orig_base = pathinfo($item1->name, PATHINFO_FILENAME);
+ $item2_orig_slug = $item2->slug;
+ $item3_orig_slug = $item3->slug;
+
+ $item2->set_data_file(MODPATH . "gallery/images/graphicsmagick.png");
+ $item2->name = "{$item1_orig_base}.png";
+ $item2->save();
+
+ $item3->name = "{$item1_orig_base}.flv";
+ $item3->save();
+
+ // item2 and item3 have same base name as item1 - conflict resolved by renaming with -01 and -02.
+ $this->assert_same("{$item1_orig_base}-01.png", $item2->name);
+ $this->assert_same("{$item2_orig_slug}-01", $item2->slug);
+ $this->assert_same("{$item1_orig_base}-02.flv", $item3->name);
+ $this->assert_same("{$item3_orig_slug}-02", $item3->slug);
+ }
}
diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php
index 376f5c81..1823420b 100644
--- a/modules/gallery/tests/Item_Rest_Helper_Test.php
+++ b/modules/gallery/tests/Item_Rest_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php
index a719db70..9d8ee8a5 100644
--- a/modules/gallery/tests/Items_Rest_Helper_Test.php
+++ b/modules/gallery/tests/Items_Rest_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Kohana_Exception_Test.php b/modules/gallery/tests/Kohana_Exception_Test.php
index f8a89c0f..4836d0dd 100644
--- a/modules/gallery/tests/Kohana_Exception_Test.php
+++ b/modules/gallery/tests/Kohana_Exception_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php
index d80bcafe..7ed5214b 100644
--- a/modules/gallery/tests/Legal_File_Helper_Test.php
+++ b/modules/gallery/tests/Legal_File_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -18,6 +18,85 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Legal_File_Helper_Test extends Gallery_Unit_Test_Case {
+ public function get_photo_types_by_extension_test() {
+ $this->assert_equal("image/jpeg", legal_file::get_photo_types_by_extension("jpg")); // regular
+ $this->assert_equal("image/jpeg", legal_file::get_photo_types_by_extension("JPG")); // all caps
+ $this->assert_equal("image/png", legal_file::get_photo_types_by_extension("Png")); // some caps
+ $this->assert_equal(null, legal_file::get_photo_types_by_extension("php")); // invalid
+ $this->assert_equal(null, legal_file::get_photo_types_by_extension("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(4, count(legal_file::get_photo_types_by_extension()));
+ }
+
+ public function get_movie_types_by_extension_test() {
+ $this->assert_equal("video/x-flv", legal_file::get_movie_types_by_extension("flv")); // regular
+ $this->assert_equal("video/x-flv", legal_file::get_movie_types_by_extension("FLV")); // all caps
+ $this->assert_equal("video/mp4", legal_file::get_movie_types_by_extension("Mp4")); // some caps
+ $this->assert_equal(null, legal_file::get_movie_types_by_extension("php")); // invalid
+ $this->assert_equal(null, legal_file::get_movie_types_by_extension("php.flv")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(3, count(legal_file::get_movie_types_by_extension()));
+ }
+
+ public function get_types_by_extension_test() {
+ $this->assert_equal("image/jpeg", legal_file::get_types_by_extension("jpg")); // photo
+ $this->assert_equal("video/x-flv", legal_file::get_types_by_extension("FLV")); // movie
+ $this->assert_equal(null, legal_file::get_types_by_extension("php")); // invalid
+ $this->assert_equal(null, legal_file::get_types_by_extension("php.flv")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(7, count(legal_file::get_types_by_extension()));
+ }
+
+ public function get_photo_extensions_test() {
+ $this->assert_equal(true, legal_file::get_photo_extensions("jpg")); // regular
+ $this->assert_equal(true, legal_file::get_photo_extensions("JPG")); // all caps
+ $this->assert_equal(true, legal_file::get_photo_extensions("Png")); // some caps
+ $this->assert_equal(false, legal_file::get_photo_extensions("php")); // invalid
+ $this->assert_equal(false, legal_file::get_photo_extensions("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(4, count(legal_file::get_photo_extensions()));
+ }
+
+ public function get_movie_extensions_test() {
+ $this->assert_equal(true, legal_file::get_movie_extensions("flv")); // regular
+ $this->assert_equal(true, legal_file::get_movie_extensions("FLV")); // all caps
+ $this->assert_equal(true, legal_file::get_movie_extensions("Mp4")); // some caps
+ $this->assert_equal(false, legal_file::get_movie_extensions("php")); // invalid
+ $this->assert_equal(false, legal_file::get_movie_extensions("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(3, count(legal_file::get_movie_extensions()));
+ }
+
+ public function get_extensions_test() {
+ $this->assert_equal(true, legal_file::get_extensions("jpg")); // photo
+ $this->assert_equal(true, legal_file::get_extensions("FLV")); // movie
+ $this->assert_equal(false, legal_file::get_extensions("php")); // invalid
+ $this->assert_equal(false, legal_file::get_extensions("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(7, count(legal_file::get_extensions()));
+ }
+
+ public function get_filters_test() {
+ // All 7 extensions both uppercase and lowercase
+ $this->assert_equal(14, count(legal_file::get_filters()));
+ }
+
+ public function get_photo_types_test() {
+ // Note that this is one *less* than photo extensions since jpeg and jpg have the same mime.
+ $this->assert_equal(3, count(legal_file::get_photo_types()));
+ }
+
+ public function get_movie_types_test() {
+ // Note that this is one *more* than movie extensions since video/flv is added.
+ $this->assert_equal(4, count(legal_file::get_movie_types()));
+ }
+
public function change_extension_test() {
$this->assert_equal("foo.jpg", legal_file::change_extension("foo.png", "jpg"));
}
@@ -36,13 +115,83 @@ class Legal_File_Helper_Test extends Gallery_Unit_Test_Case {
legal_file::change_extension("/website/foo.com/VID_20120513_105421.mp4", "jpg"));
}
+ public function change_extension_path_containing_dots_and_no_extension_test() {
+ $this->assert_equal(
+ "/website/foo.com/VID_20120513_105421.jpg",
+ legal_file::change_extension("/website/foo.com/VID_20120513_105421", "jpg"));
+ }
+
+ public function change_extension_path_containing_dots_and_dot_extension_test() {
+ $this->assert_equal(
+ "/website/foo.com/VID_20120513_105421.jpg",
+ legal_file::change_extension("/website/foo.com/VID_20120513_105421.", "jpg"));
+ }
+
+ public function change_extension_path_containing_dots_and_non_standard_chars_test() {
+ $this->assert_equal(
+ "/j'écris@un#nom/bizarre(mais quand.même/ça_passe.jpg",
+ legal_file::change_extension("/j'écris@un#nom/bizarre(mais quand.même/ça_passe.\$ÇÀ@€#_", "jpg"));
+ }
+
public function smash_extensions_test() {
$this->assert_equal("foo_bar.jpg", legal_file::smash_extensions("foo.bar.jpg"));
$this->assert_equal("foo_bar_baz.jpg", legal_file::smash_extensions("foo.bar.baz.jpg"));
- $this->assert_equal("foo_bar_baz.jpg", legal_file::smash_extensions("foo.bar.baz.jpg"));
$this->assert_equal("foo_bar_baz.jpg", legal_file::smash_extensions("...foo...bar..baz...jpg"));
$this->assert_equal("/path/to/foo_bar.jpg", legal_file::smash_extensions("/path/to/foo.bar.jpg"));
$this->assert_equal("/path/to.to/foo_bar.jpg", legal_file::smash_extensions("/path/to.to/foo.bar.jpg"));
$this->assert_equal("foo_bar-12345678.jpg", legal_file::smash_extensions("foo.bar-12345678.jpg"));
}
+
+ public function smash_extensions_pass_thru_names_without_extensions_test() {
+ $this->assert_equal("foo", legal_file::smash_extensions("foo"));
+ $this->assert_equal("foo.", legal_file::smash_extensions("foo."));
+ $this->assert_equal(".foo", legal_file::smash_extensions(".foo"));
+ $this->assert_equal(".", legal_file::smash_extensions("."));
+ $this->assert_equal("", legal_file::smash_extensions(""));
+ $this->assert_equal(null, legal_file::smash_extensions(null));
+ }
+
+ public function sanitize_filename_with_no_rename_test() {
+ $this->assert_equal("foo.jpeg", legal_file::sanitize_filename("foo.jpeg", "jpg", "photo"));
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo.jpg", "jpeg", "photo"));
+ $this->assert_equal("foo.MP4", legal_file::sanitize_filename("foo.MP4", "mp4", "movie"));
+ $this->assert_equal("foo.mp4", legal_file::sanitize_filename("foo.mp4", "MP4", "movie"));
+ }
+
+ public function sanitize_filename_with_corrected_extension_test() {
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo.png", "jpg", "photo"));
+ $this->assert_equal("foo.MP4", legal_file::sanitize_filename("foo.jpg", "MP4", "movie"));
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo.php", "jpg", "photo"));
+ }
+
+ public function sanitize_filename_with_non_standard_chars_and_dots_test() {
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo", "jpg", "photo"));
+ $this->assert_equal("foo.mp4", legal_file::sanitize_filename("foo.", "mp4", "movie"));
+ $this->assert_equal("foo.jpeg", legal_file::sanitize_filename(".foo.jpeg", "jpg", "photo"));
+ $this->assert_equal("foo_2013_02_10.jpeg",
+ legal_file::sanitize_filename("foo.2013/02/10.jpeg", "jpg", "photo"));
+ $this->assert_equal("foo_bar_baz.jpg",
+ legal_file::sanitize_filename("...foo...bar..baz...png", "jpg", "photo"));
+ $this->assert_equal("j'écris@un#nom_bizarre(mais quand_même_ça_passe.jpg",
+ legal_file::sanitize_filename("/j'écris@un#nom/bizarre(mais quand.même/ça_passe.\$ÇÀ@€#_", "jpg", "photo"));
+ }
+
+ public function sanitize_filename_with_no_base_name_test() {
+ $this->assert_equal("photo.jpg", legal_file::sanitize_filename(".png", "jpg", "photo"));
+ $this->assert_equal("movie.mp4", legal_file::sanitize_filename("__..__", "mp4", "movie"));
+ $this->assert_equal("photo.jpg", legal_file::sanitize_filename(".", "jpg", "photo"));
+ $this->assert_equal("movie.mp4", legal_file::sanitize_filename(null, "mp4", "movie"));
+ }
+
+ public function sanitize_filename_with_invalid_arguments_test() {
+ foreach (array("flv" => "photo", "jpg" => "movie", "php" => "photo",
+ null => "movie", "jpg" => "album", "jpg" => null) as $extension => $type) {
+ try {
+ legal_file::sanitize_filename("foo.jpg", $extension, $type);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/modules/gallery/tests/Locales_Helper_Test.php b/modules/gallery/tests/Locales_Helper_Test.php
index 1d27312e..ff5b05d4 100644
--- a/modules/gallery/tests/Locales_Helper_Test.php
+++ b/modules/gallery/tests/Locales_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Menu_Test.php b/modules/gallery/tests/Menu_Test.php
index 85ada63b..1e251c1f 100644
--- a/modules/gallery/tests/Menu_Test.php
+++ b/modules/gallery/tests/Menu_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Movie_Helper_Test.php b/modules/gallery/tests/Movie_Helper_Test.php
new file mode 100644
index 00000000..03fa2da9
--- /dev/null
+++ b/modules/gallery/tests/Movie_Helper_Test.php
@@ -0,0 +1,105 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 Movie_Helper_Test extends Gallery_Unit_Test_Case {
+ public function seconds_to_hhmmssdd_test() {
+ $times = array("00:00:00.50" => 0.5,
+ "00:00:06.00" => 6,
+ "00:00:59.99" => 59.999,
+ "00:01:00.00" => 60.001,
+ "00:07:00.00" => 7 * 60,
+ "00:45:19.00" => 45 * 60 + 19,
+ "03:45:19.00" => 3 * 3600 + 45 * 60 + 19,
+ "126:45:19.00" => 126 * 3600 + 45 * 60 + 19);
+ foreach ($times as $hhmmssdd => $seconds) {
+ $this->assert_equal($hhmmssdd, movie::seconds_to_hhmmssdd($seconds));
+ }
+ }
+
+ public function hhmmssdd_to_seconds_test() {
+ $times = array("0:00:00.01" => 0.01,
+ "00:00:00.50" => 0.5,
+ "00:00:06.00" => 6,
+ "00:00:59.99" => 59.99,
+ "00:01:00.00" => 60.00,
+ "00:07:00.00" => 7 * 60,
+ "00:45:19.00" => 45 * 60 + 19,
+ "03:45:19.00" => 3 * 3600 + 45 * 60 + 19,
+ "126:45:19.00" => 126 * 3600 + 45 * 60 + 19);
+ foreach ($times as $hhmmssdd => $seconds) {
+ $this->assert_equal($seconds, movie::hhmmssdd_to_seconds($hhmmssdd));
+ }
+ }
+
+ public function get_file_metadata_test() {
+ $movie = test::random_movie();
+ $this->assert_equal(array(360, 288, "video/x-flv", "flv", 6.00),
+ movie::get_file_metadata($movie->file_path()));
+ }
+
+ public function get_file_metadata_with_non_existent_file_test() {
+ try {
+ $metadata = movie::get_file_metadata(MODPATH . "gallery/tests/this_does_not_exist");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_no_extension_test() {
+ copy(MODPATH . "gallery/tests/test.flv", TMPPATH . "test_flv_with_no_extension");
+ // Since mime type and extension are based solely on the filename, this is considered invalid.
+ try {
+ $metadata = movie::get_file_metadata(TMPPATH . "test_flv_with_no_extension");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_illegal_extension_test() {
+ try {
+ $metadata = movie::get_file_metadata(MODPATH . "gallery/tests/Movie_Helper_Test.php");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_illegal_extension_but_valid_file_contents_test() {
+ copy(MODPATH . "gallery/tests/test.flv", TMPPATH . "test_flv_with_php_extension.php");
+ // Since mime type and extension are based solely on the filename, this is considered invalid.
+ try {
+ $metadata = movie::get_file_metadata(TMPPATH . "test_flv_with_php_extension.php");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_valid_extension_but_illegal_file_contents_test() {
+ copy(MODPATH . "gallery/tests/Photo_Helper_Test.php", TMPPATH . "test_php_with_flv_extension.flv");
+ // Since mime type and extension are based solely on the filename, this is considered valid.
+ // Of course, FFmpeg cannot extract width, height, or duration from the file. Note that this
+ // isn't a really a security problem, since the filename doesn't have a php extension and
+ // therefore will never be executed.
+ $this->assert_equal(array(0, 0, "video/x-flv", "flv", 0),
+ movie::get_file_metadata(TMPPATH . "test_php_with_flv_extension.flv"));
+ }
+}
diff --git a/modules/gallery/tests/Num_Helper_Test.php b/modules/gallery/tests/Num_Helper_Test.php
index a12e3fa3..2158d231 100644
--- a/modules/gallery/tests/Num_Helper_Test.php
+++ b/modules/gallery/tests/Num_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php
index 8f4e9fb1..7547f2a7 100644
--- a/modules/gallery/tests/ORM_MPTT_Test.php
+++ b/modules/gallery/tests/ORM_MPTT_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Photo_Helper_Test.php b/modules/gallery/tests/Photo_Helper_Test.php
new file mode 100644
index 00000000..79b5ccfd
--- /dev/null
+++ b/modules/gallery/tests/Photo_Helper_Test.php
@@ -0,0 +1,70 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 Photo_Helper_Test extends Gallery_Unit_Test_Case {
+ public function get_file_metadata_test() {
+ $photo = test::random_photo();
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"),
+ photo::get_file_metadata($photo->file_path()));
+ }
+
+ public function get_file_metadata_with_non_existent_file_test() {
+ try {
+ $metadata = photo::get_file_metadata(MODPATH . "gallery/tests/this_does_not_exist");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_no_extension_test() {
+ copy(MODPATH . "gallery/tests/test.jpg", TMPPATH . "test_jpg_with_no_extension");
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"),
+ photo::get_file_metadata(TMPPATH . "test_jpg_with_no_extension"));
+ }
+
+ public function get_file_metadata_with_illegal_extension_test() {
+ try {
+ $metadata = photo::get_file_metadata(MODPATH . "gallery/tests/Photo_Helper_Test.php");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_illegal_extension_but_valid_file_contents_test() {
+ // This ensures that we correctly "re-type" files with invalid extensions if the contents
+ // themselves are valid. This is needed to ensure that issues similar to those corrected by
+ // ticket #1855, where an image that looked valid (header said jpg) with a php extension was
+ // previously accepted without changing its extension, do not arise and cause security issues.
+ copy(MODPATH . "gallery/tests/test.jpg", TMPPATH . "test_jpg_with_php_extension.php");
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"),
+ photo::get_file_metadata(TMPPATH . "test_jpg_with_php_extension.php"));
+ }
+
+ public function get_file_metadata_with_valid_extension_but_illegal_file_contents_test() {
+ copy(MODPATH . "gallery/tests/Photo_Helper_Test.php", TMPPATH . "test_php_with_jpg_extension.jpg");
+ try {
+ $metadata = photo::get_file_metadata(TMPPATH . "test_php_with_jpg_extension.jpg");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+}
diff --git a/modules/gallery/tests/Photos_Controller_Test.php b/modules/gallery/tests/Photos_Controller_Test.php
index 1587ebd7..a9c6a152 100644
--- a/modules/gallery/tests/Photos_Controller_Test.php
+++ b/modules/gallery/tests/Photos_Controller_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/SafeString_Test.php b/modules/gallery/tests/SafeString_Test.php
index fb4180e4..946410d4 100644
--- a/modules/gallery/tests/SafeString_Test.php
+++ b/modules/gallery/tests/SafeString_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Sendmail_Test.php b/modules/gallery/tests/Sendmail_Test.php
index 84d24083..9a687602 100644
--- a/modules/gallery/tests/Sendmail_Test.php
+++ b/modules/gallery/tests/Sendmail_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php
index d3295008..4ac12fde 100644
--- a/modules/gallery/tests/System_Helper_Test.php
+++ b/modules/gallery/tests/System_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Url_Security_Test.php b/modules/gallery/tests/Url_Security_Test.php
index ad07191b..3eb6276c 100644
--- a/modules/gallery/tests/Url_Security_Test.php
+++ b/modules/gallery/tests/Url_Security_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Valid_Test.php b/modules/gallery/tests/Valid_Test.php
index 82001b94..fc54547f 100644
--- a/modules/gallery/tests/Valid_Test.php
+++ b/modules/gallery/tests/Valid_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Var_Test.php b/modules/gallery/tests/Var_Test.php
index 6b050be6..97bccc35 100644
--- a/modules/gallery/tests/Var_Test.php
+++ b/modules/gallery/tests/Var_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php
index 4420b40c..6f78bb6f 100644
--- a/modules/gallery/tests/Xss_Security_Test.php
+++ b/modules/gallery/tests/Xss_Security_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt
index e35708c0..9473f9f6 100644
--- a/modules/gallery/tests/controller_auth_data.txt
+++ b/modules/gallery/tests/controller_auth_data.txt
@@ -25,6 +25,7 @@ modules/gallery/controllers/user_profile.php send
modules/gallery/controllers/welcome_message.php index DIRTY_AUTH
modules/organize/controllers/organize.php tree DIRTY_CSRF
modules/organize/controllers/organize.php delete DIRTY_AUTH
+modules/organize/controllers/organize.php tag DIRTY_AUTH
modules/rest/controllers/rest.php index DIRTY_CSRF|DIRTY_AUTH
modules/rest/controllers/rest.php reset_api_key_confirm DIRTY_AUTH
modules/rest/controllers/rest.php reset_api_key DIRTY_AUTH
@@ -35,6 +36,7 @@ modules/server_add/controllers/admin_server_add.php autocomplete
modules/server_add/controllers/server_add.php children DIRTY_CSRF
modules/tag/controllers/admin_tags.php index DIRTY_CSRF
modules/tag/controllers/tag.php __call DIRTY_CSRF|DIRTY_AUTH
+modules/tag/controllers/tag_name.php __call DIRTY_AUTH
modules/tag/controllers/tags.php autocomplete DIRTY_CSRF|DIRTY_AUTH
modules/user/controllers/admin_users.php index DIRTY_CSRF
modules/user/controllers/password.php reset DIRTY_AUTH
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 2bfacb47..51347f86 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -46,7 +46,6 @@ modules/exif/views/exif_dialog.html.php 21 DIRTY $detai
modules/g2_import/views/admin_g2_import.html.php 7 DIRTY_JS url::site("__ARGS__")
modules/g2_import/views/admin_g2_import.html.php 52 DIRTY $form
modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY_ATTR text::alternate("g-odd","g-even")
-modules/gallery/views/admin_advanced_settings.html.php 22 DIRTY $var->module_name
modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity)
modules/gallery/views/admin_block_log_entries.html.php 8 DIRTY_JS user_profile::url($entry->user->id)
modules/gallery/views/admin_block_log_entries.html.php 10 DIRTY gallery::date_time($entry->timestamp)
@@ -223,10 +222,13 @@ modules/gallery/views/menu_dialog.html.php 5 DIRTY_JS $menu-
modules/gallery/views/menu_link.html.php 3 DIRTY $menu->css_id?"id='{$menu->css_id}'":""
modules/gallery/views/menu_link.html.php 4 DIRTY_ATTR $menu->css_class
modules/gallery/views/menu_link.html.php 5 DIRTY_JS $menu->url
-modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($item->file_url(true),"",$attrs)
-modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $attrs["id"]
-modules/gallery/views/movieplayer.html.php 7 DIRTY_JS url::abs_file("lib/flowplayer.swf")
-modules/gallery/views/movieplayer.html.php 17 DIRTY_JS url::abs_file("lib/flowplayer.pseudostreaming.swf")
+modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($url,"",$attrs)
+modules/gallery/views/movieplayer.html.php 4 DIRTY_JS $attrs["id"]
+modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $max_size
+modules/gallery/views/movieplayer.html.php 23 DIRTY_JS url::abs_file("lib/flowplayer.swf")
+modules/gallery/views/movieplayer.html.php 30 DIRTY_JS url::abs_file("lib/flowplayer.pseudostreaming-byterange.swf")
+modules/gallery/views/movieplayer.html.php 48 DIRTY_JS $width
+modules/gallery/views/movieplayer.html.php 48 DIRTY_JS $height
modules/gallery/views/permissions_browse.html.php 3 DIRTY_JS url::site("permissions/form/__ITEM__")
modules/gallery/views/permissions_browse.html.php 16 DIRTY_JS url::site("permissions/change/__CMD__/__GROUP__/__PERM__/__ITEM__?csrf=$csrf")
modules/gallery/views/permissions_browse.html.php 43 DIRTY_ATTR $parent->id
@@ -293,19 +295,21 @@ modules/organize/views/organize_frame.html.php 12 DIRTY_JS url::f
modules/organize/views/organize_frame.html.php 56 DIRTY_JS url::site("organize/album_info/__ID__")
modules/organize/views/organize_frame.html.php 94 DIRTY_JS access::csrf_token()
modules/organize/views/organize_frame.html.php 96 DIRTY_JS url::site("organize/set_sort/__ID__")
-modules/organize/views/organize_frame.html.php 116 DIRTY_JS url::site("organize/delete")
-modules/organize/views/organize_frame.html.php 125 DIRTY_JS access::csrf_token()
-modules/organize/views/organize_frame.html.php 238 DIRTY_JS url::site("organize/rearrange")
-modules/organize/views/organize_frame.html.php 249 DIRTY_JS access::csrf_token()
-modules/organize/views/organize_frame.html.php 287 DIRTY_JS $key
-modules/organize/views/organize_frame.html.php 410 DIRTY_JS url::site("organize/tree/{$album->id}")
-modules/organize/views/organize_frame.html.php 468 DIRTY_JS url::site("organize/reparent")
-modules/organize/views/organize_frame.html.php 491 DIRTY_JS access::csrf_token()
-modules/organize/views/organize_frame.html.php 507 DIRTY_JS access::can("edit",item::root())
-modules/organize/views/organize_frame.html.php 509 DIRTY_JS html::clean(item::root()->title)
-modules/organize/views/organize_frame.html.php 511 DIRTY_JS item::root()->id
-modules/organize/views/organize_frame.html.php 519 DIRTY_JS $album->id
-modules/organize/views/organize_frame.html.php 520 DIRTY_JS $album->id
+modules/organize/views/organize_frame.html.php 116 DIRTY_JS url::site("organize/tag")
+modules/organize/views/organize_frame.html.php 126 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 140 DIRTY_JS url::site("organize/delete")
+modules/organize/views/organize_frame.html.php 149 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 264 DIRTY_JS url::site("organize/rearrange")
+modules/organize/views/organize_frame.html.php 275 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 314 DIRTY_JS $key
+modules/organize/views/organize_frame.html.php 476 DIRTY_JS url::site("organize/tree/{$album->id}")
+modules/organize/views/organize_frame.html.php 534 DIRTY_JS url::site("organize/reparent")
+modules/organize/views/organize_frame.html.php 557 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 573 DIRTY_JS access::can("edit",item::root())
+modules/organize/views/organize_frame.html.php 575 DIRTY_JS html::clean(item::root()->title)
+modules/organize/views/organize_frame.html.php 577 DIRTY_JS item::root()->id
+modules/organize/views/organize_frame.html.php 585 DIRTY_JS $album->id
+modules/organize/views/organize_frame.html.php 586 DIRTY_JS $album->id
modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form
modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key
modules/recaptcha/views/form_recaptcha.html.php 3 DIRTY_ATTR request::protocol()
@@ -338,11 +342,13 @@ modules/rss/views/feed.mrss.php 67 DIRTY_ATTR $ite
modules/rss/views/feed.mrss.php 68 DIRTY_ATTR $item->height
modules/rss/views/feed.mrss.php 69 DIRTY_ATTR $item->width
modules/rss/views/rss_block.html.php 6 DIRTY_JS rss::url($url)
-modules/search/views/search.html.php 27 DIRTY_ATTR $item_class
-modules/search/views/search.html.php 28 DIRTY_JS $item->url()
-modules/search/views/search.html.php 29 DIRTY $item->thumb_img(array("class"=>"g-thumbnail"))
-modules/search/views/search.html.php 31 DIRTY_ATTR $item_class
-modules/search/views/search.html.php 41 DIRTY $theme->paginator()
+modules/search/views/search.html.php 39 DIRTY_ATTR $item_class
+modules/search/views/search.html.php 40 DIRTY_JS $item->url()
+modules/search/views/search.html.php 41 DIRTY $item->thumb_img(array("class"=>"g-thumbnail"))
+modules/search/views/search.html.php 43 DIRTY_ATTR $item_class
+modules/search/views/search.html.php 53 DIRTY $theme->paginator()
+modules/search/views/search_link.html.php 14 DIRTY_ATTR $item->id
+modules/search/views/search_link.html.php 16 DIRTY_ATTR $item->parent_id
modules/server_add/views/admin_server_add.html.php 8 DIRTY_JS url::site("__ARGS__")
modules/server_add/views/admin_server_add.html.php 19 DIRTY $form
modules/server_add/views/admin_server_add.html.php 30 DIRTY_ATTR $id
@@ -378,22 +384,22 @@ modules/user/views/admin_users_group.html.php 24 DIRTY_JS $group
modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width
modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height
modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url
-themes/admin_wind/views/admin.html.php 5 DIRTY $theme->html_attributes()
-themes/admin_wind/views/admin.html.php 35 DIRTY $theme->admin_head()
-themes/admin_wind/views/admin.html.php 47 DIRTY_JS $theme->url()
-themes/admin_wind/views/admin.html.php 52 DIRTY $theme->get_combined("css")
-themes/admin_wind/views/admin.html.php 55 DIRTY $theme->get_combined("script")
-themes/admin_wind/views/admin.html.php 59 DIRTY $theme->admin_page_top()
-themes/admin_wind/views/admin.html.php 67 DIRTY $theme->admin_header_top()
-themes/admin_wind/views/admin.html.php 68 DIRTY_JS item::root()->url()
-themes/admin_wind/views/admin.html.php 71 DIRTY $theme->user_menu()
-themes/admin_wind/views/admin.html.php 74 DIRTY $theme->admin_menu()
-themes/admin_wind/views/admin.html.php 77 DIRTY $theme->admin_header_bottom()
-themes/admin_wind/views/admin.html.php 84 DIRTY $content
-themes/admin_wind/views/admin.html.php 90 DIRTY $sidebar
-themes/admin_wind/views/admin.html.php 95 DIRTY $theme->admin_footer()
-themes/admin_wind/views/admin.html.php 98 DIRTY $theme->admin_credits()
-themes/admin_wind/views/admin.html.php 103 DIRTY $theme->admin_page_bottom()
+themes/admin_wind/views/admin.html.php 4 DIRTY $theme->html_attributes()
+themes/admin_wind/views/admin.html.php 34 DIRTY $theme->admin_head()
+themes/admin_wind/views/admin.html.php 46 DIRTY_JS $theme->url()
+themes/admin_wind/views/admin.html.php 51 DIRTY $theme->get_combined("css")
+themes/admin_wind/views/admin.html.php 54 DIRTY $theme->get_combined("script")
+themes/admin_wind/views/admin.html.php 58 DIRTY $theme->admin_page_top()
+themes/admin_wind/views/admin.html.php 66 DIRTY $theme->admin_header_top()
+themes/admin_wind/views/admin.html.php 67 DIRTY_JS item::root()->url()
+themes/admin_wind/views/admin.html.php 70 DIRTY $theme->user_menu()
+themes/admin_wind/views/admin.html.php 73 DIRTY $theme->admin_menu()
+themes/admin_wind/views/admin.html.php 76 DIRTY $theme->admin_header_bottom()
+themes/admin_wind/views/admin.html.php 83 DIRTY $content
+themes/admin_wind/views/admin.html.php 89 DIRTY $sidebar
+themes/admin_wind/views/admin.html.php 94 DIRTY $theme->admin_footer()
+themes/admin_wind/views/admin.html.php 97 DIRTY $theme->admin_credits()
+themes/admin_wind/views/admin.html.php 102 DIRTY $theme->admin_page_bottom()
themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor
themes/admin_wind/views/block.html.php 5 DIRTY $id
themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id
@@ -423,23 +429,23 @@ themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $chi
themes/wind/views/dynamic.html.php 29 DIRTY $theme->paginator()
themes/wind/views/movie.html.php 5 DIRTY $theme->paginator()
themes/wind/views/movie.html.php 9 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}"))
-themes/wind/views/page.html.php 5 DIRTY $theme->html_attributes()
-themes/wind/views/page.html.php 11 DIRTY $page_title
-themes/wind/views/page.html.php 33 DIRTY $new_width
-themes/wind/views/page.html.php 34 DIRTY $new_height
-themes/wind/views/page.html.php 35 DIRTY $thumb_proportion
-themes/wind/views/page.html.php 75 DIRTY_JS $theme->url()
-themes/wind/views/page.html.php 80 DIRTY $theme->get_combined("css")
-themes/wind/views/page.html.php 83 DIRTY $theme->get_combined("script")
-themes/wind/views/page.html.php 93 DIRTY $header_text
-themes/wind/views/page.html.php 95 DIRTY_JS item::root()->url()
-themes/wind/views/page.html.php 99 DIRTY $theme->user_menu()
-themes/wind/views/page.html.php 114 DIRTY_ATTR $breadcrumb->last?"g-active":""
-themes/wind/views/page.html.php 115 DIRTY_ATTR $breadcrumb->first?"g-first":""
-themes/wind/views/page.html.php 116 DIRTY_JS $breadcrumb->url
-themes/wind/views/page.html.php 129 DIRTY $content
-themes/wind/views/page.html.php 135 DIRTY newView("sidebar.html")
-themes/wind/views/page.html.php 142 DIRTY $footer_text
+themes/wind/views/page.html.php 4 DIRTY $theme->html_attributes()
+themes/wind/views/page.html.php 10 DIRTY $page_title
+themes/wind/views/page.html.php 32 DIRTY $new_width
+themes/wind/views/page.html.php 33 DIRTY $new_height
+themes/wind/views/page.html.php 34 DIRTY $thumb_proportion
+themes/wind/views/page.html.php 74 DIRTY_JS $theme->url()
+themes/wind/views/page.html.php 79 DIRTY $theme->get_combined("css")
+themes/wind/views/page.html.php 82 DIRTY $theme->get_combined("script")
+themes/wind/views/page.html.php 92 DIRTY $header_text
+themes/wind/views/page.html.php 94 DIRTY_JS item::root()->url()
+themes/wind/views/page.html.php 98 DIRTY $theme->user_menu()
+themes/wind/views/page.html.php 113 DIRTY_ATTR $breadcrumb->last?"g-active":""
+themes/wind/views/page.html.php 114 DIRTY_ATTR $breadcrumb->first?"g-first":""
+themes/wind/views/page.html.php 115 DIRTY_JS $breadcrumb->url
+themes/wind/views/page.html.php 128 DIRTY $content
+themes/wind/views/page.html.php 134 DIRTY newView("sidebar.html")
+themes/wind/views/page.html.php 141 DIRTY $footer_text
themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url
themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url
themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url
diff --git a/modules/gallery/views/admin_graphics.html.php b/modules/gallery/views/admin_graphics.html.php
index ae76f1e1..1f45bb14 100644
--- a/modules/gallery/views/admin_graphics.html.php
+++ b/modules/gallery/views/admin_graphics.html.php
@@ -16,7 +16,7 @@
<h1> <?= t("Graphics settings") ?> </h1>
<p>
<?= t("Gallery needs a graphics toolkit in order to manipulate your photos. Please choose one from the list below.") ?>
- <?= t("Can't decide which toolkit to choose? <a href=\"%url\">We can help!</a>", array("url" => "http://codex.gallery2.org/Gallery3:Choosing_A_Graphics_Toolkit")) ?>
+ <?= t("Can't decide which toolkit to choose? <a href=\"%url\">We can help!</a>", array("url" => "http://codex.galleryproject.org/Gallery3:Choosing_A_Graphics_Toolkit")) ?>
</p>
<div class="g-block-content">
diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php
index eef087e1..d6a9c225 100644
--- a/modules/gallery/views/admin_languages.html.php
+++ b/modules/gallery/views/admin_languages.html.php
@@ -80,7 +80,7 @@
</p>
<div class="g-block-content">
- <a href="http://codex.gallery2.org/Gallery3:Localization" target="_blank"
+ <a href="http://codex.galleryproject.org/Gallery3:Localization" target="_blank"
class="g-right ui-state-default ui-corner-all ui-icon ui-icon-help"
title="<?= t("Localization documentation")->for_html_attr() ?>">
<?= t("Localization documentation") ?>
diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php
index 03993bb2..5a7f7b6c 100644
--- a/modules/gallery/views/admin_modules.html.php
+++ b/modules/gallery/views/admin_modules.html.php
@@ -43,7 +43,7 @@
</script>
<h1> <?= t("Gallery Modules") ?> </h1>
<p>
- <?= t("Power up your Gallery by <a href=\"%url\">adding more modules</a>! Each module provides new cool features.", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Modules")) ?>
+ <?= t("Power up your Gallery by <a href=\"%url\">adding more modules</a>! Each module provides new cool features.", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Modules")) ?>
</p>
<div class="g-block-content">
diff --git a/modules/gallery/views/admin_themes.html.php b/modules/gallery/views/admin_themes.html.php
index 9d53779f..547f27d2 100644
--- a/modules/gallery/views/admin_themes.html.php
+++ b/modules/gallery/views/admin_themes.html.php
@@ -10,7 +10,7 @@
<div class="g-block ui-helper-clearfix">
<h1> <?= t("Theme choice") ?> </h1>
<p>
- <?= t("Make your Gallery beautiful <a href=\"%url\">with a new theme</a>! There are separate themes for the regular site and for the administration interface. Click a theme below to preview and activate it.", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?>
+ <?= t("Make your Gallery beautiful <a href=\"%url\">with a new theme</a>! There are separate themes for the regular site and for the administration interface. Click a theme below to preview and activate it.", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>
</p>
<div class="g-block-content">
@@ -48,7 +48,7 @@
<? if (!$count): ?>
<p>
- <?= t("There are no other site themes available. <a href=\"%url\">Download one now!</a>", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?>
+ <?= t("There are no other site themes available. <a href=\"%url\">Download one now!</a>", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>
</p>
<? endif ?>
</div>
@@ -88,7 +88,7 @@
<? if (!$count): ?>
<p>
- <?= t("There are no other admin themes available. <a href=\"%url\">Download one now!</a>", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?>
+ <?= t("There are no other admin themes available. <a href=\"%url\">Download one now!</a>", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>
</p>
<? endif ?>
</div>
diff --git a/modules/gallery/views/error_admin.html.php b/modules/gallery/views/error_admin.html.php
index 3e7c286e..cd1bd569 100644
--- a/modules/gallery/views/error_admin.html.php
+++ b/modules/gallery/views/error_admin.html.php
@@ -170,7 +170,7 @@
<p>
There's an error message below and you can find more details
in gallery3/var/logs (look for the file with the most recent
- date on it). Stuck? Stop by the <a href="http://gallery.menalto.com/forum/96">Gallery 3
+ date on it). Stuck? Stop by the <a href="http://galleryproject.org/forum/96">Gallery 3
Forums</a> and ask for help. You can also look at our list
of <a href="http://sourceforge.net/apps/trac/gallery/roadmap">open
tickets</a> to see if the problem you're seeing has been
diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php
index c1f985c3..4426514a 100644
--- a/modules/gallery/views/form_uploadify.html.php
+++ b/modules/gallery/views/form_uploadify.html.php
@@ -89,7 +89,7 @@
.replace("__INFO__", errorObj.info)
.replace("__TYPE__", errorObj.type);
}
- msg = " - <a target=\"_blank\" href=\"http://codex.gallery2.org/Gallery3:Troubleshooting:Uploading\">" +
+ msg = " - <a target=\"_blank\" href=\"http://codex.galleryproject.org/Gallery3:Troubleshooting:Uploading\">" +
error_msg + "</a>";
$("#g-add-photos-status ul").append(
@@ -131,7 +131,7 @@
<? if (identity::active_user()->admin && !$movies_allowed): ?>
<p class="g-warning">
- <?= t("Can't find <i>ffmpeg</i> on your system. Movie uploading disabled. <a href=\"%help_url\">Help!</a>", array("help_url" => "http://codex.gallery2.org/Gallery3:FAQ#Why_does_it_say_I.27m_missing_ffmpeg.3F")) ?>
+ <?= t("Can't find <i>ffmpeg</i> on your system. Movie uploading disabled. <a href=\"%help_url\">Help!</a>", array("help_url" => "http://codex.galleryproject.org/Gallery3:FAQ#Why_does_it_say_I.27m_missing_ffmpeg.3F")) ?>
</p>
<? endif ?>
</div>
diff --git a/modules/gallery/views/movieplayer.html.php b/modules/gallery/views/movieplayer.html.php
index 25cb9f58..edb5184c 100644
--- a/modules/gallery/views/movieplayer.html.php
+++ b/modules/gallery/views/movieplayer.html.php
@@ -18,7 +18,7 @@
$("#" + id).css({width: width, height: height});
};
// setup flowplayer
- flowplayer(id,
+ flowplayer(id,
$.extend(true, {
"src": "<?= url::abs_file("lib/flowplayer.swf") ?>",
"wmode": "transparent",
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index 70d37dd1..edfaf720 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -144,8 +144,8 @@
<p>
<em>
<?= t("Did something go wrong? Try the <a href=\"%faq_url\">FAQ</a> or ask in the <a href=\"%forums_url\">Gallery forums</a>.",
- array("faq_url" => "http://codex.gallery2.org/Gallery3:FAQ",
- "forums_url" => "http://gallery.menalto.com/forum")) ?>
+ array("faq_url" => "http://codex.galleryproject.org/Gallery3:FAQ",
+ "forums_url" => "http://galleryproject.org/forum")) ?>
</em>
</p>
</div>
diff --git a/modules/gallery/views/welcome_message.html.php b/modules/gallery/views/welcome_message.html.php
index 1fcca971..bb6b4a83 100644
--- a/modules/gallery/views/welcome_message.html.php
+++ b/modules/gallery/views/welcome_message.html.php
@@ -27,10 +27,10 @@
</p>
<p>
- <?= t("Want to learn more? The <a href=\"%url\">Gallery website</a> has news and information about the Gallery project and community.", array("url" => "http://gallery.menalto.com")) ?>
+ <?= t("Want to learn more? The <a href=\"%url\">Gallery website</a> has news and information about the Gallery project and community.", array("url" => "http://galleryproject.org")) ?>
</p>
<p>
- <?= t("Having problems? There's lots of information in our <a href=\"%codex_url\">documentation site</a> or you can <a href=\"%forum_url\">ask for help in the forums!</a>", array("codex_url" => "http://codex.gallery2.org/Main_Page", "forum_url" => "http://gallery.menalto.com/forum")) ?>
+ <?= t("Having problems? There's lots of information in our <a href=\"%codex_url\">documentation site</a> or you can <a href=\"%forum_url\">ask for help in the forums!</a>", array("codex_url" => "http://codex.galleryproject.org/Main_Page", "forum_url" => "http://galleryproject.org/forum")) ?>
</p>
</div>
diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php
index 19017a43..67d006b3 100644
--- a/modules/gallery_unit_test/controllers/gallery_unit_test.php
+++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -108,7 +108,7 @@ class Gallery_Unit_Test_Controller extends Controller {
// Install the active modules
// Force gallery and user to be installed first to resolve dependencies.
- gallery_installer::install(true);
+ module::install("gallery");
module::load_modules();
module::install("user");
diff --git a/modules/gallery_unit_test/helpers/MY_request.php b/modules/gallery_unit_test/helpers/MY_request.php
index 657f69ef..28c222b8 100644
--- a/modules/gallery_unit_test/helpers/MY_request.php
+++ b/modules/gallery_unit_test/helpers/MY_request.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/gallery_unit_test/helpers/test.php b/modules/gallery_unit_test/helpers/test.php
index 7fba0eda..75cf9b33 100644
--- a/modules/gallery_unit_test/helpers/test.php
+++ b/modules/gallery_unit_test/helpers/test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -33,6 +33,21 @@ class test_Core {
return test::random_album_unsaved($parent)->save()->reload();
}
+ static function random_movie_unsaved($parent=null) {
+ $rand = test::random_string(6);
+ $photo = ORM::factory("item");
+ $photo->type = "movie";
+ $photo->parent_id = $parent ? $parent->id : 1;
+ $photo->set_data_file(MODPATH . "gallery/tests/test.flv");
+ $photo->name = "name_$rand.flv";
+ $photo->title = "title_$rand";
+ return $photo;
+ }
+
+ static function random_movie($parent=null) {
+ return test::random_movie_unsaved($parent)->save()->reload();
+ }
+
static function random_photo_unsaved($parent=null) {
$rand = test::random_string(6);
$photo = ORM::factory("item");
@@ -48,6 +63,34 @@ class test_Core {
return test::random_photo_unsaved($parent)->save()->reload();
}
+ // If a test compares photo file contents (i.e. file_get_contents), it's best to use this
+ // function to guarantee uniqueness.
+ static function random_unique_photo_unsaved($parent=null) {
+ $rand = test::random_string(6);
+ $photo = ORM::factory("item");
+ $photo->type = "photo";
+ $photo->parent_id = $parent ? $parent->id : 1;
+ if (function_exists("gd_info")) {
+ // Make image unique - color the black dot of test.jpg to the 6-digit hex code of rand.
+ $image = imagecreatefromjpeg(MODPATH . "gallery/tests/test.jpg");
+ imagefilter($image, IMG_FILTER_COLORIZE,
+ hexdec(substr($rand, 0, 2)), hexdec(substr($rand, 2, 2)), hexdec(substr($rand, 4, 2)));
+ imagejpeg($image, TMPPATH . "test_$rand.jpg");
+ imagedestroy($image);
+ $photo->set_data_file(TMPPATH . "test_$rand.jpg");
+ } else {
+ // Just use the black dot.
+ $photo->set_data_file(MODPATH . "gallery/tests/test.jpg");
+ }
+ $photo->name = "name_$rand.jpg";
+ $photo->title = "title_$rand";
+ return $photo;
+ }
+
+ static function random_unique_photo($parent=null) {
+ return test::random_unique_photo_unsaved($parent)->save()->reload();
+ }
+
static function random_user($password="password") {
$rand = "name_" . test::random_string(6);
return identity::create_user($rand, $rand, $password, "$rand@rand.com");
diff --git a/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php b/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
index a79f2e42..4a1fcdd4 100644
--- a/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
+++ b/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/image_block/controllers/image_block.php b/modules/image_block/controllers/image_block.php
index 4956c08d..3198970c 100644
--- a/modules/image_block/controllers/image_block.php
+++ b/modules/image_block/controllers/image_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/image_block/helpers/image_block_block.php b/modules/image_block/helpers/image_block_block.php
index 9ea6fe82..37e5b4c6 100644
--- a/modules/image_block/helpers/image_block_block.php
+++ b/modules/image_block/helpers/image_block_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/image_block/helpers/image_block_installer.php b/modules/image_block/helpers/image_block_installer.php
index 0306b224..b177b971 100644
--- a/modules/image_block/helpers/image_block_installer.php
+++ b/modules/image_block/helpers/image_block_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -21,7 +21,6 @@ class image_block_installer {
static function install() {
module::set_var("image_block", "image_count", "1");
- module::set_version("image_block", $version = 3);
}
static function upgrade($version) {
diff --git a/modules/image_block/module.info b/modules/image_block/module.info
index 6722cc8f..25b89e6a 100644
--- a/modules/image_block/module.info
+++ b/modules/image_block/module.info
@@ -2,6 +2,6 @@ name = "Image Block"
description = "Display a random image in the sidebar"
version = 3
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:image_block"
-discuss_url = "http://gallery.menalto.com/forum_module_image_block"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:image_block"
+discuss_url = "http://galleryproject.org/forum_module_image_block"
diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php
index d62c900d..62aa0746 100644
--- a/modules/info/helpers/info_block.php
+++ b/modules/info/helpers/info_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -29,7 +29,7 @@ class info_block_Core {
if ($theme->item()) {
$block = new Block();
$block->css_id = "g-metadata";
- $block->title = $theme->item()->is_album() ? t("Album info") :
+ $block->title = $theme->item()->is_album() ? t("Album info") :
($theme->item()->is_movie() ? t("Movie info") : t("Photo info"));
$block->content = new View("info_block.html");
if ($theme->item->title && module::get_var("info", "show_title")) {
diff --git a/modules/info/helpers/info_installer.php b/modules/info/helpers/info_installer.php
index 61819b4a..43c216dc 100644
--- a/modules/info/helpers/info_installer.php
+++ b/modules/info/helpers/info_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -25,7 +25,6 @@ class info_installer {
module::set_var("info", "show_owner", 1);
module::set_var("info", "show_name", 1);
module::set_var("info", "show_captured", 1);
- module::set_version("info", 2);
}
static function upgrade($version) {
diff --git a/modules/info/helpers/info_theme.php b/modules/info/helpers/info_theme.php
index 69464deb..457d3308 100644
--- a/modules/info/helpers/info_theme.php
+++ b/modules/info/helpers/info_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/info/module.info b/modules/info/module.info
index f8964a78..0f35c922 100644
--- a/modules/info/module.info
+++ b/modules/info/module.info
@@ -2,6 +2,6 @@ name = "Info"
description = "Display extra information about photos and albums"
version = 2
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:info"
-discuss_url = "http://gallery.menalto.com/forum_module_info"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:info"
+discuss_url = "http://galleryproject.org/forum_module_info"
diff --git a/modules/kohana23_compat/config/pagination.php b/modules/kohana23_compat/config/pagination.php
index 1626b796..174bc23c 100644
--- a/modules/kohana23_compat/config/pagination.php
+++ b/modules/kohana23_compat/config/pagination.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/kohana23_compat/libraries/MY_Database_Builder.php b/modules/kohana23_compat/libraries/MY_Database_Builder.php
index 0b9dbe28..4a09b20c 100644
--- a/modules/kohana23_compat/libraries/MY_Database_Builder.php
+++ b/modules/kohana23_compat/libraries/MY_Database_Builder.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/kohana23_compat/libraries/Pagination.php b/modules/kohana23_compat/libraries/Pagination.php
index 46500359..bd74a346 100644
--- a/modules/kohana23_compat/libraries/Pagination.php
+++ b/modules/kohana23_compat/libraries/Pagination.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/notification/controllers/notification.php b/modules/notification/controllers/notification.php
index bb0740f3..67f8ed3f 100644
--- a/modules/notification/controllers/notification.php
+++ b/modules/notification/controllers/notification.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php
index 8ece698e..96493a2e 100644
--- a/modules/notification/helpers/notification.php
+++ b/modules/notification/helpers/notification.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php
index a29f1f4e..264ec556 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/notification/helpers/notification_installer.php b/modules/notification/helpers/notification_installer.php
index 7bd76cdf..f6b05c18 100644
--- a/modules/notification/helpers/notification_installer.php
+++ b/modules/notification/helpers/notification_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -36,8 +36,6 @@ class notification_installer {
`text` text,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
-
- module::set_version("notification", 2);
}
static function upgrade($version) {
diff --git a/modules/notification/models/pending_notification.php b/modules/notification/models/pending_notification.php
index c16e4f40..4033aedb 100644
--- a/modules/notification/models/pending_notification.php
+++ b/modules/notification/models/pending_notification.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/notification/models/subscription.php b/modules/notification/models/subscription.php
index 9c52c656..64996b6b 100644
--- a/modules/notification/models/subscription.php
+++ b/modules/notification/models/subscription.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/notification/module.info b/modules/notification/module.info
index 84be8f99..0e2cdb65 100644
--- a/modules/notification/module.info
+++ b/modules/notification/module.info
@@ -2,6 +2,6 @@ name = "Notification"
description = "Send notifications to users when changes are made to watched albums."
version = 2
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:notification"
-discuss_url = "http://gallery.menalto.com/forum_module_notification"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:notification"
+discuss_url = "http://galleryproject.org/forum_module_notification"
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index b0c13e7d..ba73ae75 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -129,12 +129,8 @@ class Organize_Controller extends Controller {
if ($album->sort_column != "weight") {
// Force all the weights into the current order before changing the order to manual
- $weight = 0;
- foreach ($album->children() as $child) {
- $child->weight = ++$weight;
- $child->save();
- }
-
+ // @todo: consider making this a trigger in the Item_Model.
+ item::resequence_child_weights($album);
$album->sort_column = "weight";
$album->sort_order = "ASC";
$album->save();
@@ -158,7 +154,7 @@ class Organize_Controller extends Controller {
// Move all the source items to the right spots.
for ($i = 0; $i < count($source_ids); $i++) {
$source = ORM::factory("item", $source_ids[$i]);
- if ($source->parent_id = $album->id) {
+ if ($source->parent_id == $album->id) {
$source->weight = $base_weight + $i;
$source->save();
}
@@ -182,6 +178,28 @@ class Organize_Controller extends Controller {
json::reply(null);
}
+ function tag() {
+ access::verify_csrf();
+ $input = Input::instance();
+
+ foreach (explode(",", $input->post("item_ids")) as $item_id) {
+ $item = ORM::factory("item", $item_id);
+ if (access::can("edit", $item)) {
+ // Assuming the user can view/edit the current item, loop
+ // through each tag that was submitted and apply it to
+ // the current item.
+ foreach (explode(",", $input->post("tag_names")) as $tag_name) {
+ $tag_name = trim($tag_name);
+ if ($tag_name) {
+ tag::add($item, $tag_name);
+ }
+ }
+ }
+ }
+
+ json::reply(null);
+ }
+
private function _get_tree($item, $selected) {
$tree = array();
$children = $item->viewable()
diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php
index 674cc064..2ca9e9b4 100644
--- a/modules/organize/helpers/organize_event.php
+++ b/modules/organize/helpers/organize_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php
index 8121bdbe..a2a07447 100644
--- a/modules/organize/helpers/organize_installer.php
+++ b/modules/organize/helpers/organize_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/organize/module.info b/modules/organize/module.info
index 07b9dc38..4d4560b9 100644
--- a/modules/organize/module.info
+++ b/modules/organize/module.info
@@ -2,6 +2,6 @@ name = "Organize"
description = "Visually rearrange and move photos in your gallery"
version = 4
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:organize"
-discuss_url = "http://gallery.menalto.com/forum_module_organize"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:organize"
+discuss_url = "http://galleryproject.org/forum_module_organize"
diff --git a/modules/organize/views/organize_frame.html.php b/modules/organize/views/organize_frame.html.php
index 51d49104..3a70ccff 100644
--- a/modules/organize/views/organize_frame.html.php
+++ b/modules/organize/views/organize_frame.html.php
@@ -104,9 +104,33 @@
});
}
+ var tag_selected_items = function(tag) {
+ var nodes = thumb_data_view.getSelectedNodes();
+ var item_ids = [];
+ for (var i = 0; i != nodes.length; i++) {
+ var node = Ext.fly(nodes[i]);
+ item_ids.push(get_id_from_node(node));
+ }
+ start_busy(<?= t("Tagging...")->for_js() ?>);
+ Ext.Ajax.request({
+ url: '<?= url::site("organize/tag") ?>',
+ method: "post",
+ success: function() {
+ stop_busy();
+ reload_album_data();
+ },
+ failure: show_generic_error,
+ params: {
+ item_ids: item_ids.join(","),
+ tag_names: tag,
+ csrf: '<?= access::csrf_token() ?>'
+ }
+ });
+ };
+
var delete_selected_items = function() {
var nodes = thumb_data_view.getSelectedNodes();
- item_ids = [];
+ var item_ids = [];
for (var i = 0; i != nodes.length; i++) {
var node = Ext.fly(nodes[i]);
item_ids.push(get_id_from_node(node));
@@ -166,8 +190,10 @@
getDragData: function(e) {
var target = e.getTarget(v.itemSelector, 10);
if (target) {
- if (!v.isSelected(target)) {
- v.onClick(e);
+ if (e.ctrlKey == false) {
+ if (!v.isSelected(target)) {
+ v.onClick(e);
+ }
}
var selected_nodes = v.getSelectedNodes();
var drag_data = {
@@ -254,6 +280,7 @@
});
},
"selectionchange": function(v, selections) {
+ tag_button.setDisabled(!selections.length || !current_album_editable || !tag_textfield.getValue());
delete_button.setDisabled(!selections.length || !current_album_editable);
}
},
@@ -330,6 +357,31 @@
displayField: "value"
});
+ var tag_textfield = new Ext.form.TextField({
+ flex: 4,
+ enableKeyEvents: true,
+ listeners: {
+ "keyup": function(v, e) {
+ var nodes = thumb_data_view.getSelectedNodes();
+ tag_button.setDisabled(!nodes.length || !current_album_editable || !tag_textfield.getValue());
+ }
+ }
+ });
+
+ var tag_button = new Ext.Button({
+ flex: 2,
+ text: <?= t("Tag")->for_js() ?>,
+ cls: "x-btn-text-icon",
+ id: "tag-button",
+ disabled: true,
+ listeners: {
+ "click": function() {
+ tag_selected_items(tag_textfield.getValue());
+ return true;
+ }
+ }
+ });
+
var delete_button = new Ext.Button({
flex: 2,
text: <?= t("Delete")->for_js() ?>,
@@ -375,10 +427,24 @@
sort_column_combobox,
sort_order_combobox
]
- }, {
+ },
+<? if (module::is_active("tag")): ?>
+ {
+ xtype: "spacer",
+ flex: 3
+ },
+ tag_textfield,
+ tag_button,
+ {
+ xtype: "spacer",
+ flex: 1
+ },
+<? else: ?>
+ {
xtype: "spacer",
flex: 10
},
+<? endif ?>
delete_button,
{
xtype: "button",
diff --git a/modules/recaptcha/controllers/admin_recaptcha.php b/modules/recaptcha/controllers/admin_recaptcha.php
index b819e4ab..8ba43bb5 100644
--- a/modules/recaptcha/controllers/admin_recaptcha.php
+++ b/modules/recaptcha/controllers/admin_recaptcha.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/recaptcha/helpers/recaptcha.php b/modules/recaptcha/helpers/recaptcha.php
index 57f8cf36..cc50d721 100644
--- a/modules/recaptcha/helpers/recaptcha.php
+++ b/modules/recaptcha/helpers/recaptcha.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/recaptcha/helpers/recaptcha_event.php b/modules/recaptcha/helpers/recaptcha_event.php
index a2ecf2d6..4ccacc75 100644
--- a/modules/recaptcha/helpers/recaptcha_event.php
+++ b/modules/recaptcha/helpers/recaptcha_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/recaptcha/helpers/recaptcha_installer.php b/modules/recaptcha/helpers/recaptcha_installer.php
index fafd47e6..1b526e5e 100644
--- a/modules/recaptcha/helpers/recaptcha_installer.php
+++ b/modules/recaptcha/helpers/recaptcha_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/recaptcha/helpers/recaptcha_theme.php b/modules/recaptcha/helpers/recaptcha_theme.php
index dd1edd23..36087ff0 100644
--- a/modules/recaptcha/helpers/recaptcha_theme.php
+++ b/modules/recaptcha/helpers/recaptcha_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/recaptcha/libraries/Form_Recaptcha.php b/modules/recaptcha/libraries/Form_Recaptcha.php
index 28368bab..8a9e63a5 100644
--- a/modules/recaptcha/libraries/Form_Recaptcha.php
+++ b/modules/recaptcha/libraries/Form_Recaptcha.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info
index ebaff7de..6806bb91 100644
--- a/modules/recaptcha/module.info
+++ b/modules/recaptcha/module.info
@@ -2,6 +2,6 @@ name = "reCAPTCHA"
description = "reCAPTCHA displays a graphical verification that protects the input form from abuse from 'bots,' or automated programs usually written to generate spam (http://recaptcha.net)."
version = 1
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:recaptcha"
-discuss_url = "http://gallery.menalto.com/forum_module_recaptcha"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:recaptcha"
+discuss_url = "http://galleryproject.org/forum_module_recaptcha"
diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php
index 21d9631b..bd03b334 100644
--- a/modules/rest/controllers/rest.php
+++ b/modules/rest/controllers/rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rest/helpers/registry_rest.php b/modules/rest/helpers/registry_rest.php
index 4ad8ca17..2b4087a8 100644
--- a/modules/rest/helpers/registry_rest.php
+++ b/modules/rest/helpers/registry_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php
index 1a062bd2..9b367feb 100644
--- a/modules/rest/helpers/rest.php
+++ b/modules/rest/helpers/rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -54,7 +54,7 @@ class rest_Core {
$html = t("Empty response");
}
print "<pre>$html</pre>";
- if (Session::instance()->get("profiler", false)) {
+ if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();
diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php
index ec500884..991e2b67 100644
--- a/modules/rest/helpers/rest_event.php
+++ b/modules/rest/helpers/rest_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rest/helpers/rest_installer.php b/modules/rest/helpers/rest_installer.php
index 474dd161..96f8acfa 100644
--- a/modules/rest/helpers/rest_installer.php
+++ b/modules/rest/helpers/rest_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -29,7 +29,6 @@ class rest_installer {
UNIQUE KEY(`user_id`))
DEFAULT CHARSET=utf8;");
module::set_var("rest", "allow_guest_access", false);
- module::set_version("rest", 3);
}
static function upgrade($version) {
diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php
index 2d81e1f2..bd08aa8e 100644
--- a/modules/rest/libraries/Rest_Exception.php
+++ b/modules/rest/libraries/Rest_Exception.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rest/models/user_access_key.php b/modules/rest/models/user_access_key.php
index 99968b6b..d464380e 100644
--- a/modules/rest/models/user_access_key.php
+++ b/modules/rest/models/user_access_key.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rest/module.info b/modules/rest/module.info
index 33c9f1cf..93a7873b 100644
--- a/modules/rest/module.info
+++ b/modules/rest/module.info
@@ -3,6 +3,6 @@ description = "A REST-based API that allows desktop clients and other apps to in
version = 3
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:rest"
-discuss_url = "http://gallery.menalto.com/forum_module_rest"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:rest"
+discuss_url = "http://galleryproject.org/forum_module_rest"
diff --git a/modules/rest/tests/Rest_Controller_Test.php b/modules/rest/tests/Rest_Controller_Test.php
index a641897a..71a1163e 100644
--- a/modules/rest/tests/Rest_Controller_Test.php
+++ b/modules/rest/tests/Rest_Controller_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rss/controllers/rss.php b/modules/rss/controllers/rss.php
index 288bf635..12461325 100644
--- a/modules/rss/controllers/rss.php
+++ b/modules/rss/controllers/rss.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rss/helpers/rss.php b/modules/rss/helpers/rss.php
index f2c2ea59..d6e60f1d 100644
--- a/modules/rss/helpers/rss.php
+++ b/modules/rss/helpers/rss.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rss/helpers/rss_block.php b/modules/rss/helpers/rss_block.php
index 3650cf62..74334e93 100644
--- a/modules/rss/helpers/rss_block.php
+++ b/modules/rss/helpers/rss_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/rss/module.info b/modules/rss/module.info
index cd13c1b0..5f32387e 100644
--- a/modules/rss/module.info
+++ b/modules/rss/module.info
@@ -2,6 +2,6 @@ name = "RSS"
description = "Provides RSS feeds"
version = 1
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:rss"
-discuss_url = "http://gallery.menalto.com/forum_module_rss"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:rss"
+discuss_url = "http://galleryproject.org/forum_module_rss"
diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php
index 52eb973c..25ccd81c 100644
--- a/modules/search/controllers/search.php
+++ b/modules/search/controllers/search.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -54,8 +54,6 @@ class Search_Controller extends Controller {
list ($count, $result) =
search::search_within_album($q_with_more_terms, $album, $page_size, $offset);
- $title = t("Search: %q", array("q" => $q_with_more_terms));
-
$max_pages = max(ceil($count / $page_size), 1);
$template = new Theme_View("page.html", "collection", "search");
@@ -77,28 +75,27 @@ class Search_Controller extends Controller {
print $template;
- item::set_display_context_callback(
- "Search_Controller::get_display_context", $album->id, $title, $q_with_more_terms, $q);
+ item::set_display_context_callback("Search_Controller::get_display_context", $album, $q);
}
- static function get_display_context($item, $album_id, $title, $query_terms, $q) {
- $album = ORM::factory("item", $album_id);
- $position = search::get_position_within_album($item, $query_terms, $album);
+ static function get_display_context($item, $album, $q) {
+ $q_with_more_terms = search::add_query_terms($q);
+ $position = search::get_position_within_album($item, $q_with_more_terms, $album);
if ($position > 1) {
list ($count, $result_data) =
- search::search_within_album($query_terms, $album, 3, $position - 2);
+ search::search_within_album($q_with_more_terms, $album, 3, $position - 2);
list ($previous_item, $ignore, $next_item) = $result_data;
} else {
$previous_item = null;
list ($count, $result_data) =
- search::search_within_album($query_terms, $album, 1, $position);
+ search::search_within_album($q_with_more_terms, $album, 1, $position);
list ($next_item) = $result_data;
}
$search_url = url::abs_site("search" .
"?q=" . urlencode($q) .
- "&album=" . urlencode($album_id) .
+ "&album=" . urlencode($album->id) .
"&show={$item->id}");
$root = item::root();
@@ -106,9 +103,15 @@ class Search_Controller extends Controller {
"previous_item" => $previous_item,
"next_item" => $next_item,
"sibling_count" => $count,
+ "siblings_callback" => array("Search_Controller::get_siblings", array($q, $album)),
"breadcrumbs" => array(
- Breadcrumb::instance($root->title, "/", $root->id)->set_first(),
+ Breadcrumb::instance($root->title, $root->url())->set_first(),
Breadcrumb::instance(t("Search: %q", array("q" => $q)), $search_url),
Breadcrumb::instance($item->title, $item->url())->set_last()));
}
+
+ static function get_siblings($q, $album, $limit=1000, $offset=1) {
+ $result = search::search_within_album(search::add_query_terms($q), $album, $limit, $offset);
+ return $result[1];
+ }
}
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php
index 32b36e73..b21e59dd 100644
--- a/modules/search/helpers/search.php
+++ b/modules/search/helpers/search.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -132,11 +132,12 @@ class search_Core {
static function get_position_within_album($item, $q, $album) {
$page_size = module::get_var("gallery", "page_size", 9);
- $query = self::_build_query_base($q, $album, array("{items}.id = " . $item->id));
+ $query = self::_build_query_base($q, $album, array("{items}.id = " . $item->id)) .
+ "ORDER BY `score` DESC ";
$db = Database::instance();
// Truncate the score by two decimal places as this resolves the issues
- // that arise due to in exact numeric conversions.
+ // that arise due to inexact numeric conversions.
$current = $db->query($query)->current();
if (!$current) {
// We can't find this result in our result set - perhaps we've fallen out of context? Clear
@@ -149,7 +150,10 @@ class search_Core {
$score = substr($score, 0, strlen($score) - 2);
}
- $data = $db->query(self::_build_query_base($q, $album) . " HAVING `score` >= " . $score);
+ // Redo the query but only look for results greater than or equal to our current location
+ // then seek backwards until we find our item.
+ $data = $db->query(self::_build_query_base($q, $album) . " HAVING `score` >= " . $score .
+ "ORDER BY `score` DESC ");
$data->seek($data->count() - 1);
while ($data->get("id") != $item->id && $data->prev()->valid()) {
diff --git a/modules/search/helpers/search_event.php b/modules/search/helpers/search_event.php
index 055cef62..a20935b1 100644
--- a/modules/search/helpers/search_event.php
+++ b/modules/search/helpers/search_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/search/helpers/search_installer.php b/modules/search/helpers/search_installer.php
index 288b706c..c9e8f26c 100644
--- a/modules/search/helpers/search_installer.php
+++ b/modules/search/helpers/search_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -30,7 +30,6 @@ class search_installer {
FULLTEXT INDEX (`data`))
ENGINE=MyISAM
DEFAULT CHARSET=utf8;");
- module::set_version("search", 1);
}
static function activate() {
diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php
index 2abe78c9..18348a22 100644
--- a/modules/search/helpers/search_task.php
+++ b/modules/search/helpers/search_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/search/helpers/search_theme.php b/modules/search/helpers/search_theme.php
index eb6c4cd3..e8735d11 100644
--- a/modules/search/helpers/search_theme.php
+++ b/modules/search/helpers/search_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/search/models/search_record.php b/modules/search/models/search_record.php
index 79614afa..be68e72e 100644
--- a/modules/search/models/search_record.php
+++ b/modules/search/models/search_record.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/search/module.info b/modules/search/module.info
index 1389798d..f1bb1fab 100644
--- a/modules/search/module.info
+++ b/modules/search/module.info
@@ -2,6 +2,6 @@ name = "Search"
description = "Allows users to search their Gallery"
version = 1
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:search"
-discuss_url = "http://gallery.menalto.com/forum_module_search"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:search"
+discuss_url = "http://galleryproject.org/forum_module_search"
diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php
index 5b75c02d..ba2b9b3f 100644
--- a/modules/server_add/controllers/admin_server_add.php
+++ b/modules/server_add/controllers/admin_server_add.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php
index c6d36a11..f6e0a944 100644
--- a/modules/server_add/controllers/server_add.php
+++ b/modules/server_add/controllers/server_add.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -61,7 +61,7 @@ class Server_Add_Controller extends Admin_Controller {
}
if (!is_dir($file)) {
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
- if (!in_array($ext, legal_file::get_extensions())) {
+ if (!legal_file::get_extensions($ext)) {
continue;
}
}
@@ -169,7 +169,7 @@ class Server_Add_Controller extends Admin_Controller {
foreach ($child_paths as $child_path) {
if (!is_dir($child_path)) {
$ext = strtolower(pathinfo($child_path, PATHINFO_EXTENSION));
- if (!in_array($ext, legal_file::get_extensions()) || !filesize($child_path)) {
+ if (!legal_file::get_extensions($ext) || !filesize($child_path)) {
// Not importable, skip it.
continue;
}
@@ -255,7 +255,7 @@ class Server_Add_Controller extends Admin_Controller {
} else {
try {
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
- if (in_array($extension, legal_file::get_photo_extensions())) {
+ if (legal_file::get_photo_extensions($extension)) {
$photo = ORM::factory("item");
$photo->type = "photo";
$photo->parent_id = $parent->id;
@@ -265,7 +265,7 @@ class Server_Add_Controller extends Admin_Controller {
$photo->owner_id = $owner_id;
$photo->save();
$entry->item_id = $photo->id;
- } else if (in_array($extension, legal_file::get_movie_extensions())) {
+ } else if (legal_file::get_movie_extensions($extension)) {
$movie = ORM::factory("item");
$movie->type = "movie";
$movie->parent_id = $parent->id;
diff --git a/modules/server_add/helpers/server_add.php b/modules/server_add/helpers/server_add.php
index 95f7be98..5cf08ce0 100644
--- a/modules/server_add/helpers/server_add.php
+++ b/modules/server_add/helpers/server_add.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/server_add/helpers/server_add_event.php b/modules/server_add/helpers/server_add_event.php
index d5fbc06c..a718e2fc 100644
--- a/modules/server_add/helpers/server_add_event.php
+++ b/modules/server_add/helpers/server_add_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php
index f107c0fd..b62bbcfa 100644
--- a/modules/server_add/helpers/server_add_installer.php
+++ b/modules/server_add/helpers/server_add_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -30,7 +30,6 @@ class server_add_installer {
`task_id` int(9) NOT NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
- module::set_version("server_add", 4);
server_add::check_config();
}
diff --git a/modules/server_add/helpers/server_add_theme.php b/modules/server_add/helpers/server_add_theme.php
index 04d128fc..7dfe6586 100644
--- a/modules/server_add/helpers/server_add_theme.php
+++ b/modules/server_add/helpers/server_add_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/server_add/models/server_add_entry.php b/modules/server_add/models/server_add_entry.php
index 8611441f..572ebcbd 100644
--- a/modules/server_add/models/server_add_entry.php
+++ b/modules/server_add/models/server_add_entry.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/server_add/module.info b/modules/server_add/module.info
index 4ce0a97d..dc455c71 100644
--- a/modules/server_add/module.info
+++ b/modules/server_add/module.info
@@ -2,6 +2,6 @@ name = "Server Add"
description = "Allows authorized users to load images directly from your web server"
version = 4
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:server_add"
-discuss_url = "http://gallery.menalto.com/forum_module_server_add"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:server_add"
+discuss_url = "http://galleryproject.org/forum_module_server_add"
diff --git a/modules/slideshow/helpers/slideshow_event.php b/modules/slideshow/helpers/slideshow_event.php
index 4a7a4c1f..add1e335 100644
--- a/modules/slideshow/helpers/slideshow_event.php
+++ b/modules/slideshow/helpers/slideshow_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/slideshow/helpers/slideshow_installer.php b/modules/slideshow/helpers/slideshow_installer.php
index 79751a95..22bd9534 100644
--- a/modules/slideshow/helpers/slideshow_installer.php
+++ b/modules/slideshow/helpers/slideshow_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -20,7 +20,6 @@
class slideshow_installer {
static function install() {
module::set_var("slideshow", "max_scale", 0);
- module::set_version("slideshow", 2);
}
static function upgrade($version) {
diff --git a/modules/slideshow/helpers/slideshow_theme.php b/modules/slideshow/helpers/slideshow_theme.php
index 62d64f48..bb022127 100644
--- a/modules/slideshow/helpers/slideshow_theme.php
+++ b/modules/slideshow/helpers/slideshow_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info
index 8c9a3176..2d71f710 100644
--- a/modules/slideshow/module.info
+++ b/modules/slideshow/module.info
@@ -2,6 +2,6 @@ name = "Slideshow"
description = "Allows users to view a slideshow of photos"
version = 2
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:slideshow"
-discuss_url = "http://gallery.menalto.com/forum_module_slideshow"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:slideshow"
+discuss_url = "http://galleryproject.org/forum_module_slideshow"
diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php
index 515b6891..19906c69 100644
--- a/modules/tag/controllers/admin_tags.php
+++ b/modules/tag/controllers/admin_tags.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php
index ee2888a5..bada9bac 100644
--- a/modules/tag/controllers/tag.php
+++ b/modules/tag/controllers/tag.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -86,6 +86,7 @@ class Tag_Controller extends Controller {
"previous_item" => $previous_item,
"next_item" => $next_item,
"sibling_count" => $tag->items_count($where),
+ "siblings_callback" => array(array($tag, "items"), array()),
"breadcrumbs" => array(
Breadcrumb::instance($root->title, $root->url())->set_first(),
Breadcrumb::instance(t("Tag: %tag_name", array("tag_name" => $tag->name)),
diff --git a/modules/tag/controllers/tag_name.php b/modules/tag/controllers/tag_name.php
index 1a1179fe..f96ab698 100644
--- a/modules/tag/controllers/tag_name.php
+++ b/modules/tag/controllers/tag_name.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 9af3843e..77d45a95 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -52,7 +52,7 @@ class Tags_Controller extends Controller {
$limit = Input::instance()->get("limit");
$tag_part = ltrim(end($tag_parts));
$tag_list = ORM::factory("tag")
- ->where("name", "LIKE", "{$tag_part}%")
+ ->where("name", "LIKE", Database::escape_for_like($tag_part) . "%")
->order_by("name", "ASC")
->limit($limit)
->find_all();
diff --git a/modules/tag/helpers/item_tags_rest.php b/modules/tag/helpers/item_tags_rest.php
index 98666338..c153cb9b 100644
--- a/modules/tag/helpers/item_tags_rest.php
+++ b/modules/tag/helpers/item_tags_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php
index 0eccb3ed..a946e01c 100644
--- a/modules/tag/helpers/tag.php
+++ b/modules/tag/helpers/tag.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php
index 5576ea81..eb5f5934 100644
--- a/modules/tag/helpers/tag_block.php
+++ b/modules/tag/helpers/tag_block.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index b54fbfb9..d62ae36e 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php
index 0d064b4b..1fd18f3e 100644
--- a/modules/tag/helpers/tag_installer.php
+++ b/modules/tag/helpers/tag_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -37,7 +37,6 @@ class tag_installer {
KEY(`item_id`, `id`))
DEFAULT CHARSET=utf8;");
module::set_var("tag", "tag_cloud_size", 30);
- module::set_version("tag", 3);
}
static function upgrade($version) {
diff --git a/modules/tag/helpers/tag_item_rest.php b/modules/tag/helpers/tag_item_rest.php
index d0182b7b..0b7a77fc 100644
--- a/modules/tag/helpers/tag_item_rest.php
+++ b/modules/tag/helpers/tag_item_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_items_rest.php b/modules/tag/helpers/tag_items_rest.php
index ec565cbb..5d9919e1 100644
--- a/modules/tag/helpers/tag_items_rest.php
+++ b/modules/tag/helpers/tag_items_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_rest.php b/modules/tag/helpers/tag_rest.php
index 059415aa..9ccb67ce 100644
--- a/modules/tag/helpers/tag_rest.php
+++ b/modules/tag/helpers/tag_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php
index c1e50ba2..b432e238 100644
--- a/modules/tag/helpers/tag_rss.php
+++ b/modules/tag/helpers/tag_rss.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_task.php b/modules/tag/helpers/tag_task.php
index bb095393..af9f2f15 100644
--- a/modules/tag/helpers/tag_task.php
+++ b/modules/tag/helpers/tag_task.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tag_theme.php b/modules/tag/helpers/tag_theme.php
index 51cd9751..81d1352f 100644
--- a/modules/tag/helpers/tag_theme.php
+++ b/modules/tag/helpers/tag_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/helpers/tags_rest.php b/modules/tag/helpers/tags_rest.php
index cdaf99f3..88a349be 100644
--- a/modules/tag/helpers/tags_rest.php
+++ b/modules/tag/helpers/tags_rest.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php
index 213ea0df..0550910d 100644
--- a/modules/tag/models/tag.php
+++ b/modules/tag/models/tag.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/module.info b/modules/tag/module.info
index 75d16bf0..19fbdb45 100644
--- a/modules/tag/module.info
+++ b/modules/tag/module.info
@@ -2,6 +2,6 @@ name = "Tags"
description = "Allows users to tag photos and albums"
version = 3
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:tag"
-discuss_url = "http://gallery.menalto.com/forum_module_tag"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:tag"
+discuss_url = "http://galleryproject.org/forum_module_tag"
diff --git a/modules/tag/tests/Tag_Item_Rest_Helper_Test.php b/modules/tag/tests/Tag_Item_Rest_Helper_Test.php
index b7f050d6..4d0a5514 100644
--- a/modules/tag/tests/Tag_Item_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tag_Item_Rest_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/tests/Tag_Rest_Helper_Test.php b/modules/tag/tests/Tag_Rest_Helper_Test.php
index ff4d5eeb..e0235b9a 100644
--- a/modules/tag/tests/Tag_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tag_Rest_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php
index 7e1e07f6..b9966c11 100644
--- a/modules/tag/tests/Tag_Test.php
+++ b/modules/tag/tests/Tag_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/tag/tests/Tags_Rest_Helper_Test.php b/modules/tag/tests/Tags_Rest_Helper_Test.php
index 16badb4d..39b7dfdb 100644
--- a/modules/tag/tests/Tags_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tags_Rest_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/config/identity.php b/modules/user/config/identity.php
index 956753bf..f2fcebf8 100644
--- a/modules/user/config/identity.php
+++ b/modules/user/config/identity.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/controllers/admin_users.php b/modules/user/controllers/admin_users.php
index d9cf174d..ed589a3f 100644
--- a/modules/user/controllers/admin_users.php
+++ b/modules/user/controllers/admin_users.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php
index adf1d000..ea14144f 100644
--- a/modules/user/controllers/password.php
+++ b/modules/user/controllers/password.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index bfa9d720..ee813446 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php
index a030a757..59c9859e 100644
--- a/modules/user/helpers/group.php
+++ b/modules/user/helpers/group.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php
index 75965611..f59cf76b 100644
--- a/modules/user/helpers/user.php
+++ b/modules/user/helpers/user.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/helpers/user_event.php b/modules/user/helpers/user_event.php
index 7622326f..40f6ddee 100644
--- a/modules/user/helpers/user_event.php
+++ b/modules/user/helpers/user_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php
index 1ba1aeaf..67f6a3d5 100644
--- a/modules/user/helpers/user_installer.php
+++ b/modules/user/helpers/user_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -138,6 +138,5 @@ class user_installer {
access::allow($registered, "view_full", $root);
module::set_var("user", "minimum_password_length", 5);
- module::set_version("user", 4);
}
} \ No newline at end of file
diff --git a/modules/user/helpers/user_theme.php b/modules/user/helpers/user_theme.php
index 298aaf73..c608cdf5 100644
--- a/modules/user/helpers/user_theme.php
+++ b/modules/user/helpers/user_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/libraries/drivers/IdentityProvider/Gallery.php b/modules/user/libraries/drivers/IdentityProvider/Gallery.php
index 0a0b9d79..67da33d6 100644
--- a/modules/user/libraries/drivers/IdentityProvider/Gallery.php
+++ b/modules/user/libraries/drivers/IdentityProvider/Gallery.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/models/group.php b/modules/user/models/group.php
index 0088ec31..a5d7c5bb 100644
--- a/modules/user/models/group.php
+++ b/modules/user/models/group.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index 6b2cd03b..af05c0c4 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/module.info b/modules/user/module.info
index 503bcd0d..d5128db4 100644
--- a/modules/user/module.info
+++ b/modules/user/module.info
@@ -3,6 +3,6 @@ description = "Gallery 3 user and group management"
version = 4
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:user"
-discuss_url = "http://gallery.menalto.com/forum_module_user"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:user"
+discuss_url = "http://galleryproject.org/forum_module_user"
diff --git a/modules/user/tests/No_Direct_ORM_Access_Test.php b/modules/user/tests/No_Direct_ORM_Access_Test.php
index 2f5089ef..30ea9cca 100644
--- a/modules/user/tests/No_Direct_ORM_Access_Test.php
+++ b/modules/user/tests/No_Direct_ORM_Access_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/tests/User_Groups_Test.php b/modules/user/tests/User_Groups_Test.php
index f213d319..50b3349c 100644
--- a/modules/user/tests/User_Groups_Test.php
+++ b/modules/user/tests/User_Groups_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/user/tests/User_Installer_Test.php b/modules/user/tests/User_Installer_Test.php
index 04dca68f..a26b72e6 100644
--- a/modules/user/tests/User_Installer_Test.php
+++ b/modules/user/tests/User_Installer_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php
index a80f82a9..b058d6a5 100644
--- a/modules/watermark/controllers/admin_watermarks.php
+++ b/modules/watermark/controllers/admin_watermarks.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -66,7 +66,7 @@ class Admin_Watermarks_Controller extends Admin_Controller {
$form = watermark::get_delete_form();
if ($form->validate()) {
- if ($name = module::get_var("watermark", "name")) {
+ if ($name = basename(module::get_var("watermark", "name"))) {
@unlink(VARPATH . "modules/watermark/$name");
module::clear_var("watermark", "name");
@@ -93,39 +93,30 @@ class Admin_Watermarks_Controller extends Admin_Controller {
access::verify_csrf();
$form = watermark::get_add_form();
- if ($form->validate()) {
+ // For TEST_MODE, we want to simulate a file upload. Because this is not a true upload, Forge's
+ // validation logic will correctly reject it. So, we skip validation when we're running tests.
+ if (TEST_MODE || $form->validate()) {
$file = $_POST["file"];
- $pathinfo = pathinfo($file);
// Forge prefixes files with "uploadfile-xxxxxxx" for uniqueness
- $name = preg_replace("/uploadfile-[^-]+-(.*)/", '$1', $pathinfo["basename"]);
- $name = legal_file::smash_extensions($name);
-
- if (!($image_info = getimagesize($file)) ||
- !in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
- message::error(t("Unable to identify this image file"));
+ $name = preg_replace("/uploadfile-[^-]+-(.*)/", '$1', basename($file));
+
+ try {
+ list ($width, $height, $mime_type, $extension) = photo::get_file_metadata($file);
+ // Sanitize filename, which ensures a valid extension. This renaming prevents the issues
+ // addressed in ticket #1855, where an image that looked valid (header said jpg) with a
+ // php extension was previously accepted without changing its extension.
+ $name = legal_file::sanitize_filename($name, $extension, "photo");
+ } catch (Exception $e) {
+ message::error(t("Invalid or unidentifiable image file"));
@unlink($file);
return;
}
- if (!in_array($pathinfo["extension"], legal_file::get_photo_extensions())) {
- switch ($image_info[2]) {
- case IMAGETYPE_GIF:
- $name = legal_file::change_extension($name, "gif");
- break;
- case IMAGETYPE_JPEG:
- $name = legal_file::change_extension($name, "jpg");
- break;
- case IMAGETYPE_PNG:
- $name = legal_file::change_extension($name, "png");
- break;
- }
- }
-
rename($file, VARPATH . "modules/watermark/$name");
module::set_var("watermark", "name", $name);
- module::set_var("watermark", "width", $image_info[0]);
- module::set_var("watermark", "height", $image_info[1]);
- module::set_var("watermark", "mime_type", $image_info["mime"]);
+ module::set_var("watermark", "width", $width);
+ module::set_var("watermark", "height", $height);
+ module::set_var("watermark", "mime_type", $mime_type);
module::set_var("watermark", "position", $form->add_watermark->position->value);
module::set_var("watermark", "transparency", $form->add_watermark->transparency->value);
$this->_update_graphics_rules();
diff --git a/modules/watermark/helpers/watermark.php b/modules/watermark/helpers/watermark.php
index 47301a6a..3357c14e 100644
--- a/modules/watermark/helpers/watermark.php
+++ b/modules/watermark/helpers/watermark.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/watermark/helpers/watermark_event.php b/modules/watermark/helpers/watermark_event.php
index 675bf68b..7547515f 100644
--- a/modules/watermark/helpers/watermark_event.php
+++ b/modules/watermark/helpers/watermark_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
diff --git a/modules/watermark/helpers/watermark_installer.php b/modules/watermark/helpers/watermark_installer.php
index 89489dc3..13338912 100644
--- a/modules/watermark/helpers/watermark_installer.php
+++ b/modules/watermark/helpers/watermark_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 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
@@ -33,7 +33,6 @@ class watermark_installer {
DEFAULT CHARSET=utf8;");
@mkdir(VARPATH . "modules/watermark");
- module::set_version("watermark", 2);
}
static function uninstall() {
diff --git a/modules/watermark/module.info b/modules/watermark/module.info
index 58efa43f..e5003cda 100644
--- a/modules/watermark/module.info
+++ b/modules/watermark/module.info
@@ -2,6 +2,6 @@ name = "Watermarks"
description = "Allows users to watermark their photos"
version = 2
author_name = "Gallery Team"
-author_url = "http://codex.gallery2.org/Gallery:Team"
-info_url = "http://codex.gallery2.org/Gallery3:Modules:watermark"
-discuss_url = "http://gallery.menalto.com/forum_module_watermark"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:watermark"
+discuss_url = "http://galleryproject.org/forum_module_watermark"
diff --git a/modules/watermark/tests/Admin_Watermarks_Controller_Test.php b/modules/watermark/tests/Admin_Watermarks_Controller_Test.php
new file mode 100644
index 00000000..0b4ba84b
--- /dev/null
+++ b/modules/watermark/tests/Admin_Watermarks_Controller_Test.php
@@ -0,0 +1,124 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 Admin_Watermarks_Controller_Test extends Gallery_Unit_Test_Case {
+ public function setup() {
+ $this->_save = array($_POST, $_SERVER);
+ $_SERVER["HTTP_REFERER"] = "HTTP_REFERER";
+ }
+
+ public function teardown() {
+ list($_POST, $_SERVER) = $this->_save;
+ }
+
+ public function add_watermark_test() {
+ // Source is a jpg file, watermark path has extension jpg
+ $name = test::random_name();
+ $source_path = MODPATH . "gallery/images/imagemagick.jpg";
+ $watermark_path = TMPPATH . "uploadfile-123-{$name}.jpg";
+ copy($source_path, $watermark_path);
+
+ // Setup and run Admin_Watermarks_Controller::add
+ $controller = new Admin_Watermarks_Controller();
+ $_POST["file"] = $watermark_path;
+ $_POST["csrf"] = access::csrf_token();
+ ob_start();
+ $controller->add();
+ $results = ob_get_clean();
+
+ // Add should be successful
+ $this->assert_equal(json_encode(array("result" => "success",
+ "location" => url::site("admin/watermarks"))), $results);
+ $this->assert_equal(file_get_contents($source_path),
+ file_get_contents(VARPATH . "modules/watermark/$name.jpg"));
+ $this->assert_equal("$name.jpg", module::get_var("watermark", "name"));
+ $this->assert_equal(114, module::get_var("watermark", "width"));
+ $this->assert_equal(118, module::get_var("watermark", "height"));
+ $this->assert_equal("image/jpeg", module::get_var("watermark", "mime_type"));
+ }
+
+ public function add_watermark_reject_illegal_file_test() {
+ // Source is a php file, watermark path has extension php
+ $name = test::random_name();
+ $source_path = MODPATH . "watermark/tests/Admin_Watermarks_Controller_Test.php";
+ $watermark_path = TMPPATH . "uploadfile-123-{$name}.php";
+ copy($source_path, $watermark_path);
+
+ // Setup and run Admin_Watermarks_Controller::add
+ $controller = new Admin_Watermarks_Controller();
+ $_POST["file"] = $watermark_path;
+ $_POST["csrf"] = access::csrf_token();
+ ob_start();
+ $controller->add();
+ $results = ob_get_clean();
+
+ // Add should *not* be successful, and watermark should be deleted
+ $this->assert_equal("", $results);
+ $this->assert_false(file_exists($watermark_path));
+ $this->assert_false(file_exists(VARPATH . "modules/watermark/$name.php"));
+ }
+
+ public function add_watermark_rename_legal_file_with_illegal_extension_test() {
+ // Source is a jpg file, watermark path has extension php
+ $name = test::random_name();
+ $source_path = MODPATH . "gallery/images/imagemagick.jpg";
+ $watermark_path = TMPPATH . "uploadfile-123-{$name}.php";
+ copy($source_path, $watermark_path);
+
+ // Setup and run Admin_Watermarks_Controller::add
+ $controller = new Admin_Watermarks_Controller();
+ $_POST["file"] = $watermark_path;
+ $_POST["csrf"] = access::csrf_token();
+ ob_start();
+ $controller->add();
+ $results = ob_get_clean();
+
+ // Add should be successful with file renamed as jpg
+ $this->assert_equal(json_encode(array("result" => "success",
+ "location" => url::site("admin/watermarks"))), $results);
+ $this->assert_equal(file_get_contents($source_path),
+ file_get_contents(VARPATH . "modules/watermark/$name.jpg"));
+ $this->assert_equal("$name.jpg", module::get_var("watermark", "name"));
+ $this->assert_equal(114, module::get_var("watermark", "width"));
+ $this->assert_equal(118, module::get_var("watermark", "height"));
+ $this->assert_equal("image/jpeg", module::get_var("watermark", "mime_type"));
+ }
+
+ public function add_watermark_reject_illegal_file_with_legal_extension_test() {
+ // Source is a php file, watermark path has extension jpg
+ $name = test::random_name();
+ $source_path = MODPATH . "watermark/tests/Admin_Watermarks_Controller_Test.php";
+ $watermark_path = TMPPATH . "uploadfile-123-{$name}.jpg";
+ copy($source_path, $watermark_path);
+
+ // Setup and run Admin_Watermarks_Controller::add
+ $controller = new Admin_Watermarks_Controller();
+ $_POST["file"] = $watermark_path;
+ $_POST["csrf"] = access::csrf_token();
+ ob_start();
+ $controller->add();
+ $results = ob_get_clean();
+
+ // Add should *not* be successful, and watermark should be deleted
+ $this->assert_equal("", $results);
+ $this->assert_false(file_exists($watermark_path));
+ $this->assert_false(file_exists(VARPATH . "modules/watermark/$name.php"));
+ $this->assert_false(file_exists(VARPATH . "modules/watermark/$name.jpg"));
+ }
+}