/**
  * @param string $key
  * @param Deployment $deployment
  * @param SurfCaptainDeployment $surfCaptainDeployment
  * @return void
  */
 protected function sendMail($key, Deployment $deployment, SurfCaptainDeployment $surfCaptainDeployment)
 {
     $settings = $this->getSettingsForFunction($key, $surfCaptainDeployment);
     $pathParts = pathinfo($settings['templatePathAndFilename']);
     $view = new StandaloneView();
     $view->setTemplatePathAndFilename($settings['templatePathAndFilename']);
     $view->setPartialRootPath($pathParts['dirname'] . '/Partials/');
     $view->setPartialRootPath($pathParts['dirname'] . '/Layouts/');
     $view->assign('deployment', $deployment)->assign('surfCaptainDeployment', $surfCaptainDeployment)->assign('settings', $settings);
     $enabled = trim($view->renderSection('Enabled'));
     if (empty($enabled)) {
         return;
     }
     switch (strtolower($pathParts['extension'])) {
         case 'txt':
             $format = 'text/plain';
             break;
         default:
             $format = 'text/html';
     }
     $mail = new Message();
     $mail->setFrom($settings['from'])->setTo($settings['to'])->setSubject(trim($view->renderSection('Subject')))->setBody(trim($view->renderSection('Body')), $format, 'utf-8');
     if (!empty($settings['cc'])) {
         $mail->setCc($settings['cc']);
     }
     if (!empty($settings['bcc'])) {
         $mail->setBcc($settings['bcc']);
     }
     $mail->send();
 }
 /**
  * @param string $templateIdentifier
  * @param string $format
  * @param array $variables
  * @return string
  */
 protected function renderEmailBody($templateIdentifier, $format, array $variables)
 {
     // Default package to use
     $templatePackage = $this->templatePackage ? $this->templatePackage : 'Sandstorm.UserManagement';
     $standaloneView = new StandaloneView();
     $request = $standaloneView->getRequest();
     $request->setControllerPackageKey($templatePackage);
     $request->setFormat($format);
     $templatePathAndFilename = sprintf('resource://' . $templatePackage . '/Private/EmailTemplates/%s.%s', $templateIdentifier, $format);
     $standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
     $standaloneView->assignMultiple($variables);
     return $standaloneView->render();
 }
 /**
  * @test
  * @expectedException \TYPO3\Fluid\View\Exception\InvalidTemplateResourceException
  */
 public function getPartialPathAndFilenameThrowsExceptionIfPartialFileIsADirectory()
 {
     vfsStreamWrapper::register();
     mkdir('vfs://MyPartials/NotAFile');
     $this->standaloneView->setPartialRootPath('vfs://MyPartials');
     $this->standaloneView->_call('getPartialPathAndFilename', 'NotAFile');
 }
Exemple #4
0
 /**
  * @test
  */
 public function getPartialSourceReturnsContentOfDefaultPartialFileIfNoPartialExistsForTheSpecifiedFormat()
 {
     $partialRootPath = dirname(__FILE__) . '/Fixtures';
     $this->view->setPartialRootPath($partialRootPath);
     $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('foo'));
     $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture');
     $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture');
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * @param string $sitePackage
  * @param string $siteName
  * @param string $baseDomain
  * @return Site
  */
 public function importSiteFromTemplate($sitePackage, $siteName, $baseDomain = '')
 {
     if (empty($baseDomain)) {
         $request = Request::createFromEnvironment();
         $baseDomain = $request->getBaseUri()->getHost();
     }
     $siteTemplate = new StandaloneView();
     $siteTemplate->setTemplatePathAndFilename(FLOW_PATH_PACKAGES . 'Sites/' . $sitePackage . '/Resources/Private/Templates/Content/Sites.xml');
     $siteTemplate->assignMultiple(['siteName' => $siteName, 'siteNodeName' => \TYPO3\TYPO3CR\Utility::renderValidNodeName($siteName), 'packageKey' => $sitePackage]);
     $generatedSiteImportXmlContent = $siteTemplate->render();
     $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory();
     $temporarySiteXml = $dataTemporaryPath . uniqid($siteName) . '.xml';
     file_put_contents($temporarySiteXml, $generatedSiteImportXmlContent);
     $site = $this->siteImportService->importFromFile($temporarySiteXml);
     $domain = new Domain();
     $domain->setActive(true);
     $domain->setSite($site);
     $domain->setHostPattern(\TYPO3\TYPO3CR\Utility::renderValidNodeName($siteName) . '.' . $baseDomain);
     $this->domainRepository->add($domain);
     return $site;
 }
 public function sendPasswordResetLink($email, $cryptJson)
 {
     $baseUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'] . '/';
     $requestLink = $baseUrl . 'changepassword?code=' . $cryptJson;
     $templatepath = 'resource://Incvisio.LostFound/Private/Templates/Emails/ForgotPassword.html';
     $this->standaloneView->setFormat('html');
     $this->standaloneView->setTemplatePathAndFilename($templatepath);
     $this->standaloneView->assign('requestLink', $requestLink);
     $emailBody = $this->standaloneView->render();
     $mail = new \TYPO3\SwiftMailer\Message();
     $mail->setTo($email)->setFrom(array('*****@*****.**' => 'LostFound UA'))->setSubject('Reset link')->setBody($emailBody, 'text/html')->send();
 }
 /**
  * @param string $key
  * @param Deployment $deployment
  * @param SurfCaptainDeployment $surfCaptainDeployment
  * @return void
  */
 protected function sendHipChatMessage($key, Deployment $deployment, SurfCaptainDeployment $surfCaptainDeployment)
 {
     $settings = $this->getSettingsForFunction($key, $surfCaptainDeployment);
     $pathParts = pathinfo($settings['templatePathAndFilename']);
     $view = new StandaloneView();
     $view->setTemplatePathAndFilename($settings['templatePathAndFilename']);
     $view->setPartialRootPath($pathParts['dirname'] . '/Partials/');
     $view->setPartialRootPath($pathParts['dirname'] . '/Layouts/');
     $view->assign('deployment', $deployment)->assign('surfCaptainDeployment', $surfCaptainDeployment)->assign('settings', $settings);
     $enabled = trim($view->renderSection('Enabled'));
     if (empty($enabled)) {
         return;
     }
     switch (strtolower($pathParts['extension'])) {
         case 'txt':
             $format = HipChatDriver::MESSAGE_FORMAT_TEXT;
             break;
         default:
             $format = HipChatDriver::MESSAGE_FORMAT_HTML;
     }
     switch ($surfCaptainDeployment->getStatus()) {
         case SurfCaptainDeployment::STATUS_RUNNING:
             $color = HipChatDriver::MESSAGE_COLOR_YELLOW;
             break;
         case SurfCaptainDeployment::STATUS_FAILED:
             $color = HipChatDriver::MESSAGE_COLOR_RED;
             break;
         default:
             $color = HipChatDriver::MESSAGE_COLOR_GREEN;
     }
     $this->hipChatDriver->setSettings($settings)->sendMessage($settings['room'], $view->renderSection('Message'), $format, TRUE, $color);
 }
 /**
  * Prepare a Fluid view for rendering an error page with the Neos backend
  *
  * @return StandaloneView
  */
 protected function prepareFluidView()
 {
     $fluidView = new StandaloneView();
     $fluidView->setTemplatePathAndFilename('resource://TYPO3.Neos/Private/Templates/Error/NeosBackendMessage.html');
     $fluidView->setLayoutRootPath('resource://TYPO3.Neos/Private/Layouts');
     // FIXME find a better way than using templates as partials
     $fluidView->setPartialRootPath('resource://TYPO3.Neos/Private/Templates/TypoScriptObjects');
     $fluidView->setControllerContext($this->runtime->getControllerContext());
     $fluidView->setFormat('html');
     return $fluidView;
 }
 /**
  * Sends email for comment approval
  *
  * @param \Lelesys\Plugin\News\Domain\Model\Comment $comment Comment for approval
  * @param \Lelesys\Plugin\News\Domain\Model\News $news The news
  * @return void
  */
 public function sendCommentApprovalNotification(\Lelesys\Plugin\News\Domain\Model\Comment $comment, \Lelesys\Plugin\News\Domain\Model\News $news)
 {
     $this->standaloneView->setTemplatePathAndFilename(FLOW_PATH_PACKAGES . $this->settings['notifications']['emailTemplatePath']);
     $this->standaloneView->assign('comment', $comment);
     $this->standaloneView->assign('adminEmail', $news->getCreatedBy());
     $this->standaloneView->assign('news', $news);
     $emailBody = $this->standaloneView->render();
     $toEmail = $news->getCreatedBy()->getPrimaryElectronicAddress()->getIdentifier();
     $mail = new \TYPO3\SwiftMailer\Message();
     $mail->setFrom(array($this->settings['notifications']['senderAddress'] => $this->settings['notifications']['senderName']))->setContentType('text/html')->setTo($toEmail)->setSubject('Comment Approval')->setBody($emailBody)->send();
 }
 /**
  * Generate a controller with the given name for the given package
  *
  * @param string $packageKey The package key of the controller's package
  * @param string $subpackage An optional subpackage name
  * @param string $controllerName The name of the new controller
  * @param string $modelClassName The name of the model to base the controler on
  * @param boolean $overwrite Overwrite any existing files?
  * @return array An array of generated filenames
  */
 public function generateCrudAction($packageKey, $subpackage, $controllerName, $modelClassName, $actionName, $overwrite = FALSE)
 {
     $controllerName = ucfirst($controllerName);
     $shortModelClassName = substr($modelClassName, strrpos($modelClassName, '\\'));
     $view = new StandaloneView();
     $view->setTemplatePathAndFilename('resource://Sandstorm.CrudForms/Private/Generator/Resources/Private/Templates/' . $actionName . '.html.tmpl');
     $view->assign('subpackage', $subpackage);
     $view->assign('modelClassName', $modelClassName);
     $view->assign('shortModelClassName', $shortModelClassName);
     $fileContent = '{namespace crud=Sandstorm\\CrudForms\\ViewHelpers}' . chr(10) . $view->render();
     $subpackagePath = $subpackage != '' ? $subpackage . '/' : '';
     $this->generateFile('resource://' . $packageKey . '/Private/Templates/' . $subpackagePath . $controllerName . '/' . $actionName . '.html', $fileContent, $overwrite);
     return $this->generatedFiles;
 }
 /**
  * @param NodeInterface $node
  * @return string
  * @throws NeosException
  */
 public function render(NodeInterface $node)
 {
     if ($this->privilegeManager->isPrivilegeTargetGranted('TYPO3.Neos:Backend.GeneralAccess') === false) {
         return '';
     }
     /** @var $actionRequest ActionRequest */
     $actionRequest = $this->controllerContext->getRequest();
     $innerView = new StandaloneView($actionRequest);
     $innerView->setTemplatePathAndFilename('resource://TYPO3.Neos/Private/Templates/Backend/Content/Container.html');
     $innerView->setFormat('html');
     $innerView->setPartialRootPath('resource://TYPO3.Neos/Private/Partials');
     $user = $this->securityContext->getPartyByType('TYPO3\\Neos\\Domain\\Model\\User');
     $innerView->assignMultiple(array('node' => $node, 'modules' => $this->menuHelper->buildModuleList($this->controllerContext), 'sites' => $this->menuHelper->buildSiteList($this->controllerContext), 'user' => $user));
     return $innerView->render();
 }
 protected function createIdentifierForFile($pathAndFilename, $prefix)
 {
     $prefix = $this->fileIdentifierPrefix . $prefix;
     return parent::createIdentifierForFile($pathAndFilename, $prefix);
 }
 /**
  * @param AbstractTypoScriptObject $typoScriptObject
  * @param ActionRequest $request The current action request. If none is specified it will be created from the environment.
  */
 public function __construct(AbstractTypoScriptObject $typoScriptObject, ActionRequest $request = null)
 {
     parent::__construct($request);
     $this->typoScriptObject = $typoScriptObject;
 }
Exemple #14
0
 /**
  * @param \TYPO3\Fluid\View\StandaloneView $view
  * @return void
  */
 protected function addTemplateViewPaths(StandaloneView &$view)
 {
     $translatedPaths = $this->environment->getTranslatedTemplatePaths();
     $view->setPartialRootPath($translatedPaths['partialRootPath']);
     $view->setLayoutRootPath($translatedPaths['layoutRootPath']);
 }
 /**
  * Prepares a Fluid view for rendering the custom error page.
  *
  * @param \Exception $exception
  * @param array $renderingOptions Rendering options as defined in the settings
  * @return StandaloneView
  */
 protected function buildCustomFluidView(\Exception $exception, array $renderingOptions)
 {
     $statusCode = 500;
     $referenceCode = NULL;
     if ($exception instanceof FlowException) {
         $statusCode = $exception->getStatusCode();
         $referenceCode = $exception->getReferenceCode();
     }
     $statusMessage = Response::getStatusMessageByCode($statusCode);
     $fluidView = new StandaloneView();
     $fluidView->getRequest()->setControllerPackageKey('TYPO3.Flow');
     $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;
 }
Exemple #16
0
 /**
  * TODO: Document this Method! ( render )
  */
 public function render()
 {
     \Debug\Toolbar\Service\DataStorage::save();
     $this->view->assign('modules', \Debug\Toolbar\Service\Collector::getModules());
     return $this->view->render();
 }
 /**
  * @return StandaloneView
  */
 protected function createStandaloneView()
 {
     // initialize view
     $standaloneView = new StandaloneView();
     $actionRequest = $standaloneView->getRequest();
     // inject TYPO3.Flow settings to fetch base URI configuration & set default package key
     $flowSettings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow');
     if (isset($flowSettings['http']['baseUri'])) {
         $actionRequest->getHttpRequest()->setBaseUri($flowSettings['http']['baseUri']);
     }
     $actionRequest->setControllerPackageKey('T3DD.Backend');
     return $standaloneView;
 }
 /**
  * @param string $defaultPackageKey
  * @return StandaloneView
  */
 protected function createStandaloneView($defaultPackageKey = null)
 {
     // initialize router
     $this->router->setRoutesConfiguration($this->routesConfiguration);
     // initialize view
     $standaloneView = new StandaloneView();
     $actionRequest = $standaloneView->getRequest();
     // inject TYPO3.Flow settings to fetch base URI configuration & set default package key
     if (isset($this->flowSettings['http']['baseUri'])) {
         $actionRequest->getHttpRequest()->setBaseUri($this->flowSettings['http']['baseUri']);
     }
     $actionRequest->setControllerPackageKey($defaultPackageKey);
     return $standaloneView;
 }
Exemple #19
0
 public function initializeObject()
 {
     parent::initializeObject();
     $this->request->setFormat('html');
 }