\Horde_Config

The Horde_Config:: package provides a framework for managing the configuration of Horde applications, writing conf.php files from conf.xml source files, generating user interfaces, etc.

Copyright 2002-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
__construct()
checkVersions()
configFile()
readXMLConfig()
getVersion()
getPHPConfig()
writePHPConfig()
generatePHPConfig()
configNoSQL()
configSQL()
No public properties found
No constants found
_generatePHPConfig()
_parseLevel()
_configLDAP()
_configLDAPUser()
_configSQLSplitRead()
_configVFS()
_default()
_isDefault()
__default()
_defaultRaw()
_isDefaultRaw()
__defaultRaw()
_getNodeOnlyText()
_getEnumValues()
_getSwitchValues()
_handleSpecials()
_quote()
$_app
$_xmlConfigTree
$_phpConfig
$_oldConfig
$_preConfig
$_postConfig
$_currentConfig
$_versionTag
$_configBegin
$_configEnd
$_versionUrl
N/A
No private methods found
No private properties found
N/A

Properties

$_app

$_app : string

The name of the configured application.

Type

string

$_xmlConfigTree

$_xmlConfigTree : array

The XML tree of the configuration file traversed to an associative array.

Type

array

$_phpConfig

$_phpConfig : string

The content of the generated configuration file.

Type

string

$_oldConfig

$_oldConfig : string

The content of the old configuration file.

Type

string

$_preConfig

$_preConfig : string

The manual configuration in front of the generated configuration.

Type

string

$_postConfig

$_postConfig : string

The manual configuration after the generated configuration.

Type

string

$_currentConfig

$_currentConfig : array

The current $conf array of the configured application.

Type

array

$_versionTag

$_versionTag : string

The version tag of the conf.xml file which will be copied into the conf.php file.

Type

string

$_configBegin

$_configBegin : string

The line marking the begin of the generated configuration.

Type

string

$_configEnd

$_configEnd : string

The line marking the end of the generated configuration.

Type

string

$_versionUrl

$_versionUrl : string

Horde URL to check version information.

Type

string

Methods

__construct()

__construct(string  $app = 'horde') 

Constructor.

Parameters

string $app

The name of the application to be configured.

checkVersions()

checkVersions() : array

Contact Horde servers and get version information.

Throws

\Horde_Exception
\Horde_Http_Exception,

Horde_Exception

Returns

array —

Keys are app names, values are arrays with two keys: 'version' and 'url'.

configFile()

configFile() 

readXMLConfig()

readXMLConfig(array  $custom_conf = null) : array

Reads the application's conf.xml file and builds an associative array from its XML tree.

Parameters

array $custom_conf

Any settings that shall be included in the generated configuration.

Returns

array —

An associative array representing the configuration tree.

getVersion()

getVersion(string  $text) : string

Get the Horde version string for a config file.

Parameters

string $text

The text to parse.

Returns

string —

The version string or false if not found.

getPHPConfig()

getPHPConfig() : string

Returns the file content of the current configuration file.

Returns

string —

The unparsed configuration file content.

writePHPConfig()

writePHPConfig(\Horde_Variables  $formvars, string  $php = null) : boolean

Generates and writes the content of the application's configuration file.

Parameters

\Horde_Variables $formvars

The processed configuration form data.

string $php

The content of the generated configuration file.

Returns

boolean —

True if the configuration file could be written immediately to the file system.

generatePHPConfig()

generatePHPConfig(\Horde_Variables  $formvars, array  $custom_conf = null) : string

Generates the content of the application's configuration file.

Parameters

\Horde_Variables $formvars

The processed configuration form data.

array $custom_conf

Any settings that shall be included in the generated configuration.

Returns

string —

The content of the generated configuration file.

configNoSQL()

configNoSQL(string  $ctx, \DomNode  $node = null, string  $switchname = 'driverconfig') : array

Returns the configuration tree for a NoSQL backend configuration to replace a <confignosql> tag.

Subnodes will be parsed and added to both the Horde defaults and the custom configuration parts.

Parameters

string $ctx

The context of the tag.

\DomNode $node

The DomNode representation of the

tag.
string $switchname

If DomNode is not set, the value of the tag's switchname attribute.

Returns

array —

An associative array with the SQL configuration tree.

configSQL()

configSQL(string  $ctx, \DomNode  $node = null, string  $switchname = 'driverconfig') : array

Returns the configuration tree for an SQL backend configuration to replace a <configsql> tag.

Subnodes will be parsed and added to both the Horde defaults and the Custom configuration parts.

Parameters

string $ctx

The context of the tag.

\DomNode $node

The DomNode representation of the tag.

string $switchname

If DomNode is not set, the value of the tag's switchname attribute.

Returns

array —

An associative array with the SQL configuration tree.

_generatePHPConfig()

_generatePHPConfig(array  $section, string  $prefix, \Horde_Variables  $formvars) 

Generates the configuration file items for a part of the configuration tree.

Parameters

array $section

An associative array containing the part of the traversed XML configuration tree that should be processed.

string $prefix

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.

\Horde_Variables $formvars

The processed configuration form data.

_parseLevel()

_parseLevel(  $conf, \DOMNodeList  $children, string  $ctx) 

Parses one level of the configuration XML tree into the associative array containing the traversed configuration tree.

Parameters

$conf
\DOMNodeList $children

The XML nodes of the level that should be parsed.

string $ctx

A string representing the current position (context prefix) inside the configuration XML file.

_configLDAP()

_configLDAP(string  $ctx, \DomNode  $node = null, string  $switchname = 'driverconfig') : array

Returns the configuration tree for an LDAP backend configuration to replace a <configldap> tag.

Subnodes will be parsed and added to both the Horde defaults and the Custom configuration parts.

Parameters

string $ctx

The context of the tag.

\DomNode $node

The DomNode representation of the

tag.
string $switchname

If $node is not set, the value of the tag's switchname attribute.

Returns

array —

An associative array with the LDAP configuration tree.

_configLDAPUser()

_configLDAPUser(string  $ctx, \DomNode  $node = null) : array

Returns the configuration tree for an LDAP configuration to search user DNs to replace a <configldapuser> tag.

Subnodes will be parsed and added.

Parameters

string $ctx

The context of the tag.

\DomNode $node

The DomNode representation of the

tag.

Returns

array —

A list of associative arrays with the LDAP configuration tree.

_configSQLSplitRead()

_configSQLSplitRead(string  $ctx, \DomNode  $node, string  $phptype) : array

Returns the configuration items for split-read database setups.

Parameters

string $ctx

The context of the tag.

\DomNode $node

The DomNode representation of the tag.

string $phptype

The SQL backend name.

Returns

array —

An associative array with the split-read SQL configuration tree.

_configVFS()

_configVFS(string  $ctx, \DomNode  $node) : array

Returns the configuration tree for a VFS backend configuration to replace a <configvfs> tag.

Subnodes will be parsed and added to both the Horde defaults and the Custom configuration parts.

Parameters

string $ctx

The context of the tag.

\DomNode $node

The DomNode representation of the tag.

Returns

array —

An associative array with the VFS configuration tree.

_default()

_default(string  $ctx, mixed  $default) : mixed

Returns a certain value from the current configuration array or a default value, if not found.

Parameters

string $ctx

A string representing the key of the configuration array to return.

mixed $default

The default value to return if the key wasn't found.

Returns

mixed —

Either the value of the configuration array's requested key or the default value if the key wasn't found.

_isDefault()

_isDefault(string  $ctx, mixed  $default) : boolean

Returns whether a certain value from the current configuration array exists or a default value will be used.

Parameters

string $ctx

A string representing the key of the configuration array to return.

mixed $default

The default value to return if the key wasn't found.

Returns

boolean —

Whether the default value will be used.

__default()

__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.

Parameters

string $ctx

A string representing the key of the configuration array to return.

mixed $default

The default value to return if the key wasn't found.

Returns

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()

_defaultRaw(string  $ctx, mixed  $default) : mixed

Returns a certain value from the current configuration file or a default value, if not found.

It does NOT return the actual value, but the PHP expression as used in the configuration file.

Parameters

string $ctx

A string representing the key of the configuration array to return.

mixed $default

The default value to return if the key wasn't found.

Returns

mixed —

Either the value of the configuration file's requested key or the default value if the key wasn't found.

_isDefaultRaw()

_isDefaultRaw(string  $ctx, mixed  $default) : boolean

Returns whether a certain value from the current configuration array exists or a default value will be used.

Parameters

string $ctx

A string representing the key of the configuration array to return.

mixed $default

The default value to return if the key wasn't found.

Returns

boolean —

Whether the default value will be used.

__defaultRaw()

__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.

It does NOT return the actual value, but the PHP expression as used in the configuration file.

Parameters

string $ctx

A string representing the key of the configuration array to return.

mixed $default

The default value to return if the key wasn't found.

Returns

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.

_getNodeOnlyText()

_getNodeOnlyText(\DomNode  $node) : string

Returns the content of all text node children of the specified node.

Parameters

\DomNode $node

A DomNode object whose text node children to return.

Returns

string —

The concatenated values of all text nodes.

_getEnumValues()

_getEnumValues(\DomNode  $node) : array

Returns an associative array containing all possible values of the specified <configenum> tag.

The keys contain the actual enum values while the values contain their corresponding descriptions.

Parameters

\DomNode $node

The DomNode representation of the tag whose values should be returned.

Returns

array —

An associative array with all possible enum values.

_getSwitchValues()

_getSwitchValues(  $node,   $curctx) : array

Returns a multidimensional associative array representing the specified <configswitch> tag.

Parameters

$node
$curctx

Returns

array —

An associative array representing the node.

_handleSpecials()

_handleSpecials(\DomNode  $node) : array

Returns an associative array containing the possible values of a <configspecial> tag as used inside of enum configurations.

Parameters

\DomNode $node

The DomNode representation of the tag.

Returns

array —

An associative array with the possible values.

_quote()

_quote(string  $string) : string

Returns the specified string with escaped single quotes

Parameters

string $string

A string to escape.

Returns

string —

The specified string with single quotes being escaped.