Index: extensions/nbc_ThemeChanger/Version.txt
===================================================================
--- extensions/nbc_ThemeChanger/Version.txt	(revision 6553)
+++ extensions/nbc_ThemeChanger/Version.txt	(revision 6573)
@@ -1,2 +1,50 @@
+Version 2.1.0.b
+
+[lang=fr]
+
+Correction du bug sur les noms de menu avec espace.
+Correction du bug sur la fonctionnalité "modifiée" (lorsqu'on clique sur "modifier l'association",  la catégorie sélectionnée par défaut est celle à modifier (et non plus la première de la liste))
+
+Fichiers impactés :
+	main.inc.php
+	admin/nbc_ThemeChanger_admin.php
+	admin/nbc_ThemeChanger_admin.tpl
+[/lang=fr]
+[lang=en]
+
+Correction of the bug on menu name with spaces.
+Correction of a regretion bug on the "Modify" functionality , "Modify association" will now correctly fill in the form.
+	
+Files modifies:
+	main.inc.php
+	admin/nbc_ThemeChanger_admin.php
+	admin/nbc_ThemeChanger_admin.tpl
+[/lang=en]
+
+[lang=it]	
+
+Correzione del bug sulla denominazione delle teme con spazio.
+Correzione della funzionalità "Modificare". "Modificare l'associazione" riempirà correttamente il formulario.
+
+File modificati :	
+	main.inc.php
+	admin/nbc_ThemeChanger_admin.php
+	admin/nbc_ThemeChanger_admin.tpl
+
+	
+[/lang=it]
+--------------------------------------------------
+Version 2.1.0.a
+
+[lang=fr]
+Portage plugin on piwigo 2.1.x
+[/lang=fr]
+[lang=en]
+compatibility for piwigo 2.1.x
+[/lang=en]
+[lang=it]
+compatibilità per la versione piwigo 2.1.x
+[/lang=it]
+--------------------------------------------------
 Version 2.0.1.b
 [lang=fr]
@@ -11,5 +59,5 @@
 	admin/nbc_ThemeChanger_admin.tpl
 [/lang=fr]
-[lang=US]
+[lang=en]
 Add of the possibility of applying the theme modification on all the sub-categories of the category selected.
 Add of the full category's name path ("Photo/Nuit" instead of "Nuit" only)
@@ -21,5 +69,5 @@
 	admin/nbc_ThemeChanger_admin.php
 	admin/nbc_ThemeChanger_admin.tpl
-[/lang=US]
+[/lang=en]
 
 [lang=IT]
Index: extensions/nbc_ThemeChanger/admin/nbc_ThemeChanger_admin.php
===================================================================
--- extensions/nbc_ThemeChanger/admin/nbc_ThemeChanger_admin.php	(revision 6553)
+++ extensions/nbc_ThemeChanger/admin/nbc_ThemeChanger_admin.php	(revision 6573)
@@ -1,6 +1,9 @@
 <?php
-//if (!defined(PHPWG_ROOT_PATH)) die('Hacking attempt!');
+
+include_once (NBC_ThemeChanger_PATH.'include/functions_ThemeChanger.inc.php');
 
 global $user, $conf, $template;
+
+$__BEBUG = 0;
 
 // Check Access and exit when user status is not ok
@@ -8,40 +11,21 @@
 
 $me = get_plugin_data($plugin_id);
-
 load_language('plugin.lang', NBC_ThemeChanger_PATH);
 $page_ThemeChanger_admin = get_admin_plugin_menu_link(__FILE__);
 
 
-
-$cat=array();
-$categories = array();
-
-
 //chargement des catégories
- $query = '
-    SELECT id, name, uppercats, global_rank
-    FROM '.CATEGORIES_TABLE.' ;
-  ';
-   $result = pwg_query($query);
-
-   while (($cat = mysql_fetch_array($result)) <> null)
-   {
-   array_push($categories , array("id" => $cat['id'],
-				"name" => $cat['name'],
-				"uppercats" =>$cat['uppercats'],
-				"longName" => get_cat_display_name_cache($cat['uppercats'], null, false),
-				"global_rank" => $cat['global_rank'],
-				));
-		}
-
+$categories = my_get_pwg_categories();
+		
 
 //chargement des thèmes
-$themes = array();
-foreach (get_pwg_themes() as $pwg_template)
-{
-	$selected = $pwg_template;
-	array_push($themes, $selected);
-}
-
+$themes = my_get_pwg_themes();
+  if ($__BEBUG)
+  {
+  echo '0 '.$themes[0]['id'] .':'. $themes[0]['name'] .'<br>';
+  echo '0 '.$themes[1]['id'] .':'. $themes[1]['name'] .'<br>';
+  echo '0 '.$themes[2]['id'] .':'. $themes[2]['name'] .'<br>';
+  echo '0 '.$themes[3]['id'] .':'. $themes[3]['name'] .'<br>';
+  }
 
 // Configuration du template
@@ -51,20 +35,30 @@
 	'F_ACTION' => add_url_params($page_ThemeChanger_admin, array()),
     'U_ADD_ASSOC' => add_url_params($page_ThemeChanger_admin, array('action' => 'add_assoc')),
-    'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=ThemeChanger_admin',
+    'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=ThemeChanger',
 	'Themes' => $themes,
 	'Categories' => $categories,
+	'page_banner' => $conf['page_banner'],
+	'gallery_title' => $conf['gallery_title']
 ));
 
-// Mise a jour de la base de donnee
+// Configuration du formulaire
+$template->assign('formulaire',array(
+    'DESCRIPION' => $lang['add_assoc'],
+  ));
+  
+//Recupération options du plugin
+$conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
+  
+  
+// Mise a jour des paramètres du plugin
 if (isset($_POST['submit']) and !is_adviser())
 	if ( (isset($_POST['categorychoise']) or isset($_POST['category_id'])) and isset($_POST['template']))
-	{
-		$conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
+	{	
+		
 		$listcategory = array();
 		$newconf_nbc_ThemeChanger = '';
-		//evol $theme = explode("/" , $_POST['template']);
+		$add_ok = false;
+		//recupération des variables
 		$theme = $_POST['template'];
-		$add_ok = false;
-
 		$applysubcategory = isset($_POST['ApplySubCategories']) ? $_POST['ApplySubCategories'] : '';
 		$thecategory = isset($_POST['categorychoise']) ? $_POST['categorychoise'] : ( isset($_POST['category_id']) ? $_POST['category_id'] : '');
@@ -136,39 +130,10 @@
 	}
 
-$conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
-
-$catsused = array();
-$assoc_ThemeChanger = array();
-
-foreach ($conf_nbc_ThemeChanger as $Theme_Cat)
-{
-  $element_ThemeChanger = explode("," , $Theme_Cat);
-
-  if ($element_ThemeChanger[0] <> '' and $element_ThemeChanger[1] <> '')
-  {
-    array_push($catsused, $element_ThemeChanger[0]);
-
-    $query = '
-      SELECT uppercats
-        FROM '.CATEGORIES_TABLE.'
-        WHERE id = \''.$element_ThemeChanger[0].'\'
-      ;';
-
-    $result = pwg_query($query);
-    $row = mysql_fetch_array($result);
-
-    $assoc_ThemeChanger[$element_ThemeChanger[0]] = array(
-      'CATEGORY_NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
-      'TEMPLATE' => $element_ThemeChanger[1],
-    );
-  }
-}
 
 //delete an association
 if ( isset($_GET['action']) and ($_GET['action']=='del_assoc') and isset($_GET['id_cat']) and is_numeric($_GET['id_cat']) and !is_adviser() )
 {
-  $conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
-
-  $newconf_nbc_ThemeChanger = '';
+
+	$newconf_nbc_ThemeChanger = '';
 
   foreach ($conf_nbc_ThemeChanger as $Theme_Cat)
@@ -198,38 +163,12 @@
 
 //modify an association
-else if ( isset($_GET['action']) and ($_GET['action']=='mod_assoc') and isset($_GET['id_cat']) and is_numeric($_GET['id_cat']) )
+else if ( isset($_GET['action']) and ($_GET['action']=='mod_assoc') and isset($_GET['id_cat']) and is_numeric($_GET['id_cat']) and isset($_GET['id_theme']) )
 {
   $template->assign('formulaire',array(
-    'DESCRIPION' => $lang['modify_assoc'].' : '.$assoc_ThemeChanger[$_GET['id_cat']]['CATEGORY_NAME'],
-    'NAMETOMODIFY' => $assoc_ThemeChanger[$_GET['id_cat']]['CATEGORY_NAME'],
+	'DESCRIPION' => $lang['modify_assoc'].' : '.get_long_categorie_name($_GET['id_cat']),
+	'THEMETOMODIFY' => $_GET['id_theme'],
+	'NAMETOMODIFY' => get_long_categorie_name($_GET['id_cat']),
     'IDTOMODIFY' => $_GET['id_cat'],
   ));
-
-  $template->assign('formulaire.categoryfield', array(
-    'NAME' => $assoc_ThemeChanger[$_GET['id_cat']]['CATEGORY_NAME'],
-    'ID' => $_GET['id_cat'],
-  ));
-
-  $blockname = 'formulaire.template_option';
-
-  foreach (get_pwg_themes() as $pwg_template)
-  {
-    if ($assoc_ThemeChanger[$_GET['id_cat']]['TEMPLATE'] == $pwg_template)
-    {
-      $selected = 'selected="selected"';
-    }
-    else
-    {
-      $selected = '';
-    }
-
-	$template->assign(
-      $blockname,
-      array(
-        'VALUE'=> $pwg_template,
-        'CONTENT' => $pwg_template,
-        'SELECTED' => $selected
-        ));
-  }
 }
 
@@ -237,52 +176,18 @@
 else if ( isset($_GET['action']) and ($_GET['action']=='add_assoc') )
 {
-	//$template->assign_var('formulaire',array(
-	$template->assign(
-		'formulaire',
-		array('DESCRIPION' => $lang['add_assoc'],
-		)
-	);
-
-	$template->assign('formulaire.categorylist', array());
-	$blockname = 'formulaire.categorylist.parent_option';
-
-  $template->assign($blockname, array());
-
-
-  $query = '
-    SELECT id, name, uppercats, global_rank
-    FROM '.CATEGORIES_TABLE.'
-  ';
-  if (!empty($catsused))
-  {
-    $query .= '
-      WHERE id NOT IN ('.implode(',', $catsused).')
-    ';
-  }
-  $query .= ' ;';
-  display_select_cat_wrapper($query, array(), $blockname);
-
-  $blockname = 'formulaire.template_option';
-
-  foreach (get_pwg_themes() as $pwg_template)
-  {
-	$template->assign(
-      $blockname,
-      array(
-        'VALUE'=> $pwg_template,
-        'CONTENT' => $pwg_template,
-        'SELECTED' => '',
-      )
-    );
-  }
-}
-
+	$template->assign('formulaire',	array(
+		'DESCRIPION' => $lang['add_assoc'],
+	));
+}
+
+
+//needed to relaod the good configuration after delete
 $conf_nbc_ThemeChanger = isset($conf['nbc_ThemeChanger']) ? explode(";" , $conf['nbc_ThemeChanger']) : array();
 
 $num = 0;
 $catsused = array();
-$assoc_ThemeChanger = array();
 $assoc = array();
 
+//reconstruction du tableau d'association.
 foreach ($conf_nbc_ThemeChanger as $Theme_Cat)
 {
@@ -304,24 +209,20 @@
      array_push($assoc , array(
         'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1',
-        'CATEGORY_NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
-        'CATEGORY_ID'   => $element_ThemeChanger[0],
-        'TEMPLATE' => $element_ThemeChanger[1],
+        'CATEGORY_NAME'	=> get_cat_display_name_cache($row['uppercats'], null, false),
+        'CATEGORY_ID'	=> $element_ThemeChanger[0],
+        'TEMPLATE'		=> my_get_pwg_themeName($element_ThemeChanger[1]),
         'U_MODIFY'      => add_url_params($page_ThemeChanger_admin, array(
-          'action' => 'mod_assoc',
-          'id_cat' => $element_ThemeChanger[0],
-          )),
-        'U_DELETE'      => add_url_params($page_ThemeChanger_admin, array(
-          'action' => 'del_assoc',
-          'id_cat' => $element_ThemeChanger[0],
-          )),));
-
-    $assoc_ThemeChanger[$element_ThemeChanger[0]] = array(
-      'CATEGORY_NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
-      'TEMPLATE' => $element_ThemeChanger[1],
-    );
+			'action'		=> 'mod_assoc',
+			'id_cat'		=> $element_ThemeChanger[0],
+			'id_theme'		=> $element_ThemeChanger[1],
+        )),
+        'U_DELETE'		=> add_url_params($page_ThemeChanger_admin, array(
+			'action'		=> 'del_assoc',
+			'id_cat'		=> $element_ThemeChanger[0],
+		)),
+	));
   }
 }
-$template->assign(
-      'assoc',$assoc );
+$template->assign('assoc',$assoc );
 
 
Index: extensions/nbc_ThemeChanger/admin/nbc_ThemeChanger_admin.tpl
===================================================================
--- extensions/nbc_ThemeChanger/admin/nbc_ThemeChanger_admin.tpl	(revision 6553)
+++ extensions/nbc_ThemeChanger/admin/nbc_ThemeChanger_admin.tpl	(revision 6573)
@@ -3,5 +3,5 @@
 </div>
 <ul class="categoryActions">
-	<li><a href="{$params.U_HELP}" onclick="popuphelp(this.href); return false;" title="{'HELP'|@translate}"><img src="{$themeconf.icon_dir}/help.png" class="button" alt="(?)"></a></li>
+	<!--li><a href="{$params.U_HELP}" onclick="popuphelp(this.href); return false;" title="{'HELP'|@translate}"><img src="{$themeconf.icon_dir}/help.png" class="button" alt="(?)"></a></li-->
 </ul>
 
@@ -62,5 +62,11 @@
 			<!-- BEGIN template_option -->
 			{foreach from=$params.Themes item=Themes key=i}
-				<option value="{$Themes}" {$Themes}>{$Themes}</option>
+			{if ($formulaire.THEMETOMODIFY==$Themes.id)}
+					<option value="{$Themes.id}" selected ="selected">{$Themes.name}</option>
+					
+				{else}
+					<option value="{$Themes.id}" {$Themes.id}>{$Themes.name}</option>
+				{/if}
+				
             {/foreach}
 			<!-- END template_option -->
Index: extensions/nbc_ThemeChanger/include/functions_ThemeChanger.inc.php
===================================================================
--- extensions/nbc_ThemeChanger/include/functions_ThemeChanger.inc.php	(revision 6573)
+++ extensions/nbc_ThemeChanger/include/functions_ThemeChanger.inc.php	(revision 6573)
@@ -0,0 +1,158 @@
+<?php
+function get_My_categories_menu($id_niveau_parent)
+{
+  global $page, $user, $filter;
+
+  $query = '
+SELECT ';
+  // From CATEGORIES_TABLE
+  $query.= '
+  id, name, permalink, nb_images, global_rank,';
+  // From USER_CACHE_CATEGORIES_TABLE
+  $query.= '
+  date_last, max_date_last, count_images, count_categories, uppercats';
+
+  // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
+  $query.= '
+FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
+  ON id = cat_id and user_id = '.$user['id'];
+
+  // Always expand when filter is activated
+  if (!$user['expand'] and !$filter['enabled'])
+  {
+    $where = '
+(id_uppercat is NULL';
+    if (isset($page['category']))
+    {
+      $where .= ' OR id_uppercat IN ('.$page['category']['uppercats'].')';
+    }
+    $where .= ')';
+  }
+  else
+  {
+    $where = '
+  '.get_sql_condition_FandF
+    (
+      array
+        (
+          'visible_categories' => 'id',
+        ),
+      null,
+      true
+    );
+  }
+
+  $where = trigger_event('get_categories_menu_sql_where',
+    $where, $user['expand'], $filter['enabled'] );
+
+  $query.= '
+WHERE '.$where.'
+;';
+
+  $result = pwg_query($query);
+  $cats = array();
+  while ($row = mysql_fetch_assoc($result))
+  {
+	$tmp = explode("," , $row['uppercats']);
+	if (in_array ($id_niveau_parent, $tmp))
+		array_push($cats, $row);
+    if ($row['id']==@$page['category']['id']) //save the number of subcats for later optim
+      $page['category']['count_categories'] = $row['count_categories'];
+  }
+  usort($cats, 'global_rank_compare');
+
+  // Update filtered data
+  if (function_exists('update_cats_with_filtered_data'))
+  {
+    update_cats_with_filtered_data($cats);
+  }
+
+  return get_html_menu_category($cats, @$page['category'] );
+}
+
+
+function my_get_pwg_themeName ($themeId)
+{
+	$themes = my_get_pwg_themes();
+	$i_themeName = 0;
+	while (($tmp = $themes[$i_themeName]['id'])<> $themeId)
+	{$i_themeName++;}
+	
+	if (ISSET($themes[$i_themeName]))
+		return $themes[$i_themeName]['name'];
+		else return  '0';
+}
+
+
+
+function my_get_pwg_themes()
+{
+  global $conf;
+
+  $themes = array();
+
+  $query = '
+SELECT
+    id,
+    name
+  FROM '.THEMES_TABLE.'
+  ORDER BY name ASC
+;';
+  $result = pwg_query($query);
+  $i_themes = 0;
+  while ($row = pwg_db_fetch_assoc($result))
+  {
+    if (check_theme_installed($row['id']))
+    {
+		$themes[$i_themes]['id'] =  $row['id'] ;
+		$themes[$i_themes]['name'] = $row['name'];
+		
+		  $i_themes =$i_themes + 1;
+    }
+  }
+  return $themes;
+}
+
+function  my_get_pwg_categories()
+{
+$cat=array();
+$categories = array();
+
+
+//chargement des catégories
+ $query = '
+    SELECT id, name, uppercats, global_rank
+    FROM '.CATEGORIES_TABLE.' ;
+  ';
+   $result = pwg_query($query);
+
+   while (($cat = mysql_fetch_array($result)) <> null)
+   {
+   array_push($categories , array("id" => $cat['id'],
+				"name" => $cat['name'],
+				"uppercats" =>$cat['uppercats'],
+				"longName" => get_cat_display_name_cache($cat['uppercats'], null, false),
+				"global_rank" => $cat['global_rank'],
+				));
+		}
+return $categories;
+}
+
+function get_long_categorie_name($id_cat)
+{
+	$categories = my_get_pwg_categories();
+	
+	$cat=array();
+	
+	   while ($cat = array_shift($categories ))
+	   {
+			if ($cat['id'] == $id_cat)
+			{
+				return $cat['longName'];
+			}
+	   }
+	
+return 'Failed';
+}
+
+?>
Index: extensions/nbc_ThemeChanger/include/functions_admin_ThemeChanger.inc.php
===================================================================
--- extensions/nbc_ThemeChanger/include/functions_admin_ThemeChanger.inc.php	(revision 6573)
+++ extensions/nbc_ThemeChanger/include/functions_admin_ThemeChanger.inc.php	(revision 6573)
@@ -0,0 +1,232 @@
+<?php
+class c_ThemeChangerConfig {
+	// Déclarations des données membres
+
+	var  $categorySize;
+	
+	function SetcategorySize($categorySize){
+	$this->categorySize = $categorySize;
+	}
+
+
+	var  $categories;
+	
+	function Setcategories($categories){
+	$this->categories = $categories;
+	}
+	
+	var $themes ;
+	function Setthemes($themes){
+	$this->themes = $themes;
+	}
+	var $listcategoryParamThemeChanger ;
+	function SetlistcategoryParamThemeChanger($listcategoryParamThemeChanger){
+	$this->listcategoryParamThemeChanger = $listcategoryParamThemeChanger;
+	}
+	
+	var $applysubcategory;
+	function Setapplysubcategory($applysubcategory){
+	$this->applysubcategory = $applysubcategory;
+	}	
+		
+	var $thecategory;
+	function Setthecategory($thecategory){
+	$this->thecategory = $thecategory;
+	}
+	var $nomGalerie;
+	function SetnomGalerie($nomGalerie){
+	$this->nomGalerie = $nomGalerie;
+	}
+	var $OverWriteHome;
+	function SetOverWriteHome($OverWriteHome){
+	$this->OverWriteHome = $OverWriteHome;
+	}
+	var $titreGalerie;
+	function SettitreGalerie($titreGalerie){
+	$this->titreGalerie = $titreGalerie;
+	}
+	
+	function get_categories ()
+	{			
+		if (ISSET($this->categories))
+			return $this->categories;
+		$this->categorySize = 0;
+		$cat=array();
+		$categoriesTmp = array();
+
+		//chargement des catégories
+		$query = '
+			SELECT id, name, uppercats, global_rank
+			FROM '.CATEGORIES_TABLE.' ;
+			';
+		$result = pwg_query($query);
+
+		while (($cat = mysql_fetch_array($result)) <> null)
+		{
+			array_push($categoriesTmp , array("id" => $cat['id'],
+				"name" => $cat['name'],
+				"uppercats" =>$cat['uppercats'],
+				"longName" => get_cat_display_name_cache($cat['uppercats'], null, false),
+				"global_rank" => $cat['global_rank'],
+				));
+				$this->categorySize = $this->categorySize + 1;
+		}
+		$cat = array();
+		$this->Setcategories($categoriesTmp);
+		return $categoriesTmp;
+	}
+	
+	function get_categoriesLongName($id)
+	{
+		$i = 0;
+		$length = $this->categorySize;
+		
+		while ($i < $length) {
+			if ($id == $this->categories[$i]['id'])
+				return $this->categories[$i]['longName'];
+			$i = $i + 1;
+		}
+		return '';
+	}
+	
+	
+	function get_themes()
+	{
+		if (ISSET($this->themes))
+			return $this->themes;
+
+		$themesTmp = array();
+		foreach (get_pwg_themes() as $pwg_template)
+		{
+			$selected = $pwg_template;
+			array_push($themesTmp, $selected);
+		}
+		$this->Setthemes($themesTmp);
+		return $themesTmp;
+	}	
+	function initThemeChanger ($thecategory, $nomGalerie, $titreGalerie, $applysubcategory, $OverWriteHome)
+	{
+	
+		if (ISSET($this->listcategoryParamThemeChanger))
+			return $this->listcategoryParamThemeChanger;
+
+		$listcategoryParamThemeChangerTmp = array();
+		
+		if ($applysubcategory <> 'false') {
+			foreach ($this->categories as $icat) {
+				$tmp = explode("," , $icat['uppercats']);
+				if (in_array ($thecategory, $tmp))
+					array_push($listcategoryParamThemeChangerTmp ,array('id' => $icat['id'], 'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory)); // ajout pour la gestion du menu categorie
+			}
+		}
+		else
+		{
+			$icat = get_cat_info($thecategory);
+			$tmp = explode("," , $icat['uppercats']);
+			array_push($listcategoryParamThemeChangerTmp ,array('id' => $thecategory, 'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory));
+		}
+		$this->listcategoryParamThemeChanger = $listcategoryParamThemeChangerTmp;
+		return $this->listcategoryParamThemeChanger;
+	}
+}
+
+class c_ThemeChanger {
+
+	var $separator = '|';
+
+	var $listcategoryParamThemeChanger ;
+	function SetlistcategoryParamThemeChanger($listcategoryParamThemeChanger){
+		$this->listcategoryParamThemeChanger = $listcategoryParamThemeChanger;
+	}
+	
+	var $newconf_nbc_ThemeChanger = '';
+	function Setnewconf_nbc_ThemeChanger($newconf_nbc_ThemeChanger){
+		$this->newconf_nbc_ThemeChanger = $newconf_nbc_ThemeChanger;
+	}
+
+	
+	function Get_newconf_nbc_ThemeChanger()
+	{
+		if (ISSET($this->newconf_nbc_ThemeChanger))
+			return $this->newconf_nbc_ThemeChanger;
+		else return '';
+	}
+	
+	
+	function initThemeChanger ($thecategory, $theme, $nomGalerie, $titreGalerie, $applysubcategory, $OverWriteHome)
+	{
+		if (ISSET($this->listcategoryParamThemeChanger))
+			return $this->listcategoryParamThemeChanger;
+
+			
+		$c_ThemeChangerConf = new c_ThemeChangerConfig();
+		$categories = $c_ThemeChangerConf->get_categories();
+		
+		$listcategoryParamThemeChangerTmp = array();
+		$newconf_nbc_ThemeChanger = '';
+		
+		if ($applysubcategory <> 'false') {
+			foreach ($categories as $icat) {
+				$tmp = explode("," , $icat['uppercats']);
+				if (in_array ($thecategory, $tmp))
+					array_push($listcategoryParamThemeChangerTmp ,array('id' => $icat['id'], 'template' =>$theme[0], 'theme' => $theme[1],'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory)); // ajout pour la gestion du menu categorie
+			}
+		}
+		else
+		{
+			$icat = get_cat_info($thecategory);
+			$tmp = explode("," , $icat['uppercats']);
+			array_push($listcategoryParamThemeChangerTmp ,array('id' => $thecategory,  'template' =>$theme[0], 'theme' => $theme[1], 'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory));
+		}
+		$this->listcategoryParamThemeChanger = $listcategoryParamThemeChangerTmp;
+		return $this->listcategoryParamThemeChanger;
+	}
+	
+	function InsertEndAssocConf($id, $tpl, $thm, $cat, $name, $title, $overHome, $appSubCat){
+		if ($this->newconf_nbc_ThemeChanger <> '' and $this->newconf_nbc_ThemeChanger [strlen($this->newconf_nbc_ThemeChanger )-1] <> $this->separator)
+			$this->newconf_nbc_ThemeChanger .= $this->separator;
+		$this->newconf_nbc_ThemeChanger .= $id.','.$tpl.','.$thm.','.$cat.','.$name.','.$title.','.$overHome.','.$appSubCat;
+		return 1;
+	}
+	
+	function AddAssocConf ($conf_nbc_ThemeChanger) {
+		foreach ($conf_nbc_ThemeChanger as $Theme_Cat)
+		{
+			$add_ok = false;
+			$element_ThemeChanger = explode("," , $Theme_Cat);
+			$i = 0;
+			foreach ($this->listcategoryParamThemeChanger as $thecategory)
+			{
+				if ($element_ThemeChanger[0] == $thecategory['id']) //MAJ de la configuration d'une categorie déjà présente dans la liste
+				{
+					//echo ' MAJ: '.$element_ThemeChanger[0];
+					$this->InsertEndAssocConf($thecategory['id'],$thecategory['template'],$thecategory['theme'],$thecategory['Parent'],$thecategory['nomGalerie'],$thecategory['titreGalerie'],$thecategory['OverWriteHome'],$thecategory['applysubcategory']);
+					$this->listcategoryParamThemeChanger[$i]['id'] = -1;
+					$add_ok = true;
+					break;
+				}
+				$i += 1;
+			}
+			if ($add_ok == false and  $element_ThemeChanger[0] <> ''){//récupération des catégories qui n'ont pas été modifié.
+				//echo ' Recup : '.$element_ThemeChanger[0];
+					$this->InsertEndAssocConf($element_ThemeChanger[0], $element_ThemeChanger[1], $element_ThemeChanger[2], $element_ThemeChanger[3], $element_ThemeChanger[4], $element_ThemeChanger[5], $element_ThemeChanger[6], $element_ThemeChanger[7]);
+				}
+			}
+		
+		foreach ($this->listcategoryParamThemeChanger as $thecategory) {//insertion des nouvelles catégories
+			//echo ' Nouveau: '.$thecategory['id'];
+			if ($thecategory['id'] <> -1)
+				$this->InsertEndAssocConf($thecategory['id'],$thecategory['template'],$thecategory['theme'], $thecategory['Parent'], $thecategory['nomGalerie'], $thecategory['titreGalerie'], $thecategory['OverWriteHome'], $thecategory['applysubcategory']);
+			$listcategoryParamThemeChanger[$i]['id'] = -1;
+		}
+		return 1;
+	}
+	
+	function DeleteAssocConf () {
+	
+	}
+	
+	
+}
+
+?>
Index: extensions/nbc_ThemeChanger/main.inc.php
===================================================================
--- extensions/nbc_ThemeChanger/main.inc.php	(revision 6553)
+++ extensions/nbc_ThemeChanger/main.inc.php	(revision 6573)
@@ -2,7 +2,7 @@
 /*
 Plugin Name: NBC ThemeChanger
-Version: 2.1.0.a
+Version: 2.1.0.B
 Description: Permet d'associer à chaque catégorie virtuel ou physique un thème spécifique.
-	ThemeChanger vous permet de spécifier pour chaque catégorie un thème différent.
+	ThemeChanger vous permet de spécifier pour chaque catérie un thème différent.
 	Pour les catégories non spécifiées, le thème par défaut s'applique.
 	ThemeChanger allow you to associate for each category a specific theme. 
@@ -17,7 +17,8 @@
 define('NBC_ThemeChanger_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
 
-//if (!defined(NBC_ThemeChanger_PATH)) die('Hacking attempt - ThemeChanger main.inc.php - NBC_ThemeChanger_PATH!');
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
 /* Set the administration panel of the plugin */
+
 
 class ThemeChanger
@@ -57,5 +58,6 @@
   {
     $user['theme'] = $category_theme[$page['category']['id']];
-	$template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme'] );
+	
+	$template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']);
   }
 }
