MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
class.phpwsdlelement.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('InterpretKeywordpw_elementHook','internal','PhpWsdlElement::InterpretElement');
24
36 public $NillAble=true;
42 public $MinOccurs=1;
48 public $MaxOccurs=1;
49
57 public function PhpWsdlElement($name,$type,$settings=null)
58 {
59 self::__construct($name, $type, $settings);
60 }
61
62 public function __construct($name,$type,$settings=null){
63 PhpWsdl::Debug('New complex type element '.$name);
64 parent::PhpWsdlParam($name,$type,$settings);
65 $this->NillAble=!in_array($type,PhpWsdl::$NonNillable);
66 if(!is_null($settings)){
67 if(isset($settings['nillable']))
68 $this->NillAble=$settings['nillable']=='1'||$settings['nillable']=='true';
69 if(isset($settings['minoccurs']))
70 $this->MinOccurs=$settings['minoccurs'];
71 if(isset($settings['maxoccurs']))
72 $this->MaxOccurs=$settings['maxoccurs'];
73 }
74 }
75
82 public function CreateElement($pw){
83 PhpWsdl::Debug('Create WSDL definition for element '.$this->Name);
84 $res='<s:element minOccurs="'.$this->MinOccurs.'" maxOccurs="'.$this->MaxOccurs.'" nillable="'.(($this->NillAble)?'true':'false').'" name="'.$this->Name.'" type="';
85 $res.=PhpWsdl::TranslateType($this->Type).'"';
86 if($pw->IncludeDocs&&!$pw->Optimize&&!is_null($this->Docs)){
87 $res.='>'."\n";
88 $res.='<s:annotation>'."\n";
89 $res.='<s:documentation><![CDATA['.$this->Docs.']]></s:documentation>'."\n";
90 $res.='</s:annotation>'."\n";
91 $res.='</s:element>';
92 }else{
93 $res.=' />';
94 }
95 return $res;
96 }
97
103 public function CreateElementHtml($data){
104 PhpWsdl::Debug('CreateElementHtml for '.$data['element']->Name);
105 $res=&$data['res'];
106 $e=&$data['element'];
107 if(in_array($e->Type,PhpWsdl::$BasicTypes)){
108 $res[]='<li><span class="blue">'.$e->Type.'</span> <span class="bold">'.$e->Name.'</span>';
109 }else{
110 $res[]='<li><a href="#'.$e->Type.'"><span class="lightBlue">'.$e->Type.'</span></a> <span class="bold">'.$e->Name.'</span>';
111 }
112 $o=sizeof($res)-1;
113 $temp=Array(
114 'nillable = <span class="blue">'.(($e->NillAble)?'true':'false').'</span>',
115 'minoccurs = <span class="blue">'.$e->MinOccurs.'</span>',
116 'maxoccurs = <span class="blue">'.$e->MaxOccurs.'</span>',
117 );
118 $res[$o].=' ('.implode(', ',$temp).')';
119 if(!is_null($e->Docs))
120 $res[$o].='<br><span class="normal">'.nl2br(htmlentities($e->Docs)).'</span>';
121 $res[$o].='</li>';
123 'CreateElementHtmlHook',
124 $data
125 );
126 }
127
134 public static function InterpretElement($data){
135 $info=explode(' ',$data['keyword'][1],3);
136 if(sizeof($info)<2)
137 return true;
138 $name=substr($info[1],1);
139 if(substr($name,strlen($name)-1,1)==';')
140 $name=substr($name,0,strlen($name)-1);
141 PhpWsdl::Debug('Interpret element '.$name);
142 if($data['server']->ParseDocs)
143 if(sizeof($info)>2)
144 $data['settings']['docs']=trim($info[2]);
145 $data['elements'][]=new PhpWsdlElement($name,$info[0],$data['settings']);
146 $data['settings']=Array();
147 return false;
148 }
149}
__construct($name, $type, $settings=null)
static InterpretElement($data)
PhpWsdlElement($name, $type, $settings=null)
static Debug($str)
static $NonNillable
static RegisterHook($hook, $name, $data)
static TranslateType($type)
static $BasicTypes
static CallHook($name, $data=null)