Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
word_doc.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/files/file/file.inc';
19 require_once SQ_DATA_PATH.'/private/conf/tools.inc';
20 
21 
33 class Word_Doc extends File
34 {
35 
36 
45  public $allowed_extensions = Array('doc', 'dot', 'docx', 'docm', 'dotx', 'dotm');
46 
47 
54  function __construct($assetid=0)
55  {
56  parent::__construct($assetid);
57 
58  }//end constructor
59 
60 
67  function getContent()
68  {
69  $file_info = $this->getExistingFile();
70  if (empty($file_info)) return '';
71  $file = $file_info['path'];
72  $file = str_replace('"', '\\\"', $file);
73 
74  $content = '';
75  if (SQ_TOOL_ANTIWORD_ENABLED) {
76  // Run a program that converts Word doc to text, set environment variable of bin_path
77  $cmd = 'ANTIWORDHOME='.SQ_TOOL_ANTIWORD_MAPPING_PATH.' '.SQ_TOOL_ANTIWORD_PATH.' '.$file;
78  $content = shell_exec($cmd);
79 
80  }
81 
82  if (!$content) return '';
83 
84  // strip out the whitespace
85  $content = strtolower(trim(preg_replace('/[\s]+/', ' ', $content)));
86 
87  return $content;
88 
89  }//end getContent()
90 
91 
92 }//end class
93 ?>