Qual: Removed errors reported by PHPCodeSniffer

This commit is contained in:
Laurent Destailleur 2011-08-28 02:18:20 +00:00
parent fbe292a439
commit 482a205936
8 changed files with 278 additions and 259 deletions

View File

@ -322,12 +322,12 @@ else if ($_GET["id"] || $_GET["ref"])
print '</tr>';
// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.'</td><td>';
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
print $product->getLibStatut(2,0);
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.'</td><td>';
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>';
print $product->getLibStatut(2,1);
print '</td></tr>';
@ -425,7 +425,12 @@ else if ($_GET["id"] || $_GET["ref"])
/**
* Fonction Barre d'actions
* Function to output a HTML select for a category
*
* @param DoliDb $db Database handler
* @param Object $object Object we want to see categories it can be classified into
* @param int $typeid Type of category (0, 1, 2, 3)
* @return int 0
*/
function formCategory($db,$object,$typeid)
{
@ -468,7 +473,7 @@ function formCategory($db,$object,$typeid)
$c = new Categorie($db);
$cats = $c->containing($object->id,$typeid);
if (sizeof($cats) > 0)
if (count($cats) > 0)
{
if ($typeid == 0) $title=$langs->trans("ProductIsInCategories");
if ($typeid == 1) $title=$langs->trans("CompanyIsInSuppliersCategories");
@ -517,7 +522,7 @@ function formCategory($db,$object,$typeid)
}
print "</table>\n";
}
else if($cats < 0)
else if ($cats < 0)
{
print $langs->trans("ErrorUnknown");
}
@ -530,6 +535,7 @@ function formCategory($db,$object,$typeid)
print $title;
print "<br/>";
}
return 0;
}
$db->close();

View File

@ -38,7 +38,7 @@ class Categorie
{
var $error;
var $db;
var $element='category';
var $table_element='category';
@ -131,7 +131,7 @@ class Categorie
// Clean parameters
if (empty($this->visible)) $this->visible=0;
$this->parentId = ($this->id_mere) != "" ? intval($this->id_mere) : 0;
$this->parentId = ($this->id_mere) != "" ? intval($this->id_mere) : 0;
if ($this->already_exists())
{
@ -217,8 +217,8 @@ class Categorie
$this->error=$langs->trans("ImpossibleUpdateCat");
$this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel");
return -1;
}
}
$this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'categorie_association';
@ -500,10 +500,11 @@ class Categorie
}
/**
* \brief Return list of contents of a category
* \param field Field name for select in table. Full field name will be fk_field.
* \param class PHP Class of object to store entity
* \param table Table name for select in table. Full table name will be PREFIX_categorie_table.
* Return list of contents of a category
*
* @param field Field name for select in table. Full field name will be fk_field.
* @param class PHP Class of object to store entity
* @param table Table name for select in table. Full table name will be PREFIX_categorie_table.
*/
function get_type($field,$classname,$table='')
{
@ -565,15 +566,18 @@ class Categorie
/**
* retourne la description d'une categorie
* Return category description
*
* @param $cate
* @return string Description
*/
function get_desc ($cate)
{
$sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie ";
$sql .= "WHERE rowid = '".$cate."'";
$res = $this->db->query ($sql);
$n = $this->db->fetch_array ($res);
$res = $this->db->query($sql);
$n = $this->db->fetch_array($res);
return ($n[0]);
}
@ -610,7 +614,7 @@ class Categorie
function get_full_arbo($type,$markafterid=0)
{
global $conf;
$this->cats = array();
// Charge tableau des meres
@ -839,7 +843,7 @@ class Categorie
$sql.= " JOIN ".MAIN_DB_PREFIX."categorie_association as ca";
$sql.= " ON c.rowid=ca.fk_categorie_fille";
$sql.= " WHERE ca.fk_categorie_mere=".$this->id_mere;
$sql.= " AND c.label='".$this->db->escape($this->label)."'";
$sql.= " AND c.label='".$this->db->escape($this->label)."'";
}
else // mother_id undefined (so it's root)
{
@ -852,14 +856,14 @@ class Categorie
$sql.= " JOIN ".MAIN_DB_PREFIX."categorie_association as ca";
$sql.= " ON c.rowid!=ca.fk_categorie_fille";
$sql.= " WHERE c.type=".$this->type;
$sql.= " AND c.label='".$this->db->escape($this->label)."'";
$sql.= " AND c.label='".$this->db->escape($this->label)."'";
}
dol_syslog("Categorie::already_exists sql=".$sql);
$res = $this->db->query($sql);
if ($res)
{
{
if($this->db->num_rows($resql) > 0) // Checking for empty resql
{
{
$obj = $this->db->fetch_array($res);
/* If object called create, obj cannot have is id.
* If object called update, he mustn't have the same label as an other category for this mother.
@ -867,7 +871,7 @@ class Categorie
* update may be for label.
*/
if($obj[0] > 0 && $obj[0] != $this->id) return 1;
}
}
return 0;
}
else
@ -961,7 +965,7 @@ class Categorie
/**
* print_primary_way() affiche le chemin le plus court pour se rendre a un produit
*/
function print_primary_way($id, $sep= " &gt;&gt; ", $url, $type="")
function print_primary_way($id, $sep= " &gt;&gt; ", $url="", $type="")
{
$primary_way = Array();
$way = $this->get_primary_way($id,$type);
@ -1073,8 +1077,14 @@ class Categorie
/**
* \brief Retourne les categories dont l'id ou le nom correspond
* ajoute des wildcards au nom sauf si $exact = true
* Retourne les categories dont l'id ou le nom correspond
* ajoute des wildcards au nom sauf si $exact = true
*
* @param id
* @param nom
* @param type
* @param exact
* @return int or array
*/
function rechercher($id, $nom, $type, $exact = false)
{
@ -1115,11 +1125,12 @@ class Categorie
}
/**
* \brief Return name and link of category (with picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \param option Sur quoi pointe le lien ('', 'xyz')
* \param maxlength Max length of text
* \return string Chaine avec URL
* Return name and link of category (with picto)
*
* @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param option Sur quoi pointe le lien ('', 'xyz')
* @param maxlength Max length of text
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='',$maxlength=0)
{
@ -1142,11 +1153,12 @@ class Categorie
/**
* \brief Deplace fichier uploade sous le nom $files dans le repertoire sdir
* \param sdir Repertoire destination finale
* \param $file Nom du fichier uploade
* \param maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
* \param maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
* Deplace fichier uploade sous le nom $files dans le repertoire sdir
*
* @param sdir Repertoire destination finale
* @param $file Nom du fichier uploade
* @param maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
* @param maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
*/
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
{
@ -1194,10 +1206,11 @@ class Categorie
/**
* \brief Retourne tableau de toutes les photos de la categorie
* \param dir Repertoire a scanner
* \param nbmax Nombre maximum de photos (0=pas de max)
* \return array Tableau de photos
* Return tableau de toutes les photos de la categorie
*
* @param dir Repertoire a scanner
* @param nbmax Nombre maximum de photos (0=pas de max)
* @return array Tableau de photos
*/
function liste_photos($dir,$nbmax=0)
{

View File

@ -52,7 +52,7 @@ $result = restrictedArea($user, 'categorie', $id);
// Action mise a jour d'une categorie
if ($action == 'update' && $user->rights->categorie->creer)
{
$categorie = new Categorie ($db);
$categorie = new Categorie($db);
$result=$categorie->fetch($id);
$categorie->label = $_POST["nom"];
@ -112,7 +112,7 @@ if ($mesg)
print '</div>';
}
$categorie = new Categorie ($db, $id);
$categorie = new Categorie($db, $id);
$html = new Form($db);
print '<table class="notopnoleft" border="0" width="100%">';
@ -144,7 +144,7 @@ $doleditor->Create();
print '</td></tr>';
// Parent category
print '<tr><td>'.$langs->trans ("In").'</td><td>';
print '<tr><td>'.$langs->trans("In").'</td><td>';
print $html->select_all_categories($type,$categorie->id_mere,'catMere',64,$categorie->id);
print '</td></tr>';

View File

@ -215,7 +215,7 @@ if ($user->rights->categorie->creer)
print '</td></tr>';
// Parent category
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $html->select_all_categories($type,$catorigin);
print '</td></tr>';

View File

@ -69,7 +69,7 @@ print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("Search").'</td>';
print '</tr>';
print '<tr '.$bc[0].'><td>';
print $langs->trans("Name").':</td><td><input class="flat" type="text" size="20" name="catname" value="' . $_POST['catname'] . '"/></td><td><input type="submit" class="button" value="'.$langs->trans ("Search").'"></td></tr>';
print $langs->trans("Name").':</td><td><input class="flat" type="text" size="20" name="catname" value="' . $_POST['catname'] . '"/></td><td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
/*
// faire une rech dans une sous categorie uniquement
print '<tr '.$bc[0].'><td>';

View File

@ -28,47 +28,47 @@ require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
if (!$user->rights->categorie->lire) accessforbidden();
llxHeader ("","",$langs->trans("Categories"));
llxHeader("","",$langs->trans("Categories"));
print_fiche_titre ($langs->trans ("CatList"));
print_fiche_titre($langs->trans("CatList"));
print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td valign="top" width="30%" class="notopnoleft">';
$c = new Categorie ($db);
$cats = $c->get_all_categories ();
$c = new Categorie($db);
$cats = $c->get_all_categories();
if ($cats != -1)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("Type").'</td>';
print '</tr>';
$var=true;
foreach ($cats as $cat)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("Type").'</td>';
print '</tr>';
$var=true;
foreach ($cats as $cat)
{
$var = ! $var;
print "\t<tr ".$bc[$var].">\n";
print "\t\t<td><a href='viewcat.php?id=".$cat->id."'>".$cat->label."</a></td>\n";
print "\t\t<td>".dol_trunc($cat->description,36)."</td>\n";
print '<td align="right">';
if ($cat->type == 0) print $langs->trans("Product");
elseif ($cat->type == 1) print $langs->trans("Supplier");
elseif ($cat->type == 2) print $langs->trans("Customer");
else print $cat->type;
print "</td>\n";
print "\t</tr>\n";
$var = ! $var;
print "\t<tr ".$bc[$var].">\n";
print "\t\t<td><a href='viewcat.php?id=".$cat->id."'>".$cat->label."</a></td>\n";
print "\t\t<td>".dol_trunc($cat->description,36)."</td>\n";
print '<td align="right">';
if ($cat->type == 0) print $langs->trans("Product");
elseif ($cat->type == 1) print $langs->trans("Supplier");
elseif ($cat->type == 2) print $langs->trans("Customer");
else print $cat->type;
print "</td>\n";
print "\t</tr>\n";
}
print "</table>";
print "</table>";
}
else
{
dol_print_error();
dol_print_error();
}
print '</td></tr></table>';

View File

@ -43,8 +43,8 @@ $confirm=GETPOST('confirm');
if ($id == "")
{
dol_print_error('','Missing parameter id');
exit();
dol_print_error('','Missing parameter id');
exit();
}
// Security check
@ -58,22 +58,22 @@ $object = new Categorie($db);
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($id)
{
$result = $object->fetch($id);
if ($id)
{
$result = $object->fetch($id);
$result = $object->add_photo($conf->categorie->dir_output, $_FILES['userfile']);
}
$result = $object->add_photo($conf->categorie->dir_output, $_FILES['userfile']);
}
}
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer)
{
$object->delete_photo($conf->categorie->dir_output."/".$_GET["file"]);
$object->delete_photo($conf->categorie->dir_output."/".$_GET["file"]);
}
if ($action == 'addthumb' && $_GET["file"])
{
$object->add_thumb($conf->categorie->dir_output."/".$_GET["file"]);
$object->add_thumb($conf->categorie->dir_output."/".$_GET["file"]);
}
@ -81,223 +81,223 @@ if ($action == 'addthumb' && $_GET["file"])
* View
*/
llxHeader ("","",$langs->trans("Categories"));
llxHeader("","",$langs->trans("Categories"));
$html = new Form($db);
if (!empty($id) || !empty($ref))
{
$result = $object->fetch($id);
$result = $object->fetch($id);
if ($result)
{
$title=$langs->trans("ProductsCategoryShort");
if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
if ($result)
{
$title=$langs->trans("ProductsCategoryShort");
if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
$head = categories_prepare_head($object,$type);
dol_fiche_head($head, 'photos', $title, 0, 'category');
$head = categories_prepare_head($object,$type);
dol_fiche_head($head, 'photos', $title, 0, 'category');
/*
* Confirmation de la suppression de photo
*/
if ($action == 'delete')
{
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>';
}
/*
* Confirmation de la suppression de photo
*/
if ($action == 'delete')
{
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>';
}
print($mesg);
print($mesg);
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
// Path of category
print '<tr><td width="20%" class="notopnoleft">';
$ways = $object->print_all_ways ();
print $langs->trans("Ref").'</td><td>';
print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
foreach ($ways as $way)
{
print $way."<br>\n";
}
print '</td></tr>';
// Path of category
print '<tr><td width="20%" class="notopnoleft">';
$ways = $object->print_all_ways();
print $langs->trans("Ref").'</td><td>';
print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
foreach ($ways as $way)
{
print $way."<br>\n";
}
print '</td></tr>';
// Description
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("Description").'</td><td>';
print nl2br($object->description);
print '</td></tr>';
// Description
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("Description").'</td><td>';
print nl2br($object->description);
print '</td></tr>';
// Visibility
/* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
if ($object->socid)
{
$soc = new Societe($db);
$soc->fetch($object->socid);
// Visibility
/* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
if ($object->socid)
{
$soc = new Societe($db);
$soc->fetch($object->socid);
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("AssignedToTheCustomer").'</td><td>';
print $soc->getNomUrl(1);
print '</td></tr>';
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("AssignedToTheCustomer").'</td><td>';
print $soc->getNomUrl(1);
print '</td></tr>';
$catsMeres = $object->get_meres ();
$catsMeres = $object->get_meres ();
if ($catsMeres < 0)
{
dol_print_error();
}
else if (count($catsMeres) > 0)
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
}
else
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
}
else
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
*/
if ($catsMeres < 0)
{
dol_print_error();
}
else if (count($catsMeres) > 0)
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
}
else
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
}
else
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("CategoryContents").'</td><td>';
print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
*/
print "</table>\n";
print "</table>\n";
print "</div>\n";
print "</div>\n";
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
print "\n<div class=\"tabsAction\">\n";
if ($action != 'ajout_photo' && $user->rights->produit->creer)
{
if (! empty($conf->global->MAIN_UPLOAD_DOC))
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/categories/photos.php?action=ajout_photo&amp;id='.$object->id.'&amp;type='.$type.'">';
print $langs->trans("AddPhoto").'</a>';
}
else
{
print '<a class="butActionRefused" href="#">';
print $langs->trans("AddPhoto").'</a>';
}
}
if ($action != 'ajout_photo' && $user->rights->produit->creer)
{
if (! empty($conf->global->MAIN_UPLOAD_DOC))
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/categories/photos.php?action=ajout_photo&amp;id='.$object->id.'&amp;type='.$type.'">';
print $langs->trans("AddPhoto").'</a>';
}
else
{
print '<a class="butActionRefused" href="#">';
print $langs->trans("AddPhoto").'</a>';
}
}
print "\n</div>\n";
print "\n</div>\n";
/*
* Ajouter une photo
*/
if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/categories/photos.php?id='.$object->id.'&amp;type='.$type,$langs->trans("AddPhoto"),1);
}
/*
* Ajouter une photo
*/
if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/categories/photos.php?id='.$object->id.'&amp;type='.$type,$langs->trans("AddPhoto"),1);
}
// Affiche photos
if ($action != 'ajout_photo')
{
$nbphoto=0;
$nbbyrow=5;
// Affiche photos
if ($action != 'ajout_photo')
{
$nbphoto=0;
$nbbyrow=5;
$maxWidth = 160;
$maxHeight = 120;
$maxWidth = 160;
$maxHeight = 120;
$pdir = get_exdir($object->id,2) . $object->id ."/photos/";
$dir = $conf->categorie->dir_output.'/'.$pdir;
$pdir = get_exdir($object->id,2) . $object->id ."/photos/";
$dir = $conf->categorie->dir_output.'/'.$pdir;
print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
foreach ($object->liste_photos($dir) as $key => $obj)
{
$nbphoto++;
foreach ($object->liste_photos($dir) as $key => $obj)
{
$nbphoto++;
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
if ($obj['photo_vignette'])
{
$filename='thumbs/'.$obj['photo_vignette'];
}
else
{
$filename=$obj['photo'];
}
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
if ($obj['photo_vignette'])
{
$filename='thumbs/'.$obj['photo_vignette'];
}
else
{
$filename=$obj['photo'];
}
// Nom affiche
$viewfilename=$obj['photo'];
// Nom affiche
$viewfilename=$obj['photo'];
// Taille de l'image
$object->get_image_size($dir.$filename);
$imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
$imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
// Taille de l'image
$object->get_image_size($dir.$filename);
$imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
$imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$filename).'">';
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=categorie&file='.urlencode($pdir.$filename).'">';
print '</a>';
print '<br>'.$viewfilename;
print '<br>';
print '</a>';
print '<br>'.$viewfilename;
print '<br>';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=addthumb&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
}
if ($user->rights->categorie->creer)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=delete&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">';
print img_delete().'</a>';
}
if ($nbbyrow) print '</td>';
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
}
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=addthumb&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
}
if ($user->rights->categorie->creer)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=delete&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">';
print img_delete().'</a>';
}
if ($nbbyrow) print '</td>';
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
}
// Ferme tableau
while ($nbphoto % $nbbyrow)
{
print '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
$nbphoto++;
}
// Ferme tableau
while ($nbphoto % $nbbyrow)
{
print '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
$nbphoto++;
}
if ($nbphoto < 1)
{
print '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
print '</td></tr>';
}
if ($nbphoto < 1)
{
print '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
print '</td></tr>';
}
print '</table>';
}
}
print '</table>';
}
}
}
else
{
print $langs->trans("ErrorUnknown");
print $langs->trans("ErrorUnknown");
}

View File

@ -82,7 +82,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
$html = new Form($db);
llxHeader ("","",$langs->trans("Categories"));
llxHeader("","",$langs->trans("Categories"));
if ($mesg) print $mesg.'<br>';
@ -109,7 +109,7 @@ print '<table border="0" width="100%" class="border">';
// Path of category
print '<tr><td width="20%" class="notopnoleft">';
$ways = $object->print_all_ways ();
$ways = $object->print_all_ways();
print $langs->trans("Ref").'</td><td>';
print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
foreach ($ways as $way)
@ -168,7 +168,7 @@ else
}
print "</td>";
print "</tr>\n";
if (sizeof ($cats) > 0)
if (count($cats) > 0)
{
$var=true;
foreach ($cats as $cat)
@ -217,7 +217,7 @@ if ($object->type == 0)
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ProductsAndServices")."</td></tr>\n";
if (sizeof ($prods) > 0)
if (count($prods) > 0)
{
$i = 0;
$var=true;
@ -255,7 +255,7 @@ if ($object->type == 1)
print "<table class='noborder' width='100%'>\n";
print "<tr class='liste_titre'><td>".$langs->trans("Suppliers")."</td></tr>\n";
if (sizeof ($socs) > 0)
if (count($socs) > 0)
{
$i = 0;
$var=true;
@ -274,7 +274,7 @@ if ($object->type == 1)
}
else
{
print "<tr ".$bc[false]."><td>".$langs->trans ("ThisCategoryHasNoSupplier")."</td></tr>";
print "<tr ".$bc[false]."><td>".$langs->trans("ThisCategoryHasNoSupplier")."</td></tr>";
}
print "</table>\n";
}
@ -293,7 +293,7 @@ if($object->type == 2)
print "<table class='noborder' width='100%'>\n";
print "<tr class='liste_titre'><td>".$langs->trans("Customers")."</td></tr>\n";
if (sizeof ($socs) > 0)
if (count($socs) > 0)
{
$i = 0;
$var=true;
@ -333,7 +333,7 @@ if ($object->type == 3)
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Member")."</td></tr>\n";
if (sizeof ($prods) > 0)
if (count($prods) > 0)
{
$i = 0;
$var=true;