ultimix
settings_1_0_0 Class Reference

Public Member Functions

 __construct ()
 load_settings ($Settings, $Separator= ';')
 delete_setting ($Name)
 append_settings ($Settings, $Separator= ';')
 load_from_http ()
 get_raw_settings ()
 add_settings_from_object (&$Settings)
 load_raw_settings (&$Settings)
 append_raw_settings (&$Settings)
 get_all_settings ()
 load_file ($FilePath, $Separator= ';')
 append_file ($FilePath, $Separator= ';')
 load_package_settings ($PackageName, $PackageVersion, $FileName)
 define ($Name, $DefaultValue= '_throw_exception')
 setting_exists ($Name, $ThrowException=false)
 get_setting ($Name, $DefaultValue= '_throw_exception')
 get_default_values ($SettingsNames, $DefaultValues)
 get_settings ($SettingsNames, $DefaultValues= '_throw_exception')
 set_setting ($Name, $Value)
 set_undefined ($Name, $Value)
 clear ()
 remove_setting ($Name)
 __toString ()

Data Fields

 $SettingsList = false
 $CachedMultyFS = false
 $SettingsUtilities = false

Detailed Description

Working with settings.

Author
Dodonov A.A.

Definition at line 26 of file settings.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 67 of file settings.php.

{
try
{
$this->SettingsUtilities = get_package( 'settings::settings_utilities' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

__toString ( )

Function converts object to string.

Returns
string with the object's description.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 909 of file settings.php.

{
try
{
return( serialize( $this->SettingsList ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
add_settings_from_object ( $Settings)

Function stores settings.

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

Definition at line 277 of file settings.php.

{
try
{
$this->SettingsList = array_merge( $this->SettingsList , $Settings->SettingsList );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
append_file (   $FilePath,
  $Separator = ';' 
)

Function loads settings from file.

Parameters
$FilePath- File path.
$Separator- Separator for keys.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 479 of file settings.php.

{
try
{
$this->append_settings( $this->get_config( $FilePath ) , $Separator );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
append_raw_settings ( $Settings)

Function stores settings.

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

Definition at line 337 of file settings.php.

{
try
{
$this->SettingsList = array_merge( $this->SettingsList , $Settings );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
append_settings (   $Settings,
  $Separator = ';' 
)

Function loads additional settings.

Parameters
$Settings- Data with settings.
$Separator- Separator for keys.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 179 of file settings.php.

{
try
{
if( $Settings === false || $Settings === '' || $Settings === null )
{
return;
}
if( is_array( $Settings ) === false )
{
$Settings = $this->SettingsUtilities->transform_settings( $Settings , $Separator );
}
$this->SettingsList = array_merge(
$this->SettingsList , $this->SettingsUtilities->load_settings( $Settings )
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
clear ( )

Function clears setings.

Returns
string with the object's description.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 849 of file settings.php.

{
try
{
$this->SettingsList = array();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
define (   $Name,
  $DefaultValue = '_throw_exception' 
)

Creating dfine by setting.

Parameters
$Name- Setting title.
$DefaultValue- Default value for undefined setting.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 553 of file settings.php.

{
try
{
DEFINE( $Name , $this->get_setting( $Name , $DefaultValue ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete_setting (   $Name)

Function deletes setting.

Parameters
$Name- Setting's title.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 132 of file settings.php.

{
try
{
if( isset( $this->SettingsList[ $Name ] ) === false )
{
return;
}
$New = array();
foreach( $this->SettingsList as $Key => $Value )
{
if( $Key !== $Name )
{
$New[ $Key ] = $Value;
}
}
$this->SettingsList = $New;
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_all_settings ( )

Function returns compiled settings.

Returns
Settings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 367 of file settings.php.

{
try
{
$Str = array();
foreach( $this->SettingsList as $Key => $Value )
{
$Str [] = "$Key=$Value";
}
$Str = implode( ';' , $Str );
return( $Str );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_default_values (   $SettingsNames,
  $DefaultValues 
)

Function provides access to the default values.

Parameters
$SettingsNames- Settings titles.
$DefaultValues- Default values for undefined setting.
Returns
Settings'es default values.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 686 of file settings.php.

{
try
{
$DefaultValues = explode( ',' , $DefaultValues );
$c1 = count( $DefaultValues );
$c2 = count( $SettingsNames );
if( $c1 < $c2 )
{
for( $i = 0 ; $i < $c2 - $c1 ; $i++ )
{
$DefaultValues [] = '_throw_exception';
}
}
return( $DefaultValues );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_raw_settings ( )

Function returns array with settings.

Returns
Array with settings.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 247 of file settings.php.

{
try
{
return( $this->SettingsList );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_setting (   $Name,
  $DefaultValue = '_throw_exception' 
)

Function provides access to the loaded settings.

Parameters
$Name- Setting title.
$DefaultValue- Default value for undefined setting.
Returns
Setting's value.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 639 of file settings.php.

{
try
{
if( $this->SettingsList !== false && isset( $this->SettingsList[ $Name ] ) )
{
return( $this->SettingsList[ $Name ] );
}
if( $DefaultValue === '_throw_exception' )
{
throw( new Exception( 'Setting "'.$Name.'" was not found' ) );
}
return( $DefaultValue );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_settings (   $SettingsNames,
  $DefaultValues = '_throw_exception' 
)

Function provides access to the loaded settings.

Parameters
$SettingsNames- Settings titles.
$DefaultValues- Default values for undefined setting.
Returns
Settings'es values.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 737 of file settings.php.

{
try
{
$Values = array();
$SettingsNames = explode( ',' , $SettingsNames );
$DefaultValues = $this->get_default_values( $SettingsNames , $DefaultValues );
foreach( $SettingsNames as $i => $Name )
{
$Values [] = $this->get_setting( $Name , $DefaultValues[ $i ] );
}
return( $Values );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
load_file (   $FilePath,
  $Separator = ';' 
)

Function loads settings from file.

Parameters
$FilePath- File path.
$Separator- Separator for keys.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 445 of file settings.php.

{
try
{
$this->load_settings( $this->get_config( $FilePath ) , $Separator );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
load_from_http ( )

Function loads settings from $_GET and $_POST.

Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 217 of file settings.php.

{
try
{
$this->SettingsList = array_merge( $_POST , $_GET );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
load_package_settings (   $PackageName,
  $PackageVersion,
  $FileName 
)

Function loads settings for package.

Parameters
$PackageName- Package's name.
$PackageVersion- Package's version.
$FileName- File's name from directory 'conf' for the specified package.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 517 of file settings.php.

{
try
{
$PackageDirectory = _get_package_path_ex( $PackageName , $PackageVersion );
$this->load_file( $PackageDirectory."/conf/$FileName" );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
load_raw_settings ( $Settings)

Function stores settings.

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

Definition at line 307 of file settings.php.

{
try
{
$this->SettingsList = $Settings;
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
load_settings (   $Settings,
  $Separator = ';' 
)

Function loads settings.

Parameters
$Settings- Data with settings.
$Separator- Separator for keys.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 101 of file settings.php.

{
try
{
$this->SettingsList = array();
$this->append_settings( $Settings , $Separator );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
remove_setting (   $Name)

Function removes setting.

Parameters
$Name- Setting title.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 879 of file settings.php.

{
try
{
remove_fields( $this->SettingsList , array( $Name ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_setting (   $Name,
  $Value 
)

Function provides setting values for settings.

Parameters
$Name- Setting title.
$Value- Default value for setting.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 781 of file settings.php.

{
try
{
if( $this->SettingsList !== false )
{
$this->SettingsList[ $Name ] = $Value;
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_undefined (   $Name,
  $Value 
)

Function provides setting of the undefined settings.

Parameters
$Name- Setting title.
$Value- Default value for setting.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 818 of file settings.php.

{
try
{
if( $this->SettingsList !== false && isset( $this->SettingsList[ $Name ] ) === false )
{
$this->SettingsList[ $Name ] = $Value;
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
setting_exists (   $Name,
  $ThrowException = false 
)

Function provides access to the loaded settings.

Parameters
$Name- Setting title.
$ThrowException- Throw exception.
Returns
true if the setting exists, false otherwise
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 591 of file settings.php.

{
try
{
if( $this->SettingsList !== false && isset( $this->SettingsList[ $Name ] ) )
{
return( true );
}
if( $ThrowException )
{
throw( new Exception( "Setting \"$Name\" does not exist" ) );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$CachedMultyFS = false

Cached objects.

Author
Dodonov A.A.

Definition at line 50 of file settings.php.

$SettingsList = false

Array with settings.

Author
Dodonov A.A.

Definition at line 38 of file settings.php.

$SettingsUtilities = false

Definition at line 51 of file settings.php.


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