Commit 3c57fe92c2ee4faee3e6800102e9d586337e3fbe
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
1 changed file
with
13 additions
and
9 deletions
plugins/thumbnails/thumbnails.php
| ... | ... | @@ -152,17 +152,17 @@ class thumbnailGenerator extends BaseProcessor |
| 152 | 152 | $pdfFile = $pdfDir . DIRECTORY_SEPARATOR . $this->document->getStoragePath(); |
| 153 | 153 | }else{ |
| 154 | 154 | $pdfDir = $default->pdfDirectory; |
| 155 | - $pdfFile = $pdfDir .'/'. $this->document->iId.'.pdf'; | |
| 155 | + $pdfFile = $pdfDir .DIRECTORY_SEPARATOR. $this->document->iId.'.pdf'; | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $thumbnaildir = $default->internalVarDirectory.'/thumbnails'; | |
| 159 | - $thumbnailfile = $thumbnaildir.'/'.$this->document->iId.'.jpg'; | |
| 158 | + $thumbnaildir = $default->internalVarDirectory.DIRECTORY_SEPARATOR.'thumbnails'; | |
| 159 | + $thumbnailfile = $thumbnaildir.DIRECTORY_SEPARATOR.$this->document->iId.'.jpg'; | |
| 160 | 160 | |
| 161 | 161 | //if thumbail dir does not exist, generate one and add an index file to block access |
| 162 | 162 | if (!file_exists($thumbnaildir)) { |
| 163 | 163 | mkdir($thumbnaildir, 0755); |
| 164 | - touch($thumbnaildir.'/index.html'); | |
| 165 | - file_put_contents($thumbnaildir.'/index.html', 'You do not have permission to access this directory.'); | |
| 164 | + touch($thumbnaildir.DIRECTORY_SEPARATOR.'index.html'); | |
| 165 | + file_put_contents($thumbnaildir.DIRECTORY_SEPARATOR.'index.html', 'You do not have permission to access this directory.'); | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // if there is no pdf that exists - hop out |
| ... | ... | @@ -180,9 +180,13 @@ class thumbnailGenerator extends BaseProcessor |
| 180 | 180 | $pathConvert = (!empty($default->convertPath)) ? $default->convertPath : 'convert'; |
| 181 | 181 | // windows path may contain spaces |
| 182 | 182 | if (WINDOWS_OS) { |
| 183 | - $pathConvert = '"' . $pathConvert . '"'; | |
| 183 | + $cmd = "\"{$pathConvert}\" -size 200x200 \"{$pdfFile}[0]\" -resize 200x200 \"$thumbnailfile\""; | |
| 184 | 184 | } |
| 185 | - $result = KTUtil::pexec("{$pathConvert} -size 200x200 {$pdfFile}[0] -resize 200x200 $thumbnailfile"); | |
| 185 | + else { | |
| 186 | + $cmd = "{$pathConvert} -size 200x200 {$pdfFile}[0] -resize 200x200 $thumbnailfile"; | |
| 187 | + } | |
| 188 | + | |
| 189 | + $result = KTUtil::pexec($cmd); | |
| 186 | 190 | return true; |
| 187 | 191 | //}else{ |
| 188 | 192 | //$default->log->debug('Thumbnail Generator Plugin: Imagemagick not installed, cannot generate a thumbnail'); |
| ... | ... | @@ -216,7 +220,7 @@ class ThumbnailViewlet extends KTDocumentViewlet { |
| 216 | 220 | // Check for the thumbnail |
| 217 | 221 | global $default; |
| 218 | 222 | $varDir = $default->internalVarDirectory; |
| 219 | - $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg'; | |
| 223 | + $thumbnailfile = $varDir . DIRECTORY_SEPARATOR . 'thumbnails'. DIRECTORY_SEPARATOR .$documentId.'.jpg'; | |
| 220 | 224 | |
| 221 | 225 | // if the thumbnail doesn't exist try to create it |
| 222 | 226 | if (!file_exists($thumbnailfile)){ |
| ... | ... | @@ -251,7 +255,7 @@ class ThumbnailViewlet extends KTDocumentViewlet { |
| 251 | 255 | public function get_width($documentId){ |
| 252 | 256 | global $default; |
| 253 | 257 | $varDir = $default->internalVarDirectory; |
| 254 | - $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg'; | |
| 258 | + $thumbnailfile = $varDir . DIRECTORY_SEPARATOR.'thumbnails'.DIRECTORY_SEPARATOR.$documentId.'.jpg'; | |
| 255 | 259 | $size = getimagesize($thumbnailfile); |
| 256 | 260 | return $size[0]; |
| 257 | 261 | } | ... | ... |