ultimix
math_markup.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 
27  {
38  function __construct()
39  {
40  try
41  {
42  }
43  catch( Exception $e )
44  {
45  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
46  }
47  }
48 
71  function compile_eq( &$Settings )
72  {
73  try
74  {
75  list( $Val1 , $Val2 ) = $Settings->get_settings( 'value1,value2' );
76 
77  return( $Val1 == $Val2 ? 1 : 0 );
78  }
79  catch( Exception $e )
80  {
81  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
82  }
83  }
84 
107  function compile_neq( &$Settings )
108  {
109  try
110  {
111  list( $Val1 , $Val2 ) = $Settings->get_settings( 'value1,value2' );
112 
113  return( $Val1 != $Val2 ? 1 : 0 );
114  }
115  catch( Exception $e )
116  {
117  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
118  }
119  }
120 
143  function compile_not( &$Settings )
144  {
145  try
146  {
147  $Value = $Settings->get_setting( 'value' );
148 
149  return( !$Value ? 1 : 0 );
150  }
151  catch( Exception $e )
152  {
153  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
154  }
155  }
156 
179  function compile_gt( &$Settings )
180  {
181  try
182  {
183  list( $Val1 , $Val2 ) = $Settings->get_settings( 'value1,value2' );
184 
185  return( $Val1 > $Val2 ? 1 : 0 );
186  }
187  catch( Exception $e )
188  {
189  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
190  }
191  }
192 
215  function compile_lt( &$Settings )
216  {
217  try
218  {
219  list( $Val1 , $Val2 ) = $Settings->get_settings( 'value1,value2' );
220 
221  return( $Val1 < $Val2 ? 1 : 0 );
222  }
223  catch( Exception $e )
224  {
225  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
226  }
227  }
228 
251  function compile_gte( &$Settings )
252  {
253  try
254  {
255  list( $Val1 , $Val2 ) = $Settings->get_settings( 'value1,value2' );
256 
257  return( $Val1 >= $Val2 ? 1 : 0 );
258  }
259  catch( Exception $e )
260  {
261  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
262  }
263  }
264 
287  function compile_lte( &$Settings )
288  {
289  try
290  {
291  list( $Val1 , $Val2 ) = $Settings->get_settings( 'value1,value2' );
292 
293  return( $Val1 <= $Val2 ? 1 : 0 );
294  }
295  catch( Exception $e )
296  {
297  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
298  }
299  }
300 
323  function compile_odd( &$Settings )
324  {
325  try
326  {
327  $Settings->load_settings( $Parameters );
328 
329  return( intval( $Settings->get_setting( 'value' ) ) % 2 == 1 );
330  }
331  catch( Exception $e )
332  {
333  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
334  }
335  }
336 
359  function compile_even( &$Settings )
360  {
361  try
362  {
363  $Settings->load_settings( $Parameters );
364 
365  return( intval( $Settings->get_setting( 'value' ) ) % 2 == 0 );
366  }
367  catch( Exception $e )
368  {
369  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
370  }
371  }
372 
395  function compile_if( &$Settings )
396  {
397  try
398  {
399  $Cond = $Settings->get_setting( 'condition' , false );
400  $Then = $Settings->get_setting( 'then' , '' );
401  $Else = $Settings->get_setting( 'else' , '' );
402 
403  return( $Cond == 0 ? $Else : $Then );
404  }
405  catch( Exception $e )
406  {
407  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
408  }
409  }
410 
433  function compile_map( &$Settings )
434  {
435  try
436  {
437  $Value = $Settings->get_setting( 'value' , false );
438 
439  $First = explode( '|' , $Settings->get_setting( 'first' , '' ) );
440  $Second = explode( '|' , $Settings->get_setting( 'second' , '' ) );
441 
442  $Code = '';
443 
444  foreach( $First as $k => $v )
445  {
446  if( $v == $Value )
447  {
448  $Code = $Second[ $k ];
449  break;
450  }
451  }
452 
453  return( $Code );
454  }
455  catch( Exception $e )
456  {
457  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
458  }
459  }
460  }
461 
462 ?>