noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_filetosend.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 /**
00021  * @brief  file to add to a message
00022  *
00023  * @see Sendmail
00024  * @author dany
00025  */
00026 class FileToSend
00027 {
00028     /** 
00029      * @brief name of the file without path
00030      */
00031     var $filename;
00032     /**
00033      *@brief mimetype of the file
00034      */
00035     var $type;
00036     /**
00037      * path
00038      */
00039     var $path;
00040     /**
00041      * Path to filename + filename
00042      */
00043     var $full_name;
00044     function __construct($p_filename,$p_type="")
00045     {
00046         $this->full_name=$p_filename;
00047         if (strpos($p_filename,'/') != false)
00048         {
00049             $this->path=dirname($p_filename);
00050         }
00051         $this->filename=basename ($p_filename);
00052         if ( $p_type=="")
00053         {
00054             $this->guess_type();
00055             
00056         }
00057     }
00058     /**
00059      * set the $this->type to the mimetype, called from __construct
00060      */
00061     private function guess_type()
00062     {
00063         $ext_pos=  strrpos($this->filename,'.');
00064         if ( $ext_pos == false ) {
00065             $this->type="application/octect";
00066             return;
00067         }
00068         $ext=  substr($this->filename, $ext_pos+1, 3);
00069         switch ($ext)
00070         {
00071             case 'odt':
00072                 $this->type='application/vnd.oasis.opendocument.text';
00073                 break;
00074             case 'ods':
00075                 $this->type='application/vnd.oasis.opendocument.spreadsheet';
00076                 break;
00077             case 'pdf':
00078                 $this->type="application/pdf";
00079                 break;
00080             case 'zip':
00081                 $this->type="application/zip";
00082                 break;
00083             default:
00084                 $this->type="application/octet";
00085         }
00086         
00087     }
00088     /**
00089      * Compute properly the filename
00090      */
00091     function compute_name($p_filename)
00092     {
00093         /**
00094          * @todo compute a filename
00095          */
00096     }
00097   
00098 }
 All Data Structures Namespaces Files Functions Variables Enumerations