2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 // +----------------------------------------------------------------------+
5 // | Akelos Framework - http://www.akelos.org |
6 // +----------------------------------------------------------------------+
7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez |
8 // | Released under the GNU Lesser General Public License, see LICENSE.txt|
9 // +----------------------------------------------------------------------+
12 * @package ActiveSupport
13 * @subpackage Converters
14 * @author Bermi Ferrer <bermi a.t akelos c.om>
15 * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
21 var $_file_type_codes = array('doc' => 0,'dot' => 1,'txt'=>2,'rtf'=>6,'unicode'=>7,'htm'=>8,'html'=>8,'asc'=>9,'wri'=>13,'wp.doc'=>24,'wps'=>28);
25 $word = new COM('word.application') or die('Unable to instantiate Word');
26 $word->Visible
= false;
27 $word->Documents
->Open($this->source_file
);
28 $word->Documents
[1]->SaveAs($this->destination_file
,$this->_file_type_codes
[$this->convert_to
]);
33 $result = Ak
::file_get_contents($this->destination_file
);
34 $this->delete_source_file ? Ak
::file_delete($this->source_file
) : null;
35 $this->keep_destination_file ?
null : Ak
::file_delete($this->destination_file
);
42 $this->ext
= empty($this->ext
) ?
'doc' : strtolower(trim($this->ext
,'.'));
43 $this->tmp_name
= Ak
::randomString();
44 if(empty($this->source_file
)){
45 $this->source_file
= AK_TMP_DIR
.DS
.$this->tmp_name
.'.'.$this->ext
;
46 Ak
::file_put_contents($this->source_file
,$this->source
);
47 $this->delete_source_file
= true;
48 $this->keep_destination_file
= empty($this->keep_destination_file
) ?
(empty($this->destination_file
) ?
false : true) : $this->keep_destination_file
;
50 $this->delete_source_file
= false;
51 $this->keep_destination_file
= true;
54 $this->convert_to
= !empty($this->convert_to
) && empty($this->_file_type_codes
[$this->convert_to
]) ?
'unicode' : (empty($this->convert_to
) ?
'unicode' : $this->convert_to
);
55 $this->destination_file_name
= empty($this->destination_file_name
) ?
$this->tmp_name
.'.'.$this->convert_to
: $this->destination_file_name
.(strstr($this->destination_file_name
,'.') ?
'' : '.'.$this->convert_to
);
56 $this->destination_file
= empty($this->destination_file
) ? AK_TMP_DIR
.DS
.$this->destination_file_name
: $this->destination_file
;