Location: PHPKode > projects > mediaIndex > classes/handler.word.php
<?php
/**
 * $Id: handler.word.php,v 1.11 2004/11/25 08:12:19 openface Exp $      
 *
 *               _ _        _         _                 
 *  _ __  ___ __| (_)__ _  (_)_ _  __| |_____ _____ _ _ 
 * | '  \/ -_) _` | / _` | | | ' \/ _` / -_) \ / -_) '_|
 * |_|_|_\___\__,_|_\__,_| |_|_||_\__,_\___/_\_\___|_|  
 *                                                     
 *     Standalone Indexer Script for Media Files
 *        jason hines, <hide@address.com>
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
 * General Public License for more details.
 */

/* absolute path to catdoc binary */
define("_CATDOC","/usr/bin/catdoc");

/* catdoc directory */
define("_CATDOCPATH",_CACHEPATH."/catdoc");
define("_CATDOCURL",_CACHEURL."/catdoc");

/**
 * Group handler class for MS word documents
 *
 * @version     $Revision: 1.11 $
 * @package     mediaIndexer
 * @subpackage  handlers
 * @author      jason hines, <hide@address.com>
 */
class wordHandler extends defaultHandler {

    public $iconName = "word.gif";

    public function wordHandler() {
        if (!is_executable(_CATDOC)) {
            _addMessage("WARNING! ". _CATDOC . " not found. Is CatDoc installed?");
        }
    }

    public function printMedia(file $file) {
      $cdname = $file->hash . ".txt";
      if (!file_exists(_CATDOCPATH . "/" . $cdname)) {
          if (!is_writable(_CATDOCPATH)) {
              mkdir(_CATDOCPATH);
          }
          exec(_CATDOC . " -f ascii "._MEDIAPATH."/{$file->path} > "._CATDOCPATH."/".$cdname,$out,$ret);
          if ($ret != 0) throw new Exception("Unable to generate text from document.");
      }
      echo "<pre>";
      echo _parseText(file_get_contents(_CATDOCPATH."/".$cdname));
      echo "</pre>";
    }

}

?>
Return current item: mediaIndex