Fixed bbcode class conflict with user's existing pear class install.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.1.0@42517 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Jeremy Shipman 2007-09-24 22:39:16 +00:00 committed by Sam Minnee
parent 76ffdd4acb
commit c8ee3933ec
10 changed files with 40 additions and 37 deletions

View File

@ -1,4 +1,4 @@
[HTML_BBCodeParser] [SSHTMLBBCodeParser]
; possible values: single|double ; possible values: single|double
; use single or double quotes for attributes ; use single or double quotes for attributes

View File

@ -4,8 +4,8 @@
require_once('HTML/HTMLBBCodeParser.php'); require_once('HTML/HTMLBBCodeParser.php');
/*Seting up the PEAR bbcode parser*/ /*Seting up the PEAR bbcode parser*/
$config = parse_ini_file('BBCodeParser.ini', true); $config = parse_ini_file('BBCodeParser.ini', true);
$options = &HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser', '_options'); $options = &SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser', '_options');
$options = $config['HTML_BBCodeParser']; $options = $config['SSHTMLBBCodeParser'];
//Debug::show($options); //Debug::show($options);
unset($options); unset($options);
@ -101,7 +101,7 @@ class BBCodeParser extends TextParser {
function parse() { function parse() {
$this->content = str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $this->content); $this->content = str_replace(array('&', '<', '>'), array('&amp;', '&lt;', '&gt;'), $this->content);
$this->content = HTML_BBCodeParser::staticQparse($this->content); $this->content = SSHTMLBBCodeParser::staticQparse($this->content);
$this->content = "<p>".$this->content."</p>"; $this->content = "<p>".$this->content."</p>";
$this->content = str_replace("\n\n", "</p><p>", $this->content); $this->content = str_replace("\n\n", "</p><p>", $this->content);
$this->content = str_replace("\n", "<br />", $this->content); $this->content = str_replace("\n", "<br />", $this->content);

View File

@ -4,7 +4,7 @@ require_once 'HTML/HTMLBBCodeParser.php';
/** /**
* Dummy class that filters need to extend from. * Dummy class that filters need to extend from.
*/ */
class HTML_BBCodeParser_Filter extends HTML_BBCodeParser class SSHTMLBBCodeParser_Filter extends SSHTMLBBCodeParser
{ {
} }
?> ?>

View File

@ -20,7 +20,7 @@
// //
/** /**
* @package HTML_BBCodeParser * @package SSHTMLBBCodeParser
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
*/ */
@ -30,7 +30,7 @@ require_once 'HTML/BBCodeParser/Filter.php';
class HTML_BBCodeParser_Filter_Basic extends HTML_BBCodeParser_Filter class SSHTMLBBCodeParser_Filter_Basic extends SSHTMLBBCodeParser_Filter
{ {
/** /**

View File

@ -20,7 +20,7 @@
// //
/** /**
* @package HTML_BBCodeParser * @package SSHTMLBBCodeParser
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
*/ */
@ -30,7 +30,7 @@ require_once 'HTML/BBCodeParser/Filter.php';
class HTML_BBCodeParser_Filter_EmailLinks extends HTML_BBCodeParser_Filter class SSHTMLBBCodeParser_Filter_EmailLinks extends SSHTMLBBCodeParser_Filter
{ {
/** /**
@ -66,7 +66,7 @@ class HTML_BBCodeParser_Filter_EmailLinks extends HTML_BBCodeParser_Filter
*/ */
function _preparse() function _preparse()
{ {
$options = HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser','_options'); $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
$o = $options['open']; $o = $options['open'];
$c = $options['close']; $c = $options['close'];
$oe = $options['open_esc']; $oe = $options['open_esc'];

View File

@ -20,7 +20,7 @@
// //
/** /**
* @package HTML_BBCodeParser * @package SSHTMLBBCodeParser
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
*/ */
@ -30,7 +30,7 @@ require_once 'HTML/BBCodeParser/Filter.php';
class HTML_BBCodeParser_Filter_Extended extends HTML_BBCodeParser_Filter class SSHTMLBBCodeParser_Filter_Extended extends SSHTMLBBCodeParser_Filter
{ {
/** /**

View File

@ -20,12 +20,12 @@
// //
/** /**
* @package HTML_BBCodeParser * @package SSHTMLBBCodeParser
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
*/ */
require_once 'HTML/BBCodeParser/Filter.php'; require_once 'HTML/BBCodeParser/Filter.php';
class HTML_BBCodeParser_Filter_Images extends HTML_BBCodeParser_Filter class SSHTMLBBCodeParser_Filter_Images extends SSHTMLBBCodeParser_Filter
{ {
/** /**
@ -66,7 +66,7 @@ class HTML_BBCodeParser_Filter_Images extends HTML_BBCodeParser_Filter
*/ */
function _preparse() function _preparse()
{ {
$options = HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser','_options'); $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
$o = $options['open']; $o = $options['open'];
$c = $options['close']; $c = $options['close'];
$oe = $options['open_esc']; $oe = $options['open_esc'];

View File

@ -20,7 +20,7 @@
// //
/** /**
* @package HTML_BBCodeParser * @package SSHTMLBBCodeParser
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
*/ */
require_once 'HTML/BBCodeParser/Filter.php'; require_once 'HTML/BBCodeParser/Filter.php';
@ -28,7 +28,7 @@ require_once 'HTML/BBCodeParser/Filter.php';
/** /**
* *
*/ */
class HTML_BBCodeParser_Filter_Links extends HTML_BBCodeParser_Filter class SSHTMLBBCodeParser_Filter_Links extends SSHTMLBBCodeParser_Filter
{ {
/** /**
* List of allowed schemes * List of allowed schemes
@ -81,7 +81,7 @@ class HTML_BBCodeParser_Filter_Links extends HTML_BBCodeParser_Filter
*/ */
function _preparse() function _preparse()
{ {
$options = HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser', '_options'); $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser', '_options');
$o = $options['open']; $o = $options['open'];
$c = $options['close']; $c = $options['close'];
$oe = $options['open_esc']; $oe = $options['open_esc'];
@ -110,7 +110,7 @@ class HTML_BBCodeParser_Filter_Links extends HTML_BBCodeParser_Filter
function smarterPPLinkExpand($matches) function smarterPPLinkExpand($matches)
{ {
//echo '<hr><pre>';var_dump($matches);echo '</pre><hr>'; //echo '<hr><pre>';var_dump($matches);echo '</pre><hr>';
$options = HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser','_options'); $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
$o = $options['open']; $o = $options['open'];
$c = $options['close']; $c = $options['close'];
@ -171,7 +171,7 @@ class HTML_BBCodeParser_Filter_Links extends HTML_BBCodeParser_Filter
*/ */
function smarterPPLink($matches) function smarterPPLink($matches)
{ {
$options = HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser','_options'); $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
$o = $options['open']; $o = $options['open'];
$c = $options['close']; $c = $options['close'];

View File

@ -21,7 +21,7 @@
/** /**
* @package HTML_BBCodeParser * @package SSHTMLBBCodeParser
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
*/ */
@ -30,7 +30,7 @@ require_once 'HTML/BBCodeParser/Filter.php';
/** /**
* *
*/ */
class HTML_BBCodeParser_Filter_Lists extends HTML_BBCodeParser_Filter class SSHTMLBBCodeParser_Filter_Lists extends SSHTMLBBCodeParser_Filter
{ {
/** /**
@ -78,7 +78,7 @@ class HTML_BBCodeParser_Filter_Lists extends HTML_BBCodeParser_Filter
*/ */
function _preparse() function _preparse()
{ {
$options = HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser','_options'); $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
$o = $options['open']; $o = $options['open'];
$c = $options['close']; $c = $options['close'];
$oe = $options['open_esc']; $oe = $options['open_esc'];

View File

@ -20,7 +20,7 @@
// //
/** /**
* @package HTML_BBCodeParser * @package SSHTMLBBCodeParser
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
* *
* *
@ -34,21 +34,21 @@
* *
* *
* Usage: * Usage:
* $parser = new HTML_BBCodeParser(); * $parser = new SSHTMLBBCodeParser();
* $parser->setText('normal [b]bold[/b] and normal again'); * $parser->setText('normal [b]bold[/b] and normal again');
* $parser->parse(); * $parser->parse();
* echo $parser->getParsed(); * echo $parser->getParsed();
* or: * or:
* $parser = new HTML_BBCodeParser(); * $parser = new SSHTMLBBCodeParser();
* echo $parser->qparse('normal [b]bold[/b] and normal again'); * echo $parser->qparse('normal [b]bold[/b] and normal again');
* or: * or:
* echo HTML_BBCodeParser::staticQparse('normal [b]bold[/b] and normal again'); * echo SSHTMLBBCodeParser::staticQparse('normal [b]bold[/b] and normal again');
* *
* *
* Setting the options from the ini file: * Setting the options from the ini file:
* $config = parse_ini_file('BBCodeParser.ini', true); * $config = parse_ini_file('BBCodeParser.ini', true);
* $options = &PEAR::getStaticProperty('HTML_BBCodeParser', '_options'); * $options = &PEAR::getStaticProperty('SSHTMLBBCodeParser', '_options');
* $options = $config['HTML_BBCodeParser']; * $options = $config['SSHTMLBBCodeParser'];
* unset($options); * unset($options);
* *
* *
@ -81,7 +81,7 @@
class HTML_BBCodeParser class SSHTMLBBCodeParser
{ {
/** /**
* An array of tags parsed by the engine, should be overwritten by filters * An array of tags parsed by the engine, should be overwritten by filters
@ -164,10 +164,10 @@ class HTML_BBCodeParser
* @access public * @access public
* @author Stijn de Reede <sjr@gmx.co.uk> * @author Stijn de Reede <sjr@gmx.co.uk>
*/ */
function HTML_BBCodeParser($options = array()) function SSHTMLBBCodeParser($options = array())
{ {
// set the already set options // set the already set options
$baseoptions = &HTML_BBCodeParser::getStaticProperty('HTML_BBCodeParser', '_options'); $baseoptions = &SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser', '_options');
if (is_array($baseoptions)) { if (is_array($baseoptions)) {
foreach ($baseoptions as $k => $v) { foreach ($baseoptions as $k => $v) {
$this->_options[$k] = $v; $this->_options[$k] = $v;
@ -197,7 +197,7 @@ class HTML_BBCodeParser
unset($baseoptions); unset($baseoptions);
// return if this is a subclass // return if this is a subclass
if (is_subclass_of($this, 'HTML_BBCodeParser_Filter')) { if (is_subclass_of($this, 'SSHTMLBBCodeParser_Filter')) {
return; return;
} }
@ -237,20 +237,23 @@ class HTML_BBCodeParser
*/ */
function addFilter($filter) function addFilter($filter)
{ {
$filter = ucfirst($filter); $filter = ucfirst($filter);
if (!array_key_exists($filter, $this->_filters)) { if (!array_key_exists($filter, $this->_filters)) {
$class = 'HTML_BBCodeParser_Filter_'.$filter; $class = 'SSHTMLBBCodeParser_Filter_'.$filter;
@include_once 'HTML/BBCodeParser/Filter/'.$filter.'.php'; @include_once 'HTML/BBCodeParser/Filter/'.$filter.'.php';
if (!class_exists($class)) { if (!class_exists($class)) {
//PEAR::raiseError("Failed to load filter $filter", null, PEAR_ERROR_DIE); //PEAR::raiseError("Failed to load filter $filter", null, PEAR_ERROR_DIE);
} }
$this->_filters[$filter] = new $class; $this->_filters[$filter] = new $class;
$this->_definedTags = array_merge( $this->_definedTags = array_merge(
$this->_definedTags, $this->_definedTags,
$this->_filters[$filter]->_definedTags $this->_filters[$filter]->_definedTags
); );
} }
} }
/** /**
@ -327,7 +330,7 @@ class HTML_BBCodeParser
$this->_preparsed = $this->_text; $this->_preparsed = $this->_text;
// return if this is a subclass // return if this is a subclass
if (is_subclass_of($this, 'HTML_BBCodeParser')) { if (is_subclass_of($this, 'SSHTMLBBCodeParser')) {
return; return;
} }
@ -887,7 +890,7 @@ class HTML_BBCodeParser
*/ */
function staticQparse($str) function staticQparse($str)
{ {
$p = new HTML_BBCodeParser(); $p = new SSHTMLBBCodeParser();
$str = $p->qparse($str); $str = $p->qparse($str);
unset($p); unset($p);
return $str; return $str;