101 private function get_main_packages()
105 $this->Messages =
get_package(
'page::messages' ,
'last' , __FILE__ );
106 $this->PageJS =
get_package(
'page::page_js' ,
'last' , __FILE__ );
107 $this->Context =
get_package(
'gui::context' ,
'last' , __FILE__ );
108 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
109 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
110 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
111 $this->Trace =
get_package(
'trace' ,
'last' , __FILE__ );
113 catch( Exception $e )
133 private function get_additional_packages()
137 $this->CustomSettings =
get_package_object(
'settings::settings' ,
'last' , __FILE__ );
138 $this->ContextSetSettings =
get_package_object(
'settings::settings' ,
'last' , __FILE__ );
139 $PackageName =
'gui::context_set::context_set_markup';
140 $this->ContextSetMarkup =
get_package( $PackageName ,
'last' , __FILE__ );
142 catch( Exception $e )
166 $this->CommonStateStartup =
get_package(
'gui::context_set::common_state_startup' ,
'last' , __FILE__ );
167 $this->ContextSetConfigs =
get_package(
'gui::context_set::context_set_configs' ,
'last' , __FILE__ );
168 $this->CustomStateStartup =
get_package(
'gui::context_set::custom_state_startup' ,
'last' , __FILE__ );
169 $this->get_main_packages();
170 $this->get_additional_packages();
172 catch( Exception $e )
201 $this->PageJS->add_javascript(
"{http_host}/$Path/include/js/context_set.js" );
203 catch( Exception $e )
227 $this->Contexts = array();
229 catch( Exception $e )
257 $this->Contexts [] = $ContextPath;
259 catch( Exception $e )
295 $HintedContext = $Options->get_setting(
'context' ,
false );
299 $this->Trace->add_trace_string(
"Hinted context : $ContextFolder/conf/$HintedContext" , COMMON );
300 $this->Contexts [] =
"$ContextFolder/conf/$HintedContext";
304 $this->Trace->add_trace_string(
"Hinted context : all contexts" , COMMON );
307 $this->Contexts [] =
"$ContextFolder/conf/$Context";
311 catch( Exception $e )
349 foreach( $New as $Field => $NewValue )
351 $Field = str_replace( $this->Prefix.
'_' ,
'' , $Field );
353 if( @$Original->$Field == $NewValue )
357 if( @$Original->$Field != $this->Security->get( $NewValue ,
'unsafe_string' ) )
359 @$Update[ $Field ] = $NewValue;
366 catch( Exception $e )
402 if( strpos( $Str ,
'{prefix}' ) !==
false )
404 $Str = str_replace(
'{prefix}' , $this->Prefix ,$Str );
408 return( array( $Str , $Changed ) );
410 catch( Exception $e )
442 $AutoRedirect = intval( $Options->get_setting(
'auto_redirect' , $AutoRedirect ) );
443 $AutoRedirect = $this->Security->get_gp(
'auto_redirect' ,
'integer' , $AutoRedirect );
444 if( $AutoRedirect && $this->Security->get_srv(
'HTTP_REFERER' ,
'set' ) )
446 header( $_SERVER[
'SERVER_PROTOCOL' ].
' 303 See Other' );
447 if( $Options->get_setting(
'redirect_page' ,
false ) )
449 header(
"Location: ".$Options->get_setting(
'redirect_page' ) );
453 header(
"Location: ".$this->Security->get_srv(
'HTTP_REFERER' ,
'raw' ) );
458 catch( Exception $e )
500 if( $this->Context->execute( $Options ,
$Provider ) )
504 $GUI->set_var(
'last_context_set_execution_code' , 0 );
506 'last_context_set_execution_message' , $this->Messages->get_last_success_message()
512 $GUI->set_var(
'last_context_set_execution_code' , 1 );
514 'last_context_set_execution_message' , $this->Messages->get_last_error_message()
519 catch( Exception $e )
551 private function load_custom_settings( $ContextPath , &$Options )
555 $Config = $this->CachedMultyFS->file_get_contents( $ContextPath );
556 $Config = str_replace(
'{prefix}' , $this->Prefix , $Config );
557 $this->CustomSettings->load_settings( $Config );
558 $this->CustomSettings->add_settings_from_object( $Options );
561 catch( Exception $e )
589 $this->Trace->start_group(
"custom_configs_processing" , COMMON );
591 foreach( $this->Contexts as $i => $ContextPath )
593 $this->Trace->add_trace_string(
"Processing context $ContextPath" , COMMON );
595 $Config = $this->load_custom_settings( $ContextPath , $Options );
597 $Result = $this->CustomStateStartup->run_config_processors(
598 $this , $Config , $this->CustomSettings , $Options
606 $this->Trace->end_group();
608 catch( Exception $e )
637 $this->Prefix = str_replace(
641 $this->Prefix = str_replace(
645 catch( Exception $e )
677 private function execute_do( &$Options ,
$Provider , $FilePath )
681 $this->ContextSetConfigs->load_context_set_config( $this->ContextSetSettings , $Options , $FilePath );
682 $this->load_context_set_data( $this->ContextSetSettings );
684 if( $this->CommonStateStartup->run_common_states( $this , $Options ) === false )
689 if( $this->Provider->Output !==
false && $this->Provider->Output !==
'' )
691 $this->Provider->Output = $this->ContextSetMarkup->compile_view(
692 $Options , $this->ContextSetSettings , $this->Provider->Output
696 catch( Exception $e )
732 $this->Trace->start_group(
"ContextSet::execute for class \"".get_class(
$Provider ).
"\"" );
733 $this->Trace->add_trace_string( serialize( $Options->get_raw_settings() ) , COMMON );
735 $Options->set_setting(
'file_path' , $FilePath );
737 $this->Provider->Output =
false;
739 $this->execute_do( $Options ,
$Provider , $FilePath );
741 $this->Trace->end_group();
743 catch( Exception $e )
783 list( $Str , $Changed ) = $this->ContextSetMarkup->compile_options( $Options , $Str , $Changed );
785 $Str = str_replace(
'{prefix}' , $this->Prefix , $Str );
789 catch( Exception $e )
817 return( serialize( $this->Config ) );
819 catch( Exception $e )