Page ce mois-ci (pagination ajax 1)
https://www.sanwebe.com/2013/03/ajax-pagination-with-jquery-php
This commit is contained in:
199
functions.php
199
functions.php
@@ -68,6 +68,23 @@ function RelativeTime() {
|
||||
}
|
||||
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
function preprint($s, $return=false) {
|
||||
$x = "<pre>";
|
||||
$x .= print_r($s, 1);
|
||||
@@ -76,4 +93,186 @@ function preprint($s, $return=false) {
|
||||
else print $x;
|
||||
}
|
||||
|
||||
|
||||
/* photo du mois */
|
||||
|
||||
function exif_date($date,$apn) {
|
||||
//'Model' => string 'Canon EOS 50D' (length=13)
|
||||
//50D: 'DateTimeOriginal' => string '2009:12:05 12:42:33' (length=19)
|
||||
|
||||
//'Model' => string 'Canon EOS 7D' (length=12)
|
||||
//7D: DateTimeOriginal' => string '2010-02-20T15:07:05.24+01:00' (length=28)
|
||||
|
||||
// -> 50D
|
||||
if (!preg_match("/7D/", $apn)) {
|
||||
$pieces = explode(' ', $date);
|
||||
list($yy, $mm, $dd) = explode(':', $pieces[0]);
|
||||
list($hh, $min, $ss) = explode(':', $pieces[1]);
|
||||
}
|
||||
// 7D
|
||||
else {
|
||||
$pieces = explode('T', $date);
|
||||
list($yy, $mm, $dd) = explode('-', $pieces[0]);
|
||||
$pieces_h = explode('.', $pieces[1]);
|
||||
list($hh, $min, $ss) = explode(':', $pieces_h[0]);
|
||||
}
|
||||
$timestamp = mktime((int) $hh, (int) $min, (int) $ss, (int) $mm, (int) $dd, (int) $yy, '-1');
|
||||
$date = date('d.m.Y à H:i',$timestamp);
|
||||
return $date;
|
||||
}
|
||||
function mois2 ($mois) {
|
||||
switch ($mois)
|
||||
{
|
||||
case 00:
|
||||
$mois = "00";
|
||||
break;
|
||||
case 1:
|
||||
$mois = __('January','CreatorThemeRes-child');
|
||||
break;
|
||||
case 2:
|
||||
$mois = __('February','CreatorThemeRes-child');
|
||||
break;
|
||||
case 3:
|
||||
$mois = __('March','CreatorThemeRes-child');
|
||||
break;
|
||||
case 4:
|
||||
$mois = __('April','CreatorThemeRes-child');
|
||||
break;
|
||||
case 5:
|
||||
$mois = __('May','CreatorThemeRes-child');
|
||||
break;
|
||||
case 6:
|
||||
$mois = __('June','CreatorThemeRes-child');
|
||||
break;
|
||||
case 7:
|
||||
$mois = __('July','CreatorThemeRes-child');
|
||||
break;
|
||||
case 8:
|
||||
$mois = __('August','CreatorThemeRes-child');
|
||||
break;
|
||||
case 9:
|
||||
$mois = __('September','CreatorThemeRes-child');
|
||||
break;
|
||||
case 10:
|
||||
$mois = __('October','CreatorThemeRes-child');
|
||||
break;
|
||||
case 11:
|
||||
$mois = __('November','CreatorThemeRes-child');
|
||||
break;
|
||||
case 12:
|
||||
$mois = __('December','CreatorThemeRes-child');
|
||||
break;
|
||||
}
|
||||
return $mois;
|
||||
}
|
||||
|
||||
function display ($filename,$album) {
|
||||
$display = '<div class="album">'.
|
||||
'<div class="thumb">' .
|
||||
'<a href="../zenphoto/albums/'.$album.'/'.$filename.'" title="'.date_archive($filename).'" class="wraptocenter swipebox" />'.
|
||||
'<img src="../zenphoto/zp-core/i.php?a='.$album.'&i='.$filename.'&s=180" class="img_archive" />'.
|
||||
'</a>'.
|
||||
'</div>'.
|
||||
'<div class="albumdesc">'.
|
||||
'<a href="../zenphoto/index.php?album='.$album.'&image='.$filename.'" title= "'.date_archive($filename).'" class="" />'.
|
||||
'<span class="exif">'.date_archive($filename).'</span>'.
|
||||
'</a></div>'.
|
||||
'</div>';
|
||||
return $display;
|
||||
}
|
||||
|
||||
function displayRetina ($filename,$album) {
|
||||
// 6_2012.jpg
|
||||
// 4_2014_180_thumb.jpg 4_2014_360_thumb.jpg
|
||||
$path = "../zenphoto/cache/" . $album . "/";
|
||||
$file = explode(".", $filename);
|
||||
|
||||
//$a = $path . $filename;
|
||||
//echo $a. "<br>";
|
||||
|
||||
$file_sd = $path . $file[0] . "_180_thumb.jpg";
|
||||
$file_hd = $path . $file[0] . "_360_thumb.jpg";
|
||||
/*
|
||||
$file_sd = $path . $file[0] . "_180_watermark.jpg";
|
||||
$file_hd = $path . $file[0] . "_360_watermark.jpg";
|
||||
*/
|
||||
//
|
||||
$th_sd = false;
|
||||
$th_hd = false;
|
||||
|
||||
if (file_exists($file_sd)) {
|
||||
$th_sd = true;
|
||||
$size_sd = getimagesize($file_sd, $info);
|
||||
$thumb['sd'] = array(
|
||||
'url' => "../" . $file_sd,
|
||||
'width' => $size_sd[0],
|
||||
'height' => $size_sd[1]
|
||||
);
|
||||
}
|
||||
if (file_exists($file_hd)) {
|
||||
$th_hd = true;
|
||||
$size_hd = getimagesize($file_hd, $info);
|
||||
$thumb['hd'] = array(
|
||||
'url' => "../" . $file_hd,
|
||||
'width' => $size_hd[0],
|
||||
'height' => $size_hd[1]
|
||||
);
|
||||
}
|
||||
//preprint($thumb);
|
||||
|
||||
if (($th_sd == true) && ($th_hd == true)) {
|
||||
$standard = $thumb['sd']['url'] . ', ' . $thumb['hd']['url'] . ' 2x';
|
||||
}
|
||||
elseif ($th_sd == true) {
|
||||
$standard = $thumb['sd']['url'];
|
||||
}
|
||||
elseif ($th_hd == true) {
|
||||
$standard = $thumb['hd']['url'] . ' 2x';
|
||||
}
|
||||
|
||||
$display = '<div class="album">';
|
||||
$display .= '<div class="thumb">';
|
||||
$display .= '<a href="../../zenphoto/albums/'.$album.'/'.$filename.'" title="'.date_archive($filename).'" class="wraptocenter swipebox" />';
|
||||
|
||||
$display .= '<picture data-picture data-alt="">';
|
||||
$display .= '<!--[if IE 9]><video style="display: none;"><![endif]-->';
|
||||
$display .= '<source class="image_standard" srcset="' . $standard . '">';
|
||||
|
||||
//$display .= '<img src="../zenphoto/zp-core/i.php?a='.$album.'&i='.$filename.'&s=180" class="img_archive" />';
|
||||
|
||||
$display .= '<!--[if IE 9]></video><![endif]-->';
|
||||
$display .= '<img srcset="' . $thumb['sd']['url'] . '" width="' . $thumb['sd']['width'] . '" height="' . $thumb['sd']['height'] . '"alt="">';
|
||||
$display .= '</picture>';
|
||||
|
||||
$display .= '</a>';
|
||||
$display .= '</div>';
|
||||
$display .= '<div class="albumdesc">';
|
||||
$display .= '<a href="../../zenphoto/index.php?album='.$album.'&image='.$filename.'" title= "'.date_archive($filename).'" class="" />';
|
||||
$display .= '<span class="exif">'.date_archive($filename).'</span>';
|
||||
$display .= '</a></div>';
|
||||
$display .= '</div>';
|
||||
return $display;
|
||||
}
|
||||
|
||||
function get_image_title ($photo) {
|
||||
$photo = '../zenphoto/albums/photos-du-mois/' . $photo;
|
||||
$size = getimagesize($photo, $info);
|
||||
if (isset($info["APP13"])) {
|
||||
$iptc = iptcparse($info["APP13"]);
|
||||
//print_r($iptc);
|
||||
$caption = isset($iptc['2#120'][0]);
|
||||
$graphic_name = isset($iptc['2#005'][0]);
|
||||
}
|
||||
return $caption;
|
||||
}
|
||||
|
||||
function date_archive ($chaine) {
|
||||
$pieces = explode(".", $chaine);
|
||||
$b = explode("_", $pieces[0]);
|
||||
$mois = $b[0];
|
||||
$an = $b[1];
|
||||
$chaine = mois2($mois) . ' '. $an;
|
||||
return $chaine;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user