ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBMFValue.php
Go to the documentation of this file.
1 <?php
25 require_once dirname(__FILE__).'/class.ilBMFBase.php';
26 
41 {
45  var $value = null;
46 
50  var $name = '';
51 
55  var $type = '';
56 
62  var $namespace = '';
63  var $type_namespace = '';
64 
65  var $attributes = array();
66 
70  var $arrayType = '';
71 
72  var $options = array();
73 
74  var $nqn;
75  var $tqn;
76 
86  function ilBMFValue($name = '', $type = false, $value = null,
87  $attributes = array())
88  {
89  // Detect type if not passed.
90  $this->nqn =& new QName($name);
91  $this->name = $this->nqn->name;
92  $this->namespace = $this->nqn->namespace;
93  $this->tqn =& new QName($type);
94  $this->type = $this->tqn->name;
95  $this->type_prefix = $this->tqn->ns;
96  $this->type_namespace = $this->tqn->namespace;
97  $this->value =& $value;
98  $this->attributes = $attributes;
99  }
100 
109  function serialize(&$serializer)
110  {
111  return $serializer->_serializeValue($this->value,
112  $this->name,
113  $this->type,
114  $this->namespace,
115  $this->type_namespace,
116  $this->options,
117  $this->attributes,
118  $this->arrayType);
119  }
120 
121 }
122 
136 class ilBMFHeader extends ilBMFValue
137 {
148  function ilBMFHeader($name = '', $type, $value, $mustunderstand = 0,
149  $attributes = array())
150  {
151  if (!is_array($attributes)) {
152  $actor = $attributes;
153  $attributes = array();
154  }
155 
157 
158  if (isset($actor)) {
159  $this->attributes['SOAP-ENV:actor'] = $actor;
160  } elseif (!isset($this->attributes['SOAP-ENV:actor'])) {
161  $this->attributes['SOAP-ENV:actor'] = 'http://schemas.xmlsoap.org/soap/actor/next';
162  }
163  $this->attributes['SOAP-ENV:mustUnderstand'] = (int)$mustunderstand;
164  }
165 
166 }
167 
177 {
187  function SOAP_Attachment($name = '', $type = 'application/octet-stream',
188  $filename, $file = null)
189  {
190  parent::ilBMFValue($name, null, null);
191 
192  if (!isset($GLOBALS['SOAP_options']['Mime'])) {
193  $this->options['attachment'] = PEAR::raiseError('Mail_mime is not installed, unable to support SOAP Attachements');
194  return;
195  }
196 
197  $filedata = ($file === null) ? $this->_file2str($filename) : $file;
198  $filename = basename($filename);
199  if (PEAR::isError($filedata)) {
200  $this->options['attachment'] = $filedata;
201  return;
202  }
203 
204  $cid = md5(uniqid(time()));
205 
206  $this->attributes['href'] = 'cid:' . $cid;
207 
208  $this->options['attachment'] = array('body' => $filedata,
209  'disposition' => $filename,
210  'content_type' => $type,
211  'encoding' => 'base64',
212  'cid' => $cid);
213  }
214 
224  function _file2str($file_name)
225  {
226  if (!is_readable($file_name)) {
227  return PEAR::raiseError('File is not readable: ' . $file_name);
228  }
229 
230  if (function_exists('file_get_contents')) {
231  return file_get_contents($file_name);
232  }
233 
234  if (!$fd = fopen($file_name, 'rb')) {
235  return PEAR::raiseError('Could not open ' . $file_name);
236  }
237  $cont = fread($fd, filesize($file_name));
238  fclose($fd);
239 
240  return $cont;
241  }
242 
243 }