Index: /extensions/ContestResults/admin/config.php
===================================================================
--- /extensions/ContestResults/admin/config.php	(revision 6781)
+++ /extensions/ContestResults/admin/config.php	(revision 6782)
@@ -8,10 +8,10 @@
 	$user_config = array(
 		'menubar_mode' => array(
-			'link' => ($_POST['menubar_mode_link']) ? 1 : 0,
-			'block' => ($_POST['menubar_mode_block']) ? 1 : 0
+			'link' => (isset($_POST['menubar_mode_link'])) ? 1 : 0,
+			'block' => (isset($_POST['menubar_mode_block'])) ? 1 : 0
 		),
 		'menubar_link' => array(
-			'menu' => ($_POST['menubar_link_menu']) ? 1 : 0,
-			'specials' => ($_POST['menubar_link_specials']) ? 1 : 0
+			'menu' => (isset($_POST['menubar_link_menu'])) ? 1 : 0,
+			'specials' => (isset($_POST['menubar_link_specials'])) ? 1 : 0
 		),
 		'menubar_block' => array(
Index: /extensions/ContestResults/admin/get_tn.php
===================================================================
--- /extensions/ContestResults/admin/get_tn.php	(revision 6782)
+++ /extensions/ContestResults/admin/get_tn.php	(revision 6782)
@@ -0,0 +1,23 @@
+<?php
+define('PHPWG_ROOT_PATH','../../../');
+define('IN_ADMIN', true);
+include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
+
+$query = "SELECT id, name, file, path, tn_ext
+	FROM " . IMAGES_TABLE . "
+	WHERE id = " . pwg_db_real_escape_string($_GET['image_id']) . ";";
+$image = pwg_query($query);
+
+if(!pwg_db_num_rows($image)){
+	$themeconf = $template->get_template_vars('themeconf');
+	$data['TN_SRC'] = $themeconf['admin_icon_dir'] . '/errors.png';
+	$data['IMAGE_NAME'] = 'N/A';
+}else{
+	$image = pwg_db_fetch_assoc($image);
+	$data['TN_SRC'] = get_thumbnail_url($image);
+	$data['IMAGE_NAME'] = (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'];
+}
+
+echo "<img src='" . str_replace('../../.', '', $data['TN_SRC']) . "'/><br>" . $data['IMAGE_NAME'];
+
+?>
Index: /extensions/ContestResults/admin/new.php
===================================================================
--- /extensions/ContestResults/admin/new.php	(revision 6781)
+++ /extensions/ContestResults/admin/new.php	(revision 6782)
@@ -11,6 +11,6 @@
 	// Pour les quatre zones de texte crée un tableau définissant le mode d'affichage
 	foreach($textareas AS $key){
-		if(isset($_POST[$key.'_pending'])) $_POST[$key.'_display']['pending'] = true; else $_POST[$key.'_display']['pending'] = false;
-		if(isset($_POST[$key.'_finished'])) $_POST[$key.'_display']['finished'] = true; else $_POST[$key.'_display']['finished'] = false;
+		$_POST[$key.'_display']['pending'] = (isset($_POST[$key.'_pending'])) ? true : false;
+		$_POST[$key.'_display']['finished'] = (isset($_POST[$key.'_finished'])) ? true : false;
 		$_POST[$key.'_display'] = serialize($_POST[$key.'_display']);
 	}
Index: /extensions/ContestResults/admin/results.php
===================================================================
--- /extensions/ContestResults/admin/results.php	(revision 6781)
+++ /extensions/ContestResults/admin/results.php	(revision 6782)
@@ -25,12 +25,4 @@
 
 // +-----------------------------------------------------------------------+
-//			Suppression d'un résultat
-// +-----------------------------------------------------------------------+
-if(isset($_GET['delete_result'])){
-	pwg_query('DELETE FROM ' . CR_TABLE_2 . ' WHERE contest_id = ' . $_GET['contest_id'] . ' AND image_id = ' . $_GET['delete_result'] . ';');
-	redirect(CR_ADMIN . '&tab=results&contest_id=' . $_GET['contest_id']);
-}
-
-// +-----------------------------------------------------------------------+
 // 			Affichage des résultats
 // +-----------------------------------------------------------------------+
@@ -46,11 +38,30 @@
 
 while($result = pwg_db_fetch_assoc($results)){
-	$template->append('results', array(
+	$data = array(
 		'RANK' => $result['rank'],
-		'ID' => $result['image_id'],
+		'IMAGE_ID' => $result['image_id'],
 		'AUTHOR' => $result['author'],
 		'COMMENT' => $result['comment'],
 		'U_DELETE' => CR_ADMIN . '&tab=results&contest_id=' . $_GET['contest_id'] . '&delete_result=' . $result['image_id'],
-	));
+	);
+	
+	// Infos de l'image
+	$query = "SELECT id, name, file, path, tn_ext
+		FROM " . IMAGES_TABLE . "
+		WHERE id = " . $result['image_id'] . ";";
+	$image = pwg_query($query);
+	
+	if(!pwg_db_num_rows($image)){
+		$themeconf = $template->get_template_vars('themeconf');
+		$data['TN_SRC'] = $themeconf['admin_icon_dir'] . '/errors.png';
+		$data['IMAGE_NAME'] = 'N/A';
+		$page['errors'][] = l10n_dec('CR_id_unknown %d', 'CR_id_unknown %d', $result['image_id']);
+	}else{
+		$image = pwg_db_fetch_assoc($image);
+		$data['TN_SRC'] = get_thumbnail_url($image);
+		$data['IMAGE_NAME'] = (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'];
+	}
+	
+	$template->append('results', $data);
 }
 
Index: /extensions/ContestResults/admin/template/config.tpl
===================================================================
--- /extensions/ContestResults/admin/template/config.tpl	(revision 6781)
+++ /extensions/ContestResults/admin/template/config.tpl	(revision 6782)
@@ -1,21 +1,23 @@
-{html_head}
-<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
-<style>
-	td {ldelim} width:300px; }
-</style>
-{/html_head}
-
 {known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
 
-<script type="text/javascript">
-	function ToggleConfig(sel, section){ldelim}
-		var obj = $('#config_'+section);
-		if(sel.checked){ldelim}
-			obj.slideDown("slow");
-		}else{ldelim}
-			obj.slideUp("slow");
+{html_head}
+	<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
+	<style>
+		tr td:first-child {ldelim} 
+			max-width:300px; 
+			min-width:300px;
 		}
-	}
-</script>
+	</style>
+	<script type="text/javascript">
+		function ToggleConfig(sel, section){ldelim}
+			var obj = $('#config_'+section);
+			if(sel.checked){ldelim}
+				obj.slideDown("slow");
+			}else{ldelim}
+				obj.slideUp("slow");
+			}
+		}
+	</script>
+{/html_head}
 
 <h2 style="float:right;top:-24px;position:relative;font-style:italic;margin-bottom:-20px;font-size:12px;font-weight:normal;">{$CR_VERSION}</h2>
@@ -33,5 +35,5 @@
 				<td>
 					<label><input type="checkbox" name="menubar_mode_link" value="true" onchange="ToggleConfig(this, 'link');" {$MODE_LINK}> {'CR_menubar_link'|@translate}</label>
-					<label><input type="checkbox" name="menubar_mode_block" value="true" onchange="ToggleConfig(this, 'block');" {$MODE_BLOCK}> {'CR_menubar_block'|@translate}</label>
+					<br><label><input type="checkbox" name="menubar_mode_block" value="true" onchange="ToggleConfig(this, 'block');" {$MODE_BLOCK}> {'CR_menubar_block'|@translate}</label>
 				</td>
 			</tr>
@@ -44,5 +46,5 @@
 				<td>
 					<label><input type="checkbox" name="menubar_link_menu" value="true" {$LINK_MENU}> {'Menu'|@translate}</label>
-					<label><input type="checkbox" name="menubar_link_specials" value="true" {$LINK_SPECIALS}> {'Specials'|@translate}</label>
+					<br><label><input type="checkbox" name="menubar_link_specials" value="true" {$LINK_SPECIALS}> {'Specials'|@translate}</label>
 				</td>
 			</tr>
Index: /extensions/ContestResults/admin/template/manage.tpl
===================================================================
--- /extensions/ContestResults/admin/template/manage.tpl	(revision 6781)
+++ /extensions/ContestResults/admin/template/manage.tpl	(revision 6782)
@@ -1,4 +1,4 @@
 {html_head}
-<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
+	<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
 {/html_head}
 
@@ -20,5 +20,5 @@
 			<ul class="categoryUl">
 				{foreach from=$contests_pending item=contest name=pending_loop}
-					<li class="categoryLi {if $smarty.foreach.pending_loop.index is odd}virtual_cat{/if} {if $contest.VISIBLE == 0}hidden{/if}">
+					<li class="categoryLi {if $smarty.foreach.pending_loop.index is odd}virtual_cat{/if} {if $contest.VISIBLE == 0}novisible{/if}">
 						<ul class="categoryActions">
 							<li>
Index: /extensions/ContestResults/admin/template/new.tpl
===================================================================
--- /extensions/ContestResults/admin/template/new.tpl	(revision 6781)
+++ /extensions/ContestResults/admin/template/new.tpl	(revision 6782)
@@ -1,6 +1,2 @@
-{html_head}
-	<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
-{/html_head}
-
 {known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
 {known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"}
@@ -9,17 +5,25 @@
 {include file='include/datepicker.inc.tpl'}
 
-<script type="text/javascript">
-	$(function() {ldelim}
-		$("#DateBegin").datepicker({ldelim}dateFormat:"yy-mm-dd", firstDay:1});
-		$("#DateEnd").datepicker({ldelim}dateFormat:"yy-mm-dd", firstDay:1});
-	});
+{html_head}
+	<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
+	<style type="text/css">
+		.cluetip:after {ldelim}
+			content:url('{$themeconf.admin_icon_dir}/help.png');
+		}
+	</style>
+	<script type="text/javascript">
+		$(function() {ldelim}
+			$('#DateBegin').datepicker({ldelim}dateFormat:'yy-mm-dd', firstDay:1});
+			$('#DateEnd').datepicker({ldelim}dateFormat:'yy-mm-dd', firstDay:1});
+		});
 
-	jQuery().ready(function(){ldelim}
-		jQuery('.cluetip').cluetip({ldelim}
-			width: 550,
-			splitTitle: '|'
+		jQuery().ready(function(){ldelim}
+			jQuery('.cluetip').cluetip({ldelim}
+				width: 550,
+				splitTitle: '|'
+			});
 		});
-	});
-</script>
+	</script>
+{/html_head}
 
 <h2 style="float:right;top:-24px;position:relative;font-style:italic;margin-bottom:-20px;font-size:12px;font-weight:normal;">{$CR_VERSION}</h2>
Index: /extensions/ContestResults/admin/template/results.tpl
===================================================================
--- /extensions/ContestResults/admin/template/results.tpl	(revision 6781)
+++ /extensions/ContestResults/admin/template/results.tpl	(revision 6782)
@@ -7,71 +7,99 @@
 
 {html_head}
-<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
+	<link rel="stylesheet" type="text/css" href="{$CR_PATH}admin/template/style.css">
+	<script type="text/javascript" src="{$CR_PATH}admin/template/vtip.js"></script>
 
-<script type="text/javascript">
-	function CreateResultField(j, new_contest){ldelim}
-		// Si il n'y a aucun résultats on efface le message
-		if(new_contest) document.getElementById('categoryUl').innerHTML = '';
+	<script type="text/javascript">
+		// AJOUTE UN CHAMP DE RESULTAT
+		function CreateResultField(j, new_contest){ldelim}
+			// Si il n'y a aucun résultats on efface le message
+			if(new_contest) document.getElementById('categoryUl').innerHTML = '';
+			
+			// Ajoute à la fin de la liste une nouvelle ligne de résultat vide
+			var new_result = document.createElement('li');
+			new_result.setAttribute('id', 'result_'+(j));
+			new_result.setAttribute('class', 'categoryLi virtual_cat');
+			document.getElementById('categoryUl').appendChild(new_result);
+			
+			// Contenu de la ligne
+			new_result.innerHTML = '<ul class="categoryActions"> '+
+					'<li> '+
+						'<a href="#" title="{'CR_delete_result'|@translate}" onclick="DeleteResultField('+ j +');return false;"> '+
+							'<img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'CR_delete_result'|@translate}"/> '+
+						'</a> '+
+					'</li> '+
+				'</ul> '+
+				'<p> '+
+					'<img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" title="{'Drag to re-order'|@translate}"> '+
+					'{'CR_image_no'|@translate} <input type="text" size="6" name="results['+ j +'][image_id]" value="" onkeyup="UpdatePreview('+ j +', this);"/> '+
+					'<span id="preview-'+ j +'"> '+
+						'<span class="vtip" title="<img src=\'{$themeconf.admin_icon_dir}/errors.png\'/><br>N/A"> '+
+							'<img src="{$CR_PATH}admin/template/image/images.png"/> '+
+						'</span> '+
+					'</span> '+
+					'{'CR_author'|@translate} : <input type="text" name="results['+ j +'][author]" value=""/> '+
+					'<textarea class="result_comment" name="results['+ j +'][comment]"></textarea> '+
+				'</p> '+
+				'<p class="catPos">{'CR_rank'|@translate} : <input type="text" name="results['+ j +'][rank]" value=""/></p>';
+			
+			// Remplace le lien de création
+			document.getElementById('AddLink').innerHTML = '<input class="submit" type="submit" onclick="CreateResultField('+ (j+1) +');return false;" value="{'CR_addfield'|@translate}"/>';
+			
+			// Réinitiliase les fonctions jQuery
+			jQuery('.catPos').hide();
+			jQuery('.drag_button').show();
+			jQuery('.categoryLi').css('cursor', 'move');
+			jQuery('textarea').autogrow();
+			jQuery('textarea').css('overflow-y', 'hidden');
+			vtip();
+		}
 		
-		// Ajoute à la fin de la liste une nouvelle ligne de résultat vide
-		var new_result = document.createElement('li');
-		new_result.setAttribute('id', 'result_'+(j));
-		new_result.setAttribute('class', 'categoryLi virtual_cat');
+		// SUPPRIME UN CHAMP DE RESULTAT (champs non enregistrés uniquement)
+		function DeleteResultField(k){ldelim}
+			var result = document.getElementById('result_'+k);
+			var parent = result.parentNode;
+			parent.removeChild(result);
+		}
+
+		jQuery().ready(function(){ldelim}
+			//  Drag-and-Drop
+			jQuery('.catPos').hide();
+			jQuery('.drag_button').show();
+			jQuery('.categoryLi').css('cursor', 'move');
+			jQuery('.categoryUl').sortable({ldelim}
+				axis: 'y',
+				opacity: 0.8
+			});
+			jQuery('#categoryOrdering').submit(function(){ldelim}
+				ar = jQuery('.categoryUl').sortable('toArray');
+				for(i=0; i<ar.length; i++) {ldelim}
+					cat = ar[i].split('result_');
+					document.getElementsByName('results[' + cat[1] + '][rank]')[0].value = i+1;
+				}
+			});
+			// Cluetip
+			jQuery('.cluetip').cluetip({ldelim}
+				width: 550,
+				splitTitle: '|'
+			});
+		});
 		
-		document.getElementById('categoryUl').appendChild(new_result);
-		
-		new_result.innerHTML = '<ul class="categoryActions"> '+
-			'<li> '+
-				'<a href="#" title="{'CR_delete_result'|@translate}" onclick="DeleteResultField('+j+');return false;"> '+
-					'<img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'CR_delete_result'|@translate}" /> '+
-				'</a> '+
-			'</li> '+
-			'</ul> '+
-			'<p> '+
-				'<img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}"> '+
-				'{'CR_image_no'|@translate} <input type="text" size="6" name="results['+j+'][image_id]" value=""/> '+
-				'{'CR_author'|@translate} : <input type="text" name="results['+j+'][author]" value=""/> '+
-				'<textarea class="result_comment" name="results['+j+'][comment]">{'CR_comment'|@translate}</textarea> '+
-			'</p> '+
-			'<p class="catPos">{'CR_rank'|@translate} : <input type="text" name="results['+j+'][rank]" value=""/></p>';
-		
-		// Remplace le lien de création
-		document.getElementById('AddLink').innerHTML = '<input class="submit" type="submit" onclick="CreateResultField('+(j+1)+');return false;" value="{'CR_addfield'|@translate}"/>';
-		
-		// Réinitiliase les fonctions jQuery
-		jQuery(".catPos").hide();
-		jQuery(".drag_button").show();
-		jQuery(".categoryLi").css("cursor","move");
-		jQuery('textarea').autogrow();
-		jQuery('textarea').css('overflow-y', 'hidden');
-	}
-
-	function DeleteResultField(k){ldelim}
-		var result = document.getElementById('result_'+k);
-		var parent = result.parentNode;
-		parent.removeChild(result);
-	}
-
-	jQuery().ready(function(){ldelim}
-		jQuery(".catPos").hide();
-		jQuery(".drag_button").show();
-		jQuery(".categoryLi").css("cursor","move");
-		jQuery(".categoryUl").sortable({ldelim}
-			axis: "y",
-			opacity: 0.8
-		});
-		jQuery("#categoryOrdering").submit(function(){ldelim}
-			ar = jQuery('.categoryUl').sortable('toArray');
-			for(i=0;i<ar.length;i++) {ldelim}
-				cat = ar[i].split('result_');
-				document.getElementsByName('results[' + cat[1] + '][rank]')[0].value = i+1;
-			}
-		});
-		jQuery('.cluetip').cluetip({ldelim}
-			width: 550,
-			splitTitle: '|'
-		});
-	});
-</script>
+		// MET A JOUR LA PREVISUALISATION DE L'IMAGE
+		function UpdatePreview(image_id, input){ldelim}
+			$.get("{$CR_PATH}admin/get_tn.php", {ldelim}image_id: input.value},
+				function success(data){ldelim}
+					document.getElementById('preview-'+image_id).innerHTML = '<span class="vtip" title="'+ data + '">'+
+							'<img src="{$CR_PATH}admin/template/image/images.png"/>'+
+						'</span>';
+					vtip();
+				}
+			);
+		}
+	</script>
+	<style type="text/css">
+		.cluetip:after {ldelim}
+			content:url('{$themeconf.admin_icon_dir}/help.png');
+		}
+	</style>
 {/html_head}
 
@@ -81,7 +109,5 @@
 	<h2>
 		{'CR_results_tab'|@translate|cat:' : '|cat:$NAME} 
-		<span class="cluetip" title="{'CR_results_tab'|@translate}|{'CR_help_results'|@translate}{'CR_help_lang'|@translate}">
-			<img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/help.png"/>
-		</span>
+		<span class="cluetip" title="{'CR_results_tab'|@translate}|{'CR_help_results'|@translate}{'CR_help_lang'|@translate}"></span>
 	</h2>
 </div>
@@ -92,15 +118,20 @@
 		{if isset($results)}
 			{foreach from=$results item=result name=result_loop}
-				<li class="categoryLi" id="result_{$i}">
+				<li class="categoryLi {if $result.IMAGE_NAME == 'N/A'}error_cat{/if}" id="result_{$i}">
 					<ul class="categoryActions">
 						<li>
-							<a href="{$result.U_DELETE}">
-								<img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'CR_delete_result'|@translate}" />
+							<a href="#" title="{'CR_delete_result'|@translate}" onclick="DeleteResultField({$i});return false;">
+								<img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'CR_delete_result'|@translate}"/>
 							</a>
 						</li>
 					</ul>
 					<p>
-						<img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}">
-						{'CR_image_no'|@translate} <input type="text" size="6" name="results[{$i}][image_id]" value="{$result.ID}"/>
+						<img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" title="{'Drag to re-order'|@translate}">
+						{'CR_image_no'|@translate} <input type="text" size="6" name="results[{$i}][image_id]" value="{$result.IMAGE_ID}" onkeyup="UpdatePreview({$i}, this);"/>
+						<span id="preview-{$i}">
+							<span class="vtip" title="<img src='{$result.TN_SRC}'/><br>{$result.IMAGE_NAME}">
+								<img src="{$CR_PATH}admin/template/image/images.png"/>
+							</span>
+						</span>
 						{'CR_author'|@translate} : <input type="text" name="results[{$i}][author]" value="{$result.AUTHOR}"/>
 						<textarea class="result_comment" name="results[{$i}][comment]">{$result.COMMENT}</textarea>
@@ -116,7 +147,7 @@
 	
 	<p>
-		<span id="AddLink"><input class="submit" type="submit" onclick="CreateResultField({$i}{if !isset($results)}, true{/if});return false;" value="{'CR_addfield'|@translate}"/></span>
 		<input type="hidden" name="contest_id" value="{$CONTEST_ID}"/>
 		<input class="submit" type="submit" value="{'Submit'|@translate}" name="results_modify"/>
+		<span id="AddLink"><input class="submit" type="submit" onclick="CreateResultField({$i}{if !isset($results)}, true{/if});return false;" value="{'CR_addfield'|@translate}"/></a>
 	</p>
 </form>
Index: /extensions/ContestResults/admin/template/style.css
===================================================================
--- /extensions/ContestResults/admin/template/style.css	(revision 6781)
+++ /extensions/ContestResults/admin/template/style.css	(revision 6782)
@@ -12,13 +12,17 @@
 }
 
-LI.categoryLi.novisible {
+li.categoryLi.novisible {
 	opacity:0.5;
 }
 
+li.categoryLi.error_cat {
+	border:1px solid #800;
+}
+
 table {
-	width:600px;
+	width:80%;
 }
 td {
-	width:150px;
+	width:25%;
 	white-space: nowrap;
 }
@@ -31,5 +35,4 @@
 .title.cluetip:after {
 	margin-left:5px;
-	content:url('image/help.png');
 	vertical-align:top;
 }
@@ -44,2 +47,18 @@
 	background-position:center right;
 }
+
+.vtip {
+	cursor:help;
+}
+p#vtip { 
+	display: none; 
+	position: absolute;
+	padding: 10px;
+	left: 5px;
+	font-size: 0.8em;
+	background-color:#222;
+	border:1px solid #666;
+	border-radius:4px;
+	-moz-border-radius:4px;
+	z-index: 9999;
+}
Index: /extensions/ContestResults/admin/template/vtip.js
===================================================================
--- /extensions/ContestResults/admin/template/vtip.js	(revision 6782)
+++ /extensions/ContestResults/admin/template/vtip.js	(revision 6782)
@@ -0,0 +1,2 @@
+/** Vertigo Tip by www.vertigo-project.com */
+this.vtip=function(){this.xOffset=-10;this.yOffset=10;$(".vtip").unbind().hover(function(a){this.t=this.title;this.title="";this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);$("body").append('<p id="vtip">'+this.t+"</p>");$("p#vtip").css("top",this.top+"px").css("left",this.left+"px").show()},function(){this.title=this.t;$("p#vtip").fadeOut("slow").remove()}).mousemove(function(a){this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);$("p#vtip").css("top",this.top+"px").css("left",this.left+"px")})};jQuery(document).ready(function(a){vtip()});
Index: /extensions/ContestResults/changelog.txt
===================================================================
--- /extensions/ContestResults/changelog.txt	(revision 6781)
+++ /extensions/ContestResults/changelog.txt	(revision 6782)
@@ -1,5 +1,7 @@
 1.1
 - Add menu block/links + configuration
+- Add results preview
 - Code revision
+- ExtendedDescription is needed to use multilanguage descriptions
 
 1.0.a
Index: /extensions/ContestResults/include/cr_comment_picture.php
===================================================================
--- /extensions/ContestResults/include/cr_comment_picture.php	(revision 6781)
+++ /extensions/ContestResults/include/cr_comment_picture.php	(revision 6782)
@@ -24,5 +24,5 @@
 	$comment = null;
 	while($result = pwg_db_fetch_assoc($results)){
-		// rang amélioré
+		// Rang amélioré
 		if($result['rank'] <= 3) $result['rank'] = l10n('CR_order_'.$result['rank']);
 		else $result['rank'] .= l10n('CR_order_sup');
Index: /extensions/ContestResults/include/cr_page.php
===================================================================
--- /extensions/ContestResults/include/cr_page.php	(revision 6781)
+++ /extensions/ContestResults/include/cr_page.php	(revision 6782)
@@ -12,7 +12,8 @@
 // Infos du concours
 $query = "SELECT * FROM " . CR_TABLE_1 . " WHERE id=" . $page['contest'] . ";";
-$contest = pwg_db_fetch_assoc(pwg_query($query));
+$results = pwg_query($query);
+$contest = pwg_db_fetch_assoc($results);
 
-if($contest['visible'] OR is_admin()){
+if(pwg_db_num_rows($results) AND ($contest['visible'] OR is_admin())){
 	// Paramètres généraux
 	$template->assign(array(
@@ -56,8 +57,4 @@
 				WHERE i.id = " . $result['image_id'] . ";";
 			$image = pwg_db_fetch_assoc(pwg_query($query));
-			
-			// Nom de l'image
-			if(empty($image['name']))
-				$image['name'] = get_name_from_file($image['file']);
 
 			// retrieving category informations
@@ -76,22 +73,22 @@
 			// Template
 			if(in_array($result['rank'], array(1,2,3))){
-				$array = array(
+				$data = array(
 					'RANK' => $result ['rank'],
 					'AUTHOR' => $result['author'],
 					'IMAGE_SRC' => str_replace('thumbnail/'.$conf['prefix_thumbnail'], null, get_thumbnail_url($image)),
 					'IMAGE_URL' => $image['url'],
-					'IMAGE_NAME' => $image['name'],
+					'IMAGE_NAME' => (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'],
 					'COMMENT' => CR_cut_string(trigger_event('render_CR_content', $result['comment']), 450),
 					);
 			}else{
-				$array = array(
+				$data = array(
 					'RANK' => $result ['rank'],
 					'AUTHOR' => $result['author'],
 					'TN_SRC' => get_thumbnail_url($image),
 					'IMAGE_URL' => $image['url'],
-					'IMAGE_NAME' => $image['name'],
+					'IMAGE_NAME' => (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'],
 				);
 			}
-			$template->append('RESULTS', $array);
+			$template->append('RESULTS', $data);
 		}
 	}
Index: /extensions/ContestResults/include/cutstring.class.php
===================================================================
--- /extensions/ContestResults/include/cutstring.class.php	(revision 6782)
+++ /extensions/ContestResults/include/cutstring.class.php	(revision 6782)
@@ -0,0 +1,65 @@
+<?php
+// Author prajwala
+// email  m.prajwala@gmail.com
+// Date   12/04/2009
+// version 1.0
+
+class HtmlCutString{
+  function __construct($string, $limit){
+    // create dom element using the html string
+    $this->tempDiv = new DomDocument;
+    $this->tempDiv->loadXML('<div>'.$string.'</div>');
+    // keep the characters count till now
+    $this->charCount = 0;
+    $this->encoding = 'UTF-8';
+    // character limit need to check
+    $this->limit = $limit;
+  }
+  function cut(){
+    // create empty document to store new html
+    $this->newDiv = new DomDocument;
+    // cut the string by parsing through each element
+    $this->searchEnd($this->tempDiv->documentElement,$this->newDiv);
+    $newhtml = $this->newDiv->saveHTML();
+    return $newhtml;
+  }
+
+  function deleteChildren($node) {
+    while (isset($node->firstChild)) {
+      $this->deleteChildren($node->firstChild);
+      $node->removeChild($node->firstChild);
+    }
+  } 
+  function searchEnd($parseDiv, $newParent){
+    foreach($parseDiv->childNodes as $ele){
+	// not text node
+	if($ele->nodeType != 3){
+	  $newEle = $this->newDiv->importNode($ele,true);
+	  if(count($ele->childNodes) === 0){
+	    $newParent->appendChild($newEle);
+	    continue;
+	  }
+	  $this->deleteChildren($newEle);
+	  $newParent->appendChild($newEle);
+	    $res = $this->searchEnd($ele,$newEle);
+	    if($res)
+			return $res;
+	    else
+			continue;
+	}
+
+	// the limit of the char count reached
+	if(mb_strlen($ele->nodeValue,$this->encoding) + $this->charCount >= $this->limit){
+	  $newEle = $this->newDiv->importNode($ele);
+	    $newEle->nodeValue = substr($newEle->nodeValue,0, $this->limit - $this->charCount);
+	    $newParent->appendChild($newEle);
+	    return true;
+	}
+	$newEle = $this->newDiv->importNode($ele);
+	$newParent->appendChild($newEle);
+	$this->charCount += mb_strlen($newEle->nodeValue,$this->encoding);
+    }
+    return false;
+  }
+}
+?>
Index: /extensions/ContestResults/include/functions.php
===================================================================
--- /extensions/ContestResults/include/functions.php	(revision 6781)
+++ /extensions/ContestResults/include/functions.php	(revision 6782)
@@ -2,40 +2,24 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-if(!function_exists('get_user_language_desc')){
-	function get_user_language_desc($desc){
-		global $user;
-		$user_lang = substr($user['language'], 0, 2);
-
-		if(!substr_count(strtolower($desc), '[lang=' . $user_lang . ']')){
-			$user_lang = 'default';
-		}
-
-		if(substr_count(strtolower($desc), '[lang=' . $user_lang . ']')){
-			// la balise avec la langue de l'utilisateur a été trouvée
-			$patterns[] = '#(^|\[/lang\])(.*?)(\[lang=(' . $user_lang . '|all)\]|$)#is';
-			$replacements[] = '';
-			$patterns[] = '#\[lang=(' . $user_lang . '|all)\](.*?)\[/lang\]#is';
-			$replacements[] = '\\1';
-
-		}else{
-			// la balise avec la langue de l'utilisateur n'a pas été trouvée
-			// On prend tout ce qui est hors balise
-			$patterns[] = '#\[lang=all\](.*?)\[/lang\]#is';
-			$replacements[] = '\\1';
-			$patterns[] = '#\[lang=.*\].*\[/lang\]#is';
-			$replacements[] = '';
-		}
-		return preg_replace($patterns, $replacements, $desc);
-	}
-}
-
-function CR_cut_string($string, $lg){
-	if(strlen($string) > $lg){
-		$string = substr($string, 0, $lg);
-		$last_space = strrpos($string,' ');
-		return substr($string, 0, $last_space).'...';
+// Racourcis un texte et ajoute une ellipse
+function CR_cut_string($string, $limit){
+	include_once(CR_PATH . 'include/cutstring.class.php');
+	if(strlen(str_replace("\r\n", "\n", strip_tags($string))) > $limit){
+		$output = new HtmlCutString($string, $limit);
+		return ($output->cut()).'...';
 	}else{
 		return $string;
 	}
 }
+
+// Recupère le nom d'un coucours à partir de l'id
+function get_contest_name($id){
+	$query = pwg_query("SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $id . ";");
+	if(pwg_db_num_rows($query)){
+		$result = pwg_db_fetch_assoc($query);
+		return $result['name'];
+	}else{
+		return null;
+	}
+}
 ?>
Index: /extensions/ContestResults/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/ContestResults/language/en_UK/plugin.lang.php	(revision 6781)
+++ /extensions/ContestResults/language/en_UK/plugin.lang.php	(revision 6782)
@@ -39,4 +39,5 @@
 $lang['CR_nopublic'] = 'This page is not available for the public !';
 $lang['CR_notavailable'] = 'This contest is not available';
+$lang['CR_id_unknown %d'] = "The picture n°%d doesn't exist";
 
 $lang['CR_order_1'] = '1<sup>st</sup>';
@@ -51,20 +52,25 @@
 $lang['CR_menubar_block_number'] = 'Quantity of contests to display in the block';
 
-$lang['CR_help_lang'] = "<b>You can use HTML and multilanguage descriptions :</b>
-	<span style='font-size:0.8em;'><br/><br/>
-	Multilanguage descriptions are placed between [lang=xx] and [/lang] tags, where xx is the language code (for example en, es, fr). There is also 2 special languages : [lang=default] and [lang=all].
-	<br/><br/>
-	Special language <i>default</i> : the default description will be used if the description is not available in the connected user selected language. If [lang=default] does not exists, anything outside the [lang] tags will be considered as the default description.
-	<br/><br/>
-	Special language <i>all</i> : anything inside [lang=all] will be included in the description, anywhat the connected user defined language is. This is mainly useful to include HTML/JavaScript code inside a description.";
-	
+$lang['CR_help_lang'] = ($ED['state'] == 'active') ? "<b>You can use HTML and multilanguage descriptions.</b>" : "<b>You can use HTML.</b>";
+	// <span style='font-size:0.8em;'><br/><br/>
+	// Multilanguage descriptions are placed between [lang=xx] and [/lang] tags, where xx is the language code (for example en, es, fr). There is also 2 special languages : [lang=default] and [lang=all].
+	// <br/><br/>
+	// Special language <i>default</i> : the default description will be used if the description is not available in the connected user selected language. If [lang=default] does not exists, anything outside the [lang] tags will be considered as the default description.
+	// <br/><br/>
+	// Special language <i>all</i> : anything inside [lang=all] will be included in the description, anywhat the connected user defined language is. This is mainly useful to include HTML/JavaScript code inside a description.";
+
 $lang['CR_help_title'] = "";
-$lang['CR_help_status'] = "When the contest is <i>Finished</i> the results are displayed on the contest page and the marker <span style='color:#a00;'>(Finished)</span> is activated.
-	<br/><b>Caution :</b> the contest doesn't switch automaticaly to the status 'finished' when the end date is reached !";
+$lang['CR_help_status'] = "When the contest is <i>Finished</i> the results are displayed on the contest page and the marker <span style='color:#a00;'>(Finished)</span> is activated.<br/>
+	<b>Caution :</b> the contest doesn't switch automaticaly to the status 'finished' when the end date is reached !";
 $lang['CR_help_visible'] = "If the contest is 'unvisible' only <b>administrators</b> can see it.";
-$lang['CR_help_summary'] = "The summary is only displayed in the general contest page.<br/><br/>";
-$lang['CR_help_textareas'] = "These four areas allow you to describe the contest.
-	<br/>For each area you can choose the displaying according to the contest status.<br/><br/>";
-$lang['CR_help_results'] = "Descriptions are displayed on each pictures pages and on the contest page for the first three.
-	<br/>Sort elements by drag-and-drop them.<br/><br/>";
+$lang['CR_help_summary'] = "The summary is only displayed in the general contest page.<br/>
+	<br/>";
+$lang['CR_help_textareas'] = "- These four areas allow you to describe the contest.<br/>
+	- For each area you can choose the displaying according to the contest status.<br/>
+	<br/>";
+$lang['CR_help_results'] = "- Descriptions are displayed on each pictures pages and on the contest page for the first three.<br/>
+	- Sort elements by drag-and-drop them.<br/>
+	- Hover this icon <img src='".CR_PATH."admin/template/image/images.png'/> to view the picture that corresponds to the id.<br/>
+	<br/>";
+
 ?>
Index: /extensions/ContestResults/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/ContestResults/language/fr_FR/plugin.lang.php	(revision 6781)
+++ /extensions/ContestResults/language/fr_FR/plugin.lang.php	(revision 6782)
@@ -39,4 +39,5 @@
 $lang['CR_nopublic'] = "Cette page n'est pas accessible au public !";
 $lang['CR_notavailable'] = "Ce concours n'est pas disponible";
+$lang['CR_id_unknown %d'] = "L'image n°%d n'existe pas";
 
 $lang['CR_order_1'] = '1<sup>er</sup>';
@@ -51,20 +52,25 @@
 $lang['CR_menubar_block_number'] = 'Nombre de concours à afficher dans le bloc';
 
-$lang['CR_help_lang'] = "<b>Vous pouvez utiliser du HTML et les descriptions multilingues :</b>
-	<span style='font-size:0.8em;'><br/><br/>
-	Les descriptions multilingues se font entre les balises [lang=xx] et [/lang], ou xx est le code de la langue (par exemple fr, en, es, it, etc....) Il existe également 2 balises spéciales: [lang=default] et [lang=all].
-	<br/><br/>
-	Balise <i>default</i> : la description par défaut sera utilisée si la description dans la langue de l'utilisateur n'est pas définie. Si [lang=default] n'existe pas, tout ce qui est situé en dehors des balises de langues sera considéré comme description par défaut.
-	<br/><br/>
-	Balise <i>all</i> : tout ce qui est situé entre les balises [lang=all] et [/lang] sera inclus dans la description, quelle que soit la langue de l'utilisateur. Ceci est particulièrement pratique pour inclure du code html ou javascript dans une description.</span>";
-	
+$lang['CR_help_lang'] = ($ED['state'] == 'active') ? "<b>Vous pouvez utiliser du HTML et les descriptions multilingues.</b>" : "<b>Vous pouvez utiliser du HTML.</b>";
+	// <span style='font-size:0.8em;'><br/><br/>
+	// Les descriptions multilingues se font entre les balises [lang=xx] et [/lang], ou xx est le code de la langue (par exemple fr, en, es, it, etc....) Il existe également 2 balises spéciales: [lang=default] et [lang=all].
+	// <br/><br/>
+	// Balise <i>default</i> : la description par défaut sera utilisée si la description dans la langue de l'utilisateur n'est pas définie. Si [lang=default] n'existe pas, tout ce qui est situé en dehors des balises de langues sera considéré comme description par défaut.
+	// <br/><br/>
+	// Balise <i>all</i> : tout ce qui est situé entre les balises [lang=all] et [/lang] sera inclus dans la description, quelle que soit la langue de l'utilisateur. Ceci est particulièrement pratique pour inclure du code html ou javascript dans une description.</span>";
+
 $lang['CR_help_title'] = "";
-$lang['CR_help_status'] = "Quand le concours est <i>Terminé</i> les résultats sont affichés sur la page du concours et l'indicateur <span style='color:#a00;'>(Terminé)</span> s'active.
-	<br/><b>Attention :</b> le concours ne passe pas automatiquement en status terminé quand la date de fin est atteinte !";
+$lang['CR_help_status'] = "Quand le concours est <i>Terminé</i> les résultats sont affichés sur la page du concours et l'indicateur <span style='color:#a00;'>(Terminé)</span> s'active.<br/>
+	<b>Attention :</b> le concours ne passe pas automatiquement en status terminé quand la date de fin est atteinte !";
 $lang['CR_help_visible'] = "Si le concours est 'invisible' seuls les <b>administrateurs</b> peuvent le voir.";
-$lang['CR_help_summary'] = "Le résumé n'est affiché que sur la page regroupant tous les concours.<br/><br/>";
-$lang['CR_help_textareas'] = "Ces quatres zones de texte vous permettent de décrire le concours.
-	<br/>Pour chaque zone vous pouvez choisir son affichage selon le status du concours.<br/><br/>";
-$lang['CR_help_results'] = "Les descriptions seront affichées sur les pages de chaque images et sur la page du concours pour les trois premiers.
-	<br/>Triez les éléments par glisser-déposer.<br/><br/>";
+$lang['CR_help_summary'] = "Le résumé n'est affiché que sur la page regroupant tous les concours.<br/>
+	<br/>";
+$lang['CR_help_textareas'] = "- Ces quatres zones de texte vous permettent de décrire le concours.<br/>
+	- Pour chaque zone vous pouvez choisir son affichage selon le status du concours.<br/>
+	<br/>";
+$lang['CR_help_results'] = "- Les descriptions seront affichées sur les pages de chaque images et sur la page du concours pour les trois premiers.<br/>
+	- Triez les éléments par glisser-déposer.<br/>
+	- Survolez l'icône <img src='".CR_PATH."admin/template/image/images.png'/> pour voir l'image correspondante à l'identifiant entré.<br/>
+	<br/>";
+
 ?>
Index: /extensions/ContestResults/main.inc.php
===================================================================
--- /extensions/ContestResults/main.inc.php	(revision 6781)
+++ /extensions/ContestResults/main.inc.php	(revision 6782)
@@ -25,4 +25,19 @@
 define('CR_PUBLIC', make_index_url(array('section' => 'contests')) . '/');
 
+
+// +-----------------------------------------------------------------------+
+//				Trigger
+// +-----------------------------------------------------------------------+
+add_event_handler('get_admin_plugin_menu_links', 'CR_admin_menu'); 	// Lien d'administration
+add_event_handler('loc_end_section_init', 'CR_section_init'); 		// Paramètre URL
+add_event_handler('loc_end_index', 'CR_index'); 					// Contenu du la page
+add_event_handler('loc_end_picture', 'CR_comment_picture', 10); 	// Commentaire sur la page image
+
+$ED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
+if($ED['state'] == 'active') add_event_handler('render_CR_content', 'get_user_language_desc'); 	// Textes multilangues
+
+// Langues
+load_language('plugin.lang', CR_PATH);
+
 // Gestion du menu
 include(CR_PATH . 'include/cr_menubar.php');
@@ -39,6 +54,7 @@
 // Paramètre URL
 function CR_section_init(){
-    global $tokens, $page;
-	load_language('plugin.lang', CR_PATH);
+    global $tokens, $page, $conf;
+	include(CR_PATH . 'include/functions.php');
+	
     if($tokens[0] == 'contests'){
 		$page['section'] = 'contests';
@@ -47,5 +63,5 @@
 			$page['contest'] = explode('-', $tokens[1]);
 			$page['contest'] = $page['contest'][0];
-			$page['title'] .= trigger_event('render_CR_content', get_contest_name($page['contest']));
+			$page['title'] .= $conf['level_separator'] . trigger_event('render_CR_content', get_contest_name($page['contest']));
 		}
 	}
@@ -54,7 +70,6 @@
 // Contenu du la page
 function CR_index(){
-    global $template, $page, $conf, $menu;
+    global $template, $page, $conf;
     if(isset($page['section']) and $page['section'] == 'contests'){
-		include(CR_PATH . 'include/functions.php');
 		if(isset($page['contest']))
 			include(CR_PATH . 'include/cr_page.php');
@@ -67,24 +82,6 @@
 function CR_comment_picture(){
 	global $page, $template, $conf;
-	include(CR_PATH . 'include/functions.php');
 	include(CR_PATH . 'include/cr_comment_picture.php');  
 }
 
-function get_contest_name($contest){
-	global $conf;
-	$query = pwg_query("SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $contest . ";");
-	if(pwg_db_num_rows($query)){
-		$result = pwg_db_fetch_assoc($query);
-		return $conf['level_separator'] . $result['name'];
-	}else{
-		return null;
-	}
-}
-
-add_event_handler('get_admin_plugin_menu_links', 'CR_admin_menu'); // Lien d'administration
-add_event_handler('loc_end_section_init', 'CR_section_init'); // Paramètre URL
-add_event_handler('loc_end_index', 'CR_index'); // Contenu du la page
-add_event_handler('loc_end_picture', 'CR_comment_picture', 10); // Ajoute le commentaire sur la page image
-add_event_handler('render_CR_content', 'get_user_language_desc'); // Textes multilangues
-
 ?>
Index: /extensions/ContestResults/maintain.inc.php
===================================================================
--- /extensions/ContestResults/maintain.inc.php	(revision 6781)
+++ /extensions/ContestResults/maintain.inc.php	(revision 6782)
@@ -51,11 +51,12 @@
 	pwg_query($query);
 	
-	if(!isset($conf['ContestResults'])){
-		$query = "INSERT INTO " . CONFIG_TABLE . "(param,value,comment) VALUES('ContestResults', '" . default_config . "', 'Parametres du plugin ContestResults');";
-		pwg_query($query);
-	}
+	$query = "INSERT INTO " . CONFIG_TABLE . "(param,value,comment) VALUES('ContestResults', '" . default_config . "', 'Parametres du plugin ContestResults');";
+	pwg_query($query);
 }
 
 function plugin_activate(){
+	global $conf;
+
+	// compatibilité avec les versions < 1.1
 	if(!isset($conf['ContestResults'])){
 		$query = "INSERT INTO " . CONFIG_TABLE . "(param,value,comment) VALUES('ContestResults', '" . default_config . "', 'Parametres du plugin ContestResults');";
Index: /extensions/ContestResults/template/cr_main.tpl
===================================================================
--- /extensions/ContestResults/template/cr_main.tpl	(revision 6781)
+++ /extensions/ContestResults/template/cr_main.tpl	(revision 6782)
@@ -13,5 +13,9 @@
 		<h2>{'Contests'|@translate}</h2>
 	</div> <!-- titrePage -->
-	
+	{if !isset($contests_pending) AND !isset($contests_finished)}
+		<div class="nopublic" style="margin-bottom:200px;">
+			{'CR_no_contest'|@translate}
+		</div>
+	{/if}
 	{if isset($contests_pending)}
 		<ul class="thumbnailCategories">
Index: /extensions/ContestResults/template/cr_page.tpl
===================================================================
--- /extensions/ContestResults/template/cr_page.tpl	(revision 6781)
+++ /extensions/ContestResults/template/cr_page.tpl	(revision 6782)
@@ -1,4 +1,4 @@
 {html_head}
-<link rel="stylesheet" type="text/css" href="{$CR_PATH}template/style.css">
+	<link rel="stylesheet" type="text/css" href="{$CR_PATH}template/style.css">
 {/html_head}
 
@@ -20,5 +20,5 @@
 	</div> <!-- titrePage -->
 
-	{if  $VISIBLE == 0}
+	{if !$VISIBLE}
 		<div class="nopublic">
 			{'CR_nopublic'|@translate}
Index: /extensions/ContestResults/template/style.css
===================================================================
--- /extensions/ContestResults/template/style.css	(revision 6781)
+++ /extensions/ContestResults/template/style.css	(revision 6782)
@@ -11,11 +11,11 @@
 }
 
-div.thumbnailCategory.novisible {
-	opacity:0.4;
-}
-
 .results {
 	overflow:hidden;
 	white-space:nowrap;
+}
+
+div.thumbnailCategory.novisible {
+	opacity:0.4;
 }
 
