Re: Pb administration des colonnes

oui et mettre Kws_mysql

Réponse ci-dessus postée le mercredi 14 novembre 2018 : 22:51



et regarder si vous avez le fichier modules/admin/class_modules.php



Code PHP :
Pour copier le contenu exact du code,
Veuillez citer le message
  1. <?php
  2. // ---------------------------------------------------------------
  3. // KwsPHP kOoGar Web System
  4. // $Id: class_modules.php 1050 2017-08-08 16:03:25Z mike007 $
  5. // ---------------------------------------------------------------
  6. // Mise a jour : 09/01/07 par Ditch
  7. // Mise a jour : 16/07/2008 par Garveur
  8. // Gestion du Drag'N'Drop dans la gestion des colonnes
  9. // ---------------------------------------------------------------
  10.  
  11. if (!(defined('__KWS__'))) {die ('Erreur d\'appel de fichier.');}
  12.  
  13. class mod_admin_bloc
  14. {
  15.  
  16.     #########################################
  17.     ##  initialisation de la class module  ##
  18.     #########################################
  19.     //function mod_admin_bloc ($id, $action, $emplacement, $module)
  20.     function __construct ($id, $action, $emplacement, $module)
  21.     {
  22.         $this->action        = $action;
  23.         $this->id            = $id;
  24.         $this->emplacement    = $emplacement;
  25.         $this->module        = $module;
  26.  
  27.         //on ouvre un tableau html
  28.         bloc_head ('Administration des colonnes');
  29.         if (empty ($action))
  30.         {
  31.             $this->admin_bloc ();
  32.         }
  33.         else
  34.         {
  35.             $this->action_bloc ();
  36.         }
  37.         //on ferme le tableau html
  38.         close_table ();
  39.     }
  40.  
  41.     function admin_bloc ()
  42.     {
  43.         //on interroge la bdd pour connaitre les differents blocs
  44.         $this->req_mod = reqmysql('
  45.             SELECT `id`, `type`, `emplacement`, `position`, `module`, `parametre1`, `parametre2`, `parametre3`, `parametre4`, `parametre5`, `afficher`
  46.             FROM `modules`
  47.             WHERE `type` = "bloc"
  48.             ORDER BY `emplacement`, `position` ASC
  49.         ');
  50.  
  51.         //on verifie si des blocs existe
  52.         if (Kws_mysql_num_rows ($this->req_mod) > 0)
  53.         {
  54.             //on creer 1 tableau array avec les differents blocs
  55.             $blocs = $this->bloc ();
  56.  
  57.             // Chargement Hack Garveur Drag'N'Drop
  58.             echo '
  59.             <script language="javascript" type="text/javascript">
  60.                 // <![CDATA[
  61.                 var id_name_arrayDrag = new Array(Array("dragLeft","sql_positionDragLeft"),Array("dragRight","sql_positionDragRight"));
  62.                 // ]]>
  63.             </script>';
  64.             include './includes/dragndrop/dragndrop.php';
  65.             // Fin chargement Hack Garveur Drag'N'Drop
  66.  
  67.             echo '
  68.             <table style="width:100%" summary="class_modules">
  69.             <tr>
  70.             <td style="vertical-align:top; width:30%;">';
  71.  
  72.             //on affiche la colonne de gauche
  73.             echo '<ul id="dragLeft" class="sortable boxy">';    // Garveur Drag'N'Drop : <Début> liste modifiable gauche
  74.             $this->array_blocs ($blocs, 0);
  75.             echo '</ul>';    // Garveur Drag'N'Drop : < Fin > liste modifiable gauche
  76.  
  77.             //on affiche la colonne centrale
  78.             $this->bloc_centre ();
  79.  
  80.             echo '
  81.             </td>
  82.             <td style="vertical-align:top; width:30%;">';
  83.  
  84.             //on affiche la colonne de droite
  85.             echo '<ul id="dragRight" class="sortable boxy">';     // Garveur Drag'N'Drop : Début liste modifiable droite
  86.             $this->array_blocs ($blocs, 1);
  87.             echo '</ul>';    // Garveur Drag'N'Drop :  Fin  liste modifiable droite
  88.  
  89.             echo '<div style="text-align:center">
  90.             <a href="index.php?mod=admin&amp;ac=modules&amp;action=new&amp;emplacement=1">Ajouter un module</a>
  91.             </div>
  92.             </td>
  93.             </tr>
  94.             </table>
  95.  
  96.             <hr/>
  97.  
  98.             <div style="text-align:center">
  99.             <span id="help">Cliquez sur un param&egrave;tre pour le modifier</span>
  100.             </div>' ;
  101.         }
  102.         else
  103.         {
  104.             //si pas de blocs existants
  105.             echo 'Pas de blocs
  106.             <br /><div style="text-align:center">
  107.             <a href="index.php?mod=admin&amp;ac=modules&amp;action=new">Ajouter un module</a>
  108.             </div>';
  109.         }
  110.     }
  111.  
  112.     ##############################################
  113.     ##  creation de tableaux array par colonne  ##
  114.     ##############################################
  115.     function bloc ()
  116.     {
  117.         //on initialise les vars
  118.         $i = $j = 0;
  119.  
  120.         while ($result = Kws_mysql_fetch_array ($this->req_mod))
  121.         {
  122.             //si l'emplacement du bloc est à gauche
  123.             if ($result['emplacement'] == 0)
  124.             {
  125.                 $nb = $i;
  126.                 $i ++;
  127.                 $bloc = 'bloc_left';
  128.  
  129.                 //si l'emplacement du bloc est à droite
  130.             }
  131.             else
  132.             {
  133.                 $nb = $j;
  134.                 $j++;
  135.                 $bloc = 'bloc_right';
  136.             }
  137.  
  138.             //remplissage des tableaux
  139.             ${$bloc}[$nb]['id']          = $result['id'];
  140.             ${$bloc}[$nb]['position']    = $result['position'];
  141.             ${$bloc}[$nb]['emplacement'] = $result['emplacement'];
  142.             ${$bloc}[$nb]['module']      = $result['module'];
  143.             ${$bloc}[$nb]['parametre1']  = $result['parametre1'];
  144.             ${$bloc}[$nb]['parametre2']  = $result['parametre2'];
  145.             ${$bloc}[$nb]['parametre3']  = $result['parametre3'];
  146.             ${$bloc}[$nb]['parametre4']  = $result['parametre4'];
  147.             ${$bloc}[$nb]['parametre5']  = $result['parametre5'];
  148.             ${$bloc}[$nb]['afficher']    = $result['afficher'];
  149.  
  150.         }
  151.  
  152.         //creation d'un tableau array avec les 2 tableaux de gauche et de droite
  153.         $blocs = array ($bloc_left, $bloc_right);
  154.  
  155.         //on retourne le tableau creer
  156.         return $blocs;
  157.     }
  158.  
  159.     ###########################################
  160.     ##  on affiche les informations du bloc  ##
  161.     ###########################################
  162.     function blocs ($blocs, $pos)
  163.     {
  164.         global $K_theme,$K_IN_DEMO;
  165.  
  166.         $temp.= str_replace('[Editer]', '<img src="themes/'.$K_theme.'/images/gestion/edit.png" style="border:none;vertical-align:middle;" alt="edit" title="&Eacute;diter" />', $this->infos).'<a href="index.php?mod=admin&amp;ac=modules&amp;action=infos&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/notice.png" border="0" alt="info sur le module" title="Infos sur le module" /></a>';
  167.  
  168.         $temp .= (($pos > 0) ? '&nbsp;<a href="index.php?mod=admin&amp;ac=modules&amp;action=up&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/up.png" border="0" alt="up" title="Monter le bloc d\'un cran" /></a>' : '&nbsp;<img src="images/admin/up2.png" border="0" alt="up2" />');
  169.  
  170.         $temp .= (($pos < count ($blocs)-1) ? '&nbsp;<a href="index.php?mod=admin&amp;ac=modules&amp;action=down&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/down.png" border="0" alt="down" title="Descendre le bloc d\'un cran" /></a>' : '&nbsp;<img src="images/admin/down2.png" border="0" alt="down2" />');
  171.  
  172.         $temp .= (($blocs[$pos]['emplacement'] == 0) ? '&nbsp;<a href="index.php?mod=admin&amp;ac=modules&amp;action=right&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/right.png" border="0" alt="right" title="Faire passer le bloc dans la colonne de droite" /></a>' : '&nbsp;<a href="index.php?mod=admin&amp;ac=modules&amp;action=left&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/left.png" border="0" alt="left" title="Faire passer le bloc dans la colonne de gauche" /></a>');
  173.  
  174.         if (!$K_IN_DEMO OR ($blocs[$pos]['module']!='menu' AND $blocs[$pos]['module']!='espace_membre'))
  175.         {
  176.             $temp .= '&nbsp;<a href="index.php?mod=admin&amp;ac=modules&amp;action=del&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/del.png" border="0" alt="del" title="Supprimer ce bloc" /></a>';
  177.  
  178.             $temp .= (($blocs[$pos]['afficher'] == 1) ? '&nbsp;<a href="index.php?mod=admin&amp;ac=modules&amp;action=hide&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/aff2.png" border="0" alt="hide" title="Masquer ce bloc" /></a>' : '&nbsp;<a href="index.php?mod=admin&amp;ac=modules&amp;action=aff&amp;id='.$blocs[$pos]['id'].'"><img src="images/admin/aff1.png" border="0" alt="aff" title="Afficher ce bloc" /></a>');
  179.         }
  180.  
  181.         return $temp;
  182.     }
  183.  
  184.     ############################################################
  185.     ##  on selectionne les blocs par emplacement et position  ##
  186.     ############################################################
  187.     function array_blocs ($blocs, $pos)
  188.     {
  189.         $noBlocs = 0;    // Garveur Drag'N'Drop : < Init > Définition du bloc référence
  190.         for($i = 0; $i<count ($blocs[$pos]); $i ++)
  191.         {
  192.             $noBlocs = 1;    // Garveur Drag'N'Drop : < Alim > Définition du bloc référence
  193.             //on affiche le bloc
  194.             echo '<li id="drag_'.$blocs[$pos][$i]['id'].'">';    // Garveur Drag'N'Drop : <Début> Définition du bloc deplaçable
  195.             bloc_head ($blocs[$pos][$i]['module'].(($blocs[$pos][$i]['module']=='menu' OR $blocs[$pos][$i]['module']=='menuD')?' N&deg;:'.$blocs[$pos][$i]['id']:''));
  196.             //on verifie si le module existe
  197.             if($this->verif_module ($blocs[$pos][$i]))
  198.             {
  199.                 echo $this->blocs ($blocs[$pos], $i);
  200.             }
  201.             else
  202.             {
  203.                 echo '
  204.                 <span style="font-size:large;font-variant:small-caps;">Erreur !!!</span>
  205.                 <a href="./index.php?mod=admin&amp;ac=modules&amp;action=del&amp;id='.$blocs[$pos][$i]['id'].'">
  206.                     <img style="float:right" src="images/admin/del.png" border="0" alt="del" title="Supprimer ce bloc" />
  207.                 </a>
  208.                 <br /><br />
  209.                 <strong>Le bloc &laquo; '.$blocs[$pos][$i]['module'].' &raquo; est introuvable.</strong><br />Le module est certainement absent ou <a href="./index.php?mod=admin&amp;ac=gestion_module">d&eacute;sactiv&eacute;</a>.';
  210.             }
  211.             close_table();
  212.             echo '</li>';    // Garveur Drag'N'Drop : < Fin > Définition du bloc deplaçable
  213.         }
  214.         // Garveur Drag'N'Drop : <Début> Définition du bloc de référence
  215.         if($noBlocs == 0)
  216.         {
  217.             echo '<li id="drag_-1"><br /><div style="text-align:center">Position de la colonne de '.(($pos==0)?'gauche':'droite').'<br />Faire Glisser ici.</div><br /></li>';
  218.         }
  219.         // Garveur Drag'N'Drop : < Fin > Définition du bloc référence
  220.     }
  221.  
  222.     ##################################
  223.     ##  on affiche le bloc central  ##
  224.     ##################################
  225.     function bloc_centre()
  226.     {
  227.         global $K_mod_dem, $K_edito_aff, $K_mod;
  228.         $K_mod_dem = unserialize($K_mod_dem);
  229.  
  230.         echo '
  231.         <div style="text-align:center">
  232.         <a href="index.php?mod=admin&amp;ac=modules&amp;action=new&amp;emplacement=0">Ajouter un module</a>
  233.         </div>
  234.         </td>
  235.         <td valign="top">';
  236.  
  237.         $dirs = ScannerRepertoire ('modules','dir', false);
  238.         $mods = '';
  239.         foreach ($dirs as $dir)
  240.         {
  241.             if (file_exists('./modules/'.$dir.'/index.php')
  242.                     and $dir != 'admin'
  243.                     and $dir != 'alerte'
  244.                     and $dir != 'bbcode_sup'
  245.                     and $dir != 'debug'
  246.                     and $dir != 'generateur'
  247.                     and $dir != 'infoZ'
  248.                     and $dir != 'ip'
  249.                     and $dir != 'maintenance'
  250.                     and $dir != 'menu'
  251.                     and $dir != 'menuD'
  252.                     and $dir != 'newsletter'
  253.                     and $dir != 'smileys'
  254.                     and $dir != 'theme_pour_tous'
  255.                     and $dir != 'eskuel'
  256.                     and is_module($dir))
  257.             {
  258.                 $mods .= '<option value="'.$dir.'" '.($dir==$K_mod_dem['nom']?'selected="selected"':'').'>'.$dir.'</option>'."\n";
  259.             }
  260.         }
  261.  
  262.         bloc_head('Edito');
  263.         echo '
  264.         <div style="text-align:center">
  265.             <a href="index.php?mod=admin&amp;ac=modules&amp;action=edito">Changer l\'&eacute;dito</a><br /><br />
  266.             <a href="index.php?mod=admin&amp;ac=modules&amp;action=aff_edito">'.($K_edito_aff=='oui' ? '<img src="images/admin/aff2.png" border="0" alt="masquer" title="Masquer l\'edito" />' : '<img src="images/admin/aff1.png" border="0" alt="afficher" title="Afficher l\'edito" />').'</a>
  267.         </div>';
  268.         close_table();
  269.         bloc_head('D&eacute;marrage');
  270.         if (is_module('page'))
  271.         {
  272.             $req_page=reqmysql('
  273.                 SELECT    `id`, `titre`
  274.                 FROM `page`
  275.                 ORDER BY `id` DESC
  276.             ');
  277.             if (Kws_mysql_num_rows($req_page)>0)
  278.             {
  279.                 while($rep_page = Kws_mysql_fetch_object($req_page))
  280.                 {
  281.                     $pages .= '<option value="page_'.$rep_page->id.'">[id='.$rep_page->id.'] - '.substr($rep_page->titre,0,20).'...</option>'."\n";
  282.                 }
  283.             }
  284.         }
  285.         if (is_module('articles'))
  286.         {
  287.             $req_art = reqmysql('
  288.                 SELECT        `articles`.`id`,
  289.                             `articles`.`titre`
  290.                 FROM `articles`
  291.                 WHERE        `validation` = "0"
  292.                 ORDER BY    `articles`.`ref` ASC,
  293.                             `articles`.`date` DESC
  294.             ');
  295.             if (Kws_mysql_num_rows($req_art)>0)
  296.             {
  297.                 while($rep_art = Kws_mysql_fetch_object($req_art))
  298.                 {
  299.                     $arts .= '<option value="articles_'.$rep_art->id.'">[id='.$rep_art->id.'] - '.substr($rep_art->titre,0,20).'...</option>'."\n";
  300.                 }
  301.             }
  302.         }
  303.         if (is_module('news'))
  304.         {
  305.             $req_news = reqmysql('
  306.                 SELECT        `news`.`id`,
  307.                             `news`.`titre`
  308.                 FROM `news`
  309.                 WHERE        `validation` = "0"
  310.                 ORDER BY    `news`.`ref` ASC,
  311.                             `news`.`date` DESC
  312.             ');
  313.             if (Kws_mysql_num_rows($req_news)>0)
  314.             {
  315.                 while($rep_news = Kws_mysql_fetch_object($req_news))
  316.                 {
  317.                     $news .= '<option value="news_'.$rep_news->id.'">[id='.$rep_news->id.'] - '.substr($rep_news->titre,0,20).'...</option>'."\n";
  318.                 }
  319.             }
  320.         }
  321.         if (is_module('ajash00t'))
  322.         {
  323.             global $K_ajash00t_options;
  324.             $K_ajash00t_options = unserialize($K_ajash00t_options);
  325.             $shoot = '';
  326.             foreach ($K_ajash00t_options as $key => $val)
  327.             {
  328.                 $shoot .= '<option value="ajash00t_'.$key.'">[id'.$key.'] - Titre: "'.$K_ajash00t_options[$key]['titre'].'"</option>'."\n";
  329.             }
  330.             $K_ajash00t_options = serialize($K_ajash00t_options);
  331.         }
  332.         echo '
  333.         <script type="text/javascript">
  334.         // <![CDATA[
  335.             function select_mod(nom_mod)
  336.             {
  337.                 document.getElementById("page_dem").style.display="none";
  338.                 document.getElementById("select_page_dem").name="";
  339.                 document.getElementById("art_dem").style.display="none";
  340.                 document.getElementById("select_art_dem").name="";
  341.                 document.getElementById("news_dem").style.display="none";
  342.                 document.getElementById("select_news_dem").name="";
  343.                 document.getElementById("shoot_dem").style.display="none";
  344.                 document.getElementById("select_shoot_dem").name="";
  345.  
  346.                 if (nom_mod=="page")
  347.                 {
  348.                     document.getElementById("page_dem").style.display="block";
  349.                     document.getElementById("select_page_dem").name="module";
  350.                 }
  351.                 else if (nom_mod=="articles")
  352.                 {
  353.                     document.getElementById("art_dem").style.display="block";
  354.                     document.getElementById("select_art_dem").name="module";
  355.                 }
  356.                 else if (nom_mod=="news")
  357.                 {
  358.                     document.getElementById("news_dem").style.display="block";
  359.                     document.getElementById("select_news_dem").name="module";
  360.                 }
  361.                 else if (nom_mod=="ajash00t")
  362.                 {
  363.                     document.getElementById("shoot_dem").style.display="block";
  364.                     document.getElementById("select_shoot_dem").name="module";
  365.                 }
  366.             }
  367.         // ]]>
  368.         </script>
  369.         <form style="text-align:center" action="index.php?mod=admin&amp;ac=modules&amp;action=mod_dem" method="post">
  370.             Modules de d&eacute;marrage
  371.             <br />';
  372.             if (empty($K_mod_dem))
  373.             {
  374.                 echo '<p style="text-align:center">Aucun module</p>';
  375.             }
  376.             else
  377.             {
  378.                 echo '<input name="submit_mod_dem" type="submit" value="Tout supprimer" /><br />';
  379.             }
  380.             $mod_dem_nbr = count($K_mod_dem);
  381.             $i=0;
  382.             foreach($K_mod_dem as $pos => $nom_mod_dem)
  383.             {
  384.                 echo '<div style="float:left;width:75%;text-align:left">'.ucfirst($nom_mod_dem).'</div>
  385.                     <input name="sql_mod_dem'.$i.'" type="hidden" value="'.$nom_mod_dem.'" />
  386.                     <div style="float:right;width:25%;text-align:left">
  387.                     <select style="text-align:right" name="int_position'.$i.'">';
  388.                     for ($j=1 ; $j<= $mod_dem_nbr ; $j++ )
  389.                     {
  390.                         echo'<option '.($j==($pos+1) ? 'selected="selected"':'').' value="'.$j.'">'.$j.'&nbsp;</option>'."\n";
  391.                     }
  392.                 echo'</select></div><br style="clear:both" />
  393.                 ';
  394.                 $i++;
  395.             }
  396.             echo '<br style="clear:both" /><hr />';
  397.             if ($mod_dem_nbr>1)
  398.             {
  399.                 echo '<input name="submit_mod_dem" type="submit" value="Modifier positions" />'.$_SESSION['erreur_mod_dem_pos'].'<hr />';
  400.                 unset($_SESSION['erreur_mod_dem_pos']);
  401.             }
  402.             echo '<select name="module" onchange="select_mod(this.options[this.selectedIndex].value)">
  403.                 <option value="">Choisissez...</option>
  404.                 '.$mods.'
  405.             </select>
  406.             <div id="page_dem" style="display:none">
  407.             <select id="select_page_dem" >
  408.                 <option value="page">Choisissez ou laissez vide...</option>
  409.                 '.$pages.'
  410.             </select>
  411.             </div>
  412.             <div id="art_dem" style="display:none">
  413.             <select id="select_art_dem" >
  414.                 <option value="articles">Choisissez ou laissez vide...</option>
  415.                 '.$arts.'
  416.             </select>
  417.             </div>
  418.             <div id="news_dem" style="display:none">
  419.             <select id="select_news_dem" >
  420.                 <option value="news">Choisissez ou laissez vide...</option>
  421.                 '.$news.'
  422.             </select>
  423.             </div>
  424.             <div id="shoot_dem" style="display:none">
  425.             <select id="select_shoot_dem" >
  426.                 <option value="ajash00t">Choisissez la sh00t...</option>
  427.                 '.$shoot.'
  428.             </select>
  429.             </div>
  430.             <br /><br />
  431.             <input name="submit_mod_dem" type="submit" value="Ajouter" />'.(empty($K_mod_dem) ? '':' &nbsp; <input type="submit" value="Supprimer" />').'
  432.         </form><br />';
  433.         close_table();
  434.         bloc_head('Pied de module');
  435.             echo '
  436.             <p style="text-align:center">
  437.                 G&eacute;rer le param&egrave;tre virtuel<br />
  438.                 <a href="index.php?mod=droit&amp;ac=gestion&amp;module='.$K_mod.'">piedModule dans le module droit</a></p>';
  439.         close_table();
  440.         bloc_head('Copyrights');
  441.         echo '<div style="text-align:center"><a href="index.php?mod=admin&amp;ac=modules&amp;action=copyrights">Modifier les copyrights</a></div>';
  442.         close_table();
  443.         // Garveur Drag'N'Drop : Début Formulaire Enregistrement des positions
  444.         echo '<br /><br /><div style="text-align:center"><form name="EnregistrementPosition" method="post" action="index.php?mod=admin&amp;ac=modules&amp;action=SavePosition">
  445.                     <input type="hidden" id="sql_positionDragLeft" name="sql_positionDragLeft" value="Position colonne de gauche" />
  446.                     <input type="hidden" id="sql_positionDragRight" name="sql_positionDragRight" value="Position colonne de droite" />
  447.                     <input type="submit" value="Enregistrer les positions des Blocs" onclick="DragCopyPosition(id_name_arrayDrag)" />
  448.                 </form></div>';
  449.         // Garveur Drag'N'Drop :  Fin  Formulaire Enregistrement des positions
  450.     }
  451.  
  452.     #######################################################
  453.     ##  on verifie si le module existe puis on l'inclus  ##
  454.     #######################################################
  455.     function verif_module($modd)
  456.     {
  457.         settype($modd, 'object');
  458.         $module=$modd->module;
  459.         if (file_exists('./modules/'.$modd->module.'/admin.php') and file_exists('./modules/'.$modd->module.'/bloc.php') and is_module($modd->module))
  460.         {
  461.             $result_blocs = $modd;
  462.             include './modules/'.$modd->module.'/admin.php' ;
  463.             $this->infos        = str_replace("ac=param", "ac=modules&amp;action=edit", $infos);
  464.             $this->informations = $informations;
  465.             $this->new          = $new;
  466.             $this->edit         = $edit;
  467.             return true;
  468.         }
  469.         else
  470.         {
  471.             return false;
  472.         }
  473.     }
  474.  
  475.     function info_bloc()
  476.     {
  477.         open_table() ;
  478.         $req_blocs=reqmysql('
  479.             SELECT    `module`
  480.             FROM `modules`
  481.             WHERE    `modules`.`id` = "'.$this->id.'"
  482.         ');
  483.         $result_blocs = Kws_mysql_fetch_object($req_blocs) ;
  484.  
  485.         require 'modules/'.$result_blocs->module.'/admin.php';
  486.         echo $informations;
  487.         close_table() ;
  488.         echo '<p style="text-align:center;"><a href="index.php?mod=admin&amp;ac=modules">Retour &agrave; l\'administration des colonnes</a></p>';
  489.     }
  490.  
  491.     function move_bloc_vertical()
  492.     {
  493.         $req_blocs=reqmysql('
  494.             SELECT    `position`, `emplacement`
  495.             FROM `modules`
  496.             WHERE    `id` = "'.$this->id.'"
  497.         ');
  498.         $result_blocs = Kws_mysql_fetch_object($req_blocs) ;
  499.         $pos_down = $result_blocs->position ;
  500.  
  501.         $var = $this->action == down ? ' AND `position` > "'.$pos_down.'" ORDER BY `position` ASC ' : ' AND `position` < "'.$pos_down.'" ORDER BY `position` DESC ';
  502.  
  503.         $req_blocs=reqmysql('
  504.             SELECT    `id`, `position`
  505.             FROM `modules`
  506.             WHERE    `emplacement` = "'.$result_blocs->emplacement.'" AND `type` = "bloc" '.$var.'
  507.             LIMIT    0,1
  508.         ');
  509.         $result_blocs = Kws_mysql_fetch_object($req_blocs) ;
  510.         $id_up        = $result_blocs->id ;
  511.         $pos_up       = $result_blocs->position ;
  512.  
  513.         reqmysql('
  514.             UPDATE `modules`
  515.             SET        `position` = "'.$pos_down.'"
  516.             WHERE    `id` = "'.$id_up.'"
  517.         ');
  518.         reqmysql('
  519.             UPDATE `modules`
  520.             SET        `position` = "'.$pos_up.'"
  521.             WHERE    `id` = "'.$this->id.'"
  522.         ');
  523.  
  524.         $this->redirection();
  525.     }
  526.  
  527.     function move_bloc_horizontal()
  528.     {
  529.         if($this->action == 'left')
  530.         {
  531.             $new_place = 0;
  532.             $last_place = 1;
  533.             $sql = '';
  534.         }
  535.         else
  536.         {
  537.             $new_place = 1;
  538.             $last_place = 0;
  539.             $sql = 'AND `id` != "'.$this->id.'"';
  540.         }
  541.  
  542.         $req_blocs=reqmysql('
  543.             SELECT    `position`
  544.             FROM `modules`
  545.             WHERE    `id` = "'.$this->id.'"
  546.         ');
  547.         $result_blocs = Kws_mysql_fetch_object($req_blocs) ;
  548.         $pos          = $result_blocs->position ;
  549.  
  550.         $req_blocs=reqmysql('
  551.             SELECT        *
  552.             FROM `modules`
  553.             WHERE        `type`="bloc" AND `emplacement` = "'.$new_place.'"
  554.             ORDER BY    `position` DESC
  555.         ');
  556.         $result_blocs = Kws_mysql_fetch_object($req_blocs);
  557.         $new_pos      = $result_blocs->position + 1;
  558.  
  559.         reqmysql('
  560.             UPDATE `modules`
  561.             SET        `emplacement` = "'.$new_place.'",
  562.                     `position` = "'.$new_pos.'"
  563.             WHERE    `id` = "'.$this->id.'"
  564.         ');
  565.  
  566.         $req_blocs=reqmysql('
  567.             SELECT        *
  568.             FROM `modules`
  569.             WHERE        `position` > "'.$pos.'" AND `type` = "bloc" AND `emplacement` = "'.$last_place.'"
  570.             ORDER BY    `position` ASC
  571.         ');
  572.  
  573.         while ($result_blocs = Kws_mysql_fetch_object($req_blocs))
  574.         {
  575.             reqmysql('
  576.                 UPDATE `modules`
  577.                 SET        `position`="'.($result_blocs->position - 1).'"
  578.                 WHERE    `id`="'.$result_blocs->id.'"
  579.                 '.$sql
  580.             );
  581.         }
  582.         $this->redirection();
  583.     }
  584.  
  585.     function aff_bloc()
  586.     {
  587.         if($this->action == 'aff')
  588.         {
  589.             reqmysql('
  590.                 UPDATE `modules`
  591.                 SET        `afficher`="1"
  592.                 WHERE    `id`="'.$this->id.'"
  593.             ');
  594.         }
  595.         else
  596.         {
  597.             reqmysql('
  598.                 UPDATE `modules`
  599.                 SET        `afficher`="0"
  600.                 WHERE    `id`="'.$this->id.'"
  601.             ');
  602.         }
  603.  
  604.         $this->redirection();
  605.     }
  606.  
  607.     function new_bloc()
  608.     {
  609.         $dirs = ScannerRepertoire('modules','dir', false);
  610.         $bloc = '';
  611.         foreach ($dirs as $dir)
  612.         {
  613.             if (file_exists('./modules/'.$dir.'/bloc.php') && is_module($dir))
  614.             {
  615.                 $img_bloc_exist = './modules/admin/images/desactive2.png';
  616.                 $req_new_bloc = reqmysql('
  617.                     SELECT    `emplacement`
  618.                     FROM `modules`
  619.                     WHERE    `type`="bloc"
  620.                     AND        `module`="'.$dir.'"
  621.                 ');
  622.                 $result_new_bloc = Kws_mysql_fetch_object($req_new_bloc);
  623.                 if (Kws_mysql_num_rows($req_new_bloc)>0) $img_bloc_exist = './modules/admin/images/active.png';
  624.                 $bloc .= '
  625.                 <li style="cursor:help; list-style-image:url(\''.$img_bloc_exist.'\')" title="Le bloc &laquo; '.$dir.' &raquo; est : '.(isset($result_new_bloc->emplacement)? 'Actif &agrave '.($result_new_bloc->emplacement==0? 'gauche':'droite') : 'Inactif').'">
  626.                     <a href="index.php?mod=admin&amp;ac=modules&amp;action=new2&amp;module='.$dir.'&amp;emplacement='.$this->emplacement.'">'.$dir.'</a>
  627.                 </li>';
  628.             }
  629.         }
  630.  
  631.         open_table() ;
  632.         echo '
  633.         <p>S&eacute;lectionnez le module &agrave; ajouter &agrave; '.($_GET['emplacement']==0 ? 'gauche' : 'droite').' :</p>
  634.         <ul>
  635.         '.$bloc.'
  636.         </ul>';
  637. /*
  638.         $file = '';
  639.         $rep  = opendir('modules');
  640.  
  641.         while (($file = readdir($rep)) != false)
  642.         {
  643.             if($file != '..' && $file !='.' && $file !='')
  644.             {
  645.                 if (is_dir('modules/'.$file) and file_exists('modules/'.$file.'/bloc.php')==1 and is_module($file))
  646.                 {
  647.                     echo '<img src="images/admin/puce.png" alt="puce" />  <a href="index.php?mod=admin&amp;ac=modules&amp;action=new2&amp;module='.$file.'&amp;emplacement='.$this->emplacement.'">'.$file.'</a><br />';
  648.                 }
  649.             }
  650.         }
  651.         closedir($rep);
  652.         clearstatcache();
  653. */        close_table();
  654.         echo '
  655.         <p style="text-align:center;"><a href="index.php?mod=admin&amp;ac=modules">Retour &agrave; l\'administration des colonnes</a></p>';
  656.     }
  657.  
  658.     function new2_bloc()
  659.     {
  660.         global $module, $emplacement;
  661.  
  662.         open_table() ;
  663.         require 'modules/'.$module.'/admin.php';
  664.         echo '
  665.         <form name="FormName" action="index.php?mod=admin&amp;ac=modules&amp;action=new3" method="post">'.preg_replace("@<form(.*?)>(.*?)</form>@si", "\\2",$new).'</form>';
  666.         close_table() ;
  667.         echo '
  668.         <p style="text-align:center;"><a href="index.php?mod=admin&amp;ac=modules">Retour &agrave; l\'administration des colonnes</a></p>';
  669.     }
  670.  
  671.     function new3_bloc()
  672.     {
  673.         $req_blocs=reqmysql('
  674.             SELECT        `position`
  675.             FROM `modules`
  676.             WHERE        `type` = "bloc" AND `emplacement` = "'.$this->emplacement.'"
  677.             ORDER BY    `position` DESC
  678.         ');
  679.         $result_blocs = Kws_mysql_fetch_object($req_blocs) ;
  680.         $new_pos      = $result_blocs->position + 1 ;
  681.  
  682.         reqmysql('
  683.             INSERT INTO `modules`
  684.             SET        `type`            = "bloc",
  685.                     `emplacement`    = "'.$this->emplacement.'",
  686.                     `position`        = "'.$new_pos.'",
  687.                     `module`        = "'.$_POST['module'].'",
  688.                     `parametre1`    = "'.$_POST['parametre1'].'",
  689.                     `parametre2`     = "'.$_POST['parametre2'].'",
  690.                     `parametre3`     = "'.$_POST['parametre3'].'",
  691.                     `parametre4`    = "'.$_POST['parametre4'].'",
  692.                     `parametre5`    = "'.$_POST['parametre5'].'",
  693.                     `afficher`        = "1"
  694.         ') or die('erreur') ;
  695.  
  696.         $this->redirection();
  697.     }
  698.  
  699.     function edit_bloc()
  700.     {
  701.         open_table();
  702.         $req_blocs=reqmysql('
  703.             SELECT    `id`, `module`, `parametre1`, `parametre2`, `parametre3`, `parametre4`, `parametre5`
  704.             FROM `modules`
  705.             WHERE    `id` = "'.$this->id.'"
  706.         ');
  707.         $result_blocs = Kws_mysql_fetch_object($req_blocs);
  708.  
  709.         require 'modules/'.$result_blocs->module.'/admin.php';
  710.         echo '
  711.         <form name="FormName" action="index.php?mod=admin&amp;ac=modules&amp;action=save_edit" method="post">'.preg_replace('@<form(.*?)>(.*?)</form>@si', '\\2',$edit).'</form>';
  712.         close_table();
  713.         echo '
  714.         <p style="text-align:center;"><a href="index.php?mod=admin&amp;ac=modules">Retour &agrave; l\'administration des colonnes</a></p>';
  715.     }
  716.  
  717.     function save_edit_bloc()
  718.     {
  719.         reqmysql('
  720.             UPDATE `modules`
  721.             SET        `parametre1`= "'.$_POST['parametre1'].'",
  722.                     `parametre2`= "'.$_POST['parametre2'].'",
  723.                     `parametre3`= "'.$_POST['parametre3'].'",
  724.                     `parametre4`= "'.$_POST['parametre4'].'",
  725.                     `parametre5`= "'.$_POST['parametre5'].'"
  726.             WHERE    `id` = "'.$this->id.'"
  727.         ');
  728.         /*reqmysql('
  729.             UPDATE `modules`
  730.             SET        `afficher` = "'.$_POST['parametre3'].'"
  731.             WHERE    `type` = "menu" AND `emplacement`= "'.$this->id.'"
  732.         ');*/
  733.  
  734.         $this->redirection();
  735.     }
  736.  
  737.     function del_bloc()
  738.     {
  739.         reqmysql('
  740.             DELETE FROM `modules`
  741.             WHERE        `id`="'.$this->id.'"
  742.         ');
  743.         reqmysql('
  744.             DELETE FROM `modules`
  745.             WHERE    `type`="menu" AND `emplacement`="'.$this->id.'"
  746.         ');
  747.         reqmysql('
  748.             DELETE FROM `modules`
  749.             WHERE    `type`="menuD" AND `emplacement`="'.$this->id.'"
  750.         ');
  751.  
  752.         $this->redirection();
  753.     }
  754.  
  755.     function mod_dem()
  756.     {
  757.         global $K_mod_dem;
  758.         $K_mod_dem = unserialize($K_mod_dem);
  759.         $mod_dem_nbr = count($K_mod_dem);
  760.         $mod_dem_maj = true;
  761.         if ($_POST['submit_mod_dem']=='Modifier positions')
  762.         {
  763.             for ($i=0 ; $i < $mod_dem_nbr ; $i++)
  764.             {
  765.                 $trouv = false;
  766.                 while (!$trouv)
  767.                 {
  768.                     for ($j=0 ; ($j < $mod_dem_nbr and $i!=$j); $j++)
  769.                     {
  770.                         if ($_POST['int_position'.$i]==$_POST['int_position'.$j])
  771.                         {
  772.                             $mod_dem_maj = false;
  773.                             break;
  774.                         }
  775.                     }
  776.                     if (!$trouv)
  777.                     {
  778.                         $trouv=true;
  779.                     }
  780.                 }
  781.             }
  782.             if ($mod_dem_maj)
  783.             {
  784.                 for ($i=0 ; $i < $mod_dem_nbr ; $i++)
  785.                 {
  786.                     $K_mod_dem[($_POST['int_position'.$i]-1)] = $_POST['sql_mod_dem'.$i];
  787.                     $_SESSION['erreur_mod_dem_pos']='<p style="font-weight:bold">Positions mises &agrave; jour</p>';
  788.                 }
  789.             }
  790.             else
  791.             {
  792.                 $_SESSION['erreur_mod_dem_pos']='<p style="font-weight:bold">Positions non mises &agrave; jour : Doublon(s)</p>';
  793.             }
  794.         }
  795.         elseif ($_POST['submit_mod_dem']=='Ajouter')
  796.         {
  797.             $pretmp=array_keys($K_mod_dem);
  798.             $tmp=array_pop($pretmp);
  799.             if(is_numeric($tmp))    $tmp++ ;
  800.             else                    $tmp=0;
  801.             if ($this->module!='')    $K_mod_dem[$tmp] = $this->module;
  802.         }
  803.         elseif ($_POST['submit_mod_dem']=='Tout supprimer')
  804.         {
  805.             $K_mod_dem = array();
  806.         }
  807.         else
  808.         {
  809.             if (in_array($this->module, $K_mod_dem))
  810.             {
  811.                 unset($K_mod_dem[array_search($this->module, $K_mod_dem)]);
  812.             }
  813.         }
  814.         if (!empty ($K_mod_dem)) $K_mod_dem = array_values($K_mod_dem);
  815.         $K_mod_dem = serialize($K_mod_dem);
  816.  
  817.         reqmysql('
  818.             UPDATE `parametres`
  819.             SET        `valeur`= "'.sp($K_mod_dem).'"
  820.             WHERE    `nom`    = "K_mod_dem"
  821.         ');
  822.  
  823.         $this->redirection();
  824.     }
  825.  
  826.     function edito()
  827.     {
  828.         global $K_edito, $tiny_mce_confType, $tiny_mce_skin;
  829.         if (is_module('tiny_mce'))
  830.         {
  831.             include './modules/tiny_mce/kwsphp.php';
  832.         }
  833.  
  834.         open_table();
  835.         echo 'Edito :<br />
  836.         <br />
  837.         <div style="text-align:center;">
  838.             <form style="text-align:center" action="index.php?mod=admin&amp;ac=modules&amp;action=save_edito" method="post">
  839.                 L&rsquo;edito est un texte d&rsquo;introduction pour votre site. Vous pouvez mettre du code HTML pour y inclure des tableaux, des images, ...<br />
  840.                 <br />
  841.                 <center><textarea name="sql_edito2" cols="100" rows="30">'.ax($K_edito,true).'</textarea></center><br />
  842.                 <br />
  843.                 <input type="submit" name="submit" id="submit" value="Enregistrer" />
  844.             </form>
  845.         </div>';
  846.         close_table() ;
  847.         echo '<p style="text-align:center;"><a href="index.php?mod=admin&amp;ac=modules">Retour &agrave; l\'administration des colonnes</a></p>';
  848.     }
  849.  
  850.     function aff_edito()
  851.     {
  852.         global $K_edito_aff;
  853.  
  854.         if ($K_edito_aff== 'oui')    $K_edito_aff='non';
  855.         else                        $K_edito_aff='oui';
  856.         reqmysql('
  857.             UPDATE `parametres`
  858.             SET        `valeur` = "'.$K_edito_aff.'"
  859.             WHERE    `nom` = "K_edito_aff"
  860.         ');
  861.  
  862.         $this->redirection();
  863.     }
  864.     function save_edito()
  865.     {
  866.         reqmysql('
  867.             UPDATE `parametres`
  868.             SET        `valeur` = "'.$_POST['sql_edito2'].'"
  869.             WHERE    `nom` = "edito"
  870.         ');
  871.  
  872.         $this->redirection();
  873.     }
  874.  
  875.  
  876.     function copyrights()
  877.     {
  878.         global $K_copyrights, $tiny_mce_confType, $tiny_mce_skin;
  879.         if (is_module('tiny_mce'))
  880.         {
  881.             include './modules/tiny_mce/kwsphp.php';
  882.         }
  883.  
  884.         open_table();
  885.         echo 'Copyrights :<br />
  886.         <br />
  887.         <div style="text-align:center;">
  888.             <form style="text-align:center" action="index.php?mod=admin&amp;ac=modules&amp;action=save_copyrights" method="post">
  889.                 Les copyrights sont situ&eacute;s &agrave; la fin, et sont affich&eacute;s sur toutes les pages. Vous pouvez mettre du code HTML pour y inclure des tableaux, des images, ...<br />
  890.                 <br />
  891.                 <center><textarea name="sql_copyrights2" cols="100" rows="15">'.ax($K_copyrights,true).'</textarea></center><br />
  892.                 <br />
  893.                 <input type="submit" name="submit" id="submit" value="Enregistrer" />
  894.             </form>
  895.         </div>';
  896.         close_table();
  897.         echo '<p style="text-align:center;"><a href="index.php?mod=admin&amp;ac=modules">Retour &agrave; l\'administration des colonnes</a></p>';
  898.     }
  899.  
  900.     function save_copyrights()
  901.     {
  902.         reqmysql('
  903.             UPDATE `parametres`
  904.             SET        `valeur` = "'.$_POST['sql_copyrights2'].'"
  905.             WHERE    `nom` = "copyrights"
  906.         ');
  907.  
  908.         $this->redirection();
  909.     }
  910.  
  911.     // Garveur Drag'N'Drop : <Début> Fonction d'enregistrement des positions
  912.     function SavePosition()
  913.     {
  914.         $positionDragLeft = $_POST['sql_positionDragLeft'];
  915.         $positionDragRight = $_POST['sql_positionDragRight'];
  916.  
  917.         // Enregistrements des positions de la colonne de gauche
  918.         $idBloc = strtok($positionDragLeft,"|drag_");
  919.         $posBloc=0;
  920.         while ($idBloc)
  921.         {
  922.             reqmysql('UPDATE `modules` SET `emplacement` = "0", `position` = "'.$posBloc.'" WHERE `id` = "'.$idBloc.'"');
  923.             $idBloc = strtok("|drag_");
  924.             $posBloc++;
  925.         }
  926.  
  927.         // Enregistrements des positions de la colonne de droite
  928.         $idBloc = strtok($positionDragRight,"|drag_");
  929.         $posBloc=0;
  930.         while ($idBloc)
  931.         {
  932.             reqmysql('UPDATE `modules` SET emplacement = "1", `position` = "'.$posBloc.'" WHERE `id` = "'.$idBloc.'"');
  933.             $idBloc = strtok("|drag_");
  934.             $posBloc++;
  935.         }
  936.  
  937.         $this->redirection();
  938.     }
  939.     // Garveur Drag'N'Drop : < Fin > Fonction d'enregistrement des positions
  940.  
  941.     function redirection()
  942.     {
  943.         echo '<script type="text/javascript">window.location="index.php?mod=admin&ac=modules";</script>';
  944.     }
  945.  
  946.     function action_bloc()
  947.     {
  948.         switch($this->action)
  949.         {
  950.             case 'infos':                $this->info_bloc();                break;
  951.             case 'up':
  952.             case 'down':                $this->move_bloc_vertical();    break;
  953.             case 'left':
  954.             case 'right':                $this->move_bloc_horizontal();    break;
  955.             case 'aff':
  956.             case 'hide':                $this->aff_bloc();                break;
  957.             case 'new':                    $this->new_bloc();                break;
  958.             case 'new2':                $this->new2_bloc();                break;
  959.             case 'new3':                $this->new3_bloc();                break;
  960.             case 'edit':                $this->edit_bloc();                break;
  961.             case 'save_edit':            $this->save_edit_bloc();        break;
  962.             case 'del':                    $this->del_bloc();                break;
  963.             case 'mod_dem':                $this->mod_dem();                break;
  964.             case 'edito':                $this->edito();                    break;
  965.             case 'aff_edito':            $this->aff_edito();                break;
  966.             case 'save_edito':            $this->save_edito();            break;
  967.             // Garveur Drag'N'Drop :  Appel de l'enregistrement des positions
  968.             case 'SavePosition':        $this->SavePosition();            break;
  969.             case 'copyrights':            $this->copyrights();            break;
  970.             case 'save_copyrights':        $this->save_copyrights();        break;
  971.         }
  972.     }
  973. }
  974.  
  975. ?>
  976.  


Sujet écrit par Musicgroove le mercredi 14 novembre 2018 à 23:08

[ Imprimer ] - [ Fermer la fenêtre ]