ultimix
tags.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
26  class tags_1_0_0{
27 
50  private function compile_format_tags( $Str )
51  {
52  try
53  {
54  $Str = preg_replace( "/\[b\](.*)\[\/b\]/U" , "<b>\\1</b>" , $Str );
55  $Str = preg_replace( "/\[u\](.*)\[\/u\]/U" , "<u>\\1</u>" , $Str );
56  $Str = preg_replace( "/\[i\](.*)\[\/i\]/U" , "<i>\\1</i>" , $Str );
57  $Str = preg_replace( "/\[s\](.*)\[\/s\]/U" , "<s>\\1</s>" , $Str );
58 
59  return( $Str );
60  }
61  catch( Exception $e )
62  {
63  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
64  }
65  }
66 
89  private function compile_publish_tags( $Str )
90  {
91  try
92  {
93  $Str = preg_replace( "/\[img=(.*)\]/U" , "<img src=\"\\1\">" , $Str );
94  $Str = preg_replace( "/\[code\](.*)\[\/code\]/U" , "<pre>\\1</pre>" , $Str );
95  $Str = preg_replace( "/\[email\](\w*)\[\/email\]/U" , "<"."a href=\"mailto:\\1\">\\1</a>" , $Str );
96  $Str = preg_replace( "/\[url=(.*)\](.*)\[\/url\]/U" , "<"."a href=\"\\1\">\\2</a>" , $Str );
97 
98  return( $Str );
99  }
100  catch( Exception $e )
101  {
102  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
103  }
104  }
105 
128  private function compile_list_tags( $Str )
129  {
130  try
131  {
132  $Str = preg_replace( "/\[list\](.*)\[\/list\]/U" , "<ul>\\1</ul>" , $Str );
133  $Str = preg_replace(
134  "/\[list=1\](.*)\[\/list\]/U" , "<ol style=\"list-style-type: decimal;\">\\1</ol>" , $Str
135  );
136  $Str = preg_replace(
137  "/\[list=a\](.*)\[\/list\]/U" , "<ol style=\"list-style-type: lower-alpha;\">\\1</ol>" , $Str
138  );
139  $Str = preg_replace( "/\[\*\]/U" , "<li>" , $Str );
140 
141  return( $Str );
142  }
143  catch( Exception $e )
144  {
145  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
146  }
147  }
148 
171  private function compile_content_tags( $Str )
172  {
173  try
174  {
175  $Str = preg_replace(
176  "/\[spoiler\](.*)\[\/spoiler\]/U" ,
177  "<span id=\"spoiler\"><span id=\"spoiler_header\">{lang:hidden_text}</span>\\2</span>" , $Str
178  );
179  $Str = preg_replace(
180  "/\[spoiler=(.*)\](.*)\[\/spoiler\]/U" ,
181  "<span id=\"spoiler\"><span id=\"spoiler_header\">\\1</span>\\2</span>" , $Str
182  );
183  $Str = preg_replace( "/\[hr\]/U" , "<hr>" , $Str );
184  $Str = preg_replace( "/\[hr=(\d+)\]/U" , "<hr width=\"\\1%\">" , $Str );
185  $Str = preg_replace( "/\[name=(.+)\]/U" , "<"."a name=\"\\1\">" , $Str );
186 
187  return( $Str );
188  }
189  catch( Exception $e )
190  {
191  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
192  }
193  }
194 
217  private function compile_style_tags( $Str )
218  {
219  try
220  {
221  $Str = preg_replace(
222  "/\[size=(\d*)\](.*)\[\/size\]/U" , "<span style=\"font-size:\\1px;\">\\2</span>" , $Str
223  );
224  $Str = preg_replace(
225  "/\[color=(\d*)\](.*)\[\/color\]/U" , "<span style=\"color:\\1px;\">\\2</span>" , $Str
226  );
227  $Str = preg_replace( "/\[quote\](.*)\[\/qoute\]/U" , "<span class=\"quote\">\\1</span>" , $Str );
228  $Str = preg_replace(
229  "/\[align=(\w*)\](.*)\[\/align\]/U" , "<span style=\"text-align:\\1px;\">\\2</span>" , $Str
230  );
231 
232  return( $Str );
233  }
234  catch( Exception $e )
235  {
236  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
237  }
238  }
239 
262  function compile_phpbb_tags( $Str )
263  {
264  try
265  {
266  $Str = $this->compile_format_tags( $Str );
267 
268  $Str = $this->compile_publish_tags( $Str );
269 
270  $Str = $this->compile_content_tags( $Str );
271 
272  $Str = $this->compile_list_tags( $Str );
273 
274  $Str = $this->compile_style_tags( $Str );
275 
276  return( $Str );
277  }
278  catch( Exception $e )
279  {
280  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
281  }
282  }
283 
306  private function compile_date_tags( $Str )
307  {
308  try
309  {
310  $Placeholders = array(
311  '{sysdate}' , '{D}' , '{l}' , '{F}' , '{m}' , '{M}' , '{n}' , '{Y}' , '{systime}'
312  );
313 
314  $Replacers = array(
315  date( 'Y-m-d' ) , date( 'D' ) , date( 'l' ) , date( 'F' ) , date( 'm' ) ,
316  date( 'M' ) , date( 'n' ) , date( 'Y' ) , date( 'H:i:s' )
317  );
318 
319  return( str_replace( $Placeholders , $Replacers , $Str ) );
320  }
321  catch( Exception $e )
322  {
323  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
324  }
325  }
326 
349  function compile_ultimix_tags( $Str )
350  {
351  try
352  {
353  $Placeholders = array(
354  '{lfb}' , '{rfb}' , '{eq}' , '[dot_comma]' , '[dot_dot]' , '[nbsp]' , '[eq]' , '{http_host}' ,
355  '{server_name}' , '[amp]' , '[r]' , '[n]' , '[sharp]' , '[br]'
356  );
357  $Replacers = array(
358  '{' , '}' , '=' , ';' , ':' , '&nbsp;' , '=' , @HTTP_HOST ,
359  $_SERVER[ 'SERVER_NAME' ] , '&' , "\r" , "\n" , '#' , '<br>'
360  );
361 
362  $Str = str_replace( $Placeholders , $Replacers , $Str );
363 
364  $Str = $this->compile_date_tags( $Str );
365 
366  return( $Str );
367  }
368  catch( Exception $e )
369  {
370  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
371  }
372  }
373  }
374 ?>