*/ /** * patConfiguration writer for WDDX files * * used by the patConfiguration object to write INI config files * * $Id: WDDX.php,v 1.1 2004/02/29 16:56:46 schst Exp $ * * @package patConfiguration * @subpackage Writer * @author Stephan Schmidt */ class patConfiguration_Writer_WDDX extends patConfiguration_Writer { /** * table used for translation of xml special chars * @var array $xmlSpecialchars */ var $xmlSpecialchars = array( "&" => "&", "'" => "'", "\"" => """, "<" => "<", ">" => ">" ); /** * 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( !function_exists( "wddx_add_vars" ) ) { return patErrorManager::raiseError( PATCONFIGURATION_ERROR_DRIVER_NOT_WORKING, "WDDX extension is not installed on your system." ); } if( !isset( $options["comment"] ) ) $options["comment"] = "Configuration generated by patConfiguration v".$this->configObj->systemVars["appVersion"].", (c) ". implode( ",", $this->configObj->systemVars["author"]); $options["comment"] = $this->replaceXMLSpecialchars( $options["comment"] ); $packet_id = wddx_packet_start( $options["comment"] ); foreach( $config as $key => $value ) { $$key = $value; wddx_add_vars( $packet_id, $key ); } $packet = wddx_packet_end( $packet_id ); $config = "configObj->encoding}\"?>". $packet; return $config; } /** * replace XML special chars * * @param string $string string, where special chars should be replaced * @param array $table table used for replacing * @return string $string string with replaced chars */ function replaceXMLSpecialchars( $string, $table = array() ) { if( empty( $table ) ) $table = &$this->xmlSpecialchars; if( is_array( $string ) ) { $string = array_map( array( $this, "replaceXMLSpecialchars" ), $string ); } else $string = strtr( $string, $table ); return $string; } } ?>