Commit 974292b9d3b74de56487a6f1ef47fb8d634b4d7a

Authored by Prince Mbekwa
1 parent 7bb38071

fixed linux paths and added php OS checks

plugins/thumbnails/thumbnails.php
... ... @@ -155,25 +155,21 @@ class thumbnailGenerator extends BaseProcessor
155 155 $pdfFile = $pdfDir .DIRECTORY_SEPARATOR. $this->document->iId.'.pdf';
156 156 }
157 157  
158   - $pdfFile = str_replace('/', '\\', $pdfFile);
159   -
160 158 $thumbnaildir = $default->internalVarDirectory.DIRECTORY_SEPARATOR.'thumbnails';
161   - if (WINDOWS_OS) {
  159 +
  160 + if (stristr(PHP_OS,'WIN')) {
162 161 $thumbnaildir = str_replace('/', '\\', $thumbnaildir);
  162 + $pdfFile = str_replace('/', '\\', $pdfFile);
163 163 }
164 164  
165 165 if (!preg_match('/' . str_replace('/', '\/', str_replace('\\', '\\\\', KT_DIR)) . '/', $thumbnaildir))
166 166 {
167   - if (WINDOWS_OS) {
  167 + if (stristr(PHP_OS,'WIN')) {
168 168 $thumbnaildir = KT_DIR . '\\' . trim($thumbnaildir, '\\');
169 169 }
170   - else {
171   - $thumbnaildir = KT_DIR . '/' . trim($thumbnaildir, '/');
172   - }
173 170 }
174 171  
175 172 $thumbnailfile = $thumbnaildir.DIRECTORY_SEPARATOR.$this->document->iId.'.jpg';
176   -
177 173 //if thumbail dir does not exist, generate one and add an index file to block access
178 174 if (!file_exists($thumbnaildir)) {
179 175 mkdir($thumbnaildir, 0755);
... ... @@ -186,7 +182,6 @@ class thumbnailGenerator extends BaseProcessor
186 182 $default->log->debug('Thumbnail Generator Plugin: PDF file does not exist, cannot generate a thumbnail');
187 183 return false;
188 184 }
189   -
190 185 // if a previous version of the thumbnail exists - delete it
191 186 if (file_exists($thumbnailfile)) {
192 187 @unlink($thumbnailfile);
... ... @@ -196,13 +191,12 @@ class thumbnailGenerator extends BaseProcessor
196 191 $pathConvert = (!empty($default->convertPath)) ? $default->convertPath : 'convert';
197 192 // windows path may contain spaces
198 193  
199   - if (WINDOWS_OS) {
  194 + if (stristr(PHP_OS,'WIN')) {
200 195 $cmd = "\"{$pathConvert}\" -size 200x200 \"{$pdfFile}[0]\" -resize 200x200 \"$thumbnailfile\"";
201 196 }
202 197 else {
203 198 $cmd = "{$pathConvert} -size 200x200 {$pdfFile}[0] -resize 200x200 $thumbnailfile";
204 199 }
205   -
206 200 $result = KTUtil::pexec($cmd);
207 201 return true;
208 202 //}else{
... ... @@ -239,18 +233,15 @@ class ThumbnailViewlet extends KTDocumentViewlet {
239 233 $varDir = $default->internalVarDirectory;
240 234 $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg';
241 235  
242   - if (WINDOWS_OS) {
  236 + if (stristr(PHP_OS,'WIN')) {
243 237 $varDir = str_replace('/', '\\', $varDir);
244 238 }
245 239  
246 240 if (!preg_match('/' . str_replace('/', '\/', str_replace('\\', '\\\\', KT_DIR)) . '/', $thumbnaildir))
247 241 {
248   - if (WINDOWS_OS) {
  242 + if (stristr(PHP_OS,'WIN')) {
249 243 $varDir = KT_DIR . '\\' . trim($varDir, '\\');
250 244 }
251   - else {
252   - $varDir = KT_DIR . '/' . trim($varDir, '/');
253   - }
254 245 }
255 246  
256 247 $thumbnailCheck = $varDir . '/thumbnails/'.$documentId.'.jpg';
... ... @@ -294,4 +285,4 @@ class ThumbnailViewlet extends KTDocumentViewlet {
294 285 }
295 286 }
296 287  
297   -?>
298 288 \ No newline at end of file
  289 +?>
... ...