public function add($featureToAddId, $categoryId)
 {
     $category = new Rubrique();
     $featureToAdd = new Caracteristique();
     $this->id = '';
     if (!$this->charger($categoryId, $featureToAddId) && $featureToAdd->charger($featureToAddId) && $category->charger($categoryId)) {
         $this->rubrique = $category->id;
         $this->caracteristique = $featureToAdd->id;
         parent::add();
         ActionsModules::instance()->appel_module("modrub", $category);
     }
 }
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}");
}
Ejemplo n.º 3
0
function boucleCaracteristique($texte, $args)
{
    global $caracteristique;
    $id = lireTag($args, "id", "int_list");
    $rubrique = lireTag($args, "rubrique", "int");
    $affiche = lireTag($args, "affiche", "int");
    $produit = lireTag($args, "produit", "int");
    $courante = lireTag($args, "courante", "int");
    $exclusion = lireTag($args, "exclusion", "int_list");
    $search = "";
    $res = "";
    // preparation de la requete
    if ($produit != "") {
        $tprod = new Produit();
        $tprod->charger_id($produit);
        $rubrique = $tprod->rubrique;
    }
    if ($rubrique != "") {
        $search .= " and rubrique=\"{$rubrique}\"";
    }
    if ($id != "") {
        $search .= " and caracteristique in({$id})";
    }
    if ($exclusion != "") {
        $search .= " and caracteristique not in({$exclusion})";
    }
    $rubcaracteristique = new Rubcaracteristique();
    $tmpcaracteristique = new Caracteristique();
    $tmpcaracteristiquedesc = new Caracteristiquedesc();
    $order = "order by {$tmpcaracteristique->table}.classement";
    $query = "select DISTINCT(caracteristique) from {$rubcaracteristique->table},{$tmpcaracteristique->table}  where 1 {$search} and {$rubcaracteristique->table}.caracteristique={$tmpcaracteristique->table}.id {$order}";
    //if($id != "") $query = "select * from $tmpcaracteristique->table where 1 $search";
    $resul = CacheBase::getCache()->query($query);
    if (empty($resul)) {
        return "";
    }
    $compt = 1;
    foreach ($resul as $row) {
        if ($courante == "1" && ($id != $caracteristique && !strstr($caracteristique, $id . "-"))) {
            continue;
        } else {
            if ($courante == "0" && ($id == $caracteristique || strstr($caracteristique, $id . "-"))) {
                continue;
            }
        }
        $tmpcaracteristiquedesc->charger($row->caracteristique);
        $temp = str_replace("#ID", "{$row->caracteristique}", $texte);
        $tmpcaracteristique->charger($tmpcaracteristiquedesc->caracteristique);
        if ($tmpcaracteristique->affiche == "0" && $affiche == "1") {
            continue;
        }
        $temp = str_replace("#TITRE", "{$tmpcaracteristiquedesc->titre}", $temp);
        $temp = str_replace("#CHAPO", "{$tmpcaracteristiquedesc->chapo}", $temp);
        $temp = str_replace("#DESCRIPTION", "{$tmpcaracteristiquedesc->description}", $temp);
        $temp = str_replace("#PRODUIT", "{$produit}", $temp);
        $temp = str_replace("#COMPT", "{$compt}", $temp);
        $compt++;
        $res .= $temp;
    }
    return $res;
}