Location: PHPKode > projects > mediaIndex > classes/handler.postscript.php
<?php
/**
 * $Id: handler.postscript.php,v 1.2 2004/12/02 04:50:24 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 pdftotext binary */
define("_PS2ASCII","/usr/bin/ps2ascii");

/* pdftext directory */
define("_PSTEXTPATH",_CACHEPATH."/pstext");
define("_PSTEXTURL",_CACHEURL."/pstext");

/**
 * File handler class for Postscript documents
 *
 * @version     $Revision: 1.2 $
 * @package     mediaIndexer
 * @subpackage  handlers
 * @author      jason hines, <hide@address.com>
 */

class postscriptHandler extends defaultHandler {

    public $iconName = "ps.gif";

    public function postscriptHandler() {
        if (!is_executable(_PS2ASCII)) {
            _addMessage("WARNING! ". _PS2ASCII . " not found. Is ps2ascii installed?");
        }
    }

    public function printMedia(file $file) {
      $ptname = $file->hash . ".txt";
      if (!file_exists(_PSTEXTPATH . "/" . $ptname)) {
          if (!is_writable(_PSTEXTPATH)) {
              mkdir(_PSTEXTPATH);
          }
          exec(_PS2ASCII." "._MEDIAPATH.escapeshellarg($file->path)." "._PSTEXTPATH."/".$ptname,$out,$ret);
          if ($ret != 0) throw new Exception("Unable to generate text from document.");
      }
      echo _parseText(file_get_contents(_PSTEXTPATH."/".$ptname));
    }

}

?>
Return current item: mediaIndex