diff --git a/src/export.php b/src/export.php index a7a4f9b..3565cc1 100644 --- a/src/export.php +++ b/src/export.php @@ -76,7 +76,16 @@ if ( (isset($_GET['op']) && $_GET['op'] == "export") && (isset($_GET['exporttype']) && array_key_exists($_GET['exporttype'], $content['EXPORTTYPES'])) ) +{ $content['exportformat'] = $_GET['exporttype']; + + // Check for extensions + if ( $content['exportformat'] == EXPORT_PDF && !$content['PDF_IS_ENABLED'] ) + { + $content['error_occured'] = true; + $content['error_details'] = $content['LN_GEN_ERROR_PDFMISSINGEXTENSION']; + } +} else { $content['error_occured'] = true; @@ -405,10 +414,50 @@ else // Set MIME TYPE and File Extension $szOutputMimeType = "application/pdf"; $szOutputFileExtension = ".pdf"; + + try + { + // Init PDF Document + $myPdf = new PDFlib(); + if ($myPdf->begin_document("", "") == 0) { + die("Error: " . $myPdf->get_errmsg()); + } + + $myPdf->set_info("Creator", "hello.php"); + $myPdf->set_info("Author", "Rainer Schaaf"); + $myPdf->set_info("Title", "Hello world (PHP)!"); + + $myPdf->begin_page_ext(595, 842, ""); + + $font = $myPdf->load_font("Helvetica-Bold", "winansi", ""); + + $myPdf->setfont($font, 24.0); + $myPdf->set_text_pos(50, 700); + + $myPdf->show("Hello world!"); + $myPdf->continue_text("(says PHP)"); + $myPdf->end_page_ext(""); + $myPdf->end_document(""); + + // Copy PDF Output + $szOutputContent = $myPdf->get_buffer(); + } + catch (PDFlibException $e) { + die("PDFlib exception occurred in hello sample:\n" . + "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . + $e->get_errmsg() . "\n"); + } + catch (Exception $e) { + die($e); + } + + // Delete PDF Object! + $myPdf = 0; } // Set needed Header properties header('Content-type: ' . $szOutputMimeType . "; " . $szOutputCharset); + header("Content-Length: " . strlen($szOutputContent) ); header('Content-Disposition: attachment; filename="' . $szOutputFileName . $szOutputFileExtension . '"'); // Output Content! diff --git a/src/include/constants_general.php b/src/include/constants_general.php index 0a68e27..09bb19e 100644 --- a/src/include/constants_general.php +++ b/src/include/constants_general.php @@ -72,9 +72,7 @@ define('SOURCE_PDO', '3'); // --- Exportformat defines define('EXPORT_CVS', 'CVS'); define('EXPORT_XML', 'XML'); -define('EXPORT_EXCEL', 'EXCEL'); define('EXPORT_PDF', 'PDF'); -define('EXPORT_HTML', 'HTML'); // --- // --- diff --git a/src/include/functions_common.php b/src/include/functions_common.php index e2329a9..58cc70c 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -334,12 +334,9 @@ function CreateExportFormatList() // Add basic formats! $content['EXPORTTYPES'][EXPORT_CVS] = array( "ID" => EXPORT_CVS, "Selected" => "", "DisplayName" => $content['LN_GEN_EXPORT_CVS'] ); -//TODO $content['EXPORTTYPES'][EXPORT_HTML] = array( "ID" => EXPORT_HTML, "Selected" => "", "DisplayName" => $content['LN_GEN_EXPORT_HTML'] ); -//TODO $content['EXPORTTYPES'][EXPORT_EXCEL] = array( "ID" => EXPORT_EXCEL, "Selected" => "", "DisplayName" => $content['LN_GEN_EXPORT_EXCEL'] ); + $content['EXPORTTYPES'][EXPORT_XML] = array( "ID" => EXPORT_XML, "Selected" => "", "DisplayName" => $content['LN_GEN_EXPORT_XML'] ); // Add formats by loaded extensions - if ( $content['XML_IS_ENABLED'] ) - $content['EXPORTTYPES'][EXPORT_XML] = array( "ID" => EXPORT_XML, "Selected" => "", "DisplayName" => $content['LN_GEN_EXPORT_XML'] ); if ( $content['PDF_IS_ENABLED'] ) $content['EXPORTTYPES'][EXPORT_PDF] = array( "ID" => EXPORT_PDF, "Selected" => "", "DisplayName" => $content['LN_GEN_EXPORT_PDF'] ); @@ -405,31 +402,12 @@ function CheckAndSetRunMode() $content['GD_IS_ENABLED'] = false; // Check MYSQL Extension - if ( in_array("mysql", $loadedExtensions) ) - $content['MYSQL_IS_ENABLED'] = true; - else - $content['MYSQL_IS_ENABLED'] = false; - + if ( in_array("mysql", $loadedExtensions) ) { $content['MYSQL_IS_ENABLED'] = true; } else { $content['MYSQL_IS_ENABLED'] = false; } // Check PDO Extension - if ( in_array("PDO", $loadedExtensions) ) - $content['PDO_IS_ENABLED'] = true; - else - $content['PDO_IS_ENABLED'] = false; - // --- - - // Check XML Extension - if ( in_array("xml", $loadedExtensions) ) - $content['XML_IS_ENABLED'] = true; - else - $content['XML_IS_ENABLED'] = false; - // --- - + if ( in_array("PDO", $loadedExtensions) ) { $content['PDO_IS_ENABLED'] = true; } else { $content['PDO_IS_ENABLED'] = false; } // Check PDF Extension - if ( in_array("pdf", $loadedExtensions) ) - $content['PDF_IS_ENABLED'] = true; - else - $content['PDF_IS_ENABLED'] = false; - // --- + if ( in_array("pdf", $loadedExtensions) ) { $content['PDF_IS_ENABLED'] = true; } else { $content['PDF_IS_ENABLED'] = false; } + } function InitRuntimeInformations() diff --git a/src/lang/de/main.php b/src/lang/de/main.php index bfbed70..4ba1c81 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -79,6 +79,14 @@ $content['LN_ERROR_NORECORDS'] = "Es wurden keine syslog-Einträge gefunden. $content['LN_ERROR_DB_INVALIDDBMAPPING'] = "Invalid datafield mappings"; $content['LN_ERROR_DB_INVALIDDBDRIVER'] = "Invalid database driver selected"; $content['LN_ERROR_DB_TABLENOTFOUND'] = "Could not find the configured table, maybe misspelled or the tablenames are case sensitive"; + $content['LN_GEN_SELECTEXPORT'] = "> Select Exportformat <"; + $content['LN_GEN_EXPORT_CVS'] = "CVS (Comma separated)"; + $content['LN_GEN_EXPORT_XML'] = "XML"; + $content['LN_GEN_EXPORT_PDF'] = "PDF"; + $content['LN_GEN_ERROR_EXPORING'] = "Error exporting data"; + $content['LN_GEN_ERROR_INVALIDEXPORTTYPE'] = "Invalid Export format selected, or other parameters were wrong."; + $content['LN_GEN_ERROR_SOURCENOTFOUND'] = "The Source with ID '%1' could not be found."; + $content['LN_GEN_ERROR_PDFMISSINGEXTENSION'] = "The PDF Extension is missing in your php environment."; // Topmenu Entries $content['LN_MENU_SEARCH'] = "Suchen"; diff --git a/src/lang/en/main.php b/src/lang/en/main.php index c8c3a16..98ec3f9 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -81,13 +81,12 @@ $content['LN_ERROR_DB_INVALIDDBDRIVER'] = "Invalid database driver selected"; $content['LN_ERROR_DB_TABLENOTFOUND'] = "Could not find the configured table, maybe misspelled or the tablenames are case sensitive"; $content['LN_GEN_SELECTEXPORT'] = "> Select Exportformat <"; $content['LN_GEN_EXPORT_CVS'] = "CVS (Comma separated)"; - $content['LN_GEN_EXPORT_HTML'] = "HTML"; $content['LN_GEN_EXPORT_XML'] = "XML"; $content['LN_GEN_EXPORT_PDF'] = "PDF"; - $content['LN_GEN_EXPORT_EXCEL'] = "Excel"; $content['LN_GEN_ERROR_EXPORING'] = "Error exporting data"; $content['LN_GEN_ERROR_INVALIDEXPORTTYPE'] = "Invalid Export format selected, or other parameters were wrong."; $content['LN_GEN_ERROR_SOURCENOTFOUND'] = "The Source with ID '%1' could not be found."; + $content['LN_GEN_ERROR_PDFMISSINGEXTENSION'] = "The PDF Extension is missing in your php environment."; // Topmenu Entries $content['LN_MENU_SEARCH'] = "Search"; diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index 4f66f2d..9f57af0 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -83,6 +83,14 @@ $content['LN_ERROR_NORECORDS'] = "Sem mensagens encontradas."; $content['LN_ERROR_DB_INVALIDDBMAPPING'] = "Invalid datafield mappings"; $content['LN_ERROR_DB_INVALIDDBDRIVER'] = "Invalid database driver selected"; $content['LN_ERROR_DB_TABLENOTFOUND'] = "Could not find the configured table, maybe misspelled or the tablenames are case sensitive"; + $content['LN_GEN_SELECTEXPORT'] = "> Select Exportformat <"; + $content['LN_GEN_EXPORT_CVS'] = "CVS (Comma separated)"; + $content['LN_GEN_EXPORT_XML'] = "XML"; + $content['LN_GEN_EXPORT_PDF'] = "PDF"; + $content['LN_GEN_ERROR_EXPORING'] = "Error exporting data"; + $content['LN_GEN_ERROR_INVALIDEXPORTTYPE'] = "Invalid Export format selected, or other parameters were wrong."; + $content['LN_GEN_ERROR_SOURCENOTFOUND'] = "The Source with ID '%1' could not be found."; + $content['LN_GEN_ERROR_PDFMISSINGEXTENSION'] = "The PDF Extension is missing in your php environment."; // Topmenu Entries diff --git a/src/templates/index.html b/src/templates/index.html index cc55e9c..f14702a 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -99,9 +99,9 @@