ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ConfigDoc_HTMLXSLTProcessor Class Reference

Decorator/extender XSLT processor specifically for HTML documents. More...

+ Collaboration diagram for ConfigDoc_HTMLXSLTProcessor:

Public Member Functions

 __construct ($proc=false)
 
 importStylesheet ($xsl)
 
 transformToHTML ($xml)
 Transforms an XML file into compatible XHTML based on the stylesheet. More...
 
 setParameters ($options)
 Bulk sets parameters for the XSL stylesheet. More...
 
 __call ($name, $arguments)
 Forward any other calls to the XSLT processor. More...
 

Protected Attributes

 $xsltProcessor
 Instance of XSLTProcessor. More...
 

Detailed Description

Decorator/extender XSLT processor specifically for HTML documents.

Definition at line 6 of file HTMLXSLTProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

ConfigDoc_HTMLXSLTProcessor::__construct (   $proc = false)

Definition at line 14 of file HTMLXSLTProcessor.php.

15 {
16 if ($proc === false) $proc = new XSLTProcessor();
17 $this->xsltProcessor = $proc;
18 }

Member Function Documentation

◆ __call()

ConfigDoc_HTMLXSLTProcessor::__call (   $name,
  $arguments 
)

Forward any other calls to the XSLT processor.

Definition at line 84 of file HTMLXSLTProcessor.php.

85 {
86 call_user_func_array(array($this->xsltProcessor, $name), $arguments);
87 }
if($format !==null) $name
Definition: metadata.php:146

References $name.

◆ importStylesheet()

ConfigDoc_HTMLXSLTProcessor::importStylesheet (   $xsl)
Note
Allows a string $xsl filename to be passed

Definition at line 23 of file HTMLXSLTProcessor.php.

24 {
25 if (is_string($xsl)) {
26 $xsl_file = $xsl;
27 $xsl = new DOMDocument();
28 $xsl->load($xsl_file);
29 }
30 return $this->xsltProcessor->importStylesheet($xsl);
31 }

◆ setParameters()

ConfigDoc_HTMLXSLTProcessor::setParameters (   $options)

Bulk sets parameters for the XSL stylesheet.

Parameters
array$optionsAssociative array of options to set

Definition at line 74 of file HTMLXSLTProcessor.php.

75 {
76 foreach ($options as $name => $value) {
77 $this->xsltProcessor->setParameter('', $name, $value);
78 }
79 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20

References $name, and $options.

◆ transformToHTML()

ConfigDoc_HTMLXSLTProcessor::transformToHTML (   $xml)

Transforms an XML file into compatible XHTML based on the stylesheet.

Parameters
$xmlXML DOM tree, or string filename
Returns
string HTML output
Todo:
Rename to transformToXHTML, as transformToHTML is misleading

Definition at line 39 of file HTMLXSLTProcessor.php.

40 {
41 if (is_string($xml)) {
42 $dom = new DOMDocument();
43 $dom->load($xml);
44 } else {
45 $dom = $xml;
46 }
47 $out = $this->xsltProcessor->transformToXML($dom);
48
49 // fudges for HTML backwards compatibility
50 // assumes that document is XHTML
51 $out = str_replace('/>', ' />', $out); // <br /> not <br/>
52 $out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns
53
54 if (class_exists('Tidy')) {
55 // cleanup output
56 $config = array(
57 'indent' => true,
58 'output-xhtml' => true,
59 'wrap' => 80
60 );
61 $tidy = new Tidy;
62 $tidy->parseString($out, $config, 'utf8');
63 $tidy->cleanRepair();
64 $out = (string) $tidy;
65 }
66
67 return $out;
68 }
$xml
Definition: metadata.php:240

References $config, $out, and $xml.

Field Documentation

◆ $xsltProcessor

ConfigDoc_HTMLXSLTProcessor::$xsltProcessor
protected

Instance of XSLTProcessor.

Definition at line 12 of file HTMLXSLTProcessor.php.


The documentation for this class was generated from the following file: