コード例 #1
0
 /**
  * Parses variables again
  *
  * @param \In2code\Powermail\Domain\Model\Mail $mail Variables and Labels array
  * @param string $type "web" or "mail"
  * @param string $function "createAction", "senderMail", "receiverMail"
  * @return string Changed string
  */
 public function render(Mail $mail, $type = 'web', $function = 'createAction')
 {
     /** @var \TYPO3\CMS\Fluid\View\StandaloneView $parseObject */
     $parseObject = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $parseObject->setTemplateSource($this->removePowermailAllParagraphTagWrap($this->renderChildren()));
     $parseObject->assignMultiple(ArrayUtility::htmlspecialcharsOnArray($this->mailRepository->getVariablesWithMarkersFromMail($mail)));
     $parseObject->assignMultiple(ArrayUtility::htmlspecialcharsOnArray($this->mailRepository->getLabelsWithMarkersFromMail($mail)));
     $parseObject->assign('powermail_all', TemplateUtility::powermailAll($mail, $type, $this->settings, $function));
     return html_entity_decode($parseObject->render(), ENT_QUOTES, 'UTF-8');
 }
コード例 #2
0
 /**
  * Create Email Body
  *
  * @param array $email Array with all needed mail information
  * @return bool
  */
 protected function createEmailBody($email)
 {
     $standaloneView = TemplateUtility::getDefaultStandAloneView();
     $standaloneView->getRequest()->setControllerName('Form');
     $standaloneView->setTemplatePathAndFilename(TemplateUtility::getTemplatePath($email['template'] . '.html'));
     $standaloneView->setLayoutRootPaths(TemplateUtility::getTemplateFolders('layout'));
     $standaloneView->setPartialRootPaths(TemplateUtility::getTemplateFolders('partial'));
     // variables
     $variablesWithMarkers = $this->mailRepository->getVariablesWithMarkersFromMail($this->mail);
     $standaloneView->assignMultiple($variablesWithMarkers);
     $standaloneView->assignMultiple($this->mailRepository->getLabelsWithMarkersFromMail($this->mail));
     $standaloneView->assignMultiple(array('variablesWithMarkers' => ArrayUtility::htmlspecialcharsOnArray($variablesWithMarkers), 'powermail_all' => TemplateUtility::powermailAll($this->mail, 'mail', $this->settings, $this->type), 'powermail_rte' => $email['rteBody'], 'marketingInfos' => SessionUtility::getMarketingInfos(), 'mail' => $this->mail, 'email' => $email, 'settings' => $this->settings));
     if (!empty($email['variables'])) {
         $standaloneView->assignMultiple($email['variables']);
     }
     $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforeRender', array($standaloneView, $email, $this->mail, $this->settings));
     $body = $standaloneView->render();
     $this->mail->setBody($body);
     return $body;
 }
コード例 #3
0
 /**
  * Generate a new array with markers and their values
  *        firstname => value
  *
  * @param Mail $mail
  * @param bool $htmlSpecialChars
  * @return array
  */
 public function getVariablesWithMarkersFromMail(Mail $mail, $htmlSpecialChars = false)
 {
     $variables = array();
     foreach ($mail->getAnswers() as $answer) {
         if (!method_exists($answer, 'getField') || !method_exists($answer->getField(), 'getMarker')) {
             continue;
         }
         $value = $answer->getValue();
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         $variables[$answer->getField()->getMarker()] = $value;
     }
     if ($htmlSpecialChars) {
         $variables = ArrayUtility::htmlspecialcharsOnArray($variables);
     }
     return $variables;
 }
コード例 #4
0
 /**
  * htmlspecialcharsOnArray Test
  *
  * @param array $array
  * @param array $expectedResult
  * @dataProvider htmlspecialcharsOnArrayReturnsArrayDataProvider
  * @return void
  * @test
  */
 public function htmlspecialcharsOnArrayReturnsArray($array, $expectedResult)
 {
     $this->assertSame($expectedResult, ArrayUtility::htmlspecialcharsOnArray($array));
 }