qbus-agentur /
qbtools
| 1 | <?php |
||||
| 2 | namespace Qbus\Qbtools\Controller; |
||||
| 3 | |||||
| 4 | /* * ************************************************************* |
||||
| 5 | * Copyright notice |
||||
| 6 | * |
||||
| 7 | * (c) 2014 Benjamin Franzke <[email protected], Qbus Werbeagentur GmbH |
||||
| 8 | * |
||||
| 9 | * All rights reserved |
||||
| 10 | * |
||||
| 11 | * This script is part of the TYPO3 project. The TYPO3 project is |
||||
| 12 | * free software; you can redistribute it and/or modify |
||||
| 13 | * it under the terms of the GNU General Public License as published by |
||||
| 14 | * the Free Software Foundation; either version 3 of the License, or |
||||
| 15 | * (at your option) any later version. |
||||
| 16 | * |
||||
| 17 | * The GNU General Public License can be found at |
||||
| 18 | * http://www.gnu.org/copyleft/gpl.html. |
||||
| 19 | * |
||||
| 20 | * This script is distributed in the hope that it will be useful, |
||||
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
| 23 | * GNU General Public License for more details. |
||||
| 24 | * |
||||
| 25 | * This copyright notice MUST APPEAR in all copies of the script! |
||||
| 26 | * ************************************************************* */ |
||||
| 27 | |||||
| 28 | /** |
||||
| 29 | * Mailform Controller that wraps the Mailform View Helper. |
||||
| 30 | * |
||||
| 31 | * It is intended to be used via typoscript from a standalone fluid template (e.g. in DCE). |
||||
| 32 | * In a standalone fluid template you need to use instead of |
||||
| 33 | * <qbtools:mailform recipient="..." sender="..." /> |
||||
| 34 | * a typoscript caller, that itself calls this controller, which passes rendering on to the viewhelper: |
||||
| 35 | * <f:cObject typoscriptObjectPath="tt_content.list.20.qbtools_mailformwrapper" |
||||
| 36 | * data="{recipientName: "Name", recipientEmail: "[email protected]"}" /> |
||||
| 37 | * |
||||
| 38 | * Note: The tt_content.list.20.qbtools_mailformwrapper is created through the |
||||
| 39 | * call configurePlugin in this extensions ext_localconf.php. |
||||
| 40 | * |
||||
| 41 | * @todo Extend to be able to be used as a tt_content ctype element. |
||||
| 42 | * |
||||
| 43 | * @deprecated <qbtools:widget.mailform> can be used in a static fluid template nowadays, so this mailform is not useful |
||||
| 44 | * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later |
||||
| 45 | */ |
||||
| 46 | class MailformController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController |
||||
| 47 | { |
||||
| 48 | /* Initialize arguments from typoscript cObject context data. |
||||
| 49 | * That is the data that is passes by the fluid f:cObject view helper. */ |
||||
| 50 | public function initializeShowAction() |
||||
| 51 | { |
||||
| 52 | $cobj = $this->configurationManager->getContentObject(); |
||||
| 53 | foreach ($this->arguments as $argument) { |
||||
| 54 | if (isset($cobj->data[$argument->getName()]) && $cobj->data[$argument->getName()]) { |
||||
| 55 | $argument->setDefaultValue($cobj->data[$argument->getName()]); |
||||
| 56 | $argument->setRequired(false); |
||||
| 57 | } |
||||
| 58 | } |
||||
| 59 | } |
||||
| 60 | |||||
| 61 | /** |
||||
| 62 | * @param \string $recipientName |
||||
| 63 | * @param \string $recipientEmail |
||||
| 64 | * @param \string $senderName |
||||
| 65 | * @param \string $senderEmail |
||||
| 66 | * @param \array $required |
||||
| 67 | * @param \string $formPartial |
||||
| 68 | * @param \string $mailTemplate |
||||
| 69 | * @param \string $property |
||||
| 70 | */ |
||||
| 71 | public function showAction($recipientName, $recipientEmail, $senderName = null, $senderEmail = null, |
||||
| 72 | $required = 'firstname,lastname,email,message', |
||||
| 73 | $formPartial = 'Mailform', |
||||
| 74 | $mailTemplate = 'EXT:qbtools/Resources/Private/Templates/Mailform/Mail.txt', |
||||
| 75 | $property = null) |
||||
| 76 | { |
||||
| 77 | $this->view->assign('recipient', array('email' => $recipientEmail, 'name' => $recipientName)); |
||||
| 78 | $this->view->assign('required', explode(',', $required)); |
||||
| 79 | $this->view->assign('formPartial', $formPartial); |
||||
| 80 | $this->view->assign('mailTemplate', $mailTemplate); |
||||
| 81 | $this->view->assign('property', $property); |
||||
| 82 | |||||
| 83 | $this->view->setPartialRootPaths(array('fileadmin/Resources/Private/Partials')); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 84 | |||||
| 85 | if (strlen($senderName) > 0 && strlen($senderEmail) > 0) { |
||||
|
0 ignored issues
–
show
It seems like
$senderName can also be of type null; however, parameter $string of strlen() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 86 | $this->view->assign('sender', array('email' => $senderEmail, 'name' => $senderName)); |
||||
| 87 | } else { |
||||
| 88 | $this->view->assign('sender', null); |
||||
| 89 | } |
||||
| 90 | } |
||||
| 91 | } |
||||
| 92 |