~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to backup/bb/xsl_emulate_xslt.inc

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// This file adds xslt_xxx emulation functions.
 
3
// It is intended for systems, e.g. those running PHP 5, where:
 
4
// 1) The XSLT library is not installed.
 
5
// 2) The XSL library is installed.
 
6
//
 
7
// Note that not everything is implemented.
 
8
// In particular, only the bare minimum to support the BB conversion is here.
 
9
 
 
10
// This silliness is required to prevent PHP from evaluating the function() blocks before processing the return;s
 
11
if(true) {
 
12
 
 
13
 
 
14
if(function_exists('xslt_create')) return;     // xslt_create() already exists, so emulation isn't needed.
 
15
if(!class_exists('XSLTProcessor')) return;     // There is no XSLTProcessor class, so emulation isn't possible.
 
16
if(!class_exists('DOMDocument')) return;       // There is no DOMDocument class, so emulation isn't possible.
 
17
 
 
18
 
 
19
 
 
20
function xslt_create() {
 
21
       return new XSLTProcessor();
 
22
}
 
23
 
 
24
// We don't support arguments or parameters because the Bb import doesn't use them
 
25
function xslt_process($proc, $xmlfile, $xslfile, $resultfile = null, $unsupported_args = null, $unsupported_params = null) {
 
26
       $doc = new DOMDocument;
 
27
       $doc->load($xmlfile);
 
28
       $xsl = new DOMDocument;
 
29
       $xsl->load($xslfile);
 
30
       $proc->importStylesheet($xsl);
 
31
 
 
32
       // Squash warnings here because xsl complains about COURSE_ACCESS tags which really are invalid XML (multiple root elements)
 
33
       if($resultfile !== null) {
 
34
               $fp = fopen($resultfile, 'w');
 
35
               fwrite($fp, @$proc->transformToXML($doc));
 
36
               fclose($fp);
 
37
               return true;
 
38
       } else {
 
39
               return @$proc->transformToXML($doc);
 
40
       }
 
41
}
 
42
 
 
43
} // end if(true)