Commit 3c57fe92c2ee4faee3e6800102e9d586337e3fbe

Authored by Jarrett Jordaan
2 parents e1d78b09 7bb07297

Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge

plugins/thumbnails/thumbnails.php
@@ -152,17 +152,17 @@ class thumbnailGenerator extends BaseProcessor @@ -152,17 +152,17 @@ class thumbnailGenerator extends BaseProcessor
152 $pdfFile = $pdfDir . DIRECTORY_SEPARATOR . $this->document->getStoragePath(); 152 $pdfFile = $pdfDir . DIRECTORY_SEPARATOR . $this->document->getStoragePath();
153 }else{ 153 }else{
154 $pdfDir = $default->pdfDirectory; 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 //if thumbail dir does not exist, generate one and add an index file to block access 161 //if thumbail dir does not exist, generate one and add an index file to block access
162 if (!file_exists($thumbnaildir)) { 162 if (!file_exists($thumbnaildir)) {
163 mkdir($thumbnaildir, 0755); 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 // if there is no pdf that exists - hop out 168 // if there is no pdf that exists - hop out
@@ -180,9 +180,13 @@ class thumbnailGenerator extends BaseProcessor @@ -180,9 +180,13 @@ class thumbnailGenerator extends BaseProcessor
180 $pathConvert = (!empty($default->convertPath)) ? $default->convertPath : 'convert'; 180 $pathConvert = (!empty($default->convertPath)) ? $default->convertPath : 'convert';
181 // windows path may contain spaces 181 // windows path may contain spaces
182 if (WINDOWS_OS) { 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 return true; 190 return true;
187 //}else{ 191 //}else{
188 //$default->log->debug('Thumbnail Generator Plugin: Imagemagick not installed, cannot generate a thumbnail'); 192 //$default->log->debug('Thumbnail Generator Plugin: Imagemagick not installed, cannot generate a thumbnail');
@@ -216,7 +220,7 @@ class ThumbnailViewlet extends KTDocumentViewlet { @@ -216,7 +220,7 @@ class ThumbnailViewlet extends KTDocumentViewlet {
216 // Check for the thumbnail 220 // Check for the thumbnail
217 global $default; 221 global $default;
218 $varDir = $default->internalVarDirectory; 222 $varDir = $default->internalVarDirectory;
219 - $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg'; 223 + $thumbnailfile = $varDir . DIRECTORY_SEPARATOR . 'thumbnails'. DIRECTORY_SEPARATOR .$documentId.'.jpg';
220 224
221 // if the thumbnail doesn't exist try to create it 225 // if the thumbnail doesn't exist try to create it
222 if (!file_exists($thumbnailfile)){ 226 if (!file_exists($thumbnailfile)){
@@ -251,7 +255,7 @@ class ThumbnailViewlet extends KTDocumentViewlet { @@ -251,7 +255,7 @@ class ThumbnailViewlet extends KTDocumentViewlet {
251 public function get_width($documentId){ 255 public function get_width($documentId){
252 global $default; 256 global $default;
253 $varDir = $default->internalVarDirectory; 257 $varDir = $default->internalVarDirectory;
254 - $thumbnailfile = $varDir . '/thumbnails/'.$documentId.'.jpg'; 258 + $thumbnailfile = $varDir . DIRECTORY_SEPARATOR.'thumbnails'.DIRECTORY_SEPARATOR.$documentId.'.jpg';
255 $size = getimagesize($thumbnailfile); 259 $size = getimagesize($thumbnailfile);
256 return $size[0]; 260 return $size[0];
257 } 261 }