altocompta/include/class_filetosend.php
Dany De Bontridder 62a5a01ba1 Merged revisions 5633-5634 via svnmerge from
svn+ssh://danydb@ns352270.ovh.net/svn/phpcompta/tags/rel671

........
  r5633 | danydb | 2013-12-30 16:13:16 +0100 (lun., 30 déc. 2013) | 1 line
  
  Final bug
........
  r5634 | danydb | 2013-12-30 16:15:04 +0100 (lun., 30 déc. 2013) | 1 line
  
  add todo
........
2013-12-30 15:15:57 +00:00

80 lines
1.7 KiB
PHP

<?php
/**
* @brief file to add to a message
*
* @see Sendmail
* @author dany
*/
class FileToSend
{
/**
* @brief name of the file without path
*/
var $filename;
/**
*@brief mimetype of the file
*/
var $type;
/**
* path
*/
var $path;
/**
* Path to filename + filename
*/
var $full_name;
function __construct($p_filename,$p_type="")
{
$this->full_name=$p_filename;
if (strpos($p_filename,'/') != false)
{
$this->path=dirname($p_filename);
}
$this->filename=basename ($p_filename);
if ( $p_type=="")
{
$this->guess_type();
}
}
/**
* set the $this->type to the mimetype, called from __construct
*/
private function guess_type()
{
$ext_pos= strrpos($this->filename,'.');
if ( $ext_pos == false ) {
$this->type="application/octect";
return;
}
$ext= substr($this->filename, $ext_pos+1, 3);
switch ($ext)
{
case 'odt':
$this->type='application/vnd.oasis.opendocument.text';
break;
case 'ods':
$this->type='application/vnd.oasis.opendocument.spreadsheet';
break;
case 'pdf':
$this->type="application/pdf";
break;
case 'zip':
$this->type="application/zip";
break;
default:
$this->type="application/octet";
}
}
/**
* Compute properly the filename
*/
function compute_name($p_filename)
{
/**
* @todo compute a filename
*/
}
}