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

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Sep 27, 2015
1 parent dccd66e commit 4bd147d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -13,7 +13,7 @@
],
"minimum-stability": "stable",
"require": {
"cakephp/cakephp": "~3.0",
"cakephp/cakephp": "3.*",
"ezyang/htmlpurifier": "*"
},
"autoload": {
Expand Down
5 changes: 4 additions & 1 deletion docs/Usage.md
Expand Up @@ -23,11 +23,14 @@ Configuration

Important: Before you start declaring a configuration you should lookup how HTML Purifier can be configured. http://htmlpurifier.org/docs

In `config/boostrap.php` you can either set the purifier config as an array or pass a native config object.
In `config/bootstrap.php` you can either set the purifier config as an array or pass a native config object.

The array style would look like this:

```php
// Don't forget to add the `use` statement
use Burzum\HtmlPurifier\Lib\Purifier;

Purifier::config('ConfigName', array(
'HTML.AllowedElements' => 'a, em, blockquote, p, strong, pre, code, span,ul,ol,li,img',
'HTML.AllowedAttributes' => 'a.href, a.title, img.src, img.alt'
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Purifier.php
Expand Up @@ -102,7 +102,7 @@ public static function clean($markup, $configName = null)
$_this = Purifier::getInstance();

if (!isset($_this->_configs[$configName])) {
throw new \InvalidArgumentException(sprintf('Invalid configuration %s!', $configName));
throw new \InvalidArgumentException(sprintf('Invalid HtmlPurifier configuration "%s"!', $configName));
}

return $_this->getPurifierInstance($configName)->purify($markup);
Expand Down
19 changes: 10 additions & 9 deletions src/View/Helper/HtmlPurifierHelper.php
Expand Up @@ -18,9 +18,9 @@ class HtmlPurifierHelper extends Helper {
*
* @var array
*/
public $_defaultConfig = [
'config' => ''
];
public $_defaultConfig = [
'config' => 'default'
];

/**
* Clean markup
Expand All @@ -29,10 +29,11 @@ class HtmlPurifierHelper extends Helper {
* @param string $config
* @return string
*/
public function clean($markup, $config = null) {
if (empty($config) && !empty($this->_config['config'])) {
$config = $this->settings['config'];
}
return Purifier::clean($markup, $config);
}
public function clean($markup, $config = null)
{
if (empty($config) && !empty($this->_config['config'])) {
$config = $this->config('config');
}
return Purifier::clean($markup, $config);
}
}

0 comments on commit 4bd147d

Please sign in to comment.