1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-30 19:00:10 +02:00

Convert to PHP 5 only codebase, adding visibility modifiers to all members and methods in the main library area (function only for test methods)

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1458 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-11-25 02:24:39 +00:00
parent 85a23bacb6
commit 43f01925cd
195 changed files with 1003 additions and 1064 deletions

View File

@@ -1,12 +1,15 @@
<?php
/**
* Special XSLTProcessor specifically for HTML documents. Loosely
* based off of XSLTProcessor, but not really
* Special XSLT processor specifically for HTML documents. Loosely
* based off of XSLTProcessor, but does not inherit from that class
*/
class ConfigDoc_HTMLXSLTProcessor
{
/**
* Instance of XSLTProcessor
*/
protected $xsltProcessor;
public function __construct() {
@@ -16,6 +19,7 @@ class ConfigDoc_HTMLXSLTProcessor
/**
* Imports stylesheet for processor to use
* @param $xsl XSLT DOM tree, or filename of the XSL transformation
* @return bool Success?
*/
public function importStylesheet($xsl) {
if (is_string($xsl)) {
@@ -27,16 +31,20 @@ class ConfigDoc_HTMLXSLTProcessor
}
/**
* Transforms an XML file into HTML based on the stylesheet
* Transforms an XML file into compatible XHTML based on the stylesheet
* @param $xml XML DOM tree
* @return string HTML output
* @todo Rename to transformToXHTML, as transformToHTML is misleading
*/
public function transformToHTML($xml) {
$out = $this->xsltProcessor->transformToXML($xml);
// fudges for HTML backwards compatibility
// assumes that document is XHTML
$out = str_replace('/>', ' />', $out); // <br /> not <br/>
$out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns
$out = str_replace(' xmlns="http://www.w3.org/1999/xhtml"', '', $out); // rm unnecessary xmlns
if (class_exists('Tidy')) {
// cleanup output
$config = array(
@@ -49,9 +57,14 @@ class ConfigDoc_HTMLXSLTProcessor
$tidy->cleanRepair();
$out = (string) $tidy;
}
return $out;
}
/**
* Bulk sets parameters for the XSL stylesheet
* @param array $options Associative array of options to set
*/
public function setParameters($options) {
foreach ($options as $name => $value) {
$this->xsltProcessor->setParameter('', $name, $value);