function ajouter($lang, $id, $titre, $chapo, $description, $tabdisp, $affiche, $ajoutrub) { $caracteristique = new Caracteristique(); $caracteristique->charger($id); if ($caracteristique->id) { return; } $caracteristique = new Caracteristique(); $query = "select max(classement) as maxClassement from {$caracteristique->table}"; $resul = $caracteristique->query($query); $maxClassement = $resul ? $caracteristique->get_result($resul, 0, "maxClassement") : 0; $caracteristique->id = $id; if ($affiche != "") { $caracteristique->affiche = 1; } else { $caracteristique->affiche = 0; } $caracteristique->classement = $maxClassement + 1; $lastid = $caracteristique->add(); $caracteristique->id = $lastid; $caracteristiquedesc = new Caracteristiquedesc(); $caracteristiquedesc->chapo = $chapo; $caracteristiquedesc->description = $description; $caracteristiquedesc->caracteristique = $lastid; $caracteristiquedesc->lang = $lang; $caracteristiquedesc->titre = $titre; $caracteristiquedesc->chapo = str_replace("\n", "<br/>", $caracteristiquedesc->chapo); $caracteristiquedesc->description = str_replace("\n", "<br/>", $caracteristiquedesc->description); $caracteristiquedesc->add(); if (intval($ajoutrub) == 1) { $rubrique = new Rubrique(); $query = "select * from {$rubrique->table}"; $resul = $rubrique->query($query); while ($resul && ($row = $rubrique->fetch_object($resul))) { $rubcaracteristique = new Rubcaracteristique(); $rubcaracteristique->rubrique = $row->id; $rubcaracteristique->caracteristique = $lastid; $rubcaracteristique->add(); } } ActionsModules::instance()->appel_module("ajcaracteristique", $caracteristique); redirige($_SERVER['PHP_SELF'] . "?id={$lastid}&lang={$lang}"); }
public function modifier($titre, $chapo, $description, $affiche, $caracdisp, $lang) { $this->verifyLoaded(); $caracdesc = new Caracteristiquedesc($this->id, $lang); $caracdesc->titre = $titre; $caracdesc->chapo = nl2br($chapo); $caracdesc->description = nl2br($description); $this->affiche = $affiche != "" ? 1 : 0; $this->maj(); if ($caracdesc->id) { $caracdesc->maj(); } else { $caracdesc->lang = $lang; $caracdesc->caracteristique = $this->id; $caracdesc->add(); } ActionsModules::instance()->appel_module("modcaracteristique", new Caracteristique($this->id)); //Caracdispdesc if (!empty($caracdisp) && is_array($caracdisp)) { foreach ($caracdisp as $id => $value) { $caracdispdesc = new Caracdispdesc(); $caracdispdesc->charger_caracdisp($id, $lang); $caracdispdesc->titre = $value; if ($caracdispdesc->id) { $caracdispdesc->maj(); } else { $caracdispdesc->caracdisp = $id; $caracdispdesc->lang = $lang; $caracdispdesc->classement = $this->getMaxCaracdispRank($this->id, $lang) + 1; $caracdispdesc->add(); } $caracdisp = new Caracdisp($id); ActionsModules::instance()->appel_module("modcaracdisp", $caracdisp); } } redirige("caracteristique_modifier.php?id=" . $this->id . "&lang=" . $lang); }