From 8f5e96857a09fa04386fc7725cc80c1fe690b56c Mon Sep 17 00:00:00 2001 From: Bruno Pesenti Date: Sun, 26 Feb 2017 19:50:29 +0100 Subject: [PATCH] infobox avec vignette et info wikipedia pour ZP, Flickr et WP sur single.php --- functions.php | 931 ++++++++++++++++++++++++++++++-------------------- infos.txt | 13 + single.php | 118 +++++-- tpl-carte.php | 6 +- 4 files changed, 664 insertions(+), 404 deletions(-) diff --git a/functions.php b/functions.php index de0768b..26c6584 100644 --- a/functions.php +++ b/functions.php @@ -8,26 +8,6 @@ update_option( 'wr2x_pro_serial', _( $serial ) ); set_transient( 'wr2x_validated', $serial, 3600 * 24 * 100 ); -/* -add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); - -function enqueue_parent_styles() { - wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); -} -*/ -/**/ - -//add_action( 'init', 'add_author_rules' ); -/* -function add_author_rules() { - add_rewrite_rule( - "en-cours-2-page-?([0-9]{1,})/?", - "index.php?page_id=804&toto=$matches[1]", - "top"); - $wp_rewrite->flush_rules(); -} -*/ - function google_jquery() { if (!is_admin()) { wp_deregister_script('jquery'); @@ -39,7 +19,6 @@ function google_jquery() { add_action('init', 'google_jquery'); - function enqueue_my_scripts() { $lightbox_choice = dess_setting('dess_lightbox_choice'); @@ -75,10 +54,9 @@ function enqueue_my_scripts() { //wp_enqueue_script( 'googlemaps', ''; - } add_action( 'wp_enqueue_scripts', 'enqueue_my_scripts' ); -/**/ + function my_theme_enqueue_styles() { @@ -108,7 +86,8 @@ function custom_class( $classes ) { } return $classes; } -/**/ + + // Bouton Shortcode Zenphoto dans l'éditeur function register_button_zp( $buttons ) { @@ -133,6 +112,7 @@ function my_zenphoto_button() { } add_action('init', 'my_zenphoto_button'); + // Bouton Shortcode Flickr dans l'éditeur function register_button_flk( $buttons ) { @@ -157,6 +137,13 @@ function my_flickr_button() { } add_action('init', 'my_flickr_button'); + +/* +accueil.php +archive.php +index.php +tpl-blog.php +*/ function RelativeTime() { $jour = get_the_date('U'); @@ -187,6 +174,9 @@ function RelativeTime() { } +/* +livre-d-or.php +*/ function getRandomFile($start_dir) { chdir($start_dir); @@ -204,43 +194,11 @@ function getRandomFile($start_dir) { } -function preprint($s, $return=false) { - $x = "
"; 
-    $x .= print_r($s, 1); 
-    $x .= "
"; - if ($return) return $x; - else print $x; - } - - -/* photo du mois */ - -function exif_date($date,$apn) { - //'Model' => string 'Canon EOS 50D' (length=13) - //50D: 'DateTimeOriginal' => string '2009:12:05 12:42:33' (length=19) - - //'Model' => string 'Canon EOS 7D' (length=12) - //7D: DateTimeOriginal' => string '2010-02-20T15:07:05.24+01:00' (length=28) - - // -> 50D - if (!preg_match("/7D/", $apn)) { - $pieces = explode(' ', $date); - list($yy, $mm, $dd) = explode(':', $pieces[0]); - list($hh, $min, $ss) = explode(':', $pieces[1]); - } - // 7D - else { - $pieces = explode('T', $date); - list($yy, $mm, $dd) = explode('-', $pieces[0]); - $pieces_h = explode('.', $pieces[1]); - list($hh, $min, $ss) = explode(':', $pieces_h[0]); - } - $timestamp = mktime((int) $hh, (int) $min, (int) $ss, (int) $mm, (int) $dd, (int) $yy, '-1'); - $date = date('d.m.Y à H:i',$timestamp); - return $date; - } - - +/* +ce-mois.php +ce-mois-ci.php +*functions.php - date_archive() +*/ function mois2 ($mois) { switch ($mois) { @@ -288,22 +246,9 @@ function mois2 ($mois) { } -function display ($filename,$album) { - $display = '
'. - '
' . - ''. - ''. - ''. - '
'. - ''. - '
'; - return $display; - } - - +/* +ce-mois-ci.php +*/ function displayRetina ($filename,$album) { global $ppage; @@ -318,7 +263,6 @@ function displayRetina ($filename,$album) { $thumbpath = "../zenphoto/cache/" . $album . "/"; $a = $path . $filename; - //echo $a. "
"; $file_sd = $thumbpath . $file[0] . "_180_thumb.jpg"; $file_hd = $thumbpath . $file[0] . "_360_thumb.jpg"; @@ -326,7 +270,7 @@ function displayRetina ($filename,$album) { $file_sd = $path . $file[0] . "_180_watermark.jpg"; $file_hd = $path . $file[0] . "_360_watermark.jpg"; */ - // + $th_sd = false; $th_hd = false; @@ -348,7 +292,6 @@ function displayRetina ($filename,$album) { 'height' => $size_hd[1] ); } - //preprint($thumb); if (($th_sd == true) && ($th_hd == true)) { $standard = $thumb['sd']['url'] . ', ' . $thumb['hd']['url'] . ' 2x'; @@ -384,19 +327,9 @@ function displayRetina ($filename,$album) { } -function get_image_title ($photo) { - $photo = '../zenphoto/albums/photos-du-mois/' . $photo; - $size = getimagesize($photo, $info); - if (isset($info["APP13"])) { - $iptc = iptcparse($info["APP13"]); - //print_r($iptc); - $caption = isset($iptc['2#120'][0]); - $graphic_name = isset($iptc['2#005'][0]); - } - return $caption; - } - - +/* +*functions.php - displayRetina() displayRetina() +*/ function date_archive ($chaine) { $pieces = explode(".", $chaine); $b = explode("_", $pieces[0]); @@ -406,7 +339,8 @@ function date_archive ($chaine) { return $chaine; } -/* Images externes (pas de Retina) */ + +/* SHORTCODE: Images externes (pas de Retina) */ function picture_handler($atts, $content=null) { @@ -450,6 +384,8 @@ function picture_handler($atts, $content=null) { add_shortcode( 'picture', 'picture_handler' ); +/* SHORTCODE: Images sur Flickr */ + function flickr_handler($atts, $content=null) { global $coord; @@ -468,14 +404,6 @@ function flickr_handler($atts, $content=null) { $pid=$e[5]; } -/* -[flickr url="https://www.flickr.com/photos/funnymac/27868468454/"] - -[flickr pid="27868468454"] - -[flickr pid="27868468454" version="Small"] -*/ - switch (strtolower($version)) { case "square": $img_sd = "Square"; @@ -537,6 +465,7 @@ function flickr_handler($atts, $content=null) { $lb = filter_var($lb, FILTER_SANITIZE_STRING); $info = array(); */ +//https://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=3884af4190ac97a95fd4777dba0d9f21&photo_id=27868468454&format=json&nojsoncallback=1 /* lb ???? */ @@ -556,6 +485,9 @@ function flickr_handler($atts, $content=null) { $taille = $response['sizes']['size']; + // Vignette wikipedia Small (240x160) Large Square (150x150) + $vignette = "Small"; + foreach ($taille as $val) { if ($val['label'] == $img_sd) { $mediumSRC = $val['source']; @@ -567,8 +499,15 @@ function flickr_handler($atts, $content=null) { $w_largeSRC = $val['width']; $h_largeSRC = $val['height']; } + if ($val['label'] == $vignette) { + $wikiSRC = $val['source']; + $w_wikiSRC = $val['width']; + $h_wikiSRC = $val['height']; + } } + $wikiIMG = ' '; + /* Info de l'image */ $url2 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getInfo'; @@ -585,8 +524,9 @@ function flickr_handler($atts, $content=null) { $lat = $response2['photo']['location']['latitude']; $long = $response2['photo']['location']['longitude']; $tag = $response2['photo']['tags']['tag']; - $desc = $response2['photo']['description']['_content']; + $descrip = $response2['photo']['description']['_content']; $copy = $response2['photo']['owner']['username']; + $desc = preg_replace('/[\x00-\x1F\x7F]/u', ' ', $descrip); //UTF-8 $tags = array(); foreach ($tag as $val) { @@ -607,32 +547,33 @@ function flickr_handler($atts, $content=null) { $response3 = json_decode($result3, true); $exif = $response3['photo']['exif']; - //preprint($exif); $meta = array(); foreach ($exif as $val) { if ($val['tag'] == 'FNumber') $meta['aperture'] = $val['raw']['_content']; - //if ($val['tag'] == 'xxx') $meta['credit'] = $val['raw']['_content']; - $meta['credit'] = $copy; if ($val['tag'] == 'Model') $meta['camera'] = $val['raw']['_content']; - //if ($val['tag'] == 'xxx') $meta['caption'] = $val['raw']['_content']; if ($val['tag'] == 'DateTimeOriginal') $meta['created_timestamp'] = strtotime($val['raw']['_content']); - //if ($val['tag'] == 'xxx') $meta['copyright'] = $val['raw']['_content']; if ($val['tag'] == 'FocalLength') $meta['focal_length'] = $val['raw']['_content']; if ($val['tag'] == 'ISO') $meta['iso'] = $val['raw']['_content']; if ($val['tag'] == 'ExposureTime') $meta['shutter_speed'] = $val['raw']['_content']; - //if ($val['tag'] == 'xxx') $meta['title'] = $val['raw']['_content']; - $meta['title'] = $title; if ($val['tag'] == 'Orientation') $meta['orientation'] = $val['raw']['_content']; + //if ($val['tag'] == 'xxx') $meta['credit'] = $val['raw']['_content']; + //if ($val['tag'] == 'xxx') $meta['caption'] = $val['raw']['_content']; + //if ($val['tag'] == 'xxx') $meta['copyright'] = $val['raw']['_content']; + //if ($val['tag'] == 'xxx') $meta['title'] = $val['raw']['_content']; + $meta['credit'] = $copy; + $meta['title'] = $title; $meta['latitude'] = $lat; $meta['longitude'] = $long; $meta['keywords'] = $tags; + $meta['medium'] = $mediumSRC; + $meta['large'] = $largeSRC; + $meta['wiki'] = $wikiIMG; + $meta['desc'] = $desc; //$meta['latitudeRef'] //$meta['longitudeRef'] //$meta['altitude'] - $meta['medium'] = $mediumSRC; - $meta['large'] = $largeSRC; } @@ -654,7 +595,8 @@ function flickr_handler($atts, $content=null) { if ($meta['caption'] != "") $fichier = $meta['caption']; else if ($meta['title'] != "") $fichier = $meta['title']; //else $fichier = end(explode("/", $court)); - array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier)); + + array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['desc'], $meta['wiki'])); } return $links; @@ -662,6 +604,8 @@ function flickr_handler($atts, $content=null) { add_filter( 'the_content', 'do_shortcode'); add_shortcode( 'flickr', 'flickr_handler' ); + +/* SHORTCODE: Images sur Zenphoto */ function zenphoto_handler($atts, $content=null) { @@ -716,7 +660,6 @@ function zenphoto_handler($atts, $content=null) { } $result->close(); } - $img_query = "SELECT `desc`, `title`, `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "'"; if ($result = $mysqli->query($img_query)) { @@ -728,7 +671,6 @@ function zenphoto_handler($atts, $content=null) { } $result->close(); } - if (($album != "") && ($image == "")) { // Trouver le filename de la plus récente image de l'album @@ -751,9 +693,40 @@ function zenphoto_handler($atts, $content=null) { if ($capt[0] != "") $title = $capt[0]; elseif ($capt[1] != "") $title = $capt[1]; elseif ($capt[2] != "") $title = $capt[2]; - + $img = substr($image, 0, strlen($image) - 4); +/* + $sizewiki = "180_thumb"; + $imgwiki = 'cache/' . $album . '/' . urlencode($img) . '_' . $sizewiki . '.jpg'; + + $filewiki = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . $imgwiki; + $zp_size = ""; + $zp_size = getimagesize(htmlentities($filewiki)); + //var_dump($filewiki); + + //$wikiSRC = ''; + $wikiSRC = ''; + var_dump($wikiSRC); +*/ + + //var_dump($coord); + //array_push($coord, array($meta['latitude']); + + /* + '' (length=153) + + ' (length=95) + ' (length=148) + + 2014-10-21_pontdarc_0406_180_thumb.jpg + 2014-10-21_pontdarc_0406_300_thumb.jpg + + $wikiIMG = '\"\"'; + + //array_push($coord, array(number_format($lat, 6), number_format($long, 6), $meta['title'], $attach, $meta['description'], $thumbnail)); + */ + $filename = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . 'cache/' . $album . '/' . urlencode($img) . '_' . $size . '_watermark.jpg'; $zp_size = getimagesize(htmlentities($filename)); @@ -776,7 +749,34 @@ add_shortcode( 'zenphoto', 'zenphoto_handler' ); /* -zp_query: récupère les exifs depuis la bdd zenphoto +* thumb_ZP_wiki: crée la vignette (zenphoto) pour infobox wikipedia +* +* add_exif() +*/ + +function thumb_ZP_wiki ($image, $album) { + + $zenphoto_url = dess_setting('dess_zenphoto'); + + $img = substr($image, 0, strlen($image) - 4); + + $sizewiki = "180_thumb"; + $imgwiki = 'cache/' . $album . '/' . urlencode($img) . '_' . $sizewiki . '.jpg'; + + $filewiki = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . $imgwiki; + $zp_size = ""; + $zp_size = getimagesize(htmlentities($filewiki)); + + $wikiSRC = ''; + + return $wikiSRC; +} + + +/* +* zp_query_exif: récupère les exifs depuis la bdd zenphoto +* +*functions.php - zenphoto_handler2() add_exif() */ function zp_query_exif($zpimage) { @@ -830,6 +830,7 @@ Array 'credit' => '', 'camera' => '', 'caption' => '', + //'description' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, @@ -853,12 +854,20 @@ Array if ( ! empty( $exif[0] ) ) { $meta['camera'] = $exif[0]; } - //caption + //caption (ZP desc (Description) + /* if ( ! empty( $exif[12] ) ) { $desc = explode(':', $exif[12]); $description = explode('"', end($desc)); $meta['description'] = utf8_encode($description[1]); } + */ + if ( ! empty( $exif[12] ) ) { + $v = unserialize($exif[12]); + $caption = reset($v); + $meta['caption'] = utf8_encode($caption); + //var_dump($meta['caption']); + } if ( ! empty( $exif[1] ) ) { //$meta['created_timestamp'] = $exif[1]; @@ -875,10 +884,14 @@ Array $shutter = explode(' ', $exif[2]); $meta['shutter_speed'] = $shutter[0]; } - //title + //title (ZP title (Titre) if ( ! empty( $exif[13] ) ) { - //echo "exif: " . $exif[13] . "
"; - // a:1:{s:5:"fr_FR";s:30:"2011-05-15_GP-France-2011_9798";} + $z = $exif[13]; // str + $w = unserialize($z); // arr + + if ($w != false) $titre = reset($w); + elseif (($w == false) && is_string($z)) $titre = $z; + /* $titr = explode(':', $exif[13]); if (count($titr) == 1) { $meta['title'] = utf8_encode($titr[0]); @@ -887,6 +900,8 @@ Array $titre = explode('"', end($titr)); $meta['title'] = utf8_encode($titre[1]); } + */ + $meta['title'] = utf8_encode($titre); } if ( ! empty( $exif[16] ) ) { $meta['orientation'] = $exif[16]; @@ -911,6 +926,7 @@ Array } //keywords if ( ! empty( $exif[19] ) ) { + //imageid $img = $exif[19]; $result2 = $mysqli->query("SELECT `tagid` FROM `" . $zp_prefix . "obj_to_tag` WHERE `type`='images' AND `objectid`='$img'"); @@ -923,30 +939,89 @@ Array } $meta['keywords'] = $tags; } + //preprint($meta); return $meta; } -function add_class_lightbox($content) { +/* +* add_class_lightbox: FILTER +* +* - Ajoute la class pour les lightbox +* - Recherche des données pour wikipédia (pour images WP) +*/ +function add_class_lightbox($content) { + + global $coord; + $selector = dess_setting('dess_lightbox_select'); //Check the page for link images direct to image (no trailing attributes) $string = '/<\/a>/i'; preg_match_all( $string, $content, $matches, PREG_SET_ORDER); + //Check which attachment is referenced + $i = 0; foreach ($matches as $val) { + + // Ajoute la class pour les lightbox $slimbox_caption = ''; $post = get_post($val[5]); + //var_dump($post); $slimbox_caption = esc_attr( $post->post_content ); //Replace the instance with the lightbox and title(caption) references. Won't fail if caption is empty. $string = ''; $replace = ''; $content = str_replace( $string, $replace, $content); + + // Recherche des données pour wikipédia + //$attach = $matches[$i][5]; + //$photo = wp_get_attachment_metadata( $attach ); + $photo = wp_get_attachment_metadata( $post->ID ); + $exifs = $photo['image_meta']; + + if ((safe_array_access($exifs, 'latitude')) && (safe_array_access($exifs, 'longitude'))) { + //if ((isset($exifs['latitude'])) && (isset($exifs['longitude']))) { + + $attribut = wp_prepare_attachment_for_js( $post->ID ); + //var_dump($attribut); + + $lat = gps($exifs['latitude'], trim($exifs['latitude_ref'])); + $long = gps($exifs['longitude'], trim($exifs['longitude_ref'])); + /**/ + $attach = $attribut['id']; + $caption = ""; + $capt = $attribut['caption']; + echo "capt: $capt
"; + $title = $attribut['title']; + echo "title: $title
"; + $alt = $attribut['alt']; + $image = $attribut['url']; + $description = $attribut['description']; + echo "description: $description
"; + $thumbnail = $attribut['sizes']['thumbnail']; + $thumbnailWiki = '' . $attribut['alt'] . ''; + + // ?????? + //$gallery[] = $attach; + + if ($capt != "") $caption = $capt; + elseif ($title != "") $caption = $title; + + var_dump($caption, $description); + + // On crée le tableau $coord qui regroupe toutes les données pour le waypoint (lat,long, titre, n° attachment, description, vignette) + + array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnailWiki)); + + } //if + + $i++; } return $content; @@ -960,6 +1035,8 @@ if ( ! function_exists( 'creator_post_nav' ) ) : * Display navigation to next/previous post when applicable. * * @since Twenty Thirteen 1.0 + * + * single.php */ function creator_post_nav() { global $post; @@ -992,6 +1069,8 @@ if ( ! function_exists( 'creator_entry_meta' ) ) : * Create your own twentythirteen_entry_meta() to override in a child theme. * * @since Twenty Thirteen 1.0 + * + * single.php */ function creator_entry_meta() { if ( is_sticky() && is_home() && ! is_paged() ) @@ -1024,7 +1103,7 @@ function creator_entry_meta() { endif; -if ( ! function_exists( 'twentythirteen_entry_date' ) ) : +if ( ! function_exists( 'creator_entry_date' ) ) : /** * Print HTML with date information for current post. * @@ -1034,6 +1113,8 @@ if ( ! function_exists( 'twentythirteen_entry_date' ) ) : * * @param boolean $echo (optional) Whether to echo the date. Default true. * @return string The HTML-formatted post date. + * + * functions.php - creator_entry_meta() */ function creator_entry_date( $echo = true ) { if ( has_post_format( array( 'chat', 'status' ) ) ) @@ -1056,6 +1137,15 @@ function creator_entry_date( $echo = true ) { endif; +/* +* addexif: FILTER +* +* - filtre les #id attachment et zp +* - filtre les liens a zenphoto et wordpress +* - rajoute les exifs sous les images, les données géo +* - remplit le tableau $coord +*/ + function addexif ($content) { global $post; global $coord; @@ -1064,16 +1154,8 @@ function addexif ($content) { $display_exif = dess_setting('dess_display_exif'); $display_gps = dess_setting('dess_display_gps'); -/* -# Avec ini_set (suffixage automatique avec un timestamp) : -ini_set('xdebug.trace_output_dir', dirname(__FILE__)); -ini_set('xdebug.trace_output_name', 'xdebug_trace_%u'); -xdebug_start_trace(null, XDEBUG_TRACE_COMPUTERIZED); - -# Fichier unique : -xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); -*/ - + $zenphoto_coord = false; + if ($display_exif == true) { $matches3 = array(); @@ -1091,15 +1173,10 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); //$pattern = '/
]*>(.*?)\<\/div>/'; //$pattern = '#((?:]+>\s*)?]+>(?:\s*)?)(.*)#is'; - $pattern = '/
]*>(.*?)\<\/div>/'; //ok //$pattern = '/
]*>(.*?)\<\/div>/'; + + $pattern = '/
]*>(.*?)\<\/div>/'; //ok preg_match_all($pattern, $content, $matches, PREG_SET_ORDER); - //preprint($matches); - /* - echo "matches[0][0]"; //
...
- echo "matches[0][1]"; // 1114 - echo "matches[0][2]"; // ... - */ // Pour tous les DIV (attachment) on cherche les for ($i = 0; $i <= (count($matches) - 1); $i++) { @@ -1109,24 +1186,50 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); array_push($matches3, array($matches2[0][1], $matches[$i][0])); - /* - echo "matches2[0][0]"; // Vautour dans le brouillard de Rémuzat - echo $matches2[0][0]; - echo "matches2[0][1]"; // http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789.jpg - echo $matches2[0][1]; - echo "matches2[0][2]"; // Vautour dans le brouillard de Rémuzat - echo $matches2[0][2]; - */ - $court = $matches2[0][1]; + $pid = ""; - if (substr_count($court, "wordpress") > 0) $meta = creator_get_exif( $court ); + if (substr_count($court, "wordpress") > 0) { + + $meta = creator_get_exif( $court ); + //var_dump($meta); + /* + //var_dump($matches2); + + $attach = $matches[$i][2]; + $pid = $attach; + + //$attribut = wp_prepare_attachment_for_js( $image->ID ); + $attribut = wp_prepare_attachment_for_js( $attach ); + //var_dump($attribut); + + //$attach = $attribut['id']; + $caption = ""; + //$capt = $attribut['caption']; + //$title = $attribut['title']; + $alt = $attribut['alt']; + //$image = $attribut['url']; + $description = $attribut['description']; + $thumbnail = $attribut['sizes']['thumbnail']; + //$thumbnail = '' . $attribut['alt'] . ''; + $img_thumb_ZP_wiki = '' . $attribut['alt'] . ''; + + if ($capt != "") $caption = $capt; + elseif ($title != "") $caption = $title; + + // On crée le tableau $coord qui regroupe toutes les données pour le waypoint (lat,long, titre, n° attachment, description, vignette) + + //array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnail)); + */ + } elseif (substr_count($court, "zenphoto") > 0) { - //echo $court; + $img = explode("/", $court); $zp_image = end($img); - $zp_album = prev($img); + $zp_album = prev($img); + $img_thumb_ZP_wiki = thumb_ZP_wiki($zp_image, $zp_album); $meta = zp_query_exif( $zp_image ); + $zenphoto_coord = true; } $exif_array = img_wp_exif( $meta ); @@ -1137,7 +1240,10 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); if ($meta['caption'] != "") $fichier = $meta['caption']; else if ($meta['title'] != "") $fichier = $meta['title']; else $fichier = end(explode("/", $court)); - array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier)); + + if ($zenphoto_coord == true) { + array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['caption'], $img_thumb_ZP_wiki)); + } } } // for @@ -1146,7 +1252,6 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); $pattern2 = '/]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU'; preg_match_all($pattern2, $content , $matches4, PREG_SET_ORDER); - //var_dump($matches4); for ($i = 0; $i <= (count($matches4) - 1); $i++) { $ancien = $matches4[$i][0]; @@ -1171,7 +1276,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); if ($meta['caption'] != "") $fichier = $meta['caption']; else if ($meta['title'] != "") $fichier = $meta['title']; else $fichier = end(explode("/", $court)); - array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier)); + //array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier)); } } // if in_multiarray @@ -1180,16 +1285,20 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED); // si source zenphoto elseif ((substr_count($ancien, 'zenphoto') != 0) and (substr_count($ancien, '"; $exifInfo .= "" . $exif_array['camera'] . ""; $exifInfo .= "" . $exif_array['shutter_speed'] . ""; @@ -1289,7 +1413,6 @@ Array $exifInfo .= ""; $exifInfo .= (($exif_array['lens'] != "") ? $exif_array['lens'] : $exif_array['focal_length']); $exifInfo .= ""; - //$exifInfo .= "
"; /* // lien exif (texte) $exifInfo = ""; @@ -1305,11 +1428,9 @@ Array if ($exif_array['latitude'] != "") { // lien lat/long/alt (avec icones) - //$exifGPS = "
"; $exifGPS .= "" . $exif_array['latitude'] . ""; $exifGPS .= "" . $exif_array['longitude'] . ""; $exifGPS .= "" . $exif_array['altitude'] . ""; - //$exifGPS .= "
"; // lien lat/long/alt (texte) //$exifGPS .= __('Latitude: ','CreatorThemeRes-child') . $exif_array['latitude'] . __(' Longitude: ','CreatorThemeRes-child') . $exif_array['longitude'] . __(' Altitude: ','CreatorThemeRes-child') . number_format($exif_array['altitude']) . 'm'; @@ -1326,6 +1447,15 @@ Array } +/* +* creator_get_exif: récupère les exifs (et données GPS) pour les images WP +* +* entree $file (str) +* retourne $meta (array) +* +* functions.php - add_exif() +*/ + function creator_get_exif( $file ) { /* if ( ! file_exists( $file ) ) { @@ -1333,7 +1463,7 @@ function creator_get_exif( $file ) { return false; } */ - echo "file: " . $file . "
"; + //echo "file: " . $file . "
"; list( , , $sourceImageType ) = getimagesize( $file ); @@ -1373,7 +1503,7 @@ function creator_get_exif( $file ) { if ( ! empty( $info['APP13'] ) ) { $iptc = iptcparse( $info['APP13'] ); - preprint($iptc); + //preprint($iptc); // Headline, "A brief synopsis of the caption." if ( ! empty( $iptc['2#105'][0] ) ) { @@ -1424,7 +1554,7 @@ function creator_get_exif( $file ) { if ( is_callable( 'exif_read_data' )) { $exif = @exif_read_data( $file ); -preprint($exif); + //preprint($exif); if ( ! empty( $exif['ImageDescription'] ) ) { mbstring_binary_safe_encoding(); @@ -1537,13 +1667,23 @@ preprint($exif); * @param int $sourceImageType Type of image. * @param array $iptc IPTC data. */ - //return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc ); + //return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc ); return $meta; } + +/* +* Convertisseurs de valeurs GPS (latitude, longitude, altitude (+Ref)) +* +* geo_frac2dec() - functions.php: creator_get_exif() geo_single_fracs2dec() +* gps() - functions.php: add_class_lightbox() creator_get_exif() - tpl-carte.php +* geo_single_fracs2dec() - +* ctc_exif_date2ts() - functions.php: creator_get_exif() +*/ + function geo_single_fracs2dec($fracs) { return geo_frac2dec($fracs[0]) + geo_frac2dec($fracs[1]) / 60 + @@ -1573,6 +1713,24 @@ function gps($coordinate, $hemisphere) { return $sign * ($degrees + $minutes/60 + $seconds/3600); } +// wp_exif_date2ts +if ( ! function_exists( 'wp_exif_date2ts' ) ) : +function ctc_exif_date2ts($str) { + @list( $date, $time ) = explode( ' ', trim($str) ); + @list( $y, $m, $d ) = explode( ':', $date ); + + return strtotime( "{$y}-{$m}-{$d} {$time}" ); +} +endif; // + +/* +* mapgallery: affiche la galerie sur la Page Map +* +* entree $attr (array) shortcode gallery +* retourne $output (str) +* +* tpl-carte.php +*/ function mapgallery( $attr ) { /* @@ -1716,14 +1874,14 @@ function mapgallery( $attr ) { return $output; } - + remove_shortcode('gallery', 'gallery_shortcode'); add_shortcode('gallery', 'creator_gallery_shortcode'); /** - * Builds the Gallery shortcode output. + * Builds the Gallery shortcode output. (*** Modifié pour ajouter des liens vers lightbox***) * * This implements the functionality of the Gallery Shortcode for displaying * WordPress images on a post. @@ -1947,6 +2105,15 @@ function creator_gallery_shortcode( $attr ) { return $output; } + +/* +* childtheme_customize_register(): modifie la page des options du thème child +* +* entree +* retourne +* +* +*/ //http://cssmary.com/wordpress/customizer-api-child-theme/ function childtheme_customize_register( $wp_customize ) { @@ -2107,6 +2274,12 @@ function choice_c_callback( $control ) { } */ + +/* +* show_bookmark_list(): SHORCODE modifie la liste des liens (wp_list_bookmarks()) +* +*/ + function show_bookmark_list(){ ?>
    add_shortcode('show_bookmark_list', 'show_bookmark_list'); +/* +* in_multiarray(): vérifie si un élément est présent dans un tableau muntidimensionnel +* +* entree $elem (str) $array(array) shortcode gallery +* retourne true ou false +* +* functions.php - add_exif() +*/ + function in_multiarray($elem, $array) { - // add_exif() $top = sizeof($array) - 1; $bottom = 0; @@ -2140,6 +2321,15 @@ function in_multiarray($elem, $array) { } +/* +* toBool(): dit si une chaine est vrai (ou fausse) +* +* entree $var (str) ("1", "true", "on", "yes", "y" retournera true) +* retourne true ou false +* +* functions.php - flickr_handler() +*/ + function toBool($var) { //flickr @@ -2157,26 +2347,21 @@ function toBool($var) { } -//wp_prepare_attachment_for_js($attachment_id) -function wp_get_attachment( $attachment_id ) { - $attachment = get_post( $attachment_id ); - return array( - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), - 'caption' => $attachment->post_excerpt, - 'description' => $attachment->post_content, - 'href' => get_permalink( $attachment->ID ), - 'src' => $attachment->guid, - 'title' => $attachment->post_title - ); -} - - -/*** INUTILE ***/ +/*** UTILE ou INUTILE ??? ***/ /** * Ajoute les données GPS aux métadata lors de l'importation du média */ +/* +* add_geo_exif(): FILTRE Ajoute les données GPS aux métadata lors de l'importation du média +* +* entree $var (str) ("1", "true", "on", "yes", "y" retournera true) +* retourne true ou false +* +* functions.php +*/ + function add_geo_exif($meta,$file,$sourceImageType) { $exif = @exif_read_data( $file ); if (!empty($exif['GPSLatitude'])) @@ -2195,185 +2380,23 @@ add_filter('wp_read_image_metadata', 'add_geo_exif','',3); -/*** A SUPPRIMER (CI-DESSOUS) ***/ - -function exifme($content) { - - /*ID du post*/ - global $post; - $postID = $post->ID; - - - if (function_exists( ' wr2x_init' ) ) $pattern = '/]* src=\"([^\"]*)\"[^>]*>/Ui'; - // sans retina - else $pattern = '/]*src=\"?([^\"]*)\"?([^>]*alt=\"?([^\"]*)\"?)?[^>]*>/Ui'; - //preg_match_all($pattern, $content , $matches, PREG_SET_ORDER); - // 2 (do_shortcode) renard wp / gp zp - - $pattern2 = '/]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU'; - preg_match_all($pattern2, $content , $matches, PREG_SET_ORDER); - // 8 (do_shortcode) 2 gp / 2 renard / 4 gp - - // post: gp (shortcode) / renard (wordpress) / gp (zenphoto) / gp (zenphoto) - - //preprint($matches); - - for ($i = 0; $i <= (count($matches) - 1); $i++) { - $ancien = $matches[$i][0]; - - $court = $matches[$i][1]; - - // source wordpress - if (substr_count($ancien, 'wordpress') != 0) { - - $patternWP = '#wp-image-[0-9]{1,4}#'; - if (preg_match($patternWP, $ancien, $matches2) === 1) { - $attachment = substr($matches2[0],9); - //echo $court; - echo $ancien; - - $meta = creator_get_exif( $court ); - //preprint($meta); - //$exif_array = img_wp_exif( $meta ); - //echo $exif_array[0]; - //preprint($exif_array); - - } // preg_match - - } // if wordpress - - // source zenphoto - elseif ((substr_count($ancien, 'zenphoto') != 0) and (substr_count($ancien, ' - - Flicker (paysage) vautour avec branche: - - - 1600x1066 https://www.flickr.com/photos/funnymac/24826683615/sizes/o/ - https://c2.staticflickr.com/2/1544/24826683615_c42292df06_o.jpg - BBCODE [url=https://flic.kr/p/DPRf6e][img]https://c1.staticflickr.com/2/1544/24826683615_558bff1744_h.jpg[/img][/url] - - - 800x533 https://www.flickr.com/photos/funnymac/24826683615/sizes/c/ - https://c2.staticflickr.com/2/1544/24826683615_3967bc60d2_c.jpg - - $atts['link'] = $link; - $atts['small'] = $small; - $atts['big'] = $big; - - */ - - - //$anc = str_replace("/>", "class='aligncenter' style='width: " . (($portrait === false) ? "610" : "408") . "px;' />", $ancien) . "\r\n"; - $anc = str_replace("/>", "class='aligncenter' />", $ancien) . "\r\n"; - - } // else - - // commun à WP et ZP - $exif_array = img_wp_exif( $meta ); - //preprint($exif_array); - echo $exif_array[0]; - - - } // for - - /*-----------------*/ - - return $content; - - /*-----------------*/ - - } -//add_action('the_content','exifme'); - - -/** - * Create a definition list containing EXIF data of featured image (if exists) - * - * @param string $post ID - * @return echo definition list - */ -function pa_the_post_thumbnail_exif_data($content) { - // if $postID not specified, then get global post and assign ID - if (!$postID) { - global $post; - $postID = $post->ID; - } - if (has_post_thumbnail($postID)) { - // get the meta data from the featured image - $postThumbnailID = get_post_thumbnail_id( $postID ); - $photoMeta = wp_get_attachment_metadata( $postThumbnailID ); - - // if the shutter speed is not equal to 0 - if ($photoMeta['image_meta']['shutter_speed'] != 0) { - - // Convert the shutter speed to a fraction - if ((1 / $photoMeta['image_meta']['shutter_speed']) > 1) { - if ((number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1)) == 1.3 - or number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1) == 1.5 - or number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1) == 1.6 - or number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1) == 2.5) { - $photoShutterSpeed = "1/" . number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1, '.', '') . " second"; - } else { - $photoShutterSpeed = "1/" . number_format((1 / $photoMeta['image_meta']['shutter_speed']), 0, '.', '') . " second"; - } - } else { - $photoShutterSpeed = $photoMeta['image_meta']['shutter_speed'] . " seconds"; - } - // print our definition list - ?> -
    -
    Date Taken
    -
    -
    Camera
    -
    -
    Focal Length
    -
    mm
    -
    Aperture
    -
    f/
    -
    ISO
    -
    -
    Shutter Speed
    -
    -
    - EXIF data not found

    '; - } - // if no featured image, echo error message - } else { - echo '

    Featured image not found

    '; - } -} +/* +* fmulticurl(): recherche et récupère des infos sur Wikipedia +* +* entree $query (array) (tableau contenant les données à rechercher sur wikipedia (1 entrée/image)) +* retourne $obj (array) +* +* single.php - tpl-carte.php +*/ function fmulticurl($query) { $url = "https://fr.wikipedia.org/w/api.php"; $erreur = array(); + + /* contruction de la requete opensearch */ + $fields = array( 'action' => 'opensearch', //'search' => $query, @@ -2382,10 +2405,27 @@ function fmulticurl($query) { ); $fields_string = ""; - foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } + foreach($fields as $key=>$value) { + $fields_string .= $key.'='.$value.'&'; + } + + /* nettoyage expressions à rechercher */ + /**/ + echo "requete avant clean_req_wiki
    "; + var_dump($query); - foreach ($query as &$val) { - $val = $url . "?" . $fields_string . "search=" . str_replace(" ", "_", trim($val)); + $wiki = clean_req_wiki($query); + //$wiki = $query; + + /**/ + echo "requete apres clean_req_wiki
    "; + var_dump($wiki); + + /* constructions des requetes */ + + foreach ($wiki as &$val) { + //$val = $url . "?" . $fields_string . "search=" . str_replace(" ", "_", trim($val)); + $val = $url . "?" . $fields_string . "search=" . $val; } //create the multiple cURL handle @@ -2398,7 +2438,7 @@ function fmulticurl($query) { $ch[$x] = curl_init(); - curl_setopt($ch[$x], CURLOPT_URL, $query[$x]); + curl_setopt($ch[$x], CURLOPT_URL, $wiki[$x]); //curl_setopt($ch[$x], CURLOPT_POST, 1);// set post data to true //curl_setopt($ch[$x], CURLOPT_POSTFIELDS, $fields); // post data @@ -2445,7 +2485,7 @@ function fmulticurl($query) { curl_multi_close($mh); - +/* OK Remplace les entrées vides par "" for ($a = 0; $a < count($obj); $a++){ if (is_array($obj[$a])) { @@ -2460,30 +2500,64 @@ function fmulticurl($query) { } //if } //for +*/ + echo "retour de la requete
    "; + var_dump($obj); + + for ($a = 0; $a < count($obj); $a++){ + /* + $req = str_replace("_", " ", $obj[$a][0]); + $req = " " . $req . " "; + */ + $req = $query[$a]; + /* + if (is_array($obj[$a])) { + + for ($b = 0; $b < count($obj[$a]); $b++){ + + if (empty($obj[$a][$b])) { + $obj[$a][$b][0] = ""; + } + + } //for + + } //if + */ + + foreach ($obj[$a][2] as $key => $val) { + //if (stripos(substr($val, 0, 50), $req) !== false) echo "matche $key"; + //echo "nettoyage du retour de la requete
    "; + //var_dump($val, $req); + + if (stripos(substr($val, 0, 50), $req) === false) { + unset($obj[$a][1][$key]); + unset($obj[$a][3][$key]); + unset($obj[$a][2][$key]); + } + + } + + } //for + if (count($erreur) > 0) var_dump($erreur); + + //echo "retour de la function multicurl
    "; + //var_dump($obj); return $obj; } + + /* -function wp_exif_frac2dec($str) { - @list( $n, $d ) = explode( '/', $str ); - if ( !empty($d) ) - return $n / $d; - return $str; -} +* safe_array_access(): recherche et récupère des infos sur Wikipedia +* +* entree $query (array) (tableau contenant les données à rechercher sur wikipedia (1 entrée/image)) +* retourne $obj (array) +* +* single.php - tpl-carte.php */ -// wp_exif_date2ts -if ( ! function_exists( 'wp_exif_date2ts' ) ) : -function ctc_exif_date2ts($str) { - @list( $date, $time ) = explode( ' ', trim($str) ); - @list( $y, $m, $d ) = explode( ':', $date ); - - return strtotime( "{$y}-{$m}-{$d} {$time}" ); -} -endif; // - function safe_array_access($ar){ $numargs = func_num_args(); @@ -2500,4 +2574,105 @@ function safe_array_access($ar){ } +/* +* clean_req_wiki(): nettoie la requete pour Wikipedia +* +* entree $req (array) (tableau contenant les données à rechercher sur wikipedia (1 entrée/image)) +* retourne $q (array) (supprime les tags, les articles en début d'expression, les accents, trim , remplace les " " par "_" +* +* functions.php - fmulticurl() +*/ + +function clean_req_wiki ($req) { + $v = array(); + + foreach($req as $val) { + //echo $val . " - "; + + $z = strip_tags($val); + + //$y= supp_article($z); + $y= supprime_article($z); + + $x = str_to_noaccent($y); + + //$w = addslashes($x); // mets pont d'arcole avant pont d'arc + + //$v = strtolower($w); + + $v = str_replace(" ", "_", $x); + + $q[] = trim($v); + } + echo "
    "; + + return $q; +} + + +/* +* str_to_noaccent(): remplace les lettres accentuées par leur équivalent sans accent +* +* entree $str (str) +* retourne $str (str) +* +* functions.php - clean_req_wiki() +*/ + +function str_to_noaccent($str) { + $str = preg_replace('#Ç#', 'C', $str); + $str = preg_replace('#ç#', 'c', $str); + $str = preg_replace('#è|é|ê|ë#', 'e', $str); + $str = preg_replace('#È|É|Ê|Ë#', 'E', $str); + $str = preg_replace('#à|á|â|ã|ä|å#', 'a', $str); + $str = preg_replace('#@|À|Á|Â|Ã|Ä|Å#', 'A', $str); + $str = preg_replace('#ì|í|î|ï#', 'i', $str); + $str = preg_replace('#Ì|Í|Î|Ï#', 'I', $str); + $str = preg_replace('#ð|ò|ó|ô|õ|ö#', 'o', $str); + $str = preg_replace('#Ò|Ó|Ô|Õ|Ö#', 'O', $str); + $str = preg_replace('#ù|ú|û|ü#', 'u', $str); + $str = preg_replace('#Ù|Ú|Û|Ü#', 'U', $str); + $str = preg_replace('#ý|ÿ#', 'y', $str); + $str = preg_replace('#Ý#', 'Y', $str); + + return ($str); +} + + +/* +* supprime_article(): supprime les articles en début d'expression +* +* +* entree $str (str) +* retourne $m (str) +* +* functions.php - clean_req_wiki() +*/ + +function supprime_article($str) { + //supprime les articles en début de chaine + //supprime expressions entre parentheses + + $pattern = "#^(le|la|les|un|une|du|de|des|ce|ces|cette|cet)\s#mUis"; + $pattern2 = "#^([l|d|s|t]')#mUis"; + $pattern3 = "#\\([^)]*\\)#"; + + $k = preg_replace($pattern, " ", $str); + $l = preg_replace($pattern2, " ", $k); + + $m = preg_replace($pattern3, "", $l); + + return trim($m); +} + + +function preprint($s, $return=false) { + $x = "
    "; 
    +    $x .= print_r($s, 1); 
    +    $x .= "
    "; + if ($return) return $x; + else print $x; + } + + ?> \ No newline at end of file diff --git a/infos.txt b/infos.txt index 457769a..ebaf191 100644 --- a/infos.txt +++ b/infos.txt @@ -58,4 +58,17 @@ add_shortcode( 'zenphoto', 'zenphoto_handler' ); Media WP -> add_class_lightbox($content) -> img wordpress avec class="selector" +--------- +$coord() + + array (size=9) + 0 => string '45.584731' (length=9) + 1 => string '7.318439' (length=8) + 2 => string '2016-01-07_Renard_2905' (length=22) + 3 => string '27868468454' (length=11) + 4 => string 'Etonnante rencontre dans le parc du Grand Paradis (Italie) Alors que l'on redescendait du refuge après une belle rando, j'aperçoit goupil qui monte par le même chemin. On stoppe. Il s'arrête à notre hauteur avant de reprendre sa route tranquillement. Puis il s'arrête de nouveau pour prendre la pose un peu plus haut.' (length=335) + 5 => string ' ' (length=130) + 6 => null + 7 => null + 8 => null diff --git a/single.php b/single.php index 30ebc72..cc58064 100755 --- a/single.php +++ b/single.php @@ -18,13 +18,35 @@ get_header(); the_content(); - //preprint($coord); ?> 0) ? "block" : "none") . ';">
'; if (count($coord) > 0) { - //var_dump($coord); + $b = array(); + + // Avec tous les titres, on crée la requete pour Wikipédia + + for ($a = 0; $a < count($coord); $a++){ + $short = $coord[$a][2]; // Titre + $b[] = $short; + } + + $wiki = fmulticurl($b); + + //On rajoute à $coord les données récupérées sur Wikipédia + + if (count($coord) == count($wiki)) { + for ($c = 0; $c < count($wiki); $c++){ + // [0] 1ere réponse, la plus pertinante + //array_push($coord[$c], $lettrine, $wiki[$c][1][0], $wiki[$c][2][0], $wiki[$c][3][0]); + array_push($coord[$c], $wiki[$c][1][0], $wiki[$c][2][0], $wiki[$c][3][0]); + //array_push($coord[$c], $wiki[$c][2][0], $wiki[$c][3][0]); + } + } + + echo "après requete Wikipedia"; + var_dump($coord); ?> @@ -55,6 +77,7 @@ get_header(); $( "button#hidemap" ).show(); $( "button#showmap" ).hide(); + $( "i.ion-ios-location" ).show(); }); // button#showmap @@ -62,21 +85,37 @@ get_header(); $( "#locations" ).toggle( "fast"); $( "button#hidemap" ).hide(); $( "button#showmap" ).show(); + $( "i.ion-ios-location" ).hide(); data = true; }); }); // jQuery - + var map; var markers = []; var cnt; + var locations = [ " . $coord[$i][2] . "', " . $coord[$i][0] . ", " . $coord[$i][1] . "]" . (($i<$j) ? "," : "")."\r\n"; - echo "['" . $coord[$i][2] . "', " . $coord[$i][0] . ", " . $coord[$i][1] . "]" . (($i<$j) ? "," : "")."\r\n"; + //echo "['

" . $coord[$i][2] . "

','

" . $coord[$i][4] . "

', " . $coord[$i][0] . ", " . $coord[$i][1] . ",'" . $coord[$i][5] . "']" . (($i<$j) ? "," : "")."\r\n"; + echo "['

" . addslashes($coord[$i][2]) . "

','

" . addslashes($coord[$i][4]) . "

', " . $coord[$i][0] . ", " . $coord[$i][1] . ",'" . addslashes($coord[$i][5]) . "','" . addslashes($coord[$i][7]) . "','" . $coord[$i][8] . "']" . (($i<$j) ? "," : "")."\r\n"; } + //array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnail)); + + /* + locations[0] => $coord[2] => Titre (court) + locations[1] => $coord[4] => Description (long) + locations[2] => $coord[0] => Latitude + locations[3] => $coord[1] => Longitude + locations[4] => $coord[5] => + locations[5] => $coord[7] => Texte Wikipedia + locations[6] => $coord[8] => Liens vers Wikipedia + $coord[3] => attachment + $coord[6] => <- requete wiki + */ + ?> ]; @@ -84,7 +123,11 @@ get_header(); // Setup the different icons and shadows var iconURLPrefix = 'https://maps.google.com/mapfiles/ms/icons/'; - + + var root = location.protocol + '//' + location.host; + var wikiImg = root + '/wordpress/wp-content/themes/CreatorThemeRes-child/images/wikipedia.png'; + var wikiUrl = ''; + var icons = [ iconURLPrefix + 'red-dot.png', iconURLPrefix + 'green-dot.png', @@ -112,9 +155,10 @@ get_header(); var iconCounter = 0; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ - position: new google.maps.LatLng(locations[i][1], locations[i][2]), + position: new google.maps.LatLng(locations[i][2], locations[i][3]), map: map, - icon: icons[iconCounter] + icon: icons[iconCounter], + title: locations[i][0] }); markers.push(marker); @@ -141,21 +185,46 @@ get_header(); } }); + /*https://www.touraineverte.fr/google-maps-api-version-3/exemple-tutoriel-infobulles-infowindows/ajouter-infowindow-infobulle-marqueur-defaut-api-google-maps-version-3.html*/ + + /* + var contenuInfoBulle = '

Cité Royale de Loches

' + + '

Royale et imprenable

' + + '' + + '

Remontez le temps pour découvrir l\'une des plus belles cités fortifiées de France.

' + + '

Le DONJON, haut de 36 mètres, a été construit par un comte d\'Anjou, Foulques Nerra, au début du XIe siècle. S\'il figure parmi les plus imposants de son époque en Europe, il est aussi l\'un des mieux conservés. Modèle d\'architecture militaire, il est transformé en prison royale par Louis XI.

' + + '

Le LOGIS ROYAL se trouve à proximité. Ce joyau de la Renaissance française, haut lieu de l\'Histoire de France, a été une résidence de prédilection de la dynastie des Valois. Sa façade ouverte en terrasse domine la ville et la vallée de l\'Indre. Le logis a accueilli notamment Jeanne d\'Arc, Agnès Sorel et Anne de Bretagne. Pour en savoir plus : La cité royale de Loches

'; + */ + /* +

Titre

=> +

Sous-titre

+ Lettrine image +

Description

+ */ + google.maps.event.addListener(marker, 'mousemove', (function (marker, i) { return function () { - /* - var contentString = '
'+ - '
'+ - '
'+ - '

' + locations[i][0] + '

'+ - '
'+ - '
'+ - '
'; - infowindow.setContent(contentString); - */ - infowindow.setContent(locations[i][0]); - infowindow.open(map, marker); - } + + //var contenuInfoBulle = locations[i][0] + locations[i][4] + locations[i][1]; + //var contenuInfoBulle = locations[i][0] + '' + locations[i][4] + locations[i][5] + ''; + var wikiLink = '' + if (locations[i][6] != '') { + wikiLink = '' + wikiUrl + '' + } + + var contenuInfoBulle = locations[i][0] + locations[i][4] + locations[i][1] + locations[i][5] + '
' + wikiLink; + + /* + locations[0] => $coord[2] => Titre (court) + locations[4] => $coord[5] => + locations[1] => $coord[4] => Description (long) + locations[5] => $coord[7] => Texte Wikipedia + locations[6] => $coord[8] => Liens vers Wikipedia + */ + + infowindow.setContent(contenuInfoBulle); + infowindow.open(map, marker); + } })(marker, i)); iconCounter++; @@ -176,12 +245,13 @@ get_header(); } setTimeout(function() { - infowindow.setContent(locations[cnt][0]); + /*infowindow.setContent(locations[cnt][0]);*/ + infowindow.setContent(contenuInfoBulle); infowindow.open(map, markers[cnt]); }, 300); } //jumpToMarker - - + + diff --git a/tpl-carte.php b/tpl-carte.php index 27e9db0..c66b8ba 100755 --- a/tpl-carte.php +++ b/tpl-carte.php @@ -106,7 +106,8 @@ $query_images = new WP_Query($query_images_args); if (count($coord) > 0) { - //var_dump($coord); + echo "avant requete Wikipedia"; + var_dump($coord); /* 0 => array (size=6) @@ -136,7 +137,8 @@ $query_images = new WP_Query($query_images_args); } } - //var_dump($coord); + echo "après requete Wikipedia"; + var_dump($coord); ?>