From d49d33f4e8e30e186779ddd8437802af70a299fc Mon Sep 17 00:00:00 2001
From: RastaPopoulos <rastapopoulos@spip.org>
Date: Sun, 12 Jun 2016 13:18:44 +0000
Subject: [PATCH] =?UTF-8?q?Nouveau=20pipeline=20"chercher=5Flogo",=20qui?=
 =?UTF-8?q?=20permet=20de=20compl=C3=A9ter=20ou=20ajouter=20des=20infos=20?=
 =?UTF-8?q?de=20logos=20apr=C3=A8s=20que=20SPIP=20ait=20cherch=C3=A9=20ave?=
 =?UTF-8?q?c=20sa=20m=C3=A9thode=20classique.=20On=20peut=20donc=20fournir?=
 =?UTF-8?q?=20autre=20chose,=20et=20surtout=20on=20peut=20d=C3=A9finir=20u?=
 =?UTF-8?q?n=20logo=20si=20SPIP=20n'en=20a=20pas=20trouv=C3=A9=20avant=20(?=
 =?UTF-8?q?exemple=20:=20prendre=20la=20premi=C3=A8re=20image=20jointe=20t?=
 =?UTF-8?q?rouv=C3=A9e,=20comme=20dans=20Logo=20auto=20de=20Tetue).=20Sans?=
 =?UTF-8?q?=20avoir=20=C3=A0=20surcharger=20salement=20ni=20bloquer=20d'au?=
 =?UTF-8?q?tres=20m=C3=A9thodes=20ensuite.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/chercher_logo.php | 27 ++++++++++++++++++++++-----
 ecrire/paquet.xml            |  1 +
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/ecrire/inc/chercher_logo.php b/ecrire/inc/chercher_logo.php
index 0937d8260a..e5696c85dc 100644
--- a/ecrire/inc/chercher_logo.php
+++ b/ecrire/inc/chercher_logo.php
@@ -37,18 +37,35 @@ if (!defined('_ECRIRE_INC_VERSION')) {
  **/
 function inc_chercher_logo_dist($id, $_id_objet, $mode = 'on') {
 	# attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
-
+	
+	$infos_logo = array();
 	$type = type_du_logo($_id_objet);
 	$nom = $type . $mode . intval($id);
-
+	
 	foreach ($GLOBALS['formats_logos'] as $format) {
 		if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
-			return array($d, _DIR_LOGOS, $nom, $format, @filemtime($d));
+			$infos_logo = array($d, _DIR_LOGOS, $nom, $format, @filemtime($d));
+			break; // On sort au premier logo trouvé
 		}
 	}
-
+	
+	// On passe dans un pipeline
+	$infos_logo = pipeline(
+		'chercher_logo',
+		array(
+			'args' => array(
+				'id_objet' => $id,
+				'objet' => objet_type($_id_objet),
+				'cle_objet' => $_id_objet,
+				'type' => $type,
+				'mode' => $mode,
+			),
+			'data' => $infos_logo,
+		)
+	);
+	
 	# coherence de type pour servir comme filtre (formulaire_login)
-	return array();
+	return $infos_logo;
 }
 
 /**
diff --git a/ecrire/paquet.xml b/ecrire/paquet.xml
index e589d7e9a3..af9a84a638 100644
--- a/ecrire/paquet.xml
+++ b/ecrire/paquet.xml
@@ -57,6 +57,7 @@
 	<pipeline nom="ajouter_onglets" action="" />
 	<pipeline nom="body_prive" action="" />
 	<pipeline nom="calculer_rubriques" action="" />
+	<pipeline nom="chercher_logo" action="" />
 	<pipeline nom="configurer_liste_metas" action="" />
 	<pipeline nom="compter_contributions_auteur" action="" />
 	<pipeline nom="declarer_filtres_squelettes" action="" />
-- 
GitLab