Index: extensions/set_plugins/admin.php
===================================================================
--- extensions/set_plugins/admin.php	(revision 11074)
+++ extensions/set_plugins/admin.php	(revision 11093)
@@ -5,6 +5,5 @@
 // Fetch the template.
 global $template;
-           $redirect_url = get_root_url().'admin.php?page='.'plugins_list';
-             redirect($redirect_url);
+
 include_once(SET_PLUGINS_PATH."include/constants.php"); 	   
 include_once(SET_PLUGINS_PATH.'include/affiche.php');
@@ -59,4 +58,6 @@
 
 // Assign the template contents to ADMIN_CONTENT
-$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin');
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin');       
+  //  $redirect_url = get_root_url().'admin.php?page='.'plugins_list';
+    //         redirect($redirect_url);
 ?>
Index: extensions/set_plugins/include/affiche.php
===================================================================
--- extensions/set_plugins/include/affiche.php	(revision 11074)
+++ extensions/set_plugins/include/affiche.php	(revision 11093)
@@ -5,4 +5,5 @@
 if (isset($conf['set_plugins']))
 $set_plugins_parametres =  unserialize($conf['set_plugins']);
+
 if(isset($set_plugins_parametres) && isset($set_plugins_parametres['nb']))
     $nb=$set_plugins_parametres['nb'];
@@ -14,4 +15,5 @@
    $state =$set_plugins_parametres['state'];
 
+ $state=isset($state)?$state:"active";
 
 $set=isset($_POST['set'])?$_POST['set']:"true";
Index: extensions/set_plugins/main.inc.php
===================================================================
--- extensions/set_plugins/main.inc.php	(revision 11074)
+++ extensions/set_plugins/main.inc.php	(revision 11093)
@@ -15,6 +15,6 @@
 load_language('plugin.lang', SET_PLUGINS_PATH);
 // Hook on to an event to show the administration page.
+
 add_event_handler('get_admin_plugin_menu_links', 'set_plugins_admin_menu');
-
 // Add an entry to the 'Plugins' menu.
 function set_plugins_admin_menu($menu) {
@@ -29,81 +29,16 @@
 }
 
-add_event_handler('loc_after_page_header','set_plugins_add'); 
+add_event_handler('loc_end_page_header','set_plugins_add'); 
 function set_plugins_add() {
-  global $user, $template, $val,$page;
+  global $user, $template, $val,$page,$conf;
   if (!isset($page['body_id'])) return;
 
   switch($page['body_id']){
-	  case  'theAdminPage': 
-    
+	  case  'theAdminPage':     
       switch($page['page']){
-	 	    case 'plugins_list':	 	
-
-include_once(SET_PLUGINS_PATH."include/constants.php"); 	   
-include_once(SET_PLUGINS_PATH.'include/affiche.php');
-
-$val_state="";
-
-if(  isset($_POST['unset_plugins']) || isset($_POST['set_plugins'])  ){
- if(isset($_POST['unset_plugins'])  ) 
-		    $val_state='inactive';
-      elseif(isset($_POST['set_plugins'])  ) 
-        $val_state='active';
-      $nb=isset($_POST['nb'])?$_POST['nb']:$nb ;
-    
-    if($val_state!=""){  
-    
-      $query = 'SELECT *
-                FROM ' . PLUGINS_TABLE . ' 
-           WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
-           LIMIT '.$nb.'
-      ';
-          $result = pwg_query($query);
-             
-      $query = '
-      UPDATE '.PLUGINS_TABLE.'
-      SET state="'.$val_state.'" 
-      WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
-      LIMIT '.$nb.'
-      ;';
-
-       pwg_query($query);
-
-    $data = array();
-    if($result)
-    while ($row = pwg_db_fetch_assoc($result))
-    {
-      $url =  $row['id'] ;$vers= $row['version'];
-      array_push($data, array('plugin' => $url,'version'=>$vers) );
-    }
-
-      unset ($_POST); 
-        $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
-         $config=array();
-             $config = array(
-                          'state' => $val_state,
-                          'list'=>$data,
-                          'nb' =>$nb
-                      );
-
-conf_update_param('set_plugins', pwg_db_real_escape_string(serialize($config)));
-
-        redirect($redirect_url);
-    }
-}
-               $template->set_filenames(
-                array(
-                  'plugin' => dirname(__FILE__).'/admin.tpl'
-                )         
-              );
-              $template->set_filenames(
-              array(    'cl_plugin' => dirname(__FILE__).'/admin.tpl'  )         
-              );
-
- 
-              $bpplus=$template->parse('cl_plugin', true);
-              $template-> assign('ADMIN_CONTENT',$bpplus); 
-              $bpplus=$template->parse('plugins', true);
-              $template-> concat('ADMIN_CONTENT',$bpplus); 
+	 	    case 'plugins_list':	 	      
+            if(!isset($template)) return ;     
+             Affiche_set_plugins();
+//============================================================
           	break;
 
@@ -122,7 +57,93 @@
 
 	
-return;
+return false;
  }
 
+ 
+function Affiche_set_plugins(){
+  global $user, $template, $val,$page,$conf;
+    include_once(SET_PLUGINS_PATH."include/constants.php"); 	   
+    include_once(SET_PLUGINS_PATH.'include/affiche.php');
+    $all_tpl_vars = $template->get_template_vars('plugins');
+  
+    if(!$all_tpl_vars)  return;     
+ 
+$val_state="";
 
+if(  isset($_POST['unset_plugins']) || isset($_POST['set_plugins'])  ){
+ if(isset($_POST['unset_plugins'])  ) 
+		    $val_state='inactive';
+      elseif(isset($_POST['set_plugins'])  ) 
+        $val_state='active';
+      $nb=isset($_POST['nb'])?$_POST['nb']:$nb ;
+    
+    if($val_state!=""){  
+    if($val_state=="activate")
+        $sens ="DESC";
+    else
+        $sens="ASC";
+
+    //==== pré-liste ===
+      $query = 'SELECT *
+                FROM ' . PLUGINS_TABLE . ' 
+           WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
+            ORDER BY `id` '.$sens.'
+           LIMIT '.$nb.'
+      ';
+          $result = pwg_query($query);
+    
+
+ 
+      $query = '
+      UPDATE '.PLUGINS_TABLE.'
+      SET state="'.$val_state.'" 
+      WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
+      ORDER BY `id`  '.$sens.'
+       LIMIT '.$nb.'
+      ;';
+
+       pwg_query($query);
+ 
+    $data = array();
+    if($result)
+    while ($row = pwg_db_fetch_assoc($result))
+    {
+ 
+     $url =  $row['id'] ;$vers= $row['version'];
+      array_push($data, array('plugin' => $url,'version'=>$vers) );
+    }
+     
+      unset ($_POST); 
+        $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
+         $config=array();
+             $config = array(
+                          'state' => $val_state,
+                          'list'=>$data,
+                          'nb' =>$nb
+                      );
+
+        conf_update_param('set_plugins', pwg_db_real_escape_string(serialize($config)));
+        redirect($redirect_url);
+    }
+}
+ 
+
+               $template->set_filenames(
+                array(
+                  'plugin' => dirname(__FILE__).'/admin.tpl'
+                )         
+              );
+              $template->set_filenames(
+              array(    'cl_plugin' => dirname(__FILE__).'/admin.tpl'  )         
+              );
+
+  
+ //===========================================================
+              $bpplus=$template->parse('cl_plugin', true);
+              $template-> assign('ADMIN_CONTENT',$bpplus); 
+              
+              $bpplus=$template->parse('plugins', true);
+              $template-> concat('ADMIN_CONTENT',$bpplus); 
+
+}
 ?>
Index: extensions/set_plugins/maintain.inc.php
===================================================================
--- extensions/set_plugins/maintain.inc.php	(revision 11074)
+++ extensions/set_plugins/maintain.inc.php	(revision 11093)
@@ -1,39 +1,61 @@
-function plugin_install()
-{
- global $conf;
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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                                          |
+// |                                                                       |
+// | 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.                                                                  |
+// +-----------------------------------------------------------------------+
+if  (!defined('PHPWG_ROOT_PATH')) {  die('Hacking attempt!');}
+if (!defined('SET_PLUGINS_PATH')) define('SET_PLUGINS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
 
-  if (!isset($conf['set_plugins']))
-  {
-    
-  $q = '
-    INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
-    VALUES ("set_plugins","","set_plugins")
-  ;';
-  pwg_query($q);
+
+function plugin_install(){
+  global $conf ;
+
+   if ( !isset($conf['set_plugins']) ){
+    plugin_uninstall() ;
+       $my_para['nb']="5";
+    $my_para['list']=array();
+    $my_para['state']="---";
+ 
+    $set_plugins_values=  pwg_db_real_escape_string(serialize($my_para));
+ //   conf_update_param('set_plugins', pwg_db_real_escape_string(serialize($config)));
+
+    $query = 'INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
+    VALUES ("set_plugins", "'.$set_plugins_values.'" ,"Parametres du plugin set_plugins");';
+    pwg_query($query);
   }
- 
+}
+function plugin_uninstall(){
+    $query = '
+      DELETE FROM '.CONFIG_TABLE.'
+      WHERE param="set_plugins"
+    ;';
+    pwg_query($query);
+
+}
+
+function plugin_activate(){
  
 }
 
+function plugin_deactivate(){
 
-
-function plugin_uninstall()
-{
-  global $conf;
-  if (isset($conf['set_plugins']))
-  {
-    $q = '
-      DELETE FROM '.CONFIG_TABLE.'
-      WHERE param="set_plugins"
-    ;';
-    pwg_query($q);
-    }
-	// $query = 'DROP TABLE IF EXISTS  '.set_plugins_TABLE.';';
-  //  pwg_query( $query);
- }
-
-
-function plugin_activate() {
-// Put anything here that should be executed during activation.
 }
 
+?>
