diff --git a/htdocs/fourn/product/fiche.php b/htdocs/fourn/product/fiche.php
index dda521e71bc..892138ce82e 100644
--- a/htdocs/fourn/product/fiche.php
+++ b/htdocs/fourn/product/fiche.php
@@ -371,7 +371,7 @@ else
if ($product->type == 1) $nblignefour++;
print '
';
- $product->show_photo($conf->produit->dir_output,1);
+ $product->show_photos($conf->produit->dir_output,1,1,0);
print ' | ';
// Description
diff --git a/htdocs/fourn/product/fourn.php b/htdocs/fourn/product/fourn.php
index e92a2c1932d..eeb449fddd5 100644
--- a/htdocs/fourn/product/fourn.php
+++ b/htdocs/fourn/product/fourn.php
@@ -110,7 +110,7 @@ if ($_GET["id"])
print '| '.$langs->trans("InternalRef").' | '.$product->ref.' | ';
print '';
- $product->show_photo($conf->produit->dir_output);
+ $product->show_photos($conf->produit->dir_output,1,1,0);
print ' |
';
print "";
diff --git a/htdocs/fourn/product/photos.php b/htdocs/fourn/product/photos.php
index efb14a23974..b6a226de1da 100644
--- a/htdocs/fourn/product/photos.php
+++ b/htdocs/fourn/product/photos.php
@@ -139,9 +139,61 @@ if ($_GET["id"])
}
- // Affiche photos
- $nbphoto=$product->show_photos($conf->produit->dir_output,1);
- if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."
";
+ // Affiche photos
+ if ($_GET["action"] != 'ajout_photo')
+ {
+ $nbphoto=0;
+ $nbbyrow=5;
+
+ $pdir = get_exdir($product->id) . $product->id ."/photos/";
+ $dir = $conf->produit->dir_output . '/'. $pdir;
+
+ print '
';
+
+ foreach ($product->liste_photos($dir) as $obj)
+ {
+ $nbphoto++;
+
+// if ($nbbyrow && $nbphoto == 1) print '';
+ }
+
+ print '
';
+ }
+
+
print "\n";
}
diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index 1f693d1527f..593fc9a7f78 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -1963,18 +1963,6 @@ function get_each_prod()
}
- /**
- * \brief Affiche la première photo du produit
- * \param sdir Répertoire à scanner
- * \param size 0=taille origine, 1 taille vignette
- * \return int Nombre de photos affichées
- */
- function show_photo($sdir,$size=0)
- {
- return $this->show_photos($sdir,$size,1,0);
- }
-
-
/**
* \brief Affiche toutes les photos du produit (nbmax maximum)
* \param sdir Répertoire à scanner
@@ -1982,7 +1970,6 @@ function get_each_prod()
* \param nbmax Nombre maximum de photos (0=pas de max)
* \param nbbyrow Nombre vignettes par ligne (si mode vignette)
* \return int Nombre de photos affichées
- * \todo A virer, seule la methode avec size=0 sert encore.
*/
function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5)
{
@@ -2059,50 +2046,53 @@ function get_each_prod()
return $nbphoto;
}
- /**
- * \brief Retourne tableau de toutes les photos du produit
- * \param dir Répertoire à scanner
- * \param nbmax Nombre maximum de photos (0=pas de max)
- * \return array Tableau de photos
- */
- function liste_photos($dir,$nbmax=0)
- {
- $nbphoto=0;
- $tabobj=array();
-
- if (file_exists($dir))
- {
- $handle=opendir($dir);
-
- while (($file = readdir($handle)) != false)
- {
- if (is_file($dir.$file))
- {
- $nbphoto++;
- $photo = $file;
+ /**
+ * \brief Retourne tableau de toutes les photos du produit
+ * \param dir Répertoire à scanner
+ * \param nbmax Nombre maximum de photos (0=pas de max)
+ * \return array Tableau de photos
+ */
+ function liste_photos($dir,$nbmax=0)
+ {
+ $nbphoto=0;
+ $tabobj=array();
+
+ if (file_exists($dir))
+ {
+ $handle=opendir($dir);
+
+ while (($file = readdir($handle)) != false)
+ {
+ if (is_file($dir.$file))
+ {
+ $nbphoto++;
+ $photo = $file;
- // 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];
- }
-
- // Objet
- $obj->photo=$photo;
- if ($photo_vignette && is_file($photo_vignette)) $obj->photo_vignette=$photo_vignette;
- else $obj->photo_vignette="";
- $tabobj[$nbphoto-1]=$obj;
+ // 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];
+ }
+
+ // Objet
+ $obj=array();
+ $obj['photo']=$photo;
+ if ($photo_vignette && is_file($photo_vignette)) $obj['photo_vignette']=$photo_vignette;
+ else $obj['photo_vignette']="";
- // On continue ou on arrete de boucler ?
- if ($nbmax && $nbphoto >= $nbmax) break;
- }
- }
-
- closedir($handle);
- }
-
- return $tabobj;
- }
+ $tabobj[$nbphoto-1]=$obj;
+
+ // On continue ou on arrete de boucler ?
+ if ($nbmax && $nbphoto >= $nbmax) break;
+ }
+ }
+
+ closedir($handle);
+ }
+
+ return $tabobj;
+ }
/**
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 75000cccb21..41521d76c68 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -616,7 +616,7 @@ if ($_GET["id"] || $_GET["ref"])
{
// Photo
print '';
- $nbphoto=$product->show_photo($conf->produit->dir_output,1);
+ $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
print ' | ';
}
diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php
index 5d1d58410f1..bf5ce99d84f 100644
--- a/htdocs/product/photos.php
+++ b/htdocs/product/photos.php
@@ -262,8 +262,8 @@ if ($_GET["id"] || $_GET["ref"])
$dir = $conf->produit->dir_output . '/'. $pdir;
print '
';
-
- foreach ($product->liste_photos($dir) as $obj)
+
+ foreach ($product->liste_photos($dir) as $key => $obj)
{
$nbphoto++;
@@ -272,11 +272,11 @@ if ($_GET["id"] || $_GET["ref"])
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '';
if ($nbbyrow) print '';
- print '';
+ print '';
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
- if ($obj->photo_vignette) $filename=$obj->photo_vignette;
- else $filename=$obj->photo;
+ if ($obj['photo_vignette']) $filename=$obj['photo_vignette'];
+ else $filename=$obj['photo'];
print ' ';
print '';
diff --git a/htdocs/product/sousproduits/fiche.php b/htdocs/product/sousproduits/fiche.php
index ea24f8168aa..6d2e4550298 100644
--- a/htdocs/product/sousproduits/fiche.php
+++ b/htdocs/product/sousproduits/fiche.php
@@ -267,7 +267,7 @@ if ($id || $ref)
{
// Photo
print ' | ';
- $nbphoto=$product->show_photo($conf->produit->dir_output,1);
+ $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
print ' | ';
}
@@ -331,7 +331,7 @@ if ($id || $ref)
{
// Photo
print '';
- $nbphoto=$product->show_photo($conf->produit->dir_output,1);
+ $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
print ' | ';
}