From a1b289d80f2d82192f0e5688e66e6ebdcec931a8 Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Fri, 2 Jan 2009 18:46:51 +0000
Subject: [PATCH] =?UTF-8?q?La=20balise=20{{{#LOGO=5FARTICLE}}}=20et=20cons?=
 =?UTF-8?q?orts=20rentrent=20dans=20le=20moule=20commnun.=20Les=20faux=20f?=
 =?UTF-8?q?iltres=20{{{|fichier}}}=20et=20{{{|lien}}}=20sont=20remplac?=
 =?UTF-8?q?=C3=A9s=20respectivement=20par=20l'=C3=A9criture=20{{{#LOGO=5FA?=
 =?UTF-8?q?RTICLE**}}}=20et=20{{{#LOGO=5FARTICLE*}}}.=20Les=20faux=20filtr?=
 =?UTF-8?q?es=20de=20positionnement=20({{{top,left,right,center,bottom}}})?=
 =?UTF-8?q?=20et=20les=20balises=20{{{#URL=5F}}}xxx=20en=20position=20de?=
 =?UTF-8?q?=20filtres=20sont=20=C3=A0=20pr=C3=A9sent=20=C3=A0=20=C3=A9crir?=
 =?UTF-8?q?e=20comme=20argument=20de=20la=20balise,=20l'=C3=A9criture=20{{?=
 =?UTF-8?q?{#LOGO=5FARTICLE|left}}}=20est=20donc=20remplac=C3=A9e=20par=20?=
 =?UTF-8?q?{{{#LOGO=5FARTICLE{left}=20}}}=20et=20l'=C3=A9criture=20{{{#LOG?=
 =?UTF-8?q?O=5FARTICLE|#URL=5FAUTEUR}}}=20est=20donc=20remplac=C3=A9e=20pa?=
 =?UTF-8?q?r=20{{{#LOGO=5FARTICLE{#URL=5FAUTEUR}=20}}}.=20Ces=20deux=20?=
 =?UTF-8?q?=C3=A9critures=20peuvent=20se=20combiner=20entre=20elles=20et?=
 =?UTF-8?q?=20avec=20les=20deux=20nombres=20donnant=20les=20dimensions,=20?=
 =?UTF-8?q?comme=20dans=20{{{LOGO=5FDOCUMENT{#URL=5FARTICLE,bottom,60,80}?=
 =?UTF-8?q?=20}}},=20l'ordre=20des=204=20param=C3=A8tres=20=C3=A9tant=20li?=
 =?UTF-8?q?bre.=20Avec=20tout=20=C3=A7a,=20il=20n'est=20plus=20n=C3=A9cess?=
 =?UTF-8?q?aire=20d'=C3=A9crire=20{{{=20||=C2=A0}}}=C2=A0pour=20stipuler?=
 =?UTF-8?q?=20que=20les=20filtres=20normaux=20commencent.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Les anciennes écritures restent comprises mais doivent être considérées comme obsolètes. Une écriture théoriquement possible mais vraisemblablement pas utilisée est néanmoins totalement exclue à présent (savoir {{{#LOGO_ARTICLE|f}}} où {{{f}}} ne contiendrait pas le caractère # mais donnerait on ne sais comment une URL).

Test (en plus de squelette-dist, remis d'équerre):

<BOUCLE_doc(DOCUMENTS){id_article}>
[(#LOGO_DOCUMENT{43,left,66})]
LOGO_DOCUMENT{# URL_ARTICLE,77,bottom,67}
[(#LOGO_DOCUMENT{#URL_ARTICLE,,bottom,77,67})]
<br>
LOGO_DOCUMENT**
[(#LOGO_DOCUMENT**)]
<br>
LOGO_DOCUMENT|lien
[(#LOGO_DOCUMENT|lien)]
<br>
LOGO_DOCUMENT*
[(#LOGO_DOCUMENT*)]
<br>
LOGO_DOCUMENT{12,13}||trim{f}}
[(#LOGO_DOCUMENT{12,13}||trim{f})]
<br>
LOGO_DOCUMENT{left,bottom,right}
[(#LOGO_DOCUMENT{left,bottom,right})]
</BOUCLE_doc>
---
 ecrire/balise/logo_.php             | 93 ++++++++++++++++++-----------
 squelettes-dist/article.html        |  2 +-
 squelettes-dist/auteur.html         |  2 +-
 squelettes-dist/backend-breves.html |  8 +--
 squelettes-dist/backend.html        |  6 +-
 squelettes-dist/breve.html          |  2 +-
 squelettes-dist/forum.html          |  4 +-
 squelettes-dist/inc-rss-item.html   |  2 +-
 squelettes-dist/mot.html            |  2 +-
 squelettes-dist/rubrique.html       |  4 +-
 squelettes-dist/site.html           |  2 +-
 squelettes-dist/sommaire.html       |  2 +-
 12 files changed, 75 insertions(+), 54 deletions(-)

diff --git a/ecrire/balise/logo_.php b/ecrire/balise/logo_.php
index 25511b4fbc..3059a577a9 100644
--- a/ecrire/balise/logo_.php
+++ b/ecrire/balise/logo_.php
@@ -38,39 +38,61 @@ function balise_LOGO__dist ($p) {
 		$_id_objet = champ_sql($id_objet, $p);
 	}
 
-	// analyser les faux filtres
-	$fichier = 0;
-	$align = $lien = $params = '';
-
-	if (is_array($p->fonctions)) {
-		foreach($p->fonctions as $couple) {
-			$nom = trim($couple[0]);
-
-			// double || signifie "on passe aux vrais filtres"
-			if ($nom == '') {
-				if ($couple[1]) {
-					$params = $couple[1]; // recuperer #LOGO_DOCUMENT{20,30}
-					array_shift($p->param);
-				} else break;
-			} else {
+	$fichier = ($p->etoile === '**') ? -1 : 0;
+	$lien = ($p->etoile === '*') ? ' ' : '';
+	$coord = array();
+	$align = $params = '';
+
+	if ($p->param AND !$p->param[0][0]) {
+		$params = array_shift($p->param);
+		array_shift($params);
+		foreach($params as $a) {
+			if ($a[0]->type === 'texte') {
+				$n = $a[0]->texte;
+				if (is_numeric($n))
+					$coord[]= $n;
+				else $align = $n;
+			} else $lien = $a[0];
+		}
+	}
+
+	$x = !$coord  ? 0 : intval(array_shift($coord));
+	$y = !$coord  ? 0 : intval(array_shift($coord));
+	
+	// Bloc de compatibilite SPIP <= 2.0
+	// Ne pas chercher a comprendre.
+	foreach($p->fonctions as $couple) {
+		$nom = trim($couple[0]);
+		if ($nom == '')  break;
+		$r = logo_faux_filtres($nom);
+		if ($r === 0) {
+			$align = $nom;
+			array_shift($p->param);
+			spip_log('filtre de logo obsolete', 'vieilles_defs');
+		} else {
+			if ($r === 2) {
+				$fichier = -1;
+				array_shift($p->param);
+				spip_log('filtre de logo obsolete', 'vieilles_defs');
+			} elseif ($r === 1) {
+				$lien = ' ';
 				array_shift($p->param);
-				$r = logo_faux_filtres($nom);
-				if ($r === 0)
-					$align = $nom;
-				else {
-					if ($r === 2)
-						$fichier = -1;
-					elseif ($r === 1)
-						$lien = ' ';
-					else	$lien = $nom;
-					break;
-				}
+				spip_log('filtre de logo obsolete', 'vieilles_defs');
+			} elseif (ltrim($nom[0])=='#') {
+				array_shift($p->param);
+				$lien = $nom;
+				// le cas else est la seule incompatibilite
+				spip_log('filtre de logo obsolete', 'vieilles_defs');
 			}
+			break;
 		}
 	}
+	// Fin du bloc
 
 	if ($lien) {
-		if (preg_match(",^[^#]*#([A-Za-z_]+),", $lien, $r)) {
+		if (!is_string($lien))
+			$lien = calculer_champ($lien);
+		elseif (preg_match(",^[^#]*#([A-Za-z_]+),", $lien, $r)) {
 			$c = new Champ();
 			$c->nom_champ = $r[1];
 			$c->id_boucle = $p->id_boucle;
@@ -85,11 +107,6 @@ function balise_LOGO__dist ($p) {
 
 	$connect = $p->id_boucle ?$p->boucles[$p->id_boucle]->sql_serveur :'';
 	if ($type == 'document') {
-		if (preg_match('/{\s*(\d+),\s*(\d+)\s*}/', $params, $r)) {
-			$x = intval($r[1]);
-			$y = intval($r[2]);
-		} else $x = $y = 0;
-
 		$qconnect = _q($connect);
 		if ($fichier)
 			$code = "quete_logo_file(quete_document($_id_objet, $qconnect), $qconnect)";
@@ -126,16 +143,20 @@ function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p,
 
 	$code = "\n((!is_array(\$l = $code)) ? '':\n (" .
 		     '"<img class=\"spip_logos\" alt=\"\"' .
-		    ($align ? " align=\"$align\"" : '')
+		    ($align ? " align=\\\"$align\\\"" : '')
 		    . ' src=\"$l[0]\"" . $l[3] .  ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))';
 
 	if (!$lien) return $code;
 
 	return ('\'<a href="\' .' . $lien . ' . \'"> \' . ' . $code . " . '</a>'");
 
-}// Pour les documents comme pour les logos, le filtre |fichier donne
-// le chemin du fichier apres 'IMG/' ;  peut-etre pas d'une purete
-// remarquable, mais a conserver pour compatibilite ascendante.
+}
+
+// Les pseudos filtres |fichier et |lien pour les balises LOGO_XXX
+// donnent le chemin du fichier et son URL.
+// Ecritures obsolete remplacees par ** et *: LOGO_XXX** et LOGO_XXX*
+// Conservees pour compatibilite ascendante mais ne plus utiliser
+// Idem pour le positionnement.
 // -> http://www.spip.net/fr_article901.html
 
 function logo_faux_filtres($nom)
diff --git a/squelettes-dist/article.html b/squelettes-dist/article.html
index 0bcb7a2b2e..d82d31a0d1 100644
--- a/squelettes-dist/article.html
+++ b/squelettes-dist/article.html
@@ -22,7 +22,7 @@
 
         <div class="cartouche">
             <div class="surlignable">
-				[(#LOGO_ARTICLE||image_reduire{200,200})]
+				[(#LOGO_ARTICLE|image_reduire{200,200})]
 				[<p class="#EDIT{surtitre} surtitre">(#SURTITRE)</p>]
 				<h1 class="#EDIT{titre} entry-title">#TITRE</h1>
 				[<p class="#EDIT{soustitre} soustitre">(#SOUSTITRE)</p>]
diff --git a/squelettes-dist/auteur.html b/squelettes-dist/auteur.html
index 782b8126e9..d7adda92bf 100644
--- a/squelettes-dist/auteur.html
+++ b/squelettes-dist/auteur.html
@@ -24,7 +24,7 @@
 
 		<div class="vcard">[(#REM) microformat vcard]
         <div class="cartouche">
-            [(#LOGO_AUTEUR||image_reduire{200,200})]
+            [(#LOGO_AUTEUR|image_reduire{200,200})]
             <h1 class="#EDIT{qui} fn">#NOM</h1>
         </div>
 
diff --git a/squelettes-dist/backend-breves.html b/squelettes-dist/backend-breves.html
index 908db651e7..b8789a0e76 100644
--- a/squelettes-dist/backend-breves.html
+++ b/squelettes-dist/backend-breves.html
@@ -15,10 +15,10 @@ version="1.0"[ encoding="(#CHARSET)"]?>
 
 [	<image>
 		<title>[(#NOM_SITE_SPIP|texte_backend)]</title>
-		<url>(#LOGO_SITE_SPIP||image_reduire{150,150}|extraire_attribut{src}|url_absolue|texte_backend)</url>
+		<url>(#LOGO_SITE_SPIP|image_reduire{150,150}|extraire_attribut{src}|url_absolue|texte_backend)</url>
 		<link>#URL_SITE_SPIP/</link>
-		[<height>(#LOGO_SITE_SPIP||image_reduire{150,150}|extraire_attribut{height})</height>]
-		[<width>(#LOGO_SITE_SPIP||image_reduire{150,150}|extraire_attribut{width})</width>]
+		[<height>(#LOGO_SITE_SPIP|image_reduire{150,150}|extraire_attribut{height})</height>]
+		[<width>(#LOGO_SITE_SPIP|image_reduire{150,150}|extraire_attribut{width})</width>]
 	</image>
 ]
 
@@ -55,7 +55,7 @@ version="1.0"[ encoding="(#CHARSET)"]?>
 	ce qui permet une syndication plus riche (mais plus "lourde").
 	Fonction desactivable depuis les reglages du site.
 ][
-(#CONFIG{syndication_integrale}|=={oui}|?{' ',''})<content:encoded>[(#LOGO_BREVE|right||image_reduire{150,150}|texte_backend)
+(#CONFIG{syndication_integrale}|=={oui}|?{' ',''})<content:encoded>[(#LOGO_BREVE{right}|image_reduire{150,150}|texte_backend)
 		][&lt;div class='rss_texte'&gt;(#TEXTE|texte_backend)&lt;/div&gt;
 		][&lt;hr /&gt;
 		&lt;div class='rss_notes'&gt;(#NOTES|texte_backend)&lt;/div&gt;]
diff --git a/squelettes-dist/backend.html b/squelettes-dist/backend.html
index ad680cd019..a69bcd370b 100644
--- a/squelettes-dist/backend.html
+++ b/squelettes-dist/backend.html
@@ -14,10 +14,10 @@ version="1.0"[ encoding="(#CHARSET)"]?>
 
 [	<image>
 		<title>[(#NOM_SITE_SPIP|texte_backend)]</title>
-		<url>(#LOGO_SITE_SPIP||image_reduire{144,400}|extraire_attribut{src}|url_absolue|texte_backend)</url>
+		<url>(#LOGO_SITE_SPIP|image_reduire{144,400}|extraire_attribut{src}|url_absolue|texte_backend)</url>
 		<link>#URL_SITE_SPIP/</link>
-		[<height>(#LOGO_SITE_SPIP||image_reduire{144,400}|extraire_attribut{height})</height>]
-		[<width>(#LOGO_SITE_SPIP||image_reduire{144,400}|extraire_attribut{width})</width>]
+		[<height>(#LOGO_SITE_SPIP|image_reduire{144,400}|extraire_attribut{height})</height>]
+		[<width>(#LOGO_SITE_SPIP|image_reduire{144,400}|extraire_attribut{width})</width>]
 	</image>
 ]
 
diff --git a/squelettes-dist/breve.html b/squelettes-dist/breve.html
index e92b2afa6b..d79a34a34e 100644
--- a/squelettes-dist/breve.html
+++ b/squelettes-dist/breve.html
@@ -23,7 +23,7 @@
         <div id="hierarchie"><a href="#URL_SITE_SPIP/" ><:accueil_site:></a><BOUCLE_ariane(RUBRIQUES){id_rubrique}> &gt; <a href="#URL_RUBRIQUE">[(#TITRE|couper{80})]</a></BOUCLE_ariane>[ &gt; <strong class="on">(#TITRE|couper{80})</strong>]</div>
 
         <div class="cartouche">
-            [(#LOGO_BREVE||image_reduire{200,200})]
+            [(#LOGO_BREVE|image_reduire{200,200})]
             <h1 class="#EDIT{titre}">#TITRE</h1>
             <p><small><abbr class="published" title="[(#DATE|date_iso)]">[(#DATE|nom_jour) ][(#DATE|affdate)]</abbr></small></p>
         </div>
diff --git a/squelettes-dist/forum.html b/squelettes-dist/forum.html
index 46a83948bf..2dd97478f3 100644
--- a/squelettes-dist/forum.html
+++ b/squelettes-dist/forum.html
@@ -75,14 +75,14 @@
             </BOUCLE_forum_parent>
             
             <BOUCLE_article(ARTICLES) {id_article}>
-            [(#LOGO_ARTICLE||image_reduire{150,100})]
+            [(#LOGO_ARTICLE|image_reduire{150,100})]
             <h3><a href="#URL_ARTICLE">#TITRE</a></h3>
             <small>[(#DATE|affdate_jourcourt)][, <:par_auteur:> (#LESAUTEURS)]</small>
             [<div class="introduction">(#INTRODUCTION)</div>]
             </BOUCLE_article>
             
             <BOUCLE_breve(BREVES) {id_breve}>
-            [(#LOGO_BREVE||image_reduire{150,100})]
+            [(#LOGO_BREVE|image_reduire{150,100})]
             <h3><a href="#URL_BREVE">#TITRE</a></h3>
             <small>[(#DATE|affdate_jourcourt)]</small>
             [<div class="introduction">(#INTRODUCTION)</div>]
diff --git a/squelettes-dist/inc-rss-item.html b/squelettes-dist/inc-rss-item.html
index 7db4d7967b..3846ec6c0f 100644
--- a/squelettes-dist/inc-rss-item.html
+++ b/squelettes-dist/inc-rss-item.html
@@ -33,7 +33,7 @@
 	ce qui permet une syndication plus riche (mais plus "lourde").
 	Fonction desactivable depuis les reglages du site.
 ][
-(#CONFIG{syndication_integrale}|=={oui}|?{' ',''})<content:encoded>[(#LOGO_ARTICLE|right||image_reduire{150,150}|texte_backend)
+(#CONFIG{syndication_integrale}|=={oui}|?{' ',''})<content:encoded>[(#LOGO_ARTICLE{right}|image_reduire{150,150}|texte_backend)
 		][&lt;div class='rss_chapo'&gt;(#CHAPO|texte_backend)&lt;/div&gt;
 		][&lt;div class='rss_texte'&gt;(#TEXTE|
 			image_reduire{500,0}|texte_backend)&lt;/div&gt;
diff --git a/squelettes-dist/mot.html b/squelettes-dist/mot.html
index cf9c30cd82..61d9d15930 100644
--- a/squelettes-dist/mot.html
+++ b/squelettes-dist/mot.html
@@ -23,7 +23,7 @@
         <div id="hierarchie"><a href="#URL_SITE_SPIP/"><:accueil_site:></a> &gt; <:mots_clefs:><BOUCLE_ariane(GROUPES_MOTS){id_groupe}> &gt; [(#TITRE|couper{80})]</BOUCLE_ariane>[ &gt; <strong class="on">(#TITRE|couper{80})</strong>]</div>
 
         <div class="cartouche">
-            [(#LOGO_MOT||image_reduire{200,200})]
+            [(#LOGO_MOT|image_reduire{200,200})]
             <h1 class="#EDIT{titre}">#TITRE</h1>
         </div>
 
diff --git a/squelettes-dist/rubrique.html b/squelettes-dist/rubrique.html
index b8cbd6680d..34637fbbd1 100644
--- a/squelettes-dist/rubrique.html
+++ b/squelettes-dist/rubrique.html
@@ -26,7 +26,7 @@
         <div id="hierarchie"><a href="#URL_SITE_SPIP/"><:accueil_site:></a><BOUCLE_ariane(HIERARCHIE){id_rubrique}> &gt; <a href="#URL_RUBRIQUE">[(#TITRE|couper{80})]</a></BOUCLE_ariane>[ &gt; <strong class="on">(#TITRE|couper{80})</strong>]</div>
 
         <div class="cartouche">
-            [(#LOGO_RUBRIQUE||image_reduire{200,200})]
+            [(#LOGO_RUBRIQUE|image_reduire{200,200})]
             <h1 class="#EDIT{titre}">#TITRE</h1>
             [<p><small><:dernier_ajout:> : (#DATE|affdate_jourcourt).</small></p>]
         </div>
@@ -41,7 +41,7 @@
             <ul>
                 <BOUCLE_articles(ARTICLES) {id_rubrique} {par date}{inverse} {pagination}>
                 <li>
-                    [(#LOGO_ARTICLE|#URL_ARTICLE|image_reduire{150,100})]
+                    [(#LOGO_ARTICLE{#URL_ARTICLE}|image_reduire{150,100})]
                     <h3><a href="#URL_ARTICLE">#TITRE</a></h3>
                     <small>[(#DATE|affdate_jourcourt)][, <:par_auteur:> (#LESAUTEURS)]</small>
                 </li>
diff --git a/squelettes-dist/site.html b/squelettes-dist/site.html
index 7dcba90b87..a01310e15b 100644
--- a/squelettes-dist/site.html
+++ b/squelettes-dist/site.html
@@ -26,7 +26,7 @@
         <div id="hierarchie"><a href="#URL_SITE_SPIP/"><:accueil_site:></a><BOUCLE_ariane(HIERARCHIE){id_syndic}> &gt; <a href="#URL_RUBRIQUE">[(#TITRE|couper{80})]</a></BOUCLE_ariane>[ &gt; <strong class="on">(#NOM_SITE|couper{80})</strong>]</div>
 
         <div class="cartouche">
-            <a href="#URL_SITE">[(#LOGO_SITE||image_reduire{150,100})]</a>
+            <a href="#URL_SITE">[(#LOGO_SITE|image_reduire{150,100})]</a>
             <h1 class="#EDIT{nom_site}">#NOM_SITE</h1>
         </div>
 
diff --git a/squelettes-dist/sommaire.html b/squelettes-dist/sommaire.html
index 372aad897c..9e41bd1a93 100644
--- a/squelettes-dist/sommaire.html
+++ b/squelettes-dist/sommaire.html
@@ -33,7 +33,7 @@
 			<ul>
 				<BOUCLE_articles_recents(ARTICLES) {par date}{inverse} {pagination 5}>
 				<li class="hentry">
-					[(#LOGO_ARTICLE_RUBRIQUE|#URL_ARTICLE|image_reduire{150,100})]
+					[(#LOGO_ARTICLE_RUBRIQUE{#URL_ARTICLE}|image_reduire{150,100})]
 					<h3 class="entry-title"><a href="#URL_ARTICLE" rel="bookmark">#TITRE</a></h3>
 					<small><abbr class="published"[ title="(#DATE|date_iso)"]>[(#DATE|affdate_jourcourt)]</abbr>[, <:par_auteur:> (#LESAUTEURS)]</small>
 					[<div class="#EDIT{intro} introduction entry-content">(#INTRODUCTION)</div>]
-- 
GitLab