MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
class.phpwsdlparam.php
Ir para a documentação deste ficheiro.
1<?php
2
3/*
4PhpWsdl - Generate WSDL from PHP
5Copyright (C) 2011 Andreas Zimmermann, wan24.de
6
7This program is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free Software
9Foundation; either version 3 of the License, or (at your option) any later
10version.
11
12This program is distributed in the hope that it will be useful, but WITHOUT
13ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, see <http://www.gnu.org/licenses/>.
18*/
19
20if(basename($_SERVER['SCRIPT_FILENAME'])==basename(__FILE__))
21 exit;
22
23PhpWsdl::RegisterHook('InterpretKeywordparamHook','internal','PhpWsdlParam::InterpretParam');
24PhpWsdl::RegisterHook('InterpretKeywordreturnHook','internal','PhpWsdlParam::InterpretReturn');
25
37 public $Type;
43 public $Docs=null;
50 public static $DefaultReturnName='return';
51
59 public function PhpWsdlParam($name,$type='string',$settings=null){
60 self::__construct($name, $type, $settings);
61 }
62
63 public function __construct($name,$type='string',$settings=null){
64 PhpWsdl::Debug('New parameter '.$name);
65 parent::__construct($name,$settings);
66 $this->Type=$type;
67 }
68
75 public function CreatePart($pw){
76 PhpWsdl::Debug('Create WSDL definition for parameter part '.$this->Name);
77 $res='<wsdl:part name="'.$this->Name.'" type="';
78 $res.=PhpWsdl::TranslateType($this->Type).'"';
79 if($pw->IncludeDocs&&!$pw->Optimize&&!is_null($this->Docs)){
80 $res.='>'."\n";
81 $res.='<s:documentation><![CDATA['.$this->Docs.']]></s:documentation>'."\n";
82 $res.='</wsdl:part>';
83 }else{
84 $res.=' />';
85 }
86 return $res;
87 }
88
94 public function CreateParamHtml($data){
95 PhpWsdl::Debug('CreateParamHtml for '.$data['param']->Name);
96 $res=&$data['res'];
97 $p=&$data['param'];
98 if(is_null($p->Docs))
99 return;
100 if(in_array($p->Type,PhpWsdl::$BasicTypes)){
101 $res[]='<li class="pre"><span class="blue">'.$p->Type.'</span> <span class="bold">'.$p->Name.'</span>';
102 }else{
103 $res[]='<li class="pre"><a href="#'.$p->Type.'"><span class="lightBlue">'.$p->Type.'</span></a> <span class="bold">'.$p->Name.'</span>';
104 }
105 $res[sizeof($res)-1].='<br><span class="normal">'.nl2br(htmlentities($p->Docs)).'</span></li>';
107 'CreateParameterHtmlHook',
108 $data
109 );
110 }
111
117 public function CreateReturnHtml($data){
118 PhpWsdl::Debug('CreateReturnHtml for '.$data['method']->Return->Name);
119 $res=&$data['res'];
120 $m=&$data['method'];
121 $res[]='<p>Return value <span class="pre">';
122 $o=sizeof($res)-1;
123 $type=$m->Return->Type;
124 if(in_array($type,PhpWsdl::$BasicTypes)){
125 $res[$o].='<span class="blue">'.$type.'</span>';
126 }else{
127 $res[$o].='<a href="#'.$type.'"><span class="lightBlue">'.$type.'</span></a>';
128 }
129 $res[$o].='</span>'.((!is_null($m->Return->Docs))?': '.nl2br(htmlentities($m->Return->Docs)):'').'</p>';
131 'CreateReturnHtmlHook',
132 $data
133 );
134 }
135
142 public static function InterpretParam($data){
143 if($data['method']=='')
144 return true;
145 $info=explode(' ',$data['keyword'][1],3);
146 if(sizeof($info)<2)
147 return true;
148 $name=substr($info[1],1);
149 if(substr($name,strlen($name)-1,1)==';')
150 $name=substr($name,0,strlen($name)-1);
151 PhpWsdl::Debug('Interpret parameter '.$name);
152 if($data['server']->ParseDocs)
153 if(sizeof($info)>2)
154 $data['settings']['docs']=trim($info[2]);
155 $data['param'][]=new PhpWsdlParam($name,$info[0],$data['settings']);
156 $data['settings']=Array();
157 return false;
158 }
159
166 public static function InterpretReturn($data){
167 if($data['method']=='')
168 return true;
169 $info=explode(' ',$data['keyword'][1],2);
170 if(sizeof($info)<1)
171 return true;
172 PhpWsdl::Debug('Interpret return');
173 if($data['server']->ParseDocs)
174 if(sizeof($info)>1)
175 $data['settings']['docs']=trim($info[1]);
176 $data['return']=new PhpWsdlParam(str_replace('%method%',$data['method'],self::$DefaultReturnName),$info[0],$data['settings']);
177 $data['settings']=Array();
178 return false;
179 }
180}
__construct($name, $type='string', $settings=null)
PhpWsdlParam($name, $type='string', $settings=null)
static InterpretParam($data)
static InterpretReturn($data)
static Debug($str)
static RegisterHook($hook, $name, $data)
static TranslateType($type)
static $BasicTypes
static CallHook($name, $data=null)