From a00619b812393cf73d1c188af7961af820d36185 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 20 Sep 2009 20:59:18 -0700 Subject: * Move the captured field into the exif module where it is created and populated. * Create a new API event get_sort_fields that allows modules to contribute new sort fields that they manage. the only condition is that the module needs to add it to the item table. * Changed g2_import to call this api to get the allowable sort fields * Changed album::get_edit_form to call this new api to get the available sort fields Partial fix for ticket #627, as the Capture date is not available until the exif module is installed. --- modules/gallery/module.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/module.info') diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 70bd91e2..65a0691c 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 12 +version = 13 -- cgit v1.2.3 From dd31b1d39f9a342afc82cc7e446e36454a882cf9 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 21 Sep 2009 13:56:52 -0700 Subject: Revert "* Move the captured field into the exif module where it is created and populated." This reverts commit a00619b812393cf73d1c188af7961af820d36185. --- modules/exif/helpers/exif_event.php | 4 ---- modules/exif/helpers/exif_installer.php | 10 +-------- modules/g2_import/helpers/g2_import.php | 32 +++++++++------------------ modules/gallery/helpers/album.php | 12 +++++----- modules/gallery/helpers/gallery_event.php | 10 --------- modules/gallery/helpers/gallery_installer.php | 17 ++------------ modules/gallery/module.info | 2 +- modules/info/views/info_block.html.php | 2 +- 8 files changed, 23 insertions(+), 66 deletions(-) (limited to 'modules/gallery/module.info') diff --git a/modules/exif/helpers/exif_event.php b/modules/exif/helpers/exif_event.php index c5c48bdc..826ec959 100644 --- a/modules/exif/helpers/exif_event.php +++ b/modules/exif/helpers/exif_event.php @@ -27,8 +27,4 @@ class exif_event_Core { static function item_deleted($item) { Database::instance()->delete("exif_records", array("item_id" => $item->id)); } - - static function get_sort_fields($sort_order) { - $sort_order->fields["captured"] = t("Date captured"); - } } diff --git a/modules/exif/helpers/exif_installer.php b/modules/exif/helpers/exif_installer.php index b826224a..66226061 100644 --- a/modules/exif/helpers/exif_installer.php +++ b/modules/exif/helpers/exif_installer.php @@ -29,12 +29,6 @@ class exif_installer { PRIMARY KEY (`id`), KEY(`item_id`)) DEFAULT CHARSET=utf8;"); - - - $item_fields = $db->list_fields("items"); - if (empty($item_fields["captured"])) { - $db->query("ALTER TABLE {items} ADD COLUMN `captured` int(9) default NULL"); - } module::set_version("exif", 1); } @@ -47,8 +41,6 @@ class exif_installer { } static function uninstall() { - $db = Database::instance(); - $db->query("DROP TABLE IF EXISTS {exif_records};"); - $db->query("ALTER TABLE {items} DROP COLUMN `captured`"); + Database::instance()->query("DROP TABLE IF EXISTS {exif_records};"); } } diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 4686b23d..7e5c6f75 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -23,7 +23,6 @@ class g2_import_Core { public static $map = array(); private static $current_g2_item = null; - private static $order_map = false; static function is_configured() { return module::get_var("g2_import", "embed_path"); @@ -314,6 +313,7 @@ class g2_import_Core { return $message; } + /** * Import a single album. */ @@ -357,26 +357,16 @@ class g2_import_Core { $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); $album->created = $g2_album->getCreationTimestamp(); - if (self::$order_map === false) { - self::$order_map = array( - "originationTimestamp" => "captured", - "creationTimestamp" => "created", - "description" => "description", - "modificationTimestamp" => "updated", - "orderWeight" => "weight", - "pathComponent" => "name", - "summary" => "description", - "title" => "title", - "viewCount" => "view_count"); - $sort_order = (object)array("fields" => array()); - module::event("get_sort_fields", $sort_order); - foreach (self::$order_map as $g2_sort_key => $g3_sort_key) { - if (empty($sort_order->fields[$g3_sort_key])) { - unset(self::$order_map[$g2_sort_key]); - } - } - } - + $order_map = array( + "originationTimestamp" => "captured", + "creationTimestamp" => "created", + "description" => "description", + "modificationTimestamp" => "updated", + "orderWeight" => "weight", + "pathComponent" => "name", + "summary" => "description", + "title" => "title", + "viewCount" => "view_count"); $direction_map = array( ORDER_ASCENDING => "asc", ORDER_DESCENDING => "desc"); diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index eeeb7e52..9cd746d7 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -166,10 +166,12 @@ class album_Core { * Return a structured set of all the possible sort orders. */ static function get_sort_order_options() { - $sort_order = (object)array("fields" => array()); - module::event("get_sort_fields", $sort_order); - asort($sort_order->fields); - - return $sort_order->fields; + return array("weight" => t("Manual"), + "captured" => t("Date captured"), + "created" => t("Date uploaded"), + "title" => t("Title"), + "updated" => t("Date modified"), + "view_count" => t("Number of views"), + "rand_key" => t("Random")); } } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 446a8a91..64f2a9ff 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -53,14 +53,4 @@ class gallery_event_Core { $data[] = $item->name; $data[] = $item->title; } - - static function get_sort_fields($sort_order) { - $sort_order->fields = array_merge($sort_order->fields, - array("weight" => t("Manual"), - "created" => t("Date uploaded"), - "title" => t("Title"), - "updated" => t("Date modified"), - "view_count" => t("Number of views"), - "rand_key" => t("Random"))); - } } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index aebb7a32..6500482b 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -68,6 +68,7 @@ class gallery_installer { $db->query("CREATE TABLE {items} ( `id` int(9) NOT NULL auto_increment, `album_cover_item_id` int(9) default NULL, + `captured` int(9) default NULL, `created` int(9) default NULL, `description` varchar(2048) default NULL, `height` int(9) default NULL, @@ -267,7 +268,7 @@ class gallery_installer { module::set_var("gallery", "show_credits", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by Gallery %version"); - module::set_version("gallery", 13); + module::set_version("gallery", 12); } static function upgrade($version) { @@ -363,20 +364,6 @@ class gallery_installer { $db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL"); module::set_version("gallery", $version = 12); } - - if ($version == 12) { - // remove the capture field if exif is not installed and it has no data - if (!module::is_active("exif")) { - $total_records = $db->query("SELECT COUNT(id) as total_records FROM {items}") - ->current()->total_records; - $count_null = $db->query("SELECT COUNT(id) as count_null FROM {items} where `captured`is NULL") - ->current()->count_null; - if ($total_records == $count_null) { - $db->query("ALTER TABLE {items} DROP COLUMN `captured`"); - } - } - module::set_version("gallery", $version = 13); - } } static function uninstall() { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 65a0691c..70bd91e2 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 13 +version = 12 diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index 1142bbd4..d8f36984 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -16,7 +16,7 @@ name) ?> - captured): ?> + captured): ?>
  • captured)?> -- cgit v1.2.3 From b038e9cbb4d913088a26f8c4e6e4699de9c860d7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 23 Sep 2009 17:03:25 -0700 Subject: set the version number to 13, so we will update the default themes in the gallery vars --- modules/gallery/helpers/gallery_installer.php | 11 +++++++++++ modules/gallery/module.info | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'modules/gallery/module.info') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 6500482b..6ea1b227 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -364,6 +364,17 @@ class gallery_installer { $db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL"); module::set_version("gallery", $version = 12); } + + if ($version == 12) { + if (module::get_var("gallery", "active_site_theme") == "default") { + module::set_var("gallery", "active_site_theme", "wind"); + } + if (module::get_var("gallery", "active_admin_theme") == "admin_default") { + module::set_var("gallery", "active_admin_theme", "admin_wind"); + } + module::set_version("gallery", $version = 13); + } + } static function uninstall() { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 70bd91e2..65a0691c 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 12 +version = 13 -- cgit v1.2.3