eZINI Class Reference
[Utility classes]

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 the file
  include_once( "classes/ezinifile.php" );

  $ini = eZINI::instance( "site.ini" );

  // get a variable from the file.
  $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
 

Initialization of object;

Definition at line ezini.php.

References UseTextCodec.

Referenced by instance().


Member Function Documentation

eZINI::appendOverrideDir   dir,
  globalDir = false
 

Appends the override directory $dir to the override directory list.

Definition at line ezini.php.

References eZDebug::writeNotice().

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

eZINI::filename  
 

Returns:
the filename.

Definition at line ezini.php.

References FileName.

eZINI::getNamedArray  
 

Returns BlockValues, which is a nicely named Array

Definition at line ezini.php.

References BlockValues.

& eZINI::group   blockName
 

Fetches a variable group and returns it as an associative array.

Definition at line ezini.php.

References eZDebug::writeError().

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]
 

Returns the current instance of the given .ini file

Definition at line ezini.php.

References rootDir().

Referenced by eZSys::varDirectory().

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]
 

Returns:
true if the ini file $fileName has been loaded yet.

Definition at line ezini.php.

References rootDir().

Referenced by isLoaded().

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]
 

Returns:
true if textcodecs is to be used, this will use the eZTextCodec class in the eZI18N library for text conversion. Set the option with setIsTextCodecEnabled().

Definition at line ezini.php.

Referenced by eZINI().

& eZINI::isVariableModified   blockName,
  varName
 

Returns:
true if the variable $varName in group $blockName has been modified.

Definition at line ezini.php.

References ModifiedBlockValues.

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

eZINI::overrideDirs  
 

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]
 

Will parse the INI file and store the variables in the variable $this->BlockValues

Definition at line ezini.php.

References eZDebug::writeNotice().

Referenced by parse().

eZINI::prependOverrideDir   dir,
  globalDir = false
 

Appends the override directory $dir to the override directory list.

Definition at line ezini.php.

References eZDebug::writeNotice().

eZINI::reset  
 

Removes all read data from .ini files.

Definition at line ezini.php.

References ModifiedBlockValues.

Referenced by saveCache().

eZINI::resetCache  
 

\removes the cache file if it exists.

Definition at line ezini.php.

eZINI::rootDir  
 

Returns:
the root directory from where all .ini and override files are read.
This is set by the instance() or eZINI() functions.

Definition at line ezini.php.

References RootDir.

Referenced by isLoaded().

& 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]
 

Stores the content of the INI object to the cache file $cachedFile.

Definition at line ezini.php.

References eZDebug::writeNotice().

Referenced by loadCache().

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
 

Sets an INI file variable.

Definition at line ezini.php.

References ModifiedBlockValues.

& eZINI::variable   blockName,
  varName
 

Reads a variable from the ini file. false is returned if the variable was not found.

Definition at line ezini.php.

References eZDebug::writeError().

Referenced by variableArray().

& 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

eZINI::Charset [private]
 

The charset of the ini file

Definition at line ezini.php.

Referenced by parseFile().


The documentation for this class was generated from the following file:  

Exponential