Source code for file /joomla/registry/format/ini.php
Documentation is available at ini.php
* @version $Id: ini.php 6472 2007-02-03 10:47:26Z pasamio $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
* INI format handler for JRegistry
* @package Joomla.Framework
* Converts an object into an INI formatted string
* - Unfortunately, there is no way to have ini values nested further than two
* levels deep. Therefore we will only go through the first two levels of
* @param object $object Data Source Object
* @param array $param Parameters used by the formatter
* @return string INI Formatted String
// First handle groups (or first level key/value pairs)
// This field is an object, so we treat it as a section
$retval .=
"[".
$key.
"]\n";
$retval .=
$key.
"=".
$level2.
"\n";
$prepend .=
$key.
"=".
$level1.
"\n";
return $prepend.
"\n".
$retval;
* Parse an .ini string, based on phpDocumentor phpDocumentor_parse_ini_file function
* @param mixed The INI string or array of lines
* @param boolean add an associative index for each section [in brackets]
* @return object Data Object
foreach ($lines as $line) {
if ($line &&
$line{0} ==
';') {
if ($line &&
$line{0} ==
'[' &&
$line{$lineLen-
1} ==
']') {
$sec_name =
substr($line, 1, $lineLen -
2);
$obj-> $sec_name =
new stdClass();
if ($pos =
strpos($line, '=')) {
// property is assumed to be ascii
if ($property &&
$property{0} ==
'"') {
$propLen =
strlen( $property );
if ($property{$propLen-
1} ==
'"') {
// AJE: 2006-11-06 Fixes problem where you want leading spaces
// for some parameters, eg, class suffix
// $value = trim(substr($line, $pos +1));
$value =
substr($line, $pos +
1);
else if ($value ==
'true') {
else if ($value &&
$value{0} ==
'"') {
if ($value{$valueLen-
1} ==
'"') {
$obj->$sec_name->$property =
$value;
$obj->$property =
$value;
if ($line &&
$line{0} ==
';') {
$property =
'__invalid'.
$unparsed ++.
'__';
$obj->$sec_name->$property =
trim($line);
$obj->$property =
trim($line);
$obj->$property =
trim($line);