/** * Show mails in a list * * @return void */ public function listAction() { $this->prepareFilterPluginVariables($this->piVars, $this->settings['search']['staticPluginsVariables']); $fieldArray = $this->getFieldList($this->settings['list']['fields']); $searchFields = $this->fieldRepository->findByUids(GeneralUtility::trimExplode(',', $this->settings['search']['fields'], true)); $this->view->assignMultiple(['mails' => $this->mailRepository->findListBySettings($this->settings, $this->piVars), 'searchFields' => $searchFields, 'fields' => $this->fieldRepository->findByUids($fieldArray), 'piVars' => $this->piVars, 'abc' => ArrayUtility::getAbcArray()]); $this->assignMultipleActions(); }
/** * 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'); }
/** * Returns the value * * @return mixed $value */ public function getValue() { $value = $this->value; // if serialized, change to array if (ArrayUtility::isJsonArray($this->value)) { // only if type multivalue or upload if ($this->getValueType() === 1 || $this->getValueType() === 3) { $value = json_decode($value, true); } } if ($this->isTypeDateForTimestamp($value)) { $value = date(LocalizationUtility::translate('datepicker_format_' . $this->getField()->getDatepickerSettings()), $value); } if ($this->isTypeMultiple($value)) { $value = empty($value) ? [] : [strval($value)]; } return $value; }
/** * Returns the value * * @return mixed $value */ public function getValue() { $value = $this->value; // if serialized, change to array if (ArrayUtility::isJsonArray($this->value)) { // only if type multivalue or upload if ($this->getValueType() === 1 || $this->getValueType() === 3) { $value = json_decode($value, true); } } // if type date if ($this->getValueType() === 2 && is_numeric($value) && $this->getField() !== null) { $value = date(LocalizationUtility::translate('datepicker_format_' . $this->getField()->getDatepickerSettings()), $value); } // if multitext or upload force array if (($this->getValueType() === 1 || $this->getValueType() === 3) && !is_array($value)) { $value = empty($value) ? array() : array(strval($value)); } return $value; }
/** * 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; }
/** * 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; }
/** * Set a powermail session and merge to old one * * @param string $name session name * @param array $values values to save * @param bool $overwrite Overwrite existing values * @param string $method "user" or "ses" * @param string $key name to save session * @return void */ protected static function setSessionValue($name, $values, $overwrite = false, $method = 'ses', $key = '') { if (empty($key)) { $key = self::$extKey; } if (!$overwrite) { $oldValues = self::getSessionValue($name, $method, $key); if (!empty($oldValues)) { $values = ArrayUtility::arrayMergeRecursiveOverrule((array) $oldValues, (array) $values); } } $newValues = [$name => $values]; self::getTyposcriptFrontendController()->fe_user->setKey($method, $key, $newValues); self::getTyposcriptFrontendController()->storeSessionData(); }
/** * @return array */ public function getMarketingPageFunnel() { if (ArrayUtility::isJsonArray($this->marketingPageFunnel)) { return json_decode($this->marketingPageFunnel); } return (array) $this->marketingPageFunnel; }
/** * htmlspecialcharsOnArray Test * * @param array $array * @param array $expectedResult * @dataProvider htmlspecialcharsOnArrayReturnsArrayDataProvider * @return void * @test */ public function htmlspecialcharsOnArrayReturnsArray($array, $expectedResult) { $this->assertSame($expectedResult, ArrayUtility::htmlspecialcharsOnArray($array)); }
/** * isJsonArray Test * * @param string $value * @param bool $expectedResult * @dataProvider isJsonArrayReturnsBoolDataProvider * @return void * @test */ public function isJsonArrayReturnsBool($value, $expectedResult) { $this->assertSame($expectedResult, ArrayUtility::isJsonArray($value)); }
/** * Merges Flexform, TypoScript and Extension Manager Settings * Note: If FF value is empty, we want the TypoScript value instead * * @param array $settings All settings * @param string $typoScriptLevel Startpoint * @return void */ public static function mergeTypoScript2FlexForm(&$settings, $typoScriptLevel = 'setup') { $settings = ArrayUtility::arrayMergeRecursiveOverrule((array) $settings[$typoScriptLevel], (array) $settings['flexform'], false, false); }