/** Do the XSLT translation and look in the local directory if the file * doesn't exist */ function generate_XSLT($xml, $pageName, $only_in_local = false) { // For common xsl pages not referenced directly // i.e. header, headerback, etc... // look if they are in the local directory, and set // an XML value accordingly include 'config/config.php'; if ($CDASH_USE_LOCAL_DIRECTORY && !$only_in_local) { $pos = strpos($xml, '</cdash>'); // this should be the last if ($pos !== false) { $xml = substr($xml, 0, $pos); $xml .= '<uselocaldirectory>1</uselocaldirectory>'; // look at the local directory if we have the same php file // and add the xml if needed $localphpfile = 'local/' . $pageName . '.php'; if (file_exists($localphpfile)) { include_once $localphpfile; $xml .= getLocalXML(); } $xml .= '</cdash>'; // finish the xml } } $xh = xslt_create(); $arguments = array('/_xml' => $xml); if (!empty($CDASH_DEBUG_XML)) { $tmp = preg_replace("#<[A-Za-z0-9\\-_.]{1,250}>#", "\\0\n", $xml); $tmp = preg_replace("#</[A-Za-z0-9\\-_.]{1,250}>#", "\n\\0\n", $tmp); $inF = fopen($CDASH_DEBUG_XML, 'w'); fwrite($inF, $tmp); fclose($inF); unset($inF); } $xslpage = $pageName . '.xsl'; // Check if the page exists in the local directory if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/' . $xslpage)) { $xslpage = 'local/' . $xslpage; } $html = xslt_process($xh, 'arg:/_xml', $xslpage, null, $arguments); // Enfore the charset to be UTF-8 header('Content-type: text/html; charset=utf-8'); echo $html; xslt_free($xh); }
/** Do the XSLT translation and look in the local directory if the file * doesn't exist */ function generate_XSLT($xml, $pageName, $only_in_local = false) { // For common xsl pages not referenced directly // i.e. header, headerback, etc... // look if they are in the local directory, and set // an XML value accordingly include "cdash/config.php"; if ($CDASH_USE_LOCAL_DIRECTORY && !$only_in_local) { $pos = strpos($xml, "</cdash>"); // this should be the last if ($pos !== FALSE) { $xml = substr($xml, 0, $pos); $xml .= "<uselocaldirectory>1</uselocaldirectory>"; // look at the local directory if we have the same php file // and add the xml if needed $localphpfile = "local/" . $pageName . ".php"; if (file_exists($localphpfile)) { include_once $localphpfile; $xml .= getLocalXML(); } $xml .= "</cdash>"; // finish the xml } } $xh = xslt_create(); if (PHP_VERSION < 5) { $filebase = 'file://' . getcwd() . '/'; xslt_set_base($xh, $filebase); } $arguments = array('/_xml' => $xml); if (!empty($CDASH_DEBUG_XML)) { $tmp = eregi_replace("(\\<)([A-Za-z0-9\\-_.]{1,250})(\\>)", "\\0\n", $xml); $tmp = eregi_replace("(\\</)([A-Za-z0-9\\-_.]{1,250})(\\>)", "\n\\0\n", $tmp); $inF = fopen($CDASH_DEBUG_XML, "w"); fwrite($inF, $tmp); fclose($inF); unset($inF); } $xslpage = $pageName . ".xsl"; // Check if the page exists in the local directory if ($CDASH_USE_LOCAL_DIRECTORY && file_exists("local/" . $xslpage)) { $xslpage = "local/" . $xslpage; } $html = xslt_process($xh, 'arg:/_xml', $xslpage, NULL, $arguments); // Enfore the charset to be UTF-8 header('Content-type: text/html; charset=utf-8'); echo $html; xslt_free($xh); }