I'm trying to add extra tags to the PEAR package BBCodeParser http://pear.php.net/package/HTML_BBCodeParser/docs/latest/li_HTML_BBCodeParser.html, to do this, I believe I need to place Object.php in \php5.3.0\PEAR\pear\HTML\BBCodeParser\Filter and call addFilter.
Object.php
<?php
/*
New filter
@todo Lots
*/
require_once 'HTML/BBCodeParser/Filter.php';
class HTML_BB_CodeParser_Filter_Object extends HTML_BBCodeParser_Filter {
var $_definedTags = array( 'object' => array ( 'htmlopen' => 'object',
'htmlclose' => 'object',
'allowed' => 'all',
'attributes' => array()
)
)
}
?>
extbbcode.php
<?php
/*
The test display page
*/
error_reporting(E_STRICT);
require_once('HTML/BBCodeParser.php');
$parser = new HTML_BBCodeParser();
$parser->addFilter('object');
$parser->setText('[b]bold[/b] [object]test[/object]');
$parser->parse();
$parsed = $parser->getParsed();
echo htmlentities($parsed, ENT_QUOTES). ' | ';
echo $parsed;
?>
When I view extbbcode.php I just get this error
Strict Standards: Non-static method PEAR::getStaticProperty() should not be called statically, assuming $this from incompatible context in D:\wamp\bin\php\php5.3.0\PEAR\pear\HTML\BBCodeParser.php on line 169
If I comment out the $parser->addFilter('object'); line then it works as expected, ie, produces valid output. I can also specify an existing filter, ie
$parser->addFilter('basic');
$parser->addFilter('images');
If I call addFilter with an invalid filter (ie, the file doesn't exist) I get the "Failed to load filter $filter" message.
Can someone spot what I'm doing wrong? It seems to me that Object.php is included, but produces those weird STRICT messages. So my problem is definitely with that file.
If anyone has experience with this class or that error message and can point me in the right direction, I'd be very happy :)
function addFilter($filter)
{
$filter = ucfirst($filter);
if (!array_key_exists($filter, $this->_filters)) {
$class = 'HTML_BBCodeParser_Filter_'.$filter;
@include_once 'HTML/BBCodeParser/Filter/'.$filter.'.php';
if (!class_exists($class)) {
PEAR::raiseError("Failed to load filter $filter", null, PEAR_ERROR_DIE);
}
$this->_filters[$filter] = new $class;
$this->_definedTags = array_merge(
$this->_definedTags,
$this->_filters[$filter]->_definedTags
);
}
}
edit: managed to get PEAR working on my local WAMP, so I can simplify the question by ruling out another problem I was having.