import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Value.php 17786 2009-08-23 22:26:33Z lars $
|
||||
* @version $Id: Value.php 18443 2009-09-30 13:35:47Z lars $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -73,16 +73,19 @@ abstract class Zend_XmlRpc_Value
|
||||
/**
|
||||
* All the XML-RPC native types
|
||||
*/
|
||||
const XMLRPC_TYPE_I4 = 'i4';
|
||||
const XMLRPC_TYPE_INTEGER = 'int';
|
||||
const XMLRPC_TYPE_DOUBLE = 'double';
|
||||
const XMLRPC_TYPE_BOOLEAN = 'boolean';
|
||||
const XMLRPC_TYPE_STRING = 'string';
|
||||
const XMLRPC_TYPE_DATETIME = 'dateTime.iso8601';
|
||||
const XMLRPC_TYPE_BASE64 = 'base64';
|
||||
const XMLRPC_TYPE_ARRAY = 'array';
|
||||
const XMLRPC_TYPE_STRUCT = 'struct';
|
||||
const XMLRPC_TYPE_NIL = 'nil';
|
||||
const XMLRPC_TYPE_I4 = 'i4';
|
||||
const XMLRPC_TYPE_INTEGER = 'int';
|
||||
const XMLRPC_TYPE_I8 = 'i8';
|
||||
const XMLRPC_TYPE_APACHEI8 = 'ex:i8';
|
||||
const XMLRPC_TYPE_DOUBLE = 'double';
|
||||
const XMLRPC_TYPE_BOOLEAN = 'boolean';
|
||||
const XMLRPC_TYPE_STRING = 'string';
|
||||
const XMLRPC_TYPE_DATETIME = 'dateTime.iso8601';
|
||||
const XMLRPC_TYPE_BASE64 = 'base64';
|
||||
const XMLRPC_TYPE_ARRAY = 'array';
|
||||
const XMLRPC_TYPE_STRUCT = 'struct';
|
||||
const XMLRPC_TYPE_NIL = 'nil';
|
||||
const XMLRPC_TYPE_APACHENIL = 'ex:nil';
|
||||
|
||||
|
||||
/**
|
||||
@ -127,6 +130,10 @@ abstract class Zend_XmlRpc_Value
|
||||
return $this->_as_dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DOMDocument $dom
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _stripXmlDeclaration(DOMDocument $dom)
|
||||
{
|
||||
return preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $dom->saveXML());
|
||||
@ -162,30 +169,47 @@ abstract class Zend_XmlRpc_Value
|
||||
case self::XMLRPC_TYPE_I4:
|
||||
// fall through to the next case
|
||||
case self::XMLRPC_TYPE_INTEGER:
|
||||
require_once 'Zend/XmlRpc/Value/Integer.php';
|
||||
return new Zend_XmlRpc_Value_Integer($value);
|
||||
|
||||
case self::XMLRPC_TYPE_I8:
|
||||
// fall through to the next case
|
||||
case self::XMLRPC_TYPE_APACHEI8:
|
||||
require_once 'Zend/XmlRpc/Value/BigInteger.php';
|
||||
return new Zend_XmlRpc_Value_BigInteger($value);
|
||||
|
||||
case self::XMLRPC_TYPE_DOUBLE:
|
||||
require_once 'Zend/XmlRpc/Value/Double.php';
|
||||
return new Zend_XmlRpc_Value_Double($value);
|
||||
|
||||
case self::XMLRPC_TYPE_BOOLEAN:
|
||||
require_once 'Zend/XmlRpc/Value/Boolean.php';
|
||||
return new Zend_XmlRpc_Value_Boolean($value);
|
||||
|
||||
case self::XMLRPC_TYPE_STRING:
|
||||
require_once 'Zend/XmlRpc/Value/String.php';
|
||||
return new Zend_XmlRpc_Value_String($value);
|
||||
|
||||
case self::XMLRPC_TYPE_BASE64:
|
||||
require_once 'Zend/XmlRpc/Value/Base64.php';
|
||||
return new Zend_XmlRpc_Value_Base64($value);
|
||||
|
||||
case self::XMLRPC_TYPE_NIL:
|
||||
// fall through to the next case
|
||||
case self::XMLRPC_TYPE_APACHENIL:
|
||||
require_once 'Zend/XmlRpc/Value/Nil.php';
|
||||
return new Zend_XmlRpc_Value_Nil();
|
||||
|
||||
case self::XMLRPC_TYPE_DATETIME:
|
||||
require_once 'Zend/XmlRpc/Value/DateTime.php';
|
||||
return new Zend_XmlRpc_Value_DateTime($value);
|
||||
|
||||
case self::XMLRPC_TYPE_ARRAY:
|
||||
require_once 'Zend/XmlRpc/Value/Array.php';
|
||||
return new Zend_XmlRpc_Value_Array($value);
|
||||
|
||||
case self::XMLRPC_TYPE_STRUCT:
|
||||
require_once 'Zend/XmlRpc/Value/Struct.php';
|
||||
return new Zend_XmlRpc_Value_Struct($value);
|
||||
|
||||
default:
|
||||
@ -231,6 +255,10 @@ abstract class Zend_XmlRpc_Value
|
||||
require_once 'Zend/XmlRpc/Value/Integer.php';
|
||||
return new Zend_XmlRpc_Value_Integer($value);
|
||||
|
||||
case 'i8':
|
||||
require_once 'Zend/XmlRpc/Value/BigInteger.php';
|
||||
return new Zend_XmlRpc_Value_BigInteger($value);
|
||||
|
||||
case 'double':
|
||||
require_once 'Zend/XmlRpc/Value/Double.php';
|
||||
return new Zend_XmlRpc_Value_Double($value);
|
||||
@ -267,7 +295,7 @@ abstract class Zend_XmlRpc_Value
|
||||
{
|
||||
if (!$xml instanceof SimpleXMLElement) {
|
||||
try {
|
||||
$xml = @new SimpleXMLElement($xml);
|
||||
$xml = new SimpleXMLElement($xml);
|
||||
} catch (Exception $e) {
|
||||
// The given string is not a valid XML
|
||||
require_once 'Zend/XmlRpc/Value/Exception.php';
|
||||
@ -275,8 +303,22 @@ abstract class Zend_XmlRpc_Value
|
||||
}
|
||||
}
|
||||
|
||||
// Get the key (tag name) and value from the simple xml object and convert the value to an XML-RPC native value
|
||||
$type = null;
|
||||
$value = null;
|
||||
list($type, $value) = each($xml);
|
||||
|
||||
if (!$type and $value === null) {
|
||||
$namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions');
|
||||
foreach ($namespaces as $namespaceName => $namespaceUri) {
|
||||
$namespaceXml = $xml->children($namespaceUri);
|
||||
list($type, $value) = each($namespaceXml);
|
||||
if ($type !== null) {
|
||||
$type = $namespaceName . ':' . $type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$type) { // If no type was specified, the default is string
|
||||
$type = self::XMLRPC_TYPE_STRING;
|
||||
}
|
||||
@ -287,30 +329,40 @@ abstract class Zend_XmlRpc_Value
|
||||
// Fall through to the next case
|
||||
case self::XMLRPC_TYPE_INTEGER:
|
||||
require_once 'Zend/XmlRpc/Value/Integer.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_Integer($value);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_Integer($value);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_APACHEI8:
|
||||
// Fall through to the next case
|
||||
case self::XMLRPC_TYPE_I8:
|
||||
require_once 'Zend/XmlRpc/Value/BigInteger.php';
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_BigInteger($value);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_DOUBLE:
|
||||
require_once 'Zend/XmlRpc/Value/Double.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_Double($value);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_Double($value);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_BOOLEAN:
|
||||
require_once 'Zend/XmlRpc/Value/Boolean.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_Boolean($value);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_Boolean($value);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_STRING:
|
||||
require_once 'Zend/XmlRpc/Value/String.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_String($value);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_String($value);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_DATETIME: // The value should already be in a iso8601 format
|
||||
require_once 'Zend/XmlRpc/Value/DateTime.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_DateTime($value);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_DateTime($value);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_BASE64: // The value should already be base64 encoded
|
||||
require_once 'Zend/XmlRpc/Value/Base64.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_Base64($value ,true);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_Base64($value, true);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_NIL: // The value should always be NULL
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_Nil();
|
||||
case self::XMLRPC_TYPE_NIL:
|
||||
// Fall through to the next case
|
||||
case self::XMLRPC_TYPE_APACHENIL:
|
||||
// The value should always be NULL
|
||||
require_once 'Zend/XmlRpc/Value/Nil.php';
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_Nil();
|
||||
break;
|
||||
case self::XMLRPC_TYPE_ARRAY:
|
||||
// PHP 5.2.4 introduced a regression in how empty($xml->value)
|
||||
@ -334,7 +386,7 @@ abstract class Zend_XmlRpc_Value
|
||||
$values[] = self::_xmlStringToNativeXmlRpc($element);
|
||||
}
|
||||
require_once 'Zend/XmlRpc/Value/Array.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_Array($values);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_Array($values);
|
||||
break;
|
||||
case self::XMLRPC_TYPE_STRUCT:
|
||||
$values = array();
|
||||
@ -350,19 +402,22 @@ abstract class Zend_XmlRpc_Value
|
||||
$values[(string)$member->name] = self::_xmlStringToNativeXmlRpc($member->value);
|
||||
}
|
||||
require_once 'Zend/XmlRpc/Value/Struct.php';
|
||||
$xmlrpc_val = new Zend_XmlRpc_Value_Struct($values);
|
||||
$xmlrpcValue = new Zend_XmlRpc_Value_Struct($values);
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/XmlRpc/Value/Exception.php';
|
||||
throw new Zend_XmlRpc_Value_Exception('Value type \''. $type .'\' parsed from the XML string is not a known XML-RPC native type');
|
||||
break;
|
||||
}
|
||||
$xmlrpc_val->_setXML($xml->asXML());
|
||||
$xmlrpcValue->_setXML($xml->asXML());
|
||||
|
||||
return $xmlrpc_val;
|
||||
return $xmlrpcValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $xml
|
||||
* @return void
|
||||
*/
|
||||
private function _setXML($xml)
|
||||
{
|
||||
$this->_as_xml = $xml;
|
||||
|
Reference in New Issue
Block a user