cvs: pear /Config/Config/Container GenericConf.php

From: Date: Tue, 17 Dec 2002 15:51:31 +0000
Subject: cvs: pear /Config/Config/Container GenericConf.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7914@lists.php.net to get a copy of this message
mansion Tue Dec 17 10:51:31 2002 EDT Modified files: /pear/Config/Config/Container GenericConf.php Log: Add reference to config object as parameter because of :: Index: pear/Config/Config/Container/GenericConf.php diff -u pear/Config/Config/Container/GenericConf.php:1.2 pear/Config/Config/Container/GenericConf.php:1.3 --- pear/Config/Config/Container/GenericConf.php:1.2 Wed Nov 27 12:04:06 2002 +++ pear/Config/Config/Container/GenericConf.php Tue Dec 17 10:51:31 2002 @@ -15,7 +15,7 @@ // | Author: Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: GenericConf.php,v 1.2 2002/11/27 17:04:06 mansion Exp $ +// $Id: GenericConf.php,v 1.3 2002/12/17 15:51:31 mansion Exp $ require_once('Config.php'); @@ -35,7 +35,7 @@ * @param string $datasrc path to the configuration file * @return mixed returns a PEAR_ERROR, if error occurs or true if ok */ - function &parseDatasrc($datasrc) + function &parseDatasrc($datasrc, &$obj) { if (is_null($datasrc) || !is_readable($datasrc)) { return PEAR::raiseError("Datasource file cannot be read.", null, PEAR_ERROR_RETURN); @@ -43,23 +43,23 @@ // Set default options for parser - if (empty($this->parserOptions['comment'])) { - $this->parserOptions['comment'] = '#'; + if (empty($obj->parserOptions['comment'])) { + $obj->parserOptions['comment'] = '#'; } - if (empty($this->parserOptions['equals'])) { - $this->parserOptions['equals'] = ':'; + if (empty($obj->parserOptions['equals'])) { + $obj->parserOptions['equals'] = ':'; } - if (empty($this->parserOptions['newline'])) { - $this->parserOptions['newline'] = '\\'; + if (empty($obj->parserOptions['newline'])) { + $obj->parserOptions['newline'] = '\\'; } $lines = file($datasrc); $n = 0; $lastline = ''; - $root =& $this->container; + $root =& $obj->container; foreach ($lines as $line) { $n++; - if (preg_match('/^\s*(.*)\s+'.$this->parserOptions['newline'].'\s*$/', $line, $match)) { + if (preg_match('/^\s*(.*)\s+'.$obj->parserOptions['newline'].'\s*$/', $line, $match)) { // directive on more than one line $lastline .= $match[1].' '; continue; @@ -68,13 +68,13 @@ $line = $lastline.$line; $lastline = ''; } - if (preg_match('/^\s*'.$this->parserOptions['comment'].'+\s*(.*?)\s*$/', $line, $match)) { + if (preg_match('/^\s*'.$obj->parserOptions['comment'].'+\s*(.*?)\s*$/', $line, $match)) { // a comment $root->addComment($match[1]); } elseif (preg_match('/^\s*$/', $line)) { // a blank line $root->addBlank(); - } elseif (preg_match('/^\s*(\w+)'.$this->parserOptions['equals'].'\s*((.*?)|)\s*$/', $line, $match)) { + } elseif (preg_match('/^\s*(\w+)'.$obj->parserOptions['equals'].'\s*((.*?)|)\s*$/', $line, $match)) { // a directive $root->addDirective($match[1], $match[2]); } else { @@ -89,7 +89,7 @@ * @access public * @return string */ - function toString($configType = 'genericconf', $options = array()) + function toString($configType = 'genericconf', $options = array(), &$obj) { if (empty($string)) { $string = ''; @@ -100,20 +100,20 @@ $options['equals'] = ':'; } } - switch ($this->type) { + switch ($obj->type) { case 'blank': $string = "\n"; break; case 'comment': - $string = $options['comment'].' '.$this->content."\n"; + $string = $options['comment'].' '.$obj->content."\n"; break; case 'directive': - $string = $this->name.$options['equals'].' '.$this->content."\n"; + $string = $obj->name.$options['equals'].' '.$obj->content."\n"; break; case 'section': - if (count($this->children) > 0) { - for ($i = 0; $i < count($this->children); $i++) { - $string .= $this->children[$i]->toString($configType, $options); + if (count($obj->children) > 0) { + for ($i = 0; $i < count($obj->children); $i++) { + $string .= $obj->children[$i]->toString($configType, $options); } } break;

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