1573 lines
48 KiB
PHP
1573 lines
48 KiB
PHP
<?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." ) );
|
||
update_option( 'wr2x_pro_serial', _( $serial ) );
|
||
set_transient( 'wr2x_validated', $serial, 3600 * 24 * 100 );
|
||
|
||
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
|
||
add_filter('sanitize_file_name', 'remove_accents' );
|
||
|
||
// Set Plugins and Themes to Update Automatically
|
||
add_filter( 'auto_update_plugin', '__return_true' );
|
||
add_filter( 'auto_update_theme', '__return_true' );
|
||
|
||
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');
|
||
|
||
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');
|
||
|
||
wp_enqueue_script( 'child', get_stylesheet_directory_uri() . '/js/child.js', '', '',false );
|
||
}
|
||
add_action( 'wp_enqueue_scripts', 'enqueue_my_scripts' );
|
||
|
||
// 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 );
|
||
}
|
||
|
||
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() */
|
||
|
||
function preprint($s, $return=false) {
|
||
$x = "<pre>";
|
||
$x .= print_r($s, 1);
|
||
$x .= "</pre>";
|
||
if ($return) return $x;
|
||
else print $x;
|
||
}
|
||
|
||
|
||
/*** Ajout d'un bouton ZP dans l'éditeur visuel (tinymce) ***/
|
||
|
||
add_action('init','add_buttons');
|
||
function add_buttons(){
|
||
if(current_user_can('edit_posts') && current_user_can('edit_pages')){
|
||
add_filter('mce_external_plugins','add_plugins');
|
||
add_filter('mce_buttons','register_buttons');
|
||
}
|
||
}
|
||
|
||
function add_plugins($plugins){
|
||
$plugins['zp'] = get_bloginfo('stylesheet_directory').'/js/zenphoto.js';
|
||
return $plugins;
|
||
}
|
||
function register_buttons($buttons){
|
||
array_push($buttons, 'zp');
|
||
return $buttons;
|
||
}
|
||
/*** /ajout bouton ZP dans l'editeur ***/
|
||
|
||
|
||
/* Shorcode Zenphoto
|
||
*/
|
||
|
||
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" 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
|
||
)
|
||
*/
|
||
|
||
$selector = theme_setting('dess_lightbox_select');
|
||
$zenphoto_url = theme_setting('dess_zenphoto');
|
||
$size = theme_setting('dess_zp_size');
|
||
|
||
$album = ! empty( $atts['album'] ) ? $atts['album'] : '';
|
||
$album = filter_var($album, FILTER_SANITIZE_STRING);
|
||
|
||
$image = ! empty( $atts['image'] ) ? $atts['image'] : '';
|
||
$image = filter_var($image, FILTER_SANITIZE_STRING);
|
||
|
||
$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 = "";
|
||
|
||
|
||
//echo dirname(__FILE__);
|
||
//echo __FILE__;
|
||
|
||
// require ($_SERVER["DOCUMENT_ROOT"]."/path/to/file.php");
|
||
|
||
//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]-->
|
||
<source class="image_standard" srcset="' . $zenphoto_url . 'cache/' . $atts['album'] . '/' . $img . '_' . $size . '_watermark.jpg, ' . $zenphoto_url . 'cache/' . $atts['album'] . '/' . $img . '_' . ($size * 2) . '_watermark.jpg 2x">
|
||
<source class="image_medium" srcset="" media="(max-width: 767px)">
|
||
<source class="image_small" srcset="" media="(max-width: 767px)">
|
||
<!--[if IE 9]></video><![endif]-->
|
||
<img class="aligncenter" srcset="' . $zenphoto_url . 'cache/' . $atts['album'] . '/' . $img . '_' . $size . '_watermark.jpg" ' . $zp_size[3] . 'alt="' . $img . '" />
|
||
</picture>';
|
||
$zenphoto_img .= '</a>';
|
||
|
||
/*
|
||
if ($b['image_meta']['description'] != "") {
|
||
$caption = "";
|
||
$caption .= '<p class="wp-caption-text aligncenter" style="width:' . $zp_size[0] . 'px">';
|
||
$caption .= $b['image_meta']['description'] . '</p>';
|
||
|
||
$zenphoto_img .= $caption;
|
||
}
|
||
*/
|
||
//echo $zenphoto_img;
|
||
return $zenphoto_img;
|
||
}
|
||
|
||
add_shortcode( 'zenphoto', 'zenphoto_handler' );
|
||
|
||
// include
|
||
|
||
|
||
/* NON UTILISE */
|
||
|
||
function field_func($atts) {
|
||
global $post;
|
||
$name = $atts['name'];
|
||
if (empty($name)) return;
|
||
return get_post_meta($post->ID, $name, true);
|
||
}
|
||
add_shortcode('field', 'field_func');
|
||
|
||
|
||
/*
|
||
// http://wp.ruche.org/2010/12/20/utiliser-les-images-a-la-une/
|
||
add_theme_support( 'post-thumbnails', array( 'post' ) ); // Ajouter sur les articles uniquement
|
||
add_theme_support( 'post-thumbnails', array( 'page' ) ); // Ajouter sur les pages uniquement
|
||
set_post_thumbnail_size( 50, 50 ); // 50 pixels en largeur par 50 pixels en hauteur, box resize
|
||
//set_post_thumbnail_size( 50, 50, true ); // 50 pixels en largeur par 50 pixels en hauteur, mode hard crop
|
||
//add_image_size( 'miniature-archives', 200, 9999 ); // Miniatures des archives
|
||
*/
|
||
|
||
|
||
/* Ajoute les données GPS aux métadata lors de l'importation du média */
|
||
|
||
function add_geo_exif($meta,$file,$sourceImageType) {
|
||
$exif = @exif_read_data( $file );
|
||
if (!empty($exif['GPSLatitude']))
|
||
$meta['latitude'] = $exif['GPSLatitude'] ;
|
||
if (!empty($exif['GPSLatitudeRef']))
|
||
$meta['latitude_ref'] = trim( $exif['GPSLatitudeRef'] );
|
||
if (!empty($exif['GPSLongitude']))
|
||
$meta['longitude'] = $exif['GPSLongitude'] ;
|
||
if (!empty($exif['GPSLongitudeRef']))
|
||
$meta['longitude_ref'] = trim( $exif['GPSLongitudeRef'] );
|
||
|
||
return $meta;
|
||
}
|
||
|
||
add_filter('wp_read_image_metadata', 'add_geo_exif','',3);
|
||
|
||
|
||
function favicon_link() {
|
||
echo '<link rel="shortcut icon" type="image/x-icon" href="' . get_bloginfo ( 'stylesheet_directory' ) . '/images/favicon.ico" />' . "\n";
|
||
}
|
||
|
||
add_action('wp_head', 'favicon_link');
|
||
|
||
|
||
function childtheme_iefix() { ?>
|
||
<!--[if lt IE 8]>
|
||
<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory') ?>/ie.css" />
|
||
<![endif]-->
|
||
<?php }
|
||
|
||
add_action('wp_head', 'childtheme_iefix');
|
||
|
||
|
||
/* NON UTILISE */
|
||
|
||
function saveCommentMeta($comment_id) {
|
||
if (isset($_POST['city']) && !empty($_POST['city'])) {
|
||
add_comment_meta($comment_id, 'city', $_POST['city'], true);
|
||
}
|
||
if (isset($_POST['pays']) && !empty($_POST['pays'])) {
|
||
add_comment_meta($comment_id, 'pays', $_POST['pays'], true);
|
||
}
|
||
}
|
||
|
||
add_action('comment_post','saveCommentMeta');
|
||
|
||
|
||
/* NON UTILISE */
|
||
|
||
function show_bookmark_list(){ ?>
|
||
<ul>
|
||
<?php
|
||
$args = array(
|
||
'title_before' => '<h3>',
|
||
'title_after' => '</h3>',
|
||
);
|
||
wp_list_bookmarks( $args ); ?>
|
||
</ul>
|
||
<?php
|
||
}
|
||
add_shortcode('show_bookmark_list', 'show_bookmark_list');
|
||
|
||
|
||
/* NON UTILISE */
|
||
|
||
// [show_bookmark_image_list catagory_name='']
|
||
function show_bookmark_image_list($atts){
|
||
extract(shortcode_atts(array(
|
||
'catagory_name' => false
|
||
), $atts));
|
||
if ( $catagory_name == false )
|
||
$bookmarks = get_bookmarks();
|
||
else
|
||
$bookmarks = get_bookmarks("catagory_name=$catagory_name");
|
||
ob_start();
|
||
echo "<ul class='link-image-list'>";
|
||
foreach($bookmarks as $bookmark){
|
||
$cat = $bookmark->link_category;
|
||
//foreach(($bookmark->link_category) as $cat){
|
||
/*
|
||
stdClass Object (
|
||
[link_id] => 10
|
||
[link_url] => http://www.eos-numerique.com/
|
||
[link_name] => EOS-Numerique
|
||
[link_image] =>
|
||
[link_target] =>
|
||
[link_category] => 3
|
||
[link_description] => Portail EOS Canon numérique
|
||
[link_visible] => Y
|
||
[link_owner] => 1
|
||
[link_rating] => 0
|
||
[link_updated] => 0000-00-00 00:00:00
|
||
[link_rel] =>
|
||
[link_notes] =>
|
||
[link_rss] =>
|
||
)
|
||
*/
|
||
//echo "<li><a href='".esc_url($bookmark->link_url) ."'><img src='".esc_url($bookmark->link_image)."' /></a></li>";
|
||
//echo "<li><a href='".esc_url($bookmark->link_url) ."'>".$bookmark->link_name."</a></li>";
|
||
echo $cat;
|
||
//}
|
||
}
|
||
echo "</ul>";
|
||
$list = ob_get_clean();
|
||
return $list;
|
||
}
|
||
add_shortcode('show_bookmark_image_list', 'show_bookmark_image_list');
|
||
//end show_bookmark_image_list
|
||
|
||
|
||
/* Signale que le post a été mis à jour
|
||
loop-single.php:365:
|
||
*/
|
||
|
||
function twentyten_post_updated() {
|
||
$u_time = get_the_time('U');
|
||
$u_modified_time = get_the_modified_time('U');
|
||
if ($u_modified_time >= $u_time + 86400) {
|
||
printf( __( '<span class="maj"> Article updated the %1$s at %2$s </span>', 'twentyten-child'),
|
||
sprintf('%1$s', get_the_modified_time('j F Y')),
|
||
sprintf('%1$s', get_the_modified_time())
|
||
);
|
||
}
|
||
}
|
||
|
||
/* Prints HTML with meta information for the current post—date/time and author.
|
||
livre-d-or.php:23:
|
||
loop-single.php:29:
|
||
loop.php:66:
|
||
loop.php:121:
|
||
loop.php:135:
|
||
*/
|
||
|
||
function twentyten_posted_on() {
|
||
printf( __( '%1$s', 'twentyten-child' ),
|
||
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
|
||
get_permalink(),
|
||
esc_attr( get_the_time() ),
|
||
get_the_date()
|
||
)
|
||
);
|
||
}
|
||
|
||
/* Prints HTML with meta information for the current post (category, tags and permalink).
|
||
livre-d-or.php:32:
|
||
loop-attachment.php:149:
|
||
loop-single.php:372:
|
||
*/
|
||
|
||
function twentyten_posted_in() {
|
||
// Retrieves tag list of current post, separated by commas.
|
||
$tag_list = get_the_tag_list( '', ', ' );
|
||
if ( $tag_list ) {
|
||
//$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
|
||
$posted_in = __( 'Posted in %1$s and tagged %2$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">Permalink</a>.', 'twentyten-child' );
|
||
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
|
||
$posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten-child' );
|
||
} else {
|
||
$posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten-child' );
|
||
}
|
||
// Prints the string, replacing the placeholders.
|
||
printf(
|
||
$posted_in,
|
||
get_the_category_list( ', ' ),
|
||
$tag_list,
|
||
get_permalink(),
|
||
the_title_attribute( 'echo=0' )
|
||
);
|
||
}
|
||
|
||
|
||
/* NON UTILISE */
|
||
|
||
function thirtyten_excerpt_more($more){
|
||
return ' … <a href="'. get_permalink() . '">' . __('finish reading '.get_the_title() .'', 'twentyten-child') . '</a>';
|
||
}
|
||
|
||
remove_filter( 'excerpt_more', 'twentyten_excerpt_more' );
|
||
add_filter ('excerpt_more', 'thirtyten_excerpt_more' );
|
||
|
||
|
||
/* Messages du livre d'or
|
||
livre-comments.php:54
|
||
*/
|
||
|
||
function twentyten_comment_guestbook( $comment, $args, $depth ) {
|
||
$GLOBALS['comment'] = $comment;
|
||
// hack 'city'
|
||
$city = htmlspecialchars(ucwords(get_comment_meta($comment->comment_ID,'city',true)));
|
||
$pays = htmlentities(get_comment_meta($comment->comment_ID,'pays',true));
|
||
$pays = str_replace('_',' ',$pays);
|
||
if (($city != "") and ($pays != "")) $a = "(" . $city . ", " . $pays . ")";
|
||
if (($city != "") and ($pays == "")) $a = "(" . $city . ")";
|
||
if (($city == "") and ($pays != "")) $a = "(" . $pays . ")";
|
||
if (($city == "") and ($pays == "")) $a = "";
|
||
|
||
switch ( $comment->comment_type ) :
|
||
case '' :
|
||
?>
|
||
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
|
||
<div id="comment-<?php comment_ID(); ?>">
|
||
<div class="comment-author vcard">
|
||
<?php echo get_avatar( $comment, 40 ); ?>
|
||
<?php //printf( __( '%s <span class="says">says:</span>', 'twentyten-child' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
|
||
<?php printf( __( '%1$s %2$s<span class="says"> says:</span>', 'twentyten-child' ), sprintf( '<cite class="fn">%1$s</cite>', get_comment_author_link() ), sprintf($a) ); ?>
|
||
</div><!-- .comment-author .vcard -->
|
||
<?php if ( $comment->comment_approved == '0' ) : ?>
|
||
<em><?php _e( 'Your comment is awaiting moderation.', 'twentyten-child' ); ?></em>
|
||
<br />
|
||
<?php endif; ?>
|
||
|
||
<div class="comment-body"><?php comment_text(); ?></div>
|
||
<div class="comment-meta commentmetadata-guestbook"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
|
||
<?php
|
||
/* translators: 1: date, 2: time */
|
||
printf( __( '%1$s at %2$s', 'twentyten-child' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten-child' ), ' ' );
|
||
?>
|
||
|
||
|
||
</div><!-- .comment-meta .commentmetadata -->
|
||
|
||
<?php
|
||
if (get_option( 'guestbook_comment' ) == true) {
|
||
?>
|
||
<div class="reply">
|
||
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
|
||
</div><!-- .reply -->
|
||
|
||
<?php
|
||
}
|
||
?>
|
||
|
||
</div><!-- #comment-## -->
|
||
|
||
<?php
|
||
break;
|
||
case 'pingback' :
|
||
case 'trackback' :
|
||
?>
|
||
<li class="post pingback">
|
||
<p><?php _e( 'Pingback:', 'twentyten-child' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'twentyten-child'), ' ' ); ?></p>
|
||
<?php
|
||
break;
|
||
endswitch;
|
||
}
|
||
|
||
|
||
/* Returns the name of one random file from within a directory
|
||
livre-d-or.php:39:
|
||
*/
|
||
|
||
function getRandomFile($start_dir) {
|
||
|
||
chdir($start_dir);
|
||
$dir = opendir('.');
|
||
while (($myfile = readdir($dir)) !==false) {
|
||
if ($myfile != '.' && $myfile != '..' && is_file($myfile) && $myfile != 'resource.frk') {
|
||
$files[] = $myfile;
|
||
}
|
||
}
|
||
closedir($dir);
|
||
chdir('../');
|
||
srand ((float) microtime() * 10000000);
|
||
$file = array_rand($files);
|
||
return $files[$file];
|
||
}
|
||
|
||
/*
|
||
loop-single.php:30
|
||
*/
|
||
|
||
function RelativeTime() {
|
||
|
||
$jour = get_the_date('U');
|
||
$aujourdhui = date('U');
|
||
$delta = round(($aujourdhui - $jour) / (3600 * 24));
|
||
|
||
if ($delta == 0) $text = "aujourd'hui";
|
||
elseif ($delta == 1) $text = __("yesterday", 'twentyten-child');
|
||
elseif ($delta == 2) $text = __("the day before yesterday", 'twentyten-child');
|
||
elseif ($delta == 3) $text = __("two days ago", 'twentyten-child');
|
||
elseif (($delta > 3) and ($delta <= 7)) $text = sprintf( __('%1$s days ago', 'twentyten-child'), $delta );
|
||
elseif (($delta > 7) and ($delta <= 14)) {
|
||
$nb = round ($delta / 7);
|
||
if ($nb < 2) $text = sprintf( __('%1$s week ago', 'twentyten-child'), $nb );
|
||
else $text = sprintf( __('%1$s weeks ago', 'twentyten-child'), $nb );
|
||
}
|
||
else $text = get_the_date();
|
||
|
||
printf( __( '%1$s', 'twentyten-child' ),
|
||
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">'.$text.'</span></a>',
|
||
get_permalink(),
|
||
esc_attr( get_the_date() . ' ' . get_the_time() )
|
||
)
|
||
);
|
||
}
|
||
|
||
/*
|
||
function exif_get_float($value) {
|
||
$pos = strpos($value, '/');
|
||
if ($pos === false) return (float) $value;
|
||
$a = (float) substr($value, 0, $pos);
|
||
$b = (float) substr($value, $pos+1);
|
||
return ($b == 0) ? ($a) : ($a / $b);
|
||
}
|
||
|
||
|
||
function exif_get_shutter($apex) {
|
||
$apex = exif_get_float($apex);
|
||
$shutter = pow(2, -$apex);
|
||
if ($shutter == 0) return false;
|
||
if ($shutter >= 1) return round($shutter) . 's';
|
||
return '1/' . round(1 / $shutter) . 's';
|
||
}
|
||
|
||
function exif_get_fstop(&$exif) {
|
||
if (!isset($exif['ApertureValue'])) return false;
|
||
$apex = exif_get_float($exif['ApertureValue']);
|
||
$fstop = pow(2, $apex/2);
|
||
if ($fstop == 0) return false;
|
||
return 'f/' . round($fstop,1);
|
||
}
|
||
*/
|
||
|
||
// === DISPLAY EXIF === //
|
||
|
||
/* return geo exif in a nice form
|
||
|
||
*/
|
||
|
||
function geo_frac2dec($str) {
|
||
@list( $n, $d ) = explode( '/', $str );
|
||
if ( !empty($d) )
|
||
return $n / $d;
|
||
return $str;
|
||
}
|
||
|
||
|
||
/*
|
||
33° 52.37′ 0″ S 151° 9.06′ 0″ E
|
||
*/
|
||
|
||
|
||
function geo_pretty_fracs2dec($fracs) {
|
||
return geo_frac2dec($fracs[0]) . '° ' .
|
||
geo_frac2dec($fracs[1]) . '′ ' .
|
||
geo_frac2dec($fracs[2]) . '″ ';
|
||
}
|
||
|
||
|
||
/*
|
||
to GoogleMaps
|
||
*/
|
||
|
||
function geo_single_fracs2dec($fracs) {
|
||
return geo_frac2dec($fracs[0]) +
|
||
geo_frac2dec($fracs[1]) / 60 +
|
||
geo_frac2dec($fracs[2]) / 3600;
|
||
}
|
||
|
||
/* Crée le cadre Afficher les exifs (WorPress)
|
||
single.php:67:
|
||
single.php:123:
|
||
functions.php:555:
|
||
functions.php:794:
|
||
loop-attachment.php:138:
|
||
loop-single.php:117:
|
||
loop-single.php:151:
|
||
loop-single.php:197:
|
||
*/
|
||
|
||
function ListeExif($meta, $attach, $i){
|
||
$before_item = '<li>';
|
||
$after_item = '</li>';
|
||
$sep = ': ';
|
||
$zoom = '11';
|
||
$exif_list = '';
|
||
$gm_lat = '';
|
||
$gm_lng = '';
|
||
|
||
if (!empty($meta['image_meta']['latitude']))
|
||
$latitude = $meta['image_meta']['latitude'];
|
||
if (!empty($meta['image_meta']['longitude']))
|
||
$longitude = $meta['image_meta']['longitude'];
|
||
if (!empty($meta['image_meta']['latitude_ref']))
|
||
$lat_ref = $meta['image_meta']['latitude_ref'];
|
||
if (!empty($meta['image_meta']['longitude_ref']))
|
||
$lng_ref = $meta['image_meta']['longitude_ref'];
|
||
|
||
// Aperture
|
||
if (!empty($meta['image_meta']['aperture']))
|
||
$exif_list .= $before_item . __('Aperture', 'twentyten-child') . $sep . "f/" . $meta['image_meta']['aperture'] . $after_item;
|
||
|
||
// Shutter speed
|
||
if (!empty($meta['image_meta']['shutter_speed'])) {
|
||
$exif_list .= $before_item . __('Shutter speed', 'twentyten-child') . $sep;
|
||
if ((1 / $meta['image_meta']['shutter_speed']) > 1) {
|
||
$exif_list .= "1/";
|
||
if ((number_format((1 / $meta['image_meta']['shutter_speed']), 1)) == 1.3
|
||
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 1.5
|
||
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 1.6
|
||
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 2.5) {
|
||
$exif_list .= number_format((1 / $meta['image_meta']['shutter_speed']), 1, '.', '') . " s" . $after_item;
|
||
}
|
||
else {
|
||
$exif_list .= number_format((1 / $meta['image_meta']['shutter_speed']), 0, '.', '') . " s" . $after_item;
|
||
}
|
||
}
|
||
else {
|
||
$exif_list .= $meta['image_meta']['shutter_speed']." s" . $after_item;
|
||
}
|
||
}
|
||
// Focal length
|
||
if (!empty($meta['image_meta']['focal_length']))
|
||
$exif_list .= $before_item . __('Focal length', 'twentyten-child') . $sep . $meta['image_meta']['focal_length'] . " mm" . $after_item;
|
||
// Camera
|
||
if (!empty($meta['image_meta']['camera']))
|
||
$exif_list .= $before_item . __('Camera', 'twentyten-child') . $sep . $meta['image_meta']['camera'] . $after_item;
|
||
// Creation time
|
||
if (!empty($meta['image_meta']['created_timestamp']))
|
||
/*
|
||
setlocale(LC_TIME, 'fr_FR');
|
||
echo $meta['image_meta']['created_timestamp'];
|
||
$dt = strftime("%e %B %Y", $meta['image_meta']['created_timestamp']);
|
||
$dt = mb_convert_encoding($dt, 'utf-8');
|
||
echo $dt;
|
||
*/
|
||
$exif_list .= $before_item . __('Taken', 'twentyten-child') . $sep . date(__('j F, Y', 'twentyten-child'),$meta['image_meta']['created_timestamp']) . $after_item;
|
||
|
||
// Latitude and Longtitude
|
||
//if ($latitude != 0 && $longitude != 0) {
|
||
if (isset($latitude) && isset($longitude)) {
|
||
|
||
$lat = geo_single_fracs2dec($latitude);
|
||
$lng = geo_single_fracs2dec($longitude);
|
||
|
||
if ($lat_ref == 'S') { $neg_lat = '-'; } else { $neg_lat = ''; }
|
||
if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; }
|
||
|
||
$gm_lat = $neg_lat . number_format($lat,6);
|
||
$gm_lng = $neg_lng . number_format($lng, 6);
|
||
|
||
$geo_link = '<a href="http://maps.google.com/maps?q=' . $neg_lat . number_format($lat,6) . '+' . $neg_lng . number_format($lng, 6) . '&z=11">';
|
||
$geo_link .= '<img src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" />';
|
||
$geo_link .= '</a>';
|
||
|
||
$exif_list .= $before_item . $geo_link . $after_item;
|
||
//affichage dans un cadre map caché
|
||
//$exif_list .= $before_item . '<a href="#carte" title="'. __('Display/hide on map', 'twentyten-child') . '" onclick="toggleExif(\'map_canvas' . $i . '\');"><img src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" /></a>' . $after_item;
|
||
}
|
||
|
||
// Titre du marker
|
||
if (!empty($meta['image_meta']['title'])) $title_marker = $meta['image_meta']['title'];
|
||
elseif (!empty($meta['file'])) {
|
||
// en 2 lignes, sinon erreur Strict Standards: Only variables should be passed by reference
|
||
$tmp = explode("/", $meta['file']);
|
||
$title_marker = end($tmp);
|
||
}
|
||
|
||
//if ((isset($exif_list)) & (isset($gm_lat)) & (isset($gm_lng)) & (isset($title_marker))) {
|
||
return array($exif_list, $gm_lat, $gm_lng, $title_marker);
|
||
//}
|
||
}
|
||
|
||
|
||
/* NON UTILISE */
|
||
|
||
function _ListeExif($meta, $attachment){
|
||
$before_item = '<li>';
|
||
$after_item = '</li>';
|
||
$sep = ': ';
|
||
$zoom = '11';
|
||
//print_r($meta);
|
||
if ($meta['image_meta']['latitude'])
|
||
$latitude = $meta['image_meta']['latitude'];
|
||
if ($meta['image_meta']['longitude'])
|
||
$longitude = $meta['image_meta']['longitude'];
|
||
if ($meta['image_meta']['latitude_ref'])
|
||
$lat_ref = $meta['image_meta']['latitude_ref'];
|
||
if ($meta['image_meta']['longitude_ref'])
|
||
$lng_ref = $meta['image_meta']['longitude_ref'];
|
||
|
||
$lat = geo_single_fracs2dec($latitude);
|
||
$lng = geo_single_fracs2dec($longitude);
|
||
if ($lat_ref == 'S') { $neg_lat = '-'; } else { $neg_lat = ''; }
|
||
if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; }
|
||
|
||
$gm_lat = $neg_lat . number_format($lat,6);
|
||
$gm_lng = $neg_lng . number_format($lng, 6);
|
||
$start_geo_link = '<a href="http://maps.google.com/maps?q=' . $gm_lat . '+' . $gm_lng . '&z='. $zoom . '">';
|
||
$end_geo_link = '</a>';
|
||
|
||
// Aperture
|
||
if (!empty($meta['image_meta']['aperture']))
|
||
$exif_list .= $before_item . __('Aperture', 'twentyten-child') . $sep . "f/" . $meta['image_meta']['aperture'] . $after_item;
|
||
|
||
// Shutter speed
|
||
if (!empty($meta['image_meta']['shutter_speed'])) {
|
||
$exif_list .= $before_item . __('Shutter speed', 'twentyten-child') . $sep;
|
||
if ((1 / $meta['image_meta']['shutter_speed']) > 1) {
|
||
$exif_list .= "1/";
|
||
if ((number_format((1 / $meta['image_meta']['shutter_speed']), 1)) == 1.3
|
||
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 1.5
|
||
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 1.6
|
||
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 2.5) {
|
||
$exif_list .= number_format((1 / $meta['image_meta']['shutter_speed']), 1, '.', '') . " s" . $after_item;
|
||
}
|
||
else {
|
||
$exif_list .= number_format((1 / $meta['image_meta']['shutter_speed']), 0, '.', '') . " s" . $after_item;
|
||
}
|
||
}
|
||
else {
|
||
$exif_list .= $meta['image_meta']['shutter_speed']." s" . $after_item;
|
||
}
|
||
}
|
||
// Focal length
|
||
if (!empty($meta['image_meta']['focal_length']))
|
||
$exif_list .= $before_item . __('Focal length', 'twentyten-child') . $sep . $meta['image_meta']['focal_length'] . " mm" . $after_item;
|
||
// Camera
|
||
if (!empty($meta['image_meta']['camera']))
|
||
$exif_list .= $before_item . __('Camera', 'twentyten-child') . $sep . $meta['image_meta']['camera'] . $after_item;
|
||
// Creation time
|
||
if (!empty($meta['image_meta']['created_timestamp']))
|
||
$exif_list .= $before_item . __('Taken', 'twentyten-child') . $sep . date('j F, Y',$meta['image_meta']['created_timestamp']) . $after_item;
|
||
// F j, Y, g:i a
|
||
|
||
//echo $exif_list;
|
||
|
||
// Latitude and Longtitude
|
||
if ($latitude != 0 && $longitude != 0)
|
||
//affichage dans un cadre map caché
|
||
//$exif_list .= $before_item . '<div onclick="toggleExif(\'map\');" ><image src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" /></div>' . $after_item;
|
||
$exif_list .= $before_item . '<image onclick="toggleExif(\'map\');" src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" />' . $after_item;
|
||
//$exif_list .= $before_item . '<img onclick="toggleExif(map'. $attachment . ');" src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" />' . $after_item;
|
||
|
||
// Titre du marker
|
||
if ($meta['image_meta']['caption']) $title_marker = $meta['image_meta']['caption'];
|
||
elseif ($meta['file']) $title_marker = $meta['file'];
|
||
|
||
|
||
|
||
//echo "exif_list: " . $exif_list;
|
||
return array($exif_list, $gm_lat, $gm_lng, $title_marker);
|
||
}
|
||
|
||
|
||
/* NON UTILISE */
|
||
|
||
function mod_image($id){
|
||
|
||
$ajout .= '</a></p>' . "\n" . '<div class="droite" onclick="toggleExif(' . $id . ');">Voir les Exif</div>';
|
||
$ajout .= '<div class="bloc_exif" id="' . $id .'">' . "\n";
|
||
$ajout .= '<ul class="exif" id="bloc_exif">';
|
||
list($liste_exif, $gm_lat, $gm_lng, $title_marker) = att_exif($id);
|
||
//$ajout .= att_exif($id);
|
||
$ajout .= $liste_exif;
|
||
$ajout .= '</ul></div>';
|
||
|
||
$ajout .= '<div class="mappy" id="map' . $id . '"></div>';
|
||
|
||
//<!--div id="map"></div-->
|
||
|
||
$ajout .= '<script type="text/javascript">';
|
||
$ajout .= 'var contentString = "' . $title_marker . '";';
|
||
$ajout .= 'var latlng = new google.maps.LatLng(' .$gm_lat .', ' . $gm_lng . ');';
|
||
$ajout .= 'initialize();';
|
||
$ajout .= 'marker = createMarker(latlng, \'\', contentString, map);';
|
||
$ajout .= '</script>';
|
||
?>
|
||
<!--script type="text/javascript">
|
||
var contentString = "<?php echo $title_marker; ?>";
|
||
var latlng = new google.maps.LatLng(<?php echo $gm_lat; ?>, <?php echo $gm_lng; ?>);
|
||
initialize();
|
||
marker = createMarker(latlng, '', contentString, map);
|
||
</script-->
|
||
|
||
<?php
|
||
return $ajout;
|
||
}
|
||
|
||
|
||
/*
|
||
functions.php:737:
|
||
functions.php:738:
|
||
functions.php:765:
|
||
*/
|
||
|
||
function att_exif($a){
|
||
global $attachment;
|
||
$att = ($attachment[$a][1]);
|
||
$att = substr_replace($att, '', 0, 18);
|
||
|
||
$metadata = wp_get_attachment_metadata($att);
|
||
//print_r($metadata);
|
||
/*
|
||
$before_block = '<div class="bloc_exif" id="' . $att . '"><ul>';
|
||
$after_block = '</ul></div>';
|
||
|
||
$liste_exif = $before_block;
|
||
*/
|
||
// ListeExif renvoie 3 paramètres dans un tableau:
|
||
// -les exifs sous forme de liste
|
||
// -latitude et longitude pour le javascript
|
||
// -le caption ou le nom du fichier pour l'infoWindow
|
||
list($exif_list, $gm_lat, $gm_lng, $title_marker) = ListeExif($metadata,$a);
|
||
|
||
//echo $exif_list;
|
||
|
||
$liste_exif .= $exif_list;
|
||
$liste_exif .= $after_block;
|
||
//echo $liste_exif;
|
||
|
||
//return $liste_exif;
|
||
return array($liste_exif, $gm_lat, $gm_lng, $title_marker);
|
||
}
|
||
|
||
|
||
/* Requete pour récupérer les exifs d'une image dans Zenphoto
|
||
loop-single.php:147
|
||
*/
|
||
|
||
function zp_query($zpimage) {
|
||
$exif = array();
|
||
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();
|
||
}
|
||
|
||
$excquery = "SELECT `EXIFModel`, `EXIFDateTimeOriginal`, `EXIFExposureTime`, `EXIFFNumber`, `EXIFISOSpeedRatings`, `EXIFFocalLength`, `EXIFGPSLatitude`, `EXIFGPSLatitudeRef`, `EXIFGPSLongitude`, `EXIFGPSLongitudeRef`, `EXIFGPSAltitude`, `EXIFGPSAltitudeRef`, `desc`, `title` FROM `" . $zp_prefix . "images` WHERE `filename` = \"$zpimage\"";
|
||
//echo $excquery;
|
||
if ($result = $mysqli->query($excquery)) {
|
||
$exif = $result->fetch_row();
|
||
$result->close();
|
||
}
|
||
|
||
//preprint($exif);
|
||
|
||
/*
|
||
Array
|
||
(
|
||
[0] => Canon EOS 7D
|
||
[1] => 2011:06:30 20:43:30
|
||
[2] => 1/400 sec
|
||
[3] => f/6,3
|
||
[4] => 640
|
||
[5] => 600 mm
|
||
[6] => lat
|
||
[7] => lat ref
|
||
[8] => long
|
||
[9] => long ref
|
||
[10] => alt
|
||
[11] => alt ref
|
||
[12] => desc
|
||
[13] => title
|
||
)*/
|
||
$meta = array();
|
||
$meta['image_meta']['camera'] = $exif[0];
|
||
$meta['image_meta']['created_timestamp'] = $exif[1];
|
||
$meta['image_meta']['shutter_speed'] = $exif[2];
|
||
$meta['image_meta']['aperture'] = $exif[3];
|
||
$meta['image_meta']['iso'] = $exif[4];
|
||
$meta['image_meta']['focal_length'] = $exif[5];
|
||
$meta['image_meta']['latitude'] = $exif[6];
|
||
$meta['image_meta']['latitude_ref'] = $exif[7];
|
||
$meta['image_meta']['longitude'] = $exif[8];
|
||
$meta['image_meta']['longitude_ref'] = $exif[9];
|
||
$meta['image_meta']['altitude'] = $exif[10];
|
||
$meta['image_meta']['altitude_ref'] = $exif[11];
|
||
|
||
if ($exif[12] != "") {
|
||
$desc = explode(':', $exif[12]);
|
||
$description = explode('"', end($desc));
|
||
//print_r($description);
|
||
$meta['image_meta']['description'] = utf8_encode($description[1]);
|
||
}
|
||
else $meta['image_meta']['description'] = "";
|
||
|
||
if ($exif[13] != "") {
|
||
//echo "exif: " . $exif[13] . "<br>";
|
||
// a:1:{s:5:"fr_FR";s:30:"2011-05-15_GP-France-2011_9798";}
|
||
|
||
$titr = explode(':', $exif[13]);
|
||
//echo count($titr) . "<br>";
|
||
|
||
if (count($titr) == 1) {
|
||
//print_r($titr);
|
||
//$titr[0]
|
||
$meta['image_meta']['title'] = utf8_encode($titr[0]);
|
||
}
|
||
else {
|
||
$titre = explode('"', end($titr));
|
||
//print_r($titre);
|
||
//$titre[1]
|
||
$meta['image_meta']['title'] = utf8_encode($titre[1]);
|
||
}
|
||
/*
|
||
echo "titr: ";
|
||
print_r($titr);
|
||
echo "<br>";
|
||
|
||
$titre = explode('"', end($titr));
|
||
print_r($titre);
|
||
|
||
foreach ($titr as $var) {
|
||
echo "<i>" . $var . "</i><br>";
|
||
}
|
||
|
||
*/
|
||
//$meta['image_meta']['title'] = utf8_encode($titre[1]);
|
||
}
|
||
else $meta['image_meta']['title'] = "";
|
||
|
||
//echo "<br><br>";
|
||
$meta['image_meta']['file'] = $image;
|
||
|
||
//preprint($meta['image_meta']);
|
||
|
||
/*
|
||
[camera] => Canon EOS-1D Mark IV
|
||
[created_timestamp] => 2014:10:21 14:42:26
|
||
[shutter_speed] => 1/80 sec
|
||
[aperture] => f/9
|
||
[iso] => 320
|
||
[focal_length] => 17 mm
|
||
[latitude] => 44,381861666667
|
||
[latitude_ref] => N
|
||
[longitude] => 4,4162216666667
|
||
[longitude_ref] => E
|
||
[altitude] => 104,1771m
|
||
[altitude_ref] =>
|
||
[description] =>
|
||
[title] =>
|
||
*/
|
||
return $meta;
|
||
}
|
||
|
||
function Getfloat($str) {
|
||
if(strstr($str, ",")) {
|
||
$str = str_replace(".", "", $str); // replace dots (thousand seps) with blancs
|
||
$str = str_replace(",", ".", $str); // replace ',' with '.'
|
||
}
|
||
|
||
if(preg_match("#([0-9\.]+)#", $str, $match)) { // search for number that may contain '.'
|
||
return floatval($match[0]);
|
||
} else {
|
||
return floatval($str); // take some last chances with floatval
|
||
}
|
||
}
|
||
|
||
/* Crée le cadre Afficher les exifs (Zenphoto)
|
||
loop-single.php:151
|
||
*/
|
||
|
||
function ListeExifZP($meta){
|
||
$before_item = '<li>';
|
||
$after_item = '</li>';
|
||
$sep = ': ';
|
||
$zoom = '11';
|
||
$exif_list = "";
|
||
$latitude = "";
|
||
$longitude = "";
|
||
$gm_lat = "";
|
||
$gm_lng = "";
|
||
|
||
if (!empty($meta['image_meta']['latitude']))
|
||
$latitude = $meta['image_meta']['latitude'];
|
||
if (!empty($meta['image_meta']['longitude']))
|
||
$longitude = $meta['image_meta']['longitude'];
|
||
if (!empty($meta['image_meta']['latitude_ref']))
|
||
$lat_ref = $meta['image_meta']['latitude_ref'];
|
||
if (!empty($meta['image_meta']['longitude_ref']))
|
||
$lng_ref = $meta['image_meta']['longitude_ref'];
|
||
|
||
// Aperture
|
||
if (!empty($meta['image_meta']['aperture']))
|
||
$exif_list .= $before_item . __('Aperture', 'twentyten-child') . $sep . str_replace(',', '.', $meta['image_meta']['aperture']) . $after_item;
|
||
|
||
// Shutter speed
|
||
if (!empty($meta['image_meta']['shutter_speed']))
|
||
$exif_list .= $before_item . __('Shutter speed', 'twentyten-child') . $sep . str_replace('sec', 's', $meta['image_meta']['shutter_speed']) . $after_item;
|
||
|
||
// Focal length
|
||
if (!empty($meta['image_meta']['focal_length']))
|
||
$exif_list .= $before_item . __('Focal length', 'twentyten-child') . $sep . $meta['image_meta']['focal_length'] . $after_item;
|
||
// Camera
|
||
if (!empty($meta['image_meta']['camera']))
|
||
$exif_list .= $before_item . __('Camera', 'twentyten-child') . $sep . $meta['image_meta']['camera'] . $after_item;
|
||
// Creation time
|
||
if (!empty($meta['image_meta']['created_timestamp']))
|
||
/*
|
||
setlocale(LC_TIME, 'fr_FR');
|
||
echo $meta['image_meta']['created_timestamp'];
|
||
$dt = strftime("%e %B %Y", $meta['image_meta']['created_timestamp']);
|
||
$dt = mb_convert_encoding($dt, 'utf-8');
|
||
echo $dt;
|
||
*/
|
||
|
||
$pieces = explode(' ', $meta['image_meta']['created_timestamp']);
|
||
list($yy, $mm, $dd) = explode(':', $pieces[0]);
|
||
list($hh, $min, $ss) = explode(':', $pieces[1]);
|
||
$timestamp = mktime((int) $hh, (int) $min, (int) $ss, (int) $mm, (int) $dd, (int) $yy);
|
||
$ddate = date('d.m.Y à H:i',$timestamp);
|
||
|
||
$exif_list .= $before_item . __('Taken', 'twentyten-child') . $sep . $ddate . $after_item;
|
||
|
||
// Latitude and Longtitude
|
||
if (($latitude != "") && ($longitude != "")) {
|
||
|
||
if ($lat_ref == 'S') { $neg_lat = '-'; } else { $neg_lat = ''; }
|
||
if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; }
|
||
|
||
$gm_lat = $neg_lat . number_format(Getfloat($latitude), 6);
|
||
$gm_lng = $neg_lng . number_format(Getfloat($longitude), 6);
|
||
|
||
$geo_link = '<a href="http://maps.google.com/maps?q=' . $gm_lat . '+' . $gm_lng . '&z=11" title="' . __('See on Google Maps', 'twentyten-child') . '">';
|
||
$geo_link .= '<img src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" />';
|
||
$geo_link .= '</a>';
|
||
|
||
//affichage dans un cadre map caché
|
||
//$exif_list .= $before_item . '<a href="#carte" title="'. __('Display/hide on map', 'twentyten-child') . '" onclick="toggleExif(\'map_canvas' . $i . '\');"><img src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" /></a>' . $after_item;
|
||
$exif_list .= $before_item . $geo_link . $after_item;
|
||
}
|
||
// Titre du marker
|
||
if (!empty($meta['image_meta']['description'])) $title_marker = $meta['image_meta']['description'];
|
||
elseif (!empty($meta['image_meta']['title'])) $title_marker = $meta['image_meta']['title'];
|
||
//elseif (!empty($meta['image_meta']['file'])) $title_marker = $meta['image_meta']['file'];
|
||
|
||
return array($exif_list, $gm_lat, $gm_lng, $title_marker);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*
|
||
* 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);
|
||
|
||
function exif_content($content) {
|
||
if ( is_single() )
|
||
$content = $content . "exif";
|
||
return $content;
|
||
}
|
||
|
||
|
||
function replace_http( $original ) {
|
||
// use preg_replace() to replace http:// with https://
|
||
//$output = preg_replace( "^http:", "https:", $original );
|
||
|
||
$output = preg_replace( "/^http:/i", "https:", $original );
|
||
|
||
return $output;
|
||
}
|
||
|
||
add_filter( 'the_content', 'replace_http' );
|
||
*/
|
||
?>
|