* Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /*! \file htdocs/admin/boxes.php \brief Page d'administration/configuration des boites \version $Revision$ */ require("./pre.inc.php"); $langs->load("admin"); if (!$user->admin) accessforbidden(); llxHeader(); print_titre($langs->trans("Boxes")); print "
".$langs->trans("BoxesDesc")."
\n"; if ($_POST["action"] == 'add') { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes WHERE box_id=".$_POST["boxid"]." AND position=".$_POST["pos"]; $result = $db->query($sql); $num = $db->num_rows(); if ($num == 0) { // Si la boite n'est pas deja active $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position) values (".$_POST["boxid"].",".$_POST["pos"].");"; $result = $db->query($sql); } } if ($_GET["action"] == 'delete') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["rowid"]; $result = $db->query($sql); } // Définition des positions possibles pour les boites $pos_array = array(0); // Positions possibles pour une boite (0,1,2,...) $pos_name = array(); // Nom des position 0=Homepage, 1=... $pos_name[0]="Homepage"; $boxes = array(); /* * Recherche des boites actives par position possible * On stocke les boites actives par $boxes[position][id_boite]=1 * */ $sql = "SELECT b.rowid, b.box_id, b.position, d.name FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d where b.box_id = d.rowid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; while ($i < $num) { $var = ! $var; $obj = $db->fetch_object( $i); //print "pos ".$obj->position; $boxes[$obj->position][$obj->box_id]=1; $i++; } } $db->free(); /* * Boites disponibles * */ print "
\n"; print_titre($langs->trans("BoxesAvailable")); print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $sql = "SELECT rowid, name, file FROM ".MAIN_DB_PREFIX."boxes_def"; $result = $db->query($sql); $var=True; if ($result) { $num = $db->num_rows(); $i = 0; // Boucle sur toutes les boites while ($i < $num) { $var = ! $var; $obj = $db->fetch_object( $i); print ''; print ''; // Pour chaque position possible, on affiche un lien // d'activation si boite non deja active pour cette position print ''; print ''; print ''; print ''; $i++; } } $db->free(); print '
'.$langs->trans("Boxe").''.$langs->trans("SourceFile").''.$langs->trans("ActivateOn").' 
'.$obj->name.'' . $obj->file . ''; $html=new Form($db); print $html->select_array("pos",$pos_name); print ''; print ''; print ' '; print ' 
'; print "
\n\n"; print_titre($langs->trans("BoxesActivated")); print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $sql = "SELECT b.rowid, b.box_id, b.position, d.name FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d where b.box_id = d.rowid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; while ($i < $num) { $var = ! $var; $obj = $db->fetch_object( $i); print ''; print ''; print ''; print ''; print "\n"; $i++; } } $db->free(); print '
'.$langs->trans("Boxe").' '.$langs->trans("ActiveOn").''.$langs->trans("Disable").'
'.$obj->name.' ' . $pos_name[$obj->position] . ''; print ''.img_delete().''; print '
'; $db->close(); llxFooter(); ?>