mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 17:44:56 +00:00
new method getPreviewFile(), start version 1.13.0
This commit is contained in:
parent
74300082fc
commit
e830477bf0
|
@ -50,6 +50,12 @@ class SeedDMS_Preview_Base {
|
||||||
*/
|
*/
|
||||||
protected $xsendfile;
|
protected $xsendfile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string $lastpreviewfile will be set to the file name of the last preview
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $lastpreviewfile;
|
||||||
|
|
||||||
function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */
|
function __construct($previewDir, $timeout=5, $xsendfile=true) { /* {{{ */
|
||||||
if(!is_dir($previewDir)) {
|
if(!is_dir($previewDir)) {
|
||||||
if (!SeedDMS_Core_File::makeDir($previewDir)) {
|
if (!SeedDMS_Core_File::makeDir($previewDir)) {
|
||||||
|
@ -154,14 +160,14 @@ class SeedDMS_Preview_Base {
|
||||||
return array_key_exists($mimetype, $this->converters) && $this->converters[$mimetype];
|
return array_key_exists($mimetype, $this->converters) && $this->converters[$mimetype];
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a file from disk to the browser
|
* Send a file from disk to the browser
|
||||||
*
|
*
|
||||||
* This function uses either readfile() or the xѕendfile apache module if
|
* This function uses either readfile() or the xѕendfile apache module if
|
||||||
* it is installed.
|
* it is installed.
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
*/
|
*/
|
||||||
protected function sendFile($filename) { /* {{{ */
|
protected function sendFile($filename) { /* {{{ */
|
||||||
if($this->xsendfile && function_exists('apache_get_modules') && in_array('mod_xsendfile',apache_get_modules())) {
|
if($this->xsendfile && function_exists('apache_get_modules') && in_array('mod_xsendfile',apache_get_modules())) {
|
||||||
header("X-Sendfile: ".$filename);
|
header("X-Sendfile: ".$filename);
|
||||||
|
@ -173,5 +179,14 @@ class SeedDMS_Preview_Base {
|
||||||
readfile($filename);
|
readfile($filename);
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return path of last created preview file
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPreviewFile() { /* {{{ */
|
||||||
|
return $this->lastpreviewfile;
|
||||||
|
} /* }}} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
|
||||||
return false;
|
return false;
|
||||||
if(!$target)
|
if(!$target)
|
||||||
$target = $this->previewDir.$dir.md5($infile);
|
$target = $this->previewDir.$dir.md5($infile);
|
||||||
|
$this->lastpreviewfile = $target.'.png';
|
||||||
if($target != '' && (!file_exists($target.'.pdf') || filectime($target.'.pdf') < filectime($infile))) {
|
if($target != '' && (!file_exists($target.'.pdf') || filectime($target.'.pdf') < filectime($infile))) {
|
||||||
$cmd = '';
|
$cmd = '';
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
|
@ -110,6 +111,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
|
||||||
try {
|
try {
|
||||||
self::execWithTimeout($cmd, $this->timeout);
|
self::execWithTimeout($cmd, $this->timeout);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
$this->lastpreviewfile = '';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
|
||||||
return false;
|
return false;
|
||||||
if(!$target)
|
if(!$target)
|
||||||
$target = $this->previewDir.$dir.md5($infile).'-'.$width;
|
$target = $this->previewDir.$dir.md5($infile).'-'.$width;
|
||||||
|
$this->lastpreviewfile = $target.'.png';
|
||||||
if($target != '' && (!file_exists($target.'.png') || filectime($target.'.png') < filectime($infile))) {
|
if($target != '' && (!file_exists($target.'.png') || filectime($target.'.png') < filectime($infile))) {
|
||||||
$cmd = '';
|
$cmd = '';
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
|
@ -120,6 +121,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
|
||||||
try {
|
try {
|
||||||
self::execWithTimeout($cmd, $this->timeout);
|
self::execWithTimeout($cmd, $this->timeout);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
$this->lastpreviewfile = '';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
<email>uwe@steinmann.cx</email>
|
<email>uwe@steinmann.cx</email>
|
||||||
<active>yes</active>
|
<active>yes</active>
|
||||||
</lead>
|
</lead>
|
||||||
<date>2019-02-11</date>
|
<date>2020-01-21</date>
|
||||||
<time>10:59:39</time>
|
<time>10:59:39</time>
|
||||||
<version>
|
<version>
|
||||||
<release>1.2.10</release>
|
<release>1.3.0</release>
|
||||||
<api>1.2.10</api>
|
<api>1.3.0</api>
|
||||||
</version>
|
</version>
|
||||||
<stability>
|
<stability>
|
||||||
<release>stable</release>
|
<release>stable</release>
|
||||||
|
@ -23,8 +23,7 @@
|
||||||
</stability>
|
</stability>
|
||||||
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||||
<notes>
|
<notes>
|
||||||
new parameter for enabling/disabling xsendfile
|
add new methode getPreviewFile()
|
||||||
fix creation of pdf preview if document content class is not SeedDMS_Core_DocumentContent
|
|
||||||
</notes>
|
</notes>
|
||||||
<contents>
|
<contents>
|
||||||
<dir baseinstalldir="SeedDMS" name="/">
|
<dir baseinstalldir="SeedDMS" name="/">
|
||||||
|
@ -404,5 +403,22 @@ make sure list of converters is always an array
|
||||||
usage of mod_sendfile can be configured
|
usage of mod_sendfile can be configured
|
||||||
</notes>
|
</notes>
|
||||||
</release>
|
</release>
|
||||||
|
<release>
|
||||||
|
<date>2019-02-11</date>
|
||||||
|
<time>10:59:39</time>
|
||||||
|
<version>
|
||||||
|
<release>1.2.10</release>
|
||||||
|
<api>1.2.10</api>
|
||||||
|
</version>
|
||||||
|
<stability>
|
||||||
|
<release>stable</release>
|
||||||
|
<api>stable</api>
|
||||||
|
</stability>
|
||||||
|
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||||
|
<notes>
|
||||||
|
new parameter for enabling/disabling xsendfile
|
||||||
|
fix creation of pdf preview if document content class is not SeedDMS_Core_DocumentContent
|
||||||
|
</notes>
|
||||||
|
</release>
|
||||||
</changelog>
|
</changelog>
|
||||||
</package>
|
</package>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user