mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
merge & tag 1.4.3
git-svn-id: http://xe-core.googlecode.com/svn/trunk@7597 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
762ebbf445
commit
289973781a
200 changed files with 2296 additions and 1827 deletions
44
classes/display/XMLDisplayHandler.php
Normal file
44
classes/display/XMLDisplayHandler.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
class XMLDisplayHandler {
|
||||
/**
|
||||
* @brief Produce XML compliant content given a module object.\n
|
||||
* @param[in] $oModule the module object
|
||||
**/
|
||||
function toDoc(&$oModule)
|
||||
{
|
||||
$variables = $oModule->getVariables();
|
||||
|
||||
$xmlDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n";
|
||||
$xmlDoc .= sprintf("<error>%s</error>\n",$oModule->getError());
|
||||
$xmlDoc .= sprintf("<message>%s</message>\n",str_replace(array('<','>','&'),array('<','>','&'),$oModule->getMessage()));
|
||||
|
||||
$xmlDoc .= $this->_makeXmlDoc($variables);
|
||||
|
||||
$xmlDoc .= "</response>";
|
||||
|
||||
return $xmlDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief produce XML code given variable object\n
|
||||
* @param[in] $oModule the module object
|
||||
**/
|
||||
function _makeXmlDoc($obj) {
|
||||
if(!count($obj)) return;
|
||||
|
||||
$xmlDoc = '';
|
||||
|
||||
foreach($obj as $key => $val) {
|
||||
if(is_numeric($key)) $key = 'item';
|
||||
|
||||
if(is_string($val)) $xmlDoc .= sprintf('<%s><![CDATA[%s]]></%s>%s', $key, $val, $key,"\n");
|
||||
else if(!is_array($val) && !is_object($val)) $xmlDoc .= sprintf('<%s>%s</%s>%s', $key, $val, $key,"\n");
|
||||
else $xmlDoc .= sprintf('<%s>%s%s</%s>%s',$key, "\n", $this->_makeXmlDoc($val), $key, "\n");
|
||||
}
|
||||
|
||||
return $xmlDoc;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue