* @license PHP License * @package WB * @subpackage base */ WBClass::load( 'WBRequest_Http' ); /** * HTTP XML request class * * * * @version 0.2.1 * @package WB * @subpackage base * @deprecated In favour of special serializer / unserializer */ class WBRequest_HttpXml extends WBRequest_Http { /** * Exception on import * @var WBException */ protected $propertyException = null; /** * constructor * * - Import meta data from $_SERVER * - Set path to $_SERVER['PATH_INFO'] * - Collect request data from XML body */ public function __construct() { parent::__construct(); // import XML body switch($this->_meta['REQUEST_METHOD']) { case 'POST': case 'PUT': break; case 'GET': case 'DELETE': default: return; break; } // prepare XML_Userializer $params = array( 'whitespace' => 'keep', 'complexType' => 'array', 'parseAttributes' => false, 'attributesArray' => '_attributes', 'forceEnum' => array( 'item' ) ); WBClass::load('XML_Unserializer'); $unser = new XML_Unserializer($params); $res = $unser->unserialize($this->getRaw(), false); if( $res instanceof PEAR_Error ) { WBClass::load( 'WBException_Pear' ); $this->propertyException = new WBException_Pear( $res->getMessage(), 1, __CLASS__ ); // flush imported properties $this->import(array()); return; } // replace imported data from XML content $submit = array('save' => 'yes'); $all = $unser->getUnserializedData(); if (!is_array($all)) { $all = array( 'data' => array() ); } else if (!isset($all['data']) || !is_array($all['data'])) { $all['data'] = array(); } $this->import(array_merge($all['data'], $submit)); } /** * receive property * * @throws WBException * @return string */ public function get( $name, $default = null ) { if ($this->propertyException) { throw $this->propertyException; } return parent::get($name, $default); } /** * trim strings * * @param mixed $in * @return mixed */ protected function trim($in) { if (is_string($in)) { return trim($in); } return $in; } } ?>