@@ -44,7 +44,7 @@ |
||
| 44 | 44 | { |
| 45 | 45 | $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ModulePreferences/Launcher.html'; |
| 46 | 46 | $view = $this->initializeStandaloneView($templateNameAndPath); |
| 47 | - $view->assign('sitePath', Environment::getPublicPath() . '/'); |
|
| 47 | + $view->assign('sitePath', Environment::getPublicPath().'/'); |
|
| 48 | 48 | return $view->render(); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -22,121 +22,121 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class ModulePreferencesTool extends AbstractTool |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Display the title of the tool on the welcome screen. |
|
| 27 | - * |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - public function getTitle() |
|
| 31 | - { |
|
| 32 | - return LocalizationUtility::translate( |
|
| 33 | - 'module_preferences_for', |
|
| 34 | - 'vidi', |
|
| 35 | - array(Tca::table($this->getModuleLoader()->getDataType())->getTitle()) |
|
| 36 | - ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Display the description of the tool in the welcome screen. |
|
| 41 | - * |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function getDescription() |
|
| 45 | - { |
|
| 46 | - $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ModulePreferences/Launcher.html'; |
|
| 47 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 48 | - $view->assign('sitePath', Environment::getPublicPath() . '/'); |
|
| 49 | - return $view->render(); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Do the job! |
|
| 54 | - * |
|
| 55 | - * @param array $arguments |
|
| 56 | - * @return string |
|
| 57 | - */ |
|
| 58 | - public function work(array $arguments = array()) |
|
| 59 | - { |
|
| 60 | - if (isset($arguments['save'])) { |
|
| 61 | - // Revert visible <-> excluded |
|
| 62 | - $excludedFields = array_diff( |
|
| 63 | - Tca::grid()->getAllFieldNames(), |
|
| 64 | - $arguments['excluded_fields'], |
|
| 65 | - $this->getExcludedFieldsFromTca() |
|
| 66 | - ); |
|
| 67 | - $arguments['excluded_fields'] = $excludedFields; |
|
| 68 | - $this->getModulePreferences()->save($arguments); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ModulePreferences/WorkResult.html'; |
|
| 72 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 73 | - |
|
| 74 | - $view->assign('title', Tca::table($this->getModuleLoader()->getDataType())->getTitle()); |
|
| 75 | - |
|
| 76 | - // Fetch the menu of visible items. |
|
| 77 | - $menuVisibleItems = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS); |
|
| 78 | - $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS, $menuVisibleItems); |
|
| 79 | - |
|
| 80 | - // Fetch the default number of menu visible items. |
|
| 81 | - $menuDefaultVisible = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT); |
|
| 82 | - $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT, $menuDefaultVisible); |
|
| 83 | - |
|
| 84 | - // Get the visible columns |
|
| 85 | - $view->assign('columns', Tca::grid()->getAllFieldNames()); |
|
| 86 | - |
|
| 87 | - return $view->render(); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @return array |
|
| 92 | - */ |
|
| 93 | - protected function getExcludedFieldsFromTca() |
|
| 94 | - { |
|
| 95 | - $tca = Tca::grid()->getTca(); |
|
| 96 | - $excludedFields = []; |
|
| 97 | - if (!empty($tca['excluded_fields'])) { |
|
| 98 | - $excludedFields = GeneralUtility::trimExplode(',', $tca['excluded_fields'], true); |
|
| 99 | - } elseif (!empty($tca['export']['excluded_fields'])) { // only for export for legacy reason. |
|
| 100 | - $excludedFields = GeneralUtility::trimExplode(',', $tca['export']['excluded_fields'], true); |
|
| 101 | - } |
|
| 102 | - return $excludedFields; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Tell whether the tools should be displayed according to the context. |
|
| 107 | - * |
|
| 108 | - * @return bool |
|
| 109 | - */ |
|
| 110 | - public function isShown() |
|
| 111 | - { |
|
| 112 | - return $this->getBackendUser()->isAdmin(); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Get the Vidi Module Loader. |
|
| 117 | - * |
|
| 118 | - * @return ModuleLoader|object |
|
| 119 | - */ |
|
| 120 | - protected function getModuleLoader() |
|
| 121 | - { |
|
| 122 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @return ModulePreferences|object |
|
| 127 | - */ |
|
| 128 | - protected function getModulePreferences() |
|
| 129 | - { |
|
| 130 | - return GeneralUtility::makeInstance(ModulePreferences::class); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Get the Vidi Module Loader. |
|
| 135 | - * |
|
| 136 | - * @return GridAnalyserService|object |
|
| 137 | - */ |
|
| 138 | - protected function getGridAnalyserService() |
|
| 139 | - { |
|
| 140 | - return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
| 141 | - } |
|
| 25 | + /** |
|
| 26 | + * Display the title of the tool on the welcome screen. |
|
| 27 | + * |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + public function getTitle() |
|
| 31 | + { |
|
| 32 | + return LocalizationUtility::translate( |
|
| 33 | + 'module_preferences_for', |
|
| 34 | + 'vidi', |
|
| 35 | + array(Tca::table($this->getModuleLoader()->getDataType())->getTitle()) |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Display the description of the tool in the welcome screen. |
|
| 41 | + * |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | + public function getDescription() |
|
| 45 | + { |
|
| 46 | + $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ModulePreferences/Launcher.html'; |
|
| 47 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 48 | + $view->assign('sitePath', Environment::getPublicPath() . '/'); |
|
| 49 | + return $view->render(); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Do the job! |
|
| 54 | + * |
|
| 55 | + * @param array $arguments |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 58 | + public function work(array $arguments = array()) |
|
| 59 | + { |
|
| 60 | + if (isset($arguments['save'])) { |
|
| 61 | + // Revert visible <-> excluded |
|
| 62 | + $excludedFields = array_diff( |
|
| 63 | + Tca::grid()->getAllFieldNames(), |
|
| 64 | + $arguments['excluded_fields'], |
|
| 65 | + $this->getExcludedFieldsFromTca() |
|
| 66 | + ); |
|
| 67 | + $arguments['excluded_fields'] = $excludedFields; |
|
| 68 | + $this->getModulePreferences()->save($arguments); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ModulePreferences/WorkResult.html'; |
|
| 72 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 73 | + |
|
| 74 | + $view->assign('title', Tca::table($this->getModuleLoader()->getDataType())->getTitle()); |
|
| 75 | + |
|
| 76 | + // Fetch the menu of visible items. |
|
| 77 | + $menuVisibleItems = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS); |
|
| 78 | + $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS, $menuVisibleItems); |
|
| 79 | + |
|
| 80 | + // Fetch the default number of menu visible items. |
|
| 81 | + $menuDefaultVisible = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT); |
|
| 82 | + $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT, $menuDefaultVisible); |
|
| 83 | + |
|
| 84 | + // Get the visible columns |
|
| 85 | + $view->assign('columns', Tca::grid()->getAllFieldNames()); |
|
| 86 | + |
|
| 87 | + return $view->render(); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @return array |
|
| 92 | + */ |
|
| 93 | + protected function getExcludedFieldsFromTca() |
|
| 94 | + { |
|
| 95 | + $tca = Tca::grid()->getTca(); |
|
| 96 | + $excludedFields = []; |
|
| 97 | + if (!empty($tca['excluded_fields'])) { |
|
| 98 | + $excludedFields = GeneralUtility::trimExplode(',', $tca['excluded_fields'], true); |
|
| 99 | + } elseif (!empty($tca['export']['excluded_fields'])) { // only for export for legacy reason. |
|
| 100 | + $excludedFields = GeneralUtility::trimExplode(',', $tca['export']['excluded_fields'], true); |
|
| 101 | + } |
|
| 102 | + return $excludedFields; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Tell whether the tools should be displayed according to the context. |
|
| 107 | + * |
|
| 108 | + * @return bool |
|
| 109 | + */ |
|
| 110 | + public function isShown() |
|
| 111 | + { |
|
| 112 | + return $this->getBackendUser()->isAdmin(); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Get the Vidi Module Loader. |
|
| 117 | + * |
|
| 118 | + * @return ModuleLoader|object |
|
| 119 | + */ |
|
| 120 | + protected function getModuleLoader() |
|
| 121 | + { |
|
| 122 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @return ModulePreferences|object |
|
| 127 | + */ |
|
| 128 | + protected function getModulePreferences() |
|
| 129 | + { |
|
| 130 | + return GeneralUtility::makeInstance(ModulePreferences::class); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Get the Vidi Module Loader. |
|
| 135 | + * |
|
| 136 | + * @return GridAnalyserService|object |
|
| 137 | + */ |
|
| 138 | + protected function getGridAnalyserService() |
|
| 139 | + { |
|
| 140 | + return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
| 141 | + } |
|
| 142 | 142 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | { |
| 41 | 41 | $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/RelationAnalyser/Launcher.html'; |
| 42 | 42 | $view = $this->initializeStandaloneView($templateNameAndPath); |
| 43 | - $view->assign('sitePath', Environment::getPublicPath() . '/'); |
|
| 43 | + $view->assign('sitePath', Environment::getPublicPath().'/'); |
|
| 44 | 44 | $view->assign('dataType', $this->getModuleLoader()->getDataType()); |
| 45 | 45 | return $view->render(); |
| 46 | 46 | } |
@@ -19,86 +19,86 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class RelationAnalyserTool extends AbstractTool |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Display the title of the tool on the welcome screen. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function getTitle(): string |
|
| 28 | - { |
|
| 29 | - return LocalizationUtility::translate( |
|
| 30 | - 'analyse_relations', |
|
| 31 | - 'vidi' |
|
| 32 | - ); |
|
| 33 | - } |
|
| 22 | + /** |
|
| 23 | + * Display the title of the tool on the welcome screen. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function getTitle(): string |
|
| 28 | + { |
|
| 29 | + return LocalizationUtility::translate( |
|
| 30 | + 'analyse_relations', |
|
| 31 | + 'vidi' |
|
| 32 | + ); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Display the description of the tool in the welcome screen. |
|
| 37 | - * |
|
| 38 | - * @return string |
|
| 39 | - */ |
|
| 40 | - public function getDescription(): string |
|
| 41 | - { |
|
| 42 | - $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/RelationAnalyser/Launcher.html'; |
|
| 43 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 44 | - $view->assign('sitePath', Environment::getPublicPath() . '/'); |
|
| 45 | - $view->assign('dataType', $this->getModuleLoader()->getDataType()); |
|
| 46 | - return $view->render(); |
|
| 47 | - } |
|
| 35 | + /** |
|
| 36 | + * Display the description of the tool in the welcome screen. |
|
| 37 | + * |
|
| 38 | + * @return string |
|
| 39 | + */ |
|
| 40 | + public function getDescription(): string |
|
| 41 | + { |
|
| 42 | + $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/RelationAnalyser/Launcher.html'; |
|
| 43 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 44 | + $view->assign('sitePath', Environment::getPublicPath() . '/'); |
|
| 45 | + $view->assign('dataType', $this->getModuleLoader()->getDataType()); |
|
| 46 | + return $view->render(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Do the job |
|
| 51 | - * |
|
| 52 | - * @param array $arguments |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 55 | - public function work(array $arguments = array()): string |
|
| 56 | - { |
|
| 57 | - $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/RelationAnalyser/WorkResult.html'; |
|
| 58 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 49 | + /** |
|
| 50 | + * Do the job |
|
| 51 | + * |
|
| 52 | + * @param array $arguments |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | + public function work(array $arguments = array()): string |
|
| 56 | + { |
|
| 57 | + $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/RelationAnalyser/WorkResult.html'; |
|
| 58 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 59 | 59 | |
| 60 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
| 61 | - $analyse = $this->getGridAnalyserService()->checkRelationForTable($dataType); |
|
| 60 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
| 61 | + $analyse = $this->getGridAnalyserService()->checkRelationForTable($dataType); |
|
| 62 | 62 | |
| 63 | - if (empty($analyse)) { |
|
| 64 | - $result = 'No relation involved in this Grid.'; |
|
| 65 | - } else { |
|
| 66 | - $result = implode("\n", $analyse); |
|
| 67 | - } |
|
| 63 | + if (empty($analyse)) { |
|
| 64 | + $result = 'No relation involved in this Grid.'; |
|
| 65 | + } else { |
|
| 66 | + $result = implode("\n", $analyse); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $view->assign('result', $result); |
|
| 70 | - $view->assign('dataType', $dataType); |
|
| 69 | + $view->assign('result', $result); |
|
| 70 | + $view->assign('dataType', $dataType); |
|
| 71 | 71 | |
| 72 | - return $view->render(); |
|
| 73 | - } |
|
| 72 | + return $view->render(); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Tell whether the tools should be displayed according to the context. |
|
| 77 | - * |
|
| 78 | - * @return bool |
|
| 79 | - */ |
|
| 80 | - public function isShown(): bool |
|
| 81 | - { |
|
| 82 | - return $this->getBackendUser()->isAdmin(); |
|
| 83 | - } |
|
| 75 | + /** |
|
| 76 | + * Tell whether the tools should be displayed according to the context. |
|
| 77 | + * |
|
| 78 | + * @return bool |
|
| 79 | + */ |
|
| 80 | + public function isShown(): bool |
|
| 81 | + { |
|
| 82 | + return $this->getBackendUser()->isAdmin(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Get the Vidi Module Loader. |
|
| 87 | - * |
|
| 88 | - * @return ModuleLoader|object |
|
| 89 | - */ |
|
| 90 | - protected function getModuleLoader(): ModuleLoader |
|
| 91 | - { |
|
| 92 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 93 | - } |
|
| 85 | + /** |
|
| 86 | + * Get the Vidi Module Loader. |
|
| 87 | + * |
|
| 88 | + * @return ModuleLoader|object |
|
| 89 | + */ |
|
| 90 | + protected function getModuleLoader(): ModuleLoader |
|
| 91 | + { |
|
| 92 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Get the Vidi Module Loader. |
|
| 97 | - * |
|
| 98 | - * @return GridAnalyserService|object |
|
| 99 | - */ |
|
| 100 | - protected function getGridAnalyserService() |
|
| 101 | - { |
|
| 102 | - return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
| 103 | - } |
|
| 95 | + /** |
|
| 96 | + * Get the Vidi Module Loader. |
|
| 97 | + * |
|
| 98 | + * @return GridAnalyserService|object |
|
| 99 | + */ |
|
| 100 | + protected function getGridAnalyserService() |
|
| 101 | + { |
|
| 102 | + return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ConfiguredPid/Launcher.html'; |
| 43 | 43 | $view = $this->initializeStandaloneView($templateNameAndPath); |
| 44 | 44 | $view->assignMultiple([ |
| 45 | - 'sitePath' => Environment::getPublicPath() . '/', |
|
| 45 | + 'sitePath' => Environment::getPublicPath().'/', |
|
| 46 | 46 | 'dataType' => $this->getModuleLoader()->getDataType(), |
| 47 | 47 | 'configuredPid' => $this->getModulePidService()->getConfiguredNewRecordPid(), |
| 48 | 48 | 'errors' => $this->getModulePidService()->validateConfiguredPid(), |
@@ -19,76 +19,76 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class ConfiguredPidTool extends AbstractTool |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Display the title of the tool on the welcome screen. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function getTitle(): string |
|
| 28 | - { |
|
| 29 | - return sprintf( |
|
| 30 | - '%s (%s)', |
|
| 31 | - LocalizationUtility::translate('tool.configured_pid', 'vidi'), |
|
| 32 | - $this->getModulePidService()->getConfiguredNewRecordPid() |
|
| 33 | - ); |
|
| 34 | - } |
|
| 22 | + /** |
|
| 23 | + * Display the title of the tool on the welcome screen. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function getTitle(): string |
|
| 28 | + { |
|
| 29 | + return sprintf( |
|
| 30 | + '%s (%s)', |
|
| 31 | + LocalizationUtility::translate('tool.configured_pid', 'vidi'), |
|
| 32 | + $this->getModulePidService()->getConfiguredNewRecordPid() |
|
| 33 | + ); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Display the description of the tool in the welcome screen. |
|
| 38 | - * |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 41 | - public function getDescription(): string |
|
| 42 | - { |
|
| 43 | - $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ConfiguredPid/Launcher.html'; |
|
| 44 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 45 | - $view->assignMultiple([ |
|
| 46 | - 'sitePath' => Environment::getPublicPath() . '/', |
|
| 47 | - 'dataType' => $this->getModuleLoader()->getDataType(), |
|
| 48 | - 'configuredPid' => $this->getModulePidService()->getConfiguredNewRecordPid(), |
|
| 49 | - 'errors' => $this->getModulePidService()->validateConfiguredPid(), |
|
| 50 | - ]); |
|
| 36 | + /** |
|
| 37 | + * Display the description of the tool in the welcome screen. |
|
| 38 | + * |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | + public function getDescription(): string |
|
| 42 | + { |
|
| 43 | + $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ConfiguredPid/Launcher.html'; |
|
| 44 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
| 45 | + $view->assignMultiple([ |
|
| 46 | + 'sitePath' => Environment::getPublicPath() . '/', |
|
| 47 | + 'dataType' => $this->getModuleLoader()->getDataType(), |
|
| 48 | + 'configuredPid' => $this->getModulePidService()->getConfiguredNewRecordPid(), |
|
| 49 | + 'errors' => $this->getModulePidService()->validateConfiguredPid(), |
|
| 50 | + ]); |
|
| 51 | 51 | |
| 52 | - return $view->render(); |
|
| 53 | - } |
|
| 52 | + return $view->render(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Do the job |
|
| 57 | - * |
|
| 58 | - * @param array $arguments |
|
| 59 | - * @return string |
|
| 60 | - */ |
|
| 61 | - public function work(array $arguments = array()): string |
|
| 62 | - { |
|
| 63 | - return ''; |
|
| 64 | - } |
|
| 55 | + /** |
|
| 56 | + * Do the job |
|
| 57 | + * |
|
| 58 | + * @param array $arguments |
|
| 59 | + * @return string |
|
| 60 | + */ |
|
| 61 | + public function work(array $arguments = array()): string |
|
| 62 | + { |
|
| 63 | + return ''; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Tell whether the tools should be displayed according to the context. |
|
| 68 | - * |
|
| 69 | - * @return bool |
|
| 70 | - */ |
|
| 71 | - public function isShown(): bool |
|
| 72 | - { |
|
| 73 | - return $this->getBackendUser()->isAdmin(); |
|
| 74 | - } |
|
| 66 | + /** |
|
| 67 | + * Tell whether the tools should be displayed according to the context. |
|
| 68 | + * |
|
| 69 | + * @return bool |
|
| 70 | + */ |
|
| 71 | + public function isShown(): bool |
|
| 72 | + { |
|
| 73 | + return $this->getBackendUser()->isAdmin(); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Get the Vidi Module Loader. |
|
| 78 | - * |
|
| 79 | - * @return ModuleLoader|object |
|
| 80 | - */ |
|
| 81 | - protected function getModuleLoader(): ModuleLoader |
|
| 82 | - { |
|
| 83 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 84 | - } |
|
| 76 | + /** |
|
| 77 | + * Get the Vidi Module Loader. |
|
| 78 | + * |
|
| 79 | + * @return ModuleLoader|object |
|
| 80 | + */ |
|
| 81 | + protected function getModuleLoader(): ModuleLoader |
|
| 82 | + { |
|
| 83 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @return ModulePidService|object |
|
| 88 | - */ |
|
| 89 | - public function getModulePidService() |
|
| 90 | - { |
|
| 91 | - /** @var ModulePidService $modulePidService */ |
|
| 92 | - return GeneralUtility::makeInstance(ModulePidService::class); |
|
| 93 | - } |
|
| 86 | + /** |
|
| 87 | + * @return ModulePidService|object |
|
| 88 | + */ |
|
| 89 | + public function getModulePidService() |
|
| 90 | + { |
|
| 91 | + /** @var ModulePidService $modulePidService */ |
|
| 92 | + return GeneralUtility::makeInstance(ModulePidService::class); |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -58,9 +58,9 @@ |
||
| 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 | } |
@@ -20,42 +20,42 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class AdditionalAssetsViewHelper extends AbstractBackendViewHelper |
| 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 | } |
@@ -33,7 +33,7 @@ |
||
| 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 | } |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class RequireJsViewHelper extends AbstractBackendViewHelper |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Load RequireJS code. |
|
| 24 | - * |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public function render() |
|
| 28 | - { |
|
| 29 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 22 | + /** |
|
| 23 | + * Load RequireJS code. |
|
| 24 | + * |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public function render() |
|
| 28 | + { |
|
| 29 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 30 | 30 | |
| 31 | - $content = $this->renderChildren(); |
|
| 32 | - $pageRenderer->addJsInlineCode('vidi-inline', $content); |
|
| 31 | + $content = $this->renderChildren(); |
|
| 32 | + $pageRenderer->addJsInlineCode('vidi-inline', $content); |
|
| 33 | 33 | |
| 34 | - $publicResourcesPath = PathUtility::getPublicResourceWebPath('EXT:vidi/Resources/Public/'); |
|
| 35 | - $configuration['paths']['Fab/Vidi'] = $publicResourcesPath . 'JavaScript'; |
|
| 36 | - $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 37 | - $pageRenderer->loadRequireJsModule('Fab/Vidi/Vidi/Main'); |
|
| 38 | - } |
|
| 34 | + $publicResourcesPath = PathUtility::getPublicResourceWebPath('EXT:vidi/Resources/Public/'); |
|
| 35 | + $configuration['paths']['Fab/Vidi'] = $publicResourcesPath . 'JavaScript'; |
|
| 36 | + $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 37 | + $pageRenderer->loadRequireJsModule('Fab/Vidi/Vidi/Main'); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -103,7 +103,7 @@ |
||
| 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'); |
@@ -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 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | use Fab\Vidi\Domain\Model\Content; |
| 18 | 18 | use Fab\Vidi\Tests\Functional\AbstractFunctionalTestCase; |
| 19 | 19 | |
| 20 | -require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php'; |
|
| 20 | +require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php'; |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Test case for class \Fab\Vidi\Grid\CategoryRenderer. |
@@ -25,42 +25,42 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class RelationRendererTest extends AbstractFunctionalTestCase |
| 27 | 27 | { |
| 28 | - /** |
|
| 29 | - * @var RelationRenderer |
|
| 30 | - */ |
|
| 31 | - private $fixture; |
|
| 28 | + /** |
|
| 29 | + * @var RelationRenderer |
|
| 30 | + */ |
|
| 31 | + private $fixture; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - private $dataType = 'fe_users'; |
|
| 33 | + /** |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + private $dataType = 'fe_users'; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - private $moduleCode = 'user_VidiFeUsersM1'; |
|
| 38 | + /** |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + private $moduleCode = 'user_VidiFeUsersM1'; |
|
| 42 | 42 | |
| 43 | - public function setUp() |
|
| 44 | - { |
|
| 45 | - parent::setUp(); |
|
| 46 | - $moduleLoader = new ModuleLoader($this->dataType); |
|
| 47 | - $moduleLoader->register(); |
|
| 48 | - $GLOBALS['_GET']['M'] = $this->moduleCode; |
|
| 49 | - $this->fixture = new RelationRenderer(); |
|
| 50 | - } |
|
| 43 | + public function setUp() |
|
| 44 | + { |
|
| 45 | + parent::setUp(); |
|
| 46 | + $moduleLoader = new ModuleLoader($this->dataType); |
|
| 47 | + $moduleLoader->register(); |
|
| 48 | + $GLOBALS['_GET']['M'] = $this->moduleCode; |
|
| 49 | + $this->fixture = new RelationRenderer(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function tearDown() |
|
| 53 | - { |
|
| 54 | - unset($this->fixture, $GLOBALS['_GET']['M']); |
|
| 55 | - } |
|
| 52 | + public function tearDown() |
|
| 53 | + { |
|
| 54 | + unset($this->fixture, $GLOBALS['_GET']['M']); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @test |
|
| 59 | - */ |
|
| 60 | - public function renderAssetWithNoCategoryReturnsEmpty() |
|
| 61 | - { |
|
| 62 | - $content = new Content($this->dataType); |
|
| 63 | - $this->markTestIncomplete(); # TCA must be faked |
|
| 64 | - #$actual = $this->fixture->setObject($content)->render(); |
|
| 65 | - } |
|
| 57 | + /** |
|
| 58 | + * @test |
|
| 59 | + */ |
|
| 60 | + public function renderAssetWithNoCategoryReturnsEmpty() |
|
| 61 | + { |
|
| 62 | + $content = new Content($this->dataType); |
|
| 63 | + $this->markTestIncomplete(); # TCA must be faked |
|
| 64 | + #$actual = $this->fixture->setObject($content)->render(); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | use Fab\Vidi\Domain\Model\Selection; |
| 5 | 5 | |
| 6 | 6 | return [ |
| 7 | - Selection::class => [ |
|
| 8 | - 'tableName' => 'tx_vidi_selection', |
|
| 9 | - ], |
|
| 7 | + Selection::class => [ |
|
| 8 | + 'tableName' => 'tx_vidi_selection', |
|
| 9 | + ], |
|
| 10 | 10 | ]; |
@@ -123,7 +123,7 @@ |
||
| 123 | 123 | /** @var Response $response */ |
| 124 | 124 | $response = $this->templateVariableContainer->get('response'); |
| 125 | 125 | $response->withHeader('Content-Type', 'application/xml'); |
| 126 | - $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"'); |
|
| 126 | + $response->withHeader('Content-Disposition', 'attachment; filename="'.basename($this->exportFileNameAndPath).'"'); |
|
| 127 | 127 | $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath)); |
| 128 | 128 | $response->withHeader('Content-Description', 'File Transfer'); |
| 129 | 129 | } |
@@ -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 | } |