php-在Zend_Loader中包含HTMLpurifier
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-在Zend_Loader中包含HTMLpurifier,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1296字,纯文字阅读大概需要2分钟。
内容图文
![php-在Zend_Loader中包含HTMLpurifier](/upload/InfoBanner/zyjiaocheng/687/522518ba136a4051b62944330bd228ae.jpg)
我想将HTMLpurifier与Zend Framework结合使用.我想用Zend_Loader加载Class及其文件.您将如何包含它?您只使用HTMLPurifier.auto.php还是知道一种更好的方法?
解决方法:
我在Zend Framework项目中将HTML Purifier用作过滤器.这是我班的改版:
require_once 'HTMLPurifier.includes.php';
require_once 'HTMLPurifier.autoload.php';
class My_Filter_HtmlPurifier implements Zend_Filter_Interface
{
protected $_htmlPurifier = null;
public function __construct($options = null)
{
// set up configuration
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'My Filter');
$config->set('HTML.DefinitionRev', 1); // increment when configuration changes
// $config->set('Cache.DefinitionImpl', null); // comment out after finalizing the config
// Doctype
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
// configure caching
$cachePath = APPLICATION_PATH . '/../cache/htmlpurifier';
if (!is_dir($cachePath)) {
mkdir($cachePath, 0755, true);
}
$cachePath = realpath($cachePath);
$config->set('Cache.SerializerPath', $cachePath);
if (!is_null($options)) {
//$config = HTMLPurifier_Config::createDefault();
foreach ($options as $option) {
$config->set($option[0], $option[1], $option[2]);
}
}
$this->_htmlPurifier = new HTMLPurifier($config);
}
public function filter($value)
{
return $this->_htmlPurifier->purify($value);
}
}
内容总结
以上是互联网集市为您收集整理的php-在Zend_Loader中包含HTMLpurifier全部内容,希望文章能够帮你解决php-在Zend_Loader中包含HTMLpurifier所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。
来源:【匿名】