From b773f7dd8bfa74a5a0fee6f614da1f9b3a2fff86 Mon Sep 17 00:00:00 2001 From: Paul Barrett Date: Fri, 25 Sep 2009 13:20:53 +0200 Subject: [PATCH] Added config settings for imagemagick and pdf2swf. Use the imagemagick config setting to create thumbnail --- lib/config/config.inc.php | 15 +++++++++------ plugins/thumbnails/thumbnails.php | 5 ++--- sql/mysql/upgrade/3.7.0/config_settings.sql | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 sql/mysql/upgrade/3.7.0/config_settings.sql diff --git a/lib/config/config.inc.php b/lib/config/config.inc.php index ecd552e..a594d6e 100644 --- a/lib/config/config.inc.php +++ b/lib/config/config.inc.php @@ -73,7 +73,8 @@ class KTConfig { } // FIXME nbm: how do we cache errors here? - function loadCache() { + function loadCache() + { $filename = $this->getCacheFilename(); if($filename === false){ return false; @@ -93,7 +94,8 @@ class KTConfig { return true; } - function createCache() { + function createCache() + { $filename = $this->getCacheFilename(); $config_cache = array(); @@ -119,20 +121,21 @@ class KTConfig { } // {{{ readConfig - function readConfig () { + function readConfig () + { //Load config data from the database $sQuery = 'select group_name, item, value, default_value from config_settings'; $confResult = DBUtil::getResultArray($sQuery); - if(PEAR::isError($confResult)){ + if(PEAR::isError($confResult)) { return $confResult; } // Update the config array - overwrite the current settings with the settings in the database. - foreach ($confResult as $confItem) - { + foreach ($confResult as $confItem) { $this->setns($confItem['group_name'], $confItem['item'], $confItem['value'], $confItem['default_value']); } + $this->populateDefault(); } // }}} diff --git a/plugins/thumbnails/thumbnails.php b/plugins/thumbnails/thumbnails.php index bcc1134..de9592d 100755 --- a/plugins/thumbnails/thumbnails.php +++ b/plugins/thumbnails/thumbnails.php @@ -141,8 +141,7 @@ class thumbnailGenerator extends BaseProcessor { } // if there is no pdf that exists - hop out - if(!file_exists($pdfFile)){ - global $default; + if(!file_exists($pdfFile)) { $default->log->debug('Thumbnail Generator Plugin: PDF file does not exist, cannot generate a thumbnail'); return false; } @@ -154,7 +153,7 @@ class thumbnailGenerator extends BaseProcessor { // do generation if (extension_loaded('imagick')) { - $result= shell_exec("convert -size 200x200 {$pdfFile}[0] -resize 200x200 $thumbnailfile"); + $result= KTUtil::pexec("\"{$default->imagemagick}\" -size 200x200 \"{$pdfFile}[0]\" -resize 230x200 \"$thumbnailfile\""); return true; }else{ $default->log->debug('Thumbnail Generator Plugin: Imagemagick not installed, cannot generate a thumbnail'); diff --git a/sql/mysql/upgrade/3.7.0/config_settings.sql b/sql/mysql/upgrade/3.7.0/config_settings.sql new file mode 100644 index 0000000..8913e1b --- /dev/null +++ b/sql/mysql/upgrade/3.7.0/config_settings.sql @@ -0,0 +1,31 @@ +INSERT INTO `dms`.`config_settings` ( +`id` , +`group_name` , +`display_name` , +`description` , +`item` , +`value` , +`default_value` , +`type` , +`options` , +`can_edit` +) +VALUES ( +NULL , 'externalBinary', 'image magick', 'Path to binary', 'imagemagick', 'default', 'convert', 'string', NULL , '1' +); + +INSERT INTO `dms`.`config_settings` ( +`id` , +`group_name` , +`display_name` , +`description` , +`item` , +`value` , +`default_value` , +`type` , +`options` , +`can_edit` +) +VALUES ( +NULL , 'externalBinary', 'pdf2swf', 'Path to binary', 'pdf2swf', 'default', 'pdf2swf', 'string', NULL , '1' +); \ No newline at end of file -- libgit2 0.21.4