/** * Parsing variables with fluid engine to allow viewhelpers in flexform * * @param array $email * @param Mail $mail * @return void */ protected function parseVariables(array &$email, Mail &$mail) { $parse = array('receiverName', 'receiverEmail', 'senderName', 'senderEmail', 'subject'); foreach ($parse as $value) { $email[$value] = TemplateUtility::fluidParseString($email[$value], $this->mailRepository->getVariablesWithMarkersFromMail($mail)); } }
/** * Mail Generation for Receiver * * @param Mail $mail * @param string $hash * @return void */ protected function sendReceiverMail(Mail $mail, $hash = null) { $receiverString = TemplateUtility::fluidParseString($this->settings['receiver']['email'], $this->mailRepository->getVariablesWithMarkersFromMail($mail)); TypoScriptUtility::overwriteValueFromTypoScript($receiverString, $this->conf['receiver.']['overwrite.'], 'email'); $receivers = StringUtility::getReceiverEmails($receiverString, $this->settings['receiver']['fe_group']); $mail->setReceiverMail(implode(PHP_EOL, $receivers)); TypoScriptUtility::overwriteValueFromTypoScript($defaultSenderEmail, $this->conf['receiver.']['default.'], 'senderEmail'); TypoScriptUtility::overwriteValueFromTypoScript($defaultSenderName, $this->conf['receiver.']['default.'], 'senderName'); foreach ($receivers as $receiver) { $email = ['template' => 'Mail/ReceiverMail', 'receiverEmail' => $receiver, 'receiverName' => !empty($this->settings['receiver']['name']) ? $this->settings['receiver']['name'] : 'Powermail', 'senderEmail' => $this->mailRepository->getSenderMailFromArguments($mail, $defaultSenderEmail), 'senderName' => $this->mailRepository->getSenderNameFromArguments($mail, $defaultSenderName), 'subject' => $this->settings['receiver']['subject'], 'rteBody' => $this->settings['receiver']['body'], 'format' => $this->settings['receiver']['mailformat'], 'variables' => ['hash' => $hash]]; TypoScriptUtility::overwriteValueFromTypoScript($email['receiverName'], $this->conf['receiver.']['overwrite.'], 'name'); TypoScriptUtility::overwriteValueFromTypoScript($email['senderName'], $this->conf['receiver.']['overwrite.'], 'senderName'); TypoScriptUtility::overwriteValueFromTypoScript($email['senderEmail'], $this->conf['receiver.']['overwrite.'], 'senderEmail'); $sent = $this->sendMailService->sendEmailPreflight($email, $mail, $this->settings, 'receiver'); if (!$sent) { $this->addFlashMessage(LocalizationUtility::translate('error_mail_not_created'), '', AbstractMessage::ERROR); $this->messageClass = 'error'; } } }
/** * Get emails from FlexForm and parse with fluid * * @return array */ protected function getEmailsFromFlexForm() { $emailString = TemplateUtility::fluidParseString($this->settings['receiver']['email'], $this->mailRepository->getVariablesWithMarkersFromMail($this->mail)); return $this->parseEmailsFromString($emailString); }
/** * @param string $string Options from the Textarea * @param $parse * @return array */ protected function buildOptions($string, $parse) { $options = []; $string = str_replace('[\\n]', PHP_EOL, $string); $settingsField = GeneralUtility::trimExplode(PHP_EOL, $string, true); foreach ($settingsField as $line) { $settings = GeneralUtility::trimExplode('|', $line, false); $value = isset($settings[1]) ? $settings[1] : $settings[0]; $label = $parse ? TemplateUtility::fluidParseString($settings[0]) : $settings[0]; $options[] = ['label' => $label, 'value' => $value, 'selected' => isset($settings[2]) ? 1 : 0]; } return $options; }
/** * Create an options array (Needed for fieldsettings: select, radio, check) * option1 => * label => Red Shoes * value => red * selected => 1 * * @param string $string Options from the Textarea * @param string $typoScriptObjectPath Path to TypoScript like lib.blabla * @param bool $parse * @return array Options Array */ protected function optionArray($string, $typoScriptObjectPath, $parse = true) { if (empty($string)) { $string = TypoScriptUtility::parseTypoScriptFromTypoScriptPath($typoScriptObjectPath); } if (empty($string)) { $string = 'Error, no options to show'; } $options = array(); $string = str_replace('[\\n]', PHP_EOL, $string); $settingsField = GeneralUtility::trimExplode(PHP_EOL, $string, true); foreach ($settingsField as $line) { $settings = GeneralUtility::trimExplode('|', $line, false); $value = isset($settings[1]) ? $settings[1] : $settings[0]; $label = $parse ? TemplateUtility::fluidParseString($settings[0]) : $settings[0]; $options[] = array('label' => $label, 'value' => $value, 'selected' => isset($settings[2]) ? 1 : 0); } return $options; }