]*>(.*?)\<\/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]"; // 
- 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]"; //

- 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'] . '](' . $thumbnail['url'] . ')
';
+ $img_thumb_ZP_wiki = '
![' . $attribut['alt'] . '](' . $thumbnail['url'] . ')
';
+
+ 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, '
]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
preg_match($patternZP, $ancien , $matches2);
$img = explode("/", $matches2[1]);
$zp_image = end($img);
$zp_album = prev($img);
+
+ var_dump($zp_image, $zp_album);
+ $img_thumb_ZP_wiki = thumb_ZP_wiki($zp_image, $zp_album);
+ var_dump($img_thumb_ZP_wiki);
$meta = zp_query_exif( $zp_image );
$exif_array = img_wp_exif( $meta );
@@ -1201,7 +1310,11 @@ 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));
+ $pid = "";
+ echo "fichier: " . $fichier;
+
+ array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['caption'], $img_thumb_ZP_wiki));
+
}
} // if in_multiarray
@@ -1243,6 +1356,18 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
add_action('the_content','addexif');
+/*
+* img_wp_exif: crée la chaine d'affichages des exifs et des données GPS
+*
+*entree $exif_array (tableau avec tous les exifs
+*retourne array($exifInfo, $exifGPS, $geo_link):
+* -$exifInfo: chaine qui affiche les exifs
+* -$exifGPS: données gps pour $exifInfo
+* -$geo_link: image globe avec lien vers googlemaps.com
+*
+* functions.php - flickr_handler() add_exif()
+*/
+
function img_wp_exif( $exif_array ) {
/*
Array
@@ -1280,7 +1405,6 @@ Array
if ($exif_array['aperture'] != "") {
// bloc exif (avec icones)
- //$exifInfo = "";
$exifInfo .= "" . date(__("F j, Y, g:i a",'CreatorThemeRes-child'),$exif_array['created_timestamp']) . "";
$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, '
]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
- preg_match($patternZP, $ancien , $matches2);
- //echo $court;
- echo $ancien;
-
- $img = explode("/", $matches2[1]);
- $zp_image = end($img);
- $zp_album = prev($img);
-
- $meta = zp_query_exif( $zp_image );
- //preprint($meta);
-
- } // else zenphoto
-
- // Autres sources que WP et ZP
- else {
-
- echo $ancien;
- $meta = creator_get_exif( $court );
- /*
- Flicker (portrait):
-
-
- 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);
?>