From d2e558c0795aa730d5fd0b35dcee753be68c00ae Mon Sep 17 00:00:00 2001 From: bastianonm Date: Fri, 18 Oct 2013 17:28:44 +0000 Subject: [PATCH] * NextGen Gallery 2 support * NextGen Gallery Pro support --- WP-GPX-Maps.js | 34 ++++++++++++++++++++++++ readme.txt | 7 +++-- wp-gpx-maps.php | 4 ++- wp-gpx-maps_utils_nggallery.php | 46 ++++++++++++++++++++++++++++++--- 4 files changed, 84 insertions(+), 7 deletions(-) diff --git a/WP-GPX-Maps.js b/WP-GPX-Maps.js index cee632b..f1f6447 100644 --- a/WP-GPX-Maps.js +++ b/WP-GPX-Maps.js @@ -388,6 +388,40 @@ function _wpgpxmaps(params) }); + /* + + // Nextgen Pro Lightbox FIX + var _xx = jQuery("#ngimages_" + targetId + " .nextgen_pro_lightbox"); + if (_xx.length > 0) + { + + var rnd1 = Math.random().toString(36).substring(7); + var rnd2 = Math.random().toString(36).substring(7); + + //get first gallery without images + for (var _temp in galleries) { + var _gal = galleries[_temp]; + + if (_gal.source == "random_images" && _gal.wpgpxmaps != true ) + { + + _gal.source == "galleries"; + _gal.wpgpxmaps = true; + _transient_id = _temp.replace("gallery_","") + _gal["entity_ids"] = []; + _gal["image_ids"] = []; + _gal["gallery_ids"] = [96]; + for (var i=0;i<_xx.length;i++) + { + var __xx = jQuery(_xx[i]); + __xx.attr("data-nplmodal-gallery-id", _transient_id); + _gal["image_ids"].push(__xx.attr("data-image-id")); + } + break; + } + } + } + */ if ( jQuery("#ngimages_" + targetId + " span").length > 0 ) { diff --git a/readme.txt b/readme.txt index dddbafb..7c379cf 100644 --- a/readme.txt +++ b/readme.txt @@ -4,8 +4,8 @@ Contributors: bastianonm Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8VHWLRW6JBTML Tags: maps, gpx, gps, graph, chart, google maps, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence Requires at least: 2.0.0 -Tested up to: 3.5 -Stable tag: 1.1.46 +Tested up to: 3.6.1 +Stable tag: 1.2.0 Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map. @@ -176,6 +176,9 @@ Yes! 1. Altitude & Speed & Hearth rate == Changelog == += 1.2.0 = +* NextGen Gallery 2 support +* NextGen Gallery Pro support = 1.1.46 = * Added meters/miles chart unit of measure * Added Russian translation, thanks to G.A.P diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index bf26ca6..bcde295 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -3,7 +3,7 @@ Plugin Name: WP-GPX-Maps Plugin URI: http://www.devfarm.it/ Description: Draws a gpx track with altitude graph -Version: 1.1.46 +Version: 1.2.0 Author: Bastianon Massimo Author URI: http://www.pedemontanadelgrappa.it/ */ @@ -500,6 +500,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') currentIcon : "'.$currentIcon.'", waypointIcon : "'.$waypointIcon.'", zoomOnScrollWheel : "'.$zoomOnScrollWheel.'", + ngGalleries : ['.$ngGalleries.'], + ngImages : ['.$ngImages.'], pluginUrl : "'.plugins_url().'", langs : { altitude : "'.__("Altitude", "wp-gpx-maps").'", currentPosition : "'.__("Current Position", "wp-gpx-maps").'", diff --git a/wp-gpx-maps_utils_nggallery.php b/wp-gpx-maps_utils_nggallery.php index 01139da..b86a030 100644 --- a/wp-gpx-maps_utils_nggallery.php +++ b/wp-gpx-maps_utils_nggallery.php @@ -3,13 +3,20 @@ function isNGGalleryActive() { if (!function_exists('is_plugin_active')) { require_once(sitePath() . '/wp-admin/includes/plugin.php'); - } + } return is_plugin_active("nextgen-gallery/nggallery.php"); } + function isNGGalleryProActive() { + if (!function_exists('is_plugin_active')) { + require_once(sitePath() . '/wp-admin/includes/plugin.php'); + } + return is_plugin_active("nextgen-gallery-pro/nggallery-pro.php"); + } + function getNGGalleryImages($ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset, &$error) { - + $result = array(); $galids = explode(',', $ngGalleries); $imgids = explode(',', $ngImages); @@ -25,10 +32,12 @@ foreach ($imgids as $i) { array_push($pictures, nggdb::find_image($i)); } - + foreach ($pictures as $p) { + $item = array(); $item["data"] = $p->thumbHTML; + if (is_callable('exif_read_data')) { $exif = @exif_read_data($p->imagePath); @@ -57,7 +66,36 @@ { $error .= "Sorry, exif_read_data function not found! check your hosting..
"; } - } + } + + +/* START FIX NEXT GEN GALLERY 2.x */ + + $renderer = C_Component_Registry::get_instance()->get_utility('I_Displayed_Gallery_Renderer'); + $params['gallery_ids'] = $ngGalleries; + $params['image_ids'] = $ngImages; + $params['display_type'] = NEXTGEN_GALLERY_BASIC_THUMBNAILS; + $params['images_per_page'] = 999; + // also add js references to get the gallery working + $dummy = $renderer->display_images($params, $inner_content); + +/* START FIX NEXT GEN GALLERY PRO */ + + if (preg_match("/data-nplmodal-gallery-id=[\"'](.*?)[\"']/", $dummy, $m)) + { + $galid = $m[1]; + if ($galid) + { + for($i = 0; $i < count($result); ++$i) + { + $result[$i]["data"] = str_replace("%PRO_LIGHTBOX_GALLERY_ID%", $galid, $result[$i]["data"]); + } + } + } + +/* END FIX NEXT GEN GALLERY PRO */ + +/* END FIX NEXT GEN GALLERY 2.x */ } catch (Exception $e) { $error .= 'Error When Retrieving NextGen Gallery galleries/images: $e
';