@@ -19,76 +19,76 @@ |
||
19 | 19 | class SelectionRepository extends Repository |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param string $dataType |
|
24 | - * @return QueryResult |
|
25 | - */ |
|
26 | - public function findByDataTypeForCurrentBackendUser($dataType) |
|
27 | - { |
|
28 | - $query = $this->createQuery(); |
|
22 | + /** |
|
23 | + * @param string $dataType |
|
24 | + * @return QueryResult |
|
25 | + */ |
|
26 | + public function findByDataTypeForCurrentBackendUser($dataType) |
|
27 | + { |
|
28 | + $query = $this->createQuery(); |
|
29 | 29 | |
30 | - // Compute the OR part |
|
31 | - if ($this->getBackendUser()->isAdmin()) { |
|
32 | - $logicalOr = $query->logicalOr( |
|
33 | - $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
34 | - $query->equals('visibility', Selection::VISIBILITY_ADMIN_ONLY), |
|
35 | - $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
36 | - ); |
|
37 | - } else { |
|
38 | - $logicalOr = $query->logicalOr( |
|
39 | - $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
40 | - $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
41 | - ); |
|
42 | - } |
|
30 | + // Compute the OR part |
|
31 | + if ($this->getBackendUser()->isAdmin()) { |
|
32 | + $logicalOr = $query->logicalOr( |
|
33 | + $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
34 | + $query->equals('visibility', Selection::VISIBILITY_ADMIN_ONLY), |
|
35 | + $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
36 | + ); |
|
37 | + } else { |
|
38 | + $logicalOr = $query->logicalOr( |
|
39 | + $query->equals('visibility', Selection::VISIBILITY_EVERYONE), |
|
40 | + $query->equals('cruser_id', $this->getBackendUser()->user['uid']) |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | |
44 | - // Add matching criteria |
|
45 | - $query->matching( |
|
46 | - $query->logicalAnd( |
|
47 | - $query->equals('dataType', $dataType), |
|
48 | - $logicalOr |
|
49 | - ) |
|
50 | - ); |
|
44 | + // Add matching criteria |
|
45 | + $query->matching( |
|
46 | + $query->logicalAnd( |
|
47 | + $query->equals('dataType', $dataType), |
|
48 | + $logicalOr |
|
49 | + ) |
|
50 | + ); |
|
51 | 51 | |
52 | - // Set ordering |
|
53 | - $query->setOrderings( |
|
54 | - array('name' => QueryInterface::ORDER_ASCENDING) |
|
55 | - ); |
|
52 | + // Set ordering |
|
53 | + $query->setOrderings( |
|
54 | + array('name' => QueryInterface::ORDER_ASCENDING) |
|
55 | + ); |
|
56 | 56 | |
57 | - return $query->execute(); |
|
58 | - } |
|
57 | + return $query->execute(); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $dataType |
|
62 | - * @return QueryResult |
|
63 | - */ |
|
64 | - public function findForEveryone($dataType) |
|
65 | - { |
|
66 | - $query = $this->createQuery(); |
|
60 | + /** |
|
61 | + * @param string $dataType |
|
62 | + * @return QueryResult |
|
63 | + */ |
|
64 | + public function findForEveryone($dataType) |
|
65 | + { |
|
66 | + $query = $this->createQuery(); |
|
67 | 67 | |
68 | - // Add matching criteria |
|
69 | - $query->matching( |
|
70 | - $query->logicalAnd( |
|
71 | - $query->equals('dataType', $dataType), |
|
72 | - $query->equals('visibility', Selection::VISIBILITY_EVERYONE) |
|
73 | - ) |
|
74 | - ); |
|
68 | + // Add matching criteria |
|
69 | + $query->matching( |
|
70 | + $query->logicalAnd( |
|
71 | + $query->equals('dataType', $dataType), |
|
72 | + $query->equals('visibility', Selection::VISIBILITY_EVERYONE) |
|
73 | + ) |
|
74 | + ); |
|
75 | 75 | |
76 | - // Set ordering |
|
77 | - $query->setOrderings( |
|
78 | - array('name' => QueryInterface::ORDER_ASCENDING) |
|
79 | - ); |
|
76 | + // Set ordering |
|
77 | + $query->setOrderings( |
|
78 | + array('name' => QueryInterface::ORDER_ASCENDING) |
|
79 | + ); |
|
80 | 80 | |
81 | - return $query->execute(); |
|
82 | - } |
|
81 | + return $query->execute(); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Returns an instance of the current Backend User. |
|
86 | - * |
|
87 | - * @return BackendUserAuthentication |
|
88 | - */ |
|
89 | - protected function getBackendUser() |
|
90 | - { |
|
91 | - return $GLOBALS['BE_USER']; |
|
92 | - } |
|
84 | + /** |
|
85 | + * Returns an instance of the current Backend User. |
|
86 | + * |
|
87 | + * @return BackendUserAuthentication |
|
88 | + */ |
|
89 | + protected function getBackendUser() |
|
90 | + { |
|
91 | + return $GLOBALS['BE_USER']; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | \ No newline at end of file |
@@ -17,44 +17,44 @@ |
||
17 | 17 | class ContentRepositoryFactory implements SingletonInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - static protected $instances = []; |
|
24 | - |
|
25 | - /** |
|
26 | - * Returns a class instance of a repository. |
|
27 | - * If not data type is given, get the value from the module loader. |
|
28 | - * |
|
29 | - * @param string $dataType |
|
30 | - * @param string $sourceFieldName |
|
31 | - * @return ContentRepository |
|
32 | - */ |
|
33 | - static public function getInstance($dataType = null, $sourceFieldName = '') |
|
34 | - { |
|
35 | - |
|
36 | - /** @var ModuleLoader $moduleLoader */ |
|
37 | - if (is_null($dataType)) { |
|
38 | - |
|
39 | - // Try to get the data type from the module loader. |
|
40 | - $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
41 | - $dataType = $moduleLoader->getDataType(); |
|
42 | - } |
|
43 | - |
|
44 | - // This should not happen. |
|
45 | - if (!$dataType) { |
|
46 | - throw new \RuntimeException('No data type given nor could be fetched by the module loader.', 1376118278); |
|
47 | - } |
|
48 | - |
|
49 | - if (empty(self::$instances[$dataType])) { |
|
50 | - $className = 'Fab\Vidi\Domain\Repository\ContentRepository'; |
|
51 | - self::$instances[$dataType] = GeneralUtility::makeInstance($className, $dataType, $sourceFieldName); |
|
52 | - } |
|
53 | - |
|
54 | - /** @var ContentRepository $contentRepository */ |
|
55 | - $contentRepository = self::$instances[$dataType]; |
|
56 | - $contentRepository->setSourceFieldName($sourceFieldName); |
|
57 | - return $contentRepository; |
|
58 | - } |
|
20 | + /** |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + static protected $instances = []; |
|
24 | + |
|
25 | + /** |
|
26 | + * Returns a class instance of a repository. |
|
27 | + * If not data type is given, get the value from the module loader. |
|
28 | + * |
|
29 | + * @param string $dataType |
|
30 | + * @param string $sourceFieldName |
|
31 | + * @return ContentRepository |
|
32 | + */ |
|
33 | + static public function getInstance($dataType = null, $sourceFieldName = '') |
|
34 | + { |
|
35 | + |
|
36 | + /** @var ModuleLoader $moduleLoader */ |
|
37 | + if (is_null($dataType)) { |
|
38 | + |
|
39 | + // Try to get the data type from the module loader. |
|
40 | + $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
41 | + $dataType = $moduleLoader->getDataType(); |
|
42 | + } |
|
43 | + |
|
44 | + // This should not happen. |
|
45 | + if (!$dataType) { |
|
46 | + throw new \RuntimeException('No data type given nor could be fetched by the module loader.', 1376118278); |
|
47 | + } |
|
48 | + |
|
49 | + if (empty(self::$instances[$dataType])) { |
|
50 | + $className = 'Fab\Vidi\Domain\Repository\ContentRepository'; |
|
51 | + self::$instances[$dataType] = GeneralUtility::makeInstance($className, $dataType, $sourceFieldName); |
|
52 | + } |
|
53 | + |
|
54 | + /** @var ContentRepository $contentRepository */ |
|
55 | + $contentRepository = self::$instances[$dataType]; |
|
56 | + $contentRepository->setSourceFieldName($sourceFieldName); |
|
57 | + return $contentRepository; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
@@ -18,36 +18,36 @@ |
||
18 | 18 | class ToolValidator extends AbstractValidator |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Check whether $tool is valid. |
|
23 | - * |
|
24 | - * @param string $tool |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function isValid($tool) |
|
28 | - { |
|
21 | + /** |
|
22 | + * Check whether $tool is valid. |
|
23 | + * |
|
24 | + * @param string $tool |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function isValid($tool) |
|
28 | + { |
|
29 | 29 | |
30 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
31 | - $isValid = ToolRegistry::getInstance()->isAllowed($dataType, $tool); |
|
30 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
31 | + $isValid = ToolRegistry::getInstance()->isAllowed($dataType, $tool); |
|
32 | 32 | |
33 | - if (!$isValid) { |
|
34 | - $message = sprintf('This Tool "%s" is not allowed for the current data type.', $tool); |
|
35 | - $this->addError($message, 1409041510); |
|
36 | - } |
|
33 | + if (!$isValid) { |
|
34 | + $message = sprintf('This Tool "%s" is not allowed for the current data type.', $tool); |
|
35 | + $this->addError($message, 1409041510); |
|
36 | + } |
|
37 | 37 | |
38 | - if (!class_exists($tool)) { |
|
39 | - $message = sprintf('I could not find class "%s"', $tool); |
|
40 | - $this->addError($message, 1409041511); |
|
41 | - } |
|
42 | - } |
|
38 | + if (!class_exists($tool)) { |
|
39 | + $message = sprintf('I could not find class "%s"', $tool); |
|
40 | + $this->addError($message, 1409041511); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the Vidi Module Loader. |
|
46 | - * |
|
47 | - * @return ModuleLoader|object |
|
48 | - */ |
|
49 | - protected function getModuleLoader() |
|
50 | - { |
|
51 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
52 | - } |
|
44 | + /** |
|
45 | + * Get the Vidi Module Loader. |
|
46 | + * |
|
47 | + * @return ModuleLoader|object |
|
48 | + */ |
|
49 | + protected function getModuleLoader() |
|
50 | + { |
|
51 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
52 | + } |
|
53 | 53 | } |
@@ -19,79 +19,79 @@ |
||
19 | 19 | class ClipboardController extends ActionController |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Save data into the clipboard. |
|
24 | - * |
|
25 | - * @param array $matches |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function saveAction(array $matches = array()) |
|
29 | - { |
|
30 | - |
|
31 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
32 | - $this->getClipboardService()->save($matcher); |
|
33 | - |
|
34 | - // Fetch objects via the Content Service. |
|
35 | - $contentService = $this->getContentService()->findBy($matcher); |
|
36 | - $numberOfObjects = $contentService->getNumberOfObjects(); |
|
37 | - |
|
38 | - if ($numberOfObjects === 0) { |
|
39 | - $this->getClipboardService()->flush(); |
|
40 | - } |
|
41 | - |
|
42 | - # Json header is not automatically sent in the BE... |
|
43 | - $this->response->setHeader('Content-Type', 'application/json'); |
|
44 | - $this->response->sendHeaders(); |
|
45 | - return json_encode($numberOfObjects); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Completely flush the clipboard. |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function flushAction() |
|
54 | - { |
|
55 | - $this->getClipboardService()->flush(); |
|
56 | - |
|
57 | - # Json header is not automatically sent in the BE... |
|
58 | - $this->response->setHeader('Content-Type', 'application/json'); |
|
59 | - $this->response->sendHeaders(); |
|
60 | - return json_encode(true); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Show the content of the clipboard. |
|
65 | - */ |
|
66 | - public function showAction() |
|
67 | - { |
|
68 | - |
|
69 | - // Retrieve matcher object from clipboard. |
|
70 | - $matcher = $this->getClipboardService()->getMatcher(); |
|
71 | - |
|
72 | - // Fetch objects via the Content Service. |
|
73 | - $contentService = $this->getContentService()->findBy($matcher); |
|
74 | - |
|
75 | - // count number of items and display it. |
|
76 | - $this->view->assign('target', GeneralUtility::_GP('id')); |
|
77 | - $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
78 | - $this->view->assign('objects', $contentService->getObjects()); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return ClipboardService|object |
|
83 | - */ |
|
84 | - protected function getClipboardService() |
|
85 | - { |
|
86 | - return GeneralUtility::makeInstance(ClipboardService::class); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return ContentService|object |
|
91 | - */ |
|
92 | - protected function getContentService() |
|
93 | - { |
|
94 | - return GeneralUtility::makeInstance(ContentService::class); |
|
95 | - } |
|
22 | + /** |
|
23 | + * Save data into the clipboard. |
|
24 | + * |
|
25 | + * @param array $matches |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function saveAction(array $matches = array()) |
|
29 | + { |
|
30 | + |
|
31 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
32 | + $this->getClipboardService()->save($matcher); |
|
33 | + |
|
34 | + // Fetch objects via the Content Service. |
|
35 | + $contentService = $this->getContentService()->findBy($matcher); |
|
36 | + $numberOfObjects = $contentService->getNumberOfObjects(); |
|
37 | + |
|
38 | + if ($numberOfObjects === 0) { |
|
39 | + $this->getClipboardService()->flush(); |
|
40 | + } |
|
41 | + |
|
42 | + # Json header is not automatically sent in the BE... |
|
43 | + $this->response->setHeader('Content-Type', 'application/json'); |
|
44 | + $this->response->sendHeaders(); |
|
45 | + return json_encode($numberOfObjects); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Completely flush the clipboard. |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function flushAction() |
|
54 | + { |
|
55 | + $this->getClipboardService()->flush(); |
|
56 | + |
|
57 | + # Json header is not automatically sent in the BE... |
|
58 | + $this->response->setHeader('Content-Type', 'application/json'); |
|
59 | + $this->response->sendHeaders(); |
|
60 | + return json_encode(true); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Show the content of the clipboard. |
|
65 | + */ |
|
66 | + public function showAction() |
|
67 | + { |
|
68 | + |
|
69 | + // Retrieve matcher object from clipboard. |
|
70 | + $matcher = $this->getClipboardService()->getMatcher(); |
|
71 | + |
|
72 | + // Fetch objects via the Content Service. |
|
73 | + $contentService = $this->getContentService()->findBy($matcher); |
|
74 | + |
|
75 | + // count number of items and display it. |
|
76 | + $this->view->assign('target', GeneralUtility::_GP('id')); |
|
77 | + $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
78 | + $this->view->assign('objects', $contentService->getObjects()); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return ClipboardService|object |
|
83 | + */ |
|
84 | + protected function getClipboardService() |
|
85 | + { |
|
86 | + return GeneralUtility::makeInstance(ClipboardService::class); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return ContentService|object |
|
91 | + */ |
|
92 | + protected function getContentService() |
|
93 | + { |
|
94 | + return GeneralUtility::makeInstance(ContentService::class); |
|
95 | + } |
|
96 | 96 | |
97 | 97 | } |
@@ -20,46 +20,46 @@ |
||
20 | 20 | class ToolController extends ActionController |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function welcomeAction() |
|
27 | - { |
|
28 | - $items = []; |
|
29 | - $tools = ToolRegistry::getInstance()->getTools($this->getModuleLoader()->getDataType()); |
|
23 | + /** |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function welcomeAction() |
|
27 | + { |
|
28 | + $items = []; |
|
29 | + $tools = ToolRegistry::getInstance()->getTools($this->getModuleLoader()->getDataType()); |
|
30 | 30 | |
31 | - foreach ($tools as $index => $tool) { |
|
32 | - $item = []; |
|
33 | - $item['title'] = $tool->getTitle(); |
|
34 | - $item['description'] = $tool->getDescription(); |
|
31 | + foreach ($tools as $index => $tool) { |
|
32 | + $item = []; |
|
33 | + $item['title'] = $tool->getTitle(); |
|
34 | + $item['description'] = $tool->getDescription(); |
|
35 | 35 | |
36 | - $items[] = $item; |
|
37 | - } |
|
38 | - $this->view->assign('items', $items); |
|
39 | - } |
|
36 | + $items[] = $item; |
|
37 | + } |
|
38 | + $this->view->assign('items', $items); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string $tool |
|
43 | - * @param array $arguments |
|
44 | - * @return void |
|
45 | - * @Extbase\Validate("Fab\Vidi\Domain\Validator\ToolValidator", param="tool") |
|
46 | - */ |
|
47 | - public function workAction(string $tool, array $arguments = array()) |
|
48 | - { |
|
49 | - /** @var ToolInterface $tool */ |
|
50 | - $tool = GeneralUtility::makeInstance($tool); |
|
51 | - $workResult = $tool->work($arguments); |
|
52 | - $this->view->assign('result', $workResult); |
|
53 | - } |
|
41 | + /** |
|
42 | + * @param string $tool |
|
43 | + * @param array $arguments |
|
44 | + * @return void |
|
45 | + * @Extbase\Validate("Fab\Vidi\Domain\Validator\ToolValidator", param="tool") |
|
46 | + */ |
|
47 | + public function workAction(string $tool, array $arguments = array()) |
|
48 | + { |
|
49 | + /** @var ToolInterface $tool */ |
|
50 | + $tool = GeneralUtility::makeInstance($tool); |
|
51 | + $workResult = $tool->work($arguments); |
|
52 | + $this->view->assign('result', $workResult); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get the Vidi Module Loader. |
|
57 | - * |
|
58 | - * @return ModuleLoader|object |
|
59 | - */ |
|
60 | - protected function getModuleLoader() |
|
61 | - { |
|
62 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
63 | - } |
|
55 | + /** |
|
56 | + * Get the Vidi Module Loader. |
|
57 | + * |
|
58 | + * @return ModuleLoader|object |
|
59 | + */ |
|
60 | + protected function getModuleLoader() |
|
61 | + { |
|
62 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -18,29 +18,29 @@ |
||
18 | 18 | class VidiModulesAspect implements TableConfigurationPostProcessingHookInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Initialize and populate TBE_MODULES_EXT with default data. |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function processData() |
|
27 | - { |
|
28 | - |
|
29 | - /** @var ModuleLoader $moduleLoader */ |
|
30 | - $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
31 | - |
|
32 | - |
|
33 | - $configuration = GeneralUtility::makeInstance( |
|
34 | - ExtensionConfiguration::class |
|
35 | - )->get('vidi'); |
|
36 | - |
|
37 | - foreach (GeneralUtility::trimExplode(',', $configuration['data_types'],true) as $dataType) { |
|
38 | - if (!$moduleLoader->isRegistered($dataType)) { |
|
39 | - $moduleLoader->setDataType($dataType) |
|
40 | - #->isShown(false) |
|
41 | - ->register(); |
|
42 | - } |
|
43 | - } |
|
44 | - } |
|
21 | + /** |
|
22 | + * Initialize and populate TBE_MODULES_EXT with default data. |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function processData() |
|
27 | + { |
|
28 | + |
|
29 | + /** @var ModuleLoader $moduleLoader */ |
|
30 | + $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); |
|
31 | + |
|
32 | + |
|
33 | + $configuration = GeneralUtility::makeInstance( |
|
34 | + ExtensionConfiguration::class |
|
35 | + )->get('vidi'); |
|
36 | + |
|
37 | + foreach (GeneralUtility::trimExplode(',', $configuration['data_types'],true) as $dataType) { |
|
38 | + if (!$moduleLoader->isRegistered($dataType)) { |
|
39 | + $moduleLoader->setDataType($dataType) |
|
40 | + #->isShown(false) |
|
41 | + ->register(); |
|
42 | + } |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | ExtensionConfiguration::class |
35 | 35 | )->get('vidi'); |
36 | 36 | |
37 | - foreach (GeneralUtility::trimExplode(',', $configuration['data_types'],true) as $dataType) { |
|
37 | + foreach (GeneralUtility::trimExplode(',', $configuration['data_types'], true) as $dataType) { |
|
38 | 38 | if (!$moduleLoader->isRegistered($dataType)) { |
39 | 39 | $moduleLoader->setDataType($dataType) |
40 | 40 | #->isShown(false) |
@@ -21,168 +21,168 @@ |
||
21 | 21 | class LanguageService implements SingletonInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected $languages; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $defaultIcon; |
|
33 | - |
|
34 | - /** |
|
35 | - * Store the localized records to boost up performance. |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $localizedRecordStorage; |
|
40 | - |
|
41 | - /** |
|
42 | - * Returns available language records. |
|
43 | - * The method stores the records in the property to speed up the process as the method can be often called. |
|
44 | - * |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function getLanguages() |
|
48 | - { |
|
49 | - if ($this->languages === null) { |
|
50 | - $this->languages = $this->getDataService()->getRecords('sys_language'); |
|
51 | - } |
|
52 | - return $this->languages; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Returns a localized record according to a Content object and a language identifier. |
|
57 | - * Notice! This method does not overlay anything but simply returns the raw localized record. |
|
58 | - * |
|
59 | - * @param Content $object |
|
60 | - * @param int $language |
|
61 | - * @return Content |
|
62 | - */ |
|
63 | - public function getLocalizedContent(Content $object, $language) |
|
64 | - { |
|
65 | - |
|
66 | - // We want to cache data per Content object. Retrieve the Object hash. |
|
67 | - $objectHash = spl_object_hash($object); |
|
68 | - |
|
69 | - // Initialize the storage |
|
70 | - if (empty($this->localizedRecordStorage[$objectHash])) { |
|
71 | - $this->localizedRecordStorage[$objectHash] = []; |
|
72 | - } |
|
73 | - |
|
74 | - if (empty($this->localizedRecordStorage[$objectHash][$language])) { |
|
75 | - |
|
76 | - $localizedRecord = $this->getDataService()->getRecord( |
|
77 | - $object->getDataType(), |
|
78 | - [ |
|
79 | - Tca::table($object)->getLanguageParentField() => $object->getUid(), // e.g. l10n_parent |
|
80 | - Tca::table($object)->getLanguageField() => $language, // e.g. sys_language_uid |
|
81 | - ] |
|
82 | - ); |
|
83 | - |
|
84 | - if ($localizedRecord) { |
|
85 | - $localizedContent = GeneralUtility::makeInstance(Content::class, $object->getDataType(), $localizedRecord); |
|
86 | - $this->localizedRecordStorage[$objectHash][$language] = $localizedContent; |
|
87 | - } else { |
|
88 | - $this->localizedRecordStorage[$objectHash][$language] = []; // We want an array at least, even if empty. |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - return $this->localizedRecordStorage[$objectHash][$language]; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Tell whether the given Content object has a localization. |
|
97 | - * |
|
98 | - * @param Content $object |
|
99 | - * @param int $language |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function hasLocalization(Content $object, $language) |
|
103 | - { |
|
104 | - $localizedRecord = $this->getLocalizedContent($object, $language); |
|
105 | - return !empty($localizedRecord); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Returns a localized field according to a Content object and a language identifier. |
|
110 | - * Notice! If there is not translation, simply returns an empty string. |
|
111 | - * |
|
112 | - * @param Content $object |
|
113 | - * @param int $language |
|
114 | - * @param string $fieldName |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - public function getLocalizedFieldName(Content $object, $language, $fieldName) |
|
118 | - { |
|
119 | - $localizedRecord = $this->getLocalizedContent($object, $language); |
|
120 | - return empty($localizedRecord) ? '' : $localizedRecord[$fieldName]; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Returns the default language configured by TSConfig. |
|
125 | - * |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - public function getDefaultFlag() |
|
129 | - { |
|
130 | - |
|
131 | - if ($this->defaultIcon === null) { |
|
132 | - |
|
133 | - $defaultFlag = ''; // default value |
|
134 | - |
|
135 | - $tsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig(0, 'mod.SHARED'); |
|
136 | - |
|
137 | - // Fallback non sprite-configuration |
|
138 | - if (($pos = strrpos($tsConfig['properties']['defaultLanguageFlag'], '.')) !== false) { |
|
139 | - $defaultFlag = substr($tsConfig['properties']['defaultLanguageFlag'], 0, $pos); |
|
140 | - } |
|
141 | - |
|
142 | - $this->defaultIcon = $defaultFlag; |
|
143 | - } |
|
144 | - |
|
145 | - return $this->defaultIcon; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Returns whether the system includes language records. |
|
150 | - * |
|
151 | - * @return bool |
|
152 | - */ |
|
153 | - public function hasLanguages() |
|
154 | - { |
|
155 | - $languages = $this->getLanguages(); |
|
156 | - return !empty($languages); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Tell whether the given language exists. |
|
161 | - * |
|
162 | - * @param int $language |
|
163 | - * @return bool |
|
164 | - */ |
|
165 | - public function languageExists($language) |
|
166 | - { |
|
167 | - $languages = $this->getLanguages(); |
|
168 | - |
|
169 | - $LanguageExists = false; |
|
170 | - foreach ($languages as $_language) { |
|
171 | - if ((int)$_language['uid'] === (int)$language) { |
|
172 | - $LanguageExists = true; |
|
173 | - break; |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - return $LanguageExists; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @return object|DataService |
|
182 | - */ |
|
183 | - protected function getDataService(): DataService |
|
184 | - { |
|
185 | - return GeneralUtility::makeInstance(DataService::class); |
|
186 | - } |
|
24 | + /** |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected $languages; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $defaultIcon; |
|
33 | + |
|
34 | + /** |
|
35 | + * Store the localized records to boost up performance. |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $localizedRecordStorage; |
|
40 | + |
|
41 | + /** |
|
42 | + * Returns available language records. |
|
43 | + * The method stores the records in the property to speed up the process as the method can be often called. |
|
44 | + * |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function getLanguages() |
|
48 | + { |
|
49 | + if ($this->languages === null) { |
|
50 | + $this->languages = $this->getDataService()->getRecords('sys_language'); |
|
51 | + } |
|
52 | + return $this->languages; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Returns a localized record according to a Content object and a language identifier. |
|
57 | + * Notice! This method does not overlay anything but simply returns the raw localized record. |
|
58 | + * |
|
59 | + * @param Content $object |
|
60 | + * @param int $language |
|
61 | + * @return Content |
|
62 | + */ |
|
63 | + public function getLocalizedContent(Content $object, $language) |
|
64 | + { |
|
65 | + |
|
66 | + // We want to cache data per Content object. Retrieve the Object hash. |
|
67 | + $objectHash = spl_object_hash($object); |
|
68 | + |
|
69 | + // Initialize the storage |
|
70 | + if (empty($this->localizedRecordStorage[$objectHash])) { |
|
71 | + $this->localizedRecordStorage[$objectHash] = []; |
|
72 | + } |
|
73 | + |
|
74 | + if (empty($this->localizedRecordStorage[$objectHash][$language])) { |
|
75 | + |
|
76 | + $localizedRecord = $this->getDataService()->getRecord( |
|
77 | + $object->getDataType(), |
|
78 | + [ |
|
79 | + Tca::table($object)->getLanguageParentField() => $object->getUid(), // e.g. l10n_parent |
|
80 | + Tca::table($object)->getLanguageField() => $language, // e.g. sys_language_uid |
|
81 | + ] |
|
82 | + ); |
|
83 | + |
|
84 | + if ($localizedRecord) { |
|
85 | + $localizedContent = GeneralUtility::makeInstance(Content::class, $object->getDataType(), $localizedRecord); |
|
86 | + $this->localizedRecordStorage[$objectHash][$language] = $localizedContent; |
|
87 | + } else { |
|
88 | + $this->localizedRecordStorage[$objectHash][$language] = []; // We want an array at least, even if empty. |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + return $this->localizedRecordStorage[$objectHash][$language]; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Tell whether the given Content object has a localization. |
|
97 | + * |
|
98 | + * @param Content $object |
|
99 | + * @param int $language |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function hasLocalization(Content $object, $language) |
|
103 | + { |
|
104 | + $localizedRecord = $this->getLocalizedContent($object, $language); |
|
105 | + return !empty($localizedRecord); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Returns a localized field according to a Content object and a language identifier. |
|
110 | + * Notice! If there is not translation, simply returns an empty string. |
|
111 | + * |
|
112 | + * @param Content $object |
|
113 | + * @param int $language |
|
114 | + * @param string $fieldName |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + public function getLocalizedFieldName(Content $object, $language, $fieldName) |
|
118 | + { |
|
119 | + $localizedRecord = $this->getLocalizedContent($object, $language); |
|
120 | + return empty($localizedRecord) ? '' : $localizedRecord[$fieldName]; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Returns the default language configured by TSConfig. |
|
125 | + * |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + public function getDefaultFlag() |
|
129 | + { |
|
130 | + |
|
131 | + if ($this->defaultIcon === null) { |
|
132 | + |
|
133 | + $defaultFlag = ''; // default value |
|
134 | + |
|
135 | + $tsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig(0, 'mod.SHARED'); |
|
136 | + |
|
137 | + // Fallback non sprite-configuration |
|
138 | + if (($pos = strrpos($tsConfig['properties']['defaultLanguageFlag'], '.')) !== false) { |
|
139 | + $defaultFlag = substr($tsConfig['properties']['defaultLanguageFlag'], 0, $pos); |
|
140 | + } |
|
141 | + |
|
142 | + $this->defaultIcon = $defaultFlag; |
|
143 | + } |
|
144 | + |
|
145 | + return $this->defaultIcon; |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Returns whether the system includes language records. |
|
150 | + * |
|
151 | + * @return bool |
|
152 | + */ |
|
153 | + public function hasLanguages() |
|
154 | + { |
|
155 | + $languages = $this->getLanguages(); |
|
156 | + return !empty($languages); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Tell whether the given language exists. |
|
161 | + * |
|
162 | + * @param int $language |
|
163 | + * @return bool |
|
164 | + */ |
|
165 | + public function languageExists($language) |
|
166 | + { |
|
167 | + $languages = $this->getLanguages(); |
|
168 | + |
|
169 | + $LanguageExists = false; |
|
170 | + foreach ($languages as $_language) { |
|
171 | + if ((int)$_language['uid'] === (int)$language) { |
|
172 | + $LanguageExists = true; |
|
173 | + break; |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + return $LanguageExists; |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @return object|DataService |
|
182 | + */ |
|
183 | + protected function getDataService(): DataService |
|
184 | + { |
|
185 | + return GeneralUtility::makeInstance(DataService::class); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | } |
@@ -19,47 +19,47 @@ |
||
19 | 19 | class DeleteButton extends AbstractComponentView |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Renders a "delete" button to be placed in the grid. |
|
24 | - * |
|
25 | - * @param Content $object |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function render(Content $object = null) |
|
29 | - { |
|
30 | - $labelField = Tca::table($object->getDataType())->getLabelField(); |
|
31 | - $label = $object[$labelField] ? $object[$labelField] : $object->getUid(); |
|
22 | + /** |
|
23 | + * Renders a "delete" button to be placed in the grid. |
|
24 | + * |
|
25 | + * @param Content $object |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function render(Content $object = null) |
|
29 | + { |
|
30 | + $labelField = Tca::table($object->getDataType())->getLabelField(); |
|
31 | + $label = $object[$labelField] ? $object[$labelField] : $object->getUid(); |
|
32 | 32 | |
33 | - return $this->makeLinkButton() |
|
34 | - ->setHref($this->getDeleteUri($object)) |
|
35 | - ->setDataAttributes([ |
|
36 | - 'uid' => $object->getUid(), |
|
37 | - 'toggle' => 'tooltip', |
|
38 | - 'label' => $label, |
|
39 | - ]) |
|
40 | - ->setClasses('btn-delete') |
|
41 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:delete')) |
|
42 | - ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
43 | - ->render(); |
|
44 | - } |
|
33 | + return $this->makeLinkButton() |
|
34 | + ->setHref($this->getDeleteUri($object)) |
|
35 | + ->setDataAttributes([ |
|
36 | + 'uid' => $object->getUid(), |
|
37 | + 'toggle' => 'tooltip', |
|
38 | + 'label' => $label, |
|
39 | + ]) |
|
40 | + ->setClasses('btn-delete') |
|
41 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:delete')) |
|
42 | + ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
43 | + ->render(); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param Content $object |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - protected function getDeleteUri(Content $object) |
|
51 | - { |
|
52 | - $additionalParameters = array( |
|
53 | - $this->getModuleLoader()->getParameterPrefix() => array( |
|
54 | - 'controller' => 'Content', |
|
55 | - 'action' => 'delete', |
|
56 | - 'format' => 'json', |
|
57 | - 'matches' => array( |
|
58 | - 'uid' => $object->getUid(), |
|
59 | - ), |
|
60 | - ), |
|
61 | - ); |
|
62 | - return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
63 | - } |
|
46 | + /** |
|
47 | + * @param Content $object |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + protected function getDeleteUri(Content $object) |
|
51 | + { |
|
52 | + $additionalParameters = array( |
|
53 | + $this->getModuleLoader()->getParameterPrefix() => array( |
|
54 | + 'controller' => 'Content', |
|
55 | + 'action' => 'delete', |
|
56 | + 'format' => 'json', |
|
57 | + 'matches' => array( |
|
58 | + 'uid' => $object->getUid(), |
|
59 | + ), |
|
60 | + ), |
|
61 | + ); |
|
62 | + return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -18,52 +18,52 @@ |
||
18 | 18 | class ClipboardButton extends AbstractComponentView |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Renders a "clipboard" button to be placed in the doc header. |
|
23 | - * |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function render() |
|
27 | - { |
|
28 | - $button = $this->makeLinkButton() |
|
29 | - ->setHref($this->getShowClipboardUri()) |
|
30 | - ->setDataAttributes([ |
|
31 | - 'style' => $this->getClipboardService()->hasItems() ? '' : 'display: none;', |
|
32 | - ]) |
|
33 | - ->setClasses('btn-clipboard-copy-or-move') |
|
34 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:clipboard.copy_or_move')) |
|
35 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)) |
|
36 | - ->render(); |
|
21 | + /** |
|
22 | + * Renders a "clipboard" button to be placed in the doc header. |
|
23 | + * |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function render() |
|
27 | + { |
|
28 | + $button = $this->makeLinkButton() |
|
29 | + ->setHref($this->getShowClipboardUri()) |
|
30 | + ->setDataAttributes([ |
|
31 | + 'style' => $this->getClipboardService()->hasItems() ? '' : 'display: none;', |
|
32 | + ]) |
|
33 | + ->setClasses('btn-clipboard-copy-or-move') |
|
34 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:clipboard.copy_or_move')) |
|
35 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)) |
|
36 | + ->render(); |
|
37 | 37 | |
38 | - // Hack! No API for adding a style upon a button |
|
39 | - $button = str_replace('data-style', 'style', $button); |
|
38 | + // Hack! No API for adding a style upon a button |
|
39 | + $button = str_replace('data-style', 'style', $button); |
|
40 | 40 | |
41 | - $output = sprintf('<div style="float: left; margin-right: 3px">%s</div>', $button); |
|
42 | - return $output; |
|
43 | - } |
|
41 | + $output = sprintf('<div style="float: left; margin-right: 3px">%s</div>', $button); |
|
42 | + return $output; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - protected function getShowClipboardUri() |
|
49 | - { |
|
50 | - $additionalParameters = array( |
|
51 | - $this->getModuleLoader()->getParameterPrefix() => array( |
|
52 | - 'controller' => 'Clipboard', |
|
53 | - 'action' => 'show', |
|
54 | - ), |
|
55 | - ); |
|
56 | - return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
57 | - } |
|
45 | + /** |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + protected function getShowClipboardUri() |
|
49 | + { |
|
50 | + $additionalParameters = array( |
|
51 | + $this->getModuleLoader()->getParameterPrefix() => array( |
|
52 | + 'controller' => 'Clipboard', |
|
53 | + 'action' => 'show', |
|
54 | + ), |
|
55 | + ); |
|
56 | + return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Get the Vidi Module Loader. |
|
61 | - * |
|
62 | - * @return ClipboardService|object |
|
63 | - */ |
|
64 | - protected function getClipboardService() |
|
65 | - { |
|
66 | - return GeneralUtility::makeInstance(ClipboardService::class); |
|
67 | - } |
|
59 | + /** |
|
60 | + * Get the Vidi Module Loader. |
|
61 | + * |
|
62 | + * @return ClipboardService|object |
|
63 | + */ |
|
64 | + protected function getClipboardService() |
|
65 | + { |
|
66 | + return GeneralUtility::makeInstance(ClipboardService::class); |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |