function soap_parser::end_element in Salesforce Suite 5
Same name in this branch
- 5 includes/nusoap.php \soap_parser::end_element()
- 5 includes/nusoap.orig.php \soap_parser::end_element()
Same name and namespace in other branches
- 5.2 includes/nusoap.php \soap_parser::end_element()
- 5.2 includes/nusoap.orig.php \soap_parser::end_element()
* end-element handler * *
Parameters
resource $parser XML parser object: * @param string $name element name * @access private
File
- includes/
nusoap.php, line 6095
Class
- soap_parser
- soap_parser class parses SOAP XML messages into native PHP values
Code
function end_element($parser, $name) {
// position of current element is equal to the last value left in depth_array for my depth
$pos = $this->depth_array[$this->depth--];
// get element prefix
if (strpos($name, ':')) {
// get ns prefix
$prefix = substr($name, 0, strpos($name, ':'));
// get unqualified name
$name = substr(strstr($name, ':'), 1);
}
// build to native type
if (isset($this->body_position) && $pos > $this->body_position) {
// deal w/ multirefs
if (isset($this->message[$pos]['attrs']['href'])) {
// get id
$id = substr($this->message[$pos]['attrs']['href'], 1);
// add placeholder to href array
$this->multirefs[$id][$pos] = 'placeholder';
// add set a reference to it as the result value
$this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
// build complexType values
}
elseif ($this->message[$pos]['children'] != '') {
// if result has already been generated (struct/array)
if (!isset($this->message[$pos]['result'])) {
$attrs = $this->message[$pos]['attrs'];
$type = isset($attrs['xsi:type']) ? $attrs['xsi:type'] : null;
$foundSObject = strpos($type, 'sObject');
// RCHOI: specifically looking for type sObject
if ($foundSObject) {
$recordArray = $this
->buildVal($pos);
$sobj = new sObject($this
->buildVal($pos));
$this->message[$pos]['result'] = $sobj;
}
else {
$this->message[$pos]['result'] = $this
->buildVal($pos);
}
}
// build complexType values of attributes and possibly simpleContent
}
elseif (isset($this->message[$pos]['xattrs'])) {
if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
$this->message[$pos]['xattrs']['!'] = null;
}
elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
if (isset($this->message[$pos]['type'])) {
$this->message[$pos]['xattrs']['!'] = $this
->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
}
else {
$parent = $this->message[$pos]['parent'];
if (isset($this->message[$parent]['type']) && $this->message[$parent]['type'] == 'array' && isset($this->message[$parent]['arrayType'])) {
$this->message[$pos]['xattrs']['!'] = $this
->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
}
else {
$this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
}
}
}
$this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
// set value of simpleType (or nil complexType)
}
else {
//$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
$this->message[$pos]['xattrs']['!'] = null;
}
elseif (isset($this->message[$pos]['type'])) {
$this->message[$pos]['result'] = $this
->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
}
else {
$parent = $this->message[$pos]['parent'];
if (isset($this->message[$parent]['type']) && $this->message[$parent]['type'] == 'array' && isset($this->message[$parent]['arrayType'])) {
$this->message[$pos]['result'] = $this
->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
}
else {
$this->message[$pos]['result'] = $this->message[$pos]['cdata'];
}
}
/* add value to parent's result, if parent is struct/array
$parent = $this->message[$pos]['parent'];
if($this->message[$parent]['type'] != 'map'){
if(strtolower($this->message[$parent]['type']) == 'array'){
$this->message[$parent]['result'][] = $this->message[$pos]['result'];
} else {
$this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
}
}
*/
}
}
// for doclit
if ($this->status == 'header') {
if ($this->root_header != $pos) {
$this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "{$name}>";
}
}
elseif ($pos >= $this->root_struct) {
$this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "{$name}>";
}
// switch status
if ($pos == $this->root_struct) {
$this->status = 'body';
$this->root_struct_namespace = $this->message[$pos]['namespace'];
}
elseif ($name == 'Body') {
$this->status = 'envelope';
}
elseif ($name == 'Header') {
$this->status = 'envelope';
}
elseif ($name == 'Envelope') {
//
}
// set parent back to my parent
$this->parent = $this->message[$pos]['parent'];
}