-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.phpwsdlelement.php
144 lines (133 loc) · 4.4 KB
/
class.phpwsdlelement.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/*
PhpWsdl - Generate WSDL from PHP
Copyright (C) 2011 Andreas Müller-Saala, wan24.de
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, see <http://www.gnu.org/licenses/>.
*/
if(basename($_SERVER['SCRIPT_FILENAME'])==basename(__FILE__))
exit;
PhpWsdl::RegisterHook('InterpretKeywordpw_elementHook','internal','PhpWsdlElement::InterpretElement');
/**
* An element of a complex type
*
* @author Andreas Müller-Saala, wan24.de
*/
class PhpWsdlElement extends PhpWsdlParam{
/**
* Can the value be NULL?
*
* @var boolean
*/
public $NillAble;
/**
* Minimum number of elements
*
* @var int
*/
public $MinOccurs=1;
/**
* Maximum number of elements
*
* @var int|string
*/
public $MaxOccurs=1;
/**
* Constructor
*
* @param string $name The name
* @param string $type The type name
* @param array $settings Optional the settings hash array (default: NULL)
*/
public function PhpWsdlElement($name,$type,$settings=null){
PhpWsdl::Debug('New complex type element '.$name);
parent::PhpWsdlParam($name,$type,$settings);
$this->NillAble=!in_array($type,PhpWsdl::$NonNillable);
if(!is_null($settings)){
if(isset($settings['nillable']))
$this->NillAble=$settings['nillable']=='1'||$settings['nillable']=='true';
if(isset($settings['minoccurs']))
$this->MinOccurs=$settings['minoccurs'];
if(isset($settings['maxoccurs']))
$this->MaxOccurs=$settings['maxoccurs'];
}
}
/**
* Create the WSDL
*
* @param PhpWsdl $pw The PhpWsdl object
* @return string The WSDL
*/
public function CreateElement($pw){
PhpWsdl::Debug('Create WSDL definition for element '.$this->Name);
$res='<s:element minOccurs="'.$this->MinOccurs.'" maxOccurs="'.$this->MaxOccurs.'" nillable="'.(($this->NillAble)?'true':'false').'" name="'.$this->Name.'" type="';
$res.=PhpWsdl::TranslateType($this->Type).'"';
if($pw->IncludeDocs&&!$pw->Optimize&&!is_null($this->Docs)){
$res.='>'."\n";
$res.='<s:annotation>'."\n";
$res.='<s:documentation><![CDATA['.$this->Docs.']]></s:documentation>'."\n";
$res.='</s:annotation>'."\n";
$res.='</s:element>';
}else{
$res.=' />';
}
return $res;
}
/**
* Create the HTML documentation for a complex type element
*
* @param array $data
*/
public function CreateElementHtml($data){
PhpWsdl::Debug('CreateElementHtml for '.$data['element']->Name);
$res=&$data['res'];
$e=&$data['element'];
if(in_array($e->Type,PhpWsdl::$BasicTypes)){
$res[]='<li><span class="blue">'.$e->Type.'</span> <span class="bold">'.$e->Name.'</span>';
}else{
$res[]='<li><a href="#'.$e->Type.'"><span class="lightBlue">'.$e->Type.'</span></a> <span class="bold">'.$e->Name.'</span>';
}
$o=sizeof($res)-1;
$temp=Array(
'nillable = <span class="blue">'.(($e->NillAble)?'true':'false').'</span>',
'minoccurs = <span class="blue">'.$e->MinOccurs.'</span>',
'maxoccurs = <span class="blue">'.$e->MaxOccurs.'</span>',
);
$res[$o].=' ('.implode(', ',$temp).')';
if(!is_null($e->Docs))
$res[$o].='<br><span class="normal">'.nl2br(htmlentities($e->Docs)).'</span>';
$res[$o].='</li>';
PhpWsdl::CallHook(
'CreateElementHtmlHook',
$data
);
}
/**
* Interpret a element keyword
*
* @param array $data The parser data
* @return boolean Response
*/
public static function InterpretElement($data){
$info=explode(' ',$data['keyword'][1],3);
if(sizeof($info)<2)
return true;
$name=substr($info[1],1);
if(substr($name,strlen($name)-1,1)==';')
$name=substr($name,0,strlen($name)-1);
PhpWsdl::Debug('Interpret element '.$name);
if($data['server']->ParseDocs)
if(sizeof($info)>2)
$data['settings']['docs']=trim($info[2]);
$data['elements'][]=new PhpWsdlElement($name,$info[0],$data['settings']);
$data['settings']=Array();
return false;
}
}