From 4ae5f981b597fa6f5417f8ac1077f015d8b03bd3 Mon Sep 17 00:00:00 2001 From: Ludovic Arnaud Date: Sun, 18 May 2003 23:26:05 +0000 Subject: [PATCH] Added: [/*] tag (list item end tag). Automagically added if needed, in which case it's stored as [/*:m:$uid] Added: any {L_*} var in bbcode.html is replaced by its matching $lang string git-svn-id: file:///svn/phpbb/trunk@4014 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/bbcode.php | 58 +++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 8de3fac2b3..601150aed8 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -204,7 +204,7 @@ class bbcode case 8: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( - '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise' => "\$this->bbcode_second_pass_code('\\1', '\\2')" + '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise' => "\$this->bbcode_second_pass_code('\\1', '\\2')" ) ); break; @@ -214,7 +214,9 @@ class bbcode '[list:$uid]' => '', '[/list:o:$uid]' => '', - '[*:$uid]' => '
  • ' + '[*:$uid]' => '
  • ', + '[/*:$uid]' => '
  • ', + '[/*:m:$uid]' => '', ), 'preg' => array( '#\[list=(.+?):$uid\]#e' => "\$this->bbcode_ordered_list('\\1')", @@ -279,34 +281,56 @@ class bbcode $this->bbcode_tpl = array(); eval($tpl); - $this->bbcode_tpl['quote_open'] = str_replace('{L_QUOTE}', $user->lang['QUOTE'], $this->bbcode_tpl['quote_open']); - $this->bbcode_tpl['quote_username_open'] = str_replace('{L_QUOTE}', $user->lang['QUOTE'], $this->bbcode_tpl['quote_username_open']); - $this->bbcode_tpl['quote_username_open'] = str_replace('{L_WROTE}', $user->lang['WROTE'], $this->bbcode_tpl['quote_username_open']); + foreach ($this->bbcode_tpl as $key => $val) + { + $this->bbcode_tpl[$key] = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : ucwords(strtolower('\\1'))", $this->bbcode_tpl[$key]); + } + $this->bbcode_tpl['quote_username_open'] = str_replace('{USERNAME}', '\\1', $this->bbcode_tpl['quote_username_open']); - $this->bbcode_tpl['code_open'] = str_replace('{L_CODE}', $user->lang['CODE'], $this->bbcode_tpl['code_open']); - $this->bbcode_tpl['flash'] = str_replace('{URL}', '\1', $this->bbcode_tpl['flash']); + $this->bbcode_tpl['flash'] = str_replace('{URL}', '\\1', $this->bbcode_tpl['flash']); } return $this->bbcode_tpl[$tpl_name]; } - function bbcode_ordered_list($chr) + function bbcode_ordered_list($type) { - if (is_numeric($chr)) - { - $start = $chr; - $chr = '1'; - } - elseif (strtolower($chr) == 'i') + if ($type == 'i') { + $type = 'lower-roman'; $start = 1; } + elseif ($type == 'I') + { + $type = 'upper-roman'; + $start = 1; + } + elseif (preg_match('#^(disc|circle|square)$#i', $type)) + { + $type = strtolower($type); + $start = 1; + } + elseif (preg_match('#^[a-z]$#', $type)) + { + $type = 'lower-alpha'; + $start = ord($type) - 96; + } + elseif (preg_match('#[A-Z]#', $type)) + { + $type = 'upper-alpha'; + $start = ord($type) - 64; + } + elseif (is_numeric($type)) + { + $type = 'arabic-numbers'; + $start = intval($chr); + } else { - $start = ord(strtolower($chr)) - 96; - $chr = 'a'; + $type = 'arabic-numbers'; + $start = 1; } - return '
      '; + return '
        '; } function bbcode_second_pass_code($type, $code)