Files
creator-child/single.php
2018-01-29 10:27:36 +01:00

392 lines
13 KiB
PHP
Executable File

<?php
//tideways_enable(TIDEWAYS_FLAGS_NO_SPANS);
get_header();
/**/
//$xhprof_data = tideways_disable();
//var_dump($xhprof_data);
/*
//$tmpfile = sys_get_temp_dir() . uniqid() . ".myapp.xhprof";
$tmpfile = "/tmp/" . uniqid() . ".myapp.xhprof";
echo $tmpfile;
file_put_contents( $tmpfile, serialize($xhprof_data) );
*/
/*
$XHPROF_ROOT = "/Users/bruno/Sites/xhprof";
define('XHPROF_LIB_ROOT', $XHPROF_ROOT . '/xhprof_lib');
include_once $XHPROF_ROOT . "/xhprof_lib/config.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "myapp");
echo "---------------\n".
"Assuming you have set up the http based UI for \n".
"XHProf at some address, you can view run at \n".
"http://dev.macbook-pro.local/index.php?run=$run_id&source=myapp\n".
"---------------\n";
*/
?>
<div class="content">
<div class="container">
<div class="post_content">
<?php while ( have_posts() ) : the_post(); ?>
<article class="post_box" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1><?php the_title(); ?></h1>
<div class="entry-meta">
<?php if (dess_setting('dess_display_meta') == true) creator_entry_meta(); ?>
<?php //edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-meta -->
<?php
$coord = array();
$compt_marker = 0;
the_content();
?>
<?php //echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none") . ';"></div>';
var_dump($coord);
if (count($coord) > 0) {
$b = array();
// Avec tous les titres, on crée la requete pour Wikipédia
for ($a = 0; $a < count($coord); $a++){
$short = $coord[$a][6]; // Titre
/*
Flickr: 2016-01-07_Renard_2905
WP:
ZP:
*/
$b[] = $short;
}
//var_dump($b);
//echo "coord avant requete Wikipedia";
//var_dump($coord);
$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]);
// Requete - Texte Wikipedia - Url Wikipedia
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 "coord après requete Wikipedia";
//var_dump($coord);
?>
<script type="text/javascript">
jQuery(document).ready(function ($) { // wait until the document is ready
data = false;
$('button#showmap').click(function(){
if (data == false) {
$.ajax({
url: "http://maps.googleapis.com/maps/api/js?key=AIzaSyB7cAx3NSH4dPM3Sx2oQeud7Zr-KaGXmLk&sensor=false&callback=MapApiLoaded",
dataType: "script",
timeout:8000,
success: function(data) {
// Run the code here that needs
// to access the data returned
data = true;
return data;
},
error: function() {
alert('Error occured');
}
});
}
$( "#locations" ).toggle( "fast");
$( "button#hidemap" ).show();
$( "button#showmap" ).hide();
$( "i.ion-ios-location" ).show();
}); // button#showmap
$('button#hidemap').click(function(){
$( "#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 = [
<?php
$j = (count($coord) - 1);
for ($i = 0; $i <= $j; $i++) {
echo "['<h1>" . addslashes($coord[$i][2]) . "</h1>','<p>" . addslashes($coord[$i][4]) . "</p>', " . $coord[$i][0] . ", " . $coord[$i][1] . ",'" . addslashes($coord[$i][5]) . "','" . addslashes($coord[$i][8]) . "','" . $coord[$i][9] . "']" . (($i<$j) ? "," : "")."\r\n";
//echo "['<h1>" . addslashes($coord[$i][2]) . "</h1>','<p>" . addslashes($coord[$i][4]) . "</p>', " . $coord[$i][0] . ", " . $coord[$i][1] . ",'" . addslashes($coord[$i][5]) . "','" . (($coord[$i][8] != "") ? addslashes($coord[$i][8]) : addslashes($coord[$i][4])) . "','" . $coord[$i][9] . "']" . (($i<$j) ? "," : "")."\r\n";
}
(($coord[$i][8] != "") ? addslashes($coord[$i][8]) : addslashes($coord[$i][4]))
//array_push($coord, array($meta['latitude'], $meta['longitude'], $caption, $pid, $description, $img_thumb_ZP_wiki, $requete_wiki));
/*
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] => <img "letrine">
locations[5] => $coord[8] => Texte Wikipedia
locations[6] => $coord[9] => Liens vers Wikipedia
$coord[3] => attachment
$coord[6] => requete wiki ->
$coord[7] => <- requete wiki
*/
?>
];
var wikiLink = '';
var contenuInfoBulle = [];
function MapApiLoaded() {
// 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 = '<img src=\"' + wikiImg + '\" width=\"32\" height=\"32\" class=\"wiki\" />';
var icons = [
iconURLPrefix + 'red-dot.png',
iconURLPrefix + 'green-dot.png',
iconURLPrefix + 'blue-dot.png',
iconURLPrefix + 'orange-dot.png',
iconURLPrefix + 'purple-dot.png',
iconURLPrefix + 'pink-dot.png',
iconURLPrefix + 'yellow-dot.png'
]
var iconsLength = icons.length;
// Create google map
map = new google.maps.Map($('#gmap')[0], {
zoom:8,
mapTypeId:google.maps.MapTypeId.ROADMAP,
panControl:false,
streetViewControl:false,
mapTypeControl:true
});
infowindow = new google.maps.InfoWindow();
var bounds = new google.maps.LatLngBounds();
var iconCounter = 0;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][2], locations[i][3]),
map: map,
icon: icons[iconCounter],
title: locations[i][0]
});
markers.push(marker);
if (locations[i][6] != '') {
wikiLink = '<a href=\"' + locations[i][6] + '\" title=\"Plus sur Wikipedia...\">' + wikiUrl + '</a>';
}
contenuInfoBulle[i] = locations[i][0] + locations[i][4] + locations[i][1] + locations[i][5] + '<br />' + wikiLink;
/*
locations[0] => $coord[2] => Titre (court)
locations[4] => $coord[5] => <img "letrine">
locations[1] => $coord[4] => Description (long)
locations[5] => $coord[8] => Texte Wikipedia
locations[6] => $coord[9] => Liens vers Wikipedia
*/
var zoom = 1;
a = map.getZoom();
bounds.extend(marker.position);
// add the double-click event listener
google.maps.event.addListener(marker, 'dblclick', function() {
map.panTo(this.getPosition());
//map.setZoom(9);
if (zoom == 1) {
if (map.getZoom() < (a + 6)) {
map.setZoom(map.getZoom() + 2);
}
else zoom = 0;
}
else if (zoom == 0) {
if (map.getZoom() >= a) {
map.setZoom(map.getZoom() - 2);
}
else zoom = 1;
}
});
/*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 = '<h1>Cité Royale de Loches</h1>' +
'<h2>Royale et imprenable</h2>' +
'<img id="lettrineImage" src="https://static.touraineverte.fr/googlemapsapiversion3/photo_monument-loches.jpg" title="La cité royale de Loches" />' +
'<p>Remontez le temps pour découvrir l\'une des plus belles cités fortifiées de France.</p>' +
'<p>Le <b>DONJON</b>, 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.</p>' +
'<p>Le <b>LOGIS ROYAL</b> 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 : <a href="http://www.cg37.fr/index.php?media=106" title="La cité royale de Loches" target="_parent">La cité royale de Loches</a></p>';
*/
/*
<h1>Titre</h1> =>
<h2>Sous-titre</h2>
Lettrine image
<p>Description</p>
*/
google.maps.event.addListener(marker, 'mousemove', (function (marker, i) {
return function () {
/*
var wikiLink = ''
if (locations[i][6] != '') {
wikiLink = '<a href=\"' + locations[i][6] + '\" title=\"Plus sur Wikipedia...\">' + wikiUrl + '</a>';
}
var contenuInfoBulle = locations[i][0] + locations[i][4] + locations[i][1] + locations[i][5] + '<br />' + wikiLink;
*/
infowindow.setContent(contenuInfoBulle[i]);
infowindow.open(map, marker);
}
})(marker, i));
iconCounter++;
if (iconCounter >= iconsLength) {
iconCounter = 0;
}
} // for
map.fitBounds(bounds);
} //MapApiLoaded
function jumpToMarker(cnt){
map.panTo(markers[cnt].getPosition());
if (map.getZoom() < 15) {
map.setZoom(a + 4);
}
setTimeout(function() {
infowindow.setContent(contenuInfoBulle[cnt]);
infowindow.open(map, markers[cnt]);
}, 300);
} //jumpToMarker
</script>
<div id="locations">
<?php
$j = (count($coord) - 1);
echo "<div id='center_marker'><ul class='list_marker'>";
for ($i = 0; $i <= $j; $i++) {
//<a href="javascript:void(0);" onclick="jumpToMarker(4)" class="button3">PontDArc</a>
echo "<li><i class='ion-ios-location'></i><a href='#gmap' onclick='jumpToMarker(" . $i . ")'>" . $coord[$i][2] . "</a></li>";
}
echo "</ul></div>";
?>
<div id="gmap" style="width: 800px; height: 600px; border:1px solid #999;" class="aligncenter"></div>
</div>
<button type="button" id="showmap"><?php _e('Show map','CreatorThemeRes-child'); ?></button>
<button type="button" id="hidemap"><?php _e('Hide map','CreatorThemeRes-child'); ?></button>
<?php
}
?>
<?php
wp_link_pages(array(
'before' => '<div class="link_pages">'.__('Pages', 'creator'),
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>'
));
?>
<?php if (dess_setting('dess_display_meta') == false) the_tags( '<div class="post_tags">' . __('Tags: ', 'CreatorThemeRes-child'), ', ', '</div>' ); ?>
</article>
<?php
if (current_user_can('edit_post')) {
edit_post_link(
sprintf(
/* translators: %s: Name of current post */
__( 'Edit post<span class="screen-reader-text"> "%s"</span>', 'CreatorThemeRes-child' ),
get_the_title()
),
'<span class="edit-link">',
'</span>'
);
}
?>
<?php creator_post_nav(); ?>
<div class="clear"></div>
<?php if ( comments_open() || '0' != get_comments_number() ) : ?>
<div class="home_blog_box">
<button id="togle">
<?php
_e('Display','CreatorThemeRes-child');
comments_number(esc_html__(' 0 Comment','CreatorThemeRes-child'), esc_html__(' 1 Comment','CreatorThemeRes-child'), '% '.esc_html__(' Comments','CreatorThemeRes-child') );
?>
</button>
<div class="comments_cont">
<?php
// If comments are open or we have at least one comment, load up the comment template
comments_template( '', true );
?>
</div>
</div>
<?php endif;
endwhile;
?>
</div>
</div>
</div>
<?php
get_footer();
?>