merge from 1.7.3.5(r13153:r13167)

git-svn-id: http://xe-core.googlecode.com/svn/trunk@13168 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2013-09-29 23:32:39 +00:00
parent cc47d2b247
commit 2d3f149b5a
2042 changed files with 129266 additions and 126243 deletions

View file

@ -1,57 +1,75 @@
<?php
/**
* XmlGenerator class
* @author NHN (developers@xpressengine.com)
* @package /classes/xml
* @version 0.1
*/
class XmlGenerator{
class XmlGenerator
{
/**
* object change to xml
* @param object $xml
* @return string
*/
function obj2xml($xml){
* object change to xml
* @param object $xml
* @return string
*/
function obj2xml($xml)
{
$buff = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
foreach($xml as $nodeName => $nodeItem){
foreach($xml as $nodeName => $nodeItem)
{
$buff .= $this->_makexml($nodeItem);
}
return $buff;
}
/**
* object change to xml
* @param object $node node in xml object
* @return string
*/
function _makexml($node){
* object change to xml
* @param object $node node in xml object
* @return string
*/
function _makexml($node)
{
$body = '';
foreach($node as $key => $value){
switch($key){
foreach($node as $key => $value)
{
switch($key)
{
case 'node_name' : break;
case 'attrs' : {
$attrs = '';
if (isset($value)){
foreach($value as $attrName=>$attrValue){
$attrs .= sprintf(' %s="%s"', $attrName, htmlspecialchars($attrValue));
}
}
}break;
case 'body' : $body = $value; break;
$attrs = '';
if(isset($value))
{
foreach($value as $attrName => $attrValue)
{
$attrs .= sprintf(' %s="%s"', $attrName, htmlspecialchars($attrValue));
}
}
}
break;
case 'body' :
$body = $value;
break;
default : {
if (is_array($value)){
foreach($value as $idx => $arrNode){
$body .= $this->_makexml($arrNode);
}
}else if(is_object($value)){
$body = $this->_makexml($value);
}
}
if(is_array($value))
{
foreach($value as $idx => $arrNode)
{
$body .= $this->_makexml($arrNode);
}
}
else if(is_object($value))
{
$body = $this->_makexml($value);
}
}
}
}
return sprintf('<%s%s>%s</%s>'."\n", $node->node_name, $attrs, $body, $node->node_name);
return sprintf('<%s%s>%s</%s>' . "\n", $node->node_name, $attrs, $body, $node->node_name);
}
}
?>
}
/* End of file XmlGenerator.class.php */
/* Location: ./classes/xml/XmlGenerator.class.php */