note 76008 deleted from function.tidy-clean-repair by danbrown
| From: | danbrown@php.net | Date: | Mon, 04 May 2009 12:59:14 +0000 |
| Subject: | note 76008 deleted from function.tidy-clean-repair by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154188@lists.php.net to get a copy of this message | ||
Note Submitter: david dot thalmann at gmail dot com
----
I use the tidy extension in my board, but i wanted to restric some html-tags and attributes for my
users... I found out, that if you use cleanRepair(), the object will be the string... sounds
strange, watch that:
<?php
class myTidy extends tidy {
public function __construct($string, $config = array(), $encoding = "utf8") {
if(!is_array($config) || empty($config)) // default config
$config = array(
"doctype" => "omit",
"logical-emphasis" => true,
"show-body-only" => true,
"char-encoding" => "utf8",
"ident" => true,
"wrap" => 0
);
if(!is_string($encoding)) // default encoding
$encoding = "utf8";
parent::parseString($string, $config, $encoding);
parent::cleanRepair();
return parent; // !!! Return the object !!!
}
}
?>
And now with "myFunctions" (e.g. restrict attributes / tags via regEx):
<?php
class myTidy extends tidy {
public function __construct($string, $config = array(), $encoding = "utf8") {
if(!is_array($config) || empty($config))
$config = array(
"doctype" => "omit",
"logical-emphasis" => true,
"show-body-only" => true,
"char-encoding" => "utf8",
"ident" => true,
"wrap" => 0
);
if(!is_string($encoding))
$encoding = "utf8";
parent::parseString($string, $config, $encoding);
parent::cleanRepair();
$string = myFunctions(parent);
return $string;
}
}
?>