• 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-2002 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 5974 2004-11-24 17:03:42Z smeyer $
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, $attributes = array())
00085     {
00086         // detect type if not passed
00087         $this->nqn = new QName($name);
00088         $this->name = $this->nqn->name;
00089         $this->namespace = $this->nqn->namespace;
00090         $this->tqn = new QName($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     
00098    
00104     function &serialize(&$serializer)
00105     {
00106         return $serializer->_serializeValue($this->value, $this->name, $this->type, $this->namespace, $this->type_namespace, $this->options, $this->attributes, $this->arrayType);
00107     }
00108 }
00109 
00110 
00125 class ilBMFHeader extends ilBMFValue
00126 {
00127 
00137     function ilBMFHeader($name = '', $type, $value = NULL,
00138                          $mustunderstand = 0,
00139                          $actor = 'http://schemas.xmlsoap.org/soap/actor/next')
00140     {
00141         parent::ilBMFValue($name, $type, $value);
00142         $this->attributes['SOAP-ENV:actor'] = $actor;
00143         $this->attributes['SOAP-ENV:mustUnderstand'] = (int)$mustunderstand;
00144     }
00145 }
00146 
00158 class ilBMFAttachment extends ilBMFValue
00159 {
00160 
00168     function ilBMFAttachment($name = '', $type = 'application/octet-stream',
00169                              $filename, $file=NULL)
00170     {
00171         global $SOAP_options;
00172         if (!isset($SOAP_options['Mime'])) {
00173             return PEAR::raiseError('Mail_mime is not installed, unable to support SOAP Attachements');
00174         }
00175         parent::ilBMFValue($name, NULL, NULL);
00176         
00177         $filedata = ($file === NULL) ? $this->_file2str($filename) : $file;
00178         $filename = basename($filename);
00179         if (PEAR::isError($filedata)) {
00180             return $filedata;
00181         }
00182         
00183         $cid = md5(uniqid(time()));
00184         
00185         $this->attributes['href'] = 'cid:'.$cid;
00186         
00187         $this->options['attachment'] = array(
00188                                 'body'     => $filedata,
00189                                 'disposition'     => $filename,
00190                                 'content_type'   => $type,
00191                                 'encoding' => 'base64',
00192                                 'cid' => $cid
00193                                );
00194     }
00195 
00196     /*
00197     * Returns the contents of the given file name as string
00198     * @param string $file_name
00199     * @return string
00200     * @acces private
00201     */
00202     function & _file2str($file_name)
00203     {
00204         if (!is_readable($file_name)) {
00205             return PEAR::raiseError('File is not readable ' . $file_name);
00206         }
00207         if (!$fd = fopen($file_name, 'rb')) {
00208             return PEAR::raiseError('Could not open ' . $file_name);
00209         }
00210         $cont = fread($fd, filesize($file_name));
00211         fclose($fd);
00212         return $cont;
00213     }
00214 }
00215 ?>

Generated on Fri Dec 13 2013 09:06:37 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1