|
From: Nathan C. <na...@us...> - 2001-10-24 23:08:04
|
Update of /cvsroot/phpbb/phpBB2/includes
In directory usw-pr-cvs1:/tmp/cvs-serv20231/includes
Modified Files:
bbcode.php
Log Message:
[quote=username] bbcode.
Index: bbcode.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/includes/bbcode.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** bbcode.php 2001/10/19 13:28:35 1.13
--- bbcode.php 2001/10/24 22:52:16 1.14
***************
*** 82,85 ****
--- 82,89 ----
$bbcode_tpl['quote_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_open']);
+ $bbcode_tpl['quote_username_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_open']);
+ $bbcode_tpl['quote_username_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_open']);
+ $bbcode_tpl['quote_username_open'] = str_replace('{USERNAME}', '\\1', $bbcode_tpl['quote_username_open']);
+
$bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']);
***************
*** 163,166 ****
--- 167,172 ----
$text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text);
$text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text);
+
+ $text = preg_replace("/\[quote:$uid=(.*?)\]/si", $bbcode_tpl['quote_username_open'], $text);
// [b] and [/b] for bolding text.
***************
*** 234,237 ****
--- 240,245 ----
// [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
$text = bbencode_first_pass_pda($text, $uid, '[quote]', '[/quote]', '', false, '');
+
+ $text = bbencode_first_pass_pda($text, $uid, '/\[quote=(.*?)\]/is', '[/quote]', '', false, '', "[quote:$uid=\\1]");
// [list] and [list=x] for (un)ordered lists.
***************
*** 299,306 ****
* - every opening tag and closing tag must be of the [...] format.
*/
! function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_new, $mark_lowest_level, $func)
{
$open_tag_count = 0;
- $open_tag_length = array();
if (!$close_tag_new || ($close_tag_new == ''))
--- 307,313 ----
* - every opening tag and closing tag must be of the [...] format.
*/
! function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_new, $mark_lowest_level, $func, $open_regexp_replace = false)
{
$open_tag_count = 0;
if (!$close_tag_new || ($close_tag_new == ''))
***************
*** 324,333 ****
return $text;
}
!
! for ($i = 0; $i < count($open_tag); $i++)
! {
! ++$open_tag_count;
! $open_tag_length[$i] = strlen($open_tag[$i]);
! }
}
else
--- 331,335 ----
return $text;
}
! $open_tag_count = count($open_tag);
}
else
***************
*** 337,344 ****
$open_tag = array();
$open_tag[0] = $open_tag_temp;
- $open_tag_length[0] = strlen($open_tag[0]);
$open_tag_count = 1;
}
!
// Start at the 2nd char of the string, looking for opening tags.
--- 339,363 ----
$open_tag = array();
$open_tag[0] = $open_tag_temp;
$open_tag_count = 1;
}
!
! $open_is_regexp = false;
!
! if ($open_regexp_replace)
! {
! $open_is_regexp = true;
! if (!is_array($open_regexp_replace))
! {
! $open_regexp_temp = $open_regexp_replace;
! $open_regexp_replace = array();
! $open_regexp_replace[0] = $open_regexp_temp;
! }
! }
!
! if ($mark_lowest_level && $open_is_regexp)
! {
! message_die(GENERAL_ERROR, "Unsupported operation for bbcode_first_pass_pda().");
! }
!
// Start at the 2nd char of the string, looking for opening tags.
***************
*** 354,366 ****
// check if it's a starting or ending tag.
$found_start = false;
! $which_start_tag = -1;
for ($i = 0; $i < $open_tag_count; $i++)
{
! $possible_start = substr($text, $curr_pos, $open_tag_length[$i]);
! if (0 == strcasecmp($open_tag[$i], $possible_start))
{
! $found_start = true;
! $which_start_tag = $i;
! break;
}
}
--- 373,406 ----
// check if it's a starting or ending tag.
$found_start = false;
! $which_start_tag = "";
! $start_tag_index = -1;
for ($i = 0; $i < $open_tag_count; $i++)
{
! // Grab everything until the first "]"...
! $possible_start = substr($text, $curr_pos, strpos($text, "]", $curr_pos + 1) - $curr_pos + 1);
!
! // Now compare, either using regexp or not.
! if ($open_is_regexp)
! {
! $match_result = array();
! // PREG regexp comparison.
! if (preg_match($open_tag[$i], $possible_start, $match_result))
! {
! $found_start = true;
! $which_start_tag = $match_result[0];
! $start_tag_index = $i;
! break;
! }
! }
! else
{
! // straightforward string comparison.
! if (0 == strcasecmp($open_tag[$i], $possible_start))
! {
! $found_start = true;
! $which_start_tag = $open_tag[$i];
! $start_tag_index = $i;
! break;
! }
}
}
***************
*** 369,374 ****
{
// We have an opening tag.
! // Push its position and length on to the stack, and then keep going to the right.
! $match = array("pos" => $curr_pos, "tag" => $which_start_tag);
bbcode_array_push($stack, $match);
++$curr_pos;
--- 409,414 ----
{
// We have an opening tag.
! // Push its position, the text we matched, and its index in the open_tag array on to the stack, and then keep going to the right.
! $match = array("pos" => $curr_pos, "tag" => $which_start_tag, "index" => $start_tag_index);
bbcode_array_push($stack, $match);
++$curr_pos;
***************
*** 389,395 ****
$match = bbcode_array_pop($stack);
$start_index = $match['pos'];
! $which_start_tag = $match['tag'];
! $start_length = $open_tag_length[$which_start_tag];
! $start_tag = $open_tag[$which_start_tag];
// everything before the opening tag.
--- 429,440 ----
$match = bbcode_array_pop($stack);
$start_index = $match['pos'];
! $start_tag = $match['tag'];
! $start_length = strlen($start_tag);
! $start_tag_index = $match['index'];
!
! if ($open_is_regexp)
! {
! $start_tag = preg_replace($open_tag[$start_tag_index], $open_regexp_replace[$start_tag_index], $start_tag);
! }
// everything before the opening tag.
***************
*** 416,420 ****
else
{
! $text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$uid]";
$text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$uid]";
}
--- 461,472 ----
else
{
! if ($open_is_regexp)
! {
! $text = $before_start_tag . $start_tag;
! }
! else
! {
! $text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$uid]";
! }
$text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$uid]";
}
|