fixes for releasetool and php7
Dieser Commit ist enthalten in:
Ursprung
e42cb01978
Commit
f529857955
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
|
@ -25,41 +26,38 @@
|
|||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
if (version_compare(PHP_VERSION, '5', '>='))
|
||||
{
|
||||
cInclude("includes", "functions.domxml-php4-to-php5.php"); // Enable PHP4 domxml under PHP 5 ff
|
||||
if (version_compare(PHP_VERSION, '5', '>=')) {
|
||||
cInclude("includes", "functions.domxml-php4-to-php5.php"); // Enable PHP4 domxml under PHP 5 ff
|
||||
}
|
||||
|
||||
class cApiXml2Array
|
||||
{
|
||||
/**
|
||||
* Result array
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_aResult = array();
|
||||
class cApiXml2Array {
|
||||
|
||||
/**
|
||||
* XML data
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_sXML = '';
|
||||
/**
|
||||
* Result array
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_aResult = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function cApiXml2Array ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
/**
|
||||
* XML data
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_sXML = '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* load XML Data
|
||||
*
|
||||
* @param string XML data
|
||||
|
@ -68,49 +66,42 @@ class cApiXml2Array
|
|||
*
|
||||
* @access public
|
||||
*/
|
||||
function loadData ($sXML)
|
||||
{
|
||||
if (substr(trim($sXML), 0, 5) != "<?xml")
|
||||
{
|
||||
// check for file
|
||||
if (@file_exists($sXML))
|
||||
{
|
||||
$sXML = file_get_contents($sXML);
|
||||
}
|
||||
}
|
||||
function loadData($sXML) {
|
||||
if (substr(trim($sXML), 0, 5) != "<?xml") {
|
||||
// check for file
|
||||
if (@file_exists($sXML)) {
|
||||
$sXML = file_get_contents($sXML);
|
||||
}
|
||||
}
|
||||
|
||||
$this->xml_string = $sXML;
|
||||
$this->xml_string = $sXML;
|
||||
|
||||
// check for string, open in dom
|
||||
if (is_string($sXML))
|
||||
{
|
||||
$sXML = @domxml_open_mem($sXML);
|
||||
// check for string, open in dom
|
||||
if (is_string($sXML)) {
|
||||
$sXML = @domxml_open_mem($sXML);
|
||||
|
||||
if (!$sXML)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$this->root_element = $sXML->document_element();
|
||||
}
|
||||
if (!$sXML) {
|
||||
return false;
|
||||
}
|
||||
$this->root_element = $sXML->document_element();
|
||||
}
|
||||
|
||||
// check for dom-creation,
|
||||
if (is_object($sXML) && $sXML->node_type() == XML_DOCUMENT_NODE)
|
||||
{
|
||||
$this->root_element = $sXML->document_element();
|
||||
//$this->xml_string = $xml->dump_mem(true);
|
||||
return true;
|
||||
}
|
||||
// check for dom-creation,
|
||||
if (is_object($sXML) && $sXML->node_type() == XML_DOCUMENT_NODE) {
|
||||
$this->root_element = $sXML->document_element();
|
||||
//$this->xml_string = $xml->dump_mem(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_object($sXML) && $sXML->node_type() == XML_ELEMENT_NODE)
|
||||
{
|
||||
$this->root_element = $sXML;
|
||||
return true;
|
||||
}
|
||||
if (is_object($sXML) && $sXML->node_type() == XML_ELEMENT_NODE) {
|
||||
$this->root_element = $sXML;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get result array
|
||||
*
|
||||
* @param array aMergeTags Defines the tag names to merge
|
||||
|
@ -118,17 +109,14 @@ class cApiXml2Array
|
|||
*
|
||||
* @access public
|
||||
*/
|
||||
function getResult ($aMergeTags = array())
|
||||
{
|
||||
if ($resultDomNode = $this->root_element)
|
||||
{
|
||||
$array_result[$resultDomNode->tagname()] = $this->_recNode2Array( $resultDomNode, $aMergeTags );
|
||||
return $array_result;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function getResult($aMergeTags = array()) {
|
||||
if ($resultDomNode = $this->root_element) {
|
||||
$array_result[$resultDomNode->tagname()] = $this->_recNode2Array($resultDomNode, $aMergeTags);
|
||||
return $array_result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive function to walk through dom and create array
|
||||
|
@ -148,8 +136,8 @@ class cApiXml2Array
|
|||
if ($domnode->has_attributes()) {
|
||||
if (is_array($domnode->attributes())) {
|
||||
foreach ($domnode->attributes() as $attrib) {
|
||||
$prefix = ($attrib->prefix()) ? $attrib->prefix().':' : '';
|
||||
$result["@".$attrib->name()] = $attrib->value();
|
||||
$prefix = ($attrib->prefix()) ? $attrib->prefix() . ':' : '';
|
||||
$result["@" . $attrib->name()] = $attrib->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,23 +147,23 @@ class cApiXml2Array
|
|||
$childs = array();
|
||||
}
|
||||
|
||||
foreach($childs as $child) {
|
||||
switch($child->node_type()) {
|
||||
foreach ($childs as $child) {
|
||||
switch ($child->node_type()) {
|
||||
|
||||
case XML_ELEMENT_NODE:
|
||||
if(is_array($aMergeTags)) {
|
||||
if (is_array($aMergeTags)) {
|
||||
if (in_array($child->node_name(), $aMergeTags)) {
|
||||
$sTagName = "merged";
|
||||
} else {
|
||||
$sTagName = $prefix.$child->node_name();
|
||||
$sTagName = $prefix . $child->node_name();
|
||||
}
|
||||
} else {
|
||||
$sTagName = $prefix.$child->node_name();
|
||||
$sTagName = $prefix . $child->node_name();
|
||||
}
|
||||
// TODO: Check the following subnode code (see below)
|
||||
#$subnode = false;
|
||||
// TODO: Check this line, as it should be too late, to specify it here (see above)
|
||||
$prefix = ($child->prefix()) ? $child->prefix().':' : '';
|
||||
$prefix = ($child->prefix()) ? $child->prefix() . ':' : '';
|
||||
$result[$sTagName][] = $this->_recNode2Array($child, $aMergeTags);
|
||||
break;
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
|
@ -187,7 +175,7 @@ class cApiXml2Array
|
|||
}
|
||||
}
|
||||
|
||||
if(!is_array($result)) {
|
||||
if (!is_array($result)) {
|
||||
// TODO
|
||||
// correct encoding from utf-8 to locale
|
||||
// NEEDS to be updated to correct in both ways!
|
||||
|
@ -197,54 +185,50 @@ class cApiXml2Array
|
|||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get encoding
|
||||
*
|
||||
* @return string encoding
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _getEncoding()
|
||||
{
|
||||
preg_match("~\<\?xml.*encoding=[\"\'](.*)[\"\'].*\?\>~i",trim($this->xml_string),$matches);
|
||||
function _getEncoding() {
|
||||
preg_match("~\<\?xml.*encoding=[\"\'](.*)[\"\'].*\?\>~i", trim($this->xml_string), $matches);
|
||||
|
||||
return ($matches[1])?$matches[1]:"";
|
||||
}
|
||||
return ($matches[1]) ? $matches[1] : "";
|
||||
}
|
||||
|
||||
function dummy_html_entity_decode ($string)
|
||||
{
|
||||
$trans_tbl = clGetHtmlTranslationTable(HTML_ENTITIES);
|
||||
$trans_tbl = array_flip($trans_tbl);
|
||||
return strtr($string, $trans_tbl);
|
||||
}
|
||||
function dummy_html_entity_decode($string) {
|
||||
$trans_tbl = clGetHtmlTranslationTable(HTML_ENTITIES);
|
||||
$trans_tbl = array_flip($trans_tbl);
|
||||
return strtr($string, $trans_tbl);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get namespace
|
||||
*
|
||||
* @return string namespace
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _getNamespaces()
|
||||
{
|
||||
preg_match_all("~[[:space:]]xmlns:([[:alnum:]]*)=[\"\'](.*?)[\"\']~i",$this->xml_string,$matches,PREG_SET_ORDER);
|
||||
foreach( $matches as $match )
|
||||
$result[ $match[1] ] = $match[2];
|
||||
return $result;
|
||||
}
|
||||
function _getNamespaces() {
|
||||
preg_match_all("~[[:space:]]xmlns:([[:alnum:]]*)=[\"\'](.*?)[\"\']~i", $this->xml_string, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match)
|
||||
$result[$match[1]] = $match[2];
|
||||
return $result;
|
||||
}
|
||||
|
||||
function setSourceEncoding ($sEncoding)
|
||||
{
|
||||
function setSourceEncoding($sEncoding) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function setTargetEncoding ($sEncoding)
|
||||
{
|
||||
function setTargetEncoding($sEncoding) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren