[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/AkConverters/ -> AkXdocToText.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
   3  
   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  // +----------------------------------------------------------------------+
  10  
  11  /**
  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>
  17   */
  18  
  19  class AkXdocToText
  20  {
  21      function convert()
  22      {
  23          $xdoc2txt_bin = AK_VENDOR_DIR.DS.'hyperestraier'.DS.'xdoc2txt.exe';
  24          
  25          if(AK_OS != 'WINDOWS'){
  26              trigger_error(Ak::t('Xdoc2Text is a windows only application. Please use wvWare instead'), E_USER_WARNING);
  27              return false;
  28          }
  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);
  31              return false;
  32          }
  33  
  34          exec('@"'.$xdoc2txt_bin . '" -f "' . $this->source_file . '" "' . $this->destination_file.'"');
  35  
  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);
  39  
  40          return $result;
  41      }
  42  
  43      function init()
  44      {
  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;
  52          }else{
  53              $this->delete_source_file = false;
  54              $this->keep_destination_file = true;
  55          }
  56  
  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;
  60      }
  61  
  62  }
  63  
  64  ?>


Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6