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