@@ -67,7 +67,7 @@ |
||
67 | 67 | ] |
68 | 68 | ); |
69 | 69 | if (!empty($record)) { |
70 | - $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1'; |
|
70 | + $moduleName = 'Vidi'.GeneralUtility::underscoredToUpperCamelCase($dataType).'M1'; |
|
71 | 71 | $title = Tca::table($dataType)->getTitle(); |
72 | 72 | $modules[$moduleName] = $title; |
73 | 73 | } |
@@ -21,106 +21,106 @@ |
||
21 | 21 | class ModuleService implements SingletonInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected $storage = []; |
|
24 | + /** |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected $storage = []; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Returns a class instance |
|
31 | - * |
|
32 | - * @return \Fab\Vidi\Module\ModuleService|object |
|
33 | - */ |
|
34 | - static public function getInstance() |
|
35 | - { |
|
36 | - return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleService::class); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Returns a class instance |
|
31 | + * |
|
32 | + * @return \Fab\Vidi\Module\ModuleService|object |
|
33 | + */ |
|
34 | + static public function getInstance() |
|
35 | + { |
|
36 | + return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleService::class); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Fetch all modules to be displayed on the current pid. |
|
41 | - * |
|
42 | - * @return array |
|
43 | - */ |
|
44 | - public function getModulesForCurrentPid(): array |
|
45 | - { |
|
46 | - $pid = $this->getModuleLoader()->getCurrentPid(); |
|
47 | - return $this->getModulesForPid($pid); |
|
48 | - } |
|
39 | + /** |
|
40 | + * Fetch all modules to be displayed on the current pid. |
|
41 | + * |
|
42 | + * @return array |
|
43 | + */ |
|
44 | + public function getModulesForCurrentPid(): array |
|
45 | + { |
|
46 | + $pid = $this->getModuleLoader()->getCurrentPid(); |
|
47 | + return $this->getModulesForPid($pid); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Fetch all modules displayed given a pid. |
|
52 | - * |
|
53 | - * @param int $pid |
|
54 | - * @return array |
|
55 | - */ |
|
56 | - public function getModulesForPid($pid = null): array |
|
57 | - { |
|
58 | - if (!isset($this->storage[$pid])) { |
|
50 | + /** |
|
51 | + * Fetch all modules displayed given a pid. |
|
52 | + * |
|
53 | + * @param int $pid |
|
54 | + * @return array |
|
55 | + */ |
|
56 | + public function getModulesForPid($pid = null): array |
|
57 | + { |
|
58 | + if (!isset($this->storage[$pid])) { |
|
59 | 59 | |
60 | - $modules = []; |
|
61 | - foreach ($GLOBALS['TCA'] as $dataType => $configuration) { |
|
62 | - if (Tca::table($dataType)->isNotHidden()) { |
|
63 | - $record = $this->getDataService()->getRecord( |
|
64 | - $dataType, |
|
65 | - [ |
|
66 | - 'pid' => $pid |
|
67 | - ] |
|
68 | - ); |
|
69 | - if (!empty($record)) { |
|
70 | - $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1'; |
|
71 | - $title = Tca::table($dataType)->getTitle(); |
|
72 | - $modules[$moduleName] = $title; |
|
73 | - } |
|
74 | - } |
|
75 | - } |
|
76 | - $this->storage[$pid] = $modules; |
|
77 | - } |
|
78 | - return $this->storage[$pid]; |
|
79 | - } |
|
60 | + $modules = []; |
|
61 | + foreach ($GLOBALS['TCA'] as $dataType => $configuration) { |
|
62 | + if (Tca::table($dataType)->isNotHidden()) { |
|
63 | + $record = $this->getDataService()->getRecord( |
|
64 | + $dataType, |
|
65 | + [ |
|
66 | + 'pid' => $pid |
|
67 | + ] |
|
68 | + ); |
|
69 | + if (!empty($record)) { |
|
70 | + $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1'; |
|
71 | + $title = Tca::table($dataType)->getTitle(); |
|
72 | + $modules[$moduleName] = $title; |
|
73 | + } |
|
74 | + } |
|
75 | + } |
|
76 | + $this->storage[$pid] = $modules; |
|
77 | + } |
|
78 | + return $this->storage[$pid]; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Fetch the first module for the current pid. |
|
83 | - * |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function getFirstModuleForCurrentPid(): string |
|
87 | - { |
|
88 | - $pid = $this->getModuleLoader()->getCurrentPid(); |
|
89 | - return $this->getFirstModuleForPid($pid); |
|
90 | - } |
|
81 | + /** |
|
82 | + * Fetch the first module for the current pid. |
|
83 | + * |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function getFirstModuleForCurrentPid(): string |
|
87 | + { |
|
88 | + $pid = $this->getModuleLoader()->getCurrentPid(); |
|
89 | + return $this->getFirstModuleForPid($pid); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Fetch the module given a pid. |
|
94 | - * |
|
95 | - * @param int $pid |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function getFirstModuleForPid($pid): string |
|
99 | - { |
|
100 | - $firstModule = ''; |
|
101 | - $modules = $this->getModulesForPid($pid); |
|
102 | - if (!empty($modules)) { |
|
103 | - $firstModule = key($modules); |
|
104 | - } |
|
92 | + /** |
|
93 | + * Fetch the module given a pid. |
|
94 | + * |
|
95 | + * @param int $pid |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function getFirstModuleForPid($pid): string |
|
99 | + { |
|
100 | + $firstModule = ''; |
|
101 | + $modules = $this->getModulesForPid($pid); |
|
102 | + if (!empty($modules)) { |
|
103 | + $firstModule = key($modules); |
|
104 | + } |
|
105 | 105 | |
106 | - return $firstModule; |
|
107 | - } |
|
106 | + return $firstModule; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return object|DataService |
|
111 | - */ |
|
112 | - protected function getDataService(): DataService |
|
113 | - { |
|
114 | - return GeneralUtility::makeInstance(DataService::class); |
|
115 | - } |
|
109 | + /** |
|
110 | + * @return object|DataService |
|
111 | + */ |
|
112 | + protected function getDataService(): DataService |
|
113 | + { |
|
114 | + return GeneralUtility::makeInstance(DataService::class); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Get the Vidi Module Loader. |
|
119 | - * |
|
120 | - * @return ModuleLoader|object |
|
121 | - */ |
|
122 | - protected function getModuleLoader() |
|
123 | - { |
|
124 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
125 | - } |
|
117 | + /** |
|
118 | + * Get the Vidi Module Loader. |
|
119 | + * |
|
120 | + * @return ModuleLoader|object |
|
121 | + */ |
|
122 | + protected function getModuleLoader() |
|
123 | + { |
|
124 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
125 | + } |
|
126 | 126 | } |
@@ -23,163 +23,163 @@ |
||
23 | 23 | class PageFacet implements FacetInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $name; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $label; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - protected $dataType; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var bool |
|
43 | - */ |
|
44 | - protected $canModifyMatcher = false; |
|
45 | - |
|
46 | - /** |
|
47 | - * Constructor of a Generic Facet in Vidi. |
|
48 | - * |
|
49 | - * @param string $name |
|
50 | - * @param string $label |
|
51 | - */ |
|
52 | - public function __construct($name, $label = '') |
|
53 | - { |
|
54 | - $this->name = 'pid'; |
|
55 | - $this->label = $label; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function getName(): string |
|
62 | - { |
|
63 | - return $this->name; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function getLabel(): string |
|
70 | - { |
|
71 | - return $this->label; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @return array |
|
76 | - */ |
|
77 | - public function getSuggestions(): array |
|
78 | - { |
|
79 | - $values = []; |
|
80 | - foreach ($this->getStoragePages() as $page) { |
|
81 | - $values[] = [ |
|
82 | - $page['uid'] => sprintf('%s (%s)', $page['title'], $page['uid']) |
|
83 | - ]; |
|
84 | - } |
|
85 | - return $values; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - protected function getStoragePages(): array |
|
92 | - { |
|
93 | - /** @var QueryBuilder $query */ |
|
94 | - $query = $this->getQueryBuilder('pages'); |
|
95 | - $query->getRestrictions()->removeAll(); |
|
96 | - return $query->select('*') |
|
97 | - ->from('pages') |
|
98 | - ->where( |
|
99 | - sprintf( |
|
100 | - 'uid IN (SELECT DISTINCT(pid) FROM %s WHERE 1=1 %s)', |
|
101 | - $this->getModuleLoader()->getDataType(), |
|
102 | - BackendUtility::deleteClause($this->getModuleLoader()->getDataType() |
|
103 | - ) |
|
104 | - ), |
|
105 | - BackendUtility::deleteClause('pages', '') |
|
106 | - ) |
|
107 | - ->execute() |
|
108 | - ->fetchAll(); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @param string $tableName |
|
113 | - * @return object|QueryBuilder |
|
114 | - */ |
|
115 | - protected function getQueryBuilder($tableName): QueryBuilder |
|
116 | - { |
|
117 | - /** @var ConnectionPool $connectionPool */ |
|
118 | - $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
119 | - return $connectionPool->getQueryBuilderForTable($tableName); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return LanguageService |
|
124 | - */ |
|
125 | - protected function getLanguageService(): LanguageService |
|
126 | - { |
|
127 | - |
|
128 | - /** @var LanguageService $langService */ |
|
129 | - $langService = $GLOBALS['LANG']; |
|
130 | - if (!$langService) { |
|
131 | - $langService = GeneralUtility::makeInstance(LanguageService::class); |
|
132 | - $langService->init('en'); |
|
133 | - } |
|
134 | - |
|
135 | - return $langService; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @return bool |
|
140 | - */ |
|
141 | - public function hasSuggestions(): bool |
|
142 | - { |
|
143 | - return true; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @param string $dataType |
|
148 | - * @return $this |
|
149 | - */ |
|
150 | - public function setDataType($dataType): self |
|
151 | - { |
|
152 | - $this->dataType = $dataType; |
|
153 | - return $this; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @return bool |
|
158 | - */ |
|
159 | - public function canModifyMatcher(): bool |
|
160 | - { |
|
161 | - return $this->canModifyMatcher; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @param Matcher $matcher |
|
166 | - * @param $value |
|
167 | - * @return Matcher |
|
168 | - */ |
|
169 | - public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
170 | - { |
|
171 | - return $matcher; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Get the Vidi Module Loader. |
|
176 | - * |
|
177 | - * @return ModuleLoader|object |
|
178 | - * @throws \InvalidArgumentException |
|
179 | - */ |
|
180 | - protected function getModuleLoader() |
|
181 | - { |
|
182 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
183 | - } |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $name; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $label; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + protected $dataType; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var bool |
|
43 | + */ |
|
44 | + protected $canModifyMatcher = false; |
|
45 | + |
|
46 | + /** |
|
47 | + * Constructor of a Generic Facet in Vidi. |
|
48 | + * |
|
49 | + * @param string $name |
|
50 | + * @param string $label |
|
51 | + */ |
|
52 | + public function __construct($name, $label = '') |
|
53 | + { |
|
54 | + $this->name = 'pid'; |
|
55 | + $this->label = $label; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function getName(): string |
|
62 | + { |
|
63 | + return $this->name; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function getLabel(): string |
|
70 | + { |
|
71 | + return $this->label; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @return array |
|
76 | + */ |
|
77 | + public function getSuggestions(): array |
|
78 | + { |
|
79 | + $values = []; |
|
80 | + foreach ($this->getStoragePages() as $page) { |
|
81 | + $values[] = [ |
|
82 | + $page['uid'] => sprintf('%s (%s)', $page['title'], $page['uid']) |
|
83 | + ]; |
|
84 | + } |
|
85 | + return $values; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + protected function getStoragePages(): array |
|
92 | + { |
|
93 | + /** @var QueryBuilder $query */ |
|
94 | + $query = $this->getQueryBuilder('pages'); |
|
95 | + $query->getRestrictions()->removeAll(); |
|
96 | + return $query->select('*') |
|
97 | + ->from('pages') |
|
98 | + ->where( |
|
99 | + sprintf( |
|
100 | + 'uid IN (SELECT DISTINCT(pid) FROM %s WHERE 1=1 %s)', |
|
101 | + $this->getModuleLoader()->getDataType(), |
|
102 | + BackendUtility::deleteClause($this->getModuleLoader()->getDataType() |
|
103 | + ) |
|
104 | + ), |
|
105 | + BackendUtility::deleteClause('pages', '') |
|
106 | + ) |
|
107 | + ->execute() |
|
108 | + ->fetchAll(); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @param string $tableName |
|
113 | + * @return object|QueryBuilder |
|
114 | + */ |
|
115 | + protected function getQueryBuilder($tableName): QueryBuilder |
|
116 | + { |
|
117 | + /** @var ConnectionPool $connectionPool */ |
|
118 | + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
119 | + return $connectionPool->getQueryBuilderForTable($tableName); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @return LanguageService |
|
124 | + */ |
|
125 | + protected function getLanguageService(): LanguageService |
|
126 | + { |
|
127 | + |
|
128 | + /** @var LanguageService $langService */ |
|
129 | + $langService = $GLOBALS['LANG']; |
|
130 | + if (!$langService) { |
|
131 | + $langService = GeneralUtility::makeInstance(LanguageService::class); |
|
132 | + $langService->init('en'); |
|
133 | + } |
|
134 | + |
|
135 | + return $langService; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @return bool |
|
140 | + */ |
|
141 | + public function hasSuggestions(): bool |
|
142 | + { |
|
143 | + return true; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @param string $dataType |
|
148 | + * @return $this |
|
149 | + */ |
|
150 | + public function setDataType($dataType): self |
|
151 | + { |
|
152 | + $this->dataType = $dataType; |
|
153 | + return $this; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * @return bool |
|
158 | + */ |
|
159 | + public function canModifyMatcher(): bool |
|
160 | + { |
|
161 | + return $this->canModifyMatcher; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @param Matcher $matcher |
|
166 | + * @param $value |
|
167 | + * @return Matcher |
|
168 | + */ |
|
169 | + public function modifyMatcher(Matcher $matcher, $value): Matcher |
|
170 | + { |
|
171 | + return $matcher; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Get the Vidi Module Loader. |
|
176 | + * |
|
177 | + * @return ModuleLoader|object |
|
178 | + * @throws \InvalidArgumentException |
|
179 | + */ |
|
180 | + protected function getModuleLoader() |
|
181 | + { |
|
182 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
183 | + } |
|
184 | 184 | |
185 | 185 | } |
@@ -18,156 +18,156 @@ |
||
18 | 18 | class DataService implements SingletonInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @param string $tableName |
|
23 | - * @param array $demand |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function getRecord(string $tableName, array $demand = []): array |
|
27 | - { |
|
28 | - /** @var QueryBuilder $queryBuilder */ |
|
29 | - $queryBuilder = $this->getQueryBuilder($tableName); |
|
30 | - $queryBuilder |
|
31 | - ->select('*') |
|
32 | - ->from($tableName); |
|
33 | - |
|
34 | - $this->addDemandConstraints($demand, $queryBuilder); |
|
35 | - $record = $queryBuilder->execute()->fetch(); |
|
36 | - return is_array($record) |
|
37 | - ? $record |
|
38 | - : []; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $tableName |
|
43 | - * @param array $demand |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function getRecords(string $tableName, array $demand = []): array |
|
47 | - { |
|
48 | - /** @var QueryBuilder $queryBuilder */ |
|
49 | - $queryBuilder = $this->getQueryBuilder($tableName); |
|
50 | - $queryBuilder |
|
51 | - ->select('*') |
|
52 | - ->from($tableName); |
|
53 | - |
|
54 | - $this->addDemandConstraints($demand, $queryBuilder); |
|
55 | - |
|
56 | - return $queryBuilder->execute()->fetchAll(); |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @param string $tableName |
|
61 | - * @param array $demand |
|
62 | - * @return int |
|
63 | - */ |
|
64 | - public function count(string $tableName, array $demand = []): int |
|
65 | - { |
|
66 | - /** @var QueryBuilder $queryBuilder */ |
|
67 | - $queryBuilder = $this->getQueryBuilder($tableName); |
|
68 | - $queryBuilder |
|
69 | - ->count('*') |
|
70 | - ->from($tableName); |
|
71 | - |
|
72 | - $this->addDemandConstraints($demand, $queryBuilder); |
|
73 | - |
|
74 | - return (int)$queryBuilder->execute()->fetchColumn(0); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param string $tableName |
|
79 | - * @param array $values |
|
80 | - * @return int |
|
81 | - */ |
|
82 | - public function insert(string $tableName, array $values): int |
|
83 | - { |
|
84 | - $connection = $this->getConnection($tableName); |
|
85 | - $connection->insert( |
|
86 | - $tableName, |
|
87 | - $values |
|
88 | - ); |
|
89 | - return (int)$connection->lastInsertId(); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @param string $tableName |
|
94 | - * @param array $values |
|
95 | - * @param array $identifiers |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public function update(string $tableName, array $values, array $identifiers): void |
|
99 | - { |
|
100 | - $connection = $this->getConnection($tableName); |
|
101 | - $connection->update( |
|
102 | - $tableName, |
|
103 | - $values, |
|
104 | - $identifiers |
|
105 | - ); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $tableName |
|
110 | - * @param array $identifiers |
|
111 | - */ |
|
112 | - public function delete(string $tableName, array $identifiers): void |
|
113 | - { |
|
114 | - $connection = $this->getConnection($tableName); |
|
115 | - $connection->delete( |
|
116 | - $tableName, |
|
117 | - $identifiers |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @param array $demand |
|
123 | - * @param QueryBuilder $queryBuilder |
|
124 | - * @return void |
|
125 | - */ |
|
126 | - protected function addDemandConstraints(array $demand, $queryBuilder): void |
|
127 | - { |
|
128 | - $expressions = []; |
|
129 | - foreach ($demand as $fieldName => $value) { |
|
130 | - if (is_numeric($value)) { |
|
131 | - $expressions[] = $queryBuilder->expr()->eq( |
|
132 | - $fieldName, |
|
133 | - $value |
|
134 | - ); |
|
135 | - } elseif (is_string($value)) { |
|
136 | - $expressions[] = $queryBuilder->expr()->eq( |
|
137 | - $fieldName, |
|
138 | - $queryBuilder->expr()->literal($value) |
|
139 | - ); |
|
140 | - } elseif (is_array($value)) { |
|
141 | - $expressions[] = $queryBuilder->expr()->in( |
|
142 | - $fieldName, |
|
143 | - $value |
|
144 | - ); |
|
145 | - } |
|
146 | - } |
|
147 | - foreach ($expressions as $expression) { |
|
148 | - $queryBuilder->andWhere($expression); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @param string $tableName |
|
154 | - * @return object|Connection |
|
155 | - */ |
|
156 | - protected function getConnection($tableName): Connection |
|
157 | - { |
|
158 | - /** @var ConnectionPool $connectionPool */ |
|
159 | - $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
160 | - return $connectionPool->getConnectionForTable($tableName); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @param string $tableName |
|
165 | - * @return object|QueryBuilder |
|
166 | - */ |
|
167 | - protected function getQueryBuilder($tableName): QueryBuilder |
|
168 | - { |
|
169 | - /** @var ConnectionPool $connectionPool */ |
|
170 | - $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
171 | - return $connectionPool->getQueryBuilderForTable($tableName); |
|
172 | - } |
|
21 | + /** |
|
22 | + * @param string $tableName |
|
23 | + * @param array $demand |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function getRecord(string $tableName, array $demand = []): array |
|
27 | + { |
|
28 | + /** @var QueryBuilder $queryBuilder */ |
|
29 | + $queryBuilder = $this->getQueryBuilder($tableName); |
|
30 | + $queryBuilder |
|
31 | + ->select('*') |
|
32 | + ->from($tableName); |
|
33 | + |
|
34 | + $this->addDemandConstraints($demand, $queryBuilder); |
|
35 | + $record = $queryBuilder->execute()->fetch(); |
|
36 | + return is_array($record) |
|
37 | + ? $record |
|
38 | + : []; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $tableName |
|
43 | + * @param array $demand |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function getRecords(string $tableName, array $demand = []): array |
|
47 | + { |
|
48 | + /** @var QueryBuilder $queryBuilder */ |
|
49 | + $queryBuilder = $this->getQueryBuilder($tableName); |
|
50 | + $queryBuilder |
|
51 | + ->select('*') |
|
52 | + ->from($tableName); |
|
53 | + |
|
54 | + $this->addDemandConstraints($demand, $queryBuilder); |
|
55 | + |
|
56 | + return $queryBuilder->execute()->fetchAll(); |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @param string $tableName |
|
61 | + * @param array $demand |
|
62 | + * @return int |
|
63 | + */ |
|
64 | + public function count(string $tableName, array $demand = []): int |
|
65 | + { |
|
66 | + /** @var QueryBuilder $queryBuilder */ |
|
67 | + $queryBuilder = $this->getQueryBuilder($tableName); |
|
68 | + $queryBuilder |
|
69 | + ->count('*') |
|
70 | + ->from($tableName); |
|
71 | + |
|
72 | + $this->addDemandConstraints($demand, $queryBuilder); |
|
73 | + |
|
74 | + return (int)$queryBuilder->execute()->fetchColumn(0); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * @param string $tableName |
|
79 | + * @param array $values |
|
80 | + * @return int |
|
81 | + */ |
|
82 | + public function insert(string $tableName, array $values): int |
|
83 | + { |
|
84 | + $connection = $this->getConnection($tableName); |
|
85 | + $connection->insert( |
|
86 | + $tableName, |
|
87 | + $values |
|
88 | + ); |
|
89 | + return (int)$connection->lastInsertId(); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @param string $tableName |
|
94 | + * @param array $values |
|
95 | + * @param array $identifiers |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public function update(string $tableName, array $values, array $identifiers): void |
|
99 | + { |
|
100 | + $connection = $this->getConnection($tableName); |
|
101 | + $connection->update( |
|
102 | + $tableName, |
|
103 | + $values, |
|
104 | + $identifiers |
|
105 | + ); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $tableName |
|
110 | + * @param array $identifiers |
|
111 | + */ |
|
112 | + public function delete(string $tableName, array $identifiers): void |
|
113 | + { |
|
114 | + $connection = $this->getConnection($tableName); |
|
115 | + $connection->delete( |
|
116 | + $tableName, |
|
117 | + $identifiers |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @param array $demand |
|
123 | + * @param QueryBuilder $queryBuilder |
|
124 | + * @return void |
|
125 | + */ |
|
126 | + protected function addDemandConstraints(array $demand, $queryBuilder): void |
|
127 | + { |
|
128 | + $expressions = []; |
|
129 | + foreach ($demand as $fieldName => $value) { |
|
130 | + if (is_numeric($value)) { |
|
131 | + $expressions[] = $queryBuilder->expr()->eq( |
|
132 | + $fieldName, |
|
133 | + $value |
|
134 | + ); |
|
135 | + } elseif (is_string($value)) { |
|
136 | + $expressions[] = $queryBuilder->expr()->eq( |
|
137 | + $fieldName, |
|
138 | + $queryBuilder->expr()->literal($value) |
|
139 | + ); |
|
140 | + } elseif (is_array($value)) { |
|
141 | + $expressions[] = $queryBuilder->expr()->in( |
|
142 | + $fieldName, |
|
143 | + $value |
|
144 | + ); |
|
145 | + } |
|
146 | + } |
|
147 | + foreach ($expressions as $expression) { |
|
148 | + $queryBuilder->andWhere($expression); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @param string $tableName |
|
154 | + * @return object|Connection |
|
155 | + */ |
|
156 | + protected function getConnection($tableName): Connection |
|
157 | + { |
|
158 | + /** @var ConnectionPool $connectionPool */ |
|
159 | + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
160 | + return $connectionPool->getConnectionForTable($tableName); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @param string $tableName |
|
165 | + * @return object|QueryBuilder |
|
166 | + */ |
|
167 | + protected function getQueryBuilder($tableName): QueryBuilder |
|
168 | + { |
|
169 | + /** @var ConnectionPool $connectionPool */ |
|
170 | + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
171 | + return $connectionPool->getQueryBuilderForTable($tableName); |
|
172 | + } |
|
173 | 173 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | #public function getLabelReturnNameAsValue() { |
52 | 52 | # $GLOBALS['LANG'] = $this->getMock('TYPO3\CMS\Core\Localization\LanguageService', [], [], '', false); |
53 | 53 | # $GLOBALS['LANG']->expects($this->once())->method('sL')->will($this->returnValue('Name')); |
54 | - # |
|
54 | + # |
|
55 | 55 | # $this->assertEquals('Name', $this->fixture->getLabel('name')); |
56 | 56 | #} |
57 | 57 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $content = str_replace('{module_name}', $label, $this->template); |
54 | 54 | GeneralUtility::writeFileToTypo3tempDir($languageFile, $content); |
55 | 55 | |
56 | - return 'LLL:' . $languageFile; |
|
56 | + return 'LLL:'.$languageFile; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function getLanguageFile($dataType) |
64 | 64 | { |
65 | - return $this->getLanguageDirectory() . '/' . $dataType . '.xlf'; |
|
65 | + return $this->getLanguageDirectory().'/'.$dataType.'.xlf'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | protected function getLanguageDirectory() |
72 | 72 | { |
73 | 73 | // Create language file dynamically |
74 | - $languageDirectory = Environment::getPublicPath() . '/typo3temp/vidi'; |
|
74 | + $languageDirectory = Environment::getPublicPath().'/typo3temp/vidi'; |
|
75 | 75 | if (!is_dir($languageDirectory)) { |
76 | 76 | GeneralUtility::mkdir($languageDirectory); |
77 | 77 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | class LanguageFileGenerator implements SingletonInterface |
20 | 20 | { |
21 | 21 | |
22 | - protected $template = '<?xml version="1.0" encoding="UTF-8"?> |
|
22 | + protected $template = '<?xml version="1.0" encoding="UTF-8"?> |
|
23 | 23 | <xliff version="1.0"> |
24 | 24 | <file source-language="en" datatype="plaintext" original="messages" date="" product-name="local lang module"> |
25 | 25 | <header/> |
@@ -37,58 +37,58 @@ discard block |
||
37 | 37 | </file> |
38 | 38 | </xliff>'; |
39 | 39 | |
40 | - /** |
|
41 | - * @param string $dataType |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function generate($dataType) |
|
45 | - { |
|
46 | - $label = $dataType; |
|
47 | - if (!empty($GLOBALS['TCA'][$dataType]['ctrl']['title'])) { |
|
48 | - $label = $this->getLanguageService()->sL($GLOBALS['TCA'][$dataType]['ctrl']['title']); |
|
49 | - } |
|
40 | + /** |
|
41 | + * @param string $dataType |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function generate($dataType) |
|
45 | + { |
|
46 | + $label = $dataType; |
|
47 | + if (!empty($GLOBALS['TCA'][$dataType]['ctrl']['title'])) { |
|
48 | + $label = $this->getLanguageService()->sL($GLOBALS['TCA'][$dataType]['ctrl']['title']); |
|
49 | + } |
|
50 | 50 | |
51 | - // Generate language file. |
|
52 | - $languageFile = $this->getLanguageFile($dataType); |
|
53 | - $content = str_replace('{module_name}', $label, $this->template); |
|
54 | - GeneralUtility::writeFileToTypo3tempDir($languageFile, $content); |
|
51 | + // Generate language file. |
|
52 | + $languageFile = $this->getLanguageFile($dataType); |
|
53 | + $content = str_replace('{module_name}', $label, $this->template); |
|
54 | + GeneralUtility::writeFileToTypo3tempDir($languageFile, $content); |
|
55 | 55 | |
56 | - return 'LLL:' . $languageFile; |
|
57 | - } |
|
56 | + return 'LLL:' . $languageFile; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param $dataType |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - protected function getLanguageFile($dataType) |
|
64 | - { |
|
65 | - return $this->getLanguageDirectory() . '/' . $dataType . '.xlf'; |
|
66 | - } |
|
59 | + /** |
|
60 | + * @param $dataType |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + protected function getLanguageFile($dataType) |
|
64 | + { |
|
65 | + return $this->getLanguageDirectory() . '/' . $dataType . '.xlf'; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - protected function getLanguageDirectory() |
|
72 | - { |
|
73 | - // Create language file dynamically |
|
74 | - $languageDirectory = Environment::getPublicPath() . '/typo3temp/vidi'; |
|
75 | - if (!is_dir($languageDirectory)) { |
|
76 | - GeneralUtility::mkdir($languageDirectory); |
|
77 | - } |
|
78 | - return $languageDirectory; |
|
79 | - } |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + protected function getLanguageDirectory() |
|
72 | + { |
|
73 | + // Create language file dynamically |
|
74 | + $languageDirectory = Environment::getPublicPath() . '/typo3temp/vidi'; |
|
75 | + if (!is_dir($languageDirectory)) { |
|
76 | + GeneralUtility::mkdir($languageDirectory); |
|
77 | + } |
|
78 | + return $languageDirectory; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return LanguageService |
|
83 | - */ |
|
84 | - protected function getLanguageService() |
|
85 | - { |
|
86 | - $locale = $GLOBALS['BE_USER']->uc['lang'] ?? ''; |
|
87 | - if ($locale === '') { |
|
88 | - $locale = 'en'; |
|
89 | - } |
|
90 | - $languageServiceFactory = GeneralUtility::makeInstance(LanguageServiceFactory::class); |
|
91 | - return $languageServiceFactory->create($locale); |
|
92 | - } |
|
81 | + /** |
|
82 | + * @return LanguageService |
|
83 | + */ |
|
84 | + protected function getLanguageService() |
|
85 | + { |
|
86 | + $locale = $GLOBALS['BE_USER']->uc['lang'] ?? ''; |
|
87 | + if ($locale === '') { |
|
88 | + $locale = 'en'; |
|
89 | + } |
|
90 | + $languageServiceFactory = GeneralUtility::makeInstance(LanguageServiceFactory::class); |
|
91 | + return $languageServiceFactory->create($locale); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | } |
@@ -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,125 +22,125 @@ |
||
22 | 22 | class ModulePreferencesTool extends AbstractTool |
23 | 23 | { |
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 | - |
|
61 | - |
|
62 | - if (isset($arguments['save'])) { |
|
63 | - |
|
64 | - // Revert visible <-> excluded |
|
65 | - $excludedFields = array_diff( |
|
66 | - Tca::grid()->getAllFieldNames(), |
|
67 | - $arguments['excluded_fields'], |
|
68 | - $this->getExcludedFieldsFromTca() |
|
69 | - ); |
|
70 | - $arguments['excluded_fields'] = $excludedFields; |
|
71 | - $this->getModulePreferences()->save($arguments); |
|
72 | - } |
|
73 | - |
|
74 | - $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ModulePreferences/WorkResult.html'; |
|
75 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
76 | - |
|
77 | - $view->assign('title', Tca::table($this->getModuleLoader()->getDataType())->getTitle()); |
|
78 | - |
|
79 | - // Fetch the menu of visible items. |
|
80 | - $menuVisibleItems = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS); |
|
81 | - $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS, $menuVisibleItems); |
|
82 | - |
|
83 | - // Fetch the default number of menu visible items. |
|
84 | - $menuDefaultVisible = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT); |
|
85 | - $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT, $menuDefaultVisible); |
|
86 | - |
|
87 | - // Get the visible columns |
|
88 | - $view->assign('columns', Tca::grid()->getAllFieldNames()); |
|
89 | - |
|
90 | - return $view->render(); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - protected function getExcludedFieldsFromTca() |
|
97 | - { |
|
98 | - $tca = Tca::grid()->getTca(); |
|
99 | - $excludedFields = []; |
|
100 | - if (!empty($tca['excluded_fields'])) { |
|
101 | - $excludedFields = GeneralUtility::trimExplode(',', $tca['excluded_fields'], true); |
|
102 | - } elseif (!empty($tca['export']['excluded_fields'])) { // only for export for legacy reason. |
|
103 | - $excludedFields = GeneralUtility::trimExplode(',', $tca['export']['excluded_fields'], true); |
|
104 | - } |
|
105 | - return $excludedFields; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Tell whether the tools should be displayed according to the context. |
|
110 | - * |
|
111 | - * @return bool |
|
112 | - */ |
|
113 | - public function isShown() |
|
114 | - { |
|
115 | - return $this->getBackendUser()->isAdmin(); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Get the Vidi Module Loader. |
|
120 | - * |
|
121 | - * @return ModuleLoader|object |
|
122 | - */ |
|
123 | - protected function getModuleLoader() |
|
124 | - { |
|
125 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return ModulePreferences|object |
|
130 | - */ |
|
131 | - protected function getModulePreferences() |
|
132 | - { |
|
133 | - return GeneralUtility::makeInstance(ModulePreferences::class); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Get the Vidi Module Loader. |
|
138 | - * |
|
139 | - * @return GridAnalyserService|object |
|
140 | - */ |
|
141 | - protected function getGridAnalyserService() |
|
142 | - { |
|
143 | - return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
144 | - } |
|
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 | + |
|
61 | + |
|
62 | + if (isset($arguments['save'])) { |
|
63 | + |
|
64 | + // Revert visible <-> excluded |
|
65 | + $excludedFields = array_diff( |
|
66 | + Tca::grid()->getAllFieldNames(), |
|
67 | + $arguments['excluded_fields'], |
|
68 | + $this->getExcludedFieldsFromTca() |
|
69 | + ); |
|
70 | + $arguments['excluded_fields'] = $excludedFields; |
|
71 | + $this->getModulePreferences()->save($arguments); |
|
72 | + } |
|
73 | + |
|
74 | + $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/ModulePreferences/WorkResult.html'; |
|
75 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
76 | + |
|
77 | + $view->assign('title', Tca::table($this->getModuleLoader()->getDataType())->getTitle()); |
|
78 | + |
|
79 | + // Fetch the menu of visible items. |
|
80 | + $menuVisibleItems = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS); |
|
81 | + $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS, $menuVisibleItems); |
|
82 | + |
|
83 | + // Fetch the default number of menu visible items. |
|
84 | + $menuDefaultVisible = $this->getModulePreferences()->get(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT); |
|
85 | + $view->assign(ConfigurablePart::MENU_VISIBLE_ITEMS_DEFAULT, $menuDefaultVisible); |
|
86 | + |
|
87 | + // Get the visible columns |
|
88 | + $view->assign('columns', Tca::grid()->getAllFieldNames()); |
|
89 | + |
|
90 | + return $view->render(); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + protected function getExcludedFieldsFromTca() |
|
97 | + { |
|
98 | + $tca = Tca::grid()->getTca(); |
|
99 | + $excludedFields = []; |
|
100 | + if (!empty($tca['excluded_fields'])) { |
|
101 | + $excludedFields = GeneralUtility::trimExplode(',', $tca['excluded_fields'], true); |
|
102 | + } elseif (!empty($tca['export']['excluded_fields'])) { // only for export for legacy reason. |
|
103 | + $excludedFields = GeneralUtility::trimExplode(',', $tca['export']['excluded_fields'], true); |
|
104 | + } |
|
105 | + return $excludedFields; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Tell whether the tools should be displayed according to the context. |
|
110 | + * |
|
111 | + * @return bool |
|
112 | + */ |
|
113 | + public function isShown() |
|
114 | + { |
|
115 | + return $this->getBackendUser()->isAdmin(); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Get the Vidi Module Loader. |
|
120 | + * |
|
121 | + * @return ModuleLoader|object |
|
122 | + */ |
|
123 | + protected function getModuleLoader() |
|
124 | + { |
|
125 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @return ModulePreferences|object |
|
130 | + */ |
|
131 | + protected function getModulePreferences() |
|
132 | + { |
|
133 | + return GeneralUtility::makeInstance(ModulePreferences::class); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Get the Vidi Module Loader. |
|
138 | + * |
|
139 | + * @return GridAnalyserService|object |
|
140 | + */ |
|
141 | + protected function getGridAnalyserService() |
|
142 | + { |
|
143 | + return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
144 | + } |
|
145 | 145 | } |
146 | 146 |
@@ -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,88 +19,88 @@ |
||
19 | 19 | class RelationAnalyserTool extends AbstractTool |
20 | 20 | { |
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 | - { |
|
49 | + /** |
|
50 | + * Do the job |
|
51 | + * |
|
52 | + * @param array $arguments |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function work(array $arguments = array()): string |
|
56 | + { |
|
57 | 57 | |
58 | - $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/RelationAnalyser/WorkResult.html'; |
|
59 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
58 | + $templateNameAndPath = 'EXT:vidi/Resources/Private/Standalone/Tool/RelationAnalyser/WorkResult.html'; |
|
59 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
60 | 60 | |
61 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
62 | - $analyse = $this->getGridAnalyserService()->checkRelationForTable($dataType); |
|
61 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
62 | + $analyse = $this->getGridAnalyserService()->checkRelationForTable($dataType); |
|
63 | 63 | |
64 | - if (empty($analyse)) { |
|
65 | - $result = 'No relation involved in this Grid.'; |
|
66 | - } else { |
|
67 | - $result = implode("\n", $analyse); |
|
68 | - } |
|
64 | + if (empty($analyse)) { |
|
65 | + $result = 'No relation involved in this Grid.'; |
|
66 | + } else { |
|
67 | + $result = implode("\n", $analyse); |
|
68 | + } |
|
69 | 69 | |
70 | - $view->assign('result', $result); |
|
71 | - $view->assign('dataType', $dataType); |
|
70 | + $view->assign('result', $result); |
|
71 | + $view->assign('dataType', $dataType); |
|
72 | 72 | |
73 | - return $view->render(); |
|
74 | - } |
|
73 | + return $view->render(); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Tell whether the tools should be displayed according to the context. |
|
78 | - * |
|
79 | - * @return bool |
|
80 | - */ |
|
81 | - public function isShown(): bool |
|
82 | - { |
|
83 | - return $this->getBackendUser()->isAdmin(); |
|
84 | - } |
|
76 | + /** |
|
77 | + * Tell whether the tools should be displayed according to the context. |
|
78 | + * |
|
79 | + * @return bool |
|
80 | + */ |
|
81 | + public function isShown(): bool |
|
82 | + { |
|
83 | + return $this->getBackendUser()->isAdmin(); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get the Vidi Module Loader. |
|
88 | - * |
|
89 | - * @return ModuleLoader|object |
|
90 | - */ |
|
91 | - protected function getModuleLoader(): ModuleLoader |
|
92 | - { |
|
93 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
94 | - } |
|
86 | + /** |
|
87 | + * Get the Vidi Module Loader. |
|
88 | + * |
|
89 | + * @return ModuleLoader|object |
|
90 | + */ |
|
91 | + protected function getModuleLoader(): ModuleLoader |
|
92 | + { |
|
93 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Get the Vidi Module Loader. |
|
98 | - * |
|
99 | - * @return GridAnalyserService|object |
|
100 | - */ |
|
101 | - protected function getGridAnalyserService() |
|
102 | - { |
|
103 | - return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
104 | - } |
|
96 | + /** |
|
97 | + * Get the Vidi Module Loader. |
|
98 | + * |
|
99 | + * @return GridAnalyserService|object |
|
100 | + */ |
|
101 | + protected function getGridAnalyserService() |
|
102 | + { |
|
103 | + return GeneralUtility::makeInstance(GridAnalyserService::class); |
|
104 | + } |
|
105 | 105 | } |
106 | 106 |
@@ -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,77 +19,77 @@ |
||
19 | 19 | class ConfiguredPidTool extends AbstractTool |
20 | 20 | { |
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('%s (%s)', |
|
30 | - LocalizationUtility::translate('tool.configured_pid', 'vidi'), |
|
31 | - $this->getModulePidService()->getConfiguredNewRecordPid() |
|
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 sprintf('%s (%s)', |
|
30 | + LocalizationUtility::translate('tool.configured_pid', 'vidi'), |
|
31 | + $this->getModulePidService()->getConfiguredNewRecordPid() |
|
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/ConfiguredPid/Launcher.html'; |
|
43 | - $view = $this->initializeStandaloneView($templateNameAndPath); |
|
44 | - $view->assignMultiple([ |
|
45 | - 'sitePath' => Environment::getPublicPath() . '/', |
|
46 | - 'dataType' => $this->getModuleLoader()->getDataType(), |
|
47 | - 'configuredPid' => $this->getModulePidService()->getConfiguredNewRecordPid(), |
|
48 | - 'errors' => $this->getModulePidService()->validateConfiguredPid(), |
|
49 | - ]); |
|
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/ConfiguredPid/Launcher.html'; |
|
43 | + $view = $this->initializeStandaloneView($templateNameAndPath); |
|
44 | + $view->assignMultiple([ |
|
45 | + 'sitePath' => Environment::getPublicPath() . '/', |
|
46 | + 'dataType' => $this->getModuleLoader()->getDataType(), |
|
47 | + 'configuredPid' => $this->getModulePidService()->getConfiguredNewRecordPid(), |
|
48 | + 'errors' => $this->getModulePidService()->validateConfiguredPid(), |
|
49 | + ]); |
|
50 | 50 | |
51 | - return $view->render(); |
|
52 | - } |
|
51 | + return $view->render(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Do the job |
|
56 | - * |
|
57 | - * @param array $arguments |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function work(array $arguments = array()): string |
|
61 | - { |
|
62 | - return ''; |
|
63 | - } |
|
54 | + /** |
|
55 | + * Do the job |
|
56 | + * |
|
57 | + * @param array $arguments |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function work(array $arguments = array()): string |
|
61 | + { |
|
62 | + return ''; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Tell whether the tools should be displayed according to the context. |
|
67 | - * |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public function isShown(): bool |
|
71 | - { |
|
72 | - return $this->getBackendUser()->isAdmin(); |
|
73 | - } |
|
65 | + /** |
|
66 | + * Tell whether the tools should be displayed according to the context. |
|
67 | + * |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public function isShown(): bool |
|
71 | + { |
|
72 | + return $this->getBackendUser()->isAdmin(); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Get the Vidi Module Loader. |
|
77 | - * |
|
78 | - * @return ModuleLoader|object |
|
79 | - */ |
|
80 | - protected function getModuleLoader(): ModuleLoader |
|
81 | - { |
|
82 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
83 | - } |
|
75 | + /** |
|
76 | + * Get the Vidi Module Loader. |
|
77 | + * |
|
78 | + * @return ModuleLoader|object |
|
79 | + */ |
|
80 | + protected function getModuleLoader(): ModuleLoader |
|
81 | + { |
|
82 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @return ModulePidService|object |
|
87 | - */ |
|
88 | - public function getModulePidService() |
|
89 | - { |
|
90 | - /** @var ModulePidService $modulePidService */ |
|
91 | - return GeneralUtility::makeInstance(ModulePidService::class); |
|
92 | - } |
|
85 | + /** |
|
86 | + * @return ModulePidService|object |
|
87 | + */ |
|
88 | + public function getModulePidService() |
|
89 | + { |
|
90 | + /** @var ModulePidService $modulePidService */ |
|
91 | + return GeneralUtility::makeInstance(ModulePidService::class); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | } |
95 | 95 |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('TYPO3')) die ('Access denied.'); |
|
2 | +if (!defined('TYPO3')) { |
|
3 | + die ('Access denied.'); |
|
4 | +} |
|
3 | 5 | |
4 | 6 | return [ |
5 | 7 | 'ctrl' => [ |
@@ -2,88 +2,88 @@ |
||
2 | 2 | if (!defined('TYPO3')) die ('Access denied.'); |
3 | 3 | |
4 | 4 | return [ |
5 | - 'ctrl' => [ |
|
6 | - 'title' => 'LLL:EXT:phpdisplay/Resources/Private/Language/locallang_db.xml:tx_phpdisplay_displays', |
|
7 | - 'label' => 'name', |
|
8 | - 'tstamp' => 'tstamp', |
|
9 | - 'crdate' => 'crdate', |
|
10 | - 'cruser_id' => 'cruser_id', |
|
11 | - 'hideTable' => true, |
|
12 | - 'delete' => 'deleted', |
|
13 | - 'enablecolumns' => [ |
|
14 | - 'disabled' => 'hidden', |
|
15 | - ], |
|
16 | - 'searchFields' => 'type,name,data_type', |
|
17 | - 'typeicon_classes' => [ |
|
18 | - 'default' => 'extensions-vidi-selection', |
|
19 | - ], |
|
20 | - ], |
|
21 | - 'types' => [ |
|
22 | - '1' => ['showitem' => 'hidden,--palette--;;1,type,name,data_type,query'], |
|
23 | - ], |
|
24 | - 'palettes' => [ |
|
25 | - '1' => ['showitem' => ''], |
|
26 | - ], |
|
27 | - 'columns' => [ |
|
5 | + 'ctrl' => [ |
|
6 | + 'title' => 'LLL:EXT:phpdisplay/Resources/Private/Language/locallang_db.xml:tx_phpdisplay_displays', |
|
7 | + 'label' => 'name', |
|
8 | + 'tstamp' => 'tstamp', |
|
9 | + 'crdate' => 'crdate', |
|
10 | + 'cruser_id' => 'cruser_id', |
|
11 | + 'hideTable' => true, |
|
12 | + 'delete' => 'deleted', |
|
13 | + 'enablecolumns' => [ |
|
14 | + 'disabled' => 'hidden', |
|
15 | + ], |
|
16 | + 'searchFields' => 'type,name,data_type', |
|
17 | + 'typeicon_classes' => [ |
|
18 | + 'default' => 'extensions-vidi-selection', |
|
19 | + ], |
|
20 | + ], |
|
21 | + 'types' => [ |
|
22 | + '1' => ['showitem' => 'hidden,--palette--;;1,type,name,data_type,query'], |
|
23 | + ], |
|
24 | + 'palettes' => [ |
|
25 | + '1' => ['showitem' => ''], |
|
26 | + ], |
|
27 | + 'columns' => [ |
|
28 | 28 | |
29 | - 'hidden' => [ |
|
30 | - 'exclude' => 1, |
|
31 | - 'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.hidden', |
|
32 | - 'config' => [ |
|
33 | - 'type' => 'check', |
|
34 | - ], |
|
35 | - ], |
|
36 | - 'visibility' => [ |
|
37 | - 'exclude' => 0, |
|
38 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility', |
|
39 | - 'config' => [ |
|
40 | - 'type' => 'select', |
|
41 | - 'renderType' => 'selectSingle', |
|
42 | - 'items' => [ |
|
43 | - ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.everyone', 0], |
|
44 | - ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.private', 1], |
|
45 | - ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.admin_only', 2], |
|
46 | - ], |
|
47 | - 'size' => 1, |
|
48 | - 'maxitems' => 1, |
|
49 | - 'minitems' => 1, |
|
50 | - ], |
|
51 | - ], |
|
52 | - 'name' => [ |
|
53 | - 'exclude' => 0, |
|
54 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:name', |
|
55 | - 'config' => [ |
|
56 | - 'type' => 'input', |
|
57 | - 'size' => 30, |
|
58 | - 'eval' => 'trim,required' |
|
59 | - ], |
|
60 | - ], |
|
61 | - 'data_type' => [ |
|
62 | - 'exclude' => 0, |
|
63 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:data_type', |
|
64 | - 'config' => [ |
|
65 | - 'type' => 'input', |
|
66 | - 'size' => 30, |
|
67 | - 'eval' => 'trim,required' |
|
68 | - ], |
|
69 | - ], |
|
70 | - 'query' => [ |
|
71 | - 'exclude' => 0, |
|
72 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:query', |
|
73 | - 'config' => [ |
|
74 | - 'type' => 'text', |
|
75 | - 'rows' => 5, |
|
76 | - 'cols' => 5, |
|
77 | - ], |
|
78 | - ], |
|
79 | - 'speaking_query' => [ |
|
80 | - 'exclude' => 0, |
|
81 | - 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:speaking_query', |
|
82 | - 'config' => [ |
|
83 | - 'type' => 'text', |
|
84 | - 'rows' => 5, |
|
85 | - 'cols' => 5, |
|
86 | - ], |
|
87 | - ], |
|
88 | - ], |
|
29 | + 'hidden' => [ |
|
30 | + 'exclude' => 1, |
|
31 | + 'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.hidden', |
|
32 | + 'config' => [ |
|
33 | + 'type' => 'check', |
|
34 | + ], |
|
35 | + ], |
|
36 | + 'visibility' => [ |
|
37 | + 'exclude' => 0, |
|
38 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility', |
|
39 | + 'config' => [ |
|
40 | + 'type' => 'select', |
|
41 | + 'renderType' => 'selectSingle', |
|
42 | + 'items' => [ |
|
43 | + ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.everyone', 0], |
|
44 | + ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.private', 1], |
|
45 | + ['LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:visibility.admin_only', 2], |
|
46 | + ], |
|
47 | + 'size' => 1, |
|
48 | + 'maxitems' => 1, |
|
49 | + 'minitems' => 1, |
|
50 | + ], |
|
51 | + ], |
|
52 | + 'name' => [ |
|
53 | + 'exclude' => 0, |
|
54 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:name', |
|
55 | + 'config' => [ |
|
56 | + 'type' => 'input', |
|
57 | + 'size' => 30, |
|
58 | + 'eval' => 'trim,required' |
|
59 | + ], |
|
60 | + ], |
|
61 | + 'data_type' => [ |
|
62 | + 'exclude' => 0, |
|
63 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:data_type', |
|
64 | + 'config' => [ |
|
65 | + 'type' => 'input', |
|
66 | + 'size' => 30, |
|
67 | + 'eval' => 'trim,required' |
|
68 | + ], |
|
69 | + ], |
|
70 | + 'query' => [ |
|
71 | + 'exclude' => 0, |
|
72 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:query', |
|
73 | + 'config' => [ |
|
74 | + 'type' => 'text', |
|
75 | + 'rows' => 5, |
|
76 | + 'cols' => 5, |
|
77 | + ], |
|
78 | + ], |
|
79 | + 'speaking_query' => [ |
|
80 | + 'exclude' => 0, |
|
81 | + 'label' => 'LLL:EXT:vidi/Resources/Private/Language/tx_vidi_selection.xlf:speaking_query', |
|
82 | + 'config' => [ |
|
83 | + 'type' => 'text', |
|
84 | + 'rows' => 5, |
|
85 | + 'cols' => 5, |
|
86 | + ], |
|
87 | + ], |
|
88 | + ], |
|
89 | 89 | ]; |