From 2f76180a812869075b04d6a309e1eaea85ad453f Mon Sep 17 00:00:00 2001
From: ARNO* <arno@rezo.net>
Date: Fri, 8 Apr 2005 08:55:39 +0000
Subject: [PATCH] Affichage sous-rubs en fonction

---
 ecrire/inc_rubriques.php3 | 133 ++++++++++++++++++++++++++++++++++++++
 ecrire/index.php3         | 132 +------------------------------------
 ecrire/naviguer.php3      | 126 +-----------------------------------
 3 files changed, 139 insertions(+), 252 deletions(-)

diff --git a/ecrire/inc_rubriques.php3 b/ecrire/inc_rubriques.php3
index 38c7dbb217..cd6bccdd64 100644
--- a/ecrire/inc_rubriques.php3
+++ b/ecrire/inc_rubriques.php3
@@ -228,4 +228,137 @@ function calculer_langues_rubriques() {
 	}
 }
 
+
+function enfant_rub($collection){
+	global $les_enfants, $couleur_foncee, $lang_dir;
+	global $spip_display, $spip_lang_left, $spip_lang_right;
+	global $connect_id_auteur;
+	
+	$query2 = "SELECT * FROM spip_rubriques WHERE id_parent='$collection' ORDER BY 0+titre,titre";
+	$result2 = spip_query($query2);
+
+
+	if ($spip_display == 4) $les_enfants .= "<ul>";
+	
+	while($row=spip_fetch_array($result2)){
+		$id_rubrique=$row['id_rubrique'];
+		$id_parent=$row['id_parent'];
+		$titre=$row['titre'];
+
+		$bouton_layer = bouton_block_invisible("enfants$id_rubrique");
+		$les_sous_enfants = sous_enfant_rub($id_rubrique);
+
+		changer_typo($row['lang']);
+		$descriptif=propre($row['descriptif']);
+
+		if ($spip_display == 4) $les_enfants .= "<li>";
+		$les_enfants.= "<div class='enfants'>";
+		
+		
+		if ($id_parent == "0") $logo_rub = "secteur-24.gif";
+		else $logo_rub = "rubrique-24.gif";
+		
+		$les_enfants .= debut_cadre_sous_rub($logo_rub, true);
+		
+		if ($spip_display != 1 AND $spip_display!=4 AND lire_meta('image_process') != "non") {
+			include_ecrire("inc_logos.php3");
+			$logo = decrire_logo("rubon$id_rubrique");
+			if ($logo) {
+				$fichier = $logo[0];
+				$taille_x = $logo[3];
+				$taille_y = $logo[4];
+				$taille = image_ratio($taille_x, $taille_y, 48, 36);
+				$w = $taille[0];
+				$h = $taille[1];
+				$fid = $logo[2];
+				$hash = calculer_action_auteur ("reduire $w $h");
+
+				$les_enfants.= "<img src='../spip_image_reduite.php3?img="._DIR_IMG."$fichier&taille_x=$w&taille_y=$h&hash=$hash&hash_id_auteur=$connect_id_auteur' width='$w' height='$h' align='$spip_lang_right' style='margin-$spip_lang_right: -6px; margin-top: -6px;' />";
+			}
+		}
+
+		if (strlen($les_sous_enfants) > 0){
+			$les_enfants .= $bouton_layer;
+		}
+
+		if (acces_restreint_rubrique($id_rubrique))
+		  $les_enfants .= http_img_pack("admin-12.gif", '', "width='12' height='12'", _T('image_administrer_rubrique'));
+
+		$les_enfants.= "<span dir='$lang_dir'><B><A HREF='naviguer.php3?id_rubrique=$id_rubrique'><font color='$couleur_foncee'>".typo($titre)."</font></A></B></span>";
+		if (strlen($descriptif)) {
+			$les_enfants .= "<div class='verdana1'>$descriptif</div>";
+		}
+
+		if ($spip_display != 4) $les_enfants .= $les_sous_enfants;		
+		
+		$les_enfants .= "<div style='clear:both;'></div>";
+
+
+		$les_enfants .= fin_cadre_sous_rub(true);
+		$les_enfants .= "</div>";
+		if ($spip_display == 4) $les_enfants .= "</li>";
+	}
+	if ($spip_display == 4) $les_enfants .= "</ul>";
+	
+}
+
+function sous_enfant_rub($collection2){
+	global $lang_dir, $spip_lang_dir, $spip_lang_left;
+	$query3 = "SELECT * FROM spip_rubriques WHERE id_parent='$collection2' ORDER BY 0+titre,titre";
+	$result3 = spip_query($query3);
+
+	if (spip_num_rows($result3) > 0){
+		$retour = debut_block_invisible("enfants$collection2")."\n<ul style='margin: 0px; padding: 0px; padding-top: 3px;'>\n";
+		while($row=spip_fetch_array($result3)){
+			$id_rubrique2=$row['id_rubrique'];
+			$id_parent2=$row['id_parent'];
+			$titre2=$row['titre'];
+			changer_typo($row['lang']);
+
+			$retour.="<div class='arial11' " .
+			  http_style_background('rubrique-12.gif', "left center no-repeat; padding: 2px; padding-$spip_lang_left: 18px; margin-$spip_lang_left: 3px") . "><A HREF='naviguer.php3?id_rubrique=$id_rubrique2'><span dir='$lang_dir'>".typo($titre2)."</span></a></div>\n";
+		}
+		$retour .= "</ul>\n\n".fin_block()."\n\n";
+	}
+	
+	return $retour;
+}
+
+function afficher_enfant_rub($id_rubrique, $afficher_bouton_creer=false) {
+	global $les_enfants, $spip_lang_right;
+	
+	enfant_rub($id_rubrique);
+	
+	$les_enfants2=substr($les_enfants,round(strlen($les_enfants)/2),strlen($les_enfants));
+	if (strpos($les_enfants2,"<div class='enfants'>")){
+		$les_enfants2=substr($les_enfants2,strpos($les_enfants2,"<div class='enfants'>"),strlen($les_enfants2));
+		$les_enfants1=substr($les_enfants,0,strlen($les_enfants)-strlen($les_enfants2));
+	}else{
+		$les_enfants1=$les_enfants;
+		$les_enfants2="";
+	}
+	
+	
+	// Afficher les sous-rubriques
+	echo "<div>&nbsp;</div>";
+	echo "<table cellpadding=0 cellspacing=0 border=0 width='100%'>";
+	echo "<tr><td valign='top' width=50% rowspan=2>$les_enfants1</td>";
+	echo "<td width='20' rowspan='2'>", http_img_pack("rien.gif", ' ', "width='20'") ."</td>\n";
+	echo "<td valign='top' width='50%'>$les_enfants2 &nbsp;";
+	if (strlen($les_enfants2) > 0) echo "<p>";
+	echo "</td></tr>";
+	
+	echo "<tr><td style='text-align: $spip_lang_right;' valign='bottom'><div align='$spip_lang_right'>";
+	if ($afficher_bouton_creer) {
+		if ($id_rubrique == "0") icone(_T('icone_creer_rubrique'), "rubriques_edit.php3?new=oui&retour=nav", "secteur-24.gif", "creer.gif");
+		else  icone(_T('icone_creer_sous_rubrique'), "rubriques_edit.php3?new=oui&retour=nav&id_parent=$id_rubrique", "rubrique-24.gif", "creer.gif");
+		echo "<p>";
+	}
+	echo "</div></td></tr>";
+	echo "</table><p />";
+	//////
+
+
+}
+
 ?>
diff --git a/ecrire/index.php3 b/ecrire/index.php3
index 6e5d4c81c4..486e0a3114 100644
--- a/ecrire/index.php3
+++ b/ecrire/index.php3
@@ -13,103 +13,7 @@
 
 include ("inc.php3");
 include_ecrire ("inc_calendrier.php");
-
-//// AFFICHAGE RUBRIQUES (COPIE naviguer.php3)
-function enfant($collection){
-	global $les_enfants, $couleur_foncee, $lang_dir;
-	global $spip_display, $spip_lang_left, $spip_lang_right;
-	global $connect_id_auteur;
-	
-	$query2 = "SELECT * FROM spip_rubriques WHERE id_parent='$collection' ORDER BY 0+titre,titre";
-	$result2 = spip_query($query2);
-
-
-	if ($spip_display == 4) $les_enfants .= "<ul>";
-	
-	while($row=spip_fetch_array($result2)){
-		$id_rubrique=$row['id_rubrique'];
-		$id_parent=$row['id_parent'];
-		$titre=$row['titre'];
-
-		$bouton_layer = bouton_block_invisible("enfants$id_rubrique");
-		$les_sous_enfants = sous_enfant($id_rubrique);
-
-		changer_typo($row['lang']);
-		$descriptif=propre($row['descriptif']);
-
-		if ($spip_display == 4) $les_enfants .= "<li>";
-		$les_enfants.= "<div class='enfants'>";
-		
-		
-		if ($id_parent == "0") $logo_rub = "secteur-24.gif";
-		else $logo_rub = "rubrique-24.gif";
-		
-		$les_enfants .= debut_cadre_sous_rub($logo_rub, true);
-		
-		if ($spip_display != 1 AND $spip_display!=4 AND lire_meta('image_process') != "non") {
-			include_ecrire("inc_logos.php3");
-			$logo = decrire_logo("rubon$id_rubrique");
-			if ($logo) {
-				$fichier = $logo[0];
-				$taille_x = $logo[3];
-				$taille_y = $logo[4];
-				$taille = image_ratio($taille_x, $taille_y, 48, 36);
-				$w = $taille[0];
-				$h = $taille[1];
-				$fid = $logo[2];
-				$hash = calculer_action_auteur ("reduire $w $h");
-
-				$les_enfants.= "<img src='../spip_image_reduite.php3?img="._DIR_IMG."$fichier&taille_x=$w&taille_y=$h&hash=$hash&hash_id_auteur=$connect_id_auteur' width='$w' height='$h' align='$spip_lang_right' style='margin-$spip_lang_right: -6px; margin-top: -6px;' />";
-			}
-		}
-
-		if (strlen($les_sous_enfants) > 0){
-			$les_enfants .= $bouton_layer;
-		}
-
-		if (acces_restreint_rubrique($id_rubrique))
-		  $les_enfants .= http_img_pack("admin-12.gif", '', "width='12' height='12'", _T('image_administrer_rubrique'));
-
-		$les_enfants.= "<span dir='$lang_dir'><B><A HREF='naviguer.php3?id_rubrique=$id_rubrique'><font color='$couleur_foncee'>".typo($titre)."</font></A></B></span>";
-		if (strlen($descriptif)) {
-			$les_enfants .= "<div class='verdana1'>$descriptif</div>";
-		}
-
-		if ($spip_display != 4) $les_enfants .= $les_sous_enfants;		
-		
-		$les_enfants .= "<div style='clear:both;'></div>";
-
-
-		$les_enfants .= fin_cadre_sous_rub(true);
-		$les_enfants .= "</div>";
-		if ($spip_display == 4) $les_enfants .= "</li>";
-	}
-	if ($spip_display == 4) $les_enfants .= "</ul>";
-	
-}
-
-function sous_enfant($collection2){
-	global $lang_dir, $spip_lang_dir, $spip_lang_left;
-	$query3 = "SELECT * FROM spip_rubriques WHERE id_parent='$collection2' ORDER BY 0+titre,titre";
-	$result3 = spip_query($query3);
-
-	if (spip_num_rows($result3) > 0){
-		$retour = debut_block_invisible("enfants$collection2")."\n<ul style='margin: 0px; padding: 0px; padding-top: 3px;'>\n";
-		while($row=spip_fetch_array($result3)){
-			$id_rubrique2=$row['id_rubrique'];
-			$id_parent2=$row['id_parent'];
-			$titre2=$row['titre'];
-			changer_typo($row['lang']);
-
-			$retour.="<div class='arial11' " .
-			  http_style_background('rubrique-12.gif', "left center no-repeat; padding: 2px; padding-$spip_lang_left: 18px; margin-$spip_lang_left: 3px") . "><A HREF='naviguer.php3?id_rubrique=$id_rubrique2'><span dir='$lang_dir'>".typo($titre2)."</span></a></div>\n";
-		}
-		$retour .= "</ul>\n\n".fin_block()."\n\n";
-	}
-	
-	return $retour;
-}
-//// FIN RUBRIQUES
+include_ecrire ("inc_rubriques.php3");
 
 debut_page(_T('titre_page_index'), "asuivre", "asuivre");
 
@@ -519,38 +423,8 @@ if ($flag_ob) {
 
 
 
-///// Afficher les rubriques (copie naviguer.php3)
-enfant(0);
-
-$les_enfants2=substr($les_enfants,round(strlen($les_enfants)/2),strlen($les_enfants));
-if (strpos($les_enfants2,"<div class='enfants'>")){
-	$les_enfants2=substr($les_enfants2,strpos($les_enfants2,"<div class='enfants'>"),strlen($les_enfants2));
-	$les_enfants1=substr($les_enfants,0,strlen($les_enfants)-strlen($les_enfants2));
-}else{
-	$les_enfants1=$les_enfants;
-	$les_enfants2="";
-}
-
-
-// Afficher les sous-rubriques
-echo "<div>&nbsp;</div>";
-echo "<table cellpadding=0 cellspacing=0 border=0 width='100%'>";
-echo "<tr><td valign='top' width=50% rowspan=2>$les_enfants1</td>";
-echo "<td width='20' rowspan='2'>", http_img_pack("rien.gif", ' ', "width='20'") ."</td>\n";
-echo "<td valign='top' width='50%'>$les_enfants2 &nbsp;";
-if (strlen($les_enfants2) > 0) echo "<p>";
-echo "</td></tr>";
-
-echo "<tr><td style='text-align: $spip_lang_right;' valign='bottom'><div align='$spip_lang_right'>";
-if ($flag_editable) {
-	if ($id_rubrique == "0") icone(_T('icone_creer_rubrique'), "rubriques_edit.php3?new=oui&retour=nav", "secteur-24.gif", "creer.gif");
-	else  icone(_T('icone_creer_sous_rubrique'), "rubriques_edit.php3?new=oui&retour=nav&id_parent=$id_rubrique", "rubrique-24.gif", "creer.gif");
-	echo "<p>";
-}
-echo "</div></td></tr>";
-echo "</table><p />";
-//////
-
+///// Afficher les rubriques 
+afficher_enfant_rub(0, false);
 
 if ($options == 'avancees') {
 
diff --git a/ecrire/naviguer.php3 b/ecrire/naviguer.php3
index e36187004e..3faa521a42 100644
--- a/ecrire/naviguer.php3
+++ b/ecrire/naviguer.php3
@@ -12,6 +12,7 @@
 
 
 include ("inc.php3");
+include_ecrire ("inc_rubriques.php3");
 include_ecrire ("inc_logos.php3");
 include_ecrire ("inc_mots.php3");
 include_ecrire ("inc_documents.php3");
@@ -21,100 +22,6 @@ include_ecrire ("inc_abstract_sql.php3");
 $id_rubrique = intval($id_rubrique);
 $flag_mots = lire_meta("articles_mots");
 
-function enfant($collection){
-	global $les_enfants, $couleur_foncee, $lang_dir;
-	global $spip_display, $spip_lang_left, $spip_lang_right;
-	global $connect_id_auteur;
-	
-	$query2 = "SELECT * FROM spip_rubriques WHERE id_parent='$collection' ORDER BY 0+titre,titre";
-	$result2 = spip_query($query2);
-
-
-	if ($spip_display == 4) $les_enfants .= "<ul>";
-	
-	while($row=spip_fetch_array($result2)){
-		$id_rubrique=$row['id_rubrique'];
-		$id_parent=$row['id_parent'];
-		$titre=$row['titre'];
-
-		$bouton_layer = bouton_block_invisible("enfants$id_rubrique");
-		$les_sous_enfants = sous_enfant($id_rubrique);
-
-		changer_typo($row['lang']);
-		$descriptif=propre($row['descriptif']);
-
-		if ($spip_display == 4) $les_enfants .= "<li>";
-		$les_enfants.= "<div class='enfants'>";
-		
-		
-		if ($id_parent == "0") $logo_rub = "secteur-24.gif";
-		else $logo_rub = "rubrique-24.gif";
-		
-		$les_enfants .= debut_cadre_sous_rub($logo_rub, true);
-		
-		if ($spip_display != 1 AND $spip_display!=4 AND lire_meta('image_process') != "non") {
-			include_ecrire("inc_logos.php3");
-			$logo = decrire_logo("rubon$id_rubrique");
-			if ($logo) {
-				$fichier = $logo[0];
-				$taille_x = $logo[3];
-				$taille_y = $logo[4];
-				$taille = image_ratio($taille_x, $taille_y, 48, 36);
-				$w = $taille[0];
-				$h = $taille[1];
-				$fid = $logo[2];
-				$hash = calculer_action_auteur ("reduire $w $h");
-
-				$les_enfants.= "<img src='../spip_image_reduite.php3?img="._DIR_IMG."$fichier&taille_x=$w&taille_y=$h&hash=$hash&hash_id_auteur=$connect_id_auteur' width='$w' height='$h' align='$spip_lang_right' style='margin-$spip_lang_right: -6px; margin-top: -6px;' />";
-			}
-		}
-
-		if (strlen($les_sous_enfants) > 0){
-			$les_enfants .= $bouton_layer;
-		}
-
-		if (acces_restreint_rubrique($id_rubrique))
-		  $les_enfants .= http_img_pack("admin-12.gif", '', "width='12' height='12'", _T('image_administrer_rubrique'));
-
-		$les_enfants.= "<span dir='$lang_dir'><B><A HREF='naviguer.php3?id_rubrique=$id_rubrique'><font color='$couleur_foncee'>".typo($titre)."</font></A></B></span>";
-		if (strlen($descriptif)) {
-			$les_enfants .= "<div class='verdana1'>$descriptif</div>";
-		}
-
-		if ($spip_display != 4) $les_enfants .= $les_sous_enfants;		
-		
-		$les_enfants .= "<div style='clear:both;'></div>";
-
-
-		$les_enfants .= fin_cadre_sous_rub(true);
-		$les_enfants .= "</div>";
-		if ($spip_display == 4) $les_enfants .= "</li>";
-	}
-	if ($spip_display == 4) $les_enfants .= "</ul>";
-	
-}
-
-function sous_enfant($collection2){
-	global $lang_dir, $spip_lang_dir, $spip_lang_left;
-	$query3 = "SELECT * FROM spip_rubriques WHERE id_parent='$collection2' ORDER BY 0+titre,titre";
-	$result3 = spip_query($query3);
-
-	if (spip_num_rows($result3) > 0){
-		$retour = debut_block_invisible("enfants$collection2")."\n<ul style='margin: 0px; padding: 0px; padding-top: 3px;'>\n";
-		while($row=spip_fetch_array($result3)){
-			$id_rubrique2=$row['id_rubrique'];
-			$id_parent2=$row['id_parent'];
-			$titre2=$row['titre'];
-			changer_typo($row['lang']);
-
-			$retour.="<div class='arial11' " .
-			  http_style_background('rubrique-12.gif', "left center no-repeat; padding: 2px; padding-$spip_lang_left: 18px; margin-$spip_lang_left: 3px") . "><A HREF='naviguer.php3?id_rubrique=$id_rubrique2'><span dir='$lang_dir'>".typo($titre2)."</span></a></div>\n";
-		}
-		$retour .= "</ul>\n\n".fin_block()."\n\n";
-	}
-	
-	return $retour;
-}
 
 
 function my_sel($num,$tex,$comp){
@@ -450,36 +357,9 @@ if ($id_rubrique>0 AND lire_meta('multi_rubriques') == 'oui' AND (lire_meta('mul
 fin_cadre_relief();
 
 
-//echo "<div align='$spip_lang_left'>";
-enfant($id_rubrique);
-
-
-$les_enfants2=substr($les_enfants,round(strlen($les_enfants)/2),strlen($les_enfants));
-if (strpos($les_enfants2,"<div class='enfants'>")){
-	$les_enfants2=substr($les_enfants2,strpos($les_enfants2,"<div class='enfants'>"),strlen($les_enfants2));
-	$les_enfants1=substr($les_enfants,0,strlen($les_enfants)-strlen($les_enfants2));
-}else{
-	$les_enfants1=$les_enfants;
-	$les_enfants2="";
-}
-
+///// Afficher les rubriques 
+afficher_enfant_rub($id_rubrique, $flag_editable);
 
-// Afficher les sous-rubriques
-echo "<table cellpadding=0 cellspacing=0 border=0 width='100%'>";
-echo "<tr><td valign='top' width=50% rowspan=2>$les_enfants1</td>";
-echo "<td width='20' rowspan='2'>", http_img_pack("rien.gif", ' ', "width='20'") ."</td>\n";
-echo "<td valign='top' width='50%'>$les_enfants2 &nbsp;";
-if (strlen($les_enfants2) > 0) echo "<p>";
-echo "</td></tr>";
-
-echo "<tr><td style='text-align: $spip_lang_right;' valign='bottom'><div align='$spip_lang_right'>";
-if ($flag_editable) {
-	if ($id_rubrique == "0") icone(_T('icone_creer_rubrique'), "rubriques_edit.php3?new=oui&retour=nav", "secteur-24.gif", "creer.gif");
-	else  icone(_T('icone_creer_sous_rubrique'), "rubriques_edit.php3?new=oui&retour=nav&id_parent=$id_rubrique", "rubrique-24.gif", "creer.gif");
-	echo "<p>";
-}
-echo "</div></td></tr>";
-echo "</table><p />";
 
 
 //echo "<div align='$spip_lang_left'>";
-- 
GitLab