From c7fd6414725f56d99b9cd6379e7e748522e0c318 Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Wed, 31 Jan 2007 16:41:17 +0000
Subject: [PATCH] faire marcher la colonne documents dans les squelettes

---
 ecrire/action/joindre.php       |  2 +-
 ecrire/inc/dater.php            |  1 +
 ecrire/inc/documents.php        |  8 +++++---
 ecrire/inc/instituer_auteur.php |  2 +-
 ecrire/inc/legender.php         | 29 ++++++++++++++++++++++++++---
 ecrire/inc/virtualiser.php      |  3 ++-
 6 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/ecrire/action/joindre.php b/ecrire/action/joindre.php
index e187efc936..4ea227d27e 100644
--- a/ecrire/action/joindre.php
+++ b/ecrire/action/joindre.php
@@ -60,7 +60,7 @@ function action_joindre_dist()
 
      $redirect = urldecode($redirect);
      if ($documents_actifs) {
-	$redirect = parametre_url($redirect,'show_docs',join(',',$documents_actifs));
+	$redirect = parametre_url($redirect,'show_docs',join(',',$documents_actifs),'&');
      }
      
     if (!$ancre) {
diff --git a/ecrire/inc/dater.php b/ecrire/inc/dater.php
index 1afeef63da..cc94e1ab2f 100644
--- a/ecrire/inc/dater.php
+++ b/ecrire/inc/dater.php
@@ -138,6 +138,7 @@ onchange=\"findObj_forcer('valider_date').style.visibility='visible';\"";
 				   _T('bouton_changer'),
 				   " style='float: $spip_lang_right; margin-top: 20px;' class='fondo visible_au_chargement' id='valider_date_redac'",
 				   "&id=$id&type=$type")
+				   ."<br class='nettoyeur' />"
 		. '</div>';
 
 		$res .= block_parfois_visible('dateredac', $invite, $masque, 'text-align: left');
diff --git a/ecrire/inc/documents.php b/ecrire/inc/documents.php
index f88aaea9d8..f70448f33f 100644
--- a/ecrire/inc/documents.php
+++ b/ecrire/inc/documents.php
@@ -130,7 +130,7 @@ function afficher_documents_colonne($id, $type="article",$script=NULL) {
 		if (_DIR_RESTREINT)
 			$script = parametre_url(self(),"show_docs",'');
 	}
-	
+	$id_document_actif = _request('show_docs');
 
 	/// Ajouter nouvelle image
 	$ret .= "<a name='images'></a>\n";
@@ -182,7 +182,9 @@ function afficher_documents_colonne($id, $type="article",$script=NULL) {
 	$ret .= "<p></p><div id='liste_documents'>\n";
 
 	foreach($documents_lies as $doc) {
-		$ret .= afficher_case_document($doc, $id, $script, $type, false);
+		$id_document = $doc['id_document'];
+		$deplier = $id_document_actif==$id_document;
+		$ret .= afficher_case_document($doc, $id, $script, $type, $deplier);
 	}
 	$ret .= "</div>";
   if (!_DIR_RESTREINT){
@@ -365,7 +367,7 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier=fals
 			$ret .= $raccourci_doc;
 
 		$legender = charger_fonction('legender', 'inc');
-		$ret .= $legender($id_document, $document, $script, $type, $id, "document$id_document");
+		$ret .= $legender($id_document, $document, $script, $type, $id, "document$id_document", $deplier);
 		
 		$ret .= fin_cadre_relief(true);
 	}
diff --git a/ecrire/inc/instituer_auteur.php b/ecrire/inc/instituer_auteur.php
index 83cbd7ee45..e522a52b6c 100644
--- a/ecrire/inc/instituer_auteur.php
+++ b/ecrire/inc/instituer_auteur.php
@@ -103,7 +103,7 @@ function inc_instituer_auteur_dist($id_auteur, $statut, $url_self)
 		. $res		  
 		. "</div>";
 
-		$res = ajax_action_post('instituer_auteur', $id_auteur, $url_self, (!$id_auteur ? "" : "id_auteur=$id_auteur"), $res, _T('bouton_valider'), " style='float: $spip_lang_right' class='fondo'");
+		$res = ajax_action_post('instituer_auteur', $id_auteur, $url_self, (!$id_auteur ? "" : "id_auteur=$id_auteur"), $res, _T('bouton_valider'), " style='float: $spip_lang_right' class='fondo'")."<br class='nettoyeur' />";
 	}
 
 	return (_request('var_ajaxcharset'))
diff --git a/ecrire/inc/legender.php b/ecrire/inc/legender.php
index 22e1b2c923..d3402ebda7 100644
--- a/ecrire/inc/legender.php
+++ b/ecrire/inc/legender.php
@@ -97,15 +97,38 @@ function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre,
 	.  $GLOBALS['spip_lang_right']
 	. "'";
 
-	$corps = ajax_action_post("legender", $id_document, $script, "show_docs=$id_document&id_$type=$id#legender-$id_document", $corps, _T('bouton_enregistrer'), $att, "&id_document=$id_document&id=$id&type=$type&ancre=$ancre")
-	.  $vignette . "\n\n";
+	if (!_DIR_RESTREINT)
+		$corps = ajax_action_post("legender", $id_document, $script, "show_docs=$id_document&id_$type=$id#legender-$id_document", $corps, _T('bouton_enregistrer'), $att, "&id_document=$id_document&id=$id&type=$type&ancre=$ancre")
+		  . "<br class='nettoyeur' />";
+	else {
+		$corps = "<div>"
+		       . $corps 
+		       . "<span"
+		       . $att
+		       . "><input type='submit' class='fondo' value='"
+		       . _T('bouton_enregistrer')
+		       ."' /></span><br class='nettoyeur' /></div>";
+		$redirect = parametre_url($script,'show_docs',$id_document,'&');
+		$redirect = parametre_url($redirect,"id_$type",$id,'&');
+		$redirect = parametre_url($redirect,"id_$type",$id,'&');
+		$redirect = ancre_url($redirect,"legender-$id_document");
+		$corps = generer_action_auteur("legender", $id_document, $redirect, $corps, "\nmethod='post'");
+	}
+	
+	$corps .=  $vignette . "\n\n";
 
 	$texte = _T('icone_supprimer_document');
 	if (preg_match('/_edit$/', $script))
 		$action = redirige_action_auteur('supprimer', "document-$id_document", $script, "id_$type=$id#$ancre");
 	else {
 		$s = ($ancre =='documents' ? '': '-');
-		$action = ajax_action_auteur('documenter', "$s$id/$type/$id_document", $script, "id_$type=$id&type=$type&s=$s#$ancre", array($texte));
+		if (!_DIR_RESTREINT)
+			$action = ajax_action_auteur('documenter', "$s$id/$type/$id_document", $script, "id_$type=$id&type=$type&s=$s#$ancre", array($texte));
+		else{
+			$redirect = str_replace('&amp;','&',$script);
+			$action = generer_action_auteur('documenter', "$s$id/$type/$id_document", $redirect);
+			$action = "<a href='$action'>$texte</a>";
+		}
 	}
 
 	// le cas $id<0 correspond a un doc charge dans un article pas encore cree,
diff --git a/ecrire/inc/virtualiser.php b/ecrire/inc/virtualiser.php
index ed60828c50..53db528eeb 100644
--- a/ecrire/inc/virtualiser.php
+++ b/ecrire/inc/virtualiser.php
@@ -31,7 +31,8 @@ function inc_virtualiser_dist($id_article, $flag, $virtuel, $script, $args)
 	.  _T('texte_reference_mais_redirige')
 	. ")</span><br />";
 
-	$res = ajax_action_post('virtualiser', $id_article, $script, $args, $res, _T('bouton_changer'), " class='fondo spip_xx-small' style='float: $spip_lang_right'");
+	$res = ajax_action_post('virtualiser', $id_article, $script, $args, $res, _T('bouton_changer'), " class='fondo spip_xx-small' style='float: $spip_lang_right'")
+	  . "<br class='nettoyeur' />";
 	return ajax_action_greffe("virtualiser-$id_article", $res);
 }
 ?>
-- 
GitLab