New: Les photos sont affiches en taille vignette.

This commit is contained in:
Laurent Destailleur
2005-04-02 14:38:54 +00:00
parent f53befd5c5
commit 3d881cecd2
5 changed files with 27 additions and 58 deletions

View File

@@ -52,4 +52,5 @@ AddToOtherProposals=Add to other proposals
AddToMyBills=Add to my bills
AddToOtherBills=Add to other bills
CorrectStock=Correct stock
ListOfStockMovements=List of stock movements
ListOfStockMovements=List of stock movements
NoPhotoYet=No pictures available yet

View File

@@ -56,4 +56,5 @@ AddToMyBills=Ajouter
AddToOtherBills=Ajouter aux autres factures
CorrectStock=Corriger stock
AddPhoto=Ajouter une photo
ListOfStockMovements=Liste des mouvements de stock
ListOfStockMovements=Liste des mouvements de stock
NoPhotoYet=Pas de photos disponibles pour l'instant

View File

@@ -880,62 +880,28 @@ class Product
* \brief Affiche la premi<6D>re photo du produit
* \param sdir R<>pertoire <20> scanner
* \param size 0=taille origine, 1 taille vignette
* \return int Nombre de photos affich<63>es
*/
function show_photo($sdir,$size=0)
{
$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 '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'" alt="Taille origine" target="_blank">';
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
if ($photo_vignette && is_file($photo_vignette)) {
print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo_vignette).'">';
}
else {
print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'">';
}
print '</a>';
}
if ($size == 0)
print '<img border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'">';
break;
}
}
}
return $this->show_photos($sdir,$size,1);
}
/**
* \brief Affiche toutes les photos du produit
* \param sdir R<>pertoire <20> scanner
* \param size 0=taille origine, 1 taille vignette
* \brief Affiche toutes les photos du produit (nbmax maximum)
* \param sdir R<EFBFBD>pertoire <20> scanner
* \param size 0=taille origine, 1 taille vignette
* \param nbmax Nombre maximum de photos
* \return int Nombre de photos affich<63>es
*/
function show_photos($sdir,$size=0)
function show_photos($sdir,$size=0,$nbmax=0)
{
$nbphoto=0;
$pdir = get_exdir($this->id) . $this->id ."/photos/";
$dir = $sdir . '/'. $pdir;
if ( file_exists($dir))
if (file_exists($dir))
{
$handle=opendir($dir);
@@ -946,6 +912,8 @@ class Product
if ($photo)
{
$nbphoto++;
if ($size == 1) {
// On determine nom du fichier vignette
$photo_vignette='';
@@ -968,10 +936,14 @@ class Product
if ($size == 0)
print '<img border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'">';
print '&nbsp;';
// On continue ou on arrete de boucler ?
if ($nbmax && $nbphoto >= $nbmax) break;
else print '&nbsp;';
}
}
}
return $nbphoto;
}
}

View File

@@ -699,7 +699,7 @@ print "\n</div>\n";
*/
if ($_GET["id"] && $_GET["action"]=='')
{
print $product->show_photo($conf->produit->dir_output,1);
$nbphoto=$product->show_photo($conf->produit->dir_output,1);
}
if ($_GET["id"] && $_GET["action"] == '' && $product->envente)

View File

@@ -141,16 +141,11 @@ if ($_GET["id"])
print "</table><br>\n";
/*
* Photo
*
*/
if ($_GET["id"] && $_GET["action"]=='')
{
print $product->show_photos($conf->produit->dir_output,1);
}
// Affiche photos
$nbphoto=$product->show_photos($conf->produit->dir_output,1);
if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>";
print "<br></div>\n";
print "</div>\n";
}
}
else