*/ /** * patConfiguration writer for INI files * * used by the patConfiguration object to write INI config files * * $Id: INI.php,v 1.1 2004/02/29 16:56:46 schst Exp $ * * @package patConfiguration * @subpackage Writer * @author Stephan Schmidt */ class patConfiguration_Writer_INI extends patConfiguration_Writer { /** * create an ini representation of the current config * * @access private * @param array $config config to serialize * @param array $options options for the serialization * @return string $content xml representation */ function serializeConfig( $config, $options ) { if( !isset( $options["mode"] ) ) $options["mode"] = "plain"; $ini = "; Configuration generated by patConfiguration v".$this->configObj->systemVars["appVersion"]."\n"; $ini .= "; (c) ".implode( ",", $this->configObj->systemVars["author"] )."\n"; $ini .= "; download at http://www.php-tools.net\n"; $ini .= "; generated on " . date( "Y-m-d H:i:s", time() ) . "\n\n"; if( $options["mode"] == "pretty" ) $maxLength = max( array_map( "strlen", array_keys( $config ) ) ); else $maxLength = NULL; foreach( $config as $key => $value ) { if( $maxLength != NULL ) $key = str_pad( $key, $maxLength, " " ); if( is_array( $value ) || is_object( $value ) ) $value = serialize( $value ); if( is_bool( $value ) ) $value = "on"; if( is_string( $value ) ) $value = '"'.$value.'"'; $ini .= $key . " = " . $value ."\n"; } return $ini; } } ?>