Example #1
0
 /**
  * @param ViewInterface $view
  * @return void
  */
 public function initializeView(ViewInterface $view)
 {
     $record = $this->getRecord();
     $this->configurationManager->getContentObject()->data = $record;
     parent::initializeView($view);
     $this->response->addAdditionalHeaderData((string) $this->view->renderStandaloneSection('HeaderCode', $this->provider->getTemplateVariables($record), true));
 }
 /**
  * @param \TYPO3\CMS\Extbase\Mvc\Web\Response $response
  * @return \TYPO3\CMS\Extbase\Mvc\Web\Response
  * @throws FailedConversionException
  */
 public function convert($response)
 {
     $pathToPDFGenFile = $this->extensionConfiguration->get('pathToPDFGenFile');
     if ($pathToPDFGenFile) {
         list($return_value, $output, $error) = $this->runCommands($pathToPDFGenFile, $response->getContent());
         if ($return_value != 0) {
             error_log("EssentialDots\\ExtbaseHijax\\HTMLConverter\\PDFConverter error:\n{$error}");
             /* @var $failedConversionException \EssentialDots\ExtbaseHijax\HTMLConverter\FailedConversionException */
             $failedConversionException = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('EssentialDots\\ExtbaseHijax\\HTMLConverter\\FailedConversionException');
             $failedConversionException->setError($error);
             $failedConversionException->setInput($response);
             $failedConversionException->setOutput($output);
             $failedConversionException->setReturnValue($return_value);
             throw $failedConversionException;
         } else {
             $filename = $this->extractTitle($response->getContent());
             $response->setContent($output);
             $response->setHeader('Content-Type', 'application/pdf');
             if ($filename) {
                 $fileFunc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
                 /* @var $fileFunc \TYPO3\CMS\Core\Utility\File\BasicFileUtility */
                 $filename = '; filename = "' . $fileFunc->cleanFileName($filename) . '.pdf"';
                 $response->setHeader('Content-Disposition', 'attachment' . $filename);
             } else {
                 $response->setHeader('Content-Disposition', 'inline');
             }
         }
     }
     return $response;
 }
Example #3
0
 /**
  * @return string
  */
 public function render()
 {
     # As of this writing, Json header is not automatically sent in the BE... even with json=format.
     $this->response->setHeader('Content-Type', 'application/json');
     $this->response->sendHeaders();
     return json_encode($this->result->toArray());
 }
Example #4
0
 /**
  * Redirects the web request to another uri.
  *
  * NOTE: This method only supports web requests and will thrown an exception if used with other request types.
  *
  * @param string $uri A string representation of a URI
  * @param int $delay (optional) The delay in seconds. Default is no delay.
  * @param int $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other
  * @throws UnsupportedRequestTypeException If the request is not a web request
  * @throws StopActionException
  */
 protected function redirectToUri(string $uri, int $delay = 0, int $statusCode = 303)
 {
     if (!$this->request instanceof Request) {
         throw new UnsupportedRequestTypeException('redirect() only supports web requests.', 1471776458);
     }
     $uri = $this->addBaseUriIfNecessary($uri);
     $escapedUri = htmlentities($uri, ENT_QUOTES, 'utf-8');
     $this->response->setContent('<html><head><meta http-equiv="refresh" content="' . (int) $delay . ';url=' . $escapedUri . '"/></head></html>');
     if ($this->response instanceof \TYPO3\CMS\Extbase\Mvc\Web\Response) {
         $this->response->setStatus($statusCode);
         $this->response->setHeader('Location', (string) $uri);
     }
     echo $this->response->shutdown();
     throw new StopActionException('redirectToUri', 1477070964);
 }
 /**
  * @param \I4W\Fileshare\Domain\Model\Share $share
  * @throws \RuntimeException
  * @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
  * @return string
  * @dontvalidate
  */
 public function downloadAllAction(\I4W\Fileshare\Domain\Model\Share $share = null)
 {
     if (false === $share instanceof Share) {
         throw new PageNotFoundException('Could not find  share', 1435910678);
     }
     $zip = new \ZipArchive();
     $res = $zip->open($share->getToken() . '.zip', \ZipArchive::CREATE);
     if (!$res) {
         throw new \RuntimeException('Could not create ZIP archive', 1435909664);
     }
     foreach ($this->getFilesFromShare($share) as $file) {
         /** @var File $file */
         $zip->addFromString($file->getName(), $file->getContents());
     }
     $zip->close();
     $this->response->setHeader('Cache-control', 'public', true);
     $this->response->setHeader('Content-Description', 'File transfer', true);
     $this->response->setHeader('Content-Disposition', 'attachment; filename=' . $share->getToken() . '.zip', true);
     $this->response->setHeader('Content-Type', 'application/zip', true);
     $this->response->sendHeaders();
     readfile($share->getToken() . '.zip');
     exit;
 }
Example #6
0
 /**
  * @test
  */
 public function renderSetsContentTypeHeader()
 {
     $this->response->expects($this->once())->method('setHeader')->with('Content-Type', 'application/json');
     $this->view->render();
 }
Example #7
0
 /**
  * Render this form.
  *
  * @return null|string rendered form
  * @throws RenderingException
  * @api
  */
 public function render()
 {
     if ($this->isAfterLastPage()) {
         $this->invokeFinishers();
         return $this->response->getContent();
     }
     $this->formState->setLastDisplayedPageIndex($this->currentPage->getIndex());
     if ($this->formDefinition->getRendererClassName() === null) {
         throw new RenderingException(sprintf('The form definition "%s" does not have a rendererClassName set.', $this->formDefinition->getIdentifier()), 1326095912);
     }
     $rendererClassName = $this->formDefinition->getRendererClassName();
     $renderer = $this->objectManager->get($rendererClassName);
     if (!$renderer instanceof RendererInterface) {
         throw new RenderingException(sprintf('The renderer "%s" des not implement RendererInterface', $rendererClassName), 1326096024);
     }
     $controllerContext = $this->getControllerContext();
     $renderer->setControllerContext($controllerContext);
     $renderer->setFormRuntime($this);
     return $renderer->render($this);
 }