Mercurial > owls
comparison Includes/Bbcodeparser.inc.php @ 8:2672cd855fa2
added further doxygen-comments
author | Meillo r e t u r n s <meillo@marmaro.de> |
---|---|
date | Wed, 13 Dec 2006 23:08:55 +0100 |
parents | ab74e95a8040 |
children | 144bc36a6c27 |
comparison
equal
deleted
inserted
replaced
7:a3a651f0cac6 | 8:2672cd855fa2 |
---|---|
1 <?php | 1 <?php |
2 | |
3 /** | 2 /** |
4 * | |
5 * BB-Code-Parser | 3 * BB-Code-Parser |
6 * | 4 * |
7 * by Meillo r e t u r n s | 5 * @author Meillo r e t u r n s <meillo@marmaro.de> |
8 * | |
9 */ | 6 */ |
10 | 7 |
11 | 8 |
12 define('SMILIE_DIR', 'Smilies/'); // path to smilies | 9 /// path to smilies |
10 define('SMILIE_DIR', 'Smilies/'); | |
13 | 11 |
14 | 12 |
15 | 13 |
16 | 14 /** |
17 function parse_quote1($textinput,$level = 1) { // ohne Quelle | 15 * parses recursive quotes without a source mentioned |
16 * | |
17 * @param $textinput the bbcode-text | |
18 * @param $level number of levels to go inside | |
19 * @return HTML-text | |
20 */ | |
21 function parse_quote1($textinput,$level = 1) { | |
18 $pattern = '#\[quote\](((?R)|(.*))*)\[/quote\]#isUe'; | 22 $pattern = '#\[quote\](((?R)|(.*))*)\[/quote\]#isUe'; |
19 $replacement = "'<br />[nl]<span class=\"quote0\">Zitat:</span>[nl]<div class=\"quote1\">[nl]'.parse_quote1('$1', | 23 $replacement = "'<br />[nl]<span class=\"quote0\">Zitat:</span>[nl]<div class=\"quote1\">[nl]'.parse_quote1('$1', |
20 ". ($level + 1) ." | 24 ". ($level + 1) ." |
21 ).'[nl]</div>[nl]'"; | 25 ).'[nl]</div>[nl]'"; |
22 return preg_replace($pattern, $replacement, $textinput); | 26 return preg_replace($pattern, $replacement, $textinput); |
23 } | 27 } |
24 function parse_quote2($textinput,$level = 1) { // mit Quelle | 28 |
29 /** | |
30 * parses recursive quotes with a source mentioned | |
31 * | |
32 * @param $textinput the bbcode-text | |
33 * @param $level number of levels to go inside | |
34 * @return HTML-text | |
35 */ | |
36 function parse_quote2($textinput,$level = 1) { | |
25 $pattern = '#\[quote\=(.*)\](((?R)|(.*))*)\[/quote\]#isUe'; | 37 $pattern = '#\[quote\=(.*)\](((?R)|(.*))*)\[/quote\]#isUe'; |
26 $replacement = "'<br />[nl]<span class=\"quote0\">Zitat: ($1)</span>[nl]<div class=\"quote2\">[nl]'.parse_quote2('$2', | 38 $replacement = "'<br />[nl]<span class=\"quote0\">Zitat: ($1)</span>[nl]<div class=\"quote2\">[nl]'.parse_quote2('$2', |
27 ". ($level + 1) ." | 39 ". ($level + 1) ." |
28 ).'[nl]</div>[nl]'"; | 40 ).'[nl]</div>[nl]'"; |
29 return preg_replace($pattern, $replacement, $textinput); | 41 return preg_replace($pattern, $replacement, $textinput); |
30 } | 42 } |
31 | 43 |
44 /** | |
45 * replaces smilies | |
46 * | |
47 * @param $text text with ASCII-smilies | |
48 * @return text with [img]-smilies | |
49 */ | |
32 function smilies($text) { | 50 function smilies($text) { |
33 $smilies = array( ':-)' => 'Smile.gif', | 51 $smilies = array( ':-)' => 'Smile.gif', |
34 ':)' => 'Smile.gif', | 52 ':)' => 'Smile.gif', |
35 ';-)' => 'Wink.gif', | 53 ';-)' => 'Wink.gif', |
36 ';)' => 'Wink.gif', | 54 ';)' => 'Wink.gif', |
55 } | 73 } |
56 return $text; | 74 return $text; |
57 } | 75 } |
58 | 76 |
59 | 77 |
78 /** | |
79 * turns bbcode in HTML | |
80 * | |
81 * @param $text the text with bbcode inside | |
82 * @param $smilies set to 1 causes smilies to be replaced with pics | |
83 * @param $images set to 1 causes images to be displayed ([img]-tag) | |
84 * @return text with HTML-code | |
85 */ | |
60 function bbcode($text, $smilies = 0, $images = 0) { | 86 function bbcode($text, $smilies = 0, $images = 0) { |
61 | 87 |
62 // smilies | 88 // smilies |
63 if ($smilies == 1) { | 89 if ($smilies == 1) { |
64 $text = smilies($text); | 90 $text = smilies($text); |