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

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

Go to the documentation of this file.
00001 <?php
00002 //
00003 // +----------------------------------------------------------------------+
00004 // | PHP Version 4                                                        |
00005 // +----------------------------------------------------------------------+
00006 // | Copyright (c) 1997-2003 The PHP Group                                |
00007 // +----------------------------------------------------------------------+
00008 // | This source file is subject to version 2.02 of the PHP license,      |
00009 // | that is bundled with this package in the file LICENSE, and is        |
00010 // | available at through the world-wide-web at                           |
00011 // | http://www.php.net/license/2_02.txt.                                 |
00012 // | If you did not receive a copy of the PHP license and are unable to   |
00013 // | obtain it through the world-wide-web, please send a note to          |
00014 // | license@php.net so we can mail you a copy immediately.               |
00015 // +----------------------------------------------------------------------+
00016 // | Authors: Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more   |
00017 // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author         |
00018 // +----------------------------------------------------------------------+
00019 //
00020 // $Id: class.ilBMFValue.php 11401 2006-07-12 10:40:54Z jconze $
00021 //
00022 require_once dirname(__FILE__).'/class.ilBMFBase.php';
00023 
00036 class ilBMFValue
00037 {
00043     var $value = NULL;
00044     
00049     var $name = '';
00050     
00055     var $type = '';
00056     
00062     var $namespace = '';
00063     var $type_namespace = '';
00064     
00065     var $attributes = array();
00066 
00071     var $arrayType = '';
00072     
00073     var $options = array();
00074 
00075     var $nqn;
00076     var $tqn;
00084     function ilBMFValue($name = '', $type = false, $value=NULL, $attributes = array())
00085     {
00086         // detect type if not passed
00087         $this->nqn =& new ilBMFQName($name);
00088         $this->name = $this->nqn->name;
00089         $this->namespace = $this->nqn->namespace;
00090         $this->tqn =& new ilBMFQName($type);
00091         $this->type = $this->tqn->name;
00092         $this->type_prefix = $this->tqn->ns;
00093         $this->type_namespace = $this->tqn->namespace;
00094         $this->value =& $value;
00095         $this->attributes = $attributes;
00096     }
00097     
00103     function &serialize(&$serializer)
00104     {
00105         return $serializer->_serializeValue($this->value, $this->name, $this->type, $this->namespace, $this->type_namespace, $this->options, $this->attributes, $this->arrayType);
00106     }
00107 }
00108 
00109 
00124 class SOAP_Header extends ilBMFValue
00125 {
00126 
00136     function SOAP_Header($name = '', $type, $value,
00137                          $mustunderstand = 0,
00138                          $actor = 'http://schemas.xmlsoap.org/soap/actor/next')
00139     {
00140         parent::ilBMFValue($name, $type, $value);
00141         $this->attributes['SOAP-ENV:actor'] = $actor;
00142         $this->attributes['SOAP-ENV:mustUnderstand'] = (int)$mustunderstand;
00143     }
00144 }
00145 
00157 class SOAP_Attachment extends ilBMFValue
00158 {
00159 
00167     function SOAP_Attachment($name = '', $type = 'application/octet-stream',
00168                              $filename, $file=NULL)
00169     {
00170         global $SOAP_options;
00171         if (!isset($SOAP_options['Mime'])) {
00172             return PEAR::raiseError('Mail_mime is not installed, unable to support SOAP Attachements');
00173         }
00174         parent::ilBMFValue($name, NULL, NULL);
00175         
00176         $filedata = ($file === NULL) ? $this->_file2str($filename) : $file;
00177         $filename = basename($filename);
00178         if (PEAR::isError($filedata)) {
00179             return $filedata;
00180         }
00181         
00182         $cid = md5(uniqid(time()));
00183         
00184         $this->attributes['href'] = 'cid:'.$cid;
00185         
00186         $this->options['attachment'] = array(
00187                                 'body'     => $filedata,
00188                                 'disposition'     => $filename,
00189                                 'content_type'   => $type,
00190                                 'encoding' => 'base64',
00191                                 'cid' => $cid
00192                                );
00193     }
00194 
00195     /*
00196     * Returns the contents of the given file name as string
00197     * @param string $file_name
00198     * @return string
00199     * @acces private
00200     */
00201     function & _file2str($file_name)
00202     {
00203         if (!is_readable($file_name)) {
00204             return PEAR::raiseError('File is not readable ' . $file_name);
00205         }
00206         if (!$fd = fopen($file_name, 'rb')) {
00207             return PEAR::raiseError('Could not open ' . $file_name);
00208         }
00209         $cont = fread($fd, filesize($file_name));
00210         fclose($fd);
00211         return $cont;
00212     }
00213 }
00214 ?>

Generated on Fri Dec 13 2013 11:57:58 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1