Detailed Description

InifileConfiguration reads the application configuraiton from ini files.

Note
This class only supports ini files with sections.
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 29 of file InifileConfiguration.php.

+ Inheritance diagram for InifileConfiguration:

Public Member Functions

 __construct ($configPath)
 
 getConfigPath ()
 
 getConfigurations ()
 
 addConfiguration ($name, $processValues=true)
 
 getSections ()
 
 hasSection ($section)
 
 getSection ($section)
 
 hasValue ($key, $section)
 
 getValue ($key, $section)
 
 getBooleanValue ($key, $section)
 
 getDirectoryValue ($key, $section)
 
 getFileValue ($key, $section)
 
 getKey ($value, $section)
 
 isEditable ($section)
 
 isModified ()
 
 createSection ($section)
 
 removeSection ($section)
 
 renameSection ($oldname, $newname)
 
 setValue ($key, $value, $section, $createSection=true)
 
 removeKey ($key, $section)
 
 renameKey ($oldname, $newname, $section)
 
 writeConfiguration ($name)
 

Protected Member Functions

 processFile ($filename, $configArray=array(), $parsedFiles=array())
 
 _parse_ini_file ($filename)
 
 processValues ()
 
 processValue (&$value)
 
 configMerge ($array1, $array2, $override)
 
 getConfigIncludes ($array)
 
 serialize ()
 
 unserialize ($parsedFiles)
 
 getSerializeFilename ($parsedFiles)
 
 checkFileDate ($fileList, $referenceFile)
 
 clearAllCache ()
 
 buildLookupTable ()
 
 lookup ($section, $key=null)
 

Constructor & Destructor Documentation

__construct (   $configPath)

Constructor.

Parameters
$configPathThe path, either absolute or relative to the executed script

Definition at line 54 of file InifileConfiguration.php.

Member Function Documentation

getConfigPath ( )

Get the filesystem path to the configuration files.

Returns
The path, either absolute or relative to the executed script

Definition at line 66 of file InifileConfiguration.php.

getConfigurations ( )

Configuration interface.

See also
Configuration::getConfigurations()

Implements Configuration.

Definition at line 77 of file InifileConfiguration.php.

addConfiguration (   $name,
  $processValues = true 
)
See also
Configuration::addConfiguration() Name is the ini file to be parsed (relative to configPath)
Note
ini files referenced in section 'config' key 'include' are parsed afterwards

Implements Configuration.

Definition at line 86 of file InifileConfiguration.php.

processFile (   $filename,
  $configArray = array(),
  $parsedFiles = array() 
)
protected

Process the given file recursivly.

Parameters
$filenameThe filename
$configArrayConfiguration array
$parsedFilesParsed files
Returns
Associative array with keys 'config' (configuration array) and 'files' (array of parsed files)

Definition at line 149 of file InifileConfiguration.php.

getSections ( )
See also
Configuration::getSections()

Implements Configuration.

Definition at line 176 of file InifileConfiguration.php.

hasSection (   $section)
See also
Configuration::hasSection()

Implements Configuration.

Definition at line 183 of file InifileConfiguration.php.

getSection (   $section)
See also
Configuration::getSection()

Implements Configuration.

Definition at line 190 of file InifileConfiguration.php.

hasValue (   $key,
  $section 
)
See also
Configuration::hasValue()

Implements Configuration.

Definition at line 203 of file InifileConfiguration.php.

getValue (   $key,
  $section 
)
See also
Configuration::getValue()

Implements Configuration.

Definition at line 210 of file InifileConfiguration.php.

getBooleanValue (   $key,
  $section 
)
See also
Configuration::getBooleanValue()

Implements Configuration.

Definition at line 223 of file InifileConfiguration.php.

getDirectoryValue (   $key,
  $section 
)
See also
Configuration::getDirectoryValue()

Implements Configuration.

Definition at line 231 of file InifileConfiguration.php.

getFileValue (   $key,
  $section 
)
See also
Configuration::getFileValue()

Implements Configuration.

Definition at line 248 of file InifileConfiguration.php.

getKey (   $value,
  $section 
)
See also
Configuration::getKey()

Implements Configuration.

Definition at line 265 of file InifileConfiguration.php.

isEditable (   $section)
isModified ( )
createSection (   $section)
removeSection (   $section)
renameSection (   $oldname,
  $newname 
)
setValue (   $key,
  $value,
  $section,
  $createSection = true 
)
removeKey (   $key,
  $section 
)
renameKey (   $oldname,
  $newname,
  $section 
)
writeConfiguration (   $name)
_parse_ini_file (   $filename)
protected

Private interface.

Load in the ini file specified in filename, and return the settings in a multidimensional array, with the section names and settings included. All section names and keys are lowercased.

Parameters
$filenameThe filename of the ini file to parse
Returns
An associative array containing the data
Author
: Sebastien Cevey seb@c.nosp@m.ine7.nosp@m..net Original Code base: info@.nosp@m.mega.nosp@m.man.n.nosp@m.l Added comment handling/Removed process sections flag: Ingo Herwig

Definition at line 502 of file InifileConfiguration.php.

processValues ( )
protected

Process the values in the ini array.

This method turns string values that hold array definitions (comma separated values enclosed by curly brackets) into array values.

Definition at line 548 of file InifileConfiguration.php.

processValue ( $value)
protected

Process the values in the ini array.

This method turns string values that hold array definitions (comma separated values enclosed by curly brackets) into array values.

Parameters
$valueA reference to the value

Definition at line 558 of file InifileConfiguration.php.

configMerge (   $array1,
  $array2,
  $override 
)
protected

Merge two arrays, preserving entries in first one unless they are overridden by ones in the second.

Parameters
$array1First array.
$array2Second array.
$overrideBoolean whether values defined in array1 should be overriden by values defined in array2.
Returns
The merged array.

Definition at line 583 of file InifileConfiguration.php.

getConfigIncludes (   $array)
protected

Search the given value for a 'include' key in a section named 'config' (case-insensivite)

Parameters
$arrayThe array to search in
Returns
Mixed

Definition at line 605 of file InifileConfiguration.php.

serialize ( )
protected

Store the instance in the filesystem.

If the instance is modified, this call is ignored.

Definition at line 622 of file InifileConfiguration.php.

unserialize (   $parsedFiles)
protected

Retrieve parsed ini data from the filesystem and update the current instance.

If the current instance is modified or the last file given in parsedFiles is newer than the serialized data, this call is ignored. If InifileConfiguration class changed, the call will be ignored as well.

Parameters
$parsedFilesAn array of ini filenames that must be contained in the data.
Returns
Boolean whether the data could be retrieved or not

Definition at line 646 of file InifileConfiguration.php.

getSerializeFilename (   $parsedFiles)
protected

Get the filename for the serialized data that correspond to the the given ini file sequence.

Parameters
$parsedFilesAn array of parsed filenames
Returns
Filename

Definition at line 678 of file InifileConfiguration.php.

checkFileDate (   $fileList,
  $referenceFile 
)
protected

Check if one file in fileList is newer than the referenceFile.

Parameters
$fileListAn array of files
$referenceFileThe file to check against
Returns
True, if one of the files is newer, false else

Definition at line 690 of file InifileConfiguration.php.

clearAllCache ( )
protected

Clear application cache.

Definition at line 702 of file InifileConfiguration.php.

buildLookupTable ( )
protected

Build the internal lookup table.

Definition at line 716 of file InifileConfiguration.php.

lookup (   $section,
  $key = null 
)
protected

Lookup section and key.

Parameters
$sectionThe section to lookup
$keyThe key to lookup (optional)
Returns
Array with section as first entry and key as second or null if not found

Definition at line 736 of file InifileConfiguration.php.