PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Configuration » Config » Bug #1260

[patch] INI file without sections

Details

Submitted2004-04-22 10:49 UTC
Fromdostick at ctco dot lv
Assignedmansion
StatusDuplicate
PackageConfig
PHP Version4.3.6
OSUNIX
Roadmaps(Not assigned)

Comments

[2004-04-22 10:49 UTC] dostick at ctco dot lv

Description:
------------
Sometimes it ts required to create INI files without sections. PEAR_Config always create section [root]

This patch creates "SimpleINIFile" container from INIFIle container . SimpleINIFile is teh same but does not create sections.

This is may be solution for bug #378

Reproduce code:
---------------
18c18
< // $Id: SimpleIniFile.php,v 1.1 2004/01/26 14:35:52 zzz Exp $
---
> // $Id: IniFile.php,v 1.1 2004/01/05 15:22:55 zzz Exp $
28c28
< class Config_Container_SimpleIniFile {
---
> class Config_Container_IniFile {
147,148c147,148
< if (!$obj->isRoot()) { // Do not write section names
< $string = '';
---
> if (!$obj->isRoot()) {
> $string = '['.$obj->name."]\n";
dostick@dragon /PUBLIC/virtual/intra4.ctco.lv/webapp> diff -u SimpleIniFile.php- PEAR/Config/Container/IniFile.php
--- SimpleIniFile.php- Mon Jan 26 16:35:52 2004
+++ PEAR/Config/Container/IniFile.php Mon Jan 5 17:22:55 2004
@@ -15,7 +15,7 @@
// | Authors: Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
//
-// $Id: SimpleIniFile.php,v 1.1 2004/01/26 14:35:52 zzz Exp $
+// $Id: IniFile.php,v 1.1 2004/01/05 15:22:55 zzz Exp $

/**
* Config parser for PHP .ini files
@@ -25,7 +25,7 @@
* @author Bertrand Mansion <bmansion@mamasam.com>
* @package Config
*/
-class Config_Container_SimpleIniFile {
+class Config_Container_IniFile {

/**
* This class options
@@ -144,8 +144,8 @@
}
break;
case 'section':
- if (!$obj->isRoot()) { // Do not write section names
- $string = '';
+ if (!$obj->isRoot()) {
+ $string = '['.$obj->name."]\n";
}
if (count($obj->children) > 0) {
for ($i = 0; $i < count($obj->children); $i++) {

[2004-04-22 11:43 UTC] dostick at ctco dot lv

correct diff:

--- SimpleIniFile.php- Mon Jan 26 16:35:52 2004
+++ PEAR/Config/Container/IniFile.php Mon Jan 5 17:22:55 2004
@@ -15,7 +15,7 @@
// | Authors: Bertrand Mansion <bmansion@mamasam.com>
|
//
+----------------------------------------------------------------------+

//
-// $Id: SimpleIniFile.php,v 1.1 2004/01/26 14:35:52 zzz Exp $
+// $Id: IniFile.php,v 1.1 2004/01/05 15:22:55 zzz Exp $

/**
* Config parser for PHP .ini files
@@ -25,7 +25,7 @@
* @author Bertrand Mansion <bmansion@mamasam.com>
* @package Config
*/
-class Config_Container_SimpleIniFile {
+class Config_Container_IniFile {

/**
* This class options
@@ -144,8 +144,8 @@
}
break;
case 'section':
- if (!$obj->isRoot()) { // Do not write section names
- $string = '';
+ if (!$obj->isRoot()) {
+ $string = '['.$obj->name."]\n";
}
if (count($obj->children) > 0) {
for ($i = 0; $i < count($obj->children); $i++) {

[2004-06-04 09:21 UTC] bmansion at mamasam dot com

This is a duplicate of #378
See how this was fixed there.