Class: Ini
- Package: saf.Misc
- Version: 1.2, 2003-09-29, $Id: Ini.php,v 1.4 2008/02/17 18:55:47 lux Exp $
Class for parsing, transforming, and writing files in the INI format,
as defined by the PHP parse_ini_file() function.
New in 1.2:
- Added ini_write() convenience function.
- Added ability for filters to reverse themselves, which is used to
properly write files that have been filtered on reading.
Properties
$vals
List of values to alternate between.
$counter
The internal position counter.
$current
Always keeps the value of the current array position here.
$headers = array ()
List of HTTP headers to be sent with the document. @see addHeader()
$meta = array ()
List of metadata attributes, which can be rendered as HTML meta tags using
the makeMeta() method. To render them into your XT templates, simply
add an xt:var tag with the name "makeMeta".
$scripts = array ()
List of javascript scripts, which can be rendered as HTML script tags using
the makeJavascript() method. To render them into your XT templates, simply
add an xt:var tag with the name "makeJavascript".
$styles = array ()
Array used to prevent duplicate loading of stylesheets.
$template_set = 'default'
The template set to use for output.
$trues = array ('on', 'On', 'yes', 'Yes', 'true', 'True')
$falses = array ('off', 'Off', 'no', 'No', 'false', 'False')
Return to Top
Methods
Ini ()
Constructor method.
parse ($file, $sections = true)
Parses the specified file as an INI file. Please note that
this method defaults to assuming INI files _do_ have $sections,
whereas PHP's parse_ini_file() function assumes the opposite.
parseStr ($str, $sections = true)
addFilter ($func, $keys = array ())
Adds a filter to the parse() process.
filter ($data, $sections = true, $reverse = false)
- Return: array hash of filtered INI data
Filters the specified data through all registered filters.
clear ()
Clears the list of registered filters, and adds one filter
back to the list, ini_filter_replace_backticks, which replaces
backtick characters with double-quotes in values. This
filter allows a second level of quotes to be used within
a single INI value.
toXml ($struct)
Returns the specified INI structure as an XML document.
The root node is an <INI> tag, and subsequent tags
all represent key names from the $struct.
fromXml ($data, $isFile = false)
Parses an XML document into an INI $struct, which can then
be saved to a file or processed further.
writeValue ($val)
Formats an individual value from an INI file, using quotes if any invalid
characters are present.
write ($struct, $instructions = false)
Turns an INI structure into an INI formatted string, ready for writing
to a file.
Return to Top