From 241c02c8cbd1940f8d4c12a183dbac08dafdbad0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2005 14:26:04 +0000 Subject: [PATCH] =?UTF-8?q?New:=20Les=20photos=20sont=20affich=E9es=20en?= =?UTF-8?q?=20taille=20vignette.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product.class.php | 117 ++++++++++++++++++++++++++------------ htdocs/product/fiche.php | 2 +- htdocs/product/photos.php | 2 +- 3 files changed, 83 insertions(+), 38 deletions(-) diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 8a686c54042..90398f972a7 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -877,56 +877,101 @@ class Product } /** - * - * + * \brief Affiche la première photo du produit + * \param sdir Répertoire à scanner + * \param size 0=taille origine, 1 taille vignette */ - function show_photo($sdir) + function show_photo($sdir,$size=0) { - $photo = ''; $pdir = get_exdir($this->id) . $this->id ."/photos/"; $dir = $sdir . '/'. $pdir; - + if ( file_exists($dir)) - { - $handle=opendir($dir); - - while (($file = readdir($handle))!==false) - { - if (is_file($dir.$file)) - { - $photo = $file; - } - } - - if (strlen($photo)) - { - print ''; - } - } + { + $handle=opendir($dir); + + while (($file = readdir($handle))!==false) + { + $photo=''; + if (is_file($dir.$file)) $photo = $file; + + if ($photo) + { + if ($size == 1) { + // On determine nom du fichier vignette + $photo_vignette=''; + if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs)) { + $photo_vignette=eregi_replace($regs[0],'',$photo)."_small".$regs[0]; + } + print ''; + + // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine + if ($photo_vignette && is_file($photo_vignette)) { + print ''; + } + else { + print ''; + } + + print ''; + } + + if ($size == 0) + print ''; + + break; + } + } + } } /** - * Je sais c'est sale mais le besoin est urgent ;-) - * + * \brief Affiche toutes les photos du produit + * \param sdir Répertoire à scanner + * \param size 0=taille origine, 1 taille vignette */ - function show_photos($sdir) + function show_photos($sdir,$size=0) { - $photo = ''; $pdir = get_exdir($this->id) . $this->id ."/photos/"; $dir = $sdir . '/'. $pdir; + + if ( file_exists($dir)) + { + $handle=opendir($dir); + + while (($file = readdir($handle))!==false) + { + $photo=''; + if (is_file($dir.$file)) $photo = $file; + + if ($photo) + { + if ($size == 1) { + // On determine nom du fichier vignette + $photo_vignette=''; + if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs)) { + $photo_vignette=eregi_replace($regs[0],'',$photo)."_small".$regs[0]; + } + print ''; - $handle=opendir($dir); - - while (($file = readdir($handle))!==false) - { - if (is_file($dir.$file)) - { - $photo = $file; - print '
'; - } - } - + // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine + if ($photo_vignette && is_file($photo_vignette)) { + print ''; + } + else { + print ''; + } + print '
'; + } + + if ($size == 0) + print ''; + + print ' '; + } + } + } } } diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 9c5aa6d50cc..f2fcf49ca1d 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -699,7 +699,7 @@ print "\n\n"; */ if ($_GET["id"] && $_GET["action"]=='') { - print $product->show_photo($conf->produit->dir_output); + print $product->show_photo($conf->produit->dir_output,1); } if ($_GET["id"] && $_GET["action"] == '' && $product->envente) diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 20125fc5f39..8b072142b01 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -147,7 +147,7 @@ if ($_GET["id"]) */ if ($_GET["id"] && $_GET["action"]=='') { - print $product->show_photos($conf->produit->dir_output); + print $product->show_photos($conf->produit->dir_output,1); } print "
\n";