/** * @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 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(); }
/** * Render a CLI command reference to reStructuredText. * * @param string $reference * @return void */ protected function renderReference($reference) { if (!isset($this->settings['commandReferences'][$reference])) { $this->outputLine('Command reference "%s" is not configured', array($reference)); $this->quit(1); } $referenceConfiguration = $this->settings['commandReferences'][$reference]; $packageKeysToRender = $referenceConfiguration['packageKeys']; array_walk($packageKeysToRender, function (&$packageKey) { $packageKey = strtolower($packageKey); }); $availableCommands = $this->commandManager->getAvailableCommands(); $commandsByPackagesAndControllers = $this->buildCommandsIndex($availableCommands); $allCommandsByPackageKey = array(); foreach ($commandsByPackagesAndControllers as $packageKey => $commandControllers) { if (!in_array($packageKey, $packageKeysToRender)) { $this->outputLine('Skipping package "%s"', array($packageKey)); continue; } $allCommands = array(); foreach ($commandControllers as $commands) { foreach ($commands as $command) { $argumentDescriptions = array(); $optionDescriptions = array(); foreach ($command->getArgumentDefinitions() as $commandArgumentDefinition) { $argumentDescription = $commandArgumentDefinition->getDescription(); if ($commandArgumentDefinition->isRequired()) { $argumentDescriptions[$commandArgumentDefinition->getDashedName()] = $argumentDescription; } else { $optionDescriptions[$commandArgumentDefinition->getDashedName()] = $argumentDescription; } } $relatedCommands = array(); $relatedCommandIdentifiers = $command->getRelatedCommandIdentifiers(); foreach ($relatedCommandIdentifiers as $relatedCommandIdentifier) { try { $relatedCommand = $this->commandManager->getCommandByIdentifier($relatedCommandIdentifier); $relatedCommands[$relatedCommandIdentifier] = $relatedCommand->getShortDescription(); } catch (\TYPO3\Flow\Mvc\Exception\CommandException $exception) { $relatedCommands[$relatedCommandIdentifier] = '*Command not available*'; } } $allCommands[$command->getCommandIdentifier()] = array('identifier' => $command->getCommandIdentifier(), 'shortDescription' => $command->getShortDescription(), 'description' => $this->transformMarkup($command->getDescription()), 'options' => $optionDescriptions, 'arguments' => $argumentDescriptions, 'relatedCommands' => $relatedCommands); } } ksort($allCommands); $allCommandsByPackageKey[strtoupper($packageKey)] = $allCommands; } ksort($allCommandsByPackageKey); $standaloneView = new \TYPO3\Fluid\View\StandaloneView(); $templatePathAndFilename = isset($settings['templatePathAndFilename']) ? $this->settings['commandReference']['templatePathAndFilename'] : 'resource://TYPO3.DocTools/Private/Templates/CommandReferenceTemplate.txt'; $standaloneView->setTemplatePathAndFilename($templatePathAndFilename); $standaloneView->assign('title', isset($referenceConfiguration['title']) ? $referenceConfiguration['title'] : $reference); $standaloneView->assign('allCommandsByPackageKey', $allCommandsByPackageKey); file_put_contents($referenceConfiguration['savePathAndFilename'], $standaloneView->render()); $this->outputLine('DONE.'); }
/** * @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(); }
private function sendMail($from, $to, $data, $templateFile) { $template = new \TYPO3\Fluid\View\StandaloneView(); $template->setFormat('html'); $template->setTemplatePathAndFilename('resource://DRKTettnang.Homepage/Private/Templates/Mail/' . $templateFile . '.html'); $template->setPartialRootPath('resource://DRKTettnang.Homepage/Private/Partials/'); $template->assign('data', $data); $subject = trim($template->renderSection('subject')); $html = $template->render(); $body = trim($template->renderSection('body')); $html2text = new \DRKTettnang\Homepage\Vendor\Html2Text($body); $plain = $html2text->getText(); $mail = new \TYPO3\SwiftMailer\Message(); $mail->setTo($to); $mail->setFrom($from); $mail->setSubject($subject); $mail->addPart($html, 'text/html', 'utf-8'); $mail->addPart($plain, 'text/plain', 'utf-8'); $mail->send(); $this->systemLogger->log('Sent mail to ' . $to, LOG_INFO); }
/** * @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; }
/** * Render a reference to reStructuredText. * * @param string $reference * @return void */ protected function renderReference($reference) { if (!isset($this->settings['references'][$reference])) { $this->outputLine('Reference "%s" is not configured', array($reference)); $this->quit(1); } $referenceConfiguration = $this->settings['references'][$reference]; $affectedClassNames = $this->getAffectedClassNames($referenceConfiguration['affectedClasses']); $parserClassName = $referenceConfiguration['parser']['implementationClassName']; $parserOptions = isset($referenceConfiguration['parser']['options']) ? $referenceConfiguration['parser']['options'] : array(); /** @var $classParser \TYPO3\DocTools\Domain\Service\AbstractClassParser */ $classParser = new $parserClassName($parserOptions); $classReferences = array(); foreach ($affectedClassNames as $className) { $classReferences[$className] = $classParser->parse($className); } usort($classReferences, function (ClassReference $a, ClassReference $b) { if ($a->getTitle() == $b->getTitle()) { return 0; } return $a->getTitle() < $b->getTitle() ? -1 : 1; }); $standaloneView = new \TYPO3\Fluid\View\StandaloneView(); $templatePathAndFilename = isset($referenceConfiguration['templatePathAndFilename']) ? $referenceConfiguration['templatePathAndFilename'] : 'resource://TYPO3.DocTools/Private/Templates/ClassReferenceTemplate.txt'; $standaloneView->setTemplatePathAndFilename($templatePathAndFilename); $standaloneView->assign('title', isset($referenceConfiguration['title']) ? $referenceConfiguration['title'] : $reference); $standaloneView->assign('classReferences', $classReferences); file_put_contents($referenceConfiguration['savePathAndFilename'], $standaloneView->render()); $this->outputLine('DONE.'); }