diff options
-rw-r--r-- | modules/exif/helpers/exif_event.php | 4 | ||||
-rw-r--r-- | modules/exif/helpers/exif_installer.php | 10 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 32 | ||||
-rw-r--r-- | modules/gallery/helpers/album.php | 12 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 10 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 17 | ||||
-rw-r--r-- | modules/gallery/module.info | 2 | ||||
-rw-r--r-- | modules/info/views/info_block.html.php | 2 |
8 files changed, 66 insertions, 23 deletions
diff --git a/modules/exif/helpers/exif_event.php b/modules/exif/helpers/exif_event.php index 826ec959..c5c48bdc 100644 --- a/modules/exif/helpers/exif_event.php +++ b/modules/exif/helpers/exif_event.php @@ -27,4 +27,8 @@ 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 66226061..b826224a 100644 --- a/modules/exif/helpers/exif_installer.php +++ b/modules/exif/helpers/exif_installer.php @@ -29,6 +29,12 @@ 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); } @@ -41,6 +47,8 @@ class exif_installer { } static function uninstall() { - Database::instance()->query("DROP TABLE IF EXISTS {exif_records};"); + $db = Database::instance(); + $db->query("DROP TABLE IF EXISTS {exif_records};"); + $db->query("ALTER TABLE {items} DROP COLUMN `captured`"); } } diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 7e5c6f75..4686b23d 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -23,6 +23,7 @@ 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"); @@ -313,7 +314,6 @@ class g2_import_Core { return $message; } - /** * Import a single album. */ @@ -357,16 +357,26 @@ class g2_import_Core { $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); $album->created = $g2_album->getCreationTimestamp(); - $order_map = array( - "originationTimestamp" => "captured", - "creationTimestamp" => "created", - "description" => "description", - "modificationTimestamp" => "updated", - "orderWeight" => "weight", - "pathComponent" => "name", - "summary" => "description", - "title" => "title", - "viewCount" => "view_count"); + 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]); + } + } + } + $direction_map = array( ORDER_ASCENDING => "asc", ORDER_DESCENDING => "desc"); diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 9cd746d7..eeeb7e52 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -166,12 +166,10 @@ class album_Core { * Return a structured set of all the possible sort orders. */ static function get_sort_order_options() { - 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")); + $sort_order = (object)array("fields" => array()); + module::event("get_sort_fields", $sort_order); + asort($sort_order->fields); + + return $sort_order->fields; } } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 64f2a9ff..446a8a91 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -53,4 +53,14 @@ 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 6500482b..aebb7a32 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -68,7 +68,6 @@ 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, @@ -268,7 +267,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 <a href=\"%url\">Gallery %version</a>"); - module::set_version("gallery", 12); + module::set_version("gallery", 13); } static function upgrade($version) { @@ -364,6 +363,20 @@ 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 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 diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index d8f36984..1142bbd4 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -16,7 +16,7 @@ <?= html::clean($item->name) ?> </li> <? endif ?> - <? if ($item->captured): ?> + <? if (module::is_active("exif") && $item->captured): ?> <li> <strong class="caption"><?= t("Captured:") ?></strong> <?= date("M j, Y H:i:s", $item->captured)?> |