New: Les photos sont affiches en taille vignette.
This commit is contained in:
parent
f53befd5c5
commit
3d881cecd2
@ -52,4 +52,5 @@ AddToOtherProposals=Add to other proposals
|
|||||||
AddToMyBills=Add to my bills
|
AddToMyBills=Add to my bills
|
||||||
AddToOtherBills=Add to other bills
|
AddToOtherBills=Add to other bills
|
||||||
CorrectStock=Correct stock
|
CorrectStock=Correct stock
|
||||||
ListOfStockMovements=List of stock movements
|
ListOfStockMovements=List of stock movements
|
||||||
|
NoPhotoYet=No pictures available yet
|
||||||
@ -56,4 +56,5 @@ AddToMyBills=Ajouter
|
|||||||
AddToOtherBills=Ajouter aux autres factures
|
AddToOtherBills=Ajouter aux autres factures
|
||||||
CorrectStock=Corriger stock
|
CorrectStock=Corriger stock
|
||||||
AddPhoto=Ajouter une photo
|
AddPhoto=Ajouter une photo
|
||||||
ListOfStockMovements=Liste des mouvements de stock
|
ListOfStockMovements=Liste des mouvements de stock
|
||||||
|
NoPhotoYet=Pas de photos disponibles pour l'instant
|
||||||
@ -880,62 +880,28 @@ class Product
|
|||||||
* \brief Affiche la première photo du produit
|
* \brief Affiche la première photo du produit
|
||||||
* \param sdir Répertoire à scanner
|
* \param sdir Répertoire à scanner
|
||||||
* \param size 0=taille origine, 1 taille vignette
|
* \param size 0=taille origine, 1 taille vignette
|
||||||
|
* \return int Nombre de photos affichées
|
||||||
*/
|
*/
|
||||||
function show_photo($sdir,$size=0)
|
function show_photo($sdir,$size=0)
|
||||||
{
|
{
|
||||||
$pdir = get_exdir($this->id) . $this->id ."/photos/";
|
return $this->show_photos($sdir,$size,1);
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Affiche toutes les photos du produit
|
* \brief Affiche toutes les photos du produit (nbmax maximum)
|
||||||
* \param sdir Répertoire à scanner
|
* \param sdir Répertoire à scanner
|
||||||
* \param size 0=taille origine, 1 taille vignette
|
* \param size 0=taille origine, 1 taille vignette
|
||||||
|
* \param nbmax Nombre maximum de photos
|
||||||
|
* \return int Nombre de photos affiché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/";
|
$pdir = get_exdir($this->id) . $this->id ."/photos/";
|
||||||
$dir = $sdir . '/'. $pdir;
|
$dir = $sdir . '/'. $pdir;
|
||||||
|
|
||||||
if ( file_exists($dir))
|
if (file_exists($dir))
|
||||||
{
|
{
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
|
||||||
@ -946,6 +912,8 @@ class Product
|
|||||||
|
|
||||||
if ($photo)
|
if ($photo)
|
||||||
{
|
{
|
||||||
|
$nbphoto++;
|
||||||
|
|
||||||
if ($size == 1) {
|
if ($size == 1) {
|
||||||
// On determine nom du fichier vignette
|
// On determine nom du fichier vignette
|
||||||
$photo_vignette='';
|
$photo_vignette='';
|
||||||
@ -968,10 +936,14 @@ class Product
|
|||||||
if ($size == 0)
|
if ($size == 0)
|
||||||
print '<img border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'">';
|
print '<img border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$photo).'">';
|
||||||
|
|
||||||
print ' ';
|
// On continue ou on arrete de boucler ?
|
||||||
|
if ($nbmax && $nbphoto >= $nbmax) break;
|
||||||
|
else print ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $nbphoto;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -699,7 +699,7 @@ print "\n</div>\n";
|
|||||||
*/
|
*/
|
||||||
if ($_GET["id"] && $_GET["action"]=='')
|
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)
|
if ($_GET["id"] && $_GET["action"] == '' && $product->envente)
|
||||||
|
|||||||
@ -141,16 +141,11 @@ if ($_GET["id"])
|
|||||||
|
|
||||||
print "</table><br>\n";
|
print "</table><br>\n";
|
||||||
|
|
||||||
/*
|
// Affiche photos
|
||||||
* Photo
|
$nbphoto=$product->show_photos($conf->produit->dir_output,1);
|
||||||
*
|
if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>";
|
||||||
*/
|
|
||||||
if ($_GET["id"] && $_GET["action"]=='')
|
|
||||||
{
|
|
||||||
print $product->show_photos($conf->produit->dir_output,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<br></div>\n";
|
print "</div>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user