Example #1
0
 /**
  * TODO: Document this Method! ( __construct )
  */
 public function __construct()
 {
     $this->view = new \TYPO3\Fluid\View\StandaloneView();
     $this->view->setTemplatePathAndFilename('resource://Debug.Toolbar/Private/Templates/Toolbar.html');
     $this->view->setPartialRootPath('resource://Debug.Toolbar/Private/Partials/');
     $this->view->setFormat('html');
 }
Example #2
0
 /**
  * @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);
 }
Example #3
0
 /**
  * @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();
 }
 /**
  * @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');
 }
Example #5
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);
 }
 /**
  * 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;
 }
 /**
  * @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();
 }
Example #8
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;
 }