@@ -19,30 +19,30 @@ |
||
19 | 19 | */ |
20 | 20 | class BackViewHelper extends AbstractViewHelper |
21 | 21 | { |
22 | - /** |
|
23 | - * Returns the "back" buttons to be placed in the doc header. |
|
24 | - * |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function render() |
|
28 | - { |
|
29 | - $result = ''; |
|
30 | - if (GeneralUtility::_GET('returnUrl')) { |
|
31 | - $result = sprintf( |
|
32 | - '<a href="%s" class="btn btn-default btn-sm btn-return-top">%s</a>', |
|
33 | - GeneralUtility::_GP('returnUrl'), |
|
34 | - $this->getIconFactory()->getIcon('actions-close', Icon::SIZE_SMALL) |
|
35 | - ); |
|
36 | - } |
|
22 | + /** |
|
23 | + * Returns the "back" buttons to be placed in the doc header. |
|
24 | + * |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function render() |
|
28 | + { |
|
29 | + $result = ''; |
|
30 | + if (GeneralUtility::_GET('returnUrl')) { |
|
31 | + $result = sprintf( |
|
32 | + '<a href="%s" class="btn btn-default btn-sm btn-return-top">%s</a>', |
|
33 | + GeneralUtility::_GP('returnUrl'), |
|
34 | + $this->getIconFactory()->getIcon('actions-close', Icon::SIZE_SMALL) |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | - return $result; |
|
39 | - } |
|
38 | + return $result; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return IconFactory|object |
|
43 | - */ |
|
44 | - protected function getIconFactory() |
|
45 | - { |
|
46 | - return GeneralUtility::makeInstance(IconFactory::class); |
|
47 | - } |
|
41 | + /** |
|
42 | + * @return IconFactory|object |
|
43 | + */ |
|
44 | + protected function getIconFactory() |
|
45 | + { |
|
46 | + return GeneralUtility::makeInstance(IconFactory::class); |
|
47 | + } |
|
48 | 48 | } |
@@ -17,59 +17,59 @@ |
||
17 | 17 | */ |
18 | 18 | class ToolWorkViewHelper extends AbstractViewHelper |
19 | 19 | { |
20 | - /** |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function initializeArguments() |
|
24 | - { |
|
25 | - $this->registerArgument('tool', 'string', '', true); |
|
26 | - $this->registerArgument('label', 'string', '', true); |
|
27 | - $this->registerArgument('arguments', 'array', '', false, []); |
|
28 | - } |
|
20 | + /** |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function initializeArguments() |
|
24 | + { |
|
25 | + $this->registerArgument('tool', 'string', '', true); |
|
26 | + $this->registerArgument('label', 'string', '', true); |
|
27 | + $this->registerArgument('arguments', 'array', '', false, []); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Renders a button for "work" for a Tool. |
|
32 | - * |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function render() |
|
36 | - { |
|
37 | - $tool = $this->arguments['tool']; |
|
38 | - $label = $this->arguments['label']; |
|
39 | - $arguments = $this->arguments['arguments']; |
|
30 | + /** |
|
31 | + * Renders a button for "work" for a Tool. |
|
32 | + * |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function render() |
|
36 | + { |
|
37 | + $tool = $this->arguments['tool']; |
|
38 | + $label = $this->arguments['label']; |
|
39 | + $arguments = $this->arguments['arguments']; |
|
40 | 40 | |
41 | - $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
41 | + $parameterPrefix = $this->getModuleLoader()->getParameterPrefix(); |
|
42 | 42 | |
43 | - // Compute the additional parameters. |
|
44 | - $additionalParameters = array( |
|
45 | - $parameterPrefix => array( |
|
46 | - 'controller' => 'Tool', |
|
47 | - 'action' => 'work', |
|
48 | - 'tool' => $tool, |
|
49 | - ), |
|
50 | - ); |
|
43 | + // Compute the additional parameters. |
|
44 | + $additionalParameters = array( |
|
45 | + $parameterPrefix => array( |
|
46 | + 'controller' => 'Tool', |
|
47 | + 'action' => 'work', |
|
48 | + 'tool' => $tool, |
|
49 | + ), |
|
50 | + ); |
|
51 | 51 | |
52 | - // Add possible additional arguments. |
|
53 | - if (!empty($arguments)) { |
|
54 | - $additionalParameters[$parameterPrefix]['arguments'] = $arguments; |
|
55 | - } |
|
52 | + // Add possible additional arguments. |
|
53 | + if (!empty($arguments)) { |
|
54 | + $additionalParameters[$parameterPrefix]['arguments'] = $arguments; |
|
55 | + } |
|
56 | 56 | |
57 | - $result = sprintf( |
|
58 | - '<a href="%s&returnUrl=%s" class="btn btn-default">%s</a>', |
|
59 | - $this->getModuleLoader()->getModuleUrl($additionalParameters), |
|
60 | - urlencode($GLOBALS['_SERVER']['REQUEST_URI']), |
|
61 | - $label |
|
62 | - ); |
|
63 | - return $result; |
|
64 | - } |
|
57 | + $result = sprintf( |
|
58 | + '<a href="%s&returnUrl=%s" class="btn btn-default">%s</a>', |
|
59 | + $this->getModuleLoader()->getModuleUrl($additionalParameters), |
|
60 | + urlencode($GLOBALS['_SERVER']['REQUEST_URI']), |
|
61 | + $label |
|
62 | + ); |
|
63 | + return $result; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Get the Vidi Module Loader. |
|
68 | - * |
|
69 | - * @return ModuleLoader|object |
|
70 | - */ |
|
71 | - protected function getModuleLoader() |
|
72 | - { |
|
73 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
74 | - } |
|
66 | + /** |
|
67 | + * Get the Vidi Module Loader. |
|
68 | + * |
|
69 | + * @return ModuleLoader|object |
|
70 | + */ |
|
71 | + protected function getModuleLoader() |
|
72 | + { |
|
73 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
74 | + } |
|
75 | 75 | } |
@@ -17,86 +17,86 @@ |
||
17 | 17 | */ |
18 | 18 | class ToCsvViewHelper extends AbstractToFormatViewHelper |
19 | 19 | { |
20 | - /** |
|
21 | - * Render a CSV export request. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function render() |
|
25 | - { |
|
26 | - $objects = $this->templateVariableContainer->get('objects'); |
|
20 | + /** |
|
21 | + * Render a CSV export request. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function render() |
|
25 | + { |
|
26 | + $objects = $this->templateVariableContainer->get('objects'); |
|
27 | 27 | |
28 | - // Make sure we have something to process... |
|
29 | - if (!empty($objects)) { |
|
30 | - // Initialization step. |
|
31 | - $this->initializeEnvironment($objects); |
|
32 | - $this->exportFileNameAndPath .= '.csv'; // add extension to the file. |
|
28 | + // Make sure we have something to process... |
|
29 | + if (!empty($objects)) { |
|
30 | + // Initialization step. |
|
31 | + $this->initializeEnvironment($objects); |
|
32 | + $this->exportFileNameAndPath .= '.csv'; // add extension to the file. |
|
33 | 33 | |
34 | - // Write the exported data to a CSV file. |
|
35 | - $this->writeCsvFile($objects); |
|
34 | + // Write the exported data to a CSV file. |
|
35 | + $this->writeCsvFile($objects); |
|
36 | 36 | |
37 | - // We must generate a zip archive since there are files included. |
|
38 | - if ($this->hasCollectedFiles()) { |
|
39 | - $this->writeZipFile(); |
|
40 | - $this->sendZipHttpHeaders(); |
|
37 | + // We must generate a zip archive since there are files included. |
|
38 | + if ($this->hasCollectedFiles()) { |
|
39 | + $this->writeZipFile(); |
|
40 | + $this->sendZipHttpHeaders(); |
|
41 | 41 | |
42 | - readfile($this->zipFileNameAndPath); |
|
43 | - } else { |
|
44 | - $this->sendCsvHttpHeaders(); |
|
45 | - readfile($this->exportFileNameAndPath); |
|
46 | - } |
|
42 | + readfile($this->zipFileNameAndPath); |
|
43 | + } else { |
|
44 | + $this->sendCsvHttpHeaders(); |
|
45 | + readfile($this->exportFileNameAndPath); |
|
46 | + } |
|
47 | 47 | |
48 | - GeneralUtility::rmdir($this->temporaryDirectory, true); |
|
49 | - } |
|
50 | - } |
|
48 | + GeneralUtility::rmdir($this->temporaryDirectory, true); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Write the CSV file to a temporary location. |
|
54 | - * |
|
55 | - * @param array $objects |
|
56 | - */ |
|
57 | - protected function writeCsvFile(array $objects) |
|
58 | - { |
|
59 | - // Create a file pointer |
|
60 | - $output = fopen($this->exportFileNameAndPath, 'w'); |
|
52 | + /** |
|
53 | + * Write the CSV file to a temporary location. |
|
54 | + * |
|
55 | + * @param array $objects |
|
56 | + */ |
|
57 | + protected function writeCsvFile(array $objects) |
|
58 | + { |
|
59 | + // Create a file pointer |
|
60 | + $output = fopen($this->exportFileNameAndPath, 'w'); |
|
61 | 61 | |
62 | - // Handle CSV header, get the first object and get the list of fields. |
|
63 | - /** @var Content $object */ |
|
64 | - $object = reset($objects); |
|
65 | - fputcsv($output, $object->toFields()); |
|
66 | - $this->checkWhetherObjectMayIncludeFiles($object); |
|
62 | + // Handle CSV header, get the first object and get the list of fields. |
|
63 | + /** @var Content $object */ |
|
64 | + $object = reset($objects); |
|
65 | + fputcsv($output, $object->toFields()); |
|
66 | + $this->checkWhetherObjectMayIncludeFiles($object); |
|
67 | 67 | |
68 | - foreach ($objects as $object) { |
|
69 | - if ($this->hasFileFields()) { |
|
70 | - $this->collectFiles($object); |
|
71 | - } |
|
68 | + foreach ($objects as $object) { |
|
69 | + if ($this->hasFileFields()) { |
|
70 | + $this->collectFiles($object); |
|
71 | + } |
|
72 | 72 | |
73 | - // Make sure we have a flat array of values for the CSV purpose. |
|
74 | - $flattenValues = []; |
|
75 | - foreach ($object->toValues() as $fieldName => $value) { |
|
76 | - if (is_array($value)) { |
|
77 | - $flattenValues[$fieldName] = implode(', ', $value); |
|
78 | - } else { |
|
79 | - $flattenValues[$fieldName] = str_replace("\n", "\r", $value); // for Excel purpose. |
|
80 | - } |
|
81 | - } |
|
73 | + // Make sure we have a flat array of values for the CSV purpose. |
|
74 | + $flattenValues = []; |
|
75 | + foreach ($object->toValues() as $fieldName => $value) { |
|
76 | + if (is_array($value)) { |
|
77 | + $flattenValues[$fieldName] = implode(', ', $value); |
|
78 | + } else { |
|
79 | + $flattenValues[$fieldName] = str_replace("\n", "\r", $value); // for Excel purpose. |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - fputcsv($output, $flattenValues); |
|
84 | - } |
|
83 | + fputcsv($output, $flattenValues); |
|
84 | + } |
|
85 | 85 | |
86 | - // close file handler |
|
87 | - fclose($output); |
|
88 | - } |
|
86 | + // close file handler |
|
87 | + fclose($output); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - protected function sendCsvHttpHeaders() |
|
94 | - { |
|
95 | - /** @var Response $response */ |
|
96 | - $response = $this->templateVariableContainer->get('response'); |
|
97 | - $response->withHeader('Content-Type', 'application/csv'); |
|
98 | - $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"'); |
|
99 | - $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath)); |
|
100 | - $response->withHeader('Content-Description', 'File Transfer'); |
|
101 | - } |
|
90 | + /** |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + protected function sendCsvHttpHeaders() |
|
94 | + { |
|
95 | + /** @var Response $response */ |
|
96 | + $response = $this->templateVariableContainer->get('response'); |
|
97 | + $response->withHeader('Content-Type', 'application/csv'); |
|
98 | + $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"'); |
|
99 | + $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath)); |
|
100 | + $response->withHeader('Content-Description', 'File Transfer'); |
|
101 | + } |
|
102 | 102 | } |
@@ -18,91 +18,91 @@ |
||
18 | 18 | */ |
19 | 19 | class ToXlsViewHelper extends AbstractToFormatViewHelper |
20 | 20 | { |
21 | - /** |
|
22 | - * Render a XLS export request. |
|
23 | - * |
|
24 | - */ |
|
25 | - public function render() |
|
26 | - { |
|
27 | - $objects = $this->templateVariableContainer->get('objects'); |
|
28 | - |
|
29 | - // Make sure we have something to process... |
|
30 | - if (!empty($objects)) { |
|
31 | - // Initialization step. |
|
32 | - $this->initializeEnvironment($objects); |
|
33 | - $this->exportFileNameAndPath .= '.xls'; // add extension to the file. |
|
34 | - |
|
35 | - // Write the exported data to a CSV file. |
|
36 | - $this->writeXlsFile($objects); |
|
37 | - |
|
38 | - // We must generate a zip archive since there are files included. |
|
39 | - if ($this->hasCollectedFiles()) { |
|
40 | - $this->writeZipFile(); |
|
41 | - $this->sendZipHttpHeaders(); |
|
42 | - |
|
43 | - readfile($this->zipFileNameAndPath); |
|
44 | - } else { |
|
45 | - $this->sendXlsHttpHeaders(); |
|
46 | - readfile($this->exportFileNameAndPath); |
|
47 | - } |
|
48 | - |
|
49 | - GeneralUtility::rmdir($this->temporaryDirectory, true); |
|
50 | - } |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Write the CSV file to a temporary location. |
|
55 | - * |
|
56 | - * @param array $objects |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - protected function writeXlsFile(array $objects) |
|
60 | - { |
|
61 | - /** @var SpreadSheetService $spreadSheet */ |
|
62 | - $spreadSheet = GeneralUtility::makeInstance(SpreadSheetService::class); |
|
63 | - |
|
64 | - // Handle object header, get the first object and get the list of fields. |
|
65 | - /** @var Content $object */ |
|
66 | - $object = reset($objects); |
|
67 | - $spreadSheet->addRow($object->toFields()); |
|
68 | - |
|
69 | - $this->checkWhetherObjectMayIncludeFiles($object); |
|
70 | - |
|
71 | - foreach ($objects as $object) { |
|
72 | - if ($this->hasFileFields()) { |
|
73 | - $this->collectFiles($object); |
|
74 | - } |
|
75 | - |
|
76 | - // Make sure we have a flat array of values for the CSV purpose. |
|
77 | - $flattenValues = []; |
|
78 | - foreach ($object->toValues() as $fieldName => $value) { |
|
79 | - if (is_array($value)) { |
|
80 | - $flattenValues[$fieldName] = implode(', ', $value); |
|
81 | - } else { |
|
82 | - $flattenValues[$fieldName] = $value; |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - $spreadSheet->addRow($flattenValues); |
|
87 | - } |
|
88 | - |
|
89 | - file_put_contents($this->exportFileNameAndPath, $spreadSheet->toString()); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return void |
|
94 | - */ |
|
95 | - protected function sendXlsHttpHeaders() |
|
96 | - { |
|
97 | - /** @var Response $response */ |
|
98 | - $response = $this->templateVariableContainer->get('response'); |
|
99 | - $response->withHeader('Pragma', 'public'); |
|
100 | - $response->withHeader('Expires', '0'); |
|
101 | - $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); |
|
102 | - $response->withHeader('Content-Type', 'application/vnd.ms-excel'); |
|
103 | - $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"'); |
|
104 | - $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath)); |
|
105 | - $response->withHeader('Content-Description', 'File Transfer'); |
|
106 | - $response->withHeader('Content-Transfer-Encoding', 'binary'); |
|
107 | - } |
|
21 | + /** |
|
22 | + * Render a XLS export request. |
|
23 | + * |
|
24 | + */ |
|
25 | + public function render() |
|
26 | + { |
|
27 | + $objects = $this->templateVariableContainer->get('objects'); |
|
28 | + |
|
29 | + // Make sure we have something to process... |
|
30 | + if (!empty($objects)) { |
|
31 | + // Initialization step. |
|
32 | + $this->initializeEnvironment($objects); |
|
33 | + $this->exportFileNameAndPath .= '.xls'; // add extension to the file. |
|
34 | + |
|
35 | + // Write the exported data to a CSV file. |
|
36 | + $this->writeXlsFile($objects); |
|
37 | + |
|
38 | + // We must generate a zip archive since there are files included. |
|
39 | + if ($this->hasCollectedFiles()) { |
|
40 | + $this->writeZipFile(); |
|
41 | + $this->sendZipHttpHeaders(); |
|
42 | + |
|
43 | + readfile($this->zipFileNameAndPath); |
|
44 | + } else { |
|
45 | + $this->sendXlsHttpHeaders(); |
|
46 | + readfile($this->exportFileNameAndPath); |
|
47 | + } |
|
48 | + |
|
49 | + GeneralUtility::rmdir($this->temporaryDirectory, true); |
|
50 | + } |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Write the CSV file to a temporary location. |
|
55 | + * |
|
56 | + * @param array $objects |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + protected function writeXlsFile(array $objects) |
|
60 | + { |
|
61 | + /** @var SpreadSheetService $spreadSheet */ |
|
62 | + $spreadSheet = GeneralUtility::makeInstance(SpreadSheetService::class); |
|
63 | + |
|
64 | + // Handle object header, get the first object and get the list of fields. |
|
65 | + /** @var Content $object */ |
|
66 | + $object = reset($objects); |
|
67 | + $spreadSheet->addRow($object->toFields()); |
|
68 | + |
|
69 | + $this->checkWhetherObjectMayIncludeFiles($object); |
|
70 | + |
|
71 | + foreach ($objects as $object) { |
|
72 | + if ($this->hasFileFields()) { |
|
73 | + $this->collectFiles($object); |
|
74 | + } |
|
75 | + |
|
76 | + // Make sure we have a flat array of values for the CSV purpose. |
|
77 | + $flattenValues = []; |
|
78 | + foreach ($object->toValues() as $fieldName => $value) { |
|
79 | + if (is_array($value)) { |
|
80 | + $flattenValues[$fieldName] = implode(', ', $value); |
|
81 | + } else { |
|
82 | + $flattenValues[$fieldName] = $value; |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + $spreadSheet->addRow($flattenValues); |
|
87 | + } |
|
88 | + |
|
89 | + file_put_contents($this->exportFileNameAndPath, $spreadSheet->toString()); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return void |
|
94 | + */ |
|
95 | + protected function sendXlsHttpHeaders() |
|
96 | + { |
|
97 | + /** @var Response $response */ |
|
98 | + $response = $this->templateVariableContainer->get('response'); |
|
99 | + $response->withHeader('Pragma', 'public'); |
|
100 | + $response->withHeader('Expires', '0'); |
|
101 | + $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); |
|
102 | + $response->withHeader('Content-Type', 'application/vnd.ms-excel'); |
|
103 | + $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"'); |
|
104 | + $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath)); |
|
105 | + $response->withHeader('Content-Description', 'File Transfer'); |
|
106 | + $response->withHeader('Content-Transfer-Encoding', 'binary'); |
|
107 | + } |
|
108 | 108 | } |
@@ -24,154 +24,154 @@ |
||
24 | 24 | */ |
25 | 25 | abstract class AbstractToFormatViewHelper extends AbstractViewHelper |
26 | 26 | { |
27 | - /** |
|
28 | - * Store fields of type "file". |
|
29 | - * |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $fileTypeProperties = []; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var File[] |
|
36 | - */ |
|
37 | - protected $collectedFiles = []; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - protected $exportFileNameAndPath; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $zipFileNameAndPath; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $temporaryDirectory; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Write the zip file to a temporary location. |
|
57 | - * |
|
58 | - * @return void |
|
59 | - * @throws \RuntimeException |
|
60 | - */ |
|
61 | - protected function writeZipFile() |
|
62 | - { |
|
63 | - $zip = new \ZipArchive(); |
|
64 | - $zip->open($this->zipFileNameAndPath, \ZipArchive::CREATE); |
|
65 | - |
|
66 | - // Add the CSV content into the zipball. |
|
67 | - $zip->addFile($this->exportFileNameAndPath, basename($this->exportFileNameAndPath)); |
|
68 | - |
|
69 | - // Add the files into the zipball. |
|
70 | - foreach ($this->collectedFiles as $file) { |
|
71 | - $zip->addFile($file->getForLocalProcessing(false), $file->getIdentifier()); |
|
72 | - } |
|
73 | - |
|
74 | - $zip->close(); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Initialize some properties |
|
79 | - * |
|
80 | - * @param array $objects |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - protected function initializeEnvironment(array $objects) |
|
84 | - { |
|
85 | - /** @var Content $object */ |
|
86 | - $object = reset($objects); |
|
87 | - |
|
88 | - $this->temporaryDirectory = Environment::getPublicPath() . '/typo3temp/' . uniqid() . '/'; |
|
89 | - GeneralUtility::mkdir($this->temporaryDirectory); |
|
90 | - |
|
91 | - // Compute file name and path variable |
|
92 | - $this->exportFileNameAndPath = $this->temporaryDirectory . $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']); |
|
93 | - |
|
94 | - // Compute file name and path variable for zip |
|
95 | - $zipFileName = $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']) . '.zip'; |
|
96 | - $this->zipFileNameAndPath = $this->temporaryDirectory . $zipFileName; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Fetch the files given an object. |
|
101 | - * |
|
102 | - * @param Content $object |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - protected function collectFiles(Content $object) |
|
106 | - { |
|
107 | - foreach ($this->fileTypeProperties as $property) { |
|
108 | - $files = FileReferenceService::getInstance()->findReferencedBy($property, $object); |
|
109 | - foreach ($files as $file) { |
|
110 | - $this->collectedFiles[$file->getUid()] = $file; |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Tells whether the object has fields containing files. |
|
117 | - * |
|
118 | - * @return boolean |
|
119 | - */ |
|
120 | - protected function hasCollectedFiles() |
|
121 | - { |
|
122 | - return !empty($this->collectedFiles); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Tells whether the object has fields containing files. |
|
127 | - * |
|
128 | - * @return boolean |
|
129 | - */ |
|
130 | - protected function hasFileFields() |
|
131 | - { |
|
132 | - return !empty($this->fileTypeProperties); |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Check whether the given object is meant to include files in some fields. |
|
137 | - * |
|
138 | - * @param Content $object |
|
139 | - */ |
|
140 | - protected function checkWhetherObjectMayIncludeFiles(Content $object) |
|
141 | - { |
|
142 | - if (Tca::grid($object->getDataType())->areFilesIncludedInExport()) { |
|
143 | - foreach ($object->toFields() as $fieldName) { |
|
144 | - $fieldType = Tca::table($object->getDataType())->field($fieldName)->getType(); |
|
145 | - |
|
146 | - if ($fieldType === FieldType::FILE) { |
|
147 | - $this->fileTypeProperties[] = GeneralUtility::camelCaseToLowerCaseUnderscored($fieldName); |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @return void |
|
155 | - */ |
|
156 | - protected function sendZipHttpHeaders() |
|
157 | - { |
|
158 | - /** @var Response $response */ |
|
159 | - $response = $this->templateVariableContainer->get('response'); |
|
160 | - $response->withHeader('Pragma', 'public'); |
|
161 | - $response->withHeader('Expires', '0'); |
|
162 | - $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); |
|
163 | - $response->withHeader('Content-Type', 'application/zip'); |
|
164 | - $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->zipFileNameAndPath) . '"'); |
|
165 | - $response->withHeader('Content-Length', filesize($this->zipFileNameAndPath)); |
|
166 | - $response->withHeader('Content-Description', 'File Transfer'); |
|
167 | - $response->withHeader('Content-Transfer-Encoding', 'binary'); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * @return Rows|object |
|
172 | - */ |
|
173 | - protected function getRowsView() |
|
174 | - { |
|
175 | - return GeneralUtility::makeInstance(Rows::class); |
|
176 | - } |
|
27 | + /** |
|
28 | + * Store fields of type "file". |
|
29 | + * |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $fileTypeProperties = []; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var File[] |
|
36 | + */ |
|
37 | + protected $collectedFiles = []; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + protected $exportFileNameAndPath; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $zipFileNameAndPath; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $temporaryDirectory; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Write the zip file to a temporary location. |
|
57 | + * |
|
58 | + * @return void |
|
59 | + * @throws \RuntimeException |
|
60 | + */ |
|
61 | + protected function writeZipFile() |
|
62 | + { |
|
63 | + $zip = new \ZipArchive(); |
|
64 | + $zip->open($this->zipFileNameAndPath, \ZipArchive::CREATE); |
|
65 | + |
|
66 | + // Add the CSV content into the zipball. |
|
67 | + $zip->addFile($this->exportFileNameAndPath, basename($this->exportFileNameAndPath)); |
|
68 | + |
|
69 | + // Add the files into the zipball. |
|
70 | + foreach ($this->collectedFiles as $file) { |
|
71 | + $zip->addFile($file->getForLocalProcessing(false), $file->getIdentifier()); |
|
72 | + } |
|
73 | + |
|
74 | + $zip->close(); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Initialize some properties |
|
79 | + * |
|
80 | + * @param array $objects |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + protected function initializeEnvironment(array $objects) |
|
84 | + { |
|
85 | + /** @var Content $object */ |
|
86 | + $object = reset($objects); |
|
87 | + |
|
88 | + $this->temporaryDirectory = Environment::getPublicPath() . '/typo3temp/' . uniqid() . '/'; |
|
89 | + GeneralUtility::mkdir($this->temporaryDirectory); |
|
90 | + |
|
91 | + // Compute file name and path variable |
|
92 | + $this->exportFileNameAndPath = $this->temporaryDirectory . $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']); |
|
93 | + |
|
94 | + // Compute file name and path variable for zip |
|
95 | + $zipFileName = $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']) . '.zip'; |
|
96 | + $this->zipFileNameAndPath = $this->temporaryDirectory . $zipFileName; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Fetch the files given an object. |
|
101 | + * |
|
102 | + * @param Content $object |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + protected function collectFiles(Content $object) |
|
106 | + { |
|
107 | + foreach ($this->fileTypeProperties as $property) { |
|
108 | + $files = FileReferenceService::getInstance()->findReferencedBy($property, $object); |
|
109 | + foreach ($files as $file) { |
|
110 | + $this->collectedFiles[$file->getUid()] = $file; |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Tells whether the object has fields containing files. |
|
117 | + * |
|
118 | + * @return boolean |
|
119 | + */ |
|
120 | + protected function hasCollectedFiles() |
|
121 | + { |
|
122 | + return !empty($this->collectedFiles); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Tells whether the object has fields containing files. |
|
127 | + * |
|
128 | + * @return boolean |
|
129 | + */ |
|
130 | + protected function hasFileFields() |
|
131 | + { |
|
132 | + return !empty($this->fileTypeProperties); |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Check whether the given object is meant to include files in some fields. |
|
137 | + * |
|
138 | + * @param Content $object |
|
139 | + */ |
|
140 | + protected function checkWhetherObjectMayIncludeFiles(Content $object) |
|
141 | + { |
|
142 | + if (Tca::grid($object->getDataType())->areFilesIncludedInExport()) { |
|
143 | + foreach ($object->toFields() as $fieldName) { |
|
144 | + $fieldType = Tca::table($object->getDataType())->field($fieldName)->getType(); |
|
145 | + |
|
146 | + if ($fieldType === FieldType::FILE) { |
|
147 | + $this->fileTypeProperties[] = GeneralUtility::camelCaseToLowerCaseUnderscored($fieldName); |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @return void |
|
155 | + */ |
|
156 | + protected function sendZipHttpHeaders() |
|
157 | + { |
|
158 | + /** @var Response $response */ |
|
159 | + $response = $this->templateVariableContainer->get('response'); |
|
160 | + $response->withHeader('Pragma', 'public'); |
|
161 | + $response->withHeader('Expires', '0'); |
|
162 | + $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); |
|
163 | + $response->withHeader('Content-Type', 'application/zip'); |
|
164 | + $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->zipFileNameAndPath) . '"'); |
|
165 | + $response->withHeader('Content-Length', filesize($this->zipFileNameAndPath)); |
|
166 | + $response->withHeader('Content-Description', 'File Transfer'); |
|
167 | + $response->withHeader('Content-Transfer-Encoding', 'binary'); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * @return Rows|object |
|
172 | + */ |
|
173 | + protected function getRowsView() |
|
174 | + { |
|
175 | + return GeneralUtility::makeInstance(Rows::class); |
|
176 | + } |
|
177 | 177 | } |
@@ -18,54 +18,54 @@ |
||
18 | 18 | */ |
19 | 19 | class ToJsonViewHelper extends AbstractViewHelper |
20 | 20 | { |
21 | - /** |
|
22 | - * Render a Json response |
|
23 | - * |
|
24 | - */ |
|
25 | - public function render() |
|
26 | - { |
|
27 | - $objects = $this->templateVariableContainer->get('objects'); |
|
28 | - $columns = $this->templateVariableContainer->get('columns'); |
|
29 | - $output = array( |
|
30 | - 'sEcho' => $this->getNextTransactionId(), |
|
31 | - 'iTotalRecords' => $this->templateVariableContainer->get('numberOfObjects'), |
|
32 | - 'iTotalDisplayRecords' => $this->templateVariableContainer->get('numberOfObjects'), |
|
33 | - 'iNumberOfRecords' => count($objects), |
|
34 | - 'aaData' => $this->getRowsView()->render($objects, $columns), |
|
35 | - ); |
|
21 | + /** |
|
22 | + * Render a Json response |
|
23 | + * |
|
24 | + */ |
|
25 | + public function render() |
|
26 | + { |
|
27 | + $objects = $this->templateVariableContainer->get('objects'); |
|
28 | + $columns = $this->templateVariableContainer->get('columns'); |
|
29 | + $output = array( |
|
30 | + 'sEcho' => $this->getNextTransactionId(), |
|
31 | + 'iTotalRecords' => $this->templateVariableContainer->get('numberOfObjects'), |
|
32 | + 'iTotalDisplayRecords' => $this->templateVariableContainer->get('numberOfObjects'), |
|
33 | + 'iNumberOfRecords' => count($objects), |
|
34 | + 'aaData' => $this->getRowsView()->render($objects, $columns), |
|
35 | + ); |
|
36 | 36 | |
37 | - $this->setHttpHeaders(); |
|
38 | - print json_encode($output); |
|
39 | - } |
|
37 | + $this->setHttpHeaders(); |
|
38 | + print json_encode($output); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return int |
|
43 | - */ |
|
44 | - protected function getNextTransactionId() |
|
45 | - { |
|
46 | - $transaction = 0; |
|
47 | - if (GeneralUtility::_GET('sEcho')) { |
|
48 | - $transaction = (int)GeneralUtility::_GET('sEcho') + 1; |
|
49 | - } |
|
50 | - return $transaction; |
|
51 | - } |
|
41 | + /** |
|
42 | + * @return int |
|
43 | + */ |
|
44 | + protected function getNextTransactionId() |
|
45 | + { |
|
46 | + $transaction = 0; |
|
47 | + if (GeneralUtility::_GET('sEcho')) { |
|
48 | + $transaction = (int)GeneralUtility::_GET('sEcho') + 1; |
|
49 | + } |
|
50 | + return $transaction; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return void |
|
55 | - * @throws \InvalidArgumentException |
|
56 | - */ |
|
57 | - protected function setHttpHeaders() |
|
58 | - { |
|
59 | - /** @var Response $response */ |
|
60 | - $response = $this->templateVariableContainer->get('response'); |
|
61 | - $response->withHeader('Content-Type', 'application/json'); |
|
62 | - } |
|
53 | + /** |
|
54 | + * @return void |
|
55 | + * @throws \InvalidArgumentException |
|
56 | + */ |
|
57 | + protected function setHttpHeaders() |
|
58 | + { |
|
59 | + /** @var Response $response */ |
|
60 | + $response = $this->templateVariableContainer->get('response'); |
|
61 | + $response->withHeader('Content-Type', 'application/json'); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return Rows|object |
|
66 | - */ |
|
67 | - protected function getRowsView() |
|
68 | - { |
|
69 | - return GeneralUtility::makeInstance(Rows::class); |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return Rows|object |
|
66 | + */ |
|
67 | + protected function getRowsView() |
|
68 | + { |
|
69 | + return GeneralUtility::makeInstance(Rows::class); |
|
70 | + } |
|
71 | 71 | } |
@@ -17,109 +17,109 @@ |
||
17 | 17 | */ |
18 | 18 | class ToXmlViewHelper extends AbstractToFormatViewHelper |
19 | 19 | { |
20 | - /** |
|
21 | - * Render an XML export. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function render() |
|
25 | - { |
|
26 | - $objects = $this->templateVariableContainer->get('objects'); |
|
20 | + /** |
|
21 | + * Render an XML export. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function render() |
|
25 | + { |
|
26 | + $objects = $this->templateVariableContainer->get('objects'); |
|
27 | 27 | |
28 | - // Make sure we have something to process... |
|
29 | - if (!empty($objects)) { |
|
30 | - // Initialization step. |
|
31 | - $this->initializeEnvironment($objects); |
|
32 | - $this->exportFileNameAndPath .= '.xml'; // add extension to the file. |
|
28 | + // Make sure we have something to process... |
|
29 | + if (!empty($objects)) { |
|
30 | + // Initialization step. |
|
31 | + $this->initializeEnvironment($objects); |
|
32 | + $this->exportFileNameAndPath .= '.xml'; // add extension to the file. |
|
33 | 33 | |
34 | - // Write the exported data to a XML file. |
|
35 | - $this->writeXmlFile($objects); |
|
34 | + // Write the exported data to a XML file. |
|
35 | + $this->writeXmlFile($objects); |
|
36 | 36 | |
37 | - // We must generate a zip archive since there are files included. |
|
38 | - if ($this->hasCollectedFiles()) { |
|
39 | - $this->writeZipFile(); |
|
40 | - $this->sendZipHttpHeaders(); |
|
37 | + // We must generate a zip archive since there are files included. |
|
38 | + if ($this->hasCollectedFiles()) { |
|
39 | + $this->writeZipFile(); |
|
40 | + $this->sendZipHttpHeaders(); |
|
41 | 41 | |
42 | - readfile($this->zipFileNameAndPath); |
|
43 | - } else { |
|
44 | - $this->sendXmlHttpHeaders(); |
|
45 | - readfile($this->exportFileNameAndPath); |
|
46 | - } |
|
42 | + readfile($this->zipFileNameAndPath); |
|
43 | + } else { |
|
44 | + $this->sendXmlHttpHeaders(); |
|
45 | + readfile($this->exportFileNameAndPath); |
|
46 | + } |
|
47 | 47 | |
48 | - GeneralUtility::rmdir($this->temporaryDirectory, true); |
|
49 | - } |
|
50 | - } |
|
48 | + GeneralUtility::rmdir($this->temporaryDirectory, true); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Write the XML file to a temporary location. |
|
54 | - * |
|
55 | - * @param array $objects |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - protected function writeXmlFile(array $objects) |
|
59 | - { |
|
60 | - // Get first object of $objects to check whether it contains possible files to include. |
|
61 | - /** @var Content $object */ |
|
62 | - $object = reset($objects); |
|
63 | - $this->checkWhetherObjectMayIncludeFiles($object); |
|
52 | + /** |
|
53 | + * Write the XML file to a temporary location. |
|
54 | + * |
|
55 | + * @param array $objects |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + protected function writeXmlFile(array $objects) |
|
59 | + { |
|
60 | + // Get first object of $objects to check whether it contains possible files to include. |
|
61 | + /** @var Content $object */ |
|
62 | + $object = reset($objects); |
|
63 | + $this->checkWhetherObjectMayIncludeFiles($object); |
|
64 | 64 | |
65 | - $items = []; |
|
66 | - foreach ($objects as $object) { |
|
67 | - if ($this->hasFileFields()) { |
|
68 | - $this->collectFiles($object); |
|
69 | - } |
|
70 | - $items[] = $object->toValues(); |
|
71 | - } |
|
65 | + $items = []; |
|
66 | + foreach ($objects as $object) { |
|
67 | + if ($this->hasFileFields()) { |
|
68 | + $this->collectFiles($object); |
|
69 | + } |
|
70 | + $items[] = $object->toValues(); |
|
71 | + } |
|
72 | 72 | |
73 | - $xml = new \SimpleXMLElement('<items/>'); |
|
74 | - $xml = $this->arrayToXml($items, $xml); |
|
75 | - file_put_contents($this->exportFileNameAndPath, $this->formatXml($xml->asXML())); |
|
76 | - } |
|
73 | + $xml = new \SimpleXMLElement('<items/>'); |
|
74 | + $xml = $this->arrayToXml($items, $xml); |
|
75 | + file_put_contents($this->exportFileNameAndPath, $this->formatXml($xml->asXML())); |
|
76 | + } |
|
77 | 77 | |
78 | - /* |
|
78 | + /* |
|
79 | 79 | * Convert an array to xml |
80 | 80 | * |
81 | 81 | * @return \SimpleXMLElement |
82 | 82 | */ |
83 | - protected function arrayToXml($array, \SimpleXMLElement $xml) |
|
84 | - { |
|
85 | - foreach ($array as $key => $value) { |
|
86 | - if (is_array($value)) { |
|
87 | - $key = is_numeric($key) ? 'item' : $key; |
|
88 | - $subNode = $xml->addChild($key); |
|
89 | - $this->arrayToXml($value, $subNode); |
|
90 | - } else { |
|
91 | - $key = is_numeric($key) ? 'item' : $key; |
|
92 | - $xml->addChild($key, "$value"); |
|
93 | - } |
|
94 | - } |
|
95 | - return $xml; |
|
96 | - } |
|
83 | + protected function arrayToXml($array, \SimpleXMLElement $xml) |
|
84 | + { |
|
85 | + foreach ($array as $key => $value) { |
|
86 | + if (is_array($value)) { |
|
87 | + $key = is_numeric($key) ? 'item' : $key; |
|
88 | + $subNode = $xml->addChild($key); |
|
89 | + $this->arrayToXml($value, $subNode); |
|
90 | + } else { |
|
91 | + $key = is_numeric($key) ? 'item' : $key; |
|
92 | + $xml->addChild($key, "$value"); |
|
93 | + } |
|
94 | + } |
|
95 | + return $xml; |
|
96 | + } |
|
97 | 97 | |
98 | - /* |
|
98 | + /* |
|
99 | 99 | * Format the XML so that is looks human friendly. |
100 | 100 | * |
101 | 101 | * @param string $xml |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - protected function formatXml($xml) |
|
105 | - { |
|
106 | - $dom = new \DOMDocument("1.0"); |
|
107 | - $dom->preserveWhiteSpace = false; |
|
108 | - $dom->formatOutput = true; |
|
109 | - $dom->loadXML($xml); |
|
110 | - return $dom->saveXML(); |
|
111 | - } |
|
104 | + protected function formatXml($xml) |
|
105 | + { |
|
106 | + $dom = new \DOMDocument("1.0"); |
|
107 | + $dom->preserveWhiteSpace = false; |
|
108 | + $dom->formatOutput = true; |
|
109 | + $dom->loadXML($xml); |
|
110 | + return $dom->saveXML(); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * @return void |
|
115 | - */ |
|
116 | - protected function sendXmlHttpHeaders() |
|
117 | - { |
|
118 | - /** @var Response $response */ |
|
119 | - $response = $this->templateVariableContainer->get('response'); |
|
120 | - $response->withHeader('Content-Type', 'application/xml'); |
|
121 | - $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"'); |
|
122 | - $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath)); |
|
123 | - $response->withHeader('Content-Description', 'File Transfer'); |
|
124 | - } |
|
113 | + /** |
|
114 | + * @return void |
|
115 | + */ |
|
116 | + protected function sendXmlHttpHeaders() |
|
117 | + { |
|
118 | + /** @var Response $response */ |
|
119 | + $response = $this->templateVariableContainer->get('response'); |
|
120 | + $response->withHeader('Content-Type', 'application/xml'); |
|
121 | + $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"'); |
|
122 | + $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath)); |
|
123 | + $response->withHeader('Content-Description', 'File Transfer'); |
|
124 | + } |
|
125 | 125 | } |
@@ -20,83 +20,83 @@ |
||
20 | 20 | */ |
21 | 21 | class UserPreferencesViewHelper extends AbstractViewHelper |
22 | 22 | { |
23 | - /** |
|
24 | - * @var AbstractFrontend |
|
25 | - */ |
|
26 | - protected $cacheInstance; |
|
23 | + /** |
|
24 | + * @var AbstractFrontend |
|
25 | + */ |
|
26 | + protected $cacheInstance; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function initializeArguments() |
|
32 | - { |
|
33 | - $this->registerArgument('key', 'string', '', true); |
|
34 | - } |
|
28 | + /** |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function initializeArguments() |
|
32 | + { |
|
33 | + $this->registerArgument('key', 'string', '', true); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Interface with the BE user data. |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function render() |
|
42 | - { |
|
43 | - $this->initializeCache(); |
|
44 | - $key = $this->getModuleLoader()->getDataType() . '_' . $this->getBackendUserIdentifier() . '_' . $this->arguments['key']; |
|
36 | + /** |
|
37 | + * Interface with the BE user data. |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function render() |
|
42 | + { |
|
43 | + $this->initializeCache(); |
|
44 | + $key = $this->getModuleLoader()->getDataType() . '_' . $this->getBackendUserIdentifier() . '_' . $this->arguments['key']; |
|
45 | 45 | |
46 | - $value = $this->cacheInstance->get($key); |
|
47 | - if ($value) { |
|
48 | - $value = addslashes($value); |
|
49 | - } else { |
|
50 | - $value = ''; |
|
51 | - } |
|
52 | - return $value; |
|
53 | - } |
|
46 | + $value = $this->cacheInstance->get($key); |
|
47 | + if ($value) { |
|
48 | + $value = addslashes($value); |
|
49 | + } else { |
|
50 | + $value = ''; |
|
51 | + } |
|
52 | + return $value; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return int |
|
57 | - */ |
|
58 | - protected function getBackendUserIdentifier() |
|
59 | - { |
|
60 | - return $this->getBackendUser()->user['uid']; |
|
61 | - } |
|
55 | + /** |
|
56 | + * @return int |
|
57 | + */ |
|
58 | + protected function getBackendUserIdentifier() |
|
59 | + { |
|
60 | + return $this->getBackendUser()->user['uid']; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Returns an instance of the current Backend User. |
|
65 | - * |
|
66 | - * @return BackendUserAuthentication |
|
67 | - */ |
|
68 | - protected function getBackendUser() |
|
69 | - { |
|
70 | - return $GLOBALS['BE_USER']; |
|
71 | - } |
|
63 | + /** |
|
64 | + * Returns an instance of the current Backend User. |
|
65 | + * |
|
66 | + * @return BackendUserAuthentication |
|
67 | + */ |
|
68 | + protected function getBackendUser() |
|
69 | + { |
|
70 | + return $GLOBALS['BE_USER']; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Get the Vidi Module Loader. |
|
75 | - * |
|
76 | - * @return ModuleLoader|object |
|
77 | - */ |
|
78 | - protected function getModuleLoader() |
|
79 | - { |
|
80 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
81 | - } |
|
73 | + /** |
|
74 | + * Get the Vidi Module Loader. |
|
75 | + * |
|
76 | + * @return ModuleLoader|object |
|
77 | + */ |
|
78 | + protected function getModuleLoader() |
|
79 | + { |
|
80 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Initialize cache instance to be ready to use |
|
85 | - * |
|
86 | - * @return void |
|
87 | - */ |
|
88 | - protected function initializeCache() |
|
89 | - { |
|
90 | - $this->cacheInstance = $this->getCacheManager()->getCache('vidi'); |
|
91 | - } |
|
83 | + /** |
|
84 | + * Initialize cache instance to be ready to use |
|
85 | + * |
|
86 | + * @return void |
|
87 | + */ |
|
88 | + protected function initializeCache() |
|
89 | + { |
|
90 | + $this->cacheInstance = $this->getCacheManager()->getCache('vidi'); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Return the Cache Manager |
|
95 | - * |
|
96 | - * @return CacheManager|object |
|
97 | - */ |
|
98 | - protected function getCacheManager() |
|
99 | - { |
|
100 | - return GeneralUtility::makeInstance(CacheManager::class); |
|
101 | - } |
|
93 | + /** |
|
94 | + * Return the Cache Manager |
|
95 | + * |
|
96 | + * @return CacheManager|object |
|
97 | + */ |
|
98 | + protected function getCacheManager() |
|
99 | + { |
|
100 | + return GeneralUtility::makeInstance(CacheManager::class); |
|
101 | + } |
|
102 | 102 | } |
@@ -18,29 +18,29 @@ |
||
18 | 18 | */ |
19 | 19 | class PreferencesViewHelper extends AbstractViewHelper |
20 | 20 | { |
21 | - /** |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function initializeArguments() |
|
25 | - { |
|
26 | - $this->registerArgument('key', 'string', '', true); |
|
27 | - } |
|
21 | + /** |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function initializeArguments() |
|
25 | + { |
|
26 | + $this->registerArgument('key', 'string', '', true); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Returns Grid preferences for the given key. |
|
31 | - * |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function render() |
|
35 | - { |
|
36 | - return $this->getModulePreferences()->get($this->arguments['key']); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Returns Grid preferences for the given key. |
|
31 | + * |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function render() |
|
35 | + { |
|
36 | + return $this->getModulePreferences()->get($this->arguments['key']); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return ModulePreferences|object |
|
41 | - */ |
|
42 | - protected function getModulePreferences() |
|
43 | - { |
|
44 | - return GeneralUtility::makeInstance(ModulePreferences::class); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @return ModulePreferences|object |
|
41 | + */ |
|
42 | + protected function getModulePreferences() |
|
43 | + { |
|
44 | + return GeneralUtility::makeInstance(ModulePreferences::class); |
|
45 | + } |
|
46 | 46 | } |