ultimix
messages.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  var $ErrorMessages = array();
39 
50  var $SuccessMessages = array();
51 
62  var $CachedMultyFS = false;
63  var $Security = false;
64 
79  function __construct()
80  {
81  try
82  {
83  $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
84  $this->Security = get_package( 'security' , 'last' , __FILE__ );
85  }
86  catch( Exception $e )
87  {
88  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
89  }
90  }
91 
110  function add_error_message( $Message )
111  {
112  try
113  {
114  if( array_search( $Message , $this->ErrorMessages ) === false )
115  {
116  $this->ErrorMessages [] = $Message;
117  }
118  }
119  catch( Exception $e )
120  {
121  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
122  }
123  }
124 
144  {
145  try
146  {
147  if( isset( $this->ErrorMessages[ 0 ] ) )
148  {
149  return( $this->ErrorMessages[ count( $this->ErrorMessages ) - 1 ] );
150  }
151  else
152  {
153  return( 'message_was_not_found' );
154  }
155  }
156  catch( Exception $e )
157  {
158  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
159  }
160  }
161 
180  function add_success_message( $Message )
181  {
182  try
183  {
184  if( array_search( $Message , $this->SuccessMessages ) === false )
185  {
186  $this->SuccessMessages [] = $Message;
187  }
188  }
189  catch( Exception $e )
190  {
191  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
192  }
193  }
194 
214  {
215  try
216  {
217  if( isset( $this->SuccessMessages[ 0 ] ) )
218  {
219  return( $this->SuccessMessages[ count( $this->SuccessMessages ) - 1 ] );
220  }
221  else
222  {
223  return( 'message_was_not_found' );
224  }
225  }
226  catch( Exception $e )
227  {
228  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
229  }
230  }
231 
247  {
248  try
249  {
250  if( $this->Security->get_s( 'success_message' , 'set' ) )
251  {
252  $this->add_success_message( $this->Security->get_s( 'success_message' , 'command' ) );
253  $this->Security->unset_s( 'success_message' );
254  }
255 
256  $PageName = $this->Security->get_gp( 'page_name' , 'command' );
257 
258  if( $this->Security->get_s( "$PageName:success_message" , 'set' ) )
259  {
260  $FieldName = "$PageName:success_message";
261  $this->add_success_message( $this->Security->get_s( $FieldName , 'command' ) );
262  $this->Security->unset_s( "$PageName:success_message" );
263  }
264  }
265  catch( Exception $e )
266  {
267  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
268  }
269  }
270 
285  function clear_messages()
286  {
287  try
288  {
289  $this->SuccessMessages = array();
290  $this->ErrorMessages = array();
291  }
292  catch( Exception $e )
293  {
294  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
295  }
296  }
297 
320  function compile_success_message( &$Settings )
321  {
322  try
323  {
324  $Code = '';
325 
326  if( isset( $this->SuccessMessages[ 0 ] ) )
327  {
328  $StartingDiv = $this->CachedMultyFS->get_template( __FILE__ , 'success_start.tpl' );
329  $ClosingDiv = $this->CachedMultyFS->get_template( __FILE__ , 'success_end.tpl' );
330 
331  $Messages = implode( '}'.$ClosingDiv.$StartingDiv.'{lang:' , $this->SuccessMessages );
332 
333  $Code = $StartingDiv."{lang:$Messages}".$ClosingDiv;
334 
335  $this->SuccessMessages = array();
336  }
337 
338  return( $Code );
339  }
340  catch( Exception $e )
341  {
342  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
343  }
344  }
345 
368  function compile_error_message( &$Settings )
369  {
370  try
371  {
372  $Code = '';
373 
374  if( isset( $this->ErrorMessages[ 0 ] ) )
375  {
376  $StartingDiv = $this->CachedMultyFS->get_template( __FILE__ , 'error_start.tpl' );
377  $ClosingDiv = $this->CachedMultyFS->get_template( __FILE__ , 'error_end.tpl' );
378 
379  $Messages = implode( '}'.$ClosingDiv.$StartingDiv.'{lang:' , $this->ErrorMessages );
380 
381  $Code = $StartingDiv."{lang:$Messages}".$ClosingDiv;
382 
383  $this->ErrorMessages = array();
384  }
385 
386  return( $Code );
387  }
388  catch( Exception $e )
389  {
390  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
391  }
392  }
393  }
394 
395 ?>