ultimix
custom_state_startup.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 $Cache = false;
39  var $DefaultControllers = false;
40  var $DefaultViews = false;
41  var $Security = false;
42  var $Utilities = false;
43 
58  function __construct()
59  {
60  try
61  {
62  $this->Cache = get_package( 'cache' , 'last' , __FILE__ );
63  $this->DefaultControllers = get_package( 'gui::context_set::default_controllers' , 'last' , __FILE__ );
64  $this->DefaultViews = get_package( 'gui::context_set::default_views' , 'last' , __FILE__ );
65  $this->Security = get_package( 'security' , 'last' , __FILE__ );
66  $this->Utilities = get_package( 'utilities' , 'last' , __FILE__ );
67  }
68  catch( Exception $e )
69  {
70  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
71  }
72  }
73 
108  private function run_multy_call( &$ContextSet , $Config , &$CustomSettings , &$Options )
109  {
110  try
111  {
112  $ContextSet->Context->load_raw_config( $Config );
113 
114  $this->DefaultControllers->set_constants( $ContextSet , $Options );
115  if( $ContextSet->run_execution( $CustomSettings , $this->DefaultControllers , 1 ) )
116  {
117  $ContextSet->clear();
118  return( true );
119  }
120 
121  return( false );
122  }
123  catch( Exception $e )
124  {
125  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
126  }
127  }
128 
163  private function run_simple_form( &$ContextSet , $Config , &$CustomSettings , &$Options )
164  {
165  try
166  {
167  $FileName = $CustomSettings->get_setting( 'form_template' );
168  if( $this->Cache->data_exists( $FileName ) )
169  {
170  $this->DefaultViews->Provider->Output = $this->Cache->get_data( $FileName );
171  return( true );
172  }
173 
174  $ContextSet->Context->load_raw_config( $Config );
175 
176  $this->DefaultViews->set_constants( $ContextSet , $Options );
177  if( $ContextSet->run_execution( $CustomSettings , $this->DefaultViews , 0 ) )
178  {
179  $this->Cache->add_data( $FileName , $this->DefaultViews->Provider->Output );
180  $ContextSet->clear();
181  return( true );
182  }
183 
184  return( false );
185  }
186  catch( Exception $e )
187  {
188  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
189  }
190  }
191 
222  private function run_list_view( &$ContextSet , $Config , &$CustomSettings )
223  {
224  try
225  {
226  global $SkipCallParamsValidation;
227  if( $SkipCallParamsValidation )
228  {
229  $CustomSettings->remove_setting( 'call_params_filter' );
230  }
231 
232  $ContextSet->Context->load_config_from_object( $CustomSettings );
233 
234  $this->DefaultViews->set_constants( $ContextSet , $Options );
235  if( $ContextSet->Context->execute( $CustomSettings , $this->DefaultViews ) )
236  {
237  $ContextSet->clear();
238  return( true );
239  }
240 
241  return( false );
242  }
243  catch( Exception $e )
244  {
245  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
246  }
247  }
248 
279  private function run_custom_config( &$ContextSet , $Config , &$CustomSettings )
280  {
281  try
282  {
283  $OldProvider = $ContextSet->Provider;
284 
285  if( $CustomSettings->get_setting( 'provider_package_name' , false ) !== false )
286  {
287  $ContextSet->Provider = $this->Utilities->get_package( $CustomSettings , __FILE__ , 'provider_' );
288  }
289 
290  $ContextSet->Context->load_raw_config( $Config );
291 
292  if( $ContextSet->run_execution( $CustomSettings , $ContextSet->Provider ) )
293  {
294  $OldProvider->Output = $ContextSet->Provider->Output;
295  $ContextSet->clear();
296  return( true );
297  }
298 
299  return( false );
300  }
301  catch( Exception $e )
302  {
303  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
304  }
305  }
306 
341  function run_config_processors( &$ContextSet , $Config , &$Settings , &$Options )
342  {
343  try
344  {
345  switch( $Settings->get_setting( 'success_func' , false ) )
346  {
347  case( 'multy_call' ):
348  $Res = $this->run_multy_call( $ContextSet , $Config , $Settings , $Options );
349  break;
350  case( 'simple_form' ):
351  $Res = $this->run_simple_form( $ContextSet , $Config , $Settings , $Options );
352  break;
353  case( 'list_view' ):
354  $Res = $this->run_list_view( $ContextSet , $Config , $Settings );
355  break;
356  default:
357  $Res = $this->run_custom_config( $ContextSet , $Config , $Settings );
358  break;
359  }
360  return( $Res );
361  }
362  catch( Exception $e )
363  {
364  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
365  }
366  }
367  }
368 
369 ?>