diff --git a/lib/mime.inc.php b/lib/mime.inc.php index 9345d31..fb44f32 100644 --- a/lib/mime.inc.php +++ b/lib/mime.inc.php @@ -154,13 +154,35 @@ class KTMime { */ function getMimeTypeFromFile($sFileName) { if (extension_loaded('fileinfo')) { - $oKTConfig =& KTConfig::getSingleton(); - $magicDatabase = $oKTConfig->get('magicDatabase', '/usr/share/file/magic'); - $res = finfo_open(FILEINFO_MIME, $magicDatabase); - $sType = finfo_file($res, $sFileName); + // NOTE: fileinfo doesn't like all magic files. ensure it is pointing to a compatible one if it does not work. + + // first check the path in the stack + $defaultMagicPath = KT_DIR . '/../php/extras/magic'; + $defaultMagicPath = realpath($defaultMagicPath); + + // if not available, attempt path from config + if ($defaultMagicPath === false) { + $oKTConfig =& KTConfig::getSingleton(); + $defaultMagicPath = $oKTConfig->get('magicDatabase'); + + if (!file_exists($defaultMagicPath)) { + $defaultMagicPath = false; + } + } + + // attempt file info if magic file is resolved + if ($defaultMagicPath) { + $res = @finfo_open(FILEINFO_MIME, $defaultMagicPath); + $sType = @finfo_file($res, $sFileName); + + // saw mention that finfo_file() can return empty string under windows + if (empty($sType)) { + $sType = false; + } + } } - if (!$sType) { + if (!$sType && OS_UNIX) { if (file_exists('/usr/bin/file')) { $aCmd = array('/usr/bin/file', '-bi', $sFileName); $sCmd = KTUtil::safeShellString($aCmd); diff --git a/plugins/ktstandard/PDFGeneratorAction.php b/plugins/ktstandard/PDFGeneratorAction.php index de7d3ff..84e60ef 100644 --- a/plugins/ktstandard/PDFGeneratorAction.php +++ b/plugins/ktstandard/PDFGeneratorAction.php @@ -59,10 +59,6 @@ class PDFGeneratorAction extends KTDocumentAction { 'odp', 'otp', 'sxi', 'sti', 'ppt', 'pot', 'sxd', 'odg', 'otg', 'std', 'asc'); - function getName() { - return 'PDF Generator'; - } - function getDisplayName() { $cmdpath = KTUtil::findCommand('externalBinary/python'); // Check if openoffice and python are available @@ -80,6 +76,10 @@ class PDFGeneratorAction extends KTDocumentAction { return _kt('Generate PDF') . " {$icon}"; } } + // If the document is empty then we are probably in the workflow admin - action restrictions section, so we can display the name. + if(empty($this->oDocument)){ + return _kt('Generate PDF'); + } } return ''; } diff --git a/templates/ktcore/workflow/admin/actions_edit.smarty b/templates/ktcore/workflow/admin/actions_edit.smarty index 4fa49ed..ebf8106 100644 --- a/templates/ktcore/workflow/admin/actions_edit.smarty +++ b/templates/ktcore/workflow/admin/actions_edit.smarty @@ -1,6 +1,6 @@
{i18n}Actions which are checked on this page will +
{i18n}Actions which are checked on this page will not be available to users.{/i18n}