aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/message_parser.php
diff options
context:
space:
mode:
authorLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2003-05-18 23:29:35 +0000
committerLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2003-05-18 23:29:35 +0000
commit1bb83a6760e5ccc218f8efedf8600375504ae24c (patch)
treeff53ab02eac56b7841d19449c80d46ae9f349e35 /phpBB/includes/message_parser.php
parente2d5fcdda9eb687934412be0361377801fcaaacd (diff)
downloadforums-1bb83a6760e5ccc218f8efedf8600375504ae24c.tar
forums-1bb83a6760e5ccc218f8efedf8600375504ae24c.tar.gz
forums-1bb83a6760e5ccc218f8efedf8600375504ae24c.tar.bz2
forums-1bb83a6760e5ccc218f8efedf8600375504ae24c.tar.xz
forums-1bb83a6760e5ccc218f8efedf8600375504ae24c.zip
Added: [/*] tag (list item end tag). Automagically added if needed, in which case it's stored as [/*:m:$uid]
git-svn-id: file:///svn/phpbb/trunk@4016 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/message_parser.php')
-rw-r--r--phpBB/includes/message_parser.php45
1 files changed, 35 insertions, 10 deletions
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index bac3348b40..86547684a8 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -189,7 +189,7 @@ class parse_message
// TODO: validation regexp
11 => array('#\[flash\](.*?)\[/flash\]#i' => '[flash:' . $this->bbcode_uid . ']\1[/flash:' . $this->bbcode_uid . ']'),
10 => array('#\[email(=.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\\1', '\\2')"),
- 9 => array('#\[list(=[a-z|0-1]+)?\].*\[/list\]#ise' => "\$this->bbcode_list('\\0')"),
+ 9 => array('#\[list(=[a-z|0-9|(?:disc|circle|square))]+)?\].*\[/list\]#ise' => "\$this->bbcode_list('\\0')"),
7 => array('#\[u\](.*?)\[/u\]#is' => '[u:' . $this->bbcode_uid . ']\1[/u:' . $this->bbcode_uid . ']'),
6 => array('!\[color=(#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]!is'
=> '[color=\1:' . $this->bbcode_uid . ']\2[/color:' . $this->bbcode_uid . ']'),
@@ -334,7 +334,7 @@ echo "<pre><hr>processing <b>$username</b><hr></pre>";
$out = '[';
$in = substr(stripslashes($in), 1);
- $close_tags = array();
+ $list_end_tags = $item_end_tags = array();
do
{
@@ -356,26 +356,47 @@ echo "<pre><hr>processing <b>$username</b><hr></pre>";
{
// if $tok is ']' the buffer holds a tag
- if ($buffer == '/list' && count($close_tags))
+ if ($buffer == '/list' && count($list_end_tags))
{
// valid [/list] tag
- $tag = array_pop($close_tags);
- $out .= $tag . ']';
+ if (count($item_end_tags))
+ {
+ // current li tag has not been closed
+ $out .= array_pop($item_end_tags) . '][';
+ }
+
+ $out .= array_pop($list_end_tags) . ']';
$tok = '[';
}
elseif (preg_match('#list(=?(?:[0-9]|[a-z]|))#i', $buffer, $m))
{
// sub-list, add a closing tag
- array_push($close_tags, (($m[1]) ? '/list:o:' . $this->bbcode_uid : '/list:u:' . $this->bbcode_uid));
+ array_push($list_end_tags, (($m[1]) ? '/list:o:' . $this->bbcode_uid : '/list:u:' . $this->bbcode_uid));
$out .= $buffer . ':' . $this->bbcode_uid . ']';
$tok = '[';
}
else
{
- if ($buffer == '*' && count($close_tags))
+ if ($buffer == '*' && count($list_end_tags))
{
// the buffer holds a bullet tag and we have a [list] tag open
- $buffer = '*:' . $this->bbcode_uid;
+
+ if (count($item_end_tags) >= count($list_end_tags))
+ {
+ // current li tag has not been closed
+ $buffer = array_pop($item_end_tags) . '][*:' . $this->bbcode_uid;
+ }
+ else
+ {
+ $buffer = '*:' . $this->bbcode_uid;
+ }
+
+ $item_end_tags[] = '/*:m:' . $this->bbcode_uid;
+ }
+ elseif ($buffer == '/*')
+ {
+ array_pop($item_end_tags);
+ $buffer = '/*:' . $this->bbcode_uid;
}
$out .= $buffer . $tok;
@@ -393,9 +414,13 @@ echo "<pre><hr>processing <b>$username</b><hr></pre>";
while ($in);
// do we have some tags open? close them now
- if (count($close_tags))
+ if (count($item_end_tags))
{
- $out .= '[' . implode('][', $close_tags) . ']';
+ $out .= '[' . implode('][', $item_end_tags) . ']';
+ }
+ if (count($list_end_tags))
+ {
+ $out .= '[' . implode('][', $list_end_tags) . ']';
}
return $out;