Commit 4cf8a87e authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] dynamic template/marker reading

parent 68f6d76c
......@@ -67,6 +67,7 @@ class MailController extends ActionController {
) . 'Configuration/Templates/' . $extensionKey . '/';
$files = glob($extPath . '*.html');
$this->view->assign('templates', array_map('basename', $files));
$this->view->assign('extensionKey', $extensionKey);
}
/**
......@@ -74,7 +75,19 @@ class MailController extends ActionController {
*
*/
public function showMarkerAction() {
$extensionKey = $this->request->getArgument('extensionKey');
$template = $this->request->getArgument('template');
$templateContent = file_get_contents(
Please register or sign in to reply
ExtensionManagementUtility::extPath(
'sg_mail'
) . 'Configuration/Templates/' . $extensionKey . '/' . $template
);
$marker = preg_match_all('/(?<={)[^}]+(?=})/', $templateContent, $matches) ? $matches[0] : [];
$comments = preg_match_all('/<!--(.|\s)*?-->/', $templateContent, $matches) ? $matches[0] : [];
$this->view->assign('marker', $marker);
$this->view->assign('comments', $comments);
}
}
......@@ -32,6 +32,12 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
*/
class MailTemplateService {
/**
* Holds default values for all Templates and their markers
* @var array
*/
protected $templateConfig = [];
/**
* @var array
*/
......
<h1>###heading###</h1>
<!--this is the heading of the template-->
<h1>{heading}</h1>
......@@ -4,7 +4,6 @@
</f:section>
<f:section name="main">
<f:flashMessages renderMode="div" />
<f:debug>{extensions}</f:debug>
<h3>Registered Extensions</h3>
<ul class="list-group">
<f:for each="{extensions}" as="extension">
......
Show Marker Template
<f:layout name="Default" />
<f:section name="iconButtons">
&nbsp;
</f:section>
<f:section name="main">
<f:flashMessages renderMode="div" />
<ul class="list-group">
<f:for each="{marker}" as="currentMarker">
<li class="list-group-item">
{currentMarker}
</li>
</f:for>
</ul>
<ul class="list-group">
<f:for each="{comments}" as="comment">
<li class="list-group-item">
{comment}
</li>
</f:for>
</ul>
</f:section>
......@@ -7,7 +7,7 @@
<ul class="list-group">
<f:for each="{templates}" as="template">
<li class="list-group-item">
<f:link.action controller="Mail" action="showMarker" arguments="{template:'{template}'}">
<f:link.action controller="Mail" action="showMarker" arguments="{template:'{template}', extensionKey: '{extensionKey}'}">
{template}
</f:link.action>
</li>
......
Auf Branch feature_sg_mail
Änderungen, die nicht zum Commit vorgemerkt sind:
(benutzen Sie "git add <Datei>...", um die Änderungen zum Commit vorzumerken)
(benutzen Sie "git checkout -- <Datei>...", um die Änderungen im Arbeitsverzeichnis zu verwerfen)
geändert: Classes/Controller/MailController.php
geändert: Configuration/Templates/sg_comments/test.html
geändert: Configuration/Templates/sg_documentation/demo_mail.html
geändert: Resources/Private/Templates/Mail/Index.html
geändert: Resources/Private/Templates/Mail/ShowMarker.html
geändert: Resources/Private/Templates/Mail/ShowTemplates.html
keine Änderungen zum Commit vorgemerkt (benutzen Sie "git add" und/oder "git commit -a")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment