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/g2_import/helpers/g2_import.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'modules/g2_import/helpers') 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"); -- cgit v1.2.3