diff --git a/bin/openoffice/pdfgen.py b/bin/openoffice/pdfgen.py
index 5d2455d..4273081 100755
--- a/bin/openoffice/pdfgen.py
+++ b/bin/openoffice/pdfgen.py
@@ -84,7 +84,7 @@ except RuntimeException, e:
sys.stderr.write("An unknown error occured: " + e.Message + "\n")
if doc == None:
- sys.stderr.write("Could not load doc.\n")
+ sys.stderr.write("OpenOffice could not load the document for conversion. This could indicate an unsupported minetype.\n")
sys.exit(1)
diff --git a/config/config.ini b/config/config.ini
index 91d068a..7caf66a 100644
--- a/config/config.ini
+++ b/config/config.ini
@@ -311,7 +311,6 @@ port = default
[user_prefs]
; minimum password length on password-setting
-; could be moved into DB-auth-config
passwordLength = 6
; apply the minimum password length to admin while creating / editing accounts?
diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php
index b0a979e..054555a 100644
--- a/config/dmsDefaults.php
+++ b/config/dmsDefaults.php
@@ -76,13 +76,14 @@ if (!defined('KT_LIB_DIR')) {
define('KT_LIB_DIR', KT_DIR . '/lib');
}
-// If not defined, set KT_INSTALL_DIR based on my usual location in the tree
-if (!defined('KT_INSTALL_DIR')) {
- $installLoc = realpath(dirname(__FILE__) . '/../..');
+// If not defined, set KT_STACK_DIR based on my usual location in the tree
+// TODO: This needs to use a config.ini entry if available
+if (!defined('KT_STACK_DIR')) {
+ $stackLoc = realpath(dirname(__FILE__) . '/../..');
if (substr(PHP_OS, 0, 3) == 'WIN') {
- $installLoc = str_replace('\\','/',$installLoc);
+ $stackLoc = str_replace('\\','/',$stackLoc);
}
- define('KT_INSTALL_DIR', $installLoc);
+ define('KT_STACK_DIR', $stackLoc);
}
diff --git a/lib/upgrades/UpgradeFunctions.inc.php b/lib/upgrades/UpgradeFunctions.inc.php
index 0b4aab0..958842d 100644
--- a/lib/upgrades/UpgradeFunctions.inc.php
+++ b/lib/upgrades/UpgradeFunctions.inc.php
@@ -1040,16 +1040,16 @@ class UpgradeFunctions {
// externalBinary Section
$ini->delSection('externalBinary');
if(OS_WINDOWS){
- $ini->addItem('externalBinary', 'xls2csv', KT_INSTALL_DIR . '/bin/catdoc/xls2csv.exe', '', 'The following are external binaries that may be used by various parts of knowledgeTree.');
- $ini->addItem('externalBinary', 'pdftotext', KT_INSTALL_DIR . '/bin/xpdf/pdftotext.exe');
- $ini->addItem('externalBinary', 'catppt', KT_INSTALL_DIR . '/bin/catdoc/catppt.exe');
- $ini->addItem('externalBinary', 'pstotext', KT_INSTALL_DIR . '/pstotext');
- $ini->addItem('externalBinary', 'catdoc', KT_INSTALL_DIR . '/bin/catdoc/catdoc.exe');
- $ini->addItem('externalBinary', 'antiword', KT_INSTALL_DIR . '/bin/antiword/antiword.exe');
- $ini->addItem('externalBinary', 'python', KT_INSTALL_DIR . '/python.bat');
- $ini->addItem('externalBinary', 'java', KT_INSTALL_DIR . '/java/jre/bin/java.exe');
- $ini->addItem('externalBinary', 'php', KT_INSTALL_DIR . '/php/php.exe');
- $ini->addItem('externalBinary', 'df', KT_INSTALL_DIR . '/bin/gnuwin32/df.exe');
+ $ini->addItem('externalBinary', 'xls2csv', KT_STACK_DIR . '/bin/catdoc/xls2csv.exe', '', 'The following are external binaries that may be used by various parts of knowledgeTree.');
+ $ini->addItem('externalBinary', 'pdftotext', KT_STACK_DIR . '/bin/xpdf/pdftotext.exe');
+ $ini->addItem('externalBinary', 'catppt', KT_STACK_DIR . '/bin/catdoc/catppt.exe');
+ $ini->addItem('externalBinary', 'pstotext', KT_STACK_DIR . '/bin/pstotext/pstotext.exe');
+ $ini->addItem('externalBinary', 'catdoc', KT_STACK_DIR . '/bin/catdoc/catdoc.exe');
+ $ini->addItem('externalBinary', 'antiword', KT_STACK_DIR . '/bin/antiword/antiword.exe');
+ $ini->addItem('externalBinary', 'python', KT_STACK_DIR . '/openoffice/program/python.bat');
+ $ini->addItem('externalBinary', 'java', KT_STACK_DIR . '/java/jre/bin/java.exe');
+ $ini->addItem('externalBinary', 'php', KT_STACK_DIR . '/php/php.exe');
+ $ini->addItem('externalBinary', 'df', KT_STACK_DIR . '/bin/gnuwin32/df.exe');
} else {
$ini->addItem('externalBinary', 'xls2csv', 'xls2csv', '', 'The following are external binaries that may be used by various parts of knowledgeTree.');
@@ -1057,7 +1057,7 @@ class UpgradeFunctions {
$ini->addItem('externalBinary', 'catppt', 'catppt');
$ini->addItem('externalBinary', 'pstotext', 'pstotext');
$ini->addItem('externalBinary', 'catdoc', 'catdoc');
- $ini->addItem('externalBinary', 'antiword', '');
+ $ini->addItem('externalBinary', 'antiword', 'antiword');
$ini->addItem('externalBinary', 'python', 'python');
$ini->addItem('externalBinary', 'java', 'java');
$ini->addItem('externalBinary', 'php', 'php');
diff --git a/lib/util/ktutil.inc b/lib/util/ktutil.inc
index b265414..a8db060 100644
--- a/lib/util/ktutil.inc
+++ b/lib/util/ktutil.inc
@@ -704,7 +704,7 @@ class KTUtil {
case 'externalBinary/python':
if (OS_WINDOWS)
{
- $script = $stackPath . '/openoffice/openoffice/program/python.bat';
+ $script = $stackPath . '/openoffice/program/python.bat';
}
else
{
diff --git a/plugins/ktstandard/PDFGeneratorAction.php b/plugins/ktstandard/PDFGeneratorAction.php
index 97a380c..2ed1148 100644
--- a/plugins/ktstandard/PDFGeneratorAction.php
+++ b/plugins/ktstandard/PDFGeneratorAction.php
@@ -58,25 +58,23 @@ class PDFGeneratorAction extends KTDocumentAction {
'odp', 'otp', 'sxi', 'sti', 'ppt', 'pot', 'sxd', 'odg',
'otg', 'std', 'asc');
+ function getName() {
+ return 'PDF Generator';
+ }
+
function getDisplayName() {
- // We need to handle Windows differently - as usual ;)
- if (substr( PHP_OS, 0, 3) == 'WIN') {
- $cmdpath = KT_DIR . "/../openoffice/openoffice/program/python.bat";
- $cmdpath = str_replace( '/','\\',$cmdpath);
- } else {
- $cmdpath = "../openoffice/program/python";
- }
+ $cmdpath = KTUtil::findCommand('externalBinary/python');
// Check if openoffice and python are available
- if(file_exists($cmdpath)) {
+ if($cmdpath != false && file_exists($cmdpath) && !empty($cmdpath)) {
$sDocType = $this->getMimeExtension();
- // make sure that the selected document id of an acceptable extension
+ // make sure that the selected document is of an acceptable extension
foreach($this->aAcceptedMimeTypes as $acceptType){
if($acceptType == $sDocType){
return _kt('Generate PDF') . " $this->oDocument->getId(), "action" => "pdfdownload") ) . "\"
";
}
}
}
- return 'PDF Generator';
+ return '';
}
function form_main() {
@@ -174,6 +172,14 @@ class PDFGeneratorAction extends KTDocumentAction {
$oDocument = $this->oDocument;
$oStorage =& KTStorageManagerUtil::getSingleton();
$oConfig =& KTConfig::getSingleton();
+ $cmdpath = KTUtil::findCommand('externalBinary/python');
+ // Check if openoffice and python are available
+ if($cmdpath == false || !file_exists($cmdpath) || empty($cmdpath)) {
+ // Set the error messsage and redirect to view document
+ $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. Python binary not found.'));
+ redirect(generateControllerLink('viewDocument',sprintf('fDocumentId=%d',$oDocument->getId())));
+ exit(0);
+ }
//get the actual path to the document on the server
$sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $oStorage->getPath($oDocument));
@@ -186,7 +192,7 @@ class PDFGeneratorAction extends KTDocumentAction {
// We need to handle Windows differently - as usual ;)
if (substr( PHP_OS, 0, 3) == 'WIN') {
- $cmd = "\"" . KT_DIR . "/../openoffice/openoffice/program/python.bat\" \"". KT_DIR . "/bin/openoffice/pdfgen.py\" \"" . $sPath . "\" \"" . $sTempFilename . "\"";
+ $cmd = "\"" . $cmdpath . "\" \"". KT_DIR . "/bin/openoffice/pdfgen.py\" \"" . $sPath . "\" \"" . $sTempFilename . "\"";
$cmd = str_replace( '/','\\',$cmd);
// TODO: Check for more errors here
@@ -202,7 +208,7 @@ class PDFGeneratorAction extends KTDocumentAction {
// TODO: Check for more errors here
// SECURTIY: Ensure $sPath and $sTempFilename are safe or they could be used to excecute arbitrary commands!
// Excecute the python script.
- $cmd = '../openoffice/program/python bin/openoffice/pdfgen.py ' . escapeshellcmd($sPath) . ' ' . escapeshellcmd($sTempFilename);
+ $cmd = $cmdpath . ' ' . KT_DIR . '/bin/openoffice/pdfgen.py ' . escapeshellcmd($sPath) . ' ' . escapeshellcmd($sTempFilename);
$res = shell_exec($cmd." 2>&1");
//print($res);
//print($cmd);
@@ -245,15 +251,15 @@ class PDFGeneratorAction extends KTDocumentAction {
} else {
// Set the error messsage and redirect to view document
- $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator.
' . $res));
- redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId())));
+ $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. ' . $res));
+ redirect(generateControllerLink('viewDocument',sprintf('fDocumentId=%d',$oDocument->getId())));
exit(0);
}
} else {
// Set the error messsage and redirect to view document
- $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator.
The path to the document did not exist.'));
- redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId())));
+ $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. The path to the document did not exist.'));
+ redirect(generateControllerLink('viewDocument',sprintf('fDocumentId=%d',$oDocument->getId())));
exit(0);
}