function lister_caracteristiques($critere, $order)
{
    $caracteristique = new Caracteristique();
    $query = "select id, classement from {$caracteristique->table} order by {$critere} {$order}";
    $resul = $caracteristique->query($query);
    while ($resul && ($row = $caracteristique->fetch_object($resul))) {
        $caracteristiquedesc = new Caracteristiquedesc();
        $caracteristiquedesc->charger($row->id);
        $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce") . "_rub";
        ?>
		<ul class="<?php 
        echo $fond;
        ?>
">
			<li style="width:770px;"><span id="<?php 
        echo $row->id;
        ?>
" class="texte_edit"><?php 
        echo $caracteristiquedesc->titre;
        ?>
</span></li>
			<li style="width:37px;"><a href="<?php 
        echo "caracteristique_modifier.php?id={$row->id}";
        ?>
"><?php 
        echo trad('editer', 'admin');
        ?>
</a></li>
			<li style="width:71px;">
			 <div class="bloc_classement">
			    <div class="classement"><a href="caracteristique_modifier.php?id=<?php 
        echo $row->id;
        ?>
&action=modclassement&type=M"><img src="gfx/up.gif" border="0" /></a></div>
			    <div class="classement"><span id="classementcarac_<?php 
        echo $row->id;
        ?>
" class="classement_edit"><?php 
        echo $row->classement;
        ?>
</span></div>
			    <div class="classement"><a href="caracteristique_modifier.php?id=<?php 
        echo $row->id;
        ?>
&action=modclassement&type=D"><img src="gfx/dn.gif" border="0" /></a></div>
			 </div>
			</li>
			<li style="width:37px; text-align:center;"><a onclick="return suppr_carac(<?php 
        echo $row->id;
        ?>
);" href="<?php 
        echo "caracteristique_modifier.php?id={$row->id}&action=supprimer";
        ?>
" ><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li>
		</ul>
		<?php 
    }
}
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}");
}
Esempio 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;
}
			</ul>
<div class="bloc_fleche" style="cursor:pointer" onclick="$('#pliantinfos').hide();"><img src="gfx/fleche_accordeon_up.gif" /></div>
</div>
<!-- fin du bloc de gestion des informations du produit -->
 <!-- début du bloc de gestion des caractéristiques ajoutées-->
		<div class="entete">
			<div class="titre" style="cursor:pointer" onclick="$('#pliantcaracteristiques').show('slow');"><?php 
    echo trad('CARACTERISTIQUES_AJOUTEES', 'admin');
    ?>
</div>
		</div>

<div class="blocs_pliants_prod" id="pliantcaracteristiques">
	 <?php 
    $rubcaracteristique = new Rubcaracteristique();
    $caracteristiquedesc = new Caracteristiquedesc();
    $caracdisp = new Caracdisp();
    $caracdispdesc = new Caracdispdesc();
    $caracteristique = new Caracteristique();
    $query = "select * from {$rubcaracteristique->table},{$caracteristique->table}  where {$rubcaracteristique->table}.caracteristique={$caracteristique->table}.id and {$rubcaracteristique->table}.rubrique='" . $rubrique . "' order by {$caracteristique->table}.classement";
    $resul = mysql_query($query);
    $caracval = new Caracval();
    while ($row = mysql_fetch_object($resul)) {
        $caracval = new Caracval();
        $caracteristiquedesc->charger($row->caracteristique);
        $caracval->charger($produit->id, $row->caracteristique);
        $query2 = "select c.* from {$caracdisp->table} c left join {$caracdispdesc->table} cd on cd.caracdisp = c.id and cd.lang = {$lang} where c.caracteristique='{$row->caracteristique}' order by cd.classement";
        $resul2 = mysql_query($query2);
        $nbres = mysql_num_rows($resul2);
        if (!$nbres) {
            ?>
 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);
 }
/*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
/*      GNU General Public License for more details.                                 */
/*                                                                                   */
/*      You should have received a copy of the GNU General Public License            */
/*	    along with this program. If not, see <http://www.gnu.org/licenses/>.         */
/*                                                                                   */
/*************************************************************************************/
require_once __DIR__ . "/../pre.php";
require_once __DIR__ . "/../auth.php";
if (!est_autorise("acces_configuration")) {
    exit;
}
require_once __DIR__ . "/../liste/caracteristique.php";
header('Content-Type: text/html; charset=utf-8');
if ($_REQUEST['action'] == "" && $_REQUEST['id'] != "") {
    $caracteristiquedesc = new Caracteristiquedesc($_REQUEST['id']);
    $caracteristiquedesc->titre = $_REQUEST['value'];
    $caracteristiquedesc->maj();
    echo $caracteristiquedesc->titre;
    exit;
}
switch ($_REQUEST["action"]) {
    case "ajouter":
        caracteristique_ajouter($_REQUEST["caracteristique"], $_REQUEST["rubrique"]);
        break;
    case "liste":
        caracteristique_liste_select($_REQUEST["id"]);
        break;
    case "supprimer":
        caracteristique_supprimer($_REQUEST["caracteristique"], $_REQUEST["rubrique"]);
        break;