From 388f4c393b7e12442ee0c81340ba2bd0bd4a3b9e Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Mon, 15 Jan 2007 09:47:52 +0000
Subject: [PATCH] =?UTF-8?q?Forcer=20la=20mise=20en=20cache=20des=20DTD=20p?=
 =?UTF-8?q?ubliques=20meme=20si=20elle=20est=20command=C3=A9e=20par=20le?=
 =?UTF-8?q?=20d=C3=A9busqueur,=20c'est=20pas=20elles=20qui=20sont=20en=20c?=
 =?UTF-8?q?ause.=20Et=20renommage=20du=20sous-r=C3=A9pertoire=20contenant?=
 =?UTF-8?q?=20ces=20caches:=20=C3=A7a=20ne=20contient=20pas=20que=20des=20?=
 =?UTF-8?q?DTD=20d=C3=A8s=20=C3=A0=20pr=C3=A9sent.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/sax.php          | 5 +++--
 ecrire/inc/utils.php        | 4 ++--
 ecrire/xml/analyser_dtd.php | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/ecrire/inc/sax.php b/ecrire/inc/sax.php
index 1347df827e..dbc38ea0e1 100644
--- a/ecrire/inc/sax.php
+++ b/ecrire/inc/sax.php
@@ -220,13 +220,14 @@ function sax_bug($data)
 		$data = html2unicode($data, true);
 	else  {
 		list ($topelement, $avail, $grammaire, $rotlvl) = $r;
-		$file = _DIR_DTD . preg_replace('/[^\w.]/','_', $rotlvl) . '.gz';
+		$file = _DIR_CACHE_XML . preg_replace('/[^\w.]/','_', $rotlvl) . '.gz';
 		if (lire_fichier($file, $r))
 			$phraseur_xml->dtc = unserialize($r);
 		else {
 			include_spip('xml/analyser_dtd');
 		    	$phraseur_xml->dtc = charger_dtd($grammaire, $avail);
-			ecrire_fichier($file, serialize($phraseur_xml->dtc));
+			if ($avail == 'PUBLIC')
+				ecrire_fichier($file, serialize($phraseur_xml->dtc), true);
 		}
 		$trans = array();
 		
diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php
index 307a7cf70c..10995f9f79 100644
--- a/ecrire/inc/utils.php
+++ b/ecrire/inc/utils.php
@@ -937,7 +937,7 @@ function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) {
 	define('_DIR_SESSIONS', $ti . "sessions/");
 	define('_DIR_TRANSFERT', $ti . "upload/");
 	define('_DIR_CACHE', $ti . "cache/");
-	define('_DIR_DTD', $ti . "cache/dtd/");
+	define('_DIR_CACHE_XML', $ti . "cache/xml/");
 	define('_DIR_SKELS', $ti . "cache/skel/");
 	define('_DIR_TMP', $ti);
 
@@ -994,7 +994,7 @@ function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) {
 	define('_DOCTYPE_ECRIRE', 
 		// "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n");
 		"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
-	       // "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n");
+		// "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n");
 	       // "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 //EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n");
 	define('_DOCTYPE_AIDE', 
 	       "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
diff --git a/ecrire/xml/analyser_dtd.php b/ecrire/xml/analyser_dtd.php
index 09b3f343bf..7e24c15cd8 100644
--- a/ecrire/xml/analyser_dtd.php
+++ b/ecrire/xml/analyser_dtd.php
@@ -57,7 +57,7 @@ function analyser_dtd($loc, $avail, &$dtc)
 	if ($avail == 'SYSTEM')
 	  $file = $loc;
 	else {
-	  $file = sous_repertoire(_DIR_DTD);
+	  $file = sous_repertoire(_DIR_CACHE_XML);
 	  $file .= preg_replace('/[^\w.]/','_', $loc);
 	}
 
@@ -68,7 +68,7 @@ function analyser_dtd($loc, $avail, &$dtc)
 		if ($avail == 'PUBLIC') {
 			include_spip('inc/distant');
 			if ($dtd = recuperer_page($loc))
-				ecrire_fichier($file, $dtd); 
+				ecrire_fichier($file, $dtd, true); 
 		}
 	}
 
-- 
GitLab