Skip to content
Snippets Groups Projects
Commit 8a44a21f authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

Merge branch 'feature_5145-editableRenderWithNl2Br' into 'master'

Feature 5145 editable render with nl2 br

See merge request !62
parents f2adb5ed ea429296
No related branches found
No related tags found
1 merge request!62Feature 5145 editable render with nl2 br
......@@ -127,6 +127,7 @@ class ConfigurationController extends AbstractController {
$csv = str_replace("\r", '', $configuration['csv']);
$subject = $configuration['subject'];
$description = $configuration['description'];
$renderWithNl2br = (bool) $configuration['renderWithNl2br'];
$markersCsv = explode("\n", $csv);
$markers = [];
foreach ($markersCsv as $markerCsv) {
......@@ -150,7 +151,8 @@ class ConfigurationController extends AbstractController {
$extensionKey,
$markers,
$subject,
$description
$description,
$renderWithNl2br
);
$this->registerService->clearCaches();
// store selected template & extension key in the session
......
......@@ -243,7 +243,7 @@ class MailController extends AbstractController {
}
/**
* send a test email to a given address
* Either just saves the mail template or saves it AND sends a test email to a given address
* redirect to index action
*
* @param array $parameters
......
......@@ -116,6 +116,7 @@ class TemplateRepository extends AbstractRepository {
/** @var Template $template */
$template = $this->findByUid($uid);
$this->fillTemplate($template, $templateData);
$this->update($template);
$this->persist();
return $template;
......@@ -167,7 +168,7 @@ class TemplateRepository extends AbstractRepository {
$template->setPid($templateData['pid']);
$template->setContent((string) $templateData['content']);
$template->setSubject($templateData['subject']);
$template->setRenderWithNl2br($templateData['render_with_nl2br'] ?? TRUE);
$template->setRenderWithNl2br((bool) $templateData['render_with_nl2br']);
if (isset($templateData['layout'])) {
$template->setLayout($templateData['layout']);
......
......@@ -394,6 +394,7 @@ class RegisterService implements SingletonInterface {
* @param array $markers
* @param string $subject
* @param string $description
* @param bool $renderWithNl2br
* @return string
*/
public function writeRegisterFile(
......@@ -401,13 +402,15 @@ class RegisterService implements SingletonInterface {
string $extensionKey,
array $markers,
string $subject = '',
string $description = ''
string $description = '',
bool $renderWithNl2br = TRUE,
): string {
$newRegisterArray = [
'extension_key' => $extensionKey,
'template_key' => $templateKey,
'description' => $description,
'subject' => $subject,
'render_with_nl2br' => $renderWithNl2br,
'markers' => [],
'templateContent' => '<f:format.raw>{all_fields_html}</f:format.raw>',
];
......
......@@ -22,7 +22,7 @@ sg_mail is multi-site and multi-language ready.
To register your extension with sg_mail, you need a **Configuration File** for each template you want to integrate.
It needs to be a *.php* file and has to be inside the configuration folder
**typo3conf/ext/{your_extension}/Configuration/Sgmail** of your extension.
**typo3conf/ext/{your_extension}/Configuration/SgMail** of your extension.
Additionally, you need to make your registration file known in your **ext_localconf.php** file:
......@@ -55,7 +55,7 @@ Inside the file you have mandatory and optional settings you can define:
#### Optional
- **template_path**: You can provide a path to your mail template that differs from the default path with this setting.
- **renderWithNl2br**: You can set this to false, if you don't want newlines to automatically be converted to HTML linebreaks. (Default is true)
#### The template folder
If not overwritten in your configuration file, the default location for your extensions templates is **ext/sg_example/Resources/Private/Templates/SgMail/{TemplateNameInUpperCamelCase}**.
......
......@@ -536,6 +536,10 @@ Bitte registrieren Sie Ihre Templates in den entsprechenden ext_localconf.php Da
<source><![CDATA[Subject]]></source>
<target><![CDATA[Betreff]]></target>
</trans-unit>
<trans-unit id="backend.renderWithNl2br" resname="backend.renderWithNl2br" approved="yes">
<source><![CDATA[Render with nl2br() (Newlines -> HTML line breaks)]]></source>
<target><![CDATA[Rendering mit nl2br() (Zeilenumbrüche -> HTML-Zeilenumbrüche)]]></target>
</trans-unit>
<trans-unit id="backend.success" resname="backend.success" approved="yes">
<source><![CDATA[Successfully saved!]]></source>
<target><![CDATA[Erfolgreich gespeichert!]]></target>
......
......@@ -198,8 +198,8 @@ Kann bspw. für CSS verwendet werden.]]></target>
<target><![CDATA[Empfänger Adresse]]></target>
</trans-unit>
<trans-unit id="tx_sgmail_domain_model_template.render_with_nl2br">
<source><![CDATA[Render with nl2br() (Newlines -> HTML breaks)]]></source>
<target><![CDATA[Rendering mit nl2br()]]></target>
<source><![CDATA[Render with nl2br() (Newlines -> HTML line breaks)]]></source>
<target><![CDATA[Rendering mit nl2br() (Zeilenumbrüche -> HTML-Zeilenumbrüche)]]></target>
</trans-unit>
</body>
</file>
......
......@@ -54,6 +54,9 @@
<trans-unit id="backend.content" resname="backend.content">
<source><![CDATA[Text]]></source>
</trans-unit>
<trans-unit id="backend.renderWithNl2br" resname="backend.renderWithNl2br">
<source><![CDATA[Render with nl2br() (Newlines -> HTML line breaks)]]></source>
</trans-unit>
<trans-unit id="backend.create.csv" resname="backend.create.csv">
<source><![CDATA[Marker (csv format)]]></source>
</trans-unit>
......
......@@ -153,7 +153,7 @@ Can be used e.g. for CSS.]]></source>
<source><![CDATA[Default Attachments]]></source>
</trans-unit>
<trans-unit id="tx_sgmail_domain_model_template.render_with_nl2br">
<source><![CDATA[Render with nl2br() (Newlines -> HTML breaks)]]></source>
<source><![CDATA[Render with nl2br() (Newlines -> HTML line breaks)]]></source>
</trans-unit>
</body>
</file>
......
......@@ -69,6 +69,18 @@
id="description"
value="{description}" />
</div>
<div class="form-group">
<div class="form-check">
<f:form.checkbox
id="renderWithNl2br"
class="form-check-input"
value="1"
checked="TRUE" property="renderWithNl2br"/>
<label class="form-check-label" for="renderWithNl2br">
{f:translate(key:'backend.renderWithNl2br')}
</label>
</div>
</div>
<f:form.submit class="btn-primary btn form-group col-xs-12 col-md-2 col-md-offset-10"
value="{f:translate(key:'backend.create.save')}" />
</div>
......
......@@ -269,6 +269,19 @@
name="parameters[templates][{languageId}][content]"
value="{template.content}" />
</div>
<div class="form-group">
<div class="form-check">
<f:form.checkbox
id="parameters-templates-{languageId}-renderWithNl2br"
class="form-check-input"
value="1"
checked="{template.renderWithNl2br}"
name="parameters[templates][{languageId}][render_with_nl2br]" />
<label class="form-check-label" for="parameters-templates-{languageId}-renderWithNl2br">
{f:translate(key:'backend.renderWithNl2br')}
</label>
</div>
</div>
<div class="form-group">
<label for="parameters-templates-{languageId}-default-attachments">
{f:translate(key:'backend.defaultAttachments')}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment