From 6732c724ce30bbdd69eee788b8f8be3062406e12 Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Tue, 8 Aug 2006 23:33:49 +0000
Subject: [PATCH] permettre la pagination en ahah

---
 ecrire/inc/filtres.php     | 4 ++--
 ecrire/public/compiler.php | 7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php
index 914fe09a86..6e17085f05 100644
--- a/ecrire/inc/filtres.php
+++ b/ecrire/inc/filtres.php
@@ -1396,13 +1396,13 @@ function calcul_pagination($total, $nom, $pas, $liste = true) {
 	$debut = 'debut'.$nom;
 
 	$pagination = array(
-		'lien_base' => self(),
+		'lien_base' => parametre_url(self(),'ahah_id',''), // nettoyer l'id ahah eventuel
 		'total' => $total,
 		'position' => intval(_request($debut)),
 		'pas' => $pas,
 		'nombre_pages' => floor(($total-1)/$pas)+1,
 		'page_courante' => floor(intval(_request($debut))/$pas)+1,
-		'lien_pagination' => '<a href="@url@">@item@</a>',
+		'lien_pagination' => '<a href="@url@" class="lien_pagination">@item@</a>',
 		'lien_item_courant' => '<span class="on">@item@</span>'
 	);
 
diff --git a/ecrire/public/compiler.php b/ecrire/public/compiler.php
index 526cdc8265..2b2fc50cbc 100644
--- a/ecrire/public/compiler.php
+++ b/ecrire/public/compiler.php
@@ -435,6 +435,7 @@ function compile_cas($tableau, $descr, &$boucles, $id_boucle) {
 	// par un caractere distinguant le cas, pour exploitation par debug.
 	foreach ($tableau as $p) {
 
+		$ahah_out = false;
 		switch($p->type) {
 		// texte seul
 		case 'texte':
@@ -488,6 +489,8 @@ function compile_cas($tableau, $descr, &$boucles, $id_boucle) {
 				$newdescr, $boucles, $id_boucle);
 			$apres = calculer_liste($p->apres,
 				$newdescr, $boucles, $id_boucle);
+			if ($boucles[$nom]->mode_partie=='p+')
+				$ahah_out = array($nom,$descr['nom']);
 			$newdescr['niv']--;
 			$altern = calculer_liste($p->altern,
 				$newdescr, $boucles, $id_boucle);
@@ -541,6 +544,10 @@ function compile_cas($tableau, $descr, &$boucles, $id_boucle) {
 				$code = "((strval($t = $code)!='')"
 					." ?\n\t$tab($res) :\n\t$tab($altern))";
 			}
+			if ($ahah_out!==false){
+				$code = "(\$ahah = '<div id=\"$ahah_out[0]_$ahah_out[1]\" class=\"bloc_ahah_pagination $ahah_out[0] $ahah_out[1]\">'.$code.'</div>').
+				((\$_GET['ahah_id']=='$ahah_out[0]_$ahah_out[1]')?die(\$ahah):'')";
+			}
 		}
 		if ($code != "''")
 			$codes[]= (($mode == 'validation') ?
-- 
GitLab