ultimix
form_buttons.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 $Settings = false;
39  var $String = false;
40 
51  var $Version = 1;
52 
67  function __construct()
68  {
69  try
70  {
71  $this->Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
72  $this->String = get_package( 'string' , 'last' , __FILE__ );
73  }
74  catch( Exception $e )
75  {
76  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
77  }
78  }
79 
106  function compile_create( &$Options , $Str )
107  {
108  try
109  {
110  if( strpos( $Str , '{create}' ) !== false )
111  {
112  $Str = str_replace( '{create}' , '{create:text=create}' ,$Str );
113  }
114 
115  for( ; $Parameters = $this->String->get_macro_parameters( $Str , 'create' ) ; )
116  {
117  $this->Settings->load_settings( $Parameters );
118  $Text = $this->Settings->get_setting( 'text' , 'create' );
119 
120  $Code = "{href:tpl=submit0;form_id={prefix}_create_form;text=$Text}";
121  $Str = str_replace( "{create:$Parameters}" , $Code , $Str );
122  }
123 
124  return( $Str );
125  }
126  catch( Exception $e )
127  {
128  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
129  }
130  }
131 
158  function compile_save( &$Options , $Str )
159  {
160  try
161  {
162  if( strpos( $Str , '{save}' ) !== false )
163  {
164  $Str = str_replace( '{save}' , '{href:tpl=submit0;form_id={prefix}_update_form;text=save}' ,$Str );
165  }
166 
167  return( $Str );
168  }
169  catch( Exception $e )
170  {
171  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
172  }
173  }
174 
201  function compile_copy( &$Options , $Str )
202  {
203  try
204  {
205  if( strpos( $Str , '{copy}' ) !== false )
206  {
207  $Str = str_replace( '{copy}' , '{href:tpl=submit0;form_id={prefix}_copy_form;text=save}' ,$Str );
208  }
209 
210  return( $Str );
211  }
212  catch( Exception $e )
213  {
214  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
215  }
216  }
217 
244  private function get_cancel_page( &$Options , &$Settings )
245  {
246  try
247  {
248  $Page = $Settings->get_setting( 'page' , $_SERVER[ 'REQUEST_URI' ] );
249 
250  $Page = $Options->get_setting( 'cancel_page' , $Page );
251 
252  $Page = str_replace( array( '=' , ';' ) , array( '[eq]' , '[dot_comma]' ) , $Page );
253 
254  return( $Page );
255  }
256  catch( Exception $e )
257  {
258  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
259  }
260  }
261 
288  function compile_cancel( &$Options , $Str )
289  {
290  try
291  {
292  if( strpos( $Str , '{cancel}' ) !== false )
293  {
294  $Str = str_replace( '{cancel}' , '{cancel:p=1}' , $Str );
295  }
296 
297  for( ; $Parameters = $this->String->get_macro_parameters( $Str , 'cancel' ) ; )
298  {
299  $this->Settings->load_settings( $Parameters );
300 
301  $Page = $this->get_cancel_page( $Options , $this->Settings );
302 
303  $Str = str_replace( "{cancel:$Parameters}" , "{href:tpl=std;page=$Page;text=cancel}" , $Str );
304  }
305 
306  return( $Str );
307  }
308  catch( Exception $e )
309  {
310  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
311  }
312  }
313 
344  function compile_buttons( &$Settings , &$Options , $Str )
345  {
346  try
347  {
348  $Str = $this->compile_create( $Options , $Str );
349 
350  $Str = $this->compile_save( $Options , $Str );
351 
352  $Str = $this->compile_copy( $Options , $Str );
353 
354  $Str = $this->compile_cancel( $Options , $Str );
355 
356  $Str = str_replace( '{prefix}' , $Settings->get_setting( 'prefix' , '' ) , $Str );
357 
358  return( $Str );
359  }
360  catch( Exception $e )
361  {
362  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
363  }
364  }
365  }
366 ?>