mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 00:41:52 +00:00
[3.1.0] Implement file sniffing of $config, for TRUE feature parity! Also add some really silly multi-column code in the XSLT.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1668 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
8708c0617a
commit
e616f07739
4
TODO
4
TODO
@ -26,10 +26,6 @@ IMPORTANT FEATURES
|
|||||||
- Factor out command line parser into its own class, and unit test it
|
- Factor out command line parser into its own class, and unit test it
|
||||||
- Figure out autoload and PEAR
|
- Figure out autoload and PEAR
|
||||||
|
|
||||||
CONFIGDOC
|
|
||||||
- Implement source code sniffing for configdoc, so we can easily figure out
|
|
||||||
which files use what configuration (we'll rely on the $config convention)
|
|
||||||
|
|
||||||
NICE FEATURES
|
NICE FEATURES
|
||||||
- Factor demo.php into a set of Printer classes, and then create a stub
|
- Factor demo.php into a set of Printer classes, and then create a stub
|
||||||
file for users here (inside the actual HTML Purifier library)
|
file for users here (inside the actual HTML Purifier library)
|
||||||
|
@ -1,16 +1,30 @@
|
|||||||
|
|
||||||
body {margin:1em 4em;}
|
body {margin:0;padding:0;}
|
||||||
|
#content {
|
||||||
|
margin:1em auto;
|
||||||
|
max-width: 47em;
|
||||||
|
width: expression(document.body.clientWidth >
|
||||||
|
85 * parseInt(document.body.currentStyle.fontSize) ?
|
||||||
|
"54em": "auto");
|
||||||
|
}
|
||||||
|
|
||||||
table {border-collapse:collapse;}
|
table {border-collapse:collapse;}
|
||||||
table td, table th {padding:0.2em;}
|
table td, table th {padding:0.2em;}
|
||||||
|
|
||||||
table.constraints {margin:0 0 1em;}
|
table.constraints {margin:0 0 1em;}
|
||||||
table.constraints th {text-align:left;padding-left:0.4em;}
|
table.constraints th {
|
||||||
table.constraints td {padding-right:0.4em;}
|
text-align:right;padding-left:0.4em;padding-right:0.4em;background:#EEE;
|
||||||
|
width:8em;vertical-align:top;}
|
||||||
|
table.constraints td {padding-right:0.4em; padding-left: 1em;}
|
||||||
|
table.constraints td ul {padding:0; margin:0; list-style:none;}
|
||||||
table.constraints td pre {margin:0;}
|
table.constraints td pre {margin:0;}
|
||||||
|
|
||||||
#toc {list-style-type:none; font-weight:bold;}
|
#tocContainer {position:relative;}
|
||||||
#toc ul {list-style-type:disc; font-weight:normal;}
|
#toc {list-style-type:none; font-weight:bold; font-size:1em; margin-bottom:1em;}
|
||||||
|
#toc li {position:relative; line-height: 1.2em;}
|
||||||
|
#toc .col-2 {margin-left:50%;}
|
||||||
|
#toc .col-l {float:left;}
|
||||||
|
#toc ul {list-style-type:disc; font-weight:normal; padding-bottom:1.2em;}
|
||||||
|
|
||||||
.description p {margin-top:0;margin-bottom:1em;}
|
.description p {margin-top:0;margin-bottom:1em;}
|
||||||
|
|
||||||
@ -19,9 +33,10 @@ table.constraints td pre {margin:0;}
|
|||||||
#library {font-size:1em;}
|
#library {font-size:1em;}
|
||||||
h1 {margin-top:0;}
|
h1 {margin-top:0;}
|
||||||
h2 {border-bottom:1px solid #CCC; font-family:sans-serif; font-weight:normal;
|
h2 {border-bottom:1px solid #CCC; font-family:sans-serif; font-weight:normal;
|
||||||
font-size:1.3em;}
|
font-size:1.3em; clear:both;}
|
||||||
h3 {font-family:sans-serif; font-size:1.1em; font-weight:bold; }
|
h3 {font-family:sans-serif; font-size:1.1em; font-weight:bold; }
|
||||||
h4 {font-family:sans-serif; font-size:0.9em; font-weight:bold; }
|
h4 {font-family:sans-serif; font-size:0.9em; font-weight:bold; }
|
||||||
|
|
||||||
.deprecated {color: #CCC;}
|
.deprecated {color: #CCC;}
|
||||||
|
.deprecated table.constraints th {background:#FFF;}
|
||||||
.deprecated-notice {color: #000; text-align:center; margin-bottom: 1em;}
|
.deprecated-notice {color: #000; text-align:center; margin-bottom: 1em;}
|
||||||
|
@ -15,7 +15,11 @@
|
|||||||
<xsl:param name="css" select="'styles/plain.css'"/>
|
<xsl:param name="css" select="'styles/plain.css'"/>
|
||||||
<xsl:param name="title" select="'Configuration Documentation'"/>
|
<xsl:param name="title" select="'Configuration Documentation'"/>
|
||||||
|
|
||||||
<xsl:variable name="typeLookup" select="document('../types.xml')" />
|
<xsl:variable name="typeLookup" select="document('../types.xml')/types" />
|
||||||
|
<xsl:variable name="usageLookup" select="document('../usage.xml')/usage" />
|
||||||
|
|
||||||
|
<!-- Twiddle this variable to get the columns as even as possible -->
|
||||||
|
<xsl:variable name="maxNumberAdjust" select="1" />
|
||||||
|
|
||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
<html lang="en" xml:lang="en">
|
<html lang="en" xml:lang="en">
|
||||||
@ -25,31 +29,58 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="{$css}" />
|
<link rel="stylesheet" type="text/css" href="{$css}" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="library"><xsl:value-of select="/configdoc/title" /></div>
|
<div id="content">
|
||||||
<h1><xsl:value-of select="$title" /></h1>
|
<div id="library"><xsl:value-of select="/configdoc/title" /></div>
|
||||||
<h2>Table of Contents</h2>
|
<h1><xsl:value-of select="$title" /></h1>
|
||||||
<ul id="toc">
|
<div id="tocContainer">
|
||||||
<xsl:apply-templates mode="toc" />
|
<h2>Table of Contents</h2>
|
||||||
</ul>
|
<ul id="toc">
|
||||||
<xsl:apply-templates />
|
<xsl:apply-templates mode="toc">
|
||||||
|
<xsl:with-param name="overflowNumber" select="round(count(/configdoc/namespace) div 2) + $maxNumberAdjust" />
|
||||||
|
</xsl:apply-templates>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<xsl:apply-templates />
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="title" mode="toc" />
|
<xsl:template match="title" mode="toc" />
|
||||||
<xsl:template match="namespace" mode="toc">
|
<xsl:template match="namespace" mode="toc">
|
||||||
|
<xsl:param name="overflowNumber" />
|
||||||
|
<xsl:variable name="number"><xsl:number level="single" /></xsl:variable>
|
||||||
|
<xsl:variable name="directiveNumber"><xsl:number level="any" count="directive" /></xsl:variable>
|
||||||
<xsl:if test="count(directive)>0">
|
<xsl:if test="count(directive)>0">
|
||||||
<li>
|
<li>
|
||||||
|
<!-- BEGIN multicolumn code -->
|
||||||
|
<xsl:if test="$number >= $overflowNumber">
|
||||||
|
<xsl:attribute name="class">col-2</xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="$number = $overflowNumber">
|
||||||
|
<xsl:attribute name="style">margin-top:-<xsl:value-of select="($number * 2 + $directiveNumber - 3) * 1.2" />em</xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
<!-- END multicolumn code -->
|
||||||
<a href="#{@id}"><xsl:value-of select="name" /></a>
|
<a href="#{@id}"><xsl:value-of select="name" /></a>
|
||||||
<ul>
|
<ul>
|
||||||
<xsl:apply-templates select="directive" mode="toc" />
|
<xsl:apply-templates select="directive" mode="toc">
|
||||||
|
<xsl:with-param name="overflowNumber" select="$overflowNumber" />
|
||||||
|
</xsl:apply-templates>
|
||||||
</ul>
|
</ul>
|
||||||
|
<xsl:if test="$number + 1 = $overflowNumber">
|
||||||
|
<div class="col-l" />
|
||||||
|
</xsl:if>
|
||||||
</li>
|
</li>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="directive" mode="toc">
|
<xsl:template match="directive" mode="toc">
|
||||||
|
<xsl:variable name="number">
|
||||||
|
<xsl:number level="any" count="directive|namespace" />
|
||||||
|
</xsl:variable>
|
||||||
<xsl:if test="not(deprecated)">
|
<xsl:if test="not(deprecated)">
|
||||||
<li><a href="#{@id}"><xsl:value-of select="name" /></a></li>
|
<li>
|
||||||
|
<a href="#{@id}"><xsl:value-of select="name" /></a>
|
||||||
|
</li>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
@ -74,14 +105,19 @@
|
|||||||
|
|
||||||
<xsl:template match="directive">
|
<xsl:template match="directive">
|
||||||
<div>
|
<div>
|
||||||
<xsl:attribute name="class">directive<xsl:if test="deprecated"> deprecated</xsl:if>
|
<xsl:attribute name="class"><!--
|
||||||
</xsl:attribute>
|
-->directive<!--
|
||||||
<xsl:apply-templates />
|
--><xsl:if test="deprecated"> deprecated</xsl:if><!--
|
||||||
|
--></xsl:attribute>
|
||||||
|
<xsl:apply-templates>
|
||||||
|
<xsl:with-param name="id" select="@id" />
|
||||||
|
</xsl:apply-templates>
|
||||||
</div>
|
</div>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="directive/name">
|
<xsl:template match="directive/name">
|
||||||
|
<xsl:param name="id" />
|
||||||
<xsl:apply-templates select="../aliases/alias" mode="anchor" />
|
<xsl:apply-templates select="../aliases/alias" mode="anchor" />
|
||||||
<h3 id="{../@id}"><xsl:value-of select="../@id" /></h3>
|
<h3 id="{$id}"><xsl:value-of select="$id" /></h3>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="alias" mode="anchor">
|
<xsl:template match="alias" mode="anchor">
|
||||||
<a id="{.}"></a>
|
<a id="{.}"></a>
|
||||||
@ -91,16 +127,18 @@
|
|||||||
<xsl:template match="alias"></xsl:template>
|
<xsl:template match="alias"></xsl:template>
|
||||||
|
|
||||||
<xsl:template match="directive/constraints">
|
<xsl:template match="directive/constraints">
|
||||||
|
<xsl:param name="id" />
|
||||||
<table class="constraints">
|
<table class="constraints">
|
||||||
<xsl:apply-templates />
|
<xsl:apply-templates />
|
||||||
<xsl:if test="../aliases/alias">
|
<xsl:if test="../aliases/alias">
|
||||||
<xsl:apply-templates select="../aliases" mode="constraints" />
|
<xsl:apply-templates select="../aliases" mode="constraints" />
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
<xsl:apply-templates select="$usageLookup/directive[@id=$id]" />
|
||||||
</table>
|
</table>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="directive/aliases" mode="constraints">
|
<xsl:template match="directive/aliases" mode="constraints">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Aliases:</th>
|
<th>Aliases</th>
|
||||||
<td>
|
<td>
|
||||||
<xsl:for-each select="alias">
|
<xsl:for-each select="alias">
|
||||||
<xsl:if test="position()>1">, </xsl:if>
|
<xsl:if test="position()>1">, </xsl:if>
|
||||||
@ -116,24 +154,45 @@
|
|||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="directive/deprecated">
|
<xsl:template match="directive/deprecated">
|
||||||
<div class="deprecated-notice">
|
<div class="deprecated-notice">
|
||||||
|
<strong>Warning:</strong>
|
||||||
This directive was deprecated in version <xsl:value-of select="version" />.
|
This directive was deprecated in version <xsl:value-of select="version" />.
|
||||||
<a href="#{use}">%<xsl:value-of select="use" /></a> should be used instead.
|
<a href="#{use}">%<xsl:value-of select="use" /></a> should be used instead.
|
||||||
</div>
|
</div>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
<xsl:template match="usage/directive">
|
||||||
|
<tr>
|
||||||
|
<th>Used in</th>
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
<xsl:apply-templates />
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="usage/directive/file">
|
||||||
|
<li>
|
||||||
|
<em><xsl:value-of select="@name" /></em> on line<xsl:if test="count(line)>1">s</xsl:if>
|
||||||
|
<xsl:text> </xsl:text>
|
||||||
|
<xsl:for-each select="line">
|
||||||
|
<xsl:if test="position()>1">, </xsl:if>
|
||||||
|
<xsl:value-of select="." />
|
||||||
|
</xsl:for-each>
|
||||||
|
</li>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="constraints/version">
|
<xsl:template match="constraints/version">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Version:</th>
|
<th>Version added</th>
|
||||||
<td><xsl:value-of select="." /></td>
|
<td><xsl:value-of select="." /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="constraints/type">
|
<xsl:template match="constraints/type">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Type:</th>
|
<th>Type</th>
|
||||||
<td>
|
<td>
|
||||||
<xsl:variable name="type" select="text()" />
|
<xsl:variable name="type" select="text()" />
|
||||||
<xsl:attribute name="class">type type-<xsl:value-of select="$type" /></xsl:attribute>
|
<xsl:attribute name="class">type type-<xsl:value-of select="$type" /></xsl:attribute>
|
||||||
<xsl:value-of select="$typeLookup/types/type[@id=$type]/text()" />
|
<xsl:value-of select="$typeLookup/type[@id=$type]/text()" />
|
||||||
<xsl:if test="@allow-null='yes'">
|
<xsl:if test="@allow-null='yes'">
|
||||||
(or null)
|
(or null)
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@ -142,7 +201,7 @@
|
|||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="constraints/allowed">
|
<xsl:template match="constraints/allowed">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Allowed values:</th>
|
<th>Allowed values</th>
|
||||||
<td>
|
<td>
|
||||||
<xsl:for-each select="value"><!--
|
<xsl:for-each select="value"><!--
|
||||||
--><xsl:if test="position()>1">, </xsl:if>
|
--><xsl:if test="position()>1">, </xsl:if>
|
||||||
@ -153,7 +212,7 @@
|
|||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="constraints/default">
|
<xsl:template match="constraints/default">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Default:</th>
|
<th>Default</th>
|
||||||
<td><pre><xsl:value-of select="." xml:space="preserve" /></pre></td>
|
<td><pre><xsl:value-of select="." xml:space="preserve" /></pre></td>
|
||||||
</tr>
|
</tr>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
346
configdoc/usage.xml
Normal file
346
configdoc/usage.xml
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<usage>
|
||||||
|
<directive id="Core.CollectErrors">
|
||||||
|
<file name="HTMLPurifier.php">
|
||||||
|
<line>130</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
|
<line>93</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Lexer/DirectLex.php">
|
||||||
|
<line>50</line>
|
||||||
|
<line>62</line>
|
||||||
|
<line>327</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
|
||||||
|
<line>44</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="CSS.Proprietary">
|
||||||
|
<file name="HTMLPurifier/CSSDefinition.php">
|
||||||
|
<line>201</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="CSS.AllowTricky">
|
||||||
|
<file name="HTMLPurifier/CSSDefinition.php">
|
||||||
|
<line>205</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="CSS.AllowImportant">
|
||||||
|
<file name="HTMLPurifier/CSSDefinition.php">
|
||||||
|
<line>209</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="CSS.AllowedProperties">
|
||||||
|
<file name="HTMLPurifier/CSSDefinition.php">
|
||||||
|
<line>261</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Cache.DefinitionImpl">
|
||||||
|
<file name="HTMLPurifier/DefinitionCacheFactory.php">
|
||||||
|
<line>49</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.Doctype">
|
||||||
|
<file name="HTMLPurifier/DoctypeRegistry.php">
|
||||||
|
<line>83</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.CustomDoctype">
|
||||||
|
<file name="HTMLPurifier/DoctypeRegistry.php">
|
||||||
|
<line>85</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.XHTML">
|
||||||
|
<file name="HTMLPurifier/DoctypeRegistry.php">
|
||||||
|
<line>88</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.Strict">
|
||||||
|
<file name="HTMLPurifier/DoctypeRegistry.php">
|
||||||
|
<line>93</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.Encoding">
|
||||||
|
<file name="HTMLPurifier/Encoder.php">
|
||||||
|
<line>267</line>
|
||||||
|
<line>285</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Test.ForceNoIconv">
|
||||||
|
<file name="HTMLPurifier/Encoder.php">
|
||||||
|
<line>269</line>
|
||||||
|
<line>290</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.EscapeNonASCIICharacters">
|
||||||
|
<file name="HTMLPurifier/Encoder.php">
|
||||||
|
<line>287</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.MaintainLineNumbers">
|
||||||
|
<file name="HTMLPurifier/ErrorCollector.php">
|
||||||
|
<line>81</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
|
<line>90</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Lexer/DirectLex.php">
|
||||||
|
<line>45</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Output.CommentScriptContents">
|
||||||
|
<file name="HTMLPurifier/Generator.php">
|
||||||
|
<line>40</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Output.TidyFormat">
|
||||||
|
<file name="HTMLPurifier/Generator.php">
|
||||||
|
<line>61</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Output.Newline">
|
||||||
|
<file name="HTMLPurifier/Generator.php">
|
||||||
|
<line>86</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.BlockWrapper">
|
||||||
|
<file name="HTMLPurifier/HTMLDefinition.php">
|
||||||
|
<line>213</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.Parent">
|
||||||
|
<file name="HTMLPurifier/HTMLDefinition.php">
|
||||||
|
<line>221</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.AllowedElements">
|
||||||
|
<file name="HTMLPurifier/HTMLDefinition.php">
|
||||||
|
<line>238</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.AllowedAttributes">
|
||||||
|
<file name="HTMLPurifier/HTMLDefinition.php">
|
||||||
|
<line>239</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.Allowed">
|
||||||
|
<file name="HTMLPurifier/HTMLDefinition.php">
|
||||||
|
<line>242</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.Trusted">
|
||||||
|
<file name="HTMLPurifier/HTMLModuleManager.php">
|
||||||
|
<line>198</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
|
<line>245</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Lexer/DirectLex.php">
|
||||||
|
<line>34</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.AllowedModules">
|
||||||
|
<file name="HTMLPurifier/HTMLModuleManager.php">
|
||||||
|
<line>205</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.CoreModules">
|
||||||
|
<file name="HTMLPurifier/HTMLModuleManager.php">
|
||||||
|
<line>206</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.Proprietary">
|
||||||
|
<file name="HTMLPurifier/HTMLModuleManager.php">
|
||||||
|
<line>220</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.IDBlacklist">
|
||||||
|
<file name="HTMLPurifier/IDAccumulator.php">
|
||||||
|
<line>26</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.Language">
|
||||||
|
<file name="HTMLPurifier/LanguageFactory.php">
|
||||||
|
<line>85</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.LexerImpl">
|
||||||
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
|
<line>78</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.ConvertDocumentToFragment">
|
||||||
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
|
<line>237</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.Host">
|
||||||
|
<file name="HTMLPurifier/URIDefinition.php">
|
||||||
|
<line>57</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/URIFilter/DisableExternal.php">
|
||||||
|
<line>8</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.Base">
|
||||||
|
<file name="HTMLPurifier/URIDefinition.php">
|
||||||
|
<line>58</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.DefaultScheme">
|
||||||
|
<file name="HTMLPurifier/URIDefinition.php">
|
||||||
|
<line>65</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.AllowedSchemes">
|
||||||
|
<file name="HTMLPurifier/URISchemeRegistry.php">
|
||||||
|
<line>42</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.OverrideAllowedSchemes">
|
||||||
|
<file name="HTMLPurifier/URISchemeRegistry.php">
|
||||||
|
<line>43</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.Disable">
|
||||||
|
<file name="HTMLPurifier/AttrDef/URI.php">
|
||||||
|
<line>24</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.Munge">
|
||||||
|
<file name="HTMLPurifier/AttrDef/URI.php">
|
||||||
|
<line>78</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.ColorKeywords">
|
||||||
|
<file name="HTMLPurifier/AttrDef/CSS/Color.php">
|
||||||
|
<line>12</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/AttrDef/HTML/Color.php">
|
||||||
|
<line>12</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.AllowedFrameTargets">
|
||||||
|
<file name="HTMLPurifier/AttrDef/HTML/FrameTarget.php">
|
||||||
|
<line>15</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.EnableID">
|
||||||
|
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
|
||||||
|
<line>20</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.IDPrefix">
|
||||||
|
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
|
||||||
|
<line>26</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.IDPrefixLocal">
|
||||||
|
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
|
||||||
|
<line>28</line>
|
||||||
|
<line>31</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.IDBlacklistRegexp">
|
||||||
|
<file name="HTMLPurifier/AttrDef/HTML/ID.php">
|
||||||
|
<line>54</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.DefaultTextDir">
|
||||||
|
<file name="HTMLPurifier/AttrTransform/BdoDir.php">
|
||||||
|
<line>13</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.RemoveInvalidImg">
|
||||||
|
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
|
||||||
|
<line>18</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
|
||||||
|
<line>20</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.DefaultInvalidImage">
|
||||||
|
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
|
||||||
|
<line>19</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Attr.DefaultInvalidImageAlt">
|
||||||
|
<file name="HTMLPurifier/AttrTransform/ImgRequired.php">
|
||||||
|
<line>27</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.EscapeInvalidChildren">
|
||||||
|
<file name="HTMLPurifier/ChildDef/Required.php">
|
||||||
|
<line>55</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Cache.SerializerPath">
|
||||||
|
<file name="HTMLPurifier/DefinitionCache/Serializer.php">
|
||||||
|
<line>91</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Filter.ExtractStyleBlocksScope">
|
||||||
|
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
|
||||||
|
<line>69</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Filter.ExtractStyleBlocksEscaping">
|
||||||
|
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
|
||||||
|
<line>127</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.TidyLevel">
|
||||||
|
<file name="HTMLPurifier/HTMLModule/Tidy.php">
|
||||||
|
<line>45</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.TidyAdd">
|
||||||
|
<file name="HTMLPurifier/HTMLModule/Tidy.php">
|
||||||
|
<line>49</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="HTML.TidyRemove">
|
||||||
|
<file name="HTMLPurifier/HTMLModule/Tidy.php">
|
||||||
|
<line>50</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="AutoFormatParam.PurifierLinkifyDocURL">
|
||||||
|
<file name="HTMLPurifier/Injector/PurifierLinkify.php">
|
||||||
|
<line>15</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.AggressivelyFixLt">
|
||||||
|
<file name="HTMLPurifier/Lexer/DOMLex.php">
|
||||||
|
<line>44</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.DirectLexLineNumberSyncInterval">
|
||||||
|
<file name="HTMLPurifier/Lexer/DirectLex.php">
|
||||||
|
<line>59</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.EscapeInvalidTags">
|
||||||
|
<file name="HTMLPurifier/Strategy/MakeWellFormed.php">
|
||||||
|
<line>22</line>
|
||||||
|
</file>
|
||||||
|
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
|
||||||
|
<line>19</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.RemoveScriptContents">
|
||||||
|
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
|
||||||
|
<line>22</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="Core.HiddenElements">
|
||||||
|
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
|
||||||
|
<line>23</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
<directive id="URI.HostBlacklist">
|
||||||
|
<file name="HTMLPurifier/URIFilter/HostBlacklist.php">
|
||||||
|
<line>8</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
|
</usage>
|
138
maintenance/config-scanner.php
Normal file
138
maintenance/config-scanner.php
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
chdir(dirname(__FILE__));
|
||||||
|
require_once 'common.php';
|
||||||
|
require_once '../library/HTMLPurifier.auto.php';
|
||||||
|
assertCli();
|
||||||
|
|
||||||
|
if (version_compare(PHP_VERSION, '5.2.2', '<')) {
|
||||||
|
echo "This script requires PHP 5.2.2 or later, for tokenizer line numbers.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Scans HTML Purifier source code for $config tokens and records the
|
||||||
|
* directive being used; configdoc can use this info later.
|
||||||
|
*
|
||||||
|
* Currently, this just dumps all the info onto the console. Eventually, it
|
||||||
|
* will create an XML file that our XSLT transform can use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$FS = new FSTools();
|
||||||
|
chdir(dirname(__FILE__) . '/../library/');
|
||||||
|
$raw_files = $FS->globr('.', '*.php');
|
||||||
|
$files = array();
|
||||||
|
foreach ($raw_files as $file) {
|
||||||
|
$file = substr($file, 2); // rm leading './'
|
||||||
|
if (strncmp('standalone/', $file, 11) === 0) continue; // rm generated files
|
||||||
|
if (substr_count($file, '.') > 1) continue; // rm meta files
|
||||||
|
$files[] = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the $i cursor to the next non-whitespace token
|
||||||
|
*/
|
||||||
|
function consumeWhitespace($tokens, &$i) {
|
||||||
|
do {$i++;} while (is_array($tokens[$i]) && $tokens[$i][0] === T_WHITESPACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether or not a token is a particular type. There are three run-cases:
|
||||||
|
* - ($token, $expect_token): tests if the token is $expect_token type;
|
||||||
|
* - ($token, $expect_value): tests if the token is the string $expect_value;
|
||||||
|
* - ($token, $expect_token, $expect_value): tests if token is $expect_token type, and
|
||||||
|
* its string representation is $expect_value
|
||||||
|
*/
|
||||||
|
function testToken($token, $value_or_token, $value = null) {
|
||||||
|
if (is_null($value)) {
|
||||||
|
if (is_int($value_or_token)) return is_array($token) && $token[0] === $value_or_token;
|
||||||
|
else return $token === $value_or_token;
|
||||||
|
} else {
|
||||||
|
return is_array($token) && $token[0] === $value_or_token && $token[1] === $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$counter = 0;
|
||||||
|
$full_counter = 0;
|
||||||
|
$tracker = array();
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$tokens = token_get_all(file_get_contents($file));
|
||||||
|
$file = str_replace('\\', '/', $file);
|
||||||
|
for ($i = 0, $c = count($tokens); $i < $c; $i++) {
|
||||||
|
if (!testToken($tokens[$i], T_VARIABLE, '$config')) continue;
|
||||||
|
$ok = false;
|
||||||
|
for($i++; $i < $c; $i++) {
|
||||||
|
if ($tokens[$i] === ',' || $tokens[$i] === ')' || $tokens[$i] === ';') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (is_string($tokens[$i])) continue;
|
||||||
|
if ($tokens[$i][0] === T_OBJECT_OPERATOR) {
|
||||||
|
$ok = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$ok) continue;
|
||||||
|
|
||||||
|
$line = $tokens[$i][2];
|
||||||
|
|
||||||
|
consumeWhitespace($tokens, $i);
|
||||||
|
if (!testToken($tokens[$i], T_STRING, 'get')) continue;
|
||||||
|
|
||||||
|
consumeWhitespace($tokens, $i);
|
||||||
|
if (!testToken($tokens[$i], '(')) continue;
|
||||||
|
|
||||||
|
$full_counter++;
|
||||||
|
|
||||||
|
// The T_CONSTANT_ENCAPSED_STRING may hide some more obscure use-cases;
|
||||||
|
// it may be useful to log these.
|
||||||
|
consumeWhitespace($tokens, $i);
|
||||||
|
if (!testToken($tokens[$i], T_CONSTANT_ENCAPSED_STRING)) continue;
|
||||||
|
$namespace = substr($tokens[$i][1], 1, -1);
|
||||||
|
|
||||||
|
consumeWhitespace($tokens, $i);
|
||||||
|
if (!testToken($tokens[$i], ',')) continue;
|
||||||
|
|
||||||
|
consumeWhitespace($tokens, $i);
|
||||||
|
if (!testToken($tokens[$i], T_CONSTANT_ENCAPSED_STRING)) continue;
|
||||||
|
$directive = substr($tokens[$i][1], 1, -1);
|
||||||
|
|
||||||
|
$counter++;
|
||||||
|
|
||||||
|
$id = "$namespace.$directive";
|
||||||
|
if (!isset($tracker[$id])) $tracker[$id] = array();
|
||||||
|
if (!isset($tracker[$id][$file])) $tracker[$id][$file] = array();
|
||||||
|
$tracker[$id][$file][] = $line;
|
||||||
|
|
||||||
|
// echo "$file:$line uses $namespace.$directive\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n$counter/$full_counter instances of \$config found in source code.\n";
|
||||||
|
|
||||||
|
echo "Generating XML... ";
|
||||||
|
|
||||||
|
$xw = new XMLWriter();
|
||||||
|
$xw->openURI('../configdoc/usage.xml');
|
||||||
|
$xw->setIndent(true);
|
||||||
|
$xw->startDocument('1.0', 'UTF-8');
|
||||||
|
$xw->startElement('usage');
|
||||||
|
foreach ($tracker as $id => $files) {
|
||||||
|
$xw->startElement('directive');
|
||||||
|
$xw->writeAttribute('id', $id);
|
||||||
|
foreach ($files as $file => $lines) {
|
||||||
|
$xw->startElement('file');
|
||||||
|
$xw->writeAttribute('name', $file);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$xw->writeElement('line', $line);
|
||||||
|
}
|
||||||
|
$xw->endElement();
|
||||||
|
}
|
||||||
|
$xw->endElement();
|
||||||
|
}
|
||||||
|
$xw->endElement();
|
||||||
|
$xw->flush();
|
||||||
|
|
||||||
|
echo "done!\n";
|
@ -25,3 +25,4 @@ e($php . ' generate-includes.php');
|
|||||||
e($php . ' generate-schema-cache.php');
|
e($php . ' generate-schema-cache.php');
|
||||||
e($php . ' flush-definition-cache.php');
|
e($php . ' flush-definition-cache.php');
|
||||||
e($php . ' generate-standalone.php');
|
e($php . ' generate-standalone.php');
|
||||||
|
e($php . ' config-scanner.php');
|
||||||
|
Loading…
Reference in New Issue
Block a user