PHP Class Horde_Config, horde

Copyright 2002-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Chuck Hagenbuch ([email protected])
Mostra file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_app string The name of the configured application.
$_configBegin string The line marking the begin of the generated configuration.
$_configEnd string The line marking the end of the generated configuration.
$_currentConfig array The current $conf array of the configured application.
$_oldConfig string The content of the old configuration file.
$_phpConfig string The content of the generated configuration file.
$_postConfig string The manual configuration after the generated configuration.
$_preConfig string The manual configuration in front of the generated configuration.
$_versionTag string The version tag of the conf.xml file which will be copied into the conf.php file.
$_versionUrl string Horde URL to check version information.
$_xmlConfigTree array The XML tree of the configuration file traversed to an associative array.

Public Methods

Method Description
__construct ( string $app = 'horde' ) Constructor.
checkVersions ( ) : array Contact Horde servers and get version information.
configFile ( )
configNoSQL ( string $ctx, DomNode $node = null, string $switchname = 'driverconfig' ) : array Returns the configuration tree for a NoSQL backend configuration to replace a tag.
configSQL ( string $ctx, DomNode $node = null, string $switchname = 'driverconfig' ) : array Returns the configuration tree for an SQL backend configuration to replace a tag.
generatePHPConfig ( Horde_Variables $formvars, array $custom_conf = null ) : string Generates the content of the application's configuration file.
getPHPConfig ( ) : string Returns the file content of the current configuration file.
getVersion ( string $text ) : string Get the Horde version string for a config file.
readXMLConfig ( array $custom_conf = null ) : array Reads the application's conf.xml file and builds an associative array from its XML tree.
writePHPConfig ( Horde_Variables $formvars, string &$php = null ) : boolean Generates and writes the content of the application's configuration file.

Protected Methods

Method Description
__default ( string $ctx, mixed $default ) : array Returns a certain value from the current configuration array or a default value, if not found, and which of the values have been returned.
__defaultRaw ( string $ctx, mixed $default ) : array Returns a certain value from the current configuration file or a default value, if not found, and which of the values have been returned.
_configLDAP ( string $ctx, DomNode $node = null, string $switchname = 'driverconfig' ) : array Returns the configuration tree for an LDAP backend configuration to replace a tag.
_configLDAPUser ( string $ctx, DomNode $node = null ) : array Returns the configuration tree for an LDAP configuration to search user DNs to replace a tag.
_configSQLSplitRead ( string $ctx, DomNode $node, string $phptype ) : array Returns the configuration items for split-read database setups.
_configVFS ( string $ctx, DomNode $node ) : array Returns the configuration tree for a VFS backend configuration to replace a tag.
_default ( string $ctx, mixed $default ) : mixed Returns a certain value from the current configuration array or a default value, if not found.
_defaultRaw ( string $ctx, mixed $default ) : mixed Returns a certain value from the current configuration file or a default value, if not found.
_generatePHPConfig ( array $section, string $prefix, Horde_Variables $formvars ) Generates the configuration file items for a part of the configuration tree.
_getEnumValues ( DomNode $node ) : array Returns an associative array containing all possible values of the specified tag.
_getNodeOnlyText ( DomNode $node ) : string Returns the content of all text node children of the specified node.
_getSwitchValues ( &$node, $curctx ) : array Returns a multidimensional associative array representing the specified tag.
_handleSpecials ( DomNode $node ) : array Returns an associative array containing the possible values of a tag as used inside of enum configurations.
_isDefault ( string $ctx, mixed $default ) : boolean Returns whether a certain value from the current configuration array exists or a default value will be used.
_isDefaultRaw ( string $ctx, mixed $default ) : boolean Returns whether a certain value from the current configuration array exists or a default value will be used.
_parseLevel ( &$conf, DOMNodeList $children, string $ctx ) Parses one level of the configuration XML tree into the associative array containing the traversed configuration tree.
_quote ( string $string ) : string Returns the specified string with escaped single quotes

Method Details

__construct() public method

Constructor.
public __construct ( string $app = 'horde' )
$app string The name of the application to be configured.

__default() protected method

Returns a certain value from the current configuration array or a default value, if not found, and which of the values have been returned.
protected __default ( string $ctx, mixed $default ) : array
$ctx string A string representing the key of the configuration array to return.
$default mixed The default value to return if the key wasn't found.
return array First element: either the value of the configuration array's requested key or the default value if the key wasn't found. Second element: whether the returned value was the default value.

__defaultRaw() protected method

It does NOT return the actual value, but the PHP expression as used in the configuration file.
protected __defaultRaw ( string $ctx, mixed $default ) : array
$ctx string A string representing the key of the configuration array to return.
$default mixed The default value to return if the key wasn't found.
return array First element: either the value of the configuration array's requested key or the default value if the key wasn't found. Second element: whether the returned value was the default value.

_configLDAP() protected method

Subnodes will be parsed and added to both the Horde defaults and the Custom configuration parts.
protected _configLDAP ( string $ctx, DomNode $node = null, string $switchname = 'driverconfig' ) : array
$ctx string The context of the tag.
$node DomNode The DomNode representation of the tag.
$switchname string If $node is not set, the value of the tag's switchname attribute.
return array An associative array with the LDAP configuration tree.

_configLDAPUser() protected method

Subnodes will be parsed and added.
protected _configLDAPUser ( string $ctx, DomNode $node = null ) : array
$ctx string The context of the tag.
$node DomNode The DomNode representation of the tag.
return array A list of associative arrays with the LDAP configuration tree.

_configSQLSplitRead() protected method

Returns the configuration items for split-read database setups.
protected _configSQLSplitRead ( string $ctx, DomNode $node, string $phptype ) : array
$ctx string The context of the tag.
$node DomNode The DomNode representation of the tag.
$phptype string The SQL backend name.
return array An associative array with the split-read SQL configuration tree.

_configVFS() protected method

Subnodes will be parsed and added to both the Horde defaults and the Custom configuration parts.
protected _configVFS ( string $ctx, DomNode $node ) : array
$ctx string The context of the tag.
$node DomNode The DomNode representation of the tag.
return array An associative array with the VFS configuration tree.

_default() protected method

Returns a certain value from the current configuration array or a default value, if not found.
protected _default ( string $ctx, mixed $default ) : mixed
$ctx string A string representing the key of the configuration array to return.
$default mixed The default value to return if the key wasn't found.
return mixed Either the value of the configuration array's requested key or the default value if the key wasn't found.

_defaultRaw() protected method

It does NOT return the actual value, but the PHP expression as used in the configuration file.
protected _defaultRaw ( string $ctx, mixed $default ) : mixed
$ctx string A string representing the key of the configuration array to return.
$default mixed The default value to return if the key wasn't found.
return mixed Either the value of the configuration file's requested key or the default value if the key wasn't found.

_generatePHPConfig() protected method

Generates the configuration file items for a part of the configuration tree.
protected _generatePHPConfig ( array $section, string $prefix, Horde_Variables $formvars )
$section array An associative array containing the part of the traversed XML configuration tree that should be processed.
$prefix string A configuration prefix determining the current position inside the configuration file. This prefix will be translated to keys of the $conf array in the generated configuration file.
$formvars Horde_Variables The processed configuration form data.

_getEnumValues() protected method

The keys contain the actual enum values while the values contain their corresponding descriptions.
protected _getEnumValues ( DomNode $node ) : array
$node DomNode The DomNode representation of the tag whose values should be returned.
return array An associative array with all possible enum values.

_getNodeOnlyText() protected method

Returns the content of all text node children of the specified node.
protected _getNodeOnlyText ( DomNode $node ) : string
$node DomNode A DomNode object whose text node children to return.
return string The concatenated values of all text nodes.

_getSwitchValues() protected method

Returns a multidimensional associative array representing the specified tag.
protected _getSwitchValues ( &$node, $curctx ) : array
return array An associative array representing the node.

_handleSpecials() protected method

Returns an associative array containing the possible values of a tag as used inside of enum configurations.
protected _handleSpecials ( DomNode $node ) : array
$node DomNode The DomNode representation of the tag.
return array An associative array with the possible values.

_isDefault() protected method

Returns whether a certain value from the current configuration array exists or a default value will be used.
protected _isDefault ( string $ctx, mixed $default ) : boolean
$ctx string A string representing the key of the configuration array to return.
$default mixed The default value to return if the key wasn't found.
return boolean Whether the default value will be used.

_isDefaultRaw() protected method

Returns whether a certain value from the current configuration array exists or a default value will be used.
protected _isDefaultRaw ( string $ctx, mixed $default ) : boolean
$ctx string A string representing the key of the configuration array to return.
$default mixed The default value to return if the key wasn't found.
return boolean Whether the default value will be used.

_parseLevel() protected method

Parses one level of the configuration XML tree into the associative array containing the traversed configuration tree.
protected _parseLevel ( &$conf, DOMNodeList $children, string $ctx )
$children DOMNodeList The XML nodes of the level that should be parsed.
$ctx string A string representing the current position (context prefix) inside the configuration XML file.

_quote() protected method

Returns the specified string with escaped single quotes
protected _quote ( string $string ) : string
$string string A string to escape.
return string The specified string with single quotes being escaped.

checkVersions() public method

Contact Horde servers and get version information.
public checkVersions ( ) : array
return array Keys are app names, values are arrays with two keys: 'version' and 'url'.

configFile() public method

public configFile ( )

configNoSQL() public method

Subnodes will be parsed and added to both the Horde defaults and the custom configuration parts.
public configNoSQL ( string $ctx, DomNode $node = null, string $switchname = 'driverconfig' ) : array
$ctx string The context of the tag.
$node DomNode The DomNode representation of the tag.
$switchname string If DomNode is not set, the value of the tag's switchname attribute.
return array An associative array with the SQL configuration tree.

configSQL() public method

Subnodes will be parsed and added to both the Horde defaults and the Custom configuration parts.
public configSQL ( string $ctx, DomNode $node = null, string $switchname = 'driverconfig' ) : array
$ctx string The context of the tag.
$node DomNode The DomNode representation of the tag.
$switchname string If DomNode is not set, the value of the tag's switchname attribute.
return array An associative array with the SQL configuration tree.

generatePHPConfig() public method

Generates the content of the application's configuration file.
public generatePHPConfig ( Horde_Variables $formvars, array $custom_conf = null ) : string
$formvars Horde_Variables The processed configuration form data.
$custom_conf array Any settings that shall be included in the generated configuration.
return string The content of the generated configuration file.

getPHPConfig() public method

Returns the file content of the current configuration file.
public getPHPConfig ( ) : string
return string The unparsed configuration file content.

getVersion() public method

Get the Horde version string for a config file.
public getVersion ( string $text ) : string
$text string The text to parse.
return string The version string or false if not found.

readXMLConfig() public method

Reads the application's conf.xml file and builds an associative array from its XML tree.
public readXMLConfig ( array $custom_conf = null ) : array
$custom_conf array Any settings that shall be included in the generated configuration.
return array An associative array representing the configuration tree.

writePHPConfig() public method

Generates and writes the content of the application's configuration file.
public writePHPConfig ( Horde_Variables $formvars, string &$php = null ) : boolean
$formvars Horde_Variables The processed configuration form data.
$php string The content of the generated configuration file.
return boolean True if the configuration file could be written immediately to the file system.

Property Details

$_app protected_oe property

The name of the configured application.
protected string $_app
return string

$_configBegin protected_oe property

The line marking the begin of the generated configuration.
protected string $_configBegin
return string

$_configEnd protected_oe property

The line marking the end of the generated configuration.
protected string $_configEnd
return string

$_currentConfig protected_oe property

The current $conf array of the configured application.
protected array $_currentConfig
return array

$_oldConfig protected_oe property

The content of the old configuration file.
protected string $_oldConfig
return string

$_phpConfig protected_oe property

The content of the generated configuration file.
protected string $_phpConfig
return string

$_postConfig protected_oe property

The manual configuration after the generated configuration.
protected string $_postConfig
return string

$_preConfig protected_oe property

The manual configuration in front of the generated configuration.
protected string $_preConfig
return string

$_versionTag protected_oe property

The version tag of the conf.xml file which will be copied into the conf.php file.
protected string $_versionTag
return string

$_versionUrl protected_oe property

Horde URL to check version information.
protected string $_versionUrl
return string

$_xmlConfigTree protected_oe property

The XML tree of the configuration file traversed to an associative array.
protected array $_xmlConfigTree
return array