From 91488f211b627173d0e914e56cf7b77ce5249c3e Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Tue, 23 Sep 2008 08:37:02 +0000
Subject: [PATCH] =?UTF-8?q?Report=20de=20[12744],=20le=20flux=20RSS=20du?=
 =?UTF-8?q?=20contr=C3=B4le=20des=20p=C3=A9titions=20marche=20=C3=A0=20nou?=
 =?UTF-8?q?veau.=20Merci=20C=C3=A9dric.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/utils.php      | 20 ++++++++++++--------
 ecrire/public/balises.php | 26 ++++++++++----------------
 2 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php
index 5d42fbd791..0e733af1a6 100644
--- a/ecrire/inc/utils.php
+++ b/ecrire/inc/utils.php
@@ -771,7 +771,6 @@ function generer_url_entite($id='', $entite='', $args='', $ancre='', $public=NUL
 	return '';
 }
 
-// http://doc.spip.org/@generer_url_entite_absolue
 function generer_url_entite_absolue($id='', $entite='', $args='', $ancre='', $connect=NULL)
 {
 	if (!$connect) $connect = true;
@@ -1462,18 +1461,23 @@ function recuperer_fond($fond, $contexte=array(), $options = array(), $connect='
 	if (isset($contexte['fond']))
 		$fond = $contexte['fond'];
 
-	// Si on a inclus sans fixer le critere de lang, on prend la langue courante
-	if (!isset($contexte['lang']))
-		$contexte['lang'] = $GLOBALS['spip_lang'];
-
-	if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
-		$lang_select = lang_select($contexte['lang']);
-	} else $lang_select ='';
+	$lang_select = '';
+	if (!isset($options['etoile']) OR !$options['etoile']){
+		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
+		if (!isset($contexte['lang']))
+			$contexte['lang'] = $GLOBALS['spip_lang'];
+	
+		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
+			$lang_select = lang_select($contexte['lang']);
+		}
+	}
 
 	@$GLOBALS['_INC_PUBLIC']++;
 
 	foreach(is_array($fond) ? $fond : array($fond) as $f){
 		$page = evaluer_fond($f, $contexte, $connect);
+		if (isset($options['ajax'])AND $options['ajax'])
+			$page['texte'] = encoder_contexte_ajax($contexte,'',$page['texte']);
 		if (isset($options['raw']) AND $options['raw'])
 			$pages[] = $page;
 		else
diff --git a/ecrire/public/balises.php b/ecrire/public/balises.php
index ab2140a9de..c4b3034ee3 100644
--- a/ecrire/public/balises.php
+++ b/ecrire/public/balises.php
@@ -820,7 +820,6 @@ function balise_CONFIG_dist($p) {
 		return balise_ENV_dist($p, '$GLOBALS["meta"]');
 }
 
-// http://doc.spip.org/@balise_CONNECT_dist
 function balise_CONNECT_dist($p) {
 	$p->code = '($connect ? $connect : NULL)';
 	$p->interdire_scripts = false;
@@ -1070,15 +1069,12 @@ function balise_INCLURE_dist($p) {
 
 		$_connect = _q(!$id_boucle ? '' : $p->boucles[$id_boucle]->sql_serveur);
 
-		$page = $p->etoile
-		  ? "evaluer_fond('', \$l = $_l, $_connect)"
-		  : "recuperer_fond('',\$l =  $_l, array(), $_connect)";
-
-		$retour = !isset($_contexte['ajax']) ? 
-		  "\$p" :
-		  'encoder_contexte_ajax($l,"",$p)';
-
-		$p->code = "(!(\$p = $page) ? '' :\n\t$retour)";
+		$_options = array();
+		if (isset($_contexte['ajax'])) $_options[] = "'ajax'=>true";
+		if ($p->etoile) $_options[] = "'etoile'=>true";
+		$_options = "array(" . join(',',$_options) . ")";
+		
+		$p->code = "recuperer_fond('',\$l =  $_l, $_options, $_connect)";
 
 	} else {
 		$n = interprete_argument_balise(1,$p);
@@ -1145,13 +1141,11 @@ function balise_MODELE_dist($p) {
 
 	$connect = $p->boucles[$p->id_boucle]->sql_serveur;
 
-	$page = "\$p = recuperer_fond('modeles/$nom', \$l = array(".join(',', $_contexte).",'recurs='.(++\$recurs), \$GLOBALS['spip_lang']), array('trim'=>true, 'modele'=>true), " . _q($connect) . ")";
-
-	$retour = !isset($_contexte['ajax']) ? 
-		  '$p' :
-		  'encoder_contexte_ajax($l,"",$p)';
+	$page = "\$p = recuperer_fond('modeles/$nom', \$l = array(".join(',', $_contexte).",'recurs='.(++\$recurs), \$GLOBALS['spip_lang']), array('trim'=>true, 'modele'=>true"
+	. (isset($_contexte['ajax'])?", 'ajax'=>true":'')
+	. "), " . _q($connect) . ")";
 
-	$p->code = "(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' : (!($page) ? '' :\n\t$retour))";
+	$p->code = "(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' : $page)";
 
 	$p->interdire_scripts = false; // securite assuree par le squelette
 
-- 
GitLab