1 | <?php |
||
19 | class bbcodes_parser |
||
20 | { |
||
21 | /** @var user */ |
||
22 | protected $user; |
||
23 | |||
24 | /** |
||
25 | * Constructor |
||
26 | * |
||
27 | * @param user $user User object |
||
28 | * @access public |
||
29 | */ |
||
30 | 11 | public function __construct(user $user) |
|
34 | |||
35 | /** |
||
36 | * Pre-Parser for special custom BBCodes created by ABBC3 |
||
37 | * |
||
38 | * @param string $text The text to parse |
||
39 | * @param string $uid The BBCode UID |
||
40 | * @return string The parsed text |
||
41 | * @access public |
||
42 | */ |
||
43 | 7 | public function pre_parse_bbcodes($text, $uid) |
|
44 | { |
||
45 | // bbvideo BBCodes (convert from older ABBC3 installations) |
||
46 | 7 | $text = preg_replace_callback('#\[(bbvideo)[\s]?([0-9,]+)?:(' . $uid . ')\]([^[]+)\[/\1:\3\]#is', array($this, 'bbvideo_pass'), $text); |
|
47 | |||
48 | 7 | return $text; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Post-Parser for special custom BBCodes created by ABBC3 |
||
53 | * |
||
54 | * @param string $text The text to parse |
||
55 | * @return string The parsed text |
||
56 | * @access public |
||
57 | */ |
||
58 | 4 | public function post_parse_bbcodes($text) |
|
59 | { |
||
60 | // hidden BBCode |
||
61 | 4 | $text = preg_replace_callback('#<!-- ABBC3_BBCODE_HIDDEN -->(.*?)<!-- ABBC3_BBCODE_HIDDEN -->#s', array($this, 'hidden_pass'), $text); |
|
62 | |||
63 | 4 | return $text; |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * Convert BBvideo from older ABBC3 posts to the new format |
||
68 | * |
||
69 | * @param array $matches 1=bbvideo, 2=width,height, 3=uid, 4=url |
||
70 | * @return string BBvideo in the correct BBCode format |
||
71 | * @access protected |
||
72 | */ |
||
73 | 4 | protected function bbvideo_pass($matches) |
|
79 | |||
80 | /** |
||
81 | * Convert Hidden BBCode into its final appearance |
||
82 | * |
||
83 | * @param array $matches |
||
84 | * @return string HTML render of hidden bbcode |
||
85 | * @access protected |
||
86 | */ |
||
87 | 3 | protected function hidden_pass($matches) |
|
112 | } |
||
113 |