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

[1.7.0] Create ConfigForm printer classes

- Extend hash to convert strings from form key,value,key,value
- Hack up configdoc to accommodate configForm.php smoketest

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1101 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-05-28 02:20:55 +00:00
parent ee61ffc0d9
commit ef51f8681a
14 changed files with 398 additions and 18 deletions

View File

@@ -14,6 +14,11 @@ TODO:
- factor out code into classes
*/
// there are several hacks for the configForm.php smoketest
// - load copies (override default schema)
// - file/line server information hack
// - post-processing, base-name change hack
// ---------------------------------------------------------------------------
// Check and configure environment
@@ -47,7 +52,15 @@ function appendHTMLDiv($document, $node, $html) {
// ---------------------------------------------------------------------------
// Load copies of HTMLPurifier_ConfigDef and HTMLPurifier
$schema = HTMLPurifier_ConfigSchema::instance();
// hack
if (defined('HTMLPURIFIER_CUSTOM_SCHEMA')) {
// included from somewhere else
$var = HTMLPURIFIER_CUSTOM_SCHEMA;
$schema = $$var;
chdir(dirname(__FILE__));
} else {
$schema = HTMLPurifier_ConfigSchema::instance();
}
$purifier = new HTMLPurifier();
@@ -153,8 +166,11 @@ foreach($schema->info as $namespace_name => $namespace_info) {
foreach ($info->descriptions as $file => $file_descriptions) {
foreach ($file_descriptions as $line => $description) {
$dom_description = $dom_document->createElement('description');
$dom_description->setAttribute('file', $file);
$dom_description->setAttribute('line', $line);
// hack
if (!defined('HTMLPURIFIER_CUSTOM_SCHEMA')) {
$dom_description->setAttribute('file', $file);
$dom_description->setAttribute('line', $line);
}
appendHTMLDiv($dom_document, $dom_description, $description);
$dom_descriptions->appendChild($dom_description);
}
@@ -203,9 +219,13 @@ if (class_exists('Tidy')) {
$html_output = (string) $tidy;
}
// write it to a file (todo: parse into seperate pages)
file_put_contents("$xsl_stylesheet_name.html", $html_output);
// hack
if (!defined('HTMLPURIFIER_CUSTOM_SCHEMA')) {
// write it to a file (todo: parse into seperate pages)
file_put_contents("$xsl_stylesheet_name.html", $html_output);
} else {
$html_output = str_replace('styles/plain.css', HTMLPURIFIER_SCRIPT_LOCATION . 'styles/plain.css', $html_output);
}
// ---------------------------------------------------------------------------
// Output for instant feedback

View File

@@ -76,15 +76,17 @@
<table class="constraints">
<xsl:apply-templates />
<!-- Calculated other values -->
<tr>
<th>Used by:</th>
<td>
<xsl:for-each select="../descriptions/description">
<xsl:if test="position()&gt;1">, </xsl:if>
<xsl:value-of select="@file" />
</xsl:for-each>
</td>
</tr>
<xsl:if test="../descriptions/description[@file]">
<tr>
<th>Used by:</th>
<td>
<xsl:for-each select="../descriptions/description">
<xsl:if test="position()&gt;1">, </xsl:if>
<xsl:value-of select="@file" />
</xsl:for-each>
</td>
</tr>
</xsl:if>
</table>
</xsl:template>
<xsl:template match="directive//description">