mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
web serviceMDL-12886 refactor servers into object + add Zend_soap and Zend_xmlrpc server
This commit is contained in:
parent
625b51d4e0
commit
06e7fadc43
79 changed files with 10475 additions and 211 deletions
78
lib/zend/Zend/XmlRpc/Value/Array.php
Normal file
78
lib/zend/Zend/XmlRpc/Value/Array.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Collection
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Collection.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Array extends Zend_XmlRpc_Value_Collection
|
||||
{
|
||||
/**
|
||||
* Set the value of an array native type
|
||||
*
|
||||
* @param array $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_ARRAY;
|
||||
parent::__construct($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the XML code that represent an array native MXL-RPC value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXML()
|
||||
{
|
||||
if (!$this->_as_xml) { // The XML code was not calculated yet
|
||||
$dom = new DOMDocument('1.0');
|
||||
$value = $dom->appendChild($dom->createElement('value'));
|
||||
$array = $value->appendChild($dom->createElement('array'));
|
||||
$data = $array->appendChild($dom->createElement('data'));
|
||||
|
||||
if (is_array($this->_value)) {
|
||||
foreach ($this->_value as $val) {
|
||||
/* @var $val Zend_XmlRpc_Value */
|
||||
$data->appendChild($dom->importNode($val->getAsDOM(), true));
|
||||
}
|
||||
}
|
||||
|
||||
$this->_as_dom = $value;
|
||||
$this->_as_xml = $this->_stripXmlDeclaration($dom);
|
||||
}
|
||||
|
||||
return $this->_as_xml;
|
||||
}
|
||||
}
|
||||
|
89
lib/zend/Zend/XmlRpc/Value/Base64.php
Normal file
89
lib/zend/Zend/XmlRpc/Value/Base64.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Scalar
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Scalar.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Base64 extends Zend_XmlRpc_Value_Scalar
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of a base64 native type
|
||||
* We keep this value in base64 encoding
|
||||
*
|
||||
* @param string $value
|
||||
* @param bool $already_encoded If set, it means that the given string is already base64 encoded
|
||||
*/
|
||||
public function __construct($value, $already_encoded=false)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_BASE64;
|
||||
|
||||
$value = (string)$value; // Make sure this value is string
|
||||
if (!$already_encoded) {
|
||||
$value = base64_encode($value); // We encode it in base64
|
||||
}
|
||||
$this->_value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this object, convert the XML-RPC native base64 value into a PHP string
|
||||
* We return this value decoded (a normal string)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return base64_decode($this->_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the XML code representing the base64-encoded value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXML()
|
||||
{
|
||||
if (! $this->_as_xml) { // The XML was not generated yet
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$value = $dom->appendChild($dom->createElement('value'));
|
||||
$type = $value->appendChild($dom->createElement($this->_type));
|
||||
$type->appendChild($dom->createTextNode($this->_value));
|
||||
|
||||
$this->_as_dom = $value;
|
||||
$this->_as_xml = $this->_stripXmlDeclaration($dom);
|
||||
}
|
||||
|
||||
return $this->_as_xml;
|
||||
}
|
||||
}
|
||||
|
84
lib/zend/Zend/XmlRpc/Value/Boolean.php
Normal file
84
lib/zend/Zend/XmlRpc/Value/Boolean.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Scalar
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Scalar.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Boolean extends Zend_XmlRpc_Value_Scalar
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of a boolean native type
|
||||
* We hold the boolean type as an integer (0 or 1)
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_BOOLEAN;
|
||||
// Make sure the value is boolean and then convert it into a integer
|
||||
// The double convertion is because a bug in the ZendOptimizer in PHP version 5.0.4
|
||||
$this->_value = (int)(bool)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this object, convert the XML-RPC native boolean value into a PHP boolean
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return (bool)$this->_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the XML-RPC serialization of the boolean value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXML()
|
||||
{
|
||||
if (! $this->_as_xml) { // The XML was not generated yet
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$value = $dom->appendChild($dom->createElement('value'));
|
||||
$type = $value->appendChild($dom->createElement($this->_type));
|
||||
$type->appendChild($dom->createTextNode($this->_value));
|
||||
|
||||
$this->_as_dom = $value;
|
||||
$this->_as_xml = $this->_stripXmlDeclaration($dom);
|
||||
}
|
||||
|
||||
return $this->_as_xml;
|
||||
}
|
||||
}
|
||||
|
79
lib/zend/Zend/XmlRpc/Value/Collection.php
Normal file
79
lib/zend/Zend/XmlRpc/Value/Collection.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_XmlRpc_Value_Collection extends Zend_XmlRpc_Value
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of a collection type (array and struct) native types
|
||||
*
|
||||
* @param array $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$values = (array)$value; // Make sure that the value is an array
|
||||
foreach ($values as $key => $value) {
|
||||
// If the elements of the given array are not Zend_XmlRpc_Value objects,
|
||||
// we need to convert them as such (using auto-detection from PHP value)
|
||||
if (!$value instanceof parent) {
|
||||
$value = self::getXmlRpcValue($value, self::AUTO_DETECT_TYPE);
|
||||
}
|
||||
$this->_value[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value of this object, convert the XML-RPC native collection values into a PHP array
|
||||
*
|
||||
* @return arary
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
$values = (array)$this->_value;
|
||||
foreach ($values as $key => $value) {
|
||||
/* @var $value Zend_XmlRpc_Value */
|
||||
|
||||
if (!$value instanceof parent) {
|
||||
throw new Zend_XmlRpc_Value_Exception('Values of '. get_class($this) .' type must be Zend_XmlRpc_Value objects');
|
||||
}
|
||||
$values[$key] = $value->getValue();
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
}
|
||||
|
81
lib/zend/Zend/XmlRpc/Value/DateTime.php
Normal file
81
lib/zend/Zend/XmlRpc/Value/DateTime.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Scalar
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Scalar.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_DateTime extends Zend_XmlRpc_Value_Scalar
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of a dateTime.iso8601 native type
|
||||
*
|
||||
* The value is in iso8601 format, minus any timezone information or dashes
|
||||
*
|
||||
* @param mixed $value Integer of the unix timestamp or any string that can be parsed
|
||||
* to a unix timestamp using the PHP strtotime() function
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_DATETIME;
|
||||
|
||||
// If the value is not numeric, we try to convert it to a timestamp (using the strtotime function)
|
||||
if (is_numeric($value)) { // The value is numeric, we make sure it is an integer
|
||||
$value = (int)$value;
|
||||
} else {
|
||||
$value = strtotime($value);
|
||||
if ($value === false || $value == -1) { // cannot convert the value to a timestamp
|
||||
throw new Zend_XmlRpc_Value_Exception('Cannot convert given value \''. $value .'\' to a timestamp');
|
||||
}
|
||||
}
|
||||
$value = date('c', $value); // Convert the timestamp to iso8601 format
|
||||
|
||||
// Strip out TZ information and dashes
|
||||
$value = preg_replace('/(\+|-)\d{2}:\d{2}$/', '', $value);
|
||||
$value = str_replace('-', '', $value);
|
||||
|
||||
$this->_value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this object as iso8601 dateTime value
|
||||
*
|
||||
* @return int As a Unix timestamp
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
62
lib/zend/Zend/XmlRpc/Value/Double.php
Normal file
62
lib/zend/Zend/XmlRpc/Value/Double.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Scalar
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Scalar.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Double extends Zend_XmlRpc_Value_Scalar
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of a double native type
|
||||
*
|
||||
* @param float $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_DOUBLE;
|
||||
$this->_value = sprintf('%f',(float)$value); // Make sure this value is float (double) and without the scientific notation
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this object, convert the XML-RPC native double value into a PHP float
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return (float)$this->_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
39
lib/zend/Zend/XmlRpc/Value/Exception.php
Normal file
39
lib/zend/Zend/XmlRpc/Value/Exception.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Exception
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Exception.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Exception extends Zend_XmlRpc_Exception
|
||||
{}
|
||||
|
62
lib/zend/Zend/XmlRpc/Value/Integer.php
Normal file
62
lib/zend/Zend/XmlRpc/Value/Integer.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Scalar
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Scalar.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Integer extends Zend_XmlRpc_Value_Scalar
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of an integer native type
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_INTEGER;
|
||||
$this->_value = (int)$value; // Make sure this value is integer
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this object, convert the XML-RPC native integer value into a PHP integer
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
79
lib/zend/Zend/XmlRpc/Value/Nil.php
Normal file
79
lib/zend/Zend/XmlRpc/Value/Nil.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Scalar
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Scalar.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Nil extends Zend_XmlRpc_Value_Scalar
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of a nil native type
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_NIL;
|
||||
$this->_value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this object, convert the XML-RPC native nill value into a PHP NULL
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the XML code representing the nil
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXML()
|
||||
{
|
||||
if (! $this->_as_xml) { // The XML was not generated yet
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$value = $dom->appendChild($dom->createElement('value'));
|
||||
$type = $value->appendChild($dom->createElement($this->_type));
|
||||
|
||||
$this->_as_dom = $value;
|
||||
$this->_as_xml = $this->_stripXmlDeclaration($dom);
|
||||
}
|
||||
|
||||
return $this->_as_xml;
|
||||
}
|
||||
}
|
||||
|
60
lib/zend/Zend/XmlRpc/Value/Scalar.php
Normal file
60
lib/zend/Zend/XmlRpc/Value/Scalar.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_XmlRpc_Value_Scalar extends Zend_XmlRpc_Value
|
||||
{
|
||||
|
||||
/**
|
||||
* Return the XML code that represent a scalar native MXL-RPC value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXML()
|
||||
{
|
||||
if (!$this->_as_xml) { // The XML code was not calculated yet
|
||||
$dom = new DOMDocument('1.0');
|
||||
$value = $dom->appendChild($dom->createElement('value'));
|
||||
$type = $value->appendChild($dom->createElement($this->_type));
|
||||
$type->appendChild($dom->createTextNode($this->getValue()));
|
||||
|
||||
$this->_as_dom = $value;
|
||||
$this->_as_xml = $this->_stripXmlDeclaration($dom);
|
||||
}
|
||||
|
||||
return $this->_as_xml;
|
||||
}
|
||||
}
|
||||
|
74
lib/zend/Zend/XmlRpc/Value/String.php
Normal file
74
lib/zend/Zend/XmlRpc/Value/String.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Scalar
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Scalar.php';
|
||||
|
||||
/**
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_String extends Zend_XmlRpc_Value_Scalar
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the value of a string native type
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_STRING;
|
||||
|
||||
// Make sure this value is string and all XML characters are encoded
|
||||
$this->_value = $this->_xml_entities($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of this object, convert the XML-RPC native string value into a PHP string
|
||||
* Decode all encoded risky XML entities back to normal characters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return html_entity_decode($this->_value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure a string will be safe for XML, convert risky characters to HTML entities
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
private function _xml_entities($str)
|
||||
{
|
||||
return htmlentities($str, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
}
|
||||
|
79
lib/zend/Zend/XmlRpc/Value/Struct.php
Normal file
79
lib/zend/Zend/XmlRpc/Value/Struct.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Zend_XmlRpc_Value_Collection
|
||||
*/
|
||||
require_once 'Zend/XmlRpc/Value/Collection.php';
|
||||
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_XmlRpc
|
||||
* @subpackage Value
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_XmlRpc_Value_Struct extends Zend_XmlRpc_Value_Collection
|
||||
{
|
||||
/**
|
||||
* Set the value of an struct native type
|
||||
*
|
||||
* @param array $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->_type = self::XMLRPC_TYPE_STRUCT;
|
||||
parent::__construct($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the XML code that represent struct native MXL-RPC value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXML()
|
||||
{
|
||||
if (!$this->_as_xml) { // The XML code was not calculated yet
|
||||
$dom = new DOMDocument('1.0');
|
||||
$value = $dom->appendChild($dom->createElement('value'));
|
||||
$struct = $value->appendChild($dom->createElement('struct'));
|
||||
|
||||
if (is_array($this->_value)) {
|
||||
foreach ($this->_value as $name => $val) {
|
||||
/* @var $val Zend_XmlRpc_Value */
|
||||
$member = $struct->appendChild($dom->createElement('member'));
|
||||
$member->appendChild($dom->createElement('name', $name));
|
||||
$member->appendChild($dom->importNode($val->getAsDOM(), 1));
|
||||
}
|
||||
}
|
||||
|
||||
$this->_as_dom = $value;
|
||||
$this->_as_xml = $this->_stripXmlDeclaration($dom);
|
||||
}
|
||||
|
||||
return $this->_as_xml;
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue