[grisbi-cvs] grisbi-web xml.php,1.8,1.9
NIEL Gérald
gegeweb at users.sourceforge.net
Mon May 31 07:40:58 CEST 2010
- Previous message: [grisbi-cvs] grisbi-web/images startcom.png,NONE,1.1
- Next message: [grisbi-cvs] grisbi-web download.shtml.de, 1.2, 1.3 download.shtml.en, 1.2, 1.3 download.shtml.es, 1.1, 1.2 download.shtml.fr, 1.3, 1.4 download.shtml.it, 1.2, 1.3 download.shtml.nl, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/grisbi/grisbi-web
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv17667
Modified Files:
xml.php
Log Message:
make xml transformation only if XML is newer than the cache.
Index: xml.php
===================================================================
RCS file: /cvsroot/grisbi/grisbi-web/xml.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- xml.php 30 May 2010 18:18:30 -0000 1.8
+++ xml.php 31 May 2010 05:40:51 -0000 1.9
@@ -1,5 +1,5 @@
<?
-
+// on récupère les variables
if (isset($_GET["lang"])) $lang=$_GET["lang"];
else $lang="en";
if (isset($_GET["xml"])) $xml_file=$_GET["xml"];
@@ -10,29 +10,30 @@
if (isset($_GET["xsl"])) $xsl_file=$_GET["xsl"];
else $xsl_file=$xml_file;
+// on construit les variables fichiers
$path=$xml_file;
$cache="$path/$xsl_file.$lang.html";
$xml_file="$path/$xml_file.xml";
$xsl_file="$path/$xsl_file.xsl";
-$expire = time() -3600 ; // valable une heure
-
-if(file_exists($cache) && filemtime($cache) > $expire)
+// on teste l'existance des fichiers xml/xsl
+if (!file_exists($xml_file)) {
+ trigger_error("file $xml_file do not exist", E_USER_ERROR);
+ exit();
+}
+if (!file_exists($xsl_file)) {
+ trigger_error("file $xsl_file do not exist", E_USER_ERROR);
+ exit();
+}
+
+// si le cache est plus récent que le fichier XML, on affiche le cache
+if(file_exists($cache) && filemtime($cache) > filemtime($xml_file))
{
readfile($cache);
}
-else {
- ob_start(); // ouverture du tampon
-
- if (!file_exists($xml_file)) {
- trigger_error("file $xml_file do not exist", E_USER_ERROR);
- exit();
- }
- if (!file_exists($xsl_file)) {
- trigger_error("file $xsl_file do not exist", E_USER_ERROR);
- exit();
- }
+else { // sinon on construit la sortie HTML, on met en cache et on l'affiche.
+ ob_start(); // ouverture du tampon
$xp = new XsltProcessor();
// create a DOM document and load the XSL stylesheet
@@ -51,17 +52,16 @@
// transform the XML into HTML using the XSL file
if ($result = $xp->transformToXML($xml_doc)) {
+ $result=str_replace("<ul/>","",$result);
$result=str_replace("<php>","<?php",$result);
$result=str_replace("</php>","?>",$result);
echo $result;
- } else {
+ } else { // si erreur transformation XML
trigger_error('XSL transformation failed.', E_USER_ERROR);
- } // if
-
+ }
$page = ob_get_contents(); // copie du contenu du tampon dans une chaîne
ob_end_clean(); // effacement du contenu du tampon et arrêt de son fonctionnement
- file_put_contents($cache, $page);
-
- echo $page;
+ file_put_contents($cache, $page); // ecriture du fichier cache
+ echo $page; // affichage de la page
}
?>
\ No newline at end of file
- Previous message: [grisbi-cvs] grisbi-web/images startcom.png,NONE,1.1
- Next message: [grisbi-cvs] grisbi-web download.shtml.de, 1.2, 1.3 download.shtml.en, 1.2, 1.3 download.shtml.es, 1.1, 1.2 download.shtml.fr, 1.3, 1.4 download.shtml.it, 1.2, 1.3 download.shtml.nl, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cvs
mailing list