[ Index ]
 

Code source de Flux CMS 1.5

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/inc/ -> Config.php (sommaire)

(pas de description)

Poids: 344 lignes (11 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 1 fichier
 inc/PEAR.php

Définit 1 class

Config:: (8 méthodes):
  Config()
  getValues()
  getBlocks()
  setValue()
  getValue()
  parseInput()
  writeInput()
  array_merge_clobber()


Classe: Config  - X-Ref

Partly implementation of the Config-Interface-API

This class implements a part of the API for working on configuration data
ConfigDefault implements getValues(), getBlocks(), getValue(), setValue()
The data is internally saved in a nested array.

Example:
include("Config.php");
$i = new Config("IniFile");
$i -> parseInput( "yourfile.ini");
$ret = $i->getValues('/section');


Config($storage_driver,$storage_options = "")   X-Ref
Constructor

requires the type of the data container, if the container needs
special parameters during creation, set them with $storage_options

param: string    $storage_driver     type of container
param: string    $storage_options    parameter for container constructor

getValues( $block = "/")   X-Ref
returns all key-value-pairs of the given block

If the block not exists, a PEAR_Error will returned, else
a hash: $array["key"] = value

param: string $block    block path
return: array                returns a hash containing all values, but a PEAR_Error if fails

getBlocks( $block = "/")   X-Ref
returns all blocks of the given block

If the block not exists, a PEAR_Error will returned, else
a array containing all child blocks

param: string $block    block path
return: array                returns a array containing all values, or a PEAR_Error, if fails

setValue( $block = "/", $key, $value = "")   X-Ref
sets the value of the key of the given block

If the block or the key not exists, both will be created.
The value will be returned.

param: string $block    block path
param: string $key      key to set
param: string $value    value for the key
return: mixed                type depends on $value

getValue( $block = "/", $key, $default = "")   X-Ref
return the value of the key of the given block

If the block or the key not exists, both will be created and
sets on the default.
The value or if not exists the default will be returned.

param: string $block    block path
param: string $key      key to set
param: string $default  default value for the key
return: mixed               type depends of the value

parseInput($files ,$feature = Null )   X-Ref
parses the input of the given data source

The format and required content of $datasrc depends of the implementation.
If the implemention requires additional data, for example a comment char, it have to
deliver in a hash as second argument.

param: string $files      Name of the datasource to parse
param: array $feature       Contains a hash of features depending on the implentation
return: mixed                returns a PEAR_ERROR, if error occurs

writeInput( $datasrc = "", $preserve = True )   X-Ref
writes the data to the given data source or if not given to the datasource of parseInput
If $datasrc was a array, the last file will used.

See parseInput for $datasrc. If the second argument $preserve is true, the implementation
should try to preserve the original format and data of the source except changed or added values.
This mean to preserve for example comments in files or so.

param: string $datasrc    Name of the datasource to parse
param: boolean    $preserve   preserving behavior
return: mixed                    returns PEAR_Error, if fails

array_merge_clobber($a1,$a2)   X-Ref
There seemed to be no built in function that would merge two arrays recursively and clobber
any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive
seemed to give unsatisfactory results... it would append duplicate key/values.

So here's a cross between array_merge and array_merge_recursive

param: array first array to be merged
param: array second array to be merged
return: array merged array



Généré le : Wed Nov 21 13:08:55 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics