Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit ed01ca3

Browse files
author
Florian Krämer
committed
Updating the documentation.
1 parent 72be39c commit ed01ca3

File tree

6 files changed

+93
-124
lines changed

6 files changed

+93
-124
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This is a CakePHP wrapper for the HTML Purifier lib. http://htmlpurifier.org/
99

1010
HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications.
1111

12-
The plugin includes a Helper and Behavior to clean your markup wherever you like, in the view or in Model::beforeSave.
12+
The plugin includes a Helper, Behavior and a Shell to clean your markup wherever you like, in the view or in Model::beforeMarshall().
1313

1414
---
1515

docs/Documentation/Configuration.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Configuration
2+
3+
**Important:** Before you start declaring a configuration you should [lookup how HTML Purifier can be configured](http://htmlpurifier.org/docs).
4+
5+
In `config/bootstrap.php` you can either set the purifier config as an array or pass a native config object.
6+
7+
The array style would look like this:
8+
9+
```php
10+
// Don't forget to add the `use` statement
11+
use Burzum\HtmlPurifier\Lib\Purifier;
12+
13+
Purifier::config('ConfigName', array(
14+
'HTML.AllowedElements' => 'a, em, blockquote, p, strong, pre, code, span,ul,ol,li,img',
15+
'HTML.AllowedAttributes' => 'a.href, a.title, img.src, img.alt'
16+
)
17+
);
18+
```
19+
20+
The plugin will construct a HTML Purifier config from that and instantiate the purifier.
21+
22+
A pure HTML Purifier config might look like this one:
23+
24+
```php
25+
$config = HTMLPurifier_Config::createDefault();
26+
$config->set('HTML.AllowedElements', 'a, em, blockquote, p, strong, pre, code, span,ul,ol,li,img');
27+
$config->set('HTML.AllowedAttributes', 'a.href, a.title, img.src, img.alt');
28+
$config->set('HTML.AllowedAttributes', "*.style");
29+
$config->set('CSS.AllowedProperties', 'text-decoration');
30+
$config->set('HTML.TidyLevel', 'heavy');
31+
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
32+
```
33+
34+
Simply assign it to a config:
35+
36+
```php
37+
Purifier::config('ConfigName', $config);
38+
```
39+
40+
Now that you have a configured instance of HTML Purifier ready you can use it directly and get you an instance of the purifier
41+
42+
```php
43+
Purifier::config('ConfigName');
44+
```
45+
46+
or clean some dirty HTML directly by calling
47+
48+
```php
49+
Purifier::clean($markup, 'ConfigName');
50+
```
51+
52+
## Caching ###
53+
54+
It is recommended to change the path of the purifier libs cache to your `tmp` folder. For example:
55+
56+
```php
57+
Purifier::config('ConfigName', array(
58+
'Cache.SerializerPath' => ROOT . DS . 'tmp' . DS . 'purifier',
59+
)
60+
);
61+
```
62+
63+
See this page as well http://htmlpurifier.org/live/configdoc/plain.html#Cache.

docs/Documentation/If-you-use-APC.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# If you use APC ...
2+
3+
...and get this error message
4+
5+
Fatal error: Cannot override final method HTMLPurifier_VarParser::parse()
6+
7+
you can fix this by adding
8+
9+
```php
10+
Configure::write('HtmlPurifier.standalone', true);
11+
```
12+
13+
to your bootstrap.php *before* you load this plugin.
14+
15+
This line will use a compacted one file version of Html Purifier. This is an official and know issue and workaround, see http://htmlpurifier.org/phorum/read.php?3,4099,6680.

docs/Installation.md renamed to docs/Documentation/Installation.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
Installation
2-
============
1+
# Installation
32

4-
Using Composer
5-
--------------
3+
## Using Composer
64

75
Installing the plugin via [Composer](https://getcomposer.org/) is very simple, just run this in your project folder:
86

docs/Home.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Home
2+
====
3+
4+
The **Html Purifier** plugin
5+
6+
Documentation
7+
-------------
8+
9+
* [Installation](Documentation/Installation.md)
10+
* [Configuration](Documentation/Configuration.md)
11+
* [If you use APC](If-you-use-APC.md)
12+

docs/Usage.md

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)