cvs: pear /XML_Serializer Serializer.php /XML_Serializer/examples serializeWithTagMap.php

From: Date: Thu, 23 Dec 2004 13:33:53 +0000
Subject: cvs: pear /XML_Serializer Serializer.php /XML_Serializer/examples serializeWithTagMap.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-27786@lists.php.net to get a copy of this message
schst Thu Dec 23 08:33:53 2004 EDT Modified files: /pear/XML_Serializer Serializer.php /pear/XML_Serializer/examples serializeWithTagMap.php Log: added new option replaceEntities (Request #2920) http://cvs.php.net/diff.php/pear/XML_Serializer/Serializer.php?r1=1.31&r2=1.32&ty=u Index: pear/XML_Serializer/Serializer.php diff -u pear/XML_Serializer/Serializer.php:1.31 pear/XML_Serializer/Serializer.php:1.32 --- pear/XML_Serializer/Serializer.php:1.31 Thu Dec 23 07:45:52 2004 +++ pear/XML_Serializer/Serializer.php Thu Dec 23 08:33:51 2004 @@ -16,7 +16,7 @@ // | Authors: Stephan Schmidt <schst@php-tools.net> | // +----------------------------------------------------------------------+ // -// $Id: Serializer.php,v 1.31 2004/12/23 12:45:52 schst Exp $ +// $Id: Serializer.php,v 1.32 2004/12/23 13:33:51 schst Exp $ /** * uses PEAR error management @@ -34,6 +34,29 @@ define('XML_SERIALIZER_ERROR_NO_SERIALIZATION', 51); /** + * do not replace entitites + */ +define('XML_SERIALIZER_ENTITIES_NONE', XML_UTIL_ENTITIES_NONE); + +/** + * replace all XML entitites + * This setting will replace <, >, ", ' and & + */ +define('XML_SERIALIZER_ENTITIES_XML', XML_UTIL_ENTITIES_XML); + +/** + * replace only required XML entitites + * This setting will replace <, " and & + */ +define('XML_SERIALIZER_ENTITIES_XML_REQUIRED', XML_UTIL_ENTITIES_XML_REQUIRED); + +/** + * replace HTML entitites + * @link http://www.php.net/htmlentities + */ +define('XML_SERIALIZER_ENTITIES_HTML', XML_UTIL_ENTITIES_HTML); + +/** * XML_Serializer * class that serializes various structures into an XML document * @@ -131,6 +154,7 @@ 'tagMap' => array(), // tag names that will be changed 'encodeFunction' => null, // function that will be applied before serializing 'namespace' => null, // namespace to use + 'replaceEntities' => XML_UTIL_ENTITIES_XML // type of entities to replace ); /** @@ -556,6 +580,10 @@ $multiline = false; $indent = false; } + + if ($replaceEntities) { + $replaceEntities = $this->options['replaceEntities']; + } if (is_array($tag['content'])) { if (empty($tag['content'])) { @@ -585,7 +613,7 @@ } $tag['attributes'] = array_map($this->options['encodeFunction'], $tag['attributes']); } - $tag = XML_Util::createTagFromArray($tag, $replaceEntities); + $tag = XML_Util::createTagFromArray($tag, $replaceEntities); } return $tag; } http://cvs.php.net/diff.php/pear/XML_Serializer/examples/serializeWithTagMap.php?r1=1.1&r2=1.2&ty=u Index: pear/XML_Serializer/examples/serializeWithTagMap.php diff -u pear/XML_Serializer/examples/serializeWithTagMap.php:1.1 pear/XML_Serializer/examples/serializeWithTagMap.php:1.2 --- pear/XML_Serializer/examples/serializeWithTagMap.php:1.1 Wed Nov 3 05:35:13 2004 +++ pear/XML_Serializer/examples/serializeWithTagMap.php Thu Dec 23 08:33:52 2004 @@ -29,7 +29,7 @@ ), array( 'title' => 'Foobar2!', - 'description' => 'This is some text....', + 'description' => 'This is some text.ü &uuml; ä ö', 'link' => 'http://foobar.com' ) ) @@ -55,6 +55,7 @@ $newOptions = array( 'rootName' => 'body', + 'replaceEntities' => XML_UTIL_ENTITIES_HTML, 'tagMap' => array( 'item' => 'div', 'title' => 'h1',

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