Reinstall silverbook

This commit is contained in:
2019-08-17 16:54:13 +02:00
parent eabe086f95
commit be5f9815e8
6 changed files with 1077 additions and 183 deletions

View File

@@ -21,7 +21,7 @@
*/
get_sidebar( 'footer' );
?>
<?php echo $_SERVER['SERVER_NAME']; ?>
<div id="site-info">
<!--a href="<?php echo home_url( '/' ) ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<?php //bloginfo( 'name' ); ?>
@@ -42,20 +42,30 @@
</div><!-- #wrapper -->
<!-- Matomo -->
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//<?php echo $_SERVER[SERVER_NAME]; ?>/piwik/";
var u="//clicclac.info/piwik/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//<?php echo $_SERVER[SERVER_NAME]; ?>/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
<!-- End Matomo Code -->
<noscript>
<!-- Matomo Image Tracker-->
<img src="https://clicclac.info/piwik/piwik.php?idsite=1&rec=1" style="border:0" alt="" />
<!-- End Matomo -->
</noscript>
<!--script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/jquery.swipebox.min.js"></script>
<script type="text/javascript">
@@ -73,6 +83,6 @@
wp_footer();
?>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB7cAx3NSH4dPM3Sx2oQeud7Zr-KaGXmLk&callback=initMap" type="text/javascript"></script>
<!--script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB7cAx3NSH4dPM3Sx2oQeud7Zr-KaGXmLk&callback=initMap" type="text/javascript"></script-->
</body>
</html>

View File

@@ -1,5 +1,6 @@
<?php load_theme_textdomain('twentyten-child', get_template_directory() . '-child/languages'); ?>
<?php
// absent sur clicclac.info, présent en local
$serial = "89f6e92540a8a80bd28cc2630c0ae022";
update_option( 'wr2x_pro', array( 'subscr_id' => $serial ) );
update_option( 'wr2x_pro_status', _( "Your subscription is manually enabled." ) );
@@ -13,74 +14,164 @@ add_filter('sanitize_file_name', 'remove_accents' );
add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );
// à l'initialisation de l'administration
// on informe WordPress des options de notre thème
add_action( 'admin_init', 'myThemeRegisterSettings' );
function myThemeRegisterSettings( ) {
register_setting( 'twentyten-child', 'zenphoto_url' ); // couleur de fond
register_setting( 'twentyten-child', 'img_size' ); // couleur du texte
register_setting( 'twentyten-child', 'guestbook_comment' ); // commentaires
function google_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
//wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', false, '3.1.1');
wp_register_script('jquery', get_stylesheet_directory_uri() . '/js/jquery.min.js', false, '3.3.1');
wp_enqueue_script('jquery');
}
}
add_action('init', 'google_jquery');
// la fonction myThemeAdminMenu( ) sera exécutée
// quand WordPress mettra en place le menu d'admin
function enqueue_my_scripts() {
//wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?key=AIzaSyB7cAx3NSH4dPM3Sx2oQeud7Zr-KaGXmLk&callback=initMap', array(), '3', true);
//wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?key=AIzaSyB7cAx3NSH4dPM3Sx2oQeud7Zr-KaGXmLk&callback=MapApiLoaded', array(), '3', true);
//wp_enqueue_script('google-jsapi','https://www.google.com/jsapi');
add_action( 'admin_menu', 'myThemeAdminMenu' );
wp_enqueue_script( 'child', get_stylesheet_directory_uri() . '/js/child.js', '', '',false );
}
add_action( 'wp_enqueue_scripts', 'enqueue_my_scripts' );
function myThemeAdminMenu( ) {
add_menu_page(
'Options de Twentyten Child', // le titre de la page
'Twentyten Child', // le nom de la page dans le menu d'admin
'administrator', // le rôle d'utilisateur requis pour voir cette page
'my-theme-page', // un identifiant unique de la page
'myThemeSettingsPage' // le nom d'une fonction qui affichera la page
// Settings
//http://cssmary.com/wordpress/customizer-api-child-theme/
function childtheme_customize_register( $wp_customize ) {
// add settings
$add_socials = array('500px','flickr','rss','mail');
for($i=0;$i<count($add_socials);$i++) {
$name = str_replace('-',' ',ucfirst($add_socials[$i]));
$wp_customize->add_setting('dess_'.$add_socials[$i], array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_url',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_'.$add_socials[$i], array(
'settings' => 'dess_'.$add_socials[$i],
'label' => $name.' URL',
'section' => 'sm_section',
'type' => 'text',
)));
}
$wp_customize->get_setting( 'dess_rss' )->default = get_bloginfo('rss2_url');
// new section
$wp_customize->add_section('settings_section', array(
'title' => __('Settings','creator'),
'capability' => 'edit_theme_options',
'description' => __('Theme settings','twentyten-child')
)
);
// new options
$wp_customize->add_setting('dess_zenphoto', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_zenphoto', array(
'settings' => 'dess_zenphoto',
'label' => __('Zenphoto path (end with /)','twentyten-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting('dess_zp_size', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
// 'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_zp_size', array(
'settings' => 'dess_zp_size',
'label' => __('Zenphoto image size (px)','twentyten-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting('dess_social_size', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_social_size', array(
'settings' => 'dess_social_size',
'label' => __('Socials icons size (16 or 32px)','twentyten-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting('dess_lightbox_select', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_lightbox_select', array(
'settings' => 'dess_lightbox_select',
'label' => __('Lightbox selector (class="xxx")','twentyten-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting( 'dess_lightbox_choice', array(
'default' => 'b',
) );
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_lightbox_choice', array(
'label' => __('Choice of lightbox','twentyten-child'),
'section' => 'settings_section',
'settings' => 'dess_lightbox_choice',
'type' => 'radio',
'choices' => array(
'a' => 'Meow box',
'b' => 'Colorbox',
'c' => 'Featherlight',
),
)));
$wp_customize->add_setting( 'dess_display_exif', array(
'default' => 'trlue',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_control( 'dess_display_exif', array(
'settings' => 'dess_display_exif',
'label' => __('Display EXIFs','twentyten-child'),
'section' => 'settings_section',
'type' => 'checkbox',
) );
$wp_customize->add_setting( 'dess_display_gps', array(
'default' => 'false',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_control( 'dess_display_gps', array(
'settings' => 'dess_display_gps',
'label' => __('Display Geo datas','twentyten-child'),
'section' => 'settings_section',
'type' => 'checkbox',
) );
$wp_customize->add_setting( 'dess_display_meta', array(
'default' => 'false',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_control( 'dess_display_meta', array(
'settings' => 'dess_display_meta',
'label' => __('Display meta (single)','twentyten-child'),
'section' => 'settings_section',
'type' => 'checkbox',
) );
}
add_action( 'customize_register', 'childtheme_customize_register', 12);
function theme_setting($name, $default = false) {
return get_theme_mod( $name, $default );
}
// La page des settings
function myThemeSettingsPage( ) {
?>
<div class="wrap">
<h2>Options de mon thème</h2>
<form method="post" action="options.php">
<?php
// cette fonction ajoute plusieurs champs cachés au formulaire
// pour vous faciliter le travail.
// elle prend en paramètre le nom du groupe d'options
// que nous avons défini plus haut.
settings_fields( 'twentyten-child' );
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="zenphoto_url">URL de Zenphoto</label></th>
<td><input type="text" id="zenphoto_url" name="zenphoto_url" size="30" value="<?php echo get_option( 'zenphoto_url' ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="img_size">Taille des images</label></th>
<td><input type="text" id="img_size" name="img_size" class="small-text" value="<?php echo get_option( 'img_size' ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="guestbook_comment">Répondre aux commentaires du livre d'or</label></th>
<td><input type="checkbox" id="guestbook_comment" name="guestbook_comment" value="1" <?php checked( '1', get_option( 'guestbook_comment' ) ); ?> /> <?php echo get_option( 'guestbook_comment' ); ?></td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="Mettre à jour" />
</p>
</form>
</div>
<?php
function dess_sanitize_html($value){
return wp_filter_post_kses($value);
}
function dess_sanitize_text($value){
return sanitize_text_field($value);
}
function dess_sanitize_url($value) {
return esc_url_raw($value);
}
/* Affichage des array() */
@@ -120,45 +211,142 @@ function register_buttons($buttons){
function zenphoto_handler($atts, $content=null) {
//utilise le cacheManager de zenphoto (extensions/utilitaires/cacheManager)
//utilisation: [zenphoto album="lievres" image="2008-08-18_Lievre_8927.jpg"]
// [zenphoto album="sports-mecaniques/gp-france" image="2010-05-23_gp-france-2010_5321.jpg"]
// ** Utilisation **
//
// [zenphoto album="lievres" image="2008-08-18_Lievre_8927.jpg" folder="false"]
// [zenphoto album="sports-mecaniques/gp-france" image="2010-05-23_gp-france-2010_5321.jpg" folder="false"]
// Folder = false: liens vers l'image, affiche l'image
// Folder = true: liens vers l'album, affiche l'image
//
// [zenphoto album="lievres"](3)
// Liens vers album, affiche la 1ere image de l'album
//
//taille des photos dans Worpress, theme Twenty Ten Child : 610x406
/*
print_r($atts);
echo "<br />";
*/
/*
Array (
[album] => sports-mecaniques/24H-Mans-2016
[image] => 2016-04-10_24H-Mans_9717.jpg
[folder] => false
)
*/
$host = (($_SERVER['HTTPS'] != "") ? "https" : "http") . '://' . $_SERVER['HTTP_HOST'] . '/zenphoto/';
$selector = theme_setting('dess_lightbox_select');
$zenphoto_url = theme_setting('dess_zenphoto');
$size = theme_setting('dess_zp_size');
$zenphoto_url2 = get_option( 'zenphoto_url' );
//echo $zenphoto_url2 . "<br>";
//preprint($zenphoto_url2);
//echo substr_count($zenphoto_url2, "https");
//echo $_SERVER['HTTPS'];
$album = ! empty( $atts['album'] ) ? $atts['album'] : '';
$album = filter_var($album, FILTER_SANITIZE_STRING);
if (substr_count($zenphoto_url2, "https") == 1) {
//echo "toto";
$zenphoto_url = (($_SERVER['HTTPS'] != "") ? substr_replace($zenphoto_url2, 'https', 0, 4) : $zenphoto_url2);
}
$zenphoto_url = $host;
//echo $zenphoto_url;
$image = ! empty( $atts['image'] ) ? $atts['image'] : '';
$image = filter_var($image, FILTER_SANITIZE_STRING);
$size = get_option( 'img_size' );
$folder = false;
$caption = ! empty( $atts['caption'] ) ? $atts['caption'] : '';
$caption = filter_var($caption, FILTER_SANITIZE_STRING);
$folder = ! empty( $atts['folder'] ) ? $atts['folder'] : '';
$folder = filter_var($folder, FILTER_VALIDATE_BOOLEAN);
$rnd = rand (1000, 9999);
$filename = "";
$zenphoto_img = "";
//preprint($atts);
$a = $atts['image'];
$b = zp_query($a); // ligne 808
if (isset($atts['folder'])) {
if ($atts['folder'] == "true") $folder = true;
}
$img = substr($atts['image'], 0, strlen($atts['image']) - 4);
//echo dirname(__FILE__);
//echo __FILE__;
$filename = $zenphoto_url . 'cache/' . $atts['album'] . '/' . urlencode($img) . '_' . $size . '_watermark.jpg';
$zp_size = getimagesize(htmlentities($filename));
// require ($_SERVER["DOCUMENT_ROOT"]."/path/to/file.php");
//if ($folder == false) $zenphoto_link = '<a rel="lightbox" href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $atts['image'] . '">';
if ($folder == false) $zenphoto_link = '<a data-rel="lightbox-0" href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $atts['image'] . '">';
else $zenphoto_link = '<a href="' . $zenphoto_url . $atts['album'] . '">';
//require(dirname(__FILE__) . '/Connections/cnx.php');
require('../Connections/cnx.php');
$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable);
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
// Trouver l'ID de l'album
$album_id_query = "SELECT `id` FROM `" . $zp_prefix . "albums` WHERE `folder` = '" . $album . "'";
if ($result = $mysqli->query($album_id_query)) {
if ($mysqli->affected_rows != 0) {
$row = $result->fetch_row();
$album_id = $row[0];
}
else {
_e("Unknow album.", 'twentyten-child' );
}
$result->close();
}
$img_query = "SELECT `desc`, `title`, `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "'";
if ($result = $mysqli->query($img_query)) {
if ($mysqli->affected_rows != 0) {
$capt = $result->fetch_row();
}
else {
_e("Unknow image.", 'twentyten-child' );
}
$result->close();
}
//echo "image1: " . $image . "<br />";
// (3) Si juste un album est donné, on cherche l'image la plus récente de l'album
if (($album != "") && ($image == "")) {
// Trouver le filename de la plus récente image de l'album
$img_album_query = "SELECT `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "' ORDER BY `id` DESC LIMIT 1";
if ($result = $mysqli->query($img_album_query)) {
if ($mysqli->affected_rows != 0) {
$row = $result->fetch_row();
$img_album = $row[0];
}
else {
_e("Unknow image.", 'twentyten-child' );
}
$result->close();
}
echo "img_album: " . $img_album . "<br />";
$image = $img_album;
$folder = true;
} // album != ""
//echo "image2: " . $image . "<br />";
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);
//echo "img: " . $img . "<br />";
$filename = $zenphoto_url . 'cache/' . $atts['album'] . '/' . urlencode($img) . '_' . $size . '_watermark.jpg';
//echo "filename: " . $filename . "<br /><br />";
$zp_size = getimagesize(htmlentities($filename));
if ($folder === false) {
$zenphoto_link = '<a data-rel="lightbox-0" href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $image . '">';
}
else {
$zenphoto_link = '<a href="' . $zenphoto_url . $atts['album'] . '">';
}
$zenphoto_img .= $zenphoto_link;
$zenphoto_img .= '<picture data-picture data-alt="">
<!--[if IE 9]><video style="display: none;"><![endif]-->
@@ -185,6 +373,7 @@ function zenphoto_handler($atts, $content=null) {
add_shortcode( 'zenphoto', 'zenphoto_handler' );
// include
/* NON UTILISE */
@@ -835,6 +1024,7 @@ function zp_query($zpimage) {
$exif = array();
require('../Connections/cnx.php');
$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable);
if (mysqli_connect_errno()) {
@@ -1046,6 +1236,318 @@ function ListeExifZP($meta){
/*
* 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,
'format' => 'json',
'profile' => 'strict' //strict, normal, *fuzzy*, classic
);
$fields_string = "";
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
/* nettoyage expressions à rechercher */
/*
echo "requete avant clean_req_wiki<br>";
var_dump($query);
*/
$wiki = clean_req_wiki($query);
//$wiki = $query;
/*
echo "requete apres clean_req_wiki<br>";
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
$mh = curl_multi_init();
$nbr = count($query);
// set URL and options
for($x = 0; $x < $nbr; $x++){
$ch[$x] = curl_init();
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
curl_setopt($ch[$x], CURLOPT_HEADER, 0);
curl_setopt($ch[$x], CURLOPT_USERAGENT, 'ClicBot/1.0 (https://clicclac.info/; contact@clicclac.info)');
curl_setopt($ch[$x], CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch[$x], CURLOPT_SSL_VERIFYPEER, false);
curl_multi_add_handle($mh,$ch[$x]);
}
$running = null;
do {
curl_multi_exec($mh, $running);
} while ($running);
for($x = 0; $x < $nbr; $x++){
$result = curl_multi_getcontent($ch[$x]);
$obj[]= json_decode($result, true);
//get info about the request
// $error = curl_getinfo($ch[$x], CURLINFO_HTTP_CODE);
// if($error != 200){
if (curl_errno($ch[$x])) {
$erreur[] = array("Url" =>curl_getinfo($ch[$x], CURLINFO_EFFECTIVE_URL), "error_info" => curl_getinfo($ch[$x]));
}
//error handling
/*
200 : succès de la requête ;
301 et 302 : redirection, respectivement permanente et temporaire ;
401 : utilisateur non authentifié ;
403 : accès refusé ;
404 : page non trouvée ;
500 et 503 : erreur serveur.
*/
curl_multi_remove_handle($mh, $ch[$x]);
curl_close($ch[$x]);
}
curl_multi_close($mh);
/* OK Remplace les entrées vides par ""
for ($a = 0; $a < count($obj); $a++){
if (is_array($obj[$a])) {
for ($b = 0; $b < count($obj[$a]); $b++){
if (empty($obj[$a][$b])) {
$obj[$a][$b][0] = "";
}
}
} //if
} //for
*/
//echo "retour de la requete<br>";
//var_dump($obj);
for ($a = 0; $a < count($obj); $a++){
/*
$req = str_replace("_", " ", $obj[$a][0]);
$req = " " . $req . " ";
*/
$req = $query[$a];
$req = " " . $req . " ";
/*
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 "<b>matche $key</b>";
//echo "nettoyage du retour de la requete<br>";
$l = substr($val, 0, 50);
//var_dump($req, $val, $l);
if (stripos(substr($val, 0, 50), $req) === false) {
//echo "on supprime<br>";
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<br>";
//var_dump($obj);
return $obj;
}
/*
* 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
*/
function safe_array_access($ar){
$numargs = func_num_args();
$arg_list = func_get_args();
$aritterator = $ar;
for($i = 1; $i < $numargs; $i++){
if (isset($aritterator[$arg_list[$i]]) || array_key_exists($arg_list[$i], $aritterator)){
$aritterator = $aritterator[$arg_list[$i]];
}else{
return(false);
}
}
return($aritterator);
}
/*
* 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) {
$q = array();
$pat = "#_([^)]*)_#";
foreach($req as $val) {
$z = strip_tags($val);
/*
$fichier = preg_match($pat, $z, $match1);
if ($fichier === 1) $h = $match1[1];
else $h = $z;
*/
//$y= supp_article($z);
$y= supprime_article($z);
$x = str_to_noaccent($y);
//$v = strtolower($w);
$v = str_replace(" ", "_", $x);
$q[] = trim($v);
}
return $q;
}
function clean_photo_name($str) {
$pat = "#_([^)]*)_#";
$fichier = preg_match($pat, $str, $match1);
if ($fichier === 1) $h = $match1[1];
else $h = $z;
return $h;
}
function supp_entre_parenth($str) {
$pattern3 = "#\\([^)]*\\)#";
$m = preg_replace($pattern3, "", $str);
return $m;
}
/*
* 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);
return trim($l);
//$m = preg_replace($pattern3, "", $l);
//return trim($m);
}
/*
add_filter('the_content', 'exif_content', 20);

View File

@@ -50,6 +50,7 @@
if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' );
?>
<!--script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/child.js"></script-->
<?php
/* Always have wp_head() just before the closing </head>
@@ -60,12 +61,35 @@
*/
wp_head();
?>
<script type="text/javascript">
$(document).ready(function(){
$( "button#togle" ).click(function() {
$( ".comments_cont" ).toggle( "slow");
var $sp = $(this).text().trim().split(" ");
if($sp[0] == '<?php _e("Display", "CreatorThemeRes-child" ); ?>' ){
var e = $("#togle").text(function(index, text) {
return text.replace("<?php _e('Display', 'CreatorThemeRes-child' ); ?>", "<?php _e('Hide', 'CreatorThemeRes-child' ); ?>");
});
}
if($sp[0] == '<?php _e("Hide", "CreatorThemeRes-child" ); ?>' ){
var e = $("#togle").text(function(index, text) {
return text.replace("<?php _e('Hide', 'CreatorThemeRes-child' ); ?>", "<?php _e('Display', 'CreatorThemeRes-child' ); ?>");
});
}
//$el.text($el.text() == "<?php _e('Display comments', 'CreatorThemeRes-child' ); ?>" ? "<?php _e('Hide comments', 'CreatorThemeRes-child' ); ?>" : "<?php _e('Display comments', 'CreatorThemeRes-child' ); ?>");
});
});
</script>
<!--script type="text/javascript" src= "<?php echo WP_CONTENT_URL; ?>/themes/twentyten-child/js/jquery.liveSearch.js"></script>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/child.js"></script-->
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/jquery-2.1.0.min.js"></script-->
<!--script type="text/css" src="<?php echo get_stylesheet_directory_uri(); ?>/js/swipebox.min.css"></script-->
<?php if (is_single() || is_attachment()) { ?>
<!--script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script-->
<!--script type="text/javascript" src="https://maps.google.com/maps/api/js"></script-->
<!--script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/src/infobubble.js"></script>
@@ -73,9 +97,7 @@
<style type="text/css">
.entry-content img {max-width: 100000%; /* override */}
.firstHeading {font-weight: bold;}
</style>
<?php
} ?>
</style>
</head>

View File

@@ -1,6 +1,8 @@
function toggleExif(id) {
/*alert(id);*/
/**/id2 = id.toString();
/**/
//alert(id);
/**/
id2 = id.toString();
var exifDiv = document.getElementById(id2);
if (exifDiv.style.display == "block") {
exifDiv.style.display = "none";
@@ -8,6 +10,11 @@ function toggleExif(id) {
else {
exifDiv.style.display = "block";
google.maps.event.trigger(map, 'resize');
/*
var zoom = map.getZoom();
map.setZoom( zoom );
alert(zoom);
*/
map.setZoom( map.getZoom() );
map.setCenter(marker.getPosition());
}

View File

@@ -34,6 +34,10 @@
<?php //the_content(); ?>
<?php
$coord = array();
$compt_marker = 0;
$content = apply_filters('the_content', get_the_content());
$content = str_replace(']]>', ']]&gt;', $content);
@@ -92,9 +96,9 @@
list($exif_list, $gm_lat, $gm_lng, $title_marker) = ListeExif($metadata, $attachment, $i);
if ($gm_lat != "") {
$coord[$j]['lat'] = $gm_lat;
$coord[$j]['lng'] = $gm_lng;
$coord[$j]['mark'] = $title_marker;
$coord[$j][0] = $gm_lat;
$coord[$j][1] = $gm_lng;
$coord[$j][2] = $title_marker;
$j++;
}
@@ -122,12 +126,25 @@
list($exif_list, $gm_lat, $gm_lng, $title_marker) = ListeExifZP($meta);
if ($gm_lat != "") {
$coord[$j]['lat'] = $gm_lat;
$coord[$j]['lng'] = $gm_lng;
$coord[$j]['mark'] = str_replace("'", "\'", $title_marker);
$coord[$j][0] = $gm_lat;
$coord[$j][1] = $gm_lng;
$coord[$j][2] = str_replace("'", "\'", $title_marker);
$j++;
}
/*
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
*/
//$new_img = $ancien . '</a>' . "\r\n";
$new_img = $ancien . "\r\n";
@@ -168,85 +185,298 @@
echo $content;
//preprint($coord);
//var_dump($coord);
?>
<a name="carte"></a><p>&nbsp;</p>
<?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);
//var_dump($wiki);
//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) {
//alert('Success occured');
// 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
echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none") . ';"></div>';
?>
<script>
function initMap() {
var locations = [
<?php
$j = (count($coord) - 1);
for ($i = 0; $i <= $j; $i++) {
//echo "['" . $coord[$i]['mark'] . "', " . $coord[$i]['lat'] . ", " . $coord[$i]['lng'] . ", " . (intval($i) + 1) . "]" . (($i<$j) ? "," : "")."\r\n";
echo "['<h4>" . $coord[$i]['mark'] . "</h4>', " . $coord[$i]['lat'] . ", " . $coord[$i]['lng'] . "]" . (($i<$j) ? "," : "")."\r\n";
}
?>
];
// Setup the different icons and shadows
var iconURLPrefix = 'https://maps.google.com/mapfiles/ms/icons/';
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;
window.map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var 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][1], locations[i][2]),
map: map,
icon: icons[iconCounter]
});
bounds.extend(marker.position);
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
/*
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">' + locations[i][0] + '</h1>'+
'<div id="bodyContent">'+
'</div>'+
'</div>';
infowindow.setContent(contentString);
*/
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
map.fitBounds(bounds);
var listener = google.maps.event.addListener(map, "idle", function () {
map.setZoom(8);
google.maps.event.removeListener(listener);
});
}
</script>
?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>

125
style.css
View File

@@ -682,6 +682,7 @@ div.threewp_ajax_search_results_content ul li:hover
.bloc_exif ul {list-style:none; padding:1em; background:#fff; border:solid #ddd; border-width:1px;
}
*/
/*
#content .bloc_exif li {display:inline; padding-right:0.5em; font-size:0.857em;
}
@@ -708,4 +709,126 @@ div.threewp_ajax_search_results_content ul li:hover
}
.infowindow {
width: 350px;
}
}
*/
/* Exif */
.image-exif {
margin-right: auto;
margin-left: auto;
text-align: center;
margin-bottom: 32px;
}
.exif-data {
display: inline-block;
margin-right: 16px;
font-size: 10px;
}
.cible i.ion-ios-location {
display: none;
color: green;
padding: 3px;
}
.cible i.ion-ios-location:hover {
color: #00b701;
}
div#locations {
display: none;
}
button#hidemap {
display: none;
margin-bottom: 24px;
margin-top: 32px;
}
button#showmap {
margin-bottom: 24px;
margin-top: 32px;
}
div#center_marker {
width: 100%;
text-align: center;
}
ul.list_marker {
padding-left: 0;
margin: 2px auto;
}
/**/
ul.list_marker a {
text-decoration: none;
color: green;
}
ul.list_marker a:hover {
color: #00b701;
}
ul.list_marker li {
color: green !important;
}
ul.list_marker li:hover {
color: #00b701 !important;
font-weight: bold;
}
.list_marker li {
display: inline;
font-size: 10px;
padding-right: 8px;
padding-left: 8px;
list-style-image: none;
text-align: center;
}
/* googlempa */
.infowindow, .gm-style-iw {
color: #5f5f5f;
font: normal normal 12px "Lucida Grande", Lucida, Verdana, sans-serif;
}
.infowindow, .gm-style-iw a {
color: black;
text-decoration: underline;
}
.infowindow, .gm-style-iw img {
margin-top: 8px;
margin-left: 8px;
}
#lettrineImage{
float: left;
width: 220px;
height: 163px;
margin: 0 1em 1em 0;
}
#map {
width: 600px;
height: 400px;
display: none;
margin: 5em auto;
}
#gmap h1{
font-family: Arial, Helvetica, sans-serif;
font-size: 1.6em;
font-style: italic;
font-weight: bold;
color:#267AA8;
text-align:center;
}
#gmap h2{
margin-bottom:1em;
font-family: Arial, Helvetica, sans-serif;
font-size: 1.3em;
font-style: normal;
font-weight: bold;
color:#FF9900;
text-align:center;
}
#gmap p{
font: 1em "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
}