• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

payment/bmf/lib/SOAP/class.ilBMFValue.php

Go to the documentation of this file.
00001 <?php
00025 require_once dirname(__FILE__).'/class.ilBMFBase.php';
00026 
00040 class ilBMFValue
00041 {
00045     var $value = null;
00046 
00050     var $name = '';
00051 
00055     var $type = '';
00056 
00062     var $namespace = '';
00063     var $type_namespace = '';
00064 
00065     var $attributes = array();
00066 
00070     var $arrayType = '';
00071 
00072     var $options = array();
00073 
00074     var $nqn;
00075     var $tqn;
00076 
00086     function ilBMFValue($name = '', $type = false, $value = null,
00087                         $attributes = array())
00088     {
00089         // Detect type if not passed.
00090         $this->nqn =& new QName($name);
00091         $this->name = $this->nqn->name;
00092         $this->namespace = $this->nqn->namespace;
00093         $this->tqn =& new QName($type);
00094         $this->type = $this->tqn->name;
00095         $this->type_prefix = $this->tqn->ns;
00096         $this->type_namespace = $this->tqn->namespace;
00097         $this->value =& $value;
00098         $this->attributes = $attributes;
00099     }
00100 
00109     function serialize(&$serializer)
00110     {
00111         return $serializer->_serializeValue($this->value,
00112                                             $this->name,
00113                                             $this->type,
00114                                             $this->namespace,
00115                                             $this->type_namespace,
00116                                             $this->options,
00117                                             $this->attributes,
00118                                             $this->arrayType);
00119     }
00120 
00121 }
00122 
00136 class ilBMFHeader extends ilBMFValue
00137 {
00148     function ilBMFHeader($name = '', $type, $value, $mustunderstand = 0,
00149                          $attributes = array())
00150     {
00151         if (!is_array($attributes)) {
00152             $actor = $attributes;
00153             $attributes = array();
00154         }
00155 
00156         parent::ilBMFValue($name, $type, $value, $attributes);
00157 
00158         if (isset($actor)) {
00159             $this->attributes['SOAP-ENV:actor'] = $actor;
00160         } elseif (!isset($this->attributes['SOAP-ENV:actor'])) {
00161             $this->attributes['SOAP-ENV:actor'] = 'http://schemas.xmlsoap.org/soap/actor/next';
00162         }
00163         $this->attributes['SOAP-ENV:mustUnderstand'] = (int)$mustunderstand;
00164     }
00165 
00166 }
00167 
00176 class SOAP_Attachment extends ilBMFValue
00177 {
00187     function SOAP_Attachment($name = '', $type = 'application/octet-stream',
00188                              $filename, $file = null)
00189     {
00190         parent::ilBMFValue($name, null, null);
00191 
00192         if (!isset($GLOBALS['SOAP_options']['Mime'])) {
00193             $this->options['attachment'] = PEAR::raiseError('Mail_mime is not installed, unable to support SOAP Attachements');
00194             return;
00195         }
00196 
00197         $filedata = ($file === null) ? $this->_file2str($filename) : $file;
00198         $filename = basename($filename);
00199         if (PEAR::isError($filedata)) {
00200             $this->options['attachment'] = $filedata;
00201             return;
00202         }
00203 
00204         $cid = md5(uniqid(time()));
00205 
00206         $this->attributes['href'] = 'cid:' . $cid; 
00207 
00208         $this->options['attachment'] = array('body' => $filedata,
00209                                              'disposition' => $filename,
00210                                              'content_type' => $type,
00211                                              'encoding' => 'base64',
00212                                              'cid' => $cid);
00213     }
00214 
00224     function _file2str($file_name)
00225     {
00226         if (!is_readable($file_name)) {
00227             return PEAR::raiseError('File is not readable: ' . $file_name);
00228         }
00229 
00230         if (function_exists('file_get_contents')) {
00231             return file_get_contents($file_name);
00232         }
00233 
00234         if (!$fd = fopen($file_name, 'rb')) {
00235             return PEAR::raiseError('Could not open ' . $file_name);
00236         }
00237         $cont = fread($fd, filesize($file_name));
00238         fclose($fd);
00239 
00240         return $cont;
00241     }
00242 
00243 }

Generated on Fri Dec 13 2013 17:56:54 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1