Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_mail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_mail
Commits
b9ce9634
Commit
b9ce9634
authored
8 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Remembering language selections
parent
c4b1229b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/MailController.php
+52
-5
52 additions, 5 deletions
Classes/Controller/MailController.php
Classes/Session/PhpSession.php
+126
-0
126 additions, 0 deletions
Classes/Session/PhpSession.php
with
178 additions
and
5 deletions
Classes/Controller/MailController.php
+
52
−
5
View file @
b9ce9634
...
...
@@ -28,6 +28,7 @@ namespace SGalinski\SgMail\Controller;
use
SGalinski\SgMail\Domain\Model\Template
;
use
SGalinski\SgMail\Service\MailTemplateService
;
use
SGalinski\SgMail\Session\PhpSession
;
use
TYPO3\CMS\Core\Messaging\FlashMessage
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Extbase\Mvc\Controller\ActionController
;
...
...
@@ -51,6 +52,11 @@ class MailController extends ActionController {
*/
protected
$templateRepository
=
NULL
;
/**
* @var \SGalinski\Lfeditor\Session\PhpSession
*/
protected
$session
;
/**
* Show template Selection and enable content input + mail preview
*
...
...
@@ -66,6 +72,11 @@ class MailController extends ActionController {
$selectedLanguageRight
=
NULL
,
$selectedExtensionKey
=
NULL
,
$selectedTemplateKey
=
NULL
)
{
if
(
!
(
$this
->
session
instanceof
PhpSession
))
{
$this
->
session
=
$this
->
objectManager
->
get
(
'SGalinski\SgMail\Session\PhpSession'
);
$this
->
session
->
setSessionKey
(
'sg_mail_controller_session'
);
}
$registerArray
=
MailTemplateService
::
getRegisterArray
();
reset
(
MailTemplateService
::
getRegisterArray
());
$firstEntry
=
key
(
MailTemplateService
::
getRegisterArray
());
...
...
@@ -86,9 +97,20 @@ class MailController extends ActionController {
)
{
$selectedTemplateArray
=
$registerArray
[
$selectedExtension
][
$selectedTemplate
];
// get last selected languages
!
isset
(
$selectedLanguageLeft
)
?
$selectedLanguageLeft
=
$this
->
session
->
getDataByKey
(
'selectedLanguageLeft'
)
:
NULL
;
!
isset
(
$selectedLanguageRight
)
?
$selectedLanguageRight
=
$this
->
session
->
getDataByKey
(
'selectedLanguageRight'
)
:
NULL
;
$this
->
view
->
assign
(
'selectedTemplate'
,
$selectedTemplateArray
);
$this
->
view
->
assign
(
'selectedTemplateKey'
,
$selectedTemplate
);
$this
->
view
->
assign
(
'selectedExtensionKey'
,
$selectedExtension
);
$this
->
view
->
assign
(
'selectedLanguageLeft'
,
$selectedLanguageLeft
);
$this
->
view
->
assign
(
'selectedLanguageRight'
,
$selectedLanguageRight
);
}
elseif
(
!
isset
(
$selectedLanguageLeft
)
&&
!
isset
(
$selectedLanguageRight
))
{
...
...
@@ -98,16 +120,38 @@ class MailController extends ActionController {
);
}
$this
->
view
->
assign
(
'selectedLanguageLeft'
,
$this
->
settings
[
'templateDefaultLanguage'
]);
$this
->
view
->
assign
(
'selectedLanguageRight'
,
$this
->
settings
[
'templateDefaultLanguage'
]);
// get last selected languages
!
isset
(
$selectedLanguageLeft
)
?
$selectedLanguageLeft
=
$this
->
session
->
getDataByKey
(
'selectedLanguageLeft'
)
:
NULL
;
!
isset
(
$selectedLanguageRight
)
?
$selectedLanguageRight
=
$this
->
session
->
getDataByKey
(
'selectedLanguageRight'
)
:
NULL
;
$this
->
view
->
assign
(
'selectedLanguageLeft'
,
$selectedLanguageLeft
);
$this
->
view
->
assign
(
'selectedLanguageRight'
,
$selectedLanguageRight
);
$this
->
view
->
assign
(
'selectedTemplateKey'
,
$secondLevelFirstEntry
);
$this
->
view
->
assign
(
'selectedExtensionKey'
,
$firstEntry
);
}
if
(
isset
(
$selectedTemplate
)
&&
isset
(
$selectedExtension
))
{
!
isset
(
$selectedLanguageLeft
)
?
$selectedLanguageLeft
=
'en'
:
NULL
;
!
isset
(
$selectedLanguageRight
)
?
$selectedLanguageRight
=
'en'
:
NULL
;
isset
(
$selectedLanguageLeft
)
?
$this
->
session
->
setDataByKey
(
'selectedLanguageLeft'
,
$selectedLanguageLeft
)
:
NULL
;
isset
(
$selectedLanguageRight
)
?
$this
->
session
->
setDataByKey
(
'selectedLanguageRight'
,
$selectedLanguageRight
)
:
NULL
;
// get last selected languages
!
isset
(
$selectedLanguageLeft
)
?
$selectedLanguageLeft
=
$this
->
session
->
getDataByKey
(
'selectedLanguageLeft'
)
:
NULL
;
!
isset
(
$selectedLanguageRight
)
?
$selectedLanguageRight
=
$this
->
session
->
getDataByKey
(
'$selectedLanguageRight'
)
:
NULL
;
$this
->
view
->
assign
(
'selectedLanguageLeft'
,
$selectedLanguageLeft
);
$this
->
view
->
assign
(
'selectedLanguageRight'
,
$selectedLanguageRight
);
...
...
@@ -289,9 +333,12 @@ class MailController extends ActionController {
* @param string $selectedExtensionKey
* @param string $selectedLanguageLeft
* @param string $selectedLanguageRight
* @param string $contentRight
* @param string $contentLeft
*/
public
function
sendTestMailAction
(
$emailAddress
,
$selectedExtensionKey
,
$selectedTemplateKey
,
$selectedLanguageLeft
,
$selectedLanguageRight
$emailAddress
,
$selectedExtensionKey
,
$selectedTemplateKey
,
$selectedLanguageLeft
,
$selectedLanguageRight
,
$contentRight
,
$contentLeft
)
{
if
(
!
filter_var
(
$this
->
settings
[
'mail'
][
'test'
][
'from'
],
FILTER_VALIDATE_EMAIL
))
{
...
...
This diff is collapsed.
Click to expand it.
Classes/Session/PhpSession.php
0 → 100644
+
126
−
0
View file @
b9ce9634
<?php
namespace
SGalinski\SgMail\Session
;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
TYPO3\CMS\Core\SingletonInterface
;
/**
* PHP Session handler
*/
class
PhpSession
implements
SingletonInterface
{
/**
* @var string
*/
protected
$sessionKey
;
/**
* Constructor
*/
public
function
__construct
()
{
session_start
();
$this
->
sessionKey
=
uniqid
();
}
/**
* @param string $sessionKey
* @return void
*/
public
function
setSessionKey
(
$sessionKey
)
{
$this
->
sessionKey
=
$sessionKey
;
}
/**
* Returns the current session key
*
* @return string
*/
public
function
getSessionKey
()
{
return
$this
->
sessionKey
;
}
/**
* Exchanges the complete session data
*
* @param mixed $data
* @return void
*/
public
function
exchangeData
(
$data
)
{
$this
->
destroy
();
$_SESSION
[
$this
->
sessionKey
]
=
$data
;
}
/**
* Returns the complete session data
*
* @return mixed
*/
public
function
getData
()
{
return
$_SESSION
[
$this
->
sessionKey
];
}
/**
* Sets data inside the session below the given key
*
* @param string $key
* @param mixed $data
* @return void
*/
public
function
setDataByKey
(
$key
,
$data
)
{
$_SESSION
[
$this
->
sessionKey
][
$key
]
=
$data
;
}
/**
* Returns data of the session defined by the given key
*
* @param string $key
* @return mixed
*/
public
function
getDataByKey
(
$key
)
{
return
$_SESSION
[
$this
->
sessionKey
][
$key
];
}
/**
* Removes data defined by the given key.
*
* @param string $key
* @return void
*/
public
function
unsetDataByKey
(
$key
)
{
unset
(
$_SESSION
[
$this
->
sessionKey
][
$key
]);
}
/**
* Removes all session data
*
* @return void
*/
public
function
destroy
()
{
unset
(
$_SESSION
[
$this
->
sessionKey
]);
}
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment