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

[1.7.0] Change ->Revision member variable to a legit configuration directive. Start writing tutorial for customization.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1171 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-06-20 02:43:43 +00:00
parent ab3ebcba6d
commit da2ea348fd
9 changed files with 446 additions and 19 deletions

View File

@@ -17,6 +17,15 @@ require_once 'HTMLPurifier/AttrDef/CSS/TextDecoration.php';
require_once 'HTMLPurifier/AttrDef/CSS/URI.php';
require_once 'HTMLPurifier/AttrDef/Enum.php';
HTMLPurifier_ConfigSchema::define(
'CSS', 'DefinitionRev', 1, 'int', '
<p>
Revision identifier for your custom definition. See
%HTML.DefinitionRev for details. This directive has been available
since 1.7.0.
</p>
');
/**
* Defines allowed CSS attributes and what their values are.
* @see HTMLPurifier_HTMLDefinition

View File

@@ -43,16 +43,6 @@ class HTMLPurifier_Config
*/
var $version = '1.6.1';
/**
* Integer key users can use to indicate they have manually
* overridden some internal behavior and would like the
* cache to invalidate itself. This is used in conjunction
* with the %NAMESPACE.DefinitionID, the semantic difference is
* that the configuration directive determines "semantic identity",
* while this integer indicates "chronological identity".
*/
var $revision = 1;
/**
* Two-level associative array of configuration directives
*/

View File

@@ -36,7 +36,7 @@ class HTMLPurifier_DefinitionCache
*/
function generateKey($config) {
return $config->version . '-' . // possibly replace with function calls
$config->revision . '-' .
$config->get($this->type, 'DefinitionRev') . '-' .
$config->getBatchSerial($this->type);
}
@@ -50,7 +50,7 @@ class HTMLPurifier_DefinitionCache
list($version, $revision, $hash) = explode('-', $key, 3);
$compare = version_compare($version, $config->version);
if ($compare > 0) return false;
if ($compare == 0 && $revision >= $config->revision) return false;
if ($compare == 0 && $revision >= $config->get($this->type, 'DefinitionRev')) return false;
return true;
}

View File

@@ -37,6 +37,19 @@ $def->addAttribute(\'a\', \'tabindex\', \'Number\');
</p>
');
HTMLPurifier_ConfigSchema::define(
'HTML', 'DefinitionRev', 1, 'int', '
<p>
Revision identifier for your custom definition specified in
%HTML.DefinitionID. This serves the same purpose: uniquely identifying
your custom definition, but this one does so in a chronological
context: revision 3 is more up-to-date then revision 2. Thus, when
this gets incremented, the cache handling is smart enough to clean
up any older revisions of your definition as well as flush the
cache. This directive has been available since 1.7.0.
</p>
');
HTMLPurifier_ConfigSchema::define(
'HTML', 'BlockWrapper', 'p', 'string', '
<p>