ultimix
settings_controller_1_0_0 Class Reference

Public Member Functions

 __construct ()
 get_posted_setting (&$Manifest)
 set_db_setting (&$Manifest)
 set_package_setting (&$Manifest)
 handle_config_line ($ConfigLine)
 save_settings ($Options)
 controller ($Options)

Data Fields

 $CachedMultyFS = false
 $DBSettings = false
 $Security = false
 $Settings = false

Detailed Description

Component's controller.

Author
Dodonov A.A.

Definition at line 26 of file settings_controller.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 53 of file settings_controller.php.

{
try
{
$this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
$this->DBSettings = get_package_object( 'settings::db_settings' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->Settings = get_package_object( 'settings::package_settings' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

controller (   $Options)

Component's controller.

Parameters
$Options- Settings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 301 of file settings_controller.php.

{
try
{
$ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
$ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_save_settings' );
if( $ContextSet->execute( $Options , $this , __FILE__ ) )return;
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_posted_setting ( $Manifest)

Function gets new setting value.

Parameters
$Manifest- Loaded config.
Returns
Setting value.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 90 of file settings_controller.php.

{
try
{
$SettingName = $Manifest->get_setting( 'setting_name' );
switch( $Manifest->get_setting( 'type' , 'input' ) )
{
case( 'input' ):
return( $this->Security->get_gp( $SettingName , 'string' , '' ) );
case( 'checkbox' ):
return( intval( $this->Security->get_gp( $SettingName , 'integer' ) ) );
case( 'textarea' ):
return( $this->Security->get_gp( $SettingName , 'string' , '' ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
handle_config_line (   $ConfigLine)

Function processes config line.

Parameters
$ConfigLine- Config's line.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 214 of file settings_controller.php.

{
try
{
$Manifest = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$Manifest->load_settings( $ConfigLine );
$PackageName = $Manifest->get_setting( 'package_name' , false );
if( $PackageName === false )
{
$this->set_db_setting( $Manifest );
}
else
{
$this->set_package_setting( $Manifest );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
save_settings (   $Options)

Function saves settings.

Parameters
$Options- Settings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 255 of file settings_controller.php.

{
try
{
$FormsName = explode( ',' , $Options->get_setting( 'form_name' ) );
foreach( $FormsName as $i => $FormName )
{
$ConfigPath = _get_package_relative_path_ex( 'settings::settings_view' , 'last' ).
"/conf/cf_$FormName";
if( $this->CachedMultyFS->file_exists( $ConfigPath ) )
{
$Config = $this->CachedMultyFS->file_get_contents( $ConfigPath , 'exploded' );
foreach( $Config as $i => $ConfigLine )
{
$this->handle_config_line( $ConfigLine );
}
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_db_setting ( $Manifest)

Function sets setting value.

Parameters
$Manifest- Loaded config.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 132 of file settings_controller.php.

{
try
{
$SettingName = $Manifest->get_setting( 'setting_name' );
$DefaultValue = $Manifest->get_setting( 'default_value' , '' );
$SettingValue = $this->DBSettings->get_setting( $SettingName , $DefaultValue );
$NewSettingValue = $this->get_posted_setting( $Manifest );
if( $SettingValue != $NewSettingValue )
{
$this->DBSettings->set_setting( $SettingName , $NewSettingValue );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_package_setting ( $Manifest)

Function sets setting value.

Parameters
$Manifest- Loaded config.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 171 of file settings_controller.php.

{
try
{
$Version = $Manifest->get_setting( 'package_version' , 'last' );
list( $Name , $ConfigFileName , $SettingName ) =
$Manifest->get_settings( 'package_name,config_file_name,setting_name' );
$SettingValue = $this->Settings->get_package_setting( $Name , $Version ,
$ConfigFileName , $SettingName , $Manifest->get_setting( 'default_value' , '' ) );
$NewSettingValue = $this->get_posted_setting( $Manifest );
if( $SettingValue != $NewSettingValue )
{
$this->Settings->set_package_setting(
$Name , $Version , $ConfigFileName , $SettingName , $NewSettingValue
);
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$CachedMultyFS = false

Cached packages.

Author
Dodonov A.A.

Definition at line 38 of file settings_controller.php.

$DBSettings = false

Definition at line 39 of file settings_controller.php.

$Security = false

Definition at line 40 of file settings_controller.php.

$Settings = false

Definition at line 41 of file settings_controller.php.


The documentation for this class was generated from the following file: