cvs: pear /Config/Config Container.php /Config/Config/Container Apache.php PHPArray.php XML.php

From: Date: Wed, 02 Apr 2003 11:50:53 +0000
Subject: cvs: pear /Config/Config Container.php /Config/Config/Container Apache.php PHPArray.php XML.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-9703@lists.php.net to get a copy of this message
mansion Wed Apr 2 06:50:53 2003 EDT Modified files: /pear/Config/Config Container.php /pear/Config/Config/Container Apache.php PHPArray.php XML.php Log: Fix warning with foreach when attributes array not set. Index: pear/Config/Config/Container.php diff -u pear/Config/Config/Container.php:1.20 pear/Config/Config/Container.php:1.21 --- pear/Config/Config/Container.php:1.20 Sun Mar 30 10:28:56 2003 +++ pear/Config/Config/Container.php Wed Apr 2 06:50:52 2003 @@ -15,7 +15,7 @@ // | Author: Bertrand Mansion <bmansion@mamasam.com> | // +---------------------------------------------------------------------+ // -// $Id: Container.php,v 1.20 2003/03/30 15:28:56 mansion Exp $ +// $Id: Container.php,v 1.21 2003/04/02 11:50:52 mansion Exp $ require_once('Config.php'); @@ -62,7 +62,7 @@ * Array of attributes for this item * @var array */ - var $attributes = array(); + var $attributes; /** * Constructor Index: pear/Config/Config/Container/Apache.php diff -u pear/Config/Config/Container/Apache.php:1.8 pear/Config/Config/Container/Apache.php:1.9 --- pear/Config/Config/Container/Apache.php:1.8 Mon Mar 24 09:18:12 2003 +++ pear/Config/Config/Container/Apache.php Wed Apr 2 06:50:52 2003 @@ -15,7 +15,7 @@ // | Author: Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: Apache.php,v 1.8 2003/03/24 14:18:12 mansion Exp $ +// $Id: Apache.php,v 1.9 2003/04/02 11:50:52 mansion Exp $ /** * Simple config parser for apache httpd.conf files @@ -66,7 +66,7 @@ foreach ($lines as $line) { $n++; if (!preg_match('/^\s*#/', $line) && - preg_match('/^\s*(.*)\s+\\\$/', $line, $match)) { + preg_match('/^\s*(.*)\s+\\\$/', $line, $match)) { // directive on more than one line $lastline .= $match[1].' '; continue; @@ -139,7 +139,7 @@ case 'section': if (!$obj->isRoot()) { $string = $ident.'<'.$obj->name; - if (count($obj->attributes) > 0) { + if (is_array($obj->attributes) && count($obj->attributes) > 0) { while (list(,$val) = each($obj->attributes)) { $string .= ' '.$val; } Index: pear/Config/Config/Container/PHPArray.php diff -u pear/Config/Config/Container/PHPArray.php:1.11 pear/Config/Config/Container/PHPArray.php:1.12 --- pear/Config/Config/Container/PHPArray.php:1.11 Wed Mar 26 14:55:34 2003 +++ pear/Config/Config/Container/PHPArray.php Wed Apr 2 06:50:53 2003 @@ -15,7 +15,7 @@ // | Authors: Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: PHPArray.php,v 1.11 2003/03/26 19:55:34 mansion Exp $ +// $Id: PHPArray.php,v 1.12 2003/04/02 11:50:53 mansion Exp $ /** * Config parser for common PHP configuration array @@ -154,7 +154,7 @@ $attrString = ''; $parentString = $this->_getParentString($obj); $attributes = $obj->getAttributes(); - if (count($attributes) > 0) { + if (is_array($attributes) && count($attributes) > 0) { // Directive with attributes '@' and value '#' $string .= $parentString."['#']"; foreach ($attributes as $attr => $val) { @@ -179,7 +179,7 @@ case 'section': $attrString = ''; $attributes = $obj->getAttributes(); - if (count($attributes) > 0) { + if (is_array($attributes) && count($attributes) > 0) { $parentString = $this->_getParentString($obj); foreach ($attributes as $attr => $val) { $attrString .= $parentString."['@']" Index: pear/Config/Config/Container/XML.php diff -u pear/Config/Config/Container/XML.php:1.4 pear/Config/Config/Container/XML.php:1.5 --- pear/Config/Config/Container/XML.php:1.4 Wed Mar 26 14:53:41 2003 +++ pear/Config/Config/Container/XML.php Wed Apr 2 06:50:53 2003 @@ -15,7 +15,7 @@ // | Author: Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: XML.php,v 1.4 2003/03/26 19:53:41 mansion Exp $ +// $Id: XML.php,v 1.5 2003/04/02 11:50:53 mansion Exp $ require_once('XML/Parser.php'); @@ -160,6 +160,8 @@ $string .= 'encoding="'.$this->options['encoding']."\"?>\n"; // <? Fix coloring if (isset($this->options['name'])) { $string .= '<'.$this->options['name'].">\n"; + $deep++; + $ident = str_repeat(' ', $deep); } } if (!isset($string)) { @@ -168,18 +170,21 @@ switch ($obj->type) { case 'directive': $string = $ident.'<'.$obj->name; - foreach ($obj->attributes as $name => $value) { - $string .= ' ' . $name . '="' . $value . '"'; + if (is_array($obj->attributes) && count($obj->attributes) > 0) { + foreach ($obj->attributes as $name => $value) { + $string .= ' ' . $name . '="' . $value . '"'; + } } - $string .= '>'.$obj->content.'</'.$obj->name.">\n"; break; case 'section': $hasChildren = (count($obj->children) > 0) ? true : false; if (!$obj->isRoot()) { $string = $ident.'<'.$obj->name; - foreach ($obj->attributes as $name => $value) { - $string .= ' ' . $name . '="' . $value . '"'; + if (is_array($obj->attributes) && count($obj->attributes) > 0) { + foreach ($obj->attributes as $name => $value) { + $string .= ' ' . $name . '="' . $value . '"'; + } } } if ($hasChildren) {

« previous php.pear.cvs (#9703) next »