Index: /extensions/Random_Header/admin/rh_admin.php
===================================================================
--- /extensions/Random_Header/admin/rh_admin.php	(revision 7133)
+++ /extensions/Random_Header/admin/rh_admin.php	(revision 7134)
@@ -2,31 +2,35 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
+global $template;
 $me = get_plugin_data($plugin_id);
-global $template;
+include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
+
 
 $template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/rh_admin.tpl') );
-$template->assign( 'RH_VERSION' , RH_VERSION );
+$rhthemes = new themes();
 
-foreach (str_replace(" ", "_", get_pwg_themes()) as $pwg_template) {
+
+foreach (get_pwg_themes() as  $pwg_templateID => $pwg_template) {
 	if (isset($_POST['submit'])) {
-		$me->rh_config[$pwg_template]['selected_cat'] 		= $_POST[$pwg_template.'selected_cat'];
-		$me->rh_config[$pwg_template]['active_on_picture'] 	= (isset( $_POST[$pwg_template.'active_on_picture'] )) ? $_POST[$pwg_template.'active_on_picture'] : 'off' ; 
-		$me->rh_config[$pwg_template]['concat_before'] 		= (isset( $_POST[$pwg_template.'concat_before'] )) ? $_POST[$pwg_template.'concat_before'] : 'off' ; 
-		$me->rh_config[$pwg_template]['concat_after'] 		= (isset( $_POST[$pwg_template.'concat_after'] )) ? $_POST[$pwg_template.'concat_after'] : 'off' ; 
-		$me->rh_config[$pwg_template]['head_css'] 			= $_POST[$pwg_template.'head_css']; 
-		$me->rh_config[$pwg_template]['img_css'] 			= $_POST[$pwg_template.'img_css']; 
-		$me->rh_config[$pwg_template]['mode_background'] 	= (isset( $_POST[$pwg_template.'mode_background'] )) ? $_POST[$pwg_template.'mode_background'] : 'off' ;
+		$me->rh_config[$pwg_templateID]['selected_cat'] 		= $_POST[$pwg_templateID.'selected_cat'];
+		$me->rh_config[$pwg_templateID]['active_on_picture'] 	= (isset( $_POST[$pwg_templateID.'active_on_picture'] )) ? $_POST[$pwg_templateID.'active_on_picture'] : 'off' ; 
+		$me->rh_config[$pwg_templateID]['concat_before'] 		= (isset( $_POST[$pwg_templateID.'concat_before'] )) ? $_POST[$pwg_templateID.'concat_before'] : 'off' ; 
+		$me->rh_config[$pwg_templateID]['concat_after'] 		= (isset( $_POST[$pwg_templateID.'concat_after'] )) ? $_POST[$pwg_templateID.'concat_after'] : 'off' ; 
+		$me->rh_config[$pwg_templateID]['head_css'] 			= $_POST[$pwg_templateID.'head_css']; 
+		$me->rh_config[$pwg_templateID]['img_css'] 				= $_POST[$pwg_templateID.'img_css']; 
+		$me->rh_config[$pwg_templateID]['mode_background'] 		= (isset( $_POST[$pwg_templateID.'mode_background'] )) ? $_POST[$pwg_templateID.'mode_background'] : 'off' ;
 		$me->save_config();
 	}
 	
-	$template->append('themes', array(
-				'CURRENT_THEME' 	=> $pwg_template,
-				'ACTIVE_ON_PICTURE' => ($me->rh_config[$pwg_template]['active_on_picture']=='on') ? 'checked' : '',
-				'MODE_BACKGROUND' 	=> ($me->rh_config[$pwg_template]['mode_background']=='on') ? 'checked' : '',
-				'CONCAT_BEFORE' 	=> ($me->rh_config[$pwg_template]['concat_before']=='on') ? 'checked' : '',
-				'CONCAT_AFTER' 		=> ($me->rh_config[$pwg_template]['concat_after']=='on') ? 'checked' : '',
-				'HEAD_CSS' 			=>  $me->rh_config[$pwg_template]['head_css'],
-				'IMG_CSS' 			=>  $me->rh_config[$pwg_template]['img_css'],
-				'CATSELECTED' 		=>  $me->rh_config[$pwg_template]['selected_cat']
+	$template->append('rhthemes', array(
+				'CURRENT_THEME_NAME'=> $pwg_template,
+				'CURRENT_THEME_ID' 	=> $pwg_templateID,
+				'ACTIVE_ON_PICTURE' => ($me->rh_config[$pwg_templateID]['active_on_picture']=='on') ? 'checked' : '',
+				'MODE_BACKGROUND' 	=> ($me->rh_config[$pwg_templateID]['mode_background']=='on') ? 'checked' : '',
+				'CONCAT_BEFORE' 	=> ($me->rh_config[$pwg_templateID]['concat_before']=='on') ? 'checked' : '',
+				'CONCAT_AFTER' 		=> ($me->rh_config[$pwg_templateID]['concat_after']=='on') ? 'checked' : '',
+				'HEAD_CSS' 			=>  $me->rh_config[$pwg_templateID]['head_css'],
+				'IMG_CSS' 			=>  $me->rh_config[$pwg_templateID]['img_css'],
+				'CATSELECTED' 		=>  $me->rh_config[$pwg_templateID]['selected_cat']
 				));
 }
@@ -37,6 +41,9 @@
 	  'categories'
 	  );
+	  
 load_language('plugin.lang', RH_PATH);
 
+  
+  
 $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
 ?>
Index: /extensions/Random_Header/admin/rh_admin.tpl
===================================================================
--- /extensions/Random_Header/admin/rh_admin.tpl	(revision 7133)
+++ /extensions/Random_Header/admin/rh_admin.tpl	(revision 7134)
@@ -1,28 +1,25 @@
-<div class="titrePage"><h2>Random Header<br />{$RH_VERSION}</h2></div>
+{html_head}<style type="text/css">
+.randomHeader_fieldset legend{ldelim}color:#ff3363;font-weight:bold;}
+.randomHeader_fieldset{ldelim}width:345px;float:left;overflow-x:auto;padding:5px;margin:3px;}
+.rh_input{ldelim}width:335px;}
+
+.themeBox {ldelim}
+display: block;
+width: 185px;
+}
+</style>{/html_head}
+<div class="titrePage"><h2>Random Header v2.1</h2></div>
 <p>{'rh_description'|@translate}</p>
 <p><i>{'rh_aide'|@translate}</i></p>
 <form method="post" action="" class="properties">
-<style>
-.randomHeader_fieldset legend{ldelim}color:#ff3363;font-weight:bold;}
-.randomHeader_fieldset{ldelim}
-	width:345px;
-	overflow-x:auto;
-	float:left;
-	padding: 5px;
-	margin: 3px;
-}#ff3363
-.rh_input{ldelim}
-	width:335px;
-}
-</style>
-{foreach from=$themes item=i}
+
+{foreach from=$rhthemes item=i}
     <fieldset class="randomHeader_fieldset">
 			
-			<legend>{'rh_theme'|@translate} : {$i.CURRENT_THEME}</legend>
-			
+			<legend>{'rh_theme'|@translate} : {$i.CURRENT_THEME_NAME}</legend>
 			<p>
 			<label>
 		      {'rh_headers_category'|@translate}<br />
-		      <select class="categoryDropDown" name="{$i.CURRENT_THEME}selected_cat">
+		      <select class="categoryDropDown" name="{$i.CURRENT_THEME_ID}selected_cat">
 		        <option value="0">{'rh_inactif'|@translate}</option>
 		        {html_options options=$categories selected=$i.CATSELECTED}
@@ -32,10 +29,10 @@
 			
 			<p>
-			<input type="checkbox" {$i.MODE_BACKGROUND} name="{$i.CURRENT_THEME}mode_background">
+			<input type="checkbox" {$i.MODE_BACKGROUND} name="{$i.CURRENT_THEME_ID}mode_background">
 			<label>{'rh_as_background'|@translate}</label>
 			</p>
 			
 			<p>
-			<input type="checkbox" {$i.ACTIVE_ON_PICTURE} name="{$i.CURRENT_THEME}active_on_picture">
+			<input type="checkbox" {$i.ACTIVE_ON_PICTURE} name="{$i.CURRENT_THEME_ID}active_on_picture">
 			<label>{'rh_on_picture'|@translate}</label>
 			</p>
@@ -44,11 +41,11 @@
 			<label>{'rh_additional_css'|@translate} :<br /></label>
 			<i>#theHeader :</i><br />
-			<input class="rh_input" type="text" name="{$i.CURRENT_THEME}head_css" value="{$i.HEAD_CSS}"><br />
-			<i>#RandomImage : {'rh_inactif_on_bg'|@translate}</i><br /><input class="rh_input"  type="text" name="{$i.CURRENT_THEME}img_css" value="{$i.IMG_CSS}"><br />
+			<input class="rh_input" type="text" name="{$i.CURRENT_THEME_ID}head_css" value="{$i.HEAD_CSS}"><br />
+			<i>#RandomImage : {'rh_inactif_on_bg'|@translate}</i><br /><input class="rh_input"  type="text" name="{$i.CURRENT_THEME_ID}img_css" value="{$i.IMG_CSS}"><br />
 			</p>
 			
 			<p>
 			<label>{'rh_concat'|@translate} :<br /></label>
-			{'rh_before'|@translate} : <input type="checkbox" {$i.CONCAT_BEFORE} name="{$i.CURRENT_THEME}concat_before"> {'rh_after'|@translate} : <input type="checkbox" {$i.CONCAT_AFTER} name="{$i.CURRENT_THEME}concat_after">
+			{'rh_before'|@translate} : <input type="checkbox" {$i.CONCAT_BEFORE} name="{$i.CURRENT_THEME_ID}concat_before"> {'rh_after'|@translate} : <input type="checkbox" {$i.CONCAT_AFTER} name="{$i.CURRENT_THEME_ID}concat_after">
 			</p>
 			
@@ -57,3 +54,2 @@
 <div align="center" style="clear:left"><input class="submit" type="submit" value="{'rh_submit'|@translate}" name="submit" /></div>
 </form>
-
Index: /extensions/Random_Header/language/en_UK/description.txt
===================================================================
--- /extensions/Random_Header/language/en_UK/description.txt	(revision 7134)
+++ /extensions/Random_Header/language/en_UK/description.txt	(revision 7134)
@@ -0,0 +1,1 @@
+Random Header allow you to show in the header a random picture from the choosen categorie, as a normal image, or as a background
Index: /extensions/Random_Header/language/fr_FR/description.txt
===================================================================
--- /extensions/Random_Header/language/fr_FR/description.txt	(revision 7134)
+++ /extensions/Random_Header/language/fr_FR/description.txt	(revision 7134)
@@ -0,0 +1,1 @@
+Permet d'afficher dans l'en-tête une image au hasard parmi la catégorie que vous aurez choisi, soit en image normale, soit en image de fond.
Index: /extensions/Random_Header/language/it_IT/description.txt
===================================================================
--- /extensions/Random_Header/language/it_IT/description.txt	(revision 7134)
+++ /extensions/Random_Header/language/it_IT/description.txt	(revision 7134)
@@ -0,0 +1,1 @@
+Permette di pubblicare nel header una fotografia a caso dalla categoria scelta, in modo normale o in immagine di fondo
Index: /extensions/Random_Header/main.inc.php
===================================================================
--- /extensions/Random_Header/main.inc.php	(revision 7133)
+++ /extensions/Random_Header/main.inc.php	(revision 7134)
@@ -2,51 +2,36 @@
 /*
 Plugin Name: Random Header
-Version: 2.0.e
+Version: 2.1
 Description: Random Header allow you to show in the header a random picture from the choosen categorie, as a normal image, or as a background
-Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=188
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=188
 Author: repie38
-Author URI: http://www.pierre-b.com
+Author URI: 
 */
 
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-DEFINE('RH_VERSION','v2.0.e');
+DEFINE('RH_VERSION','v2.1');
 define('RH_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
-
-if (! function_exists('get_file_contents')) {
-  function get_file_contents($url, $totalTries = 5)
-	 {
-		$Tries = 0;
-		do
-		 {
-				if ($Tries > 0) sleep(1); # Wait for a sec before retrieving again
-				$contents = @file_get_contents($url);
-				$Tries++;
-		 } while ($Tries <= $totalTries && $contents === FALSE);
-		 if ($contents == "") $contents = FALSE;
-		 return $contents;
-	 }
-}
 
 class RandomHeader
 {
-    var $rh_config;
-	
+	 var $rh_config;
 	function load_config()
     {
-        $x = get_file_contents( dirname(__FILE__).'/data.dat' );
+        $x = file_get_contents( dirname(__FILE__).'/data.dat' );
 		
         if ($x!==false)
         	$this->rh_config = unserialize($x);
 
-        	foreach (str_replace(" ", "_", get_pwg_themes()) as $pwg_template) {
-			  if (empty($this->rh_config[$pwg_template]['selected_cat']))  {
+        	foreach (get_pwg_themes() as $pwg_templateID => $pwg_template) {
+        	
+			  if (empty($this->rh_config[$pwg_templateID]['selected_cat']))  {
 
-				$this->rh_config[$pwg_template]['selected_cat'] = '0';
-            	$this->rh_config[$pwg_template]['active_on_picture']='off';
-				$this->rh_config[$pwg_template]['head_css']='';
-				$this->rh_config[$pwg_template]['img_css']='';
-				$this->rh_config[$pwg_template]['mode_background']='off';
-				$this->rh_config[$pwg_template]['concat_before'] ='off' ;
-				$this->rh_config[$pwg_template]['concat_after'] ='off' ;
+				$this->rh_config[$pwg_templateID]['selected_cat'] = '0';
+            	$this->rh_config[$pwg_templateID]['active_on_picture']='off';
+				$this->rh_config[$pwg_templateID]['head_css']='';
+				$this->rh_config[$pwg_templateID]['img_css']='';
+				$this->rh_config[$pwg_templateID]['mode_background']='off';
+				$this->rh_config[$pwg_templateID]['concat_before'] ='off' ;
+				$this->rh_config[$pwg_templateID]['concat_after'] ='off' ;
 
             	$this->save_config();
@@ -55,4 +40,7 @@
 
     }
+	
+	
+	
     function save_config()
     {
@@ -61,14 +49,13 @@
         fclose( $file );
     }
-    function plugin_admin_menu($menu)
-    {
-        array_push($menu,
-            array(
-                'NAME' => 'Random Header',
-                'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/rh_admin.php')
-            ));
-        return $menu;
-    }
-
+	
+	function plugin_admin_menu($menu)
+	{
+		array_push($menu,array(
+				'NAME' => 'Random Header',
+				'URL'  => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/rh_admin.php')));
+		return $menu;
+	}
+	
 	function randombanner(){
 		global $page;
@@ -76,5 +63,7 @@
 		global $conf;
 		global $user;
-		$usertheme=str_replace(" ", "_", $user['template'].'/'.$user['theme'] );
+		
+		$usertheme=$user['theme'] ;
+
 		if ( !defined('IN_ADMIN') && isset($page['body_id']) && ($page['body_id']!='thePicturePage' || $this->rh_config[$usertheme]['active_on_picture']=='on') ) {
 
@@ -97,9 +86,8 @@
 	}
 
+}
 
-}
 $obj = new RandomHeader();
 $obj->load_config();
-
 add_event_handler('loc_begin_page_header', array(&$obj, 'randombanner') );
 add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') );
