Patch traduction. merci Nicolas
This commit is contained in:
parent
8a598504af
commit
40a74211df
@ -353,49 +353,62 @@ class Product
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief update ou crée les traductions des infos produits
|
||||
*/
|
||||
* \brief update ou crée les traductions des infos produits
|
||||
*/
|
||||
function setMultiLangs()
|
||||
{
|
||||
global $langs;
|
||||
$langs_available = $langs->get_available_languages();
|
||||
$langs_available = $langs->get_available_languages();
|
||||
$current_lang = $langs->getDefaultLang();
|
||||
|
||||
foreach ($langs_available as $value)
|
||||
{
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_det";
|
||||
$sql.= " WHERE fk_product=".$this->id." AND lang='".$value."'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($value == $current_lang)
|
||||
{
|
||||
$sqlU = "UPDATE ".MAIN_DB_PREFIX."product_det";
|
||||
$sqlU.= " SET label='".$this->libelle."'";
|
||||
$sqlU.= " description='".$this->description."'";
|
||||
$sqlU.= " note='".$this->note."'";
|
||||
$sqlU.= " WHERE fk_product=".$this->id." AND lang='".$value."'";
|
||||
|
||||
$sqlI = "INSERT INTO ".MAIN_DB_PREFIX."product_det (fk_product, lang, label, description, note)";
|
||||
$sqlI.= " VALUES(".$this->id.",'".$value."','". $this->libelle;
|
||||
$sqlI.= "','".$this->description;
|
||||
$sqlI.= "','".$this->note."')";
|
||||
|
||||
if (mysql_num_rows($result)) // si aucune ligne dans la base
|
||||
{
|
||||
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_det";
|
||||
$sql2.= " SET label='".$this->libelle."',";
|
||||
$sql2.= " description='".$this->description."',";
|
||||
$sql2.= " note='".$this->note."'";
|
||||
$sql2.= " WHERE fk_product=".$this->id." AND lang='".$value."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_det (fk_product, lang, label, description, note)";
|
||||
$sql2.= " VALUES(".$this->id.",'".$value."','". $this->libelle;
|
||||
$sql2.= "','".$this->description;
|
||||
$sql2.= "','".$this->note."')";
|
||||
}
|
||||
if (!$this->db->query($sql2)) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sqlU = "UPDATE ".MAIN_DB_PREFIX."product_det";
|
||||
$sqlU.= " SET label='".$this->multilangs["$value"]["libelle"]."'";
|
||||
$sqlU.= " description='".$this->multilangs["$value"]["libelle"]."'";
|
||||
$sqlU.= " note='".$this->multilangs["$value"]["note"]."'";
|
||||
$sqlU.= " WHERE fk_product=".$this->id." AND lang='".$value."'";
|
||||
|
||||
$sqlI = "INSERT INTO ".MAIN_DB_PREFIX."product_det (fk_product, lang, label, description, note)";
|
||||
$sqlI.= " VALUES(".$this->id.",'".$value."','". $this->multilangs["$value"]["libelle"];
|
||||
$sqlI.= "','".$this->multilangs["$value"]["description"];
|
||||
$sqlI.= "','".$this->multilangs["$value"]["note"]."')";
|
||||
if (mysql_num_rows($result)) // si aucune ligne dans la base
|
||||
{
|
||||
$sql2 = "UPDATE ".MAIN_DB_PREFIX."product_det";
|
||||
$sql2.= " SET label='".$this->multilangs["$value"]["libelle"]."',";
|
||||
$sql2.= " description='".$this->multilangs["$value"]["description"]."',";
|
||||
$sql2.= " note='".$this->multilangs["$value"]["note"]."'";
|
||||
$sql2.= " WHERE fk_product=".$this->id." AND lang='".$value."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_det (fk_product, lang, label, description, note)";
|
||||
$sql2.= " VALUES(".$this->id.",'".$value."','". $this->multilangs["$value"]["libelle"];
|
||||
$sql2.= "','".$this->multilangs["$value"]["description"];
|
||||
$sql2.= "','".$this->multilangs["$value"]["note"]."')";
|
||||
}
|
||||
|
||||
// on ne sauvegarde pas des champs vides
|
||||
if ( $this->multilangs["$value"]["libelle"] || $this->multilangs["$value"]["description"] || $this->multilangs["$value"]["note"] )
|
||||
if (!$this->db->query($sql2)) return -1;
|
||||
}
|
||||
|
||||
// on ne sauvegarde pas des champs vides
|
||||
if ( $this->multilangs["$value"]["libelle"] || $this->multilangs["$value"]["description"] || $this->multilangs["$value"]["note"] )
|
||||
if (!$this->db->query($sqlU)) // si aucun champ n'est mis a jour
|
||||
if (!$this->db->query($sqlI)) return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -425,16 +438,16 @@ class Product
|
||||
{
|
||||
while ( $obj = $this->db->fetch_object($result) )
|
||||
{
|
||||
$this->multilangs["$obj->lang"]["libelle"] = $obj->label;
|
||||
$this->multilangs["$obj->lang"]["description"] = $obj->description;
|
||||
$this->multilangs["$obj->lang"]["note"] = $obj->note;
|
||||
|
||||
if( $obj->lang == $current_lang ) // si on a les traduct. dans la langue courant on les charge en infos principales.
|
||||
{
|
||||
$this->libelle = $obj->label;
|
||||
$this->description = $obj->description;
|
||||
$this->note = $obj->note;
|
||||
}
|
||||
$this->multilangs["$obj->lang"]["libelle"] = $obj->label;
|
||||
$this->multilangs["$obj->lang"]["description"] = $obj->description;
|
||||
$this->multilangs["$obj->lang"]["note"] = $obj->note;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -77,7 +77,7 @@ if ($_POST["action"] == 'vadd' &&
|
||||
}
|
||||
|
||||
// sauvegarde en base
|
||||
if ( $product->update($product->id, $user) > 0 )
|
||||
if ( $product->setMultiLangs() > 0 )
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$mesg = 'Fiche mise à jour';
|
||||
@ -108,13 +108,13 @@ if ($_POST["action"] == 'vedit' &&
|
||||
}
|
||||
else
|
||||
{
|
||||
$value["libelle"] = $_POST["libelle-".$key];
|
||||
$value["description"] = $_POST["desc-".$key];
|
||||
$value["note"] = $_POST["note-".$key];
|
||||
$product->multilangs[$key]["libelle"] = $_POST["libelle-".$key];
|
||||
$product->multilangs[$key]["description"] = $_POST["desc-".$key];
|
||||
$product->multilangs[$key]["note"] = $_POST["note-".$key];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $product->update($product->id, $user) > 0 )
|
||||
if ( $product->setMultiLangs() > 0 )
|
||||
{
|
||||
$_GET["action"] = '';
|
||||
$mesg = 'Fiche mise à jour';
|
||||
@ -271,16 +271,18 @@ if ($_GET["action"] == 'edit')
|
||||
}
|
||||
else
|
||||
{
|
||||
$cnt_trans = 0;
|
||||
foreach ( $product->multilangs as $key => $value)
|
||||
{
|
||||
$cnt_trans++;
|
||||
print "<br /><b><u>$key :</u></b><br />";
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$product->multilangs[$key]["libelle"].'</td></tr>';
|
||||
print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$product->multilangs[$key]["description"].'</td></tr>';
|
||||
print '<tr><td width="15%">'.$langs->trans('Note').'</td><td>'.$product->multilangs[$key]["note"].'</td></tr>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
}
|
||||
if ( !$cnt_trans ) print '<br />'. $langs->trans('NoTranslation');
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
@ -322,10 +324,7 @@ if ($_GET["action"] == 'add' || $user->rights->produit->modifier)
|
||||
print '<input type="hidden" name="action" value="vadd">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td valign="top" width="15%">'.$langs->trans('Translation').'</td><td>'.$select.'</td></tr>';;
|
||||
//print '<tr><td valign="top" width="15%">'.$langs->trans('Label').'</td><td><input name="libelle" size="40" value="'.$product->multilangs[$key]["libelle"].'"></td></tr>';
|
||||
//print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td><textarea name="desc" rows="3" cols="80">'.$product->multilangs[$key]["description"].'</textarea></td></tr>';
|
||||
//print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td><textarea name="note" rows="3" cols="80">'.$product->multilangs[$key]["note"].'</textarea></td></tr>';
|
||||
print '<tr><td valign="top" width="15%">'.$langs->trans('Translation').'</td><td>'.$select.'</td></tr>';
|
||||
print '<tr><td valign="top" width="15%">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
|
||||
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td><textarea name="desc" rows="3" cols="80"></textarea></td></tr>';
|
||||
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td><textarea name="note" rows="3" cols="80"></textarea></td></tr>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user