parse($text); return $stripTags ? strip_tags($text) : $text; } class GalleryNoMarkupParser { function parse($text) { return $text; } } class GalleryHtmlMarkupParser { function parse($text) { /* http://bugs.php.net/bug.php?id=22014 - TODO: remove empty check when min php is 4.3.2+ */ return empty($text) ? $text : GalleryUtilities::htmlSafe(html_entity_decode($text)); } } class GalleryBbcodeMarkupParser { var $_bbcode; function GalleryBbcodeMarkupParser() { if (!class_exists('StringParser_BBCode')) { GalleryCoreApi::requireOnce('lib/bbcode/stringparser_bbcode.class.php'); } $this->_bbcode = new StringParser_BBCode(); $this->_bbcode->setGlobalCaseSensitive(false); /* Convert line breaks everywhere */ $this->_bbcode->addParser(array('block', 'inline', 'link', 'listitem', 'list'), array($this, 'convertLineBreaks')); /* * Escape all characters everywhere * We don't need to do this 'cause G2 doesn't allow raw entities into the database * $this->_bbcode->addParser('htmlspecialchars', * array('block', 'inline', 'link', 'listitem')); */ /* Convert line endings */ $this->_bbcode->addParser(array('block', 'inline', 'link', 'listitem'), 'nl2br'); /* Strip last line break in list items */ $this->_bbcode->addParser(array('listitem'), array($this, 'stripLastLineBreak')); /* Strip contents in list elements */ $this->_bbcode->addParser(array('list'), array($this, 'stripContents')); /* [b], [i] */ $this->_bbcode->addCode('b', 'simple_replace', null, array('start_tag' => '', 'end_tag' => ''), 'inline', array('listitem', 'block', 'inline', 'link'), array()); $this->_bbcode->addCode('i', 'simple_replace', null, array('start_tag' => '', 'end_tag' => ''), 'inline', array('listitem', 'block', 'inline', 'link'), array()); /* [url]http://...[/url], [url=http://...]Text[/url] */ $this->_bbcode->addCode('url', 'usecontent?', array($this, 'url'), array('usecontent_param' => 'default'), 'link', array('listitem', 'block', 'inline'), array('link')); /* [color=...]Text[/color] */ $this->_bbcode->addCode('color', 'callback_replace', array($this, 'color'), array('usecontent_param' => 'default'), 'inline', array('listitem', 'block', 'inline', 'link'), array()); /* [img]http://...[/img] */ $this->_bbcode->addCode('img', 'usecontent', array($this, 'image'), array(), 'image', array('listitem', 'block', 'inline', 'link'), array()); /* [list] [*]Element [/list] */ $this->_bbcode->addCode('list', 'simple_replace', null, array('start_tag' => '