fixes for releasetool and php7

Dieser Commit ist enthalten in:
Oldperl 2017-03-09 17:24:38 +00:00
Ursprung e42cb01978
Commit f529857955
2 geänderte Dateien mit 719 neuen und 523 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -25,41 +26,38 @@
* }} * }}
* *
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
if (version_compare(PHP_VERSION, '5', '>=')) if (version_compare(PHP_VERSION, '5', '>=')) {
{ cInclude("includes", "functions.domxml-php4-to-php5.php"); // Enable PHP4 domxml under PHP 5 ff
cInclude("includes", "functions.domxml-php4-to-php5.php"); // Enable PHP4 domxml under PHP 5 ff
} }
class cApiXml2Array class cApiXml2Array {
{
/** /**
* Result array * Result array
* @var array * @var array
* @access private * @access private
*/ */
var $_aResult = array(); var $_aResult = array();
/** /**
* XML data * XML data
* @var string * @var string
* @access private * @access private
*/ */
var $_sXML = ''; var $_sXML = '';
/** /**
* Constructor * Constructor
*/ */
function cApiXml2Array () function __construct() {
{ // empty
// empty }
}
/**
/**
* load XML Data * load XML Data
* *
* @param string XML data * @param string XML data
@ -67,69 +65,59 @@ class cApiXml2Array
* @return boolean * @return boolean
* *
* @access public * @access public
*/ */
function loadData ($sXML) function loadData($sXML) {
{ if (substr(trim($sXML), 0, 5) != "<?xml") {
if (substr(trim($sXML), 0, 5) != "<?xml") // check for file
{ if (@file_exists($sXML)) {
// check for file $sXML = file_get_contents($sXML);
if (@file_exists($sXML)) }
{ }
$sXML = file_get_contents($sXML);
}
}
$this->xml_string = $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();
}
// check for dom-creation, $this->xml_string = $sXML;
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) // check for string, open in dom
{ if (is_string($sXML)) {
$this->root_element = $sXML; $sXML = @domxml_open_mem($sXML);
return true;
}
return false; 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;
}
if (is_object($sXML) && $sXML->node_type() == XML_ELEMENT_NODE) {
$this->root_element = $sXML;
return true;
}
return false;
}
/**
* Get result array * Get result array
* *
* @param array aMergeTags Defines the tag names to merge * @param array aMergeTags Defines the tag names to merge
* @return array containing data as array or false * @return array containing data as array or false
* *
* @access public * @access public
*/ */
function getResult ($aMergeTags = array()) function getResult($aMergeTags = array()) {
{ if ($resultDomNode = $this->root_element) {
if ($resultDomNode = $this->root_element) $array_result[$resultDomNode->tagname()] = $this->_recNode2Array($resultDomNode, $aMergeTags);
{ return $array_result;
$array_result[$resultDomNode->tagname()] = $this->_recNode2Array( $resultDomNode, $aMergeTags ); } else {
return $array_result; return false;
} else }
{ }
return false;
}
}
/** /**
* Recursive function to walk through dom and create array * Recursive function to walk through dom and create array
* *
@ -138,7 +126,7 @@ class cApiXml2Array
* @return array result * @return array result
* *
* @access private * @access private
*/ */
function _recNode2Array($domnode, $aMergeTags) { function _recNode2Array($domnode, $aMergeTags) {
// init some vars // init some vars
$prefix = ''; $prefix = '';
@ -148,36 +136,36 @@ class cApiXml2Array
if ($domnode->has_attributes()) { if ($domnode->has_attributes()) {
if (is_array($domnode->attributes())) { if (is_array($domnode->attributes())) {
foreach ($domnode->attributes() as $attrib) { foreach ($domnode->attributes() as $attrib) {
$prefix = ($attrib->prefix()) ? $attrib->prefix().':' : ''; $prefix = ($attrib->prefix()) ? $attrib->prefix() . ':' : '';
$result["@".$attrib->name()] = $attrib->value(); $result["@" . $attrib->name()] = $attrib->value();
} }
} }
} }
$result["type"] = $domnode->node_name(); $result["type"] = $domnode->node_name();
if (!is_array($childs)) { if (!is_array($childs)) {
$childs = array(); $childs = array();
} }
foreach($childs as $child) { foreach ($childs as $child) {
switch($child->node_type()) { switch ($child->node_type()) {
case XML_ELEMENT_NODE: case XML_ELEMENT_NODE:
if(is_array($aMergeTags)) { if (is_array($aMergeTags)) {
if (in_array($child->node_name(), $aMergeTags)) { if (in_array($child->node_name(), $aMergeTags)) {
$sTagName = "merged"; $sTagName = "merged";
} else { } else {
$sTagName = $prefix.$child->node_name(); $sTagName = $prefix . $child->node_name();
} }
} else { } else {
$sTagName = $prefix.$child->node_name(); $sTagName = $prefix . $child->node_name();
} }
// TODO: Check the following subnode code (see below) // TODO: Check the following subnode code (see below)
#$subnode = false; #$subnode = false;
// TODO: Check this line, as it should be too late, to specify it here (see above) // 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); $result[$sTagName][] = $this->_recNode2Array($child, $aMergeTags);
break; break;
case XML_CDATA_SECTION_NODE: case XML_CDATA_SECTION_NODE:
$result["content"] = $child->get_content(); $result["content"] = $child->get_content();
break; break;
@ -186,8 +174,8 @@ class cApiXml2Array
break; break;
} }
} }
if(!is_array($result)) { if (!is_array($result)) {
// TODO // TODO
// correct encoding from utf-8 to locale // correct encoding from utf-8 to locale
// NEEDS to be updated to correct in both ways! // NEEDS to be updated to correct in both ways!
@ -195,56 +183,52 @@ class cApiXml2Array
#$result = clHtmlEntityDecode(clHtmlEntities($domnode->get_content(), ENT_COMPAT, 'UTF-8'), ENT_COMPAT,'ISO-8859-1'); #$result = clHtmlEntityDecode(clHtmlEntities($domnode->get_content(), ENT_COMPAT, 'UTF-8'), ENT_COMPAT,'ISO-8859-1');
$result = $this->dummy_html_entity_decode(clHtmlEntities($domnode->get_content(), ENT_COMPAT, 'UTF-8')); $result = $this->dummy_html_entity_decode(clHtmlEntities($domnode->get_content(), ENT_COMPAT, 'UTF-8'));
} }
return $result; return $result;
} }
} }
/** /**
* Get encoding * Get encoding
* *
* @return string encoding * @return string encoding
* *
* @access private * @access private
*/ */
function _getEncoding() function _getEncoding() {
{ preg_match("~\<\?xml.*encoding=[\"\'](.*)[\"\'].*\?\>~i", trim($this->xml_string), $matches);
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) function dummy_html_entity_decode($string) {
{ $trans_tbl = clGetHtmlTranslationTable(HTML_ENTITIES);
$trans_tbl = clGetHtmlTranslationTable(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl);
$trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl);
return strtr($string, $trans_tbl); }
}
/**
/**
* Get namespace * Get namespace
* *
* @return string namespace * @return string namespace
* *
* @access private * @access private
*/ */
function _getNamespaces() function _getNamespaces() {
{ preg_match_all("~[[:space:]]xmlns:([[:alnum:]]*)=[\"\'](.*?)[\"\']~i", $this->xml_string, $matches, PREG_SET_ORDER);
preg_match_all("~[[:space:]]xmlns:([[:alnum:]]*)=[\"\'](.*?)[\"\']~i",$this->xml_string,$matches,PREG_SET_ORDER); foreach ($matches as $match)
foreach( $matches as $match ) $result[$match[1]] = $match[2];
$result[ $match[1] ] = $match[2]; return $result;
return $result; }
}
function setSourceEncoding($sEncoding) {
function setSourceEncoding ($sEncoding)
{
// TODO // TODO
} }
function setTargetEncoding ($sEncoding) function setTargetEncoding($sEncoding) {
{
// TODO // TODO
} }
} }
?> ?>

Datei-Diff unterdrückt, da er zu groß ist Diff laden