From 946f865c2c74340721b00ffeaf986336d45ca296 Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Sat, 4 Nov 2006 13:22:31 +0000
Subject: [PATCH] =?UTF-8?q?[7782]=C2=A0en=20un=20peu=20plus=20rationnel.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/action/joindre.php        |  13 ++-
 ecrire/inc/ajouter_documents.php | 170 +++++++++++++++++++++++++++++++
 ecrire/inc/getdocument.php       | 169 ------------------------------
 3 files changed, 180 insertions(+), 172 deletions(-)

diff --git a/ecrire/action/joindre.php b/ecrire/action/joindre.php
index 3966c4ca3c..e824dc5a8a 100644
--- a/ecrire/action/joindre.php
+++ b/ecrire/action/joindre.php
@@ -148,6 +148,14 @@ function spip_action_joindre3($path, $mode, $type, $id, $id_document,$hash, $red
 	return $ajouter_documents($files, $mode, $type, $id, $id_document, $hash, $redirect, $actifs, $iframe_redirect);
 }
 
+#-----------------------------------------------------------------------
+
+// sous-actions suite a l'envoi d'un Zip:
+// la fonction ajouter_documents standard a construit un formulaire 
+// qui renvoie sur une des 3 sous-actions qui suivent. 
+// On recharge ajouter_document sans l'appeler, car son fichier doit
+// contenir les acolytes qui nous interessent (pas bien beau)
+
 //  Zip avec confirmation "tel quel"
 
 // http://doc.spip.org/@spip_action_joindre5
@@ -158,12 +166,10 @@ function spip_action_joindre5($path, $mode, $type, $id, $id_document,$hash, $red
 	if (!$pos) {
 		$pos = strpos($path, '/zip_');
 	}
-	return $ajouter_documents($path, substr($path, $pos+5), $type, $id, $mode, $id_document, $actifs);
+	return ajouter_un_document($path, substr($path, $pos+5), $type, $id, $mode, $id_document, $actifs);
 }
 
 // Zip a deballer. 
-// Pas tres beau: on charge une fonction pas appelee mais dont le fichier
-// contient les acolytes qui nous interessent.
 
 // http://doc.spip.org/@spip_action_joindre6
 function spip_action_joindre6($path, $mode, $type, $id, $id_document,$hash, $redirect, &$actifs, $iframe_redirect)
@@ -185,4 +191,5 @@ function spip_action_joindre4($path, $mode, $type, $id, $id_document,$hash, $red
 	return spip_action_joindre5($path, $mode, $type, $id, $id_document,$hash, $redirect, $actifs);
 }
 
+
 ?>
diff --git a/ecrire/inc/ajouter_documents.php b/ecrire/inc/ajouter_documents.php
index 08b7590d8e..fe2bad7e26 100644
--- a/ecrire/inc/ajouter_documents.php
+++ b/ecrire/inc/ajouter_documents.php
@@ -330,4 +330,174 @@ function joindre_deballes($path, $mode, $type, $id, $id_document,$hash, $redirec
 	    effacer_repertoire_temporaire(_tmp_dir);
 	    return $x;
 }
+
+
+//
+// Convertit le type numerique retourne par getimagesize() en extension fichier
+//
+
+// http://doc.spip.org/@decoder_type_image
+function decoder_type_image($type, $strict = false) {
+	switch ($type) {
+	case 1:
+		return "gif";
+	case 2:
+		return "jpg";
+	case 3:
+		return "png";
+	case 4:
+		return $strict ? "" : "swf";
+	case 5:
+		return "psd";
+	case 6:
+		return "bmp";
+	case 7:
+	case 8:
+		return "tif";
+	default:
+		return "";
+	}
+}
+
+
+// http://doc.spip.org/@traite_svg
+function traite_svg($file)
+{
+	global $connect_statut;
+	$texte = spip_file_get_contents($file);
+
+	// Securite si pas guru: virer les scripts et les references externes
+	// Trop expeditif, a ameliorer
+
+        $var_auth = charger_fonction('auth', 'inc');
+	$var_auth();
+
+	if ($connect_statut != '0minirezo') {
+		include_spip('inc/texte');
+		$new = trim(safehtml($texte));
+		// petit bug safehtml
+		if (substr($new,0,2) == ']>') $new = ltrim(substr($new,2));
+		if ($new != $texte) ecrire_fichier($file, $texte = $new);
+		
+	}
+
+	$width = $height = 150;
+	if (preg_match(',<svg[^>]+>,', $texte, $s)) {
+		$s = $s[0];
+		if (preg_match(',\WviewBox\s*=\s*.\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+),i', $s, $r)){
+			$width = $r[3];
+                	$height = $r[4];
+		} else {
+	// si la taille est en centimetre, estimer le pixel a 1/64 de cm
+		if (preg_match(',\Wwidth\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
+			if ($r[2] != '%') {
+				$width = $r[1];
+				if ($r[2] == 'cm') $width <<=6;
+			}	
+		}
+		if (preg_match(',\Wheight\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
+			if ($r[2] != '%') {
+	                	$height = $r[1];
+				if ($r[2] == 'cm') $height <<=6;
+			}
+		}
+	   }
+	}
+	return array($width, $height);
+}
+
+//
+// Corrige l'extension du fichier dans quelques cas particuliers
+// (a passer dans ecrire/base/typedoc)
+//
+
+// http://doc.spip.org/@corriger_extension
+function corriger_extension($ext) {
+	switch ($ext) {
+	case 'htm':
+		return 'html';
+	case 'jpeg':
+		return 'jpg';
+	case 'tiff':
+		return 'tif';
+	default:
+		return $ext;
+	}
+}
+
+// Afficher un formulaire de choix: decompacter et/ou garder tel quel.
+// Passer ca en squelette un de ces jours.
+
+// http://doc.spip.org/@liste_archive_jointe
+function liste_archive_jointe($valables, $mode, $type, $id, $id_document, $hash, $redirect, $zip, $iframe_redirect)
+{
+	$arg = (intval($id) .'/' .intval($id_document) . "/$mode/$type");
+	$texte =
+		"<div><input type='radio' checked='checked' name='sousaction5' value='5'>" .
+	  	_T('upload_zip_telquel').
+		"</div>".
+		"<div><input type='radio' name='sousaction5' value='6'>".
+		_T('upload_zip_decompacter').
+		"</div>".
+		"<ol><li><tt>" .
+		join("</tt></li>\n<li><tt>", $valables) .
+		"</tt></li></ol>".
+		"<div>&nbsp;</div>" .
+		"<div><input type='checkbox' name='sousaction4' value='4'>".
+		_T('les_deux').
+		"</div>".
+		"<div style='text-align: right;'><input class='fondo' style='font-size: 9px;' type='submit' value='".
+		_T('bouton_valider').
+		  "'></div>";
+	echo "<p>build form $iframe_redirect</p>";
+  $action = construire_upload($texte, array(
+					 'redirect' => $redirect,
+					 'iframe_redirect' => $iframe_redirect,
+					 'hash' => $hash,
+					 'chemin' => $zip,
+					 'arg' => $arg));
+	
+	if(_request("iframe")=="iframe") {
+    echo "<div class='upload_answer upload_zip_list'><p>" .
+		_T('upload_fichier_zip_texte') .
+	  "</p><p>" .
+		_T('upload_fichier_zip_texte2') .
+	  "</p>" .
+	  $action.
+	  "</div>";
+    exit;
+  }
+  				 
+	minipres(_T('upload_fichier_zip'),
+	  "<p>" .
+		_T('upload_fichier_zip_texte') .
+	  "</p><p>" .
+		_T('upload_fichier_zip_texte2') .
+	  "</p>" .
+	  $action);
+	// a tout de suite en joindre4, joindre5, ou joindre6
+}
+
+
+// Reconstruit un generer_action_auteur 
+
+// http://doc.spip.org/@construire_upload
+function construire_upload($corps, $args, $enctype='')
+{
+	$res = "";
+	foreach($args as $k => $v)
+	  if ($v)
+	    $res .= "\n<input type='hidden' name='$k' value='$v' />";
+
+# ici enlever $action pour uploader directemet dans l'espace prive (UPLOAD_DIRECT)
+	return "\n<form method='post' action='" . generer_url_action('joindre') .
+	  "'" .
+	  (!$enctype ? '' : " enctype='$enctype'") .
+	  " 
+	  >\n" .
+	  "<div>" .
+  	  "\n<input type='hidden' name='action' value='joindre' />" .
+	  $res . $corps . "</div></form>";
+}
+
 ?>
diff --git a/ecrire/inc/getdocument.php b/ecrire/inc/getdocument.php
index 19297fe91a..12689af255 100644
--- a/ecrire/inc/getdocument.php
+++ b/ecrire/inc/getdocument.php
@@ -186,173 +186,4 @@ function callback_deballe_fichier($p_event, &$p_header) {
 	}
 }
 
-// http://doc.spip.org/@traite_svg
-function traite_svg($file)
-{
-	global $connect_statut;
-	$texte = spip_file_get_contents($file);
-
-	// Securite si pas guru: virer les scripts et les references externes
-	// Trop expeditif, a ameliorer
-
-        $var_auth = charger_fonction('auth', 'inc');
-	$var_auth();
-
-	if ($connect_statut != '0minirezo') {
-		include_spip('inc/texte');
-		$new = trim(safehtml($texte));
-		// petit bug safehtml
-		if (substr($new,0,2) == ']>') $new = ltrim(substr($new,2));
-		if ($new != $texte) ecrire_fichier($file, $texte = $new);
-		
-	}
-
-	$width = $height = 150;
-	if (preg_match(',<svg[^>]+>,', $texte, $s)) {
-		$s = $s[0];
-		if (preg_match(',\WviewBox\s*=\s*.\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+),i', $s, $r)){
-			$width = $r[3];
-                	$height = $r[4];
-		} else {
-	// si la taille est en centimetre, estimer le pixel a 1/64 de cm
-		if (preg_match(',\Wwidth\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
-			if ($r[2] != '%') {
-				$width = $r[1];
-				if ($r[2] == 'cm') $width <<=6;
-			}	
-		}
-		if (preg_match(',\Wheight\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
-			if ($r[2] != '%') {
-	                	$height = $r[1];
-				if ($r[2] == 'cm') $height <<=6;
-			}
-		}
-	   }
-	}
-	return array($width, $height);
-}
-
-
-
-// Afficher un formulaire de choix: decompacter et/ou garder tel quel.
-// Passer ca en squelette un de ces jours.
-
-// http://doc.spip.org/@liste_archive_jointe
-function liste_archive_jointe($valables, $mode, $type, $id, $id_document, $hash, $redirect, $zip, $iframe_redirect)
-{
-	$arg = (intval($id) .'/' .intval($id_document) . "/$mode/$type");
-	$texte =
-		"<div><input type='radio' checked='checked' name='sousaction5' value='5'>" .
-	  	_T('upload_zip_telquel').
-		"</div>".
-		"<div><input type='radio' name='sousaction5' value='6'>".
-		_T('upload_zip_decompacter').
-		"</div>".
-		"<ol><li><tt>" .
-		join("</tt></li>\n<li><tt>", $valables) .
-		"</tt></li></ol>".
-		"<div>&nbsp;</div>" .
-		"<div><input type='checkbox' name='sousaction4' value='4'>".
-		_T('les_deux').
-		"</div>".
-		"<div style='text-align: right;'><input class='fondo' style='font-size: 9px;' type='submit' value='".
-		_T('bouton_valider').
-		  "'></div>";
-	echo "<p>build form $iframe_redirect</p>";
-  $action = construire_upload($texte, array(
-					 'redirect' => $redirect,
-					 'iframe_redirect' => $iframe_redirect,
-					 'hash' => $hash,
-					 'chemin' => $zip,
-					 'arg' => $arg));
-	
-	if(_request("iframe")=="iframe") {
-    echo "<div class='upload_answer upload_zip_list'><p>" .
-		_T('upload_fichier_zip_texte') .
-	  "</p><p>" .
-		_T('upload_fichier_zip_texte2') .
-	  "</p>" .
-	  $action.
-	  "</div>";
-    exit;
-  }
-  				 
-	minipres(_T('upload_fichier_zip'),
-	  "<p>" .
-		_T('upload_fichier_zip_texte') .
-	  "</p><p>" .
-		_T('upload_fichier_zip_texte2') .
-	  "</p>" .
-	  $action);
-	// a tout de suite en joindre4, joindre5, ou joindre6
-}
-
-
-// Reconstruit un generer_action_auteur 
-
-// http://doc.spip.org/@construire_upload
-function construire_upload($corps, $args, $enctype='')
-{
-	$res = "";
-	foreach($args as $k => $v)
-	  if ($v)
-	    $res .= "\n<input type='hidden' name='$k' value='$v' />";
-
-# ici enlever $action pour uploader directemet dans l'espace prive (UPLOAD_DIRECT)
-	return "\n<form method='post' action='" . generer_url_action('joindre') .
-	  "'" .
-	  (!$enctype ? '' : " enctype='$enctype'") .
-	  " 
-	  >\n" .
-	  "<div>" .
-  	  "\n<input type='hidden' name='action' value='joindre' />" .
-	  $res . $corps . "</div></form>";
-}
-
-//
-// Convertit le type numerique retourne par getimagesize() en extension fichier
-//
-
-// http://doc.spip.org/@decoder_type_image
-function decoder_type_image($type, $strict = false) {
-	switch ($type) {
-	case 1:
-		return "gif";
-	case 2:
-		return "jpg";
-	case 3:
-		return "png";
-	case 4:
-		return $strict ? "" : "swf";
-	case 5:
-		return "psd";
-	case 6:
-		return "bmp";
-	case 7:
-	case 8:
-		return "tif";
-	default:
-		return "";
-	}
-}
-
-
-//
-// Corrige l'extension du fichier dans quelques cas particuliers
-// (a passer dans ecrire/base/typedoc)
-//
-
-// http://doc.spip.org/@corriger_extension
-function corriger_extension($ext) {
-	switch ($ext) {
-	case 'htm':
-		return 'html';
-	case 'jpeg':
-		return 'jpg';
-	case 'tiff':
-		return 'tif';
-	default:
-		return $ext;
-	}
-}
 ?>
-- 
GitLab