Index: bbcode-filter.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/bbcode/bbcode-filter.inc,v retrieving revision 1.56 diff -u -p -r1.56 bbcode-filter.inc --- bbcode-filter.inc 29 Apr 2007 07:39:06 -0000 1.56 +++ bbcode-filter.inc 25 May 2007 11:32:00 -0000 @@ -70,6 +70,36 @@ function _bbcode_filter_process(&$body, for ($i = 0; $i < $unclosed; $i++) $body .= '[/list]'; + // begin processing for [size] /* Code by Takafumi (Drupal Japan) */ + if (stristr($body, '[size=') !== FALSE) { // prevent useless processing + $arr = array( + 'tag' => 'size', + 'pattern' => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi', + 'replacement' => '"". stripslashes("$2") .""', + 'text' => $body); + $body = _bbcode_replace_nest_tag($arr); + } // end processing for [size] + + // begin processing for [color] /* Code by Takafumi (Drupal Japan) */ + if (stristr($body, '[color=') !== FALSE) { // prevent useless processing + $arr = array( + 'tag' => 'color', + 'pattern' => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si', + 'replacement' => '$2', + 'text' => $body); + $body = _bbcode_replace_nest_tag($arr); + } // end processing for [color] + + // begin processing for [font] /* Code by Takafumi (Drupal Japan) */ + if (stristr($body, '[font=') !== FALSE) { // prevent useless processing + $arr = array( + 'tag' => 'font', + 'pattern' => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si', + 'replacement' => '$2', + 'text' => $body); + $body = _bbcode_replace_nest_tag($arr); + } // end processing for [font] + // Define BBCode tags $preg = array( // Implement [notag] @@ -81,9 +111,6 @@ function _bbcode_filter_process(&$body, '#\[index style=(ol|ul)\]#sie' => '_bbcode_generate_index($body, \'\\1\')', // Font, text and alignment - '#\[color=([\#\w]+)(?::\w+)?\](.*?)\[/color(?::\w+)?\]#si' => '\\2', - '#\[size=(\d+)(?::\w+)?\](.*?)\[/size(?::\w+)?\]#sie' => '_bbcode_size_tag(\\1, \'\\2\')', - '#\[font=([\w\s]+)(?::\w+)?\](.*?)\[/font(?::\w+)?\]#si' => '\\2', '#\[align=(\w+)(?::\w+)?\](.*?)\[/align(?::\w+)?\]#si' => '\\2', '#\[float=(left|right)(?::\w+)?\](.*?)\[/float(?::\w+)?\]#si' => '\\2', '#\[justify(?::\w+)?\](.*?)\[/justify(?::\w+)?\]#si' => '
'. highlight_string( str_replace('
', '', stripslashes($text)), true) .'';
}
+
+// /* Code by Takafumi (Drupal Japan) */
+function _bbcode_round_size_val($size) {
+ if ($size < 6)
+ return 6;
+ elseif ($size > 48)
+ return 48;
+ else
+ return $size;
+}
+
+// /* Code by Takafumi (Drupal Japan) */
+function _bbcode_replace_nest_tag($arr = NULL) {
+ $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
+ // It will be better to use &count and do-while, if php 5 or higher.
+ while (preg_match($arr['pattern'], $text)) {
+ $text = preg_replace($arr['pattern'], $arr['replacement'], $text);
+ }
+ return $text;
+}