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>
23 $xdoc2txt_bin = AK_VENDOR_DIR
.DS
.'hyperestraier'.DS
.'xdoc2txt.exe';
25 if(AK_OS
!= 'WINDOWS'){
26 trigger_error(Ak
::t('Xdoc2Text is a windows only application. Please use wvWare instead'), E_USER_WARNING
);
29 if(!file_exists($xdoc2txt_bin)){
30 trigger_error(Ak
::t('Could not find xdoc2txt.exe on %path. Please download it from http://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html',array('%path'=>$xdoc2txt_bin)),E_USER_WARNING
);
34 exec('@"'.$xdoc2txt_bin . '" -f "' . $this->source_file
. '" "' . $this->destination_file
.'"');
36 $result = Ak
::file_get_contents($this->destination_file
);
37 $this->delete_source_file ? @Ak
::file_delete($this->source_file
) : null;
38 $this->keep_destination_file ?
null : Ak
::file_delete($this->destination_file
);
45 $this->ext
= empty($this->ext
) ?
'doc' : strtolower(trim($this->ext
,'.'));
46 $this->tmp_name
= Ak
::randomString();
47 if(empty($this->source_file
)){
48 $this->source_file
= AK_TMP_DIR
.DS
.$this->tmp_name
.'.'.$this->ext
;
49 Ak
::file_put_contents($this->source_file
,$this->source
);
50 $this->delete_source_file
= true;
51 $this->keep_destination_file
= empty($this->keep_destination_file
) ?
(empty($this->destination_file
) ?
false : true) : $this->keep_destination_file
;
53 $this->delete_source_file
= false;
54 $this->keep_destination_file
= true;
57 $this->convert_to
= 'txt';
58 $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
);
59 $this->destination_file
= empty($this->destination_file
) ? AK_TMP_DIR
.DS
.$this->destination_file_name
: $this->destination_file
;