use DIRECTORY_SEPARATOR, add prefix 'png', 'txt', 'pdf' to previewDir

This commit is contained in:
Uwe Steinmann 2023-01-05 15:08:05 +01:00
parent ba8a2d5d87
commit 58fd8877fb
2 changed files with 10 additions and 19 deletions

View File

@ -25,7 +25,7 @@
class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base { class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */ function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */
parent::__construct($previewDir, $timeout, $xsendfile); parent::__construct($previewDir.DIRECTORY_SEPARATOR.'pdf', $timeout, $xsendfile);
$this->converters = array( $this->converters = array(
); );
} /* }}} */ } /* }}} */
@ -43,7 +43,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
$document = $object->getDocument(); $document = $object->getDocument();
$dms = $document->_dms; $dms = $document->_dms;
$dir = $this->previewDir.'/'.$document->getDir(); $dir = $this->previewDir.DIRECTORY_SEPARATOR.$document->getDir();
switch(get_class($object)) { switch(get_class($object)) {
case $dms->getClassname('documentcontent'): case $dms->getClassname('documentcontent'):
$target = $dir.'p'.$object->getVersion(); $target = $dir.'p'.$object->getVersion();
@ -90,8 +90,8 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
if(!$this->previewDir) if(!$this->previewDir)
return false; return false;
if(!is_dir($this->previewDir.'/'.$dir)) { if(!is_dir($this->previewDir.DIRECTORY_SEPARATOR.$dir)) {
if (!SeedDMS_Core_File::makeDir($this->previewDir.'/'.$dir)) { if (!SeedDMS_Core_File::makeDir($this->previewDir.DIRECTORY_SEPARATOR.$dir)) {
return false; return false;
} }
} }
@ -297,7 +297,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
if(!$this->previewDir) if(!$this->previewDir)
return false; return false;
$dir = $this->previewDir.'/'.$document->getDir(); $dir = $this->previewDir.DIRECTORY_SEPARATOR.$document->getDir();
if(file_exists($dir) && is_dir($dir)) { if(file_exists($dir) && is_dir($dir)) {
return SeedDMS_Preview_Previewer::recurseRmdir($dir); return SeedDMS_Preview_Previewer::recurseRmdir($dir);
} else { } else {

View File

@ -40,17 +40,8 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
* be used. * be used.
*/ */
function __construct($previewDir, $width=40, $timeout=5, $xsendfile=true) { /* {{{ */ function __construct($previewDir, $width=40, $timeout=5, $xsendfile=true) { /* {{{ */
parent::__construct($previewDir, $timeout, $xsendfile); parent::__construct($previewDir.DIRECTORY_SEPARATOR.'png', $timeout, $xsendfile);
$this->converters = array( $this->converters = array(
'image/png' => "convert -resize %wx '%f' '%o'",
'image/gif' => "convert -resize %wx '%f' '%o'",
'image/jpg' => "convert -resize %wx '%f' '%o'",
'image/jpeg' => "convert -resize %wx '%f' '%o'",
'image/svg+xml' => "convert -resize %wx '%f' '%o'",
'text/plain' => "convert -resize %wx '%f' '%o'",
'application/pdf' => "convert -density 100 -resize %wx '%f[0]' '%o'",
'application/postscript' => "convert -density 100 -resize %wx '%f[0]' '%o'",
'application/x-compressed-tar' => "tar tzvf '%f' | convert -density 100 -resize %wx text:-[0] '%o'",
); );
$this->width = intval($width); $this->width = intval($width);
} /* }}} */ } /* }}} */
@ -74,7 +65,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
$document = $object->getDocument(); $document = $object->getDocument();
$dms = $document->_dms; $dms = $document->_dms;
$dir = $this->previewDir.'/'.$document->getDir(); $dir = $this->previewDir.DIRECTORY_SEPARATOR.$document->getDir();
switch(get_class($object)) { switch(get_class($object)) {
case $dms->getClassname('documentcontent'): case $dms->getClassname('documentcontent'):
$target = $dir.'p'.$object->getVersion().'-'.$width; $target = $dir.'p'.$object->getVersion().'-'.$width;
@ -127,8 +118,8 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
$width = intval($width); $width = intval($width);
if(!$this->previewDir) if(!$this->previewDir)
return false; return false;
if(!is_dir($this->previewDir.'/'.$dir)) { if(!is_dir($this->previewDir.DIRECTORY_SEPARATOR.$dir)) {
if (!SeedDMS_Core_File::makeDir($this->previewDir.'/'.$dir)) { if (!SeedDMS_Core_File::makeDir($this->previewDir.DIRECTORY_SEPARATOR.$dir)) {
return false; return false;
} }
} }
@ -368,7 +359,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
if(!$this->previewDir) if(!$this->previewDir)
return false; return false;
$dir = $this->previewDir.'/'.$document->getDir(); $dir = $this->previewDir.DIRECTORY_SEPARATOR.$document->getDir();
if(file_exists($dir) && is_dir($dir)) { if(file_exists($dir) && is_dir($dir)) {
return SeedDMS_Preview_Previewer::recurseRmdir($dir); return SeedDMS_Preview_Previewer::recurseRmdir($dir);
} else { } else {