Вопрос

im trying to integrate htmlpurifier with zend framework 2. according to zf2 user guide (http://framework.zend.com/manual/2.0/en/modules/zend.feed.security.html) i changed a model like this:

at the top i got:

require_once '/Purifier/HTMLPurifier.auto.php';

in a function this:

            ...
            $options = array(
                array(
                        'HTML.Allowed',
                        'p,a[href]'
                ),
            array(
                    'Output.TidyFormat',
                    true
            ),
            array(
                    'HTML.Doctype',
                    'XHTML 1.0 Strict'
            ),
            array(
                    'Cache.DefinitionImpl',
                    null
            )
    );

    $config = HTMLPurifier_Config::createDefault();
    foreach ($options as $option) {
        $config->set($option[0], $option[1]);
    }
    $purifier = new HTMLPurifier($config);

    $text = $purifier->purify($this->getPosttext());
    ...

i copied htmlpurifiers "library" folder to "src/Application/Model/Purifier" the auto file is at: "src/Application/Model/Purifier/HTMLPurifier.auto.php" the model file is in "src/Application/Model"

but still i get this error:

Fatal error: Class 'Application\Model\HTMLPurifier_Config' not found in ...path...\module\Application\src\Application\Model\Post.php on line 76

how can i include htmlpurifier correctly?

Это было полезно?

Решение

There are namespaces in your class, use

\HTMLPurifier_Config::createDefault();
new \HTMLPurifier();

please. and you'd better take a learn about php namepace first.

Другие советы

Use HTMLPurifier as ZF2 filter inside forms.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top