[Fixed] no img leads to an error
[Added] metadata setting for alternative PDF-Logo filename; translations [Changed] img-handling in documentsGeneric and header.html.twig I didn't check for smarty yet!
This commit is contained in:
parent
d555656a38
commit
785637254b
@ -12,13 +12,16 @@ namespace D3\PdfDocuments\Application\Model\AbstractClasses;
|
|||||||
|
|
||||||
use Assert\InvalidArgumentException;
|
use Assert\InvalidArgumentException;
|
||||||
use D3\ModCfg\Application\Model\d3filesystem;
|
use D3\ModCfg\Application\Model\d3filesystem;
|
||||||
|
use D3\PdfDocuments\Application\Model\Constants;
|
||||||
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
|
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
|
||||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
||||||
use OxidEsales\Eshop\Core\Base;
|
use OxidEsales\Eshop\Core\Base;
|
||||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\Eshop\Core\UtilsView;
|
use OxidEsales\Eshop\Core\UtilsView;
|
||||||
|
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateEngineInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateEngineInterface;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||||
@ -182,12 +185,37 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
unset($iSelLang);
|
unset($iSelLang);
|
||||||
|
|
||||||
$this->oTemplateEngine->addGlobal('config', Registry::getConfig());
|
$this->oTemplateEngine->addGlobal('config', Registry::getConfig());
|
||||||
|
$this->oTemplateEngine->addGlobal('sAlternativePdfLogo', $this->getAlternativePdfLogoFileName());
|
||||||
$this->oTemplateEngine->addGlobal('oViewConf', Registry::getConfig()->getActiveView()->getViewConfig());
|
$this->oTemplateEngine->addGlobal('oViewConf', Registry::getConfig()->getActiveView()->getViewConfig());
|
||||||
$this->oTemplateEngine->addGlobal('shop', Registry::getConfig()->getActiveShop());
|
$this->oTemplateEngine->addGlobal('shop', Registry::getConfig()->getActiveShop());
|
||||||
$this->oTemplateEngine->addGlobal('lang', Registry::getLang());
|
$this->oTemplateEngine->addGlobal('lang', Registry::getLang());
|
||||||
$this->oTemplateEngine->addGlobal('document', $this);
|
$this->oTemplateEngine->addGlobal('document', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAlternativePdfLogoFileName() :string
|
||||||
|
{
|
||||||
|
$sStandardLogoFile = 'pdf_logo.jpg';
|
||||||
|
$oViewConf = Registry::getConfig()->getActiveView()->getViewConfig();
|
||||||
|
$moduleSettingService = ContainerFacade::get(ModuleSettingServiceInterface::class);
|
||||||
|
$sAlternativePdfLogoName = $moduleSettingService->getString(Constants::OXID_MODULE_ID."_sAlternativePdfLogoName", Constants::OXID_MODULE_ID);
|
||||||
|
|
||||||
|
$sAlternativePdfLogoName = trim($sAlternativePdfLogoName) ?: $sStandardLogoFile;
|
||||||
|
|
||||||
|
$bAlternativeFileExists = file_exists(Registry::getConfig()->getImagePath($sAlternativePdfLogoName));
|
||||||
|
$bFileExists = file_exists(Registry::getConfig()->getImagePath($sStandardLogoFile));
|
||||||
|
|
||||||
|
return $bAlternativeFileExists
|
||||||
|
? $oViewConf->getImageUrl($sAlternativePdfLogoName, true)
|
||||||
|
: (
|
||||||
|
$bFileExists
|
||||||
|
? $oViewConf->getImageUrl($sStandardLogoFile, true)
|
||||||
|
: ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $iSelLang
|
* @param int $iSelLang
|
||||||
*
|
*
|
||||||
|
@ -13,7 +13,11 @@ $aLang = array(
|
|||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
|
|
||||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
|
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
|
||||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Entwicklermodus',
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus',
|
||||||
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternativer PDF-Logo Name<br><br>
|
||||||
|
Ohne Angabe ( leer ) wird <u style="color: orangered">automatisch</u> folgender Datei-Name gewählt: <b>pdf_logo.jpg</b><br>
|
||||||
|
Diese Datei muss sich im <b>source/out/THEME/img/</b> Ordner befinden.<br><br>
|
||||||
|
<u>Notfalls wird kein Bild eingefügt!</u>',
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
|
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
|
||||||
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
||||||
|
@ -13,7 +13,11 @@ $aLang = array(
|
|||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
|
|
||||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
|
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
|
||||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Developer mode',
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode',
|
||||||
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternative PDF Logo Name<br><br>
|
||||||
|
Without specification (empty) the following file name will be <u style="color: orangered">automatically</u> selected: <b>pdf_logo.jpg</b><br>
|
||||||
|
This file must be located in the <b>source/out/THEME/img/</b> folder.<br><br>
|
||||||
|
<u>If necessary, no image will be inserted!</u>',
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS' => 'PDF Documents',
|
'D3_PDFDOCUMENTS' => 'PDF Documents',
|
||||||
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
|
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
|
||||||
|
@ -8,12 +8,18 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use D3\PdfDocuments\Application\Model\Constants;
|
||||||
|
|
||||||
$sLangName = "Deutsch";
|
$sLangName = "Deutsch";
|
||||||
$aLang = array(
|
$aLang = array(
|
||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
|
|
||||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
|
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
|
||||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Entwicklermodus',
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus',
|
||||||
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternativer PDF-Logo Name<br><br>
|
||||||
|
Ohne Angabe ( leer ) wird <u style="color: orangered">automatisch</u> folgender Datei-Name gewählt: <b>pdf_logo.jpg</b><br>
|
||||||
|
Diese Datei muss sich im <b>source/out/THEME/img/</b> Ordner befinden.<br><br>
|
||||||
|
<u>Notfalls wird kein Bild eingefügt!</u>',
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
|
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
|
||||||
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
||||||
|
@ -13,7 +13,11 @@ $aLang = array(
|
|||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
|
|
||||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
|
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
|
||||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Developer mode',
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode',
|
||||||
|
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName' => 'Alternative PDF Logo Name<br><br>
|
||||||
|
Without specification (empty) the following file name will be <u style="color: orangered">automatically</u> selected: <b>pdf_logo.jpg</b><br>
|
||||||
|
This file must be located in the <b>source/out/THEME/img/</b> folder.<br><br>
|
||||||
|
<u>If necessary, no image will be inserted!</u>',
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS' => 'PDF Documents',
|
'D3_PDFDOCUMENTS' => 'PDF Documents',
|
||||||
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
|
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
|
||||||
|
@ -92,6 +92,12 @@ $aModule = [
|
|||||||
'name' => Constants::OXID_MODULE_ID.'bDev',
|
'name' => Constants::OXID_MODULE_ID.'bDev',
|
||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'value' => false
|
'value' => false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'group' => Constants::OXID_MODULE_ID.'main',
|
||||||
|
'name' => Constants::OXID_MODULE_ID.'_sAlternativePdfLogoName',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => ''
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% set showLogo = showLogo|default(1) %}
|
{% set showLogo = showLogo|default(1) %}
|
||||||
|
{% set sPdfLogo = sAlternativePdfLogo %}
|
||||||
|
|
||||||
{% block pdfHeader %}
|
{% block pdfHeader %}
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -6,7 +7,9 @@
|
|||||||
{# pdf logo is available only in non admin theme #}
|
{# pdf logo is available only in non admin theme #}
|
||||||
{% set isAdmin = oViewConf.isAdmin() %}
|
{% set isAdmin = oViewConf.isAdmin() %}
|
||||||
{{ oViewConf.setAdminMode(false) }}
|
{{ oViewConf.setAdminMode(false) }}
|
||||||
<img class="logo" alt="Logo" src="{{ oViewConf.getImageUrl('pdf_logo.jpg') }}">
|
{% if sPdfLogo %}
|
||||||
|
<img class="logo" alt="Logo" src="{{ sPdfLogo }}">
|
||||||
|
{% endif %}
|
||||||
{{ oViewConf.setAdminMode(isAdmin) }}
|
{{ oViewConf.setAdminMode(isAdmin) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user