public function add($title, $parent)
 {
     $rubriquedesc = new Rubriquedesc();
     $rubriquedesc->titre = $title;
     if ($rubriquedesc->titre !== '') {
         if (!is_numeric($parent) && $parent < 1) {
             $parent = 0;
         }
         $this->parent = $parent;
         $this->ligne = 1;
         $this->classement = $this->getMaxRanking($parent) + 1;
         $this->id = parent::add();
         $rubriquedesc->rubrique = $this->id;
         $rubriquedesc->lang = ActionsLang::instance()->get_id_langue_courante();
         $rubriquedesc->chapo = '';
         $rubriquedesc->description = '';
         $rubriquedesc->postscriptum = '';
         $rubriquedesc->id = $rubriquedesc->add();
         $caracteristique = new Caracteristique();
         $qCarac = "select * from {$caracteristique->table}";
         $rCarac = $caracteristique->query($qCarac);
         while ($rCarac && ($theCarac = $caracteristique->fetch_object($rCarac))) {
             $rubcaracteristique = new Rubcaracteristique();
             $rubcaracteristique->rubrique = $this->id;
             $rubcaracteristique->caracteristique = $theCarac->id;
             $rubcaracteristique->add();
         }
         $rubriquedesc->reecrire();
         ActionsModules::instance()->appel_module("ajoutrub", new Rubrique($this->id));
         redirige("rubrique_modifier.php?id=" . $this->id);
     } else {
         throw new TheliaAdminException("impossible to add new category", TheliaAdminException::CATEGORY_ADD_ERROR, null, $rubriquedesc);
     }
 }
 function getListAvailableFeature($idrubrique)
 {
     $return = array();
     $qList = "SELECT * FROM " . self::TABLE . " WHERE rubrique={$idrubrique}";
     $rList = $this->query($qList);
     $notAvailable = array();
     while ($rList && ($theAssociatedFeature = $this->fetch_object($rList))) {
         $notAvailable[] = $theAssociatedFeature->caracteristique;
     }
     $feature = new Caracteristique();
     $qFeatures = "SELECT * FROM " . Caracteristique::TABLE . "" . (!empty($notAvailable) ? " WHERE id NOT IN(" . implode(',', $notAvailable) . ")" : '');
     $rFeature = $feature->query($qFeatures);
     while ($rFeature && ($theFeature = $feature->fetch_object($rFeature))) {
         $featureDescription = new Caracteristiquedesc($theFeature->id);
         $return[] = array('id' => $theFeature->id, 'titre' => $featureDescription->titre);
     }
     return $return;
 }
Exemplo n.º 3
0
function caracteristique_liste_select($idrubrique)
{
    $rubcaracteristique = new Rubcaracteristique();
    $query = "select * from {$rubcaracteristique->table} where rubrique={$idrubrique}";
    $resul = $rubcaracteristique->query($query);
    $listeid = "";
    while ($resul && ($row = $rubcaracteristique->fetch_object($resul))) {
        $listeid .= $row->caracteristique . ",";
    }
    if (strlen($listeid) > 0) {
        $listeid = substr($listeid, 0, strlen($listeid) - 1);
        $caracteristique = new Caracteristique();
        $query = "select * from {$caracteristique->table} where id NOT IN({$listeid})";
        $resul = $caracteristique->query($query);
    } else {
        $caracteristique = new Caracteristique();
        $query = "select * from {$caracteristique->table}";
        $resul = $caracteristique->query($query);
    }
    ?>
	<select class="form_select" id="prod_caracteristique">
 	<option value="">&nbsp;</option>
	<?php 
    while ($resul && ($row = $caracteristique->fetch_object($resul))) {
        $caracteristiquedesc = new Caracteristiquedesc($row->id);
        ?>
			<option value="<?php 
        echo $row->id;
        ?>
"><?php 
        echo $caracteristiquedesc->titre;
        ?>
</option>
		<?php 
    }
    ?>
	</select>
	<?php 
}
function ajouter($parent, $lang, $titre, $chapo, $description, $postscriptum, $lien, $ligne)
{
    $rubrique = new Rubrique();
    $rubrique->parent = $parent;
    $rubrique->lien = $lien;
    if ($ligne != "") {
        $rubrique->ligne = 1;
    } else {
        $rubrique->ligne = 0;
    }
    if ($parent == "") {
        $parent = 0;
    }
    $lastid = $rubrique->add();
    $rubrique->charger($lastid);
    $rubrique->maj();
    $rubriquedesc = new Rubriquedesc();
    $rubriquedesc->rubrique = $lastid;
    $rubriquedesc->lang = $lang;
    $rubriquedesc->titre = $titre;
    $rubriquedesc->chapo = $chapo;
    $rubriquedesc->description = $description;
    $rubriquedesc->postscriptum = $postscriptum;
    $rubriquedesc->add();
    $caracteristique = new Caracteristique();
    $query = "select * from {$caracteristique->table}";
    $resul = $caracteristique->query($query);
    $rubcaracteristique = new Rubcaracteristique();
    while ($resul && ($row = $caracteristique->fetch_object($resul))) {
        $rubcaracteristique->rubrique = $lastid;
        $rubcaracteristique->caracteristique = $row->id;
        $rubcaracteristique->add();
    }
    $rubriquedesc->reecrire();
    ActionsModules::instance()->appel_module("ajoutrub", $rubrique);
    redirige("" . $_SERVER['PHP_SELF'] . "?id=" . $lastid);
}