From 4ea2af41afd0c16c97b81a4d8920e675572cbc9c Mon Sep 17 00:00:00 2001
From: Fil <fil@rezo.net>
Date: Wed, 22 May 2002 21:15:07 +0000
Subject: [PATCH] logos par defaut dans IMG/arton-defaut.gif etc.

---
 inc-calcul.php3 | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/inc-calcul.php3 b/inc-calcul.php3
index 80e3a9488a..8f6b11a51e 100644
--- a/inc-calcul.php3
+++ b/inc-calcul.php3
@@ -52,25 +52,31 @@ function transformer_lien_logo($contexte, $lien) {
 // Retrouver l'image d'un objet (et son survol)
 //
 
-function cherche_image($id_objet, $type_objet) {
+// chercher une image nommee dans tous les formats
+function cherche_image_nommee($nom) {
 	$formats = array ('gif', 'jpg', 'png');
+	while (list(, $format) = each($formats))
+		if (file_exists('IMG/'.$nom.'.'.$format))
+			return ($nom.'.'.$format);
+}
+
+function cherche_image($id_objet, $type_objet) {
 	$image = array('', '');
-	while (list(, $format) = each($formats)) {
-		if (file_exists('IMG/'.$type_objet.'on'.$id_objet.'.'.$format)) {
-			$image[0]=$type_objet.'on'.$id_objet.'.'.$format;
-			break;
-		}
+
+	// cherche l'image liee a l'objet
+	$image[0] = cherche_image_nommee($type_objet.'on'.$id_objet);
+
+	// sinon eventuellement une image par defaut
+	if (!$image[0]) {
+		$id_objet = '-defaut';
+		$image[0] = cherche_image_nommee($type_objet.'on'.$id_objet);
 	}
 
+	// cherche un survol
 	if ($image[0]) {
-		reset ($formats);
-		while (list(, $format) = each($formats)) {
-			if (file_exists('IMG/'.$type_objet.'off'.$id_objet.'.'.$format)) {
-				$image[1] = $type_objet.'off'.$id_objet.'.'.$format;
-				break;
-			}
-		}
+		$image[1] = cherche_image_nommee($type_objet.'off'.$id_objet);
 	}
+
 	return $image;
 }
 
-- 
GitLab