Reads and writes .ini style configuration files.
More...
List of all members.
|
Public Methods |
| eZINI ($fileName,$rootDir="",$useTextCodec=null,$useCache=null) |
| filename () |
| isNoCacheAdviced () |
| load ($reset=true) |
| resetCache () |
& | save ($fileName=false,$suffix=false,$useOverride=false,$onlyModified=false) |
| reset () |
| rootDir () |
| overrideDirs () |
| prependOverrideDir ($dir,$globalDir=false) |
| appendOverrideDir ($dir,$globalDir=false) |
& | assign ($blockName,$varName,&$variable) |
& | variable ($blockName,$varName) |
& | hasVariable ($blockName,$varName) |
& | isVariableModified ($blockName,$varName) |
& | variableArray ($blockName,$varName) |
| hasGroup ($blockName) |
& | group ($blockName) |
& | setVariable ($blockName,$varName,$varValue) |
| getNamedArray () |
Static Public Methods |
| isCacheEnabled () |
| setIsCacheEnabled ($cache) |
| isDebugEnabled () |
| setIsDebugEnabled ($debug) |
| isTextCodecEnabled () |
| setIsTextCodecEnabled ($codec) |
| exists ($fileName="site.ini",$rootDir="settings") |
| isLoaded ($fileName="site.ini",$rootDir="settings") |
& | instance ($fileName="site.ini",$rootDir="settings",$useTextCodec=null,$useCache=null) |
Private Methods |
| loadCache ($reset=true) |
| saveCache ($cachedFile) |
& | parse ($inputFiles=false,$iniFile=false,$reset=true) |
& | parseFile ($file) |
Private Attributes |
| Charset |
| BlockValues |
| Variable to store the ini file values.
|
| ModifiedBlockValues |
| Variable to store whether variables are modified or not.
|
| FileName |
| Stores the filename.
|
| RootDir |
| The root of all ini files.
|
| UseTextCodec |
| Whether to use the text codec when reading the ini file or not.
|
| CacheFile |
| Stores the path and filename of the cache file.
|
Detailed Description
Reads and writes .ini style configuration files.
The most common way of using it is.
include_once( "classes/ezinifile.php" );
$ini = eZINI::instance( "site.ini" );
$iniVar = $ini->variable( "BlockName", "Variable" );
The default ini file is site.ini but others can be passed to the instance() function among with some others. It will create one unique instance for each ini file and rootdir, this means that the next time instance() is used with the same parameters the same object will be returned and no new parsing is required.
The class will by default try to create a cache file in var/cache/ini, however to change this behaviour the static setIsCacheEnabled() function can be used, or use the $useCache parameter in instance() for setting this for one object only.
The class will also handle charset conversion using eZTextCodec, to turn this behaviour off use the static setIsTextCodecEnabled() function or set the $useTextCodec parameter in instance() for a per object basis setting.
Normally the eZINI class will not give out much information about what it's doing, it's only when errors occur that you'll see this. To enable internal debugging use the static setIsDebugEnabled() function. The class will then give information about which files are load, if cache files are used and when cache files are written.
Definition at line ezini.php.
Constructor & Destructor Documentation
eZINI::eZINI |
( |
$ |
fileName, |
|
|
$ |
rootDir = "", |
|
|
$ |
useTextCodec = null, |
|
|
$ |
useCache = null |
|
) |
|
|
Member Function Documentation
eZINI::appendOverrideDir |
( |
$ |
dir, |
|
|
$ |
globalDir = false |
|
) |
|
|
& eZINI::assign |
( |
$ |
blockName, |
|
|
$ |
varName, |
|
|
&$ |
variable |
|
) |
|
|
|
Reads a variable from the ini file and puts it in the parameter $variable. - Note:
-
$variable is not modified if the variable does not exist
Definition at line ezini.php.
References variable(). |
eZINI::exists |
( |
$ |
fileName = "site.ini", |
|
|
$ |
rootDir = "settings" |
|
) |
[static] |
|
|
- Returns:
-
true if the INI file $fileName exists in the root dir $rootDir. $fileName defaults to site.ini and rootDir to settings.
Definition at line ezini.php.
References rootDir().
Referenced by eZLocale::localeFile(). |
|
Returns BlockValues, which is a nicely named Array
Definition at line ezini.php.
References BlockValues. |
& eZINI::group |
( |
$ |
blockName |
) |
|
|
eZINI::hasGroup |
( |
$ |
blockName |
) |
|
|
|
Checks if group $blockName is set. Returns true if the group exists, false if not.
Definition at line ezini.php. |
& eZINI::hasVariable |
( |
$ |
blockName, |
|
|
$ |
varName |
|
) |
|
|
|
Checks if a variable is set. Returns true if the variable exists, false if not.
Definition at line ezini.php.
Referenced by assign(). |
& eZINI::instance |
( |
$ |
fileName = "site.ini", |
|
|
$ |
rootDir = "settings", |
|
|
$ |
useTextCodec = null, |
|
|
$ |
useCache = null |
|
) |
[static] |
|
eZINI::isCacheEnabled |
( |
|
) |
[static] |
|
|
- Returns:
-
true if INI cache is enabled globally, the default value is true. Change this setting with setIsCacheEnabled.
Definition at line ezini.php.
Referenced by eZINI(). |
eZINI::isDebugEnabled |
( |
|
) |
[static] |
|
|
- Returns:
-
true if debugging of internals is enabled, this will display which files are loaded and when cache files are created. Set the option with setIsDebugEnabled().
Definition at line ezini.php.
Referenced by saveCache(). |
eZINI::isLoaded |
( |
$ |
fileName = "site.ini", |
|
|
$ |
rootDir = "settings" |
|
) |
[static] |
|
eZINI::isNoCacheAdviced |
( |
|
) |
|
|
|
- Returns:
-
true if cache is not adviced to be used.
- Note:
-
The no-cache-adviced flag might not be modified in time for site.ini and some other important files to be affected.
Definition at line ezini.php.
Referenced by eZINI(). |
eZINI::isTextCodecEnabled |
( |
|
) |
[static] |
|
& eZINI::isVariableModified |
( |
$ |
blockName, |
|
|
$ |
varName |
|
) |
|
|
eZINI::load |
( |
$ |
reset = true |
) |
|
|
|
Tries to load the ini file specified in the constructor or instance() function. If cache files should be used and a cache file is found it loads that instead. Set $reset to false if you don't want to reset internal data.
Definition at line ezini.php.
References reset().
Referenced by eZINI(). |
eZINI::loadCache |
( |
$ |
reset = true |
) |
[private] |
|
|
Will load a cached version of the ini file if it exists, if not it will parse the original file and create the cache file.
Definition at line ezini.php.
References eZDebug::writeNotice().
Referenced by loadCache(). |
|
- Returns:
-
the override directories, if no directories has been set "override" is returned.
The override directories are relative to the rootDir().
Definition at line ezini.php. |
& eZINI::parse |
( |
$ |
inputFiles = false, |
|
|
$ |
iniFile = false, |
|
|
$ |
reset = true |
|
) |
[private] |
|
|
Parses either the override ini file or the standard file and then the append override file if it exists.
Definition at line ezini.php.
References reset().
Referenced by loadCache(). |
& eZINI::parseFile |
( |
$ |
file |
) |
[private] |
|
eZINI::prependOverrideDir |
( |
$ |
dir, |
|
|
$ |
globalDir = false |
|
) |
|
|
|
\removes the cache file if it exists.
Definition at line ezini.php. |
& eZINI::save |
( |
$ |
fileName = false, |
|
|
$ |
suffix = false, |
|
|
$ |
useOverride = false, |
|
|
$ |
onlyModified = false |
|
) |
|
|
|
Saves the file to disk. If filename is given the file is saved with that name if not the current name is used. If $useOverride is true then the file will be placed in the override directory, if $useOverride is "append" it will append ".append" to the filename.
Definition at line ezini.php.
References eZDebug::writeError(). |
eZINI::saveCache |
( |
$ |
cachedFile |
) |
[private] |
|
eZINI::setIsCacheEnabled |
( |
$ |
cache |
) |
[static] |
|
|
Sets whether caching is enabled for INI files or not. This setting is global and can be overriden in the instance() function.
Definition at line ezini.php. |
eZINI::setIsDebugEnabled |
( |
$ |
debug |
) |
[static] |
|
|
Sets whether internal debugging is enabled or not.
Definition at line ezini.php. |
eZINI::setIsTextCodecEnabled |
( |
$ |
codec |
) |
[static] |
|
|
Sets whether textcodec conversion is enabled or not.
Definition at line ezini.php. |
& eZINI::setVariable |
( |
$ |
blockName, |
|
|
$ |
varName, |
|
|
$ |
varValue |
|
) |
|
|
& eZINI::variable |
( |
$ |
blockName, |
|
|
$ |
varName |
|
) |
|
|
& eZINI::variableArray |
( |
$ |
blockName, |
|
|
$ |
varName |
|
) |
|
|
|
Reads a variable from the ini file. The variable will be returned as an array. ; is used as delimiter.
Definition at line ezini.php.
References variable(). |
Member Data Documentation
The documentation for this class was generated from the following file:
|