|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file adds xslt_xxx emulation functions. 00003 // It is intended for systems, e.g. those running PHP 5, where: 00004 // 1) The XSLT library is not installed. 00005 // 2) The XSL library is installed. 00006 // 00007 // Note that not everything is implemented. 00008 // In particular, only the bare minimum to support the BB conversion is here. 00009 00010 // This silliness is required to prevent PHP from evaluating the function() blocks before processing the return;s 00011 if(true) { 00012 00013 00014 if(function_exists('xslt_create')) return; // xslt_create() already exists, so emulation isn't needed. 00015 if(!class_exists('XSLTProcessor')) return; // There is no XSLTProcessor class, so emulation isn't possible. 00016 if(!class_exists('DOMDocument')) return; // There is no DOMDocument class, so emulation isn't possible. 00017 00018 00019 00020 function xslt_create() { 00021 return new XSLTProcessor(); 00022 } 00023 00024 // We don't support arguments or parameters because the Bb import doesn't use them 00025 function xslt_process($proc, $xmlfile, $xslfile, $resultfile = null, $unsupported_args = null, $unsupported_params = null) { 00026 $doc = new DOMDocument; 00027 $doc->load($xmlfile); 00028 $xsl = new DOMDocument; 00029 $xsl->load($xslfile); 00030 $proc->importStylesheet($xsl); 00031 00032 // Squash warnings here because xsl complains about COURSE_ACCESS tags which really are invalid XML (multiple root elements) 00033 if($resultfile !== null) { 00034 $fp = fopen($resultfile, 'w'); 00035 fwrite($fp, @$proc->transformToXML($doc)); 00036 fclose($fp); 00037 return true; 00038 } else { 00039 return @$proc->transformToXML($doc); 00040 } 00041 } 00042 00043 } // end if(true)