/** * Executes statements before the actual array building starts * * This method should be overwritten in a filter if you want to do * something before the parsing process starts. This can be useful to * allow certain short alternative tags which then can be converted into * proper tags with preg_replace() calls. * The main class walks through all the filters and and calls this * method if it exists. The filters should modify their private $_text * variable. * * @return none * @access private * @see $_text * @author Stijn de Reede <*****@*****.**> */ function _preparse() { $options = HTML_BBCodeParser_Filter::_getOptions(); $o = $options['open']; $c = $options['close']; $oe = $options['open_esc']; $ce = $options['close_esc']; $pattern = array("!(^|\\s)([-a-z0-9_.]+@[-a-z0-9.]+\\.[a-z]{2,4})!i", "!" . $oe . "email(" . $ce . "|\\s.*" . $ce . ")(.*)" . $oe . "/email" . $ce . "!Ui"); $replace = array("\\1" . $o . "email=\\2" . $c . "\\2" . $o . "/email" . $c, $o . "email=\\2\\1\\2" . $o . "/email" . $c); $this->_preparsed = preg_replace($pattern, $replace, $this->_text); }
/** * Executes statements before the actual array building starts * * This method should be overwritten in a filter if you want to do * something before the parsing process starts. This can be useful to * allow certain short alternative tags which then can be converted into * proper tags with preg_replace() calls. * The main class walks through all the filters and and calls this * method if it exists. The filters should modify their private $_text * variable. * * @return none * @access private * @see $_text * @author Stijn de Reede <*****@*****.**>, Seth Price <*****@*****.**> */ function _preparse() { $options = HTML_BBCodeParser_Filter::_getOptions(); $o = $options['open']; $c = $options['close']; $oe = $options['open_esc']; $ce = $options['close_esc']; $pattern = array("!" . $oe . "\\*" . $ce . "!", "!" . $oe . "(u?)list=(?-i:A)(\\s*[^" . $ce . "]*)" . $ce . "!i", "!" . $oe . "(u?)list=(?-i:a)(\\s*[^" . $ce . "]*)" . $ce . "!i", "!" . $oe . "(u?)list=(?-i:I)(\\s*[^" . $ce . "]*)" . $ce . "!i", "!" . $oe . "(u?)list=(?-i:i)(\\s*[^" . $ce . "]*)" . $ce . "!i", "!" . $oe . "(u?)list=(?-i:1)(\\s*[^" . $ce . "]*)" . $ce . "!i", "!" . $oe . "(u?)list([^" . $ce . "]*)" . $ce . "!i"); $replace = array($o . "li" . $c, $o . "\$1list=upper-alpha\$2" . $c, $o . "\$1list=lower-alpha\$2" . $c, $o . "\$1list=upper-roman\$2" . $c, $o . "\$1list=lower-roman\$2" . $c, $o . "\$1list=decimal\$2" . $c, $o . "\$1list\$2" . $c); $this->_preparsed = preg_replace($pattern, $replace, $this->_text); }
/** * Finish preparsing URL to clean it up * * @return string * @access private * @author Seth Price <*****@*****.**> */ function smarterPPLink($matches) { $options = HTML_BBCodeParser_Filter::_getOptions(); $o = $options['open']; $c = $options['close']; $urlServ = $matches[1]; $path = $matches[5]; $off = strpos($urlServ, ':'); if ($off === false) { //Default to http $urlServ = $this->_defaultScheme . '://' . $urlServ; $off = strpos($urlServ, ':'); } //Add trailing slash if missing (to create a valid URL) if (!$path) { $path = '/'; } $protocol = substr($urlServ, 0, $off); if (in_array($protocol, $this->_allowedSchemes)) { //If protocol is in the approved list than allow it return $o . 'url=' . $urlServ . $path . $c . $matches[6] . $o . '/url' . $c; } //Else remove url tag return $matches[6]; }