/** * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node * @return string */ public function render(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node) { $view = new \TYPO3\Fluid\View\StandaloneView($this->controllerContext->getRequest()); $view->setTemplatePathAndFilename('resource://TYPO3.TYPO3/Private/Templates/Backend/Content/Container.html'); $view->assignMultiple(array('node' => $node, 'modules' => $this->settings['modules'])); return $view->render(); }
/** * @param $templateIdentifier * @param \GIB\GradingTool\Domain\Model\Project $project * @param \GIB\GradingTool\Domain\Model\ProjectManager $projectManager * @param string $recipientName * @param string $recipientEmail * @param string $additionalContent * @param array $attachements * @return bool|void */ public function sendNotificationMail($templateIdentifier, \GIB\GradingTool\Domain\Model\Project $project, \GIB\GradingTool\Domain\Model\ProjectManager $projectManager = NULL, $recipientName = '', $recipientEmail = '', $additionalContent = '', $attachements = array()) { if ($this->settings['email']['activateNotifications'] === FALSE) { return TRUE; } /** @var \GIB\GradingTool\Domain\Model\Template $template */ $template = $this->templateRepository->findOneByTemplateIdentifier($templateIdentifier); $templateContentArray = unserialize($template->getContent()); // some kind of wrapper of all e-mail templates containing the HTML structure and styles $beforeContent = Files::getFileContents($this->settings['email']['beforeContentTemplate']); $afterContent = Files::getFileContents($this->settings['email']['afterContentTemplate']); /** @var \TYPO3\Fluid\View\StandaloneView $emailView */ $emailView = new \TYPO3\Fluid\View\StandaloneView(); $emailView->setTemplateSource('<f:format.raw>' . $beforeContent . $templateContentArray['content'] . $afterContent . '</f:format.raw>'); $emailView->setPartialRootPath(FLOW_PATH_PACKAGES . 'Application/GIB.GradingTool/Resources/Private/Partials'); $emailView->setFormat('html'); $emailView->assignMultiple(array('beforeContent' => $beforeContent, 'afterContent' => $afterContent, 'project' => $project, 'projectManager' => $projectManager, 'dataSheetContent' => $project->getDataSheetContentArray(), 'additionalContent' => $additionalContent)); $emailBody = $emailView->render(); /** @var \TYPO3\SwiftMailer\Message $email */ $email = new Message(); $email->setFrom(array($templateContentArray['senderEmail'] => $templateContentArray['senderName'])); // the recipient e-mail can be overridden by method arguments if (!empty($recipientEmail)) { $email->setTo(array((string) $recipientEmail => (string) $recipientName)); // in this case, send a bcc to the GIB team $email->setBcc(array($templateContentArray['senderEmail'] => $templateContentArray['senderName'])); } else { $email->setTo(array($templateContentArray['recipientEmail'] => $templateContentArray['recipientName'])); } if (!empty($attachements)) { foreach ($attachements as $attachement) { $email->attach(\Swift_Attachment::fromPath($attachement['source'])->setFilename($attachement['fileName'])); } } $email->setSubject($templateContentArray['subject']); $email->setBody($emailBody, 'text/html'); $email->send(); }
/** * @param string $templatePathAndFilename * @param array $arguments * @return string */ public function render($templatePathAndFilename, $arguments = array()) { $standaloneView = new \TYPO3\Fluid\View\StandaloneView($this->controllerContext->getRequest()); $standaloneView->setTemplatePathAndFilename($templatePathAndFilename); return $standaloneView->assignMultiple($arguments)->render(); }
/** * @param string $templateName * @param array $arguments * @return string */ public function pdfTemplateRenderer($templateName, $arguments) { $standAloneView = new \TYPO3\Fluid\View\StandaloneView(); $standAloneView->setTemplatePathAndFilename('resource://GIB.GradingTool/Private/Templates/PdfExport/' . $templateName . '.html'); $standAloneView->assignMultiple($arguments); return $standAloneView->render(); }
/** * @return \TYPO3\Fluid\View\StandaloneView * @throws \TYPO3\Form\Exception\FinisherException */ protected function initializeStandaloneView() { $standaloneView = new \TYPO3\Fluid\View\StandaloneView(); if (!isset($this->options['templatePathAndFilename'])) { throw new \TYPO3\Form\Exception\FinisherException('The option "templatePathAndFilename" must be set for the EmailFinisher.', 1327058829); } $standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']); if (isset($this->options['partialRootPath'])) { $standaloneView->setPartialRootPath($this->options['partialRootPath']); } if (isset($this->options['layoutRootPath'])) { $standaloneView->setLayoutRootPath($this->options['layoutRootPath']); } if (isset($this->options['variables'])) { $standaloneView->assignMultiple($this->options['variables']); } return $standaloneView; }
/** * Prepares a Fluid view for rendering the custom error page. * * @param \Exception $exception * @param array $renderingOptions Rendering options as defined in the settings * @return \TYPO3\Fluid\View\StandaloneView */ protected function buildCustomFluidView(\Exception $exception, array $renderingOptions) { $statusCode = 500; $referenceCode = NULL; if ($exception instanceof \TYPO3\Flow\Exception) { $statusCode = $exception->getStatusCode(); $referenceCode = $exception->getReferenceCode(); } $statusMessage = \TYPO3\Flow\Http\Response::getStatusMessageByCode($statusCode); $fluidView = new \TYPO3\Fluid\View\StandaloneView(); $fluidView->setTemplatePathAndFilename($renderingOptions['templatePathAndFilename']); if (isset($renderingOptions['layoutRootPath'])) { $fluidView->setLayoutRootPath($renderingOptions['layoutRootPath']); } if (isset($renderingOptions['partialRootPath'])) { $fluidView->setPartialRootPath($renderingOptions['partialRootPath']); } if (isset($renderingOptions['format'])) { $fluidView->setFormat($renderingOptions['format']); } if (isset($renderingOptions['variables'])) { $fluidView->assignMultiple($renderingOptions['variables']); } $fluidView->assignMultiple(array('exception' => $exception, 'renderingOptions' => $renderingOptions, 'statusCode' => $statusCode, 'statusMessage' => $statusMessage, 'referenceCode' => $referenceCode)); return $fluidView; }