コード例 #1
0
 /**
  * 
  * @param string $title Caracteristique title
  * @param string $display display caracteristique in boucle function
  * @param int $addAuto add automatically this caracteristique to all category
  */
 public function add($title, $display, $addAuto)
 {
     $title = trim($title);
     if (empty($title)) {
         throw new TheliaAdminException("Title caracteristique empty", TheliaAdminException::CARAC_TITLE_EMPTY);
     }
     $this->classement = $this->getMaxRank() + 1;
     $this->affiche = $display != "" ? 1 : 0;
     $this->id = parent::add();
     $caracdesc = new Caracteristiquedesc();
     $caracdesc->caracteristique = $this->id;
     $caracdesc->titre = $title;
     $caracdesc->lang = ActionsAdminLang::instance()->get_id_langue_courante();
     $caracdesc->add();
     if (intval($addAuto) == 1) {
         $query = "SELECT id FROM " . Rubrique::TABLE;
         foreach (CacheBase::getCache()->query($query) as $rub) {
             $rubcaracteristique = new Rubcaracteristique();
             $rubcaracteristique->rubrique = $rub->id;
             $rubcaracteristique->caracteristique = $this->id;
             $rubcaracteristique->add();
         }
     }
     ActionsModules::instance()->appel_module("ajcaracteristique", new Caracteristique($this->id));
     redirige("caracteristique_modifier.php?id=" . $this->id);
 }
コード例 #2
0
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}");
}