00001 <?php 00002 // 00003 // Definition of eZWordParser class 00004 // 00005 // Created on: <17-Jun-2003 09:33:14 bf> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ publish 00009 // SOFTWARE RELEASE: 3.9.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! 00032 \class eZWordParser ezwordparser.php 00033 \ingroup eZKernel 00034 \brief The class eZWordParser handles parsing of Word files and returns the metadata 00035 00036 */ 00037 00038 class eZWordParser 00039 { 00040 function &parseFile( $fileName ) 00041 { 00042 $binaryINI =& eZINI::instance( 'binaryfile.ini' ); 00043 00044 $textExtractionTool = $binaryINI->variable( 'WordHandlerSettings', 'TextExtractionTool' ); 00045 00046 $tmpName = "var/cache/" . md5( mktime() ) . '.txt'; 00047 $handle = fopen( $tmpName, "w" ); 00048 fclose( $handle ); 00049 chmod( $tmpName, 0777 ); 00050 00051 exec( "$textExtractionTool $fileName > $tmpName", $ret ); 00052 00053 $metaData = ""; 00054 if ( file_exists( $tmpName ) ) 00055 { 00056 $fp = fopen( $tmpName, "r" ); 00057 $metaData = fread( $fp, filesize( $tmpName ) ); 00058 $metaData = strip_tags( $metaData ); 00059 fclose( $fp ); 00060 unlink( $tmpName ); 00061 } 00062 00063 return $metaData; 00064 } 00065 } 00066 00067 ?>
1.6.3