From 97735bab3bd3efaee265e79b48e215ccd49d9c42 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Wed, 14 May 2025 21:44:40 +0200 Subject: [PATCH] change translation structure --- .../AbstractClasses/pdfdocumentsGeneric.php | 19 ++++---- .../admin_smarty/de/pdfdocuments_lang.php | 44 +++++-------------- .../admin_smarty/en/pdfdocuments_lang.php | 44 +++++-------------- .../views/admin_twig/de/pdfdocuments_lang.php | 33 +++++--------- .../views/admin_twig/en/pdfdocuments_lang.php | 33 +++++--------- Application/views/de/translations.php | 44 +++++++++++++++++++ Application/views/en/translations.php | 44 +++++++++++++++++++ .../d3_overview_controller_pdfdocuments.php | 8 +--- metadata.php | 8 ++-- 9 files changed, 146 insertions(+), 131 deletions(-) create mode 100644 Application/views/de/translations.php create mode 100644 Application/views/en/translations.php diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index eb6396f..3966eaf 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -18,6 +18,7 @@ use OxidEsales\Eshop\Core\Exception\StandardException; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\UtilsView; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService; use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface; @@ -34,9 +35,9 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface { const PDF_DESTINATION_DOWNLOAD = 'D'; // force download in browser const PDF_DESTINATION_STDOUT = 'I'; // show in browser plugin if available, otherwise download - const PDF_DESTINATION_FILE = 'F'; // save as local file - const PDF_DESTINATION_FILEANDSTDOUT = 'FI'; // output as local file and show in browser plugin - const PDF_DESTINATION_FILEANDDOWNLOAD = 'FD'; // output as local file and force download in browser + const PDF_DESTINATION_FILE = 'F'; // save as a local file + const PDF_DESTINATION_FILEANDSTDOUT = 'FI'; // output as a local file and show in browser plugin + const PDF_DESTINATION_FILEANDDOWNLOAD = 'FD'; // output as a local file and force download in browser const PDF_DESTINATION_STRING = 'S'; // output as string const PDF_ORIENTATION_PORTRAIT = 'P'; @@ -84,11 +85,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface return $this->output($oPdf, $sFilename, $target, $htmlContent); } - /** - * @param int $iLanguage - * @throws Html2PdfException - */ - /** * @param $iLanguage * @@ -213,9 +209,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface protected function addBasicAuth($content) { -// ToDo: change to ModuleSettingService - $username = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthUserName')); - $password = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthPassword')); + /** @var ModuleSettingService $settingsService */ + $settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class); + $username = trim($settingsService->getString('d3PdfDocumentsbasicAuthUserName', Constants::OXID_MODULE_ID)); + $password = trim($settingsService->getString('d3PdfDocumentsbasicAuthPassword', Constants::OXID_MODULE_ID)); if ($username && $password) { $shopUrl = parse_url( Registry::getConfig()->getShopCurrentUrl() ); diff --git a/Application/views/admin_smarty/de/pdfdocuments_lang.php b/Application/views/admin_smarty/de/pdfdocuments_lang.php index 39eb0da..b786354 100644 --- a/Application/views/admin_smarty/de/pdfdocuments_lang.php +++ b/Application/views/admin_smarty/de/pdfdocuments_lang.php @@ -1,40 +1,18 @@ - * @link http://www.oxidmodule.com + * @author D3 Data Development - Daniel Seifert + * @link https://www.oxidmodule.com */ -use D3\PdfDocuments\Application\Model\Constants; +declare(strict_types=1); -$sLangName = "Deutsch"; - -$basicAuthHelp = << 'utf-8', - - 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', - 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Mit aktiviertem Entwicklermodus wird das Dokument im '. - 'HTML-Format ausgegeben. Inhaltliche Fehler können so besser nachvollzogen werden.', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)', - 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp, - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth des Shops - Passwort (optional)', - 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp, - - 'D3_PDFDOCUMENTS' => 'PDF-Dokumente', - 'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung', - 'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Rechnung ohne Logo', - 'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Lieferschein', - 'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Lieferschein ohne Logo', - - 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument', - 'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache', - 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen', -); +// @codeCoverageIgnoreStart +$aLang = include __DIR__ . "/../../de/translations.php"; +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/en/pdfdocuments_lang.php b/Application/views/admin_smarty/en/pdfdocuments_lang.php index 802d607..cf78917 100644 --- a/Application/views/admin_smarty/en/pdfdocuments_lang.php +++ b/Application/views/admin_smarty/en/pdfdocuments_lang.php @@ -1,40 +1,18 @@ - * @link http://www.oxidmodule.com + * @author D3 Data Development - Daniel Seifert + * @link https://www.oxidmodule.com */ -use D3\PdfDocuments\Application\Model\Constants; +declare(strict_types=1); -$sLangName = "English"; - -$basicAuthHelp = << 'utf-8', - - 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', - 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'If developer mode is activated, the document is output in '. - 'HTML format. This makes it much easier to trace content errors.', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth of the shop - user name (optional)', - 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp, - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth of the shop - password (optional)', - 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp, - - 'D3_PDFDOCUMENTS' => 'PDF Documents', - 'D3_PDFDOCUMENTS_INVOICE' => 'Invoice', - 'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Invoice without logo', - 'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Deliverynote', - 'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Deliverynote without logo', - - 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Document', - 'D3_PDFDOCUMENTS_LANGUAGE' => 'Language', - 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document', -); +// @codeCoverageIgnoreStart +$aLang = include __DIR__ . "/../../en/translations.php"; +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_twig/de/pdfdocuments_lang.php b/Application/views/admin_twig/de/pdfdocuments_lang.php index 2ecffb8..b786354 100644 --- a/Application/views/admin_twig/de/pdfdocuments_lang.php +++ b/Application/views/admin_twig/de/pdfdocuments_lang.php @@ -1,29 +1,18 @@ - * @link http://www.oxidmodule.com + * @author D3 Data Development - Daniel Seifert + * @link https://www.oxidmodule.com */ - - use D3\PdfDocuments\Application\Model\Constants; - - $sLangName = "Deutsch"; -$aLang = array( - 'charset' => 'utf-8', - 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', +declare(strict_types=1); - 'D3_PDFDOCUMENTS' => 'PDF-Dokumente', - 'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung', - 'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Rechnung ohne Logo', - 'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Lieferschein', - 'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Lieferschein ohne Logo', - - 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument', - 'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache', - 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen', -); +// @codeCoverageIgnoreStart +$aLang = include __DIR__ . "/../../de/translations.php"; +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_twig/en/pdfdocuments_lang.php b/Application/views/admin_twig/en/pdfdocuments_lang.php index bd868d4..cf78917 100644 --- a/Application/views/admin_twig/en/pdfdocuments_lang.php +++ b/Application/views/admin_twig/en/pdfdocuments_lang.php @@ -1,29 +1,18 @@ - * @link http://www.oxidmodule.com + * @author D3 Data Development - Daniel Seifert + * @link https://www.oxidmodule.com */ -use D3\PdfDocuments\Application\Model\Constants; +declare(strict_types=1); -$sLangName = "English"; -$aLang = array( - 'charset' => 'utf-8', - - 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings', - 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', - - 'D3_PDFDOCUMENTS' => 'PDF Documents', - 'D3_PDFDOCUMENTS_INVOICE' => 'Invoice', - 'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Invoice without logo', - 'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Deliverynote', - 'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Deliverynote without logo', - - 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Document', - 'D3_PDFDOCUMENTS_LANGUAGE' => 'Language', - 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document', -); +// @codeCoverageIgnoreStart +$aLang = include __DIR__ . "/../../en/translations.php"; +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/de/translations.php b/Application/views/de/translations.php new file mode 100644 index 0000000..b0574b8 --- /dev/null +++ b/Application/views/de/translations.php @@ -0,0 +1,44 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +use D3\PdfDocuments\Application\Model\Constants; + +// @codeCoverageIgnoreStart +$basicAuthHelp = << 'utf-8', + + 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus', + 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Mit aktiviertem Entwicklermodus wird das Dokument im '. + 'HTML-Format ausgegeben. Inhaltliche Fehler können so besser nachvollzogen werden.', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)', + 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp, + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth des Shops - Passwort (optional)', + 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp, + + 'D3_PDFDOCUMENTS' => 'PDF-Dokumente', + 'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung', + 'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Rechnung ohne Logo', + 'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Lieferschein', + 'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Lieferschein ohne Logo', + + 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Dokument', + 'D3_PDFDOCUMENTS_LANGUAGE' => 'Sprache', + 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Dokument erstellen', +]; diff --git a/Application/views/en/translations.php b/Application/views/en/translations.php new file mode 100644 index 0000000..493b583 --- /dev/null +++ b/Application/views/en/translations.php @@ -0,0 +1,44 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +use D3\PdfDocuments\Application\Model\Constants; + +// @codeCoverageIgnoreStart +$basicAuthHelp = << 'utf-8', + + 'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode', + 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'If developer mode is activated, the document is output in '. + 'HTML format. This makes it much easier to trace content errors.', + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth of the shop - user name (optional)', + 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp, + 'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth of the shop - password (optional)', + 'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp, + + 'D3_PDFDOCUMENTS' => 'PDF Documents', + 'D3_PDFDOCUMENTS_INVOICE' => 'Invoice', + 'D3_PDFDOCUMENTS_INVOICE_WITHOUT_LOGO' => 'Invoice without logo', + 'D3_PDFDOCUMENTS_DELIVERYNOTE' => 'Deliverynote', + 'D3_PDFDOCUMENTS_DELIVERYNOTE_WITHOUT_LOGO' => 'Deliverynote without logo', + + 'D3_PDFDOCUMENTS_PDF_TYPE' => 'Document', + 'D3_PDFDOCUMENTS_LANGUAGE' => 'Language', + 'D3_PDFDOCUMENTS_PDF_GENERATE' => 'Create Document', +]; diff --git a/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php b/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php index eac6c83..50fe354 100644 --- a/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php +++ b/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php @@ -16,14 +16,10 @@ use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract; use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview; use Exception; -use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview; -use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\QueryBuilder; use OxidEsales\Eshop\Application\Model\Order; -use OxidEsales\Eshop\Core\DatabaseProvider; -use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\TableViewNameGenerator; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; @@ -33,7 +29,7 @@ use Psr\Container\NotFoundExceptionInterface; class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent { - private $generatorError = false; + private ?string $generatorError = null; public function render() { @@ -53,7 +49,7 @@ form.submit(); HTML; - Registry::getUtils()->showMessageAndExit(); + Registry::getUtils()->showMessageAndExit(''); } elseif ($generatorError = Registry::getRequest()->getRequestParameter('generatorError')) { Registry::getUtilsView()->addErrorToDisplay(urldecode($generatorError)); } diff --git a/metadata.php b/metadata.php index a97e172..d18febf 100644 --- a/metadata.php +++ b/metadata.php @@ -86,13 +86,13 @@ $aModule = [ 'value' => false ], [ - 'group' => $sModuleId.'main', - 'name' => $sModuleId.'basicAuthUserName', + 'group' => Constants::OXID_MODULE_ID.'main', + 'name' => Constants::OXID_MODULE_ID.'basicAuthUserName', 'type' => 'str' ], [ - 'group' => $sModuleId.'main', - 'name' => $sModuleId.'basicAuthPassword', + 'group' => Constants::OXID_MODULE_ID.'main', + 'name' => Constants::OXID_MODULE_ID.'basicAuthPassword', 'type' => 'password' ] ]