From 22a280a0eace7b5285a76603f1de58407a1ad09f Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Sun, 8 Oct 2006 19:25:56 +0000
Subject: [PATCH] Unifier les noms des fonctions et fichiers utilisant Ajax.

---
 .gitattributes               |   3 +-
 ecrire/exec/plonger.php      |   4 +-
 ecrire/exec/rubriquer.php    |   3 +-
 ecrire/exec/selectionner.php |  10 +-
 ecrire/inc/mini_nav.php      | 183 -----------------------------------
 ecrire/inc/plonger.php       |  91 +++++++++++++++++
 ecrire/inc/selectionner.php  | 109 +++++++++++++++++++++
 7 files changed, 211 insertions(+), 192 deletions(-)
 delete mode 100644 ecrire/inc/mini_nav.php
 create mode 100644 ecrire/inc/plonger.php
 create mode 100644 ecrire/inc/selectionner.php

diff --git a/.gitattributes b/.gitattributes
index dbead44f06..35b2f8cbdf 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -452,13 +452,14 @@ ecrire/inc/lang_liste.php -text
 ecrire/inc/legender.php -text
 ecrire/inc/maintenance.php -text
 ecrire/inc/message_select.php -text
-ecrire/inc/mini_nav.php -text
 ecrire/inc/minipres.php -text
 ecrire/inc/petitionner.php -text
+ecrire/inc/plonger.php -text
 ecrire/inc/plugin.php -text
 ecrire/inc/popularites.php -text
 ecrire/inc/poster.php -text
 ecrire/inc/referencer_traduction.php -text
+ecrire/inc/selectionner.php -text
 ecrire/inc/sites_voir.php -text
 ecrire/inc/suivi_versions.php -text
 ecrire/inc/syndic.php -text
diff --git a/ecrire/exec/plonger.php b/ecrire/exec/plonger.php
index 8cf35c1116..5b12894d25 100644
--- a/ecrire/exec/plonger.php
+++ b/ecrire/exec/plonger.php
@@ -23,8 +23,8 @@ function exec_plonger_dist()
 	$col = intval($col);
 
 	include_spip('inc/texte');
-	include_spip('inc/mini_nav');
-	ajax_retour(mini_afficher_rubrique($id, htmlentities($rac), array(), $col, $exclus));
+	$plonger = charger_fonction('plonger', 'inc');
+	ajax_retour($plonger($id, htmlentities($rac), array(), $col, $exclus));
 }
 
 ?>
diff --git a/ecrire/exec/rubriquer.php b/ecrire/exec/rubriquer.php
index 428a6cecb4..06a19cebf9 100644
--- a/ecrire/exec/rubriquer.php
+++ b/ecrire/exec/rubriquer.php
@@ -21,7 +21,8 @@ function exec_rubriquer_dist()
 
 	include_spip('inc/texte');
 	include_spip('inc/mini_nav');
-	ajax_retour(mini_nav($id, "aff_nav_recherche", 
+	$selectionner = charger_fonction('selectionner', 'inc');
+	ajax_retour($selectionner($id, "aff_nav_recherche", 
 			"document.location.href='" . generer_url_ecrire('naviguer', "id_rubrique=::sel::") .
 			      "';", 0, true));
 }
diff --git a/ecrire/exec/selectionner.php b/ecrire/exec/selectionner.php
index e35ea74452..401214d0b5 100644
--- a/ecrire/exec/selectionner.php
+++ b/ecrire/exec/selectionner.php
@@ -16,14 +16,14 @@ if (!defined("_ECRIRE_INC_VERSION")) return;
 
 function exec_selectionner_dist()
 {
-	global $id, $exclus, $rac;
-	$id = intval($id);
-	$exclus = intval($exclus);
+	$id = intval(_request('id'));
+	$exclus = intval(_request('exclus'));
 	$type = _request('type');
+	$rac = _request('racine');
 
 	include_spip('inc/texte');
-	include_spip('inc/mini_nav');
-	ajax_retour(mini_nav($id, "choix_parent", "this.form.id_rubrique.value=::sel::;this.form.titreparent.value='::sel2::';findObj_forcer('selection_rubrique').style.display='none';", $exclus, $rac, $type!='breve'));
+	$selectionner = charger_fonction('selectionner', 'inc');
+	ajax_retour($selectionner($id, "choix_parent", "this.form.id_rubrique.value=::sel::;this.form.titreparent.value='::sel2::';findObj_forcer('selection_rubrique').style.display='none';", $exclus, $rac, $type!='breve'));
 
 }
 ?>
diff --git a/ecrire/inc/mini_nav.php b/ecrire/inc/mini_nav.php
deleted file mode 100644
index c4f74d7c9d..0000000000
--- a/ecrire/inc/mini_nav.php
+++ /dev/null
@@ -1,183 +0,0 @@
-<?php
-
-/***************************************************************************\
- *  SPIP, Systeme de publication pour l'internet                           *
- *                                                                         *
- *  Copyright (c) 2001-2006                                                *
- *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
- *                                                                         *
- *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
- *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
-\***************************************************************************/
-
-if (!defined("_ECRIRE_INC_VERSION")) return;
-
-// http://doc.spip.org/@mini_afficher_rubrique
-function mini_afficher_rubrique($id_rubrique, $rac="", $list=array(), $col = 1, $exclu=0) {
-	global  $spip_lang_left;
-	
-	if ($list) $id_rubrique = $list[$col-1];
-	
-	$ret = '';
-
-	# recherche les filles et petites-filles de la rubrique donnee
-	$ordre = array();
-	$rub = array();
-
-	$res = spip_query("SELECT rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie FROM spip_rubriques AS rub1, spip_rubriques AS rub2 WHERE ((rub1.id_parent = $id_rubrique) OR (rub2.id_parent = $id_rubrique AND rub1.id_parent=rub2.id_rubrique)) AND rub1.id_rubrique!=$exclu GROUP BY rub1.id_rubrique");
-
-	while ($row = spip_fetch_array($res)) {
-		$rub[$row['id_parent']]['enfants'] = true;
-		if ($row['id_parent'] == $id_rubrique)
-			$ordre[$row['id_rubrique']]= trim(typo($row['titre']))
-			. (($row['langue_choisie'] != 'oui')
-			   ? '' : (' [' . $row['lang'] . ']'));
-	}
-
-	$next = $list[$col];
-	if ($ordre) {
-		asort($ordre);
-		$rec = generer_url_ecrire('plonger',"rac=$rac&exclus=$exclu&col=".($col+1));
-		$args = "'$rac',this,$col,'$spip_lang_left'";
-		while (list($id, $titrebrut) = each($ordre)) {
-
-			$titre = "<div class='"
-			. ($id_rubrique ? 'petite-rubrique' : "petit-secteur")
-			. "'>"
-			. supprimer_numero($titrebrut)
-			. "</div>";
-
-			if (isset($rub[$id]["enfants"])) {
-				$titre = "<div class='rub-ouverte'>$titre</div>";
-
-				$acces = "firstChild.";
-				$url = "\nhref='$rec&amp;id=$id'" ;
-			} else {  $url = $acces = ''; }
-
-			$ret .= "<a class='"
-			. (($id == $next) ? "highlight" : "pashighlight")
-			. "'"
-			. $url
-			.  "\nonClick=\"changerhighlight(this);return "
-			. (!is_array($list) ? ' false' 
-			   : "aff_selection_provisoire($id,$args)")
-# ce lien provoque la selection (directe) de la rubrique cliquee
-# et l'affichage de son titre dans le bandeau
-			. "\"\nondblclick=\""
-			. "return aff_selection_titre(this."
-			. $acces
-			. "firstChild.firstChild.nodeValue,$id,$args);"
-			. "\">$titre</a>";
-		}
-	}
-
-	$nom_col = $rac . "_col_".($col+1);
-	$left = ($col*150);
-
-	return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: "
-	. ($left-30)
-	. "px; top: 2px; z-index: 2;' id='img_$nom_col'")
-	. "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: "
-	.($left-150)
-	."px;'>"
-	. $ret
-	. "\n</div>\n<div id='$nom_col'>"
-	. ($next
-	   ? mini_afficher_rubrique($id_rubrique, $rac, $list, $col+1, $exclu)
-	   : "")
-	. "\n</div>";
-}
-
-
-// http://doc.spip.org/@mini_hierarchie_rub
-function mini_hierarchie_rub ($id_rubrique) {
-	$row = spip_fetch_array(spip_query("SELECT id_parent FROM spip_rubriques WHERE id_rubrique = " . intval($id_rubrique)));
-	return $row["id_parent"];
-}
-
-
-// http://doc.spip.org/@mini_afficher_hierarchie
-function mini_hier ($id_rubrique) {
-	
-	$id_parent = $id_rubrique;
-	$liste = $id_rubrique;
-	while ($id_parent = mini_hierarchie_rub ($id_parent)) {
-		$liste = $id_parent.",".$liste;
-	}
-	$liste = "0,".$liste;
-	return explode(',',$liste);
-}
-
-//
-// Affiche un mini-navigateur ajax positionne sur la rubrique $sel
-//
-// http://doc.spip.org/@mini_nav
-function mini_nav ($sel, $rac="",$fonction="", $rub_exclus=0, $aff_racine=false, $plonger=true) {
-
-	if (!$fonction)
-		$fonction = "document.location='"
-		. generer_url_ecrire('naviguer', "id_rubrique=::sel::")
-		. "';";
-
-	global $couleur_foncee, $spip_lang_right, $spip_lang_left;
-	if ($id_rubrique < 1) $id_rubrique = 0;
-
-	$ret = "<div id='$rac'>"
-	. "<div style='display: none;'>"
-	. "<input type='text' id='".$rac."_fonc' value=\"$fonction\" />"
-	. "</div>\n"
-	. "<table width='100%' cellpadding='0' cellspacing='0'>"
-	. "<tr>"
-	. "<td style='vertical-align: bottom;'>";
-
-	if ($aff_racine) {
-		$onClick = " aff_selection('rubrique','$rac', '0');";
-		# ce lien provoque la selection (directe) de la rubrique cliquee
-		$ondbClick = "findObj_forcer('id_parent').value=0;";
-		# et l'affichage de son titre dans le bandeau
-		$ondbClick .= "findObj_forcer('titreparent').value='"
-			. strtr(
-				str_replace("'", "&#8217;",
-				str_replace('"', "&#34;",
-					textebrut(_T('info_racine_site')))),
-				"\n\r", "  ")."';";
-		$ondbClick .= "findObj_forcer('selection_rubrique').style.display='none';";
-	}
-
-	if ($plonger)
-		$onClick .= "charger_id_url('" . generer_url_ecrire('plonger',"rac=$rac&exclus=$rub_exclus&id=0&col=1", true) . "', '".$rac."_col_1');";
-
-	$ret .= "\n<div class='arial11 petite-racine'\nonclick=\""
-	. $onClick
-	. "\"\nondblclick=\""
-	. $ondbClick
-	. $onClick
-	. "\">\n<div class='pashighlight'>"
-	. _T("info_racine_site")
-	. "</div></div>"
-	. "</td>"	. "\n<td>"
-	. http_img_pack("searching.gif", "*", "style='visibility: hidden;' id='img_".$rac."_col_1'")
-	. "</td>"
-	. "\n<td style='text-align: $spip_lang_right'>"
-	. "<input style='width: 100px;' type='search' id='"
-	. $rac
-	. "_champ_recherche'\nonkeypress=\"t=setTimeout('lancer_recherche_rub(\'"
-	  . $rac
-	  . "_champ_recherche\',\'$rac\',\'$rub_exclus\')', 200); key = event.keyCode; if (key == 13 || key == 3) { return false;} \" />"
-	. "</td></tr></table>\n<div id='"
-	. $rac
-	. "_principal' style='position: relative; height: 170px; background-color: white; border: 1px solid $couleur_foncee; overflow: auto;'><div id='"
-	. $rac
-	. "_col_1' class='arial1'>" 
-	. ($plonger
-	   ? mini_afficher_rubrique($sel, $rac, mini_hier($sel), 1, $rub_exclus)
-	   : mini_afficher_rubrique(0, $rac, false, 1, $rub_exclus))
-	. "</div></div>\n<div id='"
-	. $rac
-	. "_selection'></div></div>\n";
-
-	return $ret;
-}
-
-
-?>
diff --git a/ecrire/inc/plonger.php b/ecrire/inc/plonger.php
new file mode 100644
index 0000000000..7c9c56d5e6
--- /dev/null
+++ b/ecrire/inc/plonger.php
@@ -0,0 +1,91 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2006                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+// http://doc.spip.org/@mini_afficher_rubrique
+function inc_plonger_dist($id_rubrique, $idom="", $list=array(), $col = 1, $exclu=0) {
+	global  $spip_lang_left;
+	
+	if ($list) $id_rubrique = $list[$col-1];
+	
+	$ret = '';
+
+	# recherche les filles et petites-filles de la rubrique donnee
+	$ordre = array();
+	$rub = array();
+
+	$res = spip_query("SELECT rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie FROM spip_rubriques AS rub1, spip_rubriques AS rub2 WHERE ((rub1.id_parent = $id_rubrique) OR (rub2.id_parent = $id_rubrique AND rub1.id_parent=rub2.id_rubrique)) AND rub1.id_rubrique!=$exclu GROUP BY rub1.id_rubrique");
+
+	while ($row = spip_fetch_array($res)) {
+		$rub[$row['id_parent']]['enfants'] = true;
+		if ($row['id_parent'] == $id_rubrique)
+			$ordre[$row['id_rubrique']]= trim(typo($row['titre']))
+			. (($row['langue_choisie'] != 'oui')
+			   ? '' : (' [' . $row['lang'] . ']'));
+	}
+
+	$next = $list[$col];
+	if ($ordre) {
+		asort($ordre);
+		$rec = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclu&col=".($col+1));
+		$args = "'$idom',this,$col,'$spip_lang_left'";
+		while (list($id, $titrebrut) = each($ordre)) {
+
+			$titre = "<div class='"
+			. ($id_rubrique ? 'petite-rubrique' : "petit-secteur")
+			. "'>"
+			. supprimer_numero($titrebrut)
+			. "</div>";
+
+			if (isset($rub[$id]["enfants"])) {
+				$titre = "<div class='rub-ouverte'>$titre</div>";
+
+				$acces = "firstChild.";
+				$url = "\nhref='$rec&amp;id=$id'" ;
+			} else {  $url = $acces = ''; }
+
+			$ret .= "<a class='"
+			. (($id == $next) ? "highlight" : "pashighlight")
+			. "'"
+			. $url
+			.  "\nonClick=\"changerhighlight(this);return "
+			. (!is_array($list) ? ' false' 
+			   : "aff_selection_provisoire($id,$args)")
+# ce lien provoque la selection (directe) de la rubrique cliquee
+# et l'affichage de son titre dans le bandeau
+			. "\"\nondblclick=\""
+			. "return aff_selection_titre(this."
+			. $acces
+			. "firstChild.firstChild.nodeValue,$id,$args);"
+			. "\">$titre</a>";
+		}
+	}
+
+	$idom2 = $idom . "_col_".($col+1);
+	$left = ($col*150);
+
+	return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: "
+	. ($left-30)
+	. "px; top: 2px; z-index: 2;' id='img_$idom2'")
+	. "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: "
+	.($left-150)
+	."px;'>"
+	. $ret
+	. "\n</div>\n<div id='$idom2'>"
+	. ($next
+	   ? inc_plonger_dist($id_rubrique, $idom, $list, $col+1, $exclu)
+	   : "")
+	. "\n</div>";
+}
+
+?>
diff --git a/ecrire/inc/selectionner.php b/ecrire/inc/selectionner.php
new file mode 100644
index 0000000000..758d4dd985
--- /dev/null
+++ b/ecrire/inc/selectionner.php
@@ -0,0 +1,109 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2006                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+//
+// Affiche un mini-navigateur ajax positionne sur la rubrique $sel
+//
+
+function inc_selectionner_dist ($sel, $idom="",$fonction="", $exclus=0, $aff_racine=false, $recur=true) {
+
+	global $couleur_foncee, $spip_lang_right, $spip_lang_left;
+
+	if (!$fonction)
+		$fonction = "document.location='"
+		. generer_url_ecrire('naviguer', "id_rubrique=::sel::")
+		. "';";
+
+	if ($recur) $recur = mini_hier($sel); else $sel = 0;
+
+	if ($aff_racine) {
+		$onClick = " aff_selection('rubrique','$idom', '0');";
+
+		$ondbClick = "findObj_forcer('id_parent').value=0;"
+		.  "findObj_forcer('titreparent').value='"
+			. strtr(
+				str_replace("'", "&#8217;",
+				str_replace('"', "&#34;",
+					textebrut(_T('info_racine_site')))),
+				"\n\r", "  ")."';"
+		. "findObj_forcer('selection_rubrique').style.display='none';";
+	}
+
+	$idom1 = $idom . "_champ_recherche";
+	$idom2 = $idom . "_principal";
+	$idom3 = $idom . "_selection";
+	$idom4 = $idom . "_col_1";
+	$idom5 = 'img_' . $idom4;
+	$idom6 = $idom."_fonc";
+
+	if ($recur) {
+		$plonger = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1", true);
+		$onClick .= "charger_id_url('$plonger', '$idom4');";
+	}
+
+	$plonger = charger_fonction('plonger', 'inc');
+		
+	return "<div id='$idom'>"
+	. "<div style='display: none;'>"
+	. "<input type='text' id='$idom6' value=\"$fonction\" />"
+	. "</div>\n"
+	. "<table width='100%' cellpadding='0' cellspacing='0'>"
+	. "<tr>"
+	. "<td style='vertical-align: bottom;'>"
+	. "\n<div class='arial11 petite-racine'\nonclick=\""
+	. $onClick
+	. "\"\nondblclick=\""
+	. $ondbClick
+	. $onClick
+	. "\">\n<div class='pashighlight'>"
+	. _T("info_racine_site")
+	. "</div></div></td>\n<td>"
+	. http_img_pack("searching.gif", "*", "style='visibility: hidden;' id='$idom5'")
+	. "</td>"
+	. "\n<td style='text-align: $spip_lang_right'>"
+	. "<input style='width: 100px;' type='search' id='$idom1'"
+	. "\nonkeypress=\"t=setTimeout('lancer_recherche_rub(\'"
+	. $idom1
+	. "\',\'"
+	. $idom
+	. "\',\'"
+	. $exclus
+	. "\')', 200); key = event.keyCode; if (key == 13 || key == 3) { return false;} \" />"
+	. "</td></tr></table>\n<div id='$idom2'"
+	. " style='position: relative; height: 170px; background-color: white; border: 1px solid $couleur_foncee; overflow: auto;'><div id='$idom4'"
+	. " class='arial1'>" 
+	. $plonger($sel, $idom, $recur, 1, $exclus)
+	. "</div></div>\n<div id='$idom3'></div></div>\n";
+}
+
+// http://doc.spip.org/@mini_afficher_hierarchie
+function mini_hier ($id_rubrique) {
+	
+	$id_parent = $id_rubrique;
+	$liste = $id_rubrique;
+	while ($id_parent = mini_hierarchie_rub ($id_parent)) {
+		$liste = $id_parent.",".$liste;
+	}
+	$liste = "0,".$liste;
+	return explode(',',$liste);
+}
+
+
+// http://doc.spip.org/@mini_hierarchie_rub
+function mini_hierarchie_rub ($id_rubrique) {
+	$row = spip_fetch_array(spip_query("SELECT id_parent FROM spip_rubriques WHERE id_rubrique = " . intval($id_rubrique)));
+	return $row["id_parent"];
+}
+
+?>
-- 
GitLab