Completed
Push — master ( 892a3f...068784 )
by Fabien
50:28
created
Classes/Controller/FacetController.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,50 +21,50 @@
 block discarded – undo
21 21
 class FacetController extends ActionController
22 22
 {
23 23
 
24
-    /**
25
-     * Suggest values according to a facet.
26
-     * Output a json list of key / values.
27
-     *
28
-     * @param string $facet
29
-     * @param string $searchTerm
30
-     * @Validate("Fab\Vidi\Domain\Validator\FacetValidator", param="facet")
31
-     */
32
-    public function autoSuggestAction($facet, $searchTerm)
33
-    {
24
+	/**
25
+	 * Suggest values according to a facet.
26
+	 * Output a json list of key / values.
27
+	 *
28
+	 * @param string $facet
29
+	 * @param string $searchTerm
30
+	 * @Validate("Fab\Vidi\Domain\Validator\FacetValidator", param="facet")
31
+	 */
32
+	public function autoSuggestAction($facet, $searchTerm)
33
+	{
34 34
 
35
-        $suggestions = $this->getFacetSuggestionService()->getSuggestions($facet);
35
+		$suggestions = $this->getFacetSuggestionService()->getSuggestions($facet);
36 36
 
37 37
 
38
-        return $this->responseFactory->createResponse()
39
-            ->withAddedHeader('Content-Type', 'application/json')
40
-            ->withBody($this->streamFactory->createStream(json_encode($suggestions)));
41
-    }
38
+		return $this->responseFactory->createResponse()
39
+			->withAddedHeader('Content-Type', 'application/json')
40
+			->withBody($this->streamFactory->createStream(json_encode($suggestions)));
41
+	}
42 42
 
43
-    /**
44
-     * Suggest values for all configured facets in the Grid.
45
-     * Output a json list of key / values.
46
-     */
47
-    public function autoSuggestsAction()
48
-    {
43
+	/**
44
+	 * Suggest values for all configured facets in the Grid.
45
+	 * Output a json list of key / values.
46
+	 */
47
+	public function autoSuggestsAction()
48
+	{
49 49
 
50
-        $suggestions = [];
51
-        foreach (Tca::grid()->getFacets() as $facet) {
52
-            /** @var FacetInterface $facet */
53
-            $name = $facet->getName();
54
-            $suggestions[$name] = $this->getFacetSuggestionService()->getSuggestions($name);
55
-        }
50
+		$suggestions = [];
51
+		foreach (Tca::grid()->getFacets() as $facet) {
52
+			/** @var FacetInterface $facet */
53
+			$name = $facet->getName();
54
+			$suggestions[$name] = $this->getFacetSuggestionService()->getSuggestions($name);
55
+		}
56 56
 
57
-        return $this->responseFactory->createResponse()
58
-            ->withAddedHeader('Content-Type', 'application/json')
59
-            ->withBody($this->streamFactory->createStream(json_encode($suggestions)));
60
-    }
57
+		return $this->responseFactory->createResponse()
58
+			->withAddedHeader('Content-Type', 'application/json')
59
+			->withBody($this->streamFactory->createStream(json_encode($suggestions)));
60
+	}
61 61
 
62
-    /**
63
-     * @return FacetSuggestionService|object
64
-     */
65
-    protected function getFacetSuggestionService()
66
-    {
67
-        return GeneralUtility::makeInstance(FacetSuggestionService::class);
68
-    }
62
+	/**
63
+	 * @return FacetSuggestionService|object
64
+	 */
65
+	protected function getFacetSuggestionService()
66
+	{
67
+		return GeneralUtility::makeInstance(FacetSuggestionService::class);
68
+	}
69 69
 
70 70
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/ExportXlsMenuItem.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,20 +17,20 @@
 block discarded – undo
17 17
 class ExportXlsMenuItem extends AbstractComponentView
18 18
 {
19 19
 
20
-    /**
21
-     * Renders a "xls export" item to be placed in the menu.
22
-     * Only the admin is allowed to export for now as security is not handled.
23
-     *
24
-     * @return string
25
-     * @throws \InvalidArgumentException
26
-     */
27
-    public function render()
28
-    {
29
-        $result = sprintf('<li><a href="#" class="dropdown-item export-xls" data-format="xls">%s %s</a></li>',
30
-            $this->getIconFactory()->getIcon('mimetypes-excel', Icon::SIZE_SMALL),
31
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xls')
32
-        );
33
-        return $result;
34
-    }
20
+	/**
21
+	 * Renders a "xls export" item to be placed in the menu.
22
+	 * Only the admin is allowed to export for now as security is not handled.
23
+	 *
24
+	 * @return string
25
+	 * @throws \InvalidArgumentException
26
+	 */
27
+	public function render()
28
+	{
29
+		$result = sprintf('<li><a href="#" class="dropdown-item export-xls" data-format="xls">%s %s</a></li>',
30
+			$this->getIconFactory()->getIcon('mimetypes-excel', Icon::SIZE_SMALL),
31
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xls')
32
+		);
33
+		return $result;
34
+	}
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/ExportCsvMenuItem.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@
 block discarded – undo
17 17
 class ExportCsvMenuItem extends AbstractComponentView
18 18
 {
19 19
 
20
-    /**
21
-     * Renders a "csv export" item to be placed in the menu.
22
-     * Only the admin is allowed to export for now as security is not handled.
23
-     *
24
-     * @return string
25
-     * @throws \InvalidArgumentException
26
-     */
27
-    public function render()
28
-    {
29
-        $result = sprintf('<li><a href="#" class="dropdown-item export-csv" data-format="csv">%s %s</a></li>',
30
-            $this->getIconFactory()->getIcon('mimetypes-text-csv', Icon::SIZE_SMALL),
31
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-csv')
32
-        );
33
-        return $result;
34
-    }
20
+	/**
21
+	 * Renders a "csv export" item to be placed in the menu.
22
+	 * Only the admin is allowed to export for now as security is not handled.
23
+	 *
24
+	 * @return string
25
+	 * @throws \InvalidArgumentException
26
+	 */
27
+	public function render()
28
+	{
29
+		$result = sprintf('<li><a href="#" class="dropdown-item export-csv" data-format="csv">%s %s</a></li>',
30
+			$this->getIconFactory()->getIcon('mimetypes-text-csv', Icon::SIZE_SMALL),
31
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-csv')
32
+		);
33
+		return $result;
34
+	}
35 35
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/MassDeleteMenuItem.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -17,35 +17,35 @@
 block discarded – undo
17 17
 class MassDeleteMenuItem extends AbstractComponentView
18 18
 {
19 19
 
20
-    /**
21
-     * Renders a "mass delete" menu item to be placed in the grid menu.
22
-     *
23
-     * @return string
24
-     * @throws \InvalidArgumentException
25
-     */
26
-    public function render()
27
-    {
28
-        return sprintf('<li><a href="%s" class="dropdown-item mass-delete" >%s %s</a>',
29
-            $this->getMassDeleteUri(),
30
-            $this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL),
31
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:delete')
32
-        );
33
-    }
20
+	/**
21
+	 * Renders a "mass delete" menu item to be placed in the grid menu.
22
+	 *
23
+	 * @return string
24
+	 * @throws \InvalidArgumentException
25
+	 */
26
+	public function render()
27
+	{
28
+		return sprintf('<li><a href="%s" class="dropdown-item mass-delete" >%s %s</a>',
29
+			$this->getMassDeleteUri(),
30
+			$this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL),
31
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:delete')
32
+		);
33
+	}
34 34
 
35
-    /**
36
-     * @return string
37
-     * @throws \InvalidArgumentException
38
-     */
39
-    protected function getMassDeleteUri()
40
-    {
41
-        $additionalParameters = array(
42
-            $this->getModuleLoader()->getParameterPrefix() => array(
43
-                'controller' => 'Content',
44
-                'action' => 'delete',
45
-                'format' => 'json',
46
-            ),
47
-        );
48
-        return $this->getModuleLoader()->getModuleUrl($additionalParameters);
49
-    }
35
+	/**
36
+	 * @return string
37
+	 * @throws \InvalidArgumentException
38
+	 */
39
+	protected function getMassDeleteUri()
40
+	{
41
+		$additionalParameters = array(
42
+			$this->getModuleLoader()->getParameterPrefix() => array(
43
+				'controller' => 'Content',
44
+				'action' => 'delete',
45
+				'format' => 'json',
46
+			),
47
+		);
48
+		return $this->getModuleLoader()->getModuleUrl($additionalParameters);
49
+	}
50 50
 
51 51
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/DividerMenuItem.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
 class DividerMenuItem extends AbstractComponentView
17 17
 {
18 18
 
19
-    /**
20
-     * Renders a "divider" menu item to be placed in the grid menu.
21
-     *
22
-     * @return string
23
-     */
24
-    public function render()
25
-    {
26
-        return ' <li><hr class="dropdown-divider"></li>';
27
-    }
19
+	/**
20
+	 * Renders a "divider" menu item to be placed in the grid menu.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function render()
25
+	{
26
+		return ' <li><hr class="dropdown-divider"></li>';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/ExportXmlMenuItem.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,20 +17,20 @@
 block discarded – undo
17 17
 class ExportXmlMenuItem extends AbstractComponentView
18 18
 {
19 19
 
20
-    /**
21
-     * Renders an "xml export" item to be placed in the menu.
22
-     * Only the admin is allowed to export for now as security is not handled.
23
-     *
24
-     * @return string
25
-     * @throws \InvalidArgumentException
26
-     */
27
-    public function render()
28
-    {
29
-        $result = sprintf('<li><a href="#" class="dropdown-item export-xml" data-format="xml">%s %s</a></li>',
30
-            $this->getIconFactory()->getIcon('mimetypes-text-html', Icon::SIZE_SMALL),
31
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xml')
32
-        );
33
-        return $result;
34
-    }
20
+	/**
21
+	 * Renders an "xml export" item to be placed in the menu.
22
+	 * Only the admin is allowed to export for now as security is not handled.
23
+	 *
24
+	 * @return string
25
+	 * @throws \InvalidArgumentException
26
+	 */
27
+	public function render()
28
+	{
29
+		$result = sprintf('<li><a href="#" class="dropdown-item export-xml" data-format="xml">%s %s</a></li>',
30
+			$this->getIconFactory()->getIcon('mimetypes-text-html', Icon::SIZE_SMALL),
31
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xml')
32
+		);
33
+		return $result;
34
+	}
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Be/AdditionalAssetsViewHelper.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
     protected function resolvePath($uri)
59 59
     {
60 60
         $uri = GeneralUtility::getFileAbsFileName($uri);
61
-        $uri = substr($uri, strlen(Environment::getPublicPath() . '/'));
61
+        $uri = substr($uri, strlen(Environment::getPublicPath().'/'));
62 62
         if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && $uri !== false) {
63
-            $uri = '../' . $uri;
63
+            $uri = '../'.$uri;
64 64
         }
65 65
         return $uri;
66 66
     }
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -20,43 +20,43 @@
 block discarded – undo
20 20
 class AdditionalAssetsViewHelper extends AbstractBackendViewHelper
21 21
 {
22 22
 
23
-    /**
24
-     * Load the assets (JavaScript, CSS) for this Vidi module.
25
-     *
26
-     * @return void
27
-     * @api
28
-     */
29
-    public function render()
30
-    {
31
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
32
-        /** @var ModuleLoader $moduleLoader */
33
-        $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
23
+	/**
24
+	 * Load the assets (JavaScript, CSS) for this Vidi module.
25
+	 *
26
+	 * @return void
27
+	 * @api
28
+	 */
29
+	public function render()
30
+	{
31
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
32
+		/** @var ModuleLoader $moduleLoader */
33
+		$moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
34 34
 
35
-        foreach ($moduleLoader->getAdditionalStyleSheetFiles() as $addCssFile) {
36
-            $fileNameAndPath = $this->resolvePath($addCssFile);
37
-            $pageRenderer->addCssFile($fileNameAndPath);
38
-        }
35
+		foreach ($moduleLoader->getAdditionalStyleSheetFiles() as $addCssFile) {
36
+			$fileNameAndPath = $this->resolvePath($addCssFile);
37
+			$pageRenderer->addCssFile($fileNameAndPath);
38
+		}
39 39
 
40
-        foreach ($moduleLoader->getAdditionalJavaScriptFiles() as $addJsFile) {
41
-            $fileNameAndPath = $this->resolvePath($addJsFile);
42
-            $pageRenderer->addJsFile($fileNameAndPath);
43
-        }
44
-    }
40
+		foreach ($moduleLoader->getAdditionalJavaScriptFiles() as $addJsFile) {
41
+			$fileNameAndPath = $this->resolvePath($addJsFile);
42
+			$pageRenderer->addJsFile($fileNameAndPath);
43
+		}
44
+	}
45 45
 
46
-    /**
47
-     * Resolve a resource path.
48
-     *
49
-     * @param string $uri
50
-     * @return string
51
-     */
52
-    protected function resolvePath($uri)
53
-    {
54
-        $uri = GeneralUtility::getFileAbsFileName($uri);
55
-        $uri = substr($uri, strlen(Environment::getPublicPath() . '/'));
56
-        if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && $uri !== false) {
57
-            $uri = '../' . $uri;
58
-        }
59
-        return $uri;
60
-    }
46
+	/**
47
+	 * Resolve a resource path.
48
+	 *
49
+	 * @param string $uri
50
+	 * @return string
51
+	 */
52
+	protected function resolvePath($uri)
53
+	{
54
+		$uri = GeneralUtility::getFileAbsFileName($uri);
55
+		$uri = substr($uri, strlen(Environment::getPublicPath() . '/'));
56
+		if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && $uri !== false) {
57
+			$uri = '../' . $uri;
58
+		}
59
+		return $uri;
60
+	}
61 61
 
62 62
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Be/RequireJsViewHelper.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,23 +19,23 @@
 block discarded – undo
19 19
 class RequireJsViewHelper extends AbstractBackendViewHelper
20 20
 {
21 21
 
22
-    /**
23
-     * Load RequireJS code.
24
-     *
25
-     * @return void
26
-     */
27
-    public function render()
28
-    {
29
-
30
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
31
-
32
-        $content = $this->renderChildren();
33
-        $pageRenderer->addJsInlineCode('vidi-inline', $content);
34
-
35
-        $publicResourcesPath = PathUtility::getPublicResourceWebPath('EXT:vidi/Resources/Public/');
36
-        $configuration['paths']['Fab/Vidi'] = $publicResourcesPath . 'JavaScript';
37
-        $pageRenderer->addRequireJsConfiguration($configuration);
38
-        $pageRenderer->loadRequireJsModule('Fab/Vidi/Vidi/Main');
39
-    }
22
+	/**
23
+	 * Load RequireJS code.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function render()
28
+	{
29
+
30
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
31
+
32
+		$content = $this->renderChildren();
33
+		$pageRenderer->addJsInlineCode('vidi-inline', $content);
34
+
35
+		$publicResourcesPath = PathUtility::getPublicResourceWebPath('EXT:vidi/Resources/Public/');
36
+		$configuration['paths']['Fab/Vidi'] = $publicResourcesPath . 'JavaScript';
37
+		$pageRenderer->addRequireJsConfiguration($configuration);
38
+		$pageRenderer->loadRequireJsModule('Fab/Vidi/Vidi/Main');
39
+	}
40 40
 
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
         $pageRenderer->addJsInlineCode('vidi-inline', $content);
34 34
 
35 35
         $publicResourcesPath = PathUtility::getPublicResourceWebPath('EXT:vidi/Resources/Public/');
36
-        $configuration['paths']['Fab/Vidi'] = $publicResourcesPath . 'JavaScript';
36
+        $configuration['paths']['Fab/Vidi'] = $publicResourcesPath.'JavaScript';
37 37
         $pageRenderer->addRequireJsConfiguration($configuration);
38 38
         $pageRenderer->loadRequireJsModule('Fab/Vidi/Vidi/Main');
39 39
     }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Result/ToXlsViewHelper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@
 block discarded – undo
103 103
         $response->withHeader('Expires', '0');
104 104
         $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
105 105
         $response->withHeader('Content-Type', 'application/vnd.ms-excel');
106
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
106
+        $response->withHeader('Content-Disposition', 'attachment; filename="'.basename($this->exportFileNameAndPath).'"');
107 107
         $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
108 108
         $response->withHeader('Content-Description', 'File Transfer');
109 109
         $response->withHeader('Content-Transfer-Encoding', 'binary');
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -18,96 +18,96 @@
 block discarded – undo
18 18
 class ToXlsViewHelper extends AbstractToFormatViewHelper
19 19
 {
20 20
 
21
-    /**
22
-     * Render a XLS export request.
23
-     *
24
-     */
25
-    public function render()
26
-    {
27
-
28
-        $objects = $this->templateVariableContainer->get('objects');
29
-
30
-        // Make sure we have something to process...
31
-        if (!empty($objects)) {
32
-
33
-            // Initialization step.
34
-            $this->initializeEnvironment($objects);
35
-            $this->exportFileNameAndPath .= '.xls'; // add extension to the file.
36
-
37
-            // Write the exported data to a CSV file.
38
-            $this->writeXlsFile($objects);
39
-
40
-            // We must generate a zip archive since there are files included.
41
-            if ($this->hasCollectedFiles()) {
42
-
43
-                $this->writeZipFile();
44
-                $this->sendZipHttpHeaders();
45
-
46
-                readfile($this->zipFileNameAndPath);
47
-            } else {
48
-                $this->sendXlsHttpHeaders();
49
-                readfile($this->exportFileNameAndPath);
50
-            }
51
-
52
-            GeneralUtility::rmdir($this->temporaryDirectory, true);
53
-        }
54
-    }
55
-
56
-    /**
57
-     * Write the CSV file to a temporary location.
58
-     *
59
-     * @param array $objects
60
-     * @return void
61
-     */
62
-    protected function writeXlsFile(array $objects)
63
-    {
64
-
65
-        /** @var SpreadSheetService $spreadSheet */
66
-        $spreadSheet = GeneralUtility::makeInstance(SpreadSheetService::class);
67
-
68
-        // Handle object header, get the first object and get the list of fields.
69
-        /** @var Content $object */
70
-        $object = reset($objects);
71
-        $spreadSheet->addRow($object->toFields());
72
-
73
-        $this->checkWhetherObjectMayIncludeFiles($object);
74
-
75
-        foreach ($objects as $object) {
76
-            if ($this->hasFileFields()) {
77
-                $this->collectFiles($object);
78
-            }
79
-
80
-            // Make sure we have a flat array of values for the CSV purpose.
81
-            $flattenValues = [];
82
-            foreach ($object->toValues() as $fieldName => $value) {
83
-                if (is_array($value)) {
84
-                    $flattenValues[$fieldName] = implode(', ', $value);
85
-                } else {
86
-                    $flattenValues[$fieldName] = $value;
87
-                }
88
-            }
89
-
90
-            $spreadSheet->addRow($flattenValues);
91
-        }
92
-
93
-        file_put_contents($this->exportFileNameAndPath, $spreadSheet->toString());
94
-    }
95
-
96
-    /**
97
-     * @return void
98
-     */
99
-    protected function sendXlsHttpHeaders()
100
-    {
101
-        /** @var Response $response */
102
-        $response = $this->templateVariableContainer->get('response');
103
-        $response->withHeader('Pragma', 'public');
104
-        $response->withHeader('Expires', '0');
105
-        $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
106
-        $response->withHeader('Content-Type', 'application/vnd.ms-excel');
107
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
108
-        $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
109
-        $response->withHeader('Content-Description', 'File Transfer');
110
-        $response->withHeader('Content-Transfer-Encoding', 'binary');
111
-    }
21
+	/**
22
+	 * Render a XLS export request.
23
+	 *
24
+	 */
25
+	public function render()
26
+	{
27
+
28
+		$objects = $this->templateVariableContainer->get('objects');
29
+
30
+		// Make sure we have something to process...
31
+		if (!empty($objects)) {
32
+
33
+			// Initialization step.
34
+			$this->initializeEnvironment($objects);
35
+			$this->exportFileNameAndPath .= '.xls'; // add extension to the file.
36
+
37
+			// Write the exported data to a CSV file.
38
+			$this->writeXlsFile($objects);
39
+
40
+			// We must generate a zip archive since there are files included.
41
+			if ($this->hasCollectedFiles()) {
42
+
43
+				$this->writeZipFile();
44
+				$this->sendZipHttpHeaders();
45
+
46
+				readfile($this->zipFileNameAndPath);
47
+			} else {
48
+				$this->sendXlsHttpHeaders();
49
+				readfile($this->exportFileNameAndPath);
50
+			}
51
+
52
+			GeneralUtility::rmdir($this->temporaryDirectory, true);
53
+		}
54
+	}
55
+
56
+	/**
57
+	 * Write the CSV file to a temporary location.
58
+	 *
59
+	 * @param array $objects
60
+	 * @return void
61
+	 */
62
+	protected function writeXlsFile(array $objects)
63
+	{
64
+
65
+		/** @var SpreadSheetService $spreadSheet */
66
+		$spreadSheet = GeneralUtility::makeInstance(SpreadSheetService::class);
67
+
68
+		// Handle object header, get the first object and get the list of fields.
69
+		/** @var Content $object */
70
+		$object = reset($objects);
71
+		$spreadSheet->addRow($object->toFields());
72
+
73
+		$this->checkWhetherObjectMayIncludeFiles($object);
74
+
75
+		foreach ($objects as $object) {
76
+			if ($this->hasFileFields()) {
77
+				$this->collectFiles($object);
78
+			}
79
+
80
+			// Make sure we have a flat array of values for the CSV purpose.
81
+			$flattenValues = [];
82
+			foreach ($object->toValues() as $fieldName => $value) {
83
+				if (is_array($value)) {
84
+					$flattenValues[$fieldName] = implode(', ', $value);
85
+				} else {
86
+					$flattenValues[$fieldName] = $value;
87
+				}
88
+			}
89
+
90
+			$spreadSheet->addRow($flattenValues);
91
+		}
92
+
93
+		file_put_contents($this->exportFileNameAndPath, $spreadSheet->toString());
94
+	}
95
+
96
+	/**
97
+	 * @return void
98
+	 */
99
+	protected function sendXlsHttpHeaders()
100
+	{
101
+		/** @var Response $response */
102
+		$response = $this->templateVariableContainer->get('response');
103
+		$response->withHeader('Pragma', 'public');
104
+		$response->withHeader('Expires', '0');
105
+		$response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
106
+		$response->withHeader('Content-Type', 'application/vnd.ms-excel');
107
+		$response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
108
+		$response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
109
+		$response->withHeader('Content-Description', 'File Transfer');
110
+		$response->withHeader('Content-Transfer-Encoding', 'binary');
111
+	}
112 112
 
113 113
 }
Please login to merge, or discard this patch.