noalyss Version-9
filetosend.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19// Copyright Author Dany De Bontridder danydb@noalyss.eu
20/**
21 *@file
22 * @brief file to add to a message
23 *
24 * @see Sendmail_Core
25 * @author dany
26 */
27
28/**
29 * @brief file to add to a message
30 *
31 * @see Sendmail_Core
32 * @author dany
33 */
34
36{
37 /**
38 * @brief name of the file without path
39 */
41 /**
42 *@brief mimetype of the file
43 */
44 var $type;
45 /**
46 * path
47 */
48 var $path;
49 /**
50 * Path to filename + filename
51 */
53 function __construct($p_filename,$p_type="")
54 {
55 $this->full_name=$p_filename;
56 if (strpos($p_filename,'/') != false)
57 {
58 $this->path=dirname($p_filename);
59 }
60 $this->filename=basename ($p_filename);
61 if ( $p_type=="")
62 {
63 $this->guess_type();
64
65 }
66 }
67 /**
68 * set the $this->type to the mimetype, called from __construct
69 */
70 private function guess_type()
71 {
72 $ext_pos= strrpos($this->filename,'.');
73 if ( $ext_pos == false ) {
74 $this->type="application/octect";
75 return;
76 }
77 $ext= substr($this->filename, $ext_pos+1, 3);
78 switch ($ext)
79 {
80 case 'odt':
81 $this->type='application/vnd.oasis.opendocument.text';
82 break;
83 case 'ods':
84 $this->type='application/vnd.oasis.opendocument.spreadsheet';
85 break;
86 case 'pdf':
87 $this->type="application/pdf";
88 break;
89 case 'zip':
90 $this->type="application/zip";
91 break;
92 default:
93 $this->type="application/octet";
94 }
95
96 }
97 /**
98 * Compute properly the filename
99 */
100 function compute_name($p_filename)
101 {
102 /**
103 * @todo compute a filename
104 */
105 }
106
107}
$input_from type
Definition: balance.inc.php:65
file to add to a message
__construct($p_filename, $p_type="")
$filename
name of the file without path
guess_type()
set the $this->type to the mimetype, called from __construct
compute_name($p_filename)
Compute properly the filename.
$type
mimetype of the file
$full_name
Path to filename + filename.