admin
doz
html2pdf_v4.03
htmlpurifier-4.10.0
art
benchmarks
configdoc
docs
extras
library
HTMLPurifier
AttrDef
AttrTransform
ChildDef
ConfigSchema
Builder
ConfigSchema.php
Xml.php
Interchange
schema
Exception.php
Interchange.php
InterchangeBuilder.php
Validator.php
ValidatorAtom.php
schema.ser
DefinitionCache
EntityLookup
Filter
HTMLModule
Injector
Language
Lexer
Node
Printer
Strategy
TagTransform
Token
URIFilter
URIScheme
VarParser
Arborize.php
AttrCollections.php
AttrDef.php
AttrTransform.php
AttrTypes.php
AttrValidator.php
Bootstrap.php
CSSDefinition.php
ChildDef.php
Config.php
ConfigSchema.php
ContentSets.php
Context.php
Definition.php
DefinitionCache.php
DefinitionCacheFactory.php
Doctype.php
DoctypeRegistry.php
ElementDef.php
Encoder.php
EntityLookup.php
EntityParser.php
ErrorCollector.php
ErrorStruct.php
Exception.php
Filter.php
Generator.php
HTMLDefinition.php
HTMLModule.php
HTMLModuleManager.php
IDAccumulator.php
Injector.php
Language.php
LanguageFactory.php
Length.php
Lexer.php
Node.php
PercentEncoder.php
Printer.php
PropertyList.php
PropertyListIterator.php
Queue.php
Strategy.php
StringHash.php
StringHashParser.php
TagTransform.php
Token.php
TokenFactory.php
URI.php
URIDefinition.php
URIFilter.php
URIParser.php
URIScheme.php
URISchemeRegistry.php
UnitConverter.php
VarParser.php
VarParserException.php
Zipper.php
HTMLPurifier.auto.php
HTMLPurifier.autoload-legacy.php
HTMLPurifier.autoload.php
HTMLPurifier.composer.php
HTMLPurifier.func.php
HTMLPurifier.includes.php
HTMLPurifier.kses.php
HTMLPurifier.path.php
HTMLPurifier.php
HTMLPurifier.safe-includes.php
maintenance
plugins
smoketests
tests
.gitattributes
.gitignore
.travis.yml
CREDITS
Doxyfile
INSTALL
INSTALL.fr.utf8
LICENSE
NEWS
README.md
TODO
VERSION
WHATSNEW
WYSIWYG
composer.json
phpdoc.ini
images
prints
prints3
stud
Kennwortwechsel.php
hauptframe.php
htmlpurifier-4.10.0.zip
index.php
index_alt.php
index_db.php
index_frame.htm
index_ldap.php
login.php
logout.php
menuframe.htm
styles_pc.css
testpdf.php
topframe.php
145 lines
4.4 KiB
PHP
Executable File
145 lines
4.4 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* Converts HTMLPurifier_ConfigSchema_Interchange to an XML format,
|
|
* which can be further processed to generate documentation.
|
|
*/
|
|
class HTMLPurifier_ConfigSchema_Builder_Xml extends XMLWriter
|
|
{
|
|
|
|
/**
|
|
* @type HTMLPurifier_ConfigSchema_Interchange
|
|
*/
|
|
protected $interchange;
|
|
|
|
/**
|
|
* @type string
|
|
*/
|
|
private $namespace;
|
|
|
|
/**
|
|
* @param string $html
|
|
*/
|
|
protected function writeHTMLDiv($html)
|
|
{
|
|
$this->startElement('div');
|
|
|
|
$purifier = HTMLPurifier::getInstance();
|
|
$html = $purifier->purify($html);
|
|
$this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
|
|
$this->writeRaw($html);
|
|
|
|
$this->endElement(); // div
|
|
}
|
|
|
|
/**
|
|
* @param mixed $var
|
|
* @return string
|
|
*/
|
|
protected function export($var)
|
|
{
|
|
if ($var === array()) {
|
|
return 'array()';
|
|
}
|
|
return var_export($var, true);
|
|
}
|
|
|
|
/**
|
|
* @param HTMLPurifier_ConfigSchema_Interchange $interchange
|
|
*/
|
|
public function build($interchange)
|
|
{
|
|
// global access, only use as last resort
|
|
$this->interchange = $interchange;
|
|
|
|
$this->setIndent(true);
|
|
$this->startDocument('1.0', 'UTF-8');
|
|
$this->startElement('configdoc');
|
|
$this->writeElement('title', $interchange->name);
|
|
|
|
foreach ($interchange->directives as $directive) {
|
|
$this->buildDirective($directive);
|
|
}
|
|
|
|
if ($this->namespace) {
|
|
$this->endElement();
|
|
} // namespace
|
|
|
|
$this->endElement(); // configdoc
|
|
$this->flush();
|
|
}
|
|
|
|
/**
|
|
* @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive
|
|
*/
|
|
public function buildDirective($directive)
|
|
{
|
|
// Kludge, although I suppose having a notion of a "root namespace"
|
|
// certainly makes things look nicer when documentation is built.
|
|
// Depends on things being sorted.
|
|
if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) {
|
|
if ($this->namespace) {
|
|
$this->endElement();
|
|
} // namespace
|
|
$this->namespace = $directive->id->getRootNamespace();
|
|
$this->startElement('namespace');
|
|
$this->writeAttribute('id', $this->namespace);
|
|
$this->writeElement('name', $this->namespace);
|
|
}
|
|
|
|
$this->startElement('directive');
|
|
$this->writeAttribute('id', $directive->id->toString());
|
|
|
|
$this->writeElement('name', $directive->id->getDirective());
|
|
|
|
$this->startElement('aliases');
|
|
foreach ($directive->aliases as $alias) {
|
|
$this->writeElement('alias', $alias->toString());
|
|
}
|
|
$this->endElement(); // aliases
|
|
|
|
$this->startElement('constraints');
|
|
if ($directive->version) {
|
|
$this->writeElement('version', $directive->version);
|
|
}
|
|
$this->startElement('type');
|
|
if ($directive->typeAllowsNull) {
|
|
$this->writeAttribute('allow-null', 'yes');
|
|
}
|
|
$this->text($directive->type);
|
|
$this->endElement(); // type
|
|
if ($directive->allowed) {
|
|
$this->startElement('allowed');
|
|
foreach ($directive->allowed as $value => $x) {
|
|
$this->writeElement('value', $value);
|
|
}
|
|
$this->endElement(); // allowed
|
|
}
|
|
$this->writeElement('default', $this->export($directive->default));
|
|
$this->writeAttribute('xml:space', 'preserve');
|
|
if ($directive->external) {
|
|
$this->startElement('external');
|
|
foreach ($directive->external as $project) {
|
|
$this->writeElement('project', $project);
|
|
}
|
|
$this->endElement();
|
|
}
|
|
$this->endElement(); // constraints
|
|
|
|
if ($directive->deprecatedVersion) {
|
|
$this->startElement('deprecated');
|
|
$this->writeElement('version', $directive->deprecatedVersion);
|
|
$this->writeElement('use', $directive->deprecatedUse->toString());
|
|
$this->endElement(); // deprecated
|
|
}
|
|
|
|
$this->startElement('description');
|
|
$this->writeHTMLDiv($directive->description);
|
|
$this->endElement(); // description
|
|
|
|
$this->endElement(); // directive
|
|
}
|
|
}
|
|
|
|
// vim: et sw=4 sts=4
|