[grisbi-cvs] grisbi-web .htaccess,1.32,1.33 xml.php,1.6,1.7

NIEL Gérald gegeweb at users.sourceforge.net
Sun May 30 18:51:29 CEST 2010


Update of /cvsroot/grisbi/grisbi-web
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv13858

Modified Files:
	.htaccess xml.php 
Log Message:

new xml.php file


Index: .htaccess
===================================================================
RCS file: /cvsroot/grisbi/grisbi-web/.htaccess,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- .htaccess	26 May 2010 22:40:42 -0000	1.32
+++ .htaccess	30 May 2010 16:51:27 -0000	1.33
@@ -12,6 +12,8 @@
 ErrorDocument 403 /403.shtml
 ErrorDocument 406 /index.en.shtml
 
+RewriteRule rss.(.*).xml xml.php?xml=news&xsl=rss&lang=$1
+
 RewriteRule manuel.html manuel.shtml
 RewriteRule download.html download.shtml
 RewriteRule forums/index.(.*).html newsportal/index.php?lang=$1

Index: xml.php
===================================================================
RCS file: /cvsroot/grisbi/grisbi-web/xml.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- xml.php	3 Jan 2004 21:04:38 -0000	1.6
+++ xml.php	30 May 2010 16:51:27 -0000	1.7
@@ -1,22 +1,51 @@
-<?php
+<?
 
 if (isset($_GET["lang"])) $lang=$_GET["lang"];
 else $lang="en";
-if (isset($_GET["file"])) $file=$_GET["file"];
+if (isset($_GET["xml"])) $xml_file=$_GET["xml"];
 else {
-	echo "<p>ERREUR: paramètre fichier XML absent.</p>";
+	trigger_error('XML file parameter missing.', E_USER_ERROR);
 	exit();
 }
+if (isset($_GET["xsl"])) $xsl_file=$_GET["xsl"];
+else $xsl_file=$xml_file;
 
-require 'class_xslt.php';
-$Xparams = array('param.1' => $lang);
+$path=$xml_file;
+$xml_file="$path/$xml_file.xml";
+$xsl_file="$path/$xsl_file.xsl";
 
-$XS = new xslt("$file/$file.xml","$file/$file.xsl",true,'xsltproc');
-$XS->setParams($Xparams);
-$XS->transform();
-/*$result=ereg_replace('<br>','<br />',$XS->output());*/
-$result=str_replace("<ul />","",$XS->output());
-$result=str_replace("<php>","<?php",$result);
-$result=str_replace("</php>","?>",$result);
-$result=eval("?".chr(62).$result.chr(60)."?");
-?>
+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();
+}
+
+$xp = new XsltProcessor();
+
+// create a DOM document and load the XSL stylesheet
+$xsl = new DomDocument;
+$xsl->load("$xsl_file");
+  
+// import the XSL styelsheet into the XSLT process
+$xp->importStylesheet($xsl);
+
+// create a DOM document and load the XML datat
+$xml_doc = new DomDocument;
+$xml_doc->load("$xml_file");
+
+$params['param.1'] = $lang;
+$xp->setParameter($namespace, $params);
+
+// transform the XML into HTML using the XSL file
+if ($result = $xp->transformToXML($xml_doc)) {
+	$result=str_replace("<php>","<?php",$result);
+	$result=str_replace("</php>","?>",$result);
+    echo $result;
+} else {
+    trigger_error('XSL transformation failed.', E_USER_ERROR);
+} // if 
+
+?>
\ No newline at end of file



More information about the cvs mailing list