@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | $fulltext['mimetype'] = $this->document->getDoc()->getFileMimeType($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$page]]['files'][$fileGrpFulltext]); |
147 | 147 | break; |
148 | 148 | } else { |
149 | - $this->logger->notice('No full-text file found for page "' . $page . '" in fileGrp "' . $fileGrpFulltext . '"'); |
|
149 | + $this->logger->notice('No full-text file found for page "'.$page.'" in fileGrp "'.$fileGrpFulltext.'"'); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | if (empty($fulltext)) { |
153 | - $this->logger->notice('No full-text file found for page "' . $page . '" in fileGrps "' . $this->extConf['fileGrpFulltext'] . '"'); |
|
153 | + $this->logger->notice('No full-text file found for page "'.$page.'" in fileGrps "'.$this->extConf['fileGrpFulltext'].'"'); |
|
154 | 154 | } |
155 | 155 | return $fulltext; |
156 | 156 | } |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | $viewerConfiguration = '$(document).ready(function() { |
169 | 169 | if (dlfUtils.exists(dlfViewer)) { |
170 | 170 | tx_dlf_viewer = new dlfViewer({ |
171 | - controls: ["' . implode('", "', $this->controls) . '"], |
|
172 | - div: "' . $this->settings['elementId'] . '", |
|
173 | - progressElementId: "' . $this->settings['progressElementId'] . '", |
|
174 | - images: ' . json_encode($this->images) . ', |
|
175 | - fulltexts: ' . json_encode($this->fulltexts) . ', |
|
176 | - annotationContainers: ' . json_encode($this->annotationContainers) . ', |
|
177 | - useInternalProxy: ' . ($this->settings['useInternalProxy'] ? 1 : 0) . ' |
|
171 | + controls: ["' . implode('", "', $this->controls).'"], |
|
172 | + div: "' . $this->settings['elementId'].'", |
|
173 | + progressElementId: "' . $this->settings['progressElementId'].'", |
|
174 | + images: ' . json_encode($this->images).', |
|
175 | + fulltexts: ' . json_encode($this->fulltexts).', |
|
176 | + annotationContainers: ' . json_encode($this->annotationContainers).', |
|
177 | + useInternalProxy: ' . ($this->settings['useInternalProxy'] ? 1 : 0).' |
|
178 | 178 | }); |
179 | 179 | } |
180 | 180 | });'; |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | } |
276 | 276 | break; |
277 | 277 | } else { |
278 | - $this->logger->notice('No image file found for page "' . $page . '" in fileGrp "' . $fileGrpImages . '"'); |
|
278 | + $this->logger->notice('No image file found for page "'.$page.'" in fileGrp "'.$fileGrpImages.'"'); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | if (empty($image)) { |
282 | - $this->logger->warning('No image file found for page "' . $page . '" in fileGrps "' . $this->extConf['fileGrpImages'] . '"'); |
|
282 | + $this->logger->warning('No image file found for page "'.$page.'" in fileGrps "'.$this->extConf['fileGrpImages'].'"'); |
|
283 | 283 | } |
284 | 284 | return $image; |
285 | 285 | } |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | * @subpackage dlf |
27 | 27 | * @access public |
28 | 28 | */ |
29 | -class PageViewController extends AbstractController |
|
30 | -{ |
|
29 | +class PageViewController extends AbstractController { |
|
31 | 30 | /** |
32 | 31 | * Holds the controls to add to the map |
33 | 32 | * |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | * |
66 | 65 | * @return void |
67 | 66 | */ |
68 | - public function mainAction() |
|
69 | - { |
|
67 | + public function mainAction() { |
|
70 | 68 | // Load current document. |
71 | 69 | $this->loadDocument($this->requestData); |
72 | 70 | if ($this->isDocMissingOrEmpty()) { |
@@ -118,8 +116,7 @@ discard block |
||
118 | 116 | * |
119 | 117 | * @return array URL and MIME type of fulltext file |
120 | 118 | */ |
121 | - protected function getFulltext($page) |
|
122 | - { |
|
119 | + protected function getFulltext($page) { |
|
123 | 120 | $fulltext = []; |
124 | 121 | // Get fulltext link. |
125 | 122 | $fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->extConf['fileGrpFulltext']); |
@@ -159,8 +156,7 @@ discard block |
||
159 | 156 | * |
160 | 157 | * @return void |
161 | 158 | */ |
162 | - protected function addViewerJS() |
|
163 | - { |
|
159 | + protected function addViewerJS() { |
|
164 | 160 | // Viewer configuration. |
165 | 161 | $viewerConfiguration = '$(document).ready(function() { |
166 | 162 | if (dlfUtils.exists(dlfViewer)) { |
@@ -187,8 +183,7 @@ discard block |
||
187 | 183 | * @return array An array containing the IRIs of the AnnotationLists / AnnotationPages as well as |
188 | 184 | * some information about the canvas. |
189 | 185 | */ |
190 | - protected function getAnnotationContainers($page) |
|
191 | - { |
|
186 | + protected function getAnnotationContainers($page) { |
|
192 | 187 | if ($this->document->getDoc() instanceof IiifManifest) { |
193 | 188 | $canvasId = $this->document->getDoc()->physicalStructure[$page]; |
194 | 189 | $iiif = $this->document->getDoc()->getIiif(); |
@@ -244,8 +239,7 @@ discard block |
||
244 | 239 | * |
245 | 240 | * @return array URL and MIME type of image file |
246 | 241 | */ |
247 | - protected function getImage($page) |
|
248 | - { |
|
242 | + protected function getImage($page) { |
|
249 | 243 | $image = []; |
250 | 244 | // Get @USE value of METS fileGrp. |
251 | 245 | $fileGrpsImages = GeneralUtility::trimExplode(',', $this->extConf['fileGrpImages']); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // Configure @action URL for form. |
131 | 131 | $uri = $this->uriBuilder->reset() |
132 | 132 | ->setTargetPageUid($GLOBALS['TSFE']->id) |
133 | - ->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? true : false) |
|
133 | + ->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? TRUE : FALSE) |
|
134 | 134 | ->setArguments([ |
135 | 135 | 'eID' => 'tx_dlf_pageview_proxy', |
136 | 136 | 'url' => $fulltext['url'], |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if ($iiif instanceof ManifestInterface) { |
196 | 196 | $canvas = $iiif->getContainedResourceById($canvasId); |
197 | 197 | /* @var $canvas \Ubl\Iiif\Presentation\Common\Model\Resources\CanvasInterface */ |
198 | - if ($canvas != null && !empty($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING))) { |
|
198 | + if ($canvas != NULL && !empty($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING))) { |
|
199 | 199 | $annotationContainers = []; |
200 | 200 | /* |
201 | 201 | * TODO Analyzing the annotations on the server side requires loading the annotation lists / pages |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | * On the other hand, server connections are potentially better than client connections. Downloading annotation lists |
206 | 206 | */ |
207 | 207 | foreach ($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING) as $annotationContainer) { |
208 | - if (($textAnnotations = $annotationContainer->getTextAnnotations(Motivation::PAINTING)) != null) { |
|
208 | + if (($textAnnotations = $annotationContainer->getTextAnnotations(Motivation::PAINTING)) != NULL) { |
|
209 | 209 | foreach ($textAnnotations as $annotation) { |
210 | 210 | if ( |
211 | 211 | $annotation->getBody()->getFormat() == 'text/plain' |
212 | - && $annotation->getBody()->getChars() != null |
|
212 | + && $annotation->getBody()->getChars() != NULL |
|
213 | 213 | ) { |
214 | 214 | $annotationListData = []; |
215 | 215 | $annotationListData['uri'] = $annotationContainer->getId(); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // Configure @action URL for form. |
262 | 262 | $uri = $this->uriBuilder->reset() |
263 | 263 | ->setTargetPageUid($GLOBALS['TSFE']->id) |
264 | - ->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? true : false) |
|
264 | + ->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? TRUE : FALSE) |
|
265 | 265 | ->setArguments([ |
266 | 266 | 'eID' => 'tx_dlf_pageview_proxy', |
267 | 267 | 'url' => $image['url'], |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | * @subpackage dlf |
27 | 27 | * @access public |
28 | 28 | */ |
29 | -class CalendarController extends AbstractController |
|
30 | -{ |
|
29 | +class CalendarController extends AbstractController { |
|
31 | 30 | /** |
32 | 31 | * @var StructureRepository |
33 | 32 | */ |
@@ -36,8 +35,7 @@ discard block |
||
36 | 35 | /** |
37 | 36 | * @param StructureRepository $structureRepository |
38 | 37 | */ |
39 | - public function injectStructureRepository(StructureRepository $structureRepository) |
|
40 | - { |
|
38 | + public function injectStructureRepository(StructureRepository $structureRepository) { |
|
41 | 39 | $this->structureRepository = $structureRepository; |
42 | 40 | } |
43 | 41 | |
@@ -54,8 +52,7 @@ discard block |
||
54 | 52 | * |
55 | 53 | * @return void |
56 | 54 | */ |
57 | - public function mainAction() |
|
58 | - { |
|
55 | + public function mainAction() { |
|
59 | 56 | // Set initial document (anchor or year file) if configured. |
60 | 57 | if (empty($this->requestData['id']) && !empty($this->settings['initialDocument'])) { |
61 | 58 | $this->requestData['id'] = $this->settings['initialDocument']; |
@@ -100,8 +97,7 @@ discard block |
||
100 | 97 | * |
101 | 98 | * @return void |
102 | 99 | */ |
103 | - public function calendarAction() |
|
104 | - { |
|
100 | + public function calendarAction() { |
|
105 | 101 | // access arguments passed by the mainAction() |
106 | 102 | $mainrequestData = $this->request->getArguments(); |
107 | 103 | |
@@ -206,8 +202,7 @@ discard block |
||
206 | 202 | * |
207 | 203 | * @return void |
208 | 204 | */ |
209 | - public function yearsAction() |
|
210 | - { |
|
205 | + public function yearsAction() { |
|
211 | 206 | // access arguments passed by the mainAction() |
212 | 207 | $mainrequestData = $this->request->getArguments(); |
213 | 208 | |
@@ -262,8 +257,7 @@ discard block |
||
262 | 257 | * |
263 | 258 | * @return string Content for template subpart |
264 | 259 | */ |
265 | - protected function getCalendarYear(&$calendarData, $calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) |
|
266 | - { |
|
260 | + protected function getCalendarYear(&$calendarData, $calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) { |
|
267 | 261 | for ($i = $firstMonth; $i <= $lastMonth; $i++) { |
268 | 262 | $key = $year . '-' . $i; |
269 | 263 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | // Load current document. |
65 | 65 | $this->loadDocument($this->requestData); |
66 | - if ($this->document === null) { |
|
66 | + if ($this->document === NULL) { |
|
67 | 67 | // Quit without doing anything if required variables are not set. |
68 | 68 | return ''; |
69 | 69 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | switch ($type) { |
79 | 79 | case 'newspaper': |
80 | 80 | case 'ephemera': |
81 | - $this->forward('years', null, null, $this->requestData); |
|
81 | + $this->forward('years', NULL, NULL, $this->requestData); |
|
82 | 82 | break; |
83 | 83 | case 'year': |
84 | - $this->forward('calendar', null, null, $this->requestData); |
|
84 | + $this->forward('calendar', NULL, NULL, $this->requestData); |
|
85 | 85 | break; |
86 | 86 | case 'issue': |
87 | 87 | default: |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | // Load current document. |
112 | 112 | $this->loadDocument($this->requestData); |
113 | - if ($this->document === null) { |
|
113 | + if ($this->document === NULL) { |
|
114 | 114 | // Quit without doing anything if required variables are not set. |
115 | 115 | return ''; |
116 | 116 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | foreach ($month['children'] as $day) { |
129 | 129 | foreach ($day['children'] as $issue) { |
130 | 130 | $title = $issue['label'] ?: $issue['orderlabel']; |
131 | - if (strtotime($title) !== false) { |
|
131 | + if (strtotime($title) !== FALSE) { |
|
132 | 132 | $title = strftime('%x', strtotime($title)); |
133 | 133 | } |
134 | 134 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $title = $document->getTitle(); |
150 | 150 | } else { |
151 | 151 | $title = !empty($document->getMetsLabel()) ? $document->getMetsLabel() : $document->getMetsOrderlabel(); |
152 | - if (strtotime($title) !== false) { |
|
152 | + if (strtotime($title) !== FALSE) { |
|
153 | 153 | $title = strftime('%x', strtotime($title)); |
154 | 154 | } |
155 | 155 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $calendarIssuesByYear = []; |
166 | 166 | foreach ($issues as $issue) { |
167 | 167 | $dateTimestamp = strtotime($issue['year']); |
168 | - if ($dateTimestamp !== false) { |
|
168 | + if ($dateTimestamp !== FALSE) { |
|
169 | 169 | $_year = date('Y', $dateTimestamp); |
170 | 170 | $_month = date('n', $dateTimestamp); |
171 | 171 | $_day = date('j', $dateTimestamp); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | // Load current document. |
241 | 241 | $this->loadDocument($this->requestData); |
242 | - if ($this->document === null) { |
|
242 | + if ($this->document === NULL) { |
|
243 | 243 | // Quit without doing anything if required variables are not set. |
244 | 244 | return ''; |
245 | 245 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | foreach ($year['children'] as $month) { |
128 | 128 | foreach ($month['children'] as $day) { |
129 | 129 | foreach ($day['children'] as $issue) { |
130 | - $title = $issue['label'] ?: $issue['orderlabel']; |
|
130 | + $title = $issue['label'] ? : $issue['orderlabel']; |
|
131 | 131 | if (strtotime($title) !== false) { |
132 | 132 | $title = strftime('%x', strtotime($title)); |
133 | 133 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $_day = date('j', $dateTimestamp); |
172 | 172 | $calendarIssuesByYear[$_year][$_month][$_day][] = $issue; |
173 | 173 | } else { |
174 | - $this->logger->warning('Document with UID ' . $issue['uid'] . 'has no valid date of publication'); |
|
174 | + $this->logger->warning('Document with UID '.$issue['uid'].'has no valid date of publication'); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | // Sort by years. |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | $this->view->assign('calendarData', $calendarData); |
219 | 219 | $this->view->assign('documentId', $this->document->getUid()); |
220 | 220 | $this->view->assign('yearLinkTitle', $yearLinkTitle); |
221 | - $this->view->assign('parentDocumentId', $this->document->getPartof() ?: $this->document->getDoc()->tableOfContents[0]['points']); |
|
222 | - $this->view->assign('allYearDocTitle', $this->document->getDoc()->getTitle($this->document->getPartof()) ?: $this->document->getDoc()->tableOfContents[0]['label']); |
|
221 | + $this->view->assign('parentDocumentId', $this->document->getPartof() ? : $this->document->getDoc()->tableOfContents[0]['points']); |
|
222 | + $this->view->assign('allYearDocTitle', $this->document->getDoc()->getTitle($this->document->getPartof()) ? : $this->document->getDoc()->tableOfContents[0]['label']); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | if (empty($yearLabel)) { |
257 | 257 | // if neither order nor orderlabel is set, use the id... |
258 | - $yearLabel = (string)$id; |
|
258 | + $yearLabel = (string) $id; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | $years[] = [ |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | if (is_int($key)) { |
295 | 295 | $yearFilled[] = $yearArray[$key]; |
296 | 296 | } else { |
297 | - $yearFilled[] = ['title' => $min+$i, 'documentId' => '']; |
|
297 | + $yearFilled[] = ['title' => $min + $i, 'documentId' => '']; |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | $yearArray = $yearFilled; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | protected function getCalendarYear(&$calendarData, $calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) |
324 | 324 | { |
325 | 325 | for ($i = $firstMonth; $i <= $lastMonth; $i++) { |
326 | - $key = $year . '-' . $i; |
|
326 | + $key = $year.'-'.$i; |
|
327 | 327 | |
328 | 328 | $calendarData[$key] = [ |
329 | 329 | 'DAYMON_NAME' => strftime('%a', strtotime('last Monday')), |
@@ -333,16 +333,16 @@ discard block |
||
333 | 333 | 'DAYFRI_NAME' => strftime('%a', strtotime('last Friday')), |
334 | 334 | 'DAYSAT_NAME' => strftime('%a', strtotime('last Saturday')), |
335 | 335 | 'DAYSUN_NAME' => strftime('%a', strtotime('last Sunday')), |
336 | - 'MONTHNAME' => strftime('%B', strtotime($year . '-' . $i . '-1')) . ' ' . $year, |
|
336 | + 'MONTHNAME' => strftime('%B', strtotime($year.'-'.$i.'-1')).' '.$year, |
|
337 | 337 | 'CALYEAR' => ($i == $firstMonth) ? $year : '' |
338 | 338 | ]; |
339 | 339 | |
340 | - $firstOfMonth = strtotime($year . '-' . $i . '-1'); |
|
340 | + $firstOfMonth = strtotime($year.'-'.$i.'-1'); |
|
341 | 341 | $lastOfMonth = strtotime('last day of', ($firstOfMonth)); |
342 | 342 | $firstOfMonthStart = strtotime('last Monday', $firstOfMonth); |
343 | 343 | // There are never more than 6 weeks in a month. |
344 | 344 | for ($j = 0; $j <= 5; $j++) { |
345 | - $firstDayOfWeek = strtotime('+ ' . $j . ' Week', $firstOfMonthStart); |
|
345 | + $firstDayOfWeek = strtotime('+ '.$j.' Week', $firstOfMonthStart); |
|
346 | 346 | |
347 | 347 | $calendarData[$key]['week'][$j] = [ |
348 | 348 | 'DAYMON' => ['dayValue' => ' '], |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | ]; |
356 | 356 | // Every week has seven days. ;-) |
357 | 357 | for ($k = 0; $k <= 6; $k++) { |
358 | - $currentDayTime = strtotime('+ ' . $k . ' Day', $firstDayOfWeek); |
|
358 | + $currentDayTime = strtotime('+ '.$k.' Day', $firstDayOfWeek); |
|
359 | 359 | if ( |
360 | 360 | $currentDayTime >= $firstOfMonth |
361 | 361 | && $currentDayTime <= $lastOfMonth |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | $dayLinkDiv = $dayLinksText; |
388 | 388 | } |
389 | - switch (strftime('%w', strtotime('+ ' . $k . ' Day', $firstDayOfWeek))) { |
|
389 | + switch (strftime('%w', strtotime('+ '.$k.' Day', $firstDayOfWeek))) { |
|
390 | 390 | case '0': |
391 | 391 | $calendarData[$key]['week'][$j]['DAYSUN']['dayValue'] = strftime('%d', $currentDayTime); |
392 | 392 | if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
@@ -21,13 +21,11 @@ |
||
21 | 21 | * @subpackage dlf |
22 | 22 | * @access public |
23 | 23 | */ |
24 | -class View3DController extends AbstractController |
|
25 | -{ |
|
24 | +class View3DController extends AbstractController { |
|
26 | 25 | /** |
27 | 26 | * @return string|void |
28 | 27 | */ |
29 | - public function mainAction() |
|
30 | - { |
|
28 | + public function mainAction() { |
|
31 | 29 | $this->cObj = $this->configurationManager->getContentObject(); |
32 | 30 | // Load current document. |
33 | 31 | $this->loadDocument($this->requestData); |
@@ -48,8 +48,8 @@ |
||
48 | 48 | |
49 | 49 | $settingsParts = explode("/", $model); |
50 | 50 | $fileName = end($settingsParts); |
51 | - $path = substr($model, 0, strrpos($model, $fileName)); |
|
52 | - $modelSettings = $path . "metadata/" . $fileName . "_viewer"; |
|
51 | + $path = substr($model, 0, strrpos($model, $fileName)); |
|
52 | + $modelSettings = $path."metadata/".$fileName."_viewer"; |
|
53 | 53 | |
54 | 54 | if (!empty($modelConverted)) { |
55 | 55 | $model = $modelConverted; |
@@ -55,7 +55,7 @@ |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | if ($this->settings['useInternalProxy']) { |
58 | - $absoluteUri = !empty($this->settings['forceAbsoluteUrl']) ? true : false; |
|
58 | + $absoluteUri = !empty($this->settings['forceAbsoluteUrl']) ? TRUE : FALSE; |
|
59 | 59 | |
60 | 60 | $model = $this->uriBuilder->reset() |
61 | 61 | ->setTargetPageUid($GLOBALS['TSFE']->id) |
@@ -48,6 +48,6 @@ |
||
48 | 48 | $metadata['video_duration'] = [$videoDuration]; |
49 | 49 | } |
50 | 50 | |
51 | - $metadata['duration'] = $metadata['video_duration'] ?: $metadata['audio_duration'] ?: []; |
|
51 | + $metadata['duration'] = $metadata['video_duration'] ? : $metadata['audio_duration'] ? : []; |
|
52 | 52 | } |
53 | 53 | } |
@@ -35,8 +35,7 @@ |
||
35 | 35 | * |
36 | 36 | * @return void |
37 | 37 | */ |
38 | - public function extractMetadata(\SimpleXMLElement $xml, array &$metadata) |
|
39 | - { |
|
38 | + public function extractMetadata(\SimpleXMLElement $xml, array &$metadata) { |
|
40 | 39 | $xml->registerXPathNamespace('audiomd', 'http://www.loc.gov/audioMD/'); |
41 | 40 | $xml->registerXPathNamespace('videomd', 'http://www.loc.gov/videoMD/'); |
42 | 41 |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $fileMimeType = $this->getFileMimeType($id); |
218 | 218 | $fileLocation = $this->getFileLocation($id); |
219 | 219 | if ($fileMimeType === 'application/vnd.kitodo.iiif') { |
220 | - $fileLocation = (strrpos($fileLocation, 'info.json') === strlen($fileLocation) - 9) ? $fileLocation : (strrpos($fileLocation, '/') === strlen($fileLocation) ? $fileLocation . 'info.json' : $fileLocation . '/info.json'); |
|
220 | + $fileLocation = (strrpos($fileLocation, 'info.json') === strlen($fileLocation) - 9) ? $fileLocation : (strrpos($fileLocation, '/') === strlen($fileLocation) ? $fileLocation.'info.json' : $fileLocation.'/info.json'); |
|
221 | 221 | $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
222 | 222 | IiifHelper::setUrlReader(IiifUrlReader::getInstance()); |
223 | 223 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | return $service->getImageUrl(); |
228 | 228 | } |
229 | 229 | } elseif ($fileMimeType === 'application/vnd.netfpx') { |
230 | - $baseURL = $fileLocation . (strpos($fileLocation, '?') === false ? '?' : ''); |
|
230 | + $baseURL = $fileLocation.(strpos($fileLocation, '?') === false ? '?' : ''); |
|
231 | 231 | // TODO CVT is an optional IIP server capability; in theory, capabilities should be determined in the object request with '&obj=IIP-server' |
232 | - return $baseURL . '&CVT=jpeg'; |
|
232 | + return $baseURL.'&CVT=jpeg'; |
|
233 | 233 | } |
234 | 234 | return $fileLocation; |
235 | 235 | } |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function getFileLocation($id) |
242 | 242 | { |
243 | - $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]'); |
|
243 | + $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/mets:FLocat[@LOCTYPE="URL"]'); |
|
244 | 244 | if ( |
245 | 245 | !empty($id) |
246 | 246 | && !empty($location) |
247 | 247 | ) { |
248 | 248 | return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href; |
249 | 249 | } else { |
250 | - $this->logger->warning('There is no file node with @ID "' . $id . '"'); |
|
250 | + $this->logger->warning('There is no file node with @ID "'.$id.'"'); |
|
251 | 251 | return ''; |
252 | 252 | } |
253 | 253 | } |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function getFileMimeType($id) |
260 | 260 | { |
261 | - $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/@MIMETYPE'); |
|
261 | + $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/@MIMETYPE'); |
|
262 | 262 | if ( |
263 | 263 | !empty($id) |
264 | 264 | && !empty($mimetype) |
265 | 265 | ) { |
266 | 266 | return (string) $mimetype[0]; |
267 | 267 | } else { |
268 | - $this->logger->warning('There is no file node with @ID "' . $id . '" or no MIME type specified'); |
|
268 | + $this->logger->warning('There is no file node with @ID "'.$id.'" or no MIME type specified'); |
|
269 | 269 | return ''; |
270 | 270 | } |
271 | 271 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | return $this->logicalUnits[$id]; |
287 | 287 | } elseif (!empty($id)) { |
288 | 288 | // Get specified logical unit. |
289 | - $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $id . '"]'); |
|
289 | + $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]'); |
|
290 | 290 | } else { |
291 | 291 | // Get all logical units at top level. |
292 | 292 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]/mets:div'); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | // Retain current PID. |
428 | 428 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
429 | 429 | } elseif (!$cPid) { |
430 | - $this->logger->warning('Invalid PID ' . $cPid . ' for metadata definitions'); |
|
430 | + $this->logger->warning('Invalid PID '.$cPid.' for metadata definitions'); |
|
431 | 431 | return []; |
432 | 432 | } |
433 | 433 | // Get metadata from parsed metadata array if available. |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | if (!empty($this->logicalUnits[$id])) { |
479 | 479 | $metadata['type'] = [$this->logicalUnits[$id]['type']]; |
480 | 480 | } else { |
481 | - $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $id . '"]/@TYPE'); |
|
481 | + $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE'); |
|
482 | 482 | if (!empty($struct)) { |
483 | 483 | $metadata['type'] = [(string) $struct[0]]; |
484 | 484 | } |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | ) { |
504 | 504 | $obj->extractMetadata($this->mdSec[$dmdId]['xml'], $metadata); |
505 | 505 | } else { |
506 | - $this->logger->warning('Invalid class/method "' . $class . '->extractMetadata()" for metadata format "' . $this->mdSec[$dmdId]['type'] . '"'); |
|
506 | + $this->logger->warning('Invalid class/method "'.$class.'->extractMetadata()" for metadata format "'.$this->mdSec[$dmdId]['type'].'"'); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } else { |
510 | - $this->logger->notice('Unsupported metadata format "' . $this->mdSec[$dmdId]['type'] . '" in ' . $mdSectionType . ' with @ID "' . $dmdId . '"'); |
|
510 | + $this->logger->notice('Unsupported metadata format "'.$this->mdSec[$dmdId]['type'].'" in '.$mdSectionType.' with @ID "'.$dmdId.'"'); |
|
511 | 511 | // Continue searching for supported metadata with next @DMDID. |
512 | 512 | continue; |
513 | 513 | } |
@@ -623,13 +623,13 @@ discard block |
||
623 | 623 | $values instanceof \DOMNodeList |
624 | 624 | && $values->length > 0 |
625 | 625 | ) { |
626 | - $metadata[$resArray['index_name'] . '_sorting'][0] = trim((string) $values->item(0)->nodeValue); |
|
626 | + $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values->item(0)->nodeValue); |
|
627 | 627 | } elseif (!($values instanceof \DOMNodeList)) { |
628 | - $metadata[$resArray['index_name'] . '_sorting'][0] = trim((string) $values); |
|
628 | + $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values); |
|
629 | 629 | } |
630 | 630 | } |
631 | - if (empty($metadata[$resArray['index_name'] . '_sorting'][0])) { |
|
632 | - $metadata[$resArray['index_name'] . '_sorting'][0] = $metadata[$resArray['index_name']][0]; |
|
631 | + if (empty($metadata[$resArray['index_name'].'_sorting'][0])) { |
|
632 | + $metadata[$resArray['index_name'].'_sorting'][0] = $metadata[$resArray['index_name']][0]; |
|
633 | 633 | } |
634 | 634 | } |
635 | 635 | } |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | if (isset($this->fileInfos[$id]) || isset($hasMetadataSection['dmdSec'])) { |
646 | 646 | return $metadata; |
647 | 647 | } else { |
648 | - $this->logger->warning('No supported descriptive metadata found for logical structure with @ID "' . $id . '"'); |
|
648 | + $this->logger->warning('No supported descriptive metadata found for logical structure with @ID "'.$id.'"'); |
|
649 | 649 | return []; |
650 | 650 | } |
651 | 651 | } |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | $dmdIds = $this->logicalUnits[$id]['dmdId'] ?? ''; |
671 | 671 | $admIds = $this->logicalUnits[$id]['admId'] ?? ''; |
672 | 672 | } else { |
673 | - $mdSec = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $id . '"]')[0]; |
|
673 | + $mdSec = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]')[0]; |
|
674 | 674 | if ($mdSec) { |
675 | 675 | $dmdIds = (string) $mdSec->attributes()->DMDID; |
676 | 676 | $admIds = (string) $mdSec->attributes()->ADMID; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | } |
699 | 699 | } |
700 | 700 | |
701 | - return array_filter($allMdIds, function ($element) { |
|
701 | + return array_filter($allMdIds, function($element) { |
|
702 | 702 | return !empty($element); |
703 | 703 | }); |
704 | 704 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | */ |
726 | 726 | public function getStructureDepth($logId) |
727 | 727 | { |
728 | - $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
|
728 | + $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$logId.'"]/ancestor::*'); |
|
729 | 729 | if (!empty($ancestors)) { |
730 | 730 | return count($ancestors); |
731 | 731 | } else { |
@@ -749,9 +749,9 @@ discard block |
||
749 | 749 | $this->registerNamespaces($this->mets); |
750 | 750 | } else { |
751 | 751 | if (!empty($location)) { |
752 | - $this->logger->error('No METS part found in document with location "' . $location . '".'); |
|
752 | + $this->logger->error('No METS part found in document with location "'.$location.'".'); |
|
753 | 753 | } else if (!empty($this->recordId)) { |
754 | - $this->logger->error('No METS part found in document with recordId "' . $this->recordId . '".'); |
|
754 | + $this->logger->error('No METS part found in document with recordId "'.$this->recordId.'".'); |
|
755 | 755 | } else { |
756 | 756 | $this->logger->error('No METS part found in current document.'); |
757 | 757 | } |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | return true; |
774 | 774 | } |
775 | 775 | } |
776 | - $this->logger->error('Could not load XML file from "' . $location . '"'); |
|
776 | + $this->logger->error('Could not load XML file from "'.$location.'"'); |
|
777 | 777 | return false; |
778 | 778 | } |
779 | 779 | |
@@ -888,12 +888,12 @@ discard block |
||
888 | 888 | if ($type = $element->xpath('./mets:mdWrap[not(@MDTYPE="OTHER")]/@MDTYPE')) { |
889 | 889 | if (!empty($this->formats[(string) $type[0]])) { |
890 | 890 | $type = (string) $type[0]; |
891 | - $xml = $element->xpath('./mets:mdWrap[@MDTYPE="' . $type . '"]/mets:xmlData/' . strtolower($type) . ':' . $this->formats[$type]['rootElement']); |
|
891 | + $xml = $element->xpath('./mets:mdWrap[@MDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
892 | 892 | } |
893 | 893 | } elseif ($type = $element->xpath('./mets:mdWrap[@MDTYPE="OTHER"]/@OTHERMDTYPE')) { |
894 | 894 | if (!empty($this->formats[(string) $type[0]])) { |
895 | 895 | $type = (string) $type[0]; |
896 | - $xml = $element->xpath('./mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="' . $type . '"]/mets:xmlData/' . strtolower($type) . ':' . $this->formats[$type]['rootElement']); |
|
896 | + $xml = $element->xpath('./mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | // Retain current PID. |
1101 | 1101 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
1102 | 1102 | if (!$cPid) { |
1103 | - $this->logger->error('Invalid PID ' . $cPid . ' for structure definitions'); |
|
1103 | + $this->logger->error('Invalid PID '.$cPid.' for structure definitions'); |
|
1104 | 1104 | $this->thumbnailLoaded = true; |
1105 | 1105 | return $this->thumbnail; |
1106 | 1106 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | if (!empty($resArray['thumbnail'])) { |
1138 | 1138 | $strctType = Helper::getIndexNameFromUid($resArray['thumbnail'], 'tx_dlf_structures', $cPid); |
1139 | 1139 | // Check if this document has a structure element of the desired type. |
1140 | - $strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="' . $strctType . '"]/@ID'); |
|
1140 | + $strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="'.$strctType.'"]/@ID'); |
|
1141 | 1141 | if (!empty($strctIds)) { |
1142 | 1142 | $strctId = (string) $strctIds[0]; |
1143 | 1143 | } |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | } |
1161 | 1161 | } |
1162 | 1162 | } else { |
1163 | - $this->logger->error('No structure of type "' . $metadata['type'][0] . '" found in database'); |
|
1163 | + $this->logger->error('No structure of type "'.$metadata['type'][0].'" found in database'); |
|
1164 | 1164 | } |
1165 | 1165 | $this->thumbnailLoaded = true; |
1166 | 1166 | } |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | $this->parentHref = ''; |
1208 | 1208 | |
1209 | 1209 | // Get the closest ancestor of the current document which has a MPTR child. |
1210 | - $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->toplevelId . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
|
1210 | + $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$this->toplevelId.'"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
|
1211 | 1211 | if (!empty($parentMptr)) { |
1212 | 1212 | $this->parentHref = (string) $parentMptr[0]->attributes('http://www.w3.org/1999/xlink')->href; |
1213 | 1213 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @var bool |
96 | 96 | * @access protected |
97 | 97 | */ |
98 | - protected $mdSecLoaded = false; |
|
98 | + protected $mdSecLoaded = FALSE; |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Subset of $mdSec storing only the dmdSec entries; kept for compatibility. |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @var bool |
130 | 130 | * @access protected |
131 | 131 | */ |
132 | - protected $fileGrpsLoaded = false; |
|
132 | + protected $fileGrpsLoaded = FALSE; |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Additional information about files (e.g., ADMID), indexed by ID. |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']); |
224 | 224 | IiifHelper::setMaxThumbnailWidth($conf['iiifThumbnailWidth']); |
225 | 225 | $service = IiifHelper::loadIiifResource($fileLocation); |
226 | - if ($service !== null && $service instanceof AbstractImageService) { |
|
226 | + if ($service !== NULL && $service instanceof AbstractImageService) { |
|
227 | 227 | return $service->getImageUrl(); |
228 | 228 | } |
229 | 229 | } elseif ($fileMimeType === 'application/vnd.netfpx') { |
230 | - $baseURL = $fileLocation . (strpos($fileLocation, '?') === false ? '?' : ''); |
|
230 | + $baseURL = $fileLocation . (strpos($fileLocation, '?') === FALSE ? '?' : ''); |
|
231 | 231 | // TODO CVT is an optional IIP server capability; in theory, capabilities should be determined in the object request with '&obj=IIP-server' |
232 | 232 | return $baseURL . '&CVT=jpeg'; |
233 | 233 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * {@inheritDoc} |
275 | 275 | * @see \Kitodo\Dlf\Common\Doc::getLogicalStructure() |
276 | 276 | */ |
277 | - public function getLogicalStructure($id, $recursive = false) |
|
277 | + public function getLogicalStructure($id, $recursive = FALSE) |
|
278 | 278 | { |
279 | 279 | $details = []; |
280 | 280 | // Is the requested logical unit already loaded? |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
317 | 317 | */ |
318 | - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) |
|
318 | + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = FALSE) |
|
319 | 319 | { |
320 | 320 | // Get attributes. |
321 | 321 | foreach ($structure->attributes() as $attribute => $value) { |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | && array_key_exists($details['id'], $this->smLinks['l2p']) |
362 | 362 | ) { |
363 | 363 | // Link logical structure to the first corresponding physical page/track. |
364 | - $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, true)), 1); |
|
364 | + $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE)), 1); |
|
365 | 365 | $fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']); |
366 | 366 | while ($fileGrpThumb = array_shift($fileGrpsThumb)) { |
367 | 367 | if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$fileGrpThumb])) { |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $details['children'] = []; |
406 | 406 | foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) { |
407 | 407 | // Repeat for all children. |
408 | - $details['children'][] = $this->getLogicalStructureInfo($child, true); |
|
408 | + $details['children'][] = $this->getLogicalStructureInfo($child, TRUE); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | return $details; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
637 | - $hasMetadataSection[$mdSectionType] = true; |
|
637 | + $hasMetadataSection[$mdSectionType] = TRUE; |
|
638 | 638 | } |
639 | 639 | // Set title to empty string if not present. |
640 | 640 | if (empty($metadata['title'][0])) { |
@@ -765,16 +765,16 @@ discard block |
||
765 | 765 | protected function loadLocation($location) |
766 | 766 | { |
767 | 767 | $fileResource = Helper::getUrl($location); |
768 | - if ($fileResource !== false) { |
|
768 | + if ($fileResource !== FALSE) { |
|
769 | 769 | $xml = Helper::getXmlFileAsString($fileResource); |
770 | 770 | // Set some basic properties. |
771 | - if ($xml !== false) { |
|
771 | + if ($xml !== FALSE) { |
|
772 | 772 | $this->xml = $xml; |
773 | - return true; |
|
773 | + return TRUE; |
|
774 | 774 | } |
775 | 775 | } |
776 | 776 | $this->logger->error('Could not load XML file from "' . $location . '"'); |
777 | - return false; |
|
777 | + return FALSE; |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -798,9 +798,9 @@ discard block |
||
798 | 798 | |
799 | 799 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
800 | 800 | $this->xml = $preloadedDocument; |
801 | - return true; |
|
801 | + return TRUE; |
|
802 | 802 | } |
803 | - return false; |
|
803 | + return FALSE; |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | foreach ($this->mets->xpath('./mets:dmdSec') as $dmdSecTag) { |
828 | 828 | $dmdSec = $this->processMdSec($dmdSecTag); |
829 | 829 | |
830 | - if ($dmdSec !== null) { |
|
830 | + if ($dmdSec !== NULL) { |
|
831 | 831 | $this->mdSec[$dmdSec['id']] = $dmdSec; |
832 | 832 | $this->dmdSec[$dmdSec['id']] = $dmdSec; |
833 | 833 | } |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | // TODO: Should we check that the format may occur within this type (e.g., to ignore VIDEOMD within rightsMD)? |
845 | 845 | $mdSec = $this->processMdSec($mdSecTag); |
846 | 846 | |
847 | - if ($mdSec !== null) { |
|
847 | + if ($mdSec !== NULL) { |
|
848 | 848 | $this->mdSec[$mdSec['id']] = $mdSec; |
849 | 849 | |
850 | 850 | $childIds[] = $mdSec['id']; |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | } |
858 | 858 | } |
859 | 859 | |
860 | - $this->mdSecLoaded = true; |
|
860 | + $this->mdSecLoaded = TRUE; |
|
861 | 861 | } |
862 | 862 | return $this->mdSec; |
863 | 863 | } |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | { |
882 | 882 | $mdId = (string) $element->attributes()->ID; |
883 | 883 | if (empty($mdId)) { |
884 | - return null; |
|
884 | + return NULL; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | $this->registerNamespaces($element); |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | } |
899 | 899 | |
900 | 900 | if (empty($xml)) { |
901 | - return null; |
|
901 | + return NULL; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | $this->registerNamespaces($xml[0]); |
@@ -959,9 +959,9 @@ discard block |
||
959 | 959 | !empty($extConf['fileGrpFulltext']) |
960 | 960 | && array_intersect(GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']), $this->fileGrps) !== [] |
961 | 961 | ) { |
962 | - $this->hasFulltext = true; |
|
962 | + $this->hasFulltext = TRUE; |
|
963 | 963 | } |
964 | - $this->fileGrpsLoaded = true; |
|
964 | + $this->fileGrpsLoaded = TRUE; |
|
965 | 965 | } |
966 | 966 | return $this->fileGrps; |
967 | 967 | } |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | $this->physicalStructure = array_merge($physSeq, $elements); |
1064 | 1064 | } |
1065 | 1065 | } |
1066 | - $this->physicalStructureLoaded = true; |
|
1066 | + $this->physicalStructureLoaded = TRUE; |
|
1067 | 1067 | } |
1068 | 1068 | return $this->physicalStructure; |
1069 | 1069 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | $this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from; |
1083 | 1083 | } |
1084 | 1084 | } |
1085 | - $this->smLinksLoaded = true; |
|
1085 | + $this->smLinksLoaded = TRUE; |
|
1086 | 1086 | } |
1087 | 1087 | return $this->smLinks; |
1088 | 1088 | } |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | * {@inheritDoc} |
1092 | 1092 | * @see \Kitodo\Dlf\Common\Doc::_getThumbnail() |
1093 | 1093 | */ |
1094 | - protected function _getThumbnail($forceReload = false) |
|
1094 | + protected function _getThumbnail($forceReload = FALSE) |
|
1095 | 1095 | { |
1096 | 1096 | if ( |
1097 | 1097 | !$this->thumbnailLoaded |
@@ -1101,14 +1101,14 @@ discard block |
||
1101 | 1101 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
1102 | 1102 | if (!$cPid) { |
1103 | 1103 | $this->logger->error('Invalid PID ' . $cPid . ' for structure definitions'); |
1104 | - $this->thumbnailLoaded = true; |
|
1104 | + $this->thumbnailLoaded = TRUE; |
|
1105 | 1105 | return $this->thumbnail; |
1106 | 1106 | } |
1107 | 1107 | // Load extension configuration. |
1108 | 1108 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
1109 | 1109 | if (empty($extConf['fileGrpThumbs'])) { |
1110 | 1110 | $this->logger->warning('No fileGrp for thumbnails specified'); |
1111 | - $this->thumbnailLoaded = true; |
|
1111 | + $this->thumbnailLoaded = TRUE; |
|
1112 | 1112 | return $this->thumbnail; |
1113 | 1113 | } |
1114 | 1114 | $strctId = $this->_getToplevelId(); |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | } else { |
1163 | 1163 | $this->logger->error('No structure of type "' . $metadata['type'][0] . '" found in database'); |
1164 | 1164 | } |
1165 | - $this->thumbnailLoaded = true; |
|
1165 | + $this->thumbnailLoaded = TRUE; |
|
1166 | 1166 | } |
1167 | 1167 | return $this->thumbnail; |
1168 | 1168 | } |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | */ |
1204 | 1204 | public function _getParentHref() |
1205 | 1205 | { |
1206 | - if ($this->parentHref === null) { |
|
1206 | + if ($this->parentHref === NULL) { |
|
1207 | 1207 | $this->parentHref = ''; |
1208 | 1208 | |
1209 | 1209 | // Get the closest ancestor of the current document which has a MPTR child. |
@@ -1241,8 +1241,8 @@ discard block |
||
1241 | 1241 | public function __toString() |
1242 | 1242 | { |
1243 | 1243 | $xml = new \DOMDocument('1.0', 'utf-8'); |
1244 | - $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
|
1245 | - $xml->formatOutput = true; |
|
1244 | + $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE)); |
|
1245 | + $xml->formatOutput = TRUE; |
|
1246 | 1246 | return $xml->saveXML(); |
1247 | 1247 | } |
1248 | 1248 | |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | public function __wakeup() |
1258 | 1258 | { |
1259 | 1259 | $xml = Helper::getXmlFileAsString($this->asXML); |
1260 | - if ($xml !== false) { |
|
1260 | + if ($xml !== FALSE) { |
|
1261 | 1261 | $this->asXML = ''; |
1262 | 1262 | $this->xml = $xml; |
1263 | 1263 | // Rebuild the unserializable properties. |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * @property-read string $toplevelId This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF) |
51 | 51 | * @property-read string $parentHref URL of the parent document (determined via mptr element), or empty string if none is available |
52 | 52 | */ |
53 | -final class MetsDocument extends Doc |
|
54 | -{ |
|
53 | +final class MetsDocument extends Doc { |
|
55 | 54 | /** |
56 | 55 | * Subsections / tags that may occur within `<mets:amdSec>`. |
57 | 56 | * |
@@ -176,8 +175,7 @@ discard block |
||
176 | 175 | * |
177 | 176 | * @return void |
178 | 177 | */ |
179 | - public function addMetadataFromMets(&$metadata, $id) |
|
180 | - { |
|
178 | + public function addMetadataFromMets(&$metadata, $id) { |
|
181 | 179 | $details = $this->getLogicalStructure($id); |
182 | 180 | if (!empty($details)) { |
183 | 181 | $metadata['mets_order'][0] = $details['order']; |
@@ -191,8 +189,7 @@ discard block |
||
191 | 189 | * {@inheritDoc} |
192 | 190 | * @see \Kitodo\Dlf\Common\Doc::establishRecordId() |
193 | 191 | */ |
194 | - protected function establishRecordId($pid) |
|
195 | - { |
|
192 | + protected function establishRecordId($pid) { |
|
196 | 193 | // Check for METS object @ID. |
197 | 194 | if (!empty($this->mets['OBJID'])) { |
198 | 195 | $this->recordId = (string) $this->mets['OBJID']; |
@@ -212,8 +209,7 @@ discard block |
||
212 | 209 | * {@inheritDoc} |
213 | 210 | * @see \Kitodo\Dlf\Common\Doc::getDownloadLocation() |
214 | 211 | */ |
215 | - public function getDownloadLocation($id) |
|
216 | - { |
|
212 | + public function getDownloadLocation($id) { |
|
217 | 213 | $fileMimeType = $this->getFileMimeType($id); |
218 | 214 | $fileLocation = $this->getFileLocation($id); |
219 | 215 | if ($fileMimeType === 'application/vnd.kitodo.iiif') { |
@@ -238,8 +234,7 @@ discard block |
||
238 | 234 | * {@inheritDoc} |
239 | 235 | * @see \Kitodo\Dlf\Common\Doc::getFileLocation() |
240 | 236 | */ |
241 | - public function getFileLocation($id) |
|
242 | - { |
|
237 | + public function getFileLocation($id) { |
|
243 | 238 | $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]'); |
244 | 239 | if ( |
245 | 240 | !empty($id) |
@@ -256,8 +251,7 @@ discard block |
||
256 | 251 | * {@inheritDoc} |
257 | 252 | * @see \Kitodo\Dlf\Common\Doc::getFileMimeType() |
258 | 253 | */ |
259 | - public function getFileMimeType($id) |
|
260 | - { |
|
254 | + public function getFileMimeType($id) { |
|
261 | 255 | $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/@MIMETYPE'); |
262 | 256 | if ( |
263 | 257 | !empty($id) |
@@ -274,8 +268,7 @@ discard block |
||
274 | 268 | * {@inheritDoc} |
275 | 269 | * @see \Kitodo\Dlf\Common\Doc::getLogicalStructure() |
276 | 270 | */ |
277 | - public function getLogicalStructure($id, $recursive = false) |
|
278 | - { |
|
271 | + public function getLogicalStructure($id, $recursive = false) { |
|
279 | 272 | $details = []; |
280 | 273 | // Is the requested logical unit already loaded? |
281 | 274 | if ( |
@@ -315,8 +308,7 @@ discard block |
||
315 | 308 | * |
316 | 309 | * @return array Array of the element's id, label, type and physical page indexes/mptr link |
317 | 310 | */ |
318 | - protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) |
|
319 | - { |
|
311 | + protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) { |
|
320 | 312 | // Get attributes. |
321 | 313 | foreach ($structure->attributes() as $attribute => $value) { |
322 | 314 | $attributes[$attribute] = (string) $value; |
@@ -420,8 +412,7 @@ discard block |
||
420 | 412 | * {@inheritDoc} |
421 | 413 | * @see \Kitodo\Dlf\Common\Doc::getMetadata() |
422 | 414 | */ |
423 | - public function getMetadata($id, $cPid = 0) |
|
424 | - { |
|
415 | + public function getMetadata($id, $cPid = 0) { |
|
425 | 416 | // Make sure $cPid is a non-negative integer. |
426 | 417 | $cPid = max(intval($cPid), 0); |
427 | 418 | // If $cPid is not given, try to get it elsewhere. |
@@ -675,8 +666,7 @@ discard block |
||
675 | 666 | * @param string $id: The "@ID" attribute of the file node |
676 | 667 | * @return void |
677 | 668 | */ |
678 | - protected function getMetadataIds($id) |
|
679 | - { |
|
669 | + protected function getMetadataIds($id) { |
|
680 | 670 | // Load amdSecChildIds concordance |
681 | 671 | $this->_getMdSec(); |
682 | 672 | $this->_getFileInfos(); |
@@ -723,8 +713,7 @@ discard block |
||
723 | 713 | * {@inheritDoc} |
724 | 714 | * @see \Kitodo\Dlf\Common\Doc::getFullText() |
725 | 715 | */ |
726 | - public function getFullText($id) |
|
727 | - { |
|
716 | + public function getFullText($id) { |
|
728 | 717 | $fullText = ''; |
729 | 718 | |
730 | 719 | // Load fileGrps and check for full text files. |
@@ -739,8 +728,7 @@ discard block |
||
739 | 728 | * {@inheritDoc} |
740 | 729 | * @see Doc::getStructureDepth() |
741 | 730 | */ |
742 | - public function getStructureDepth($logId) |
|
743 | - { |
|
731 | + public function getStructureDepth($logId) { |
|
744 | 732 | $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*'); |
745 | 733 | if (!empty($ancestors)) { |
746 | 734 | return count($ancestors); |
@@ -753,8 +741,7 @@ discard block |
||
753 | 741 | * {@inheritDoc} |
754 | 742 | * @see \Kitodo\Dlf\Common\Doc::init() |
755 | 743 | */ |
756 | - protected function init($location) |
|
757 | - { |
|
744 | + protected function init($location) { |
|
758 | 745 | $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_class($this)); |
759 | 746 | // Get METS node from XML file. |
760 | 747 | $this->registerNamespaces($this->xml); |
@@ -778,8 +765,7 @@ discard block |
||
778 | 765 | * {@inheritDoc} |
779 | 766 | * @see \Kitodo\Dlf\Common\Doc::loadLocation() |
780 | 767 | */ |
781 | - protected function loadLocation($location) |
|
782 | - { |
|
768 | + protected function loadLocation($location) { |
|
783 | 769 | $fileResource = Helper::getUrl($location); |
784 | 770 | if ($fileResource !== false) { |
785 | 771 | $xml = Helper::getXmlFileAsString($fileResource); |
@@ -797,8 +783,7 @@ discard block |
||
797 | 783 | * {@inheritDoc} |
798 | 784 | * @see \Kitodo\Dlf\Common\Doc::ensureHasFulltextIsSet() |
799 | 785 | */ |
800 | - protected function ensureHasFulltextIsSet() |
|
801 | - { |
|
786 | + protected function ensureHasFulltextIsSet() { |
|
802 | 787 | // Are the fileGrps already loaded? |
803 | 788 | if (!$this->fileGrpsLoaded) { |
804 | 789 | $this->_getFileGrps(); |
@@ -809,8 +794,7 @@ discard block |
||
809 | 794 | * {@inheritDoc} |
810 | 795 | * @see Doc::setPreloadedDocument() |
811 | 796 | */ |
812 | - protected function setPreloadedDocument($preloadedDocument) |
|
813 | - { |
|
797 | + protected function setPreloadedDocument($preloadedDocument) { |
|
814 | 798 | |
815 | 799 | if ($preloadedDocument instanceof \SimpleXMLElement) { |
816 | 800 | $this->xml = $preloadedDocument; |
@@ -823,8 +807,7 @@ discard block |
||
823 | 807 | * {@inheritDoc} |
824 | 808 | * @see Doc::getDocument() |
825 | 809 | */ |
826 | - protected function getDocument() |
|
827 | - { |
|
810 | + protected function getDocument() { |
|
828 | 811 | return $this->mets; |
829 | 812 | } |
830 | 813 | |
@@ -835,8 +818,7 @@ discard block |
||
835 | 818 | * |
836 | 819 | * @return array Array of metadata sections with their IDs as array key |
837 | 820 | */ |
838 | - protected function _getMdSec() |
|
839 | - { |
|
821 | + protected function _getMdSec() { |
|
840 | 822 | if (!$this->mdSecLoaded) { |
841 | 823 | $this->loadFormats(); |
842 | 824 | |
@@ -878,8 +860,7 @@ discard block |
||
878 | 860 | return $this->mdSec; |
879 | 861 | } |
880 | 862 | |
881 | - protected function _getDmdSec() |
|
882 | - { |
|
863 | + protected function _getDmdSec() { |
|
883 | 864 | $this->_getMdSec(); |
884 | 865 | return $this->dmdSec; |
885 | 866 | } |
@@ -893,8 +874,7 @@ discard block |
||
893 | 874 | * |
894 | 875 | * @return array|null The processed metadata section |
895 | 876 | */ |
896 | - protected function processMdSec($element) |
|
897 | - { |
|
877 | + protected function processMdSec($element) { |
|
898 | 878 | $mdId = (string) $element->attributes()->ID; |
899 | 879 | if (empty($mdId)) { |
900 | 880 | return null; |
@@ -934,8 +914,7 @@ discard block |
||
934 | 914 | * |
935 | 915 | * @return array Array of file use groups with file IDs |
936 | 916 | */ |
937 | - protected function _getFileGrps() |
|
938 | - { |
|
917 | + protected function _getFileGrps() { |
|
939 | 918 | if (!$this->fileGrpsLoaded) { |
940 | 919 | // Get configured USE attributes. |
941 | 920 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
@@ -987,8 +966,7 @@ discard block |
||
987 | 966 | * @access protected |
988 | 967 | * @return array |
989 | 968 | */ |
990 | - protected function _getFileInfos() |
|
991 | - { |
|
969 | + protected function _getFileInfos() { |
|
992 | 970 | $this->_getFileGrps(); |
993 | 971 | return $this->fileInfos; |
994 | 972 | } |
@@ -997,8 +975,7 @@ discard block |
||
997 | 975 | * {@inheritDoc} |
998 | 976 | * @see \Kitodo\Dlf\Common\Doc::prepareMetadataArray() |
999 | 977 | */ |
1000 | - protected function prepareMetadataArray($cPid) |
|
1001 | - { |
|
978 | + protected function prepareMetadataArray($cPid) { |
|
1002 | 979 | $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'); |
1003 | 980 | // Get all logical structure nodes with metadata. |
1004 | 981 | if (!empty($ids)) { |
@@ -1016,8 +993,7 @@ discard block |
||
1016 | 993 | * |
1017 | 994 | * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object |
1018 | 995 | */ |
1019 | - protected function _getMets() |
|
1020 | - { |
|
996 | + protected function _getMets() { |
|
1021 | 997 | return $this->mets; |
1022 | 998 | } |
1023 | 999 | |
@@ -1025,8 +1001,7 @@ discard block |
||
1025 | 1001 | * {@inheritDoc} |
1026 | 1002 | * @see \Kitodo\Dlf\Common\Doc::_getPhysicalStructure() |
1027 | 1003 | */ |
1028 | - protected function _getPhysicalStructure() |
|
1029 | - { |
|
1004 | + protected function _getPhysicalStructure() { |
|
1030 | 1005 | // Is there no physical structure array yet? |
1031 | 1006 | if (!$this->physicalStructureLoaded) { |
1032 | 1007 | // Does the document have a structMap node of type "PHYSICAL"? |
@@ -1088,8 +1063,7 @@ discard block |
||
1088 | 1063 | * {@inheritDoc} |
1089 | 1064 | * @see \Kitodo\Dlf\Common\Doc::_getSmLinks() |
1090 | 1065 | */ |
1091 | - protected function _getSmLinks() |
|
1092 | - { |
|
1066 | + protected function _getSmLinks() { |
|
1093 | 1067 | if (!$this->smLinksLoaded) { |
1094 | 1068 | $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
1095 | 1069 | if (!empty($smLinks)) { |
@@ -1107,8 +1081,7 @@ discard block |
||
1107 | 1081 | * {@inheritDoc} |
1108 | 1082 | * @see \Kitodo\Dlf\Common\Doc::_getThumbnail() |
1109 | 1083 | */ |
1110 | - protected function _getThumbnail($forceReload = false) |
|
1111 | - { |
|
1084 | + protected function _getThumbnail($forceReload = false) { |
|
1112 | 1085 | if ( |
1113 | 1086 | !$this->thumbnailLoaded |
1114 | 1087 | || $forceReload |
@@ -1187,8 +1160,7 @@ discard block |
||
1187 | 1160 | * {@inheritDoc} |
1188 | 1161 | * @see \Kitodo\Dlf\Common\Doc::_getToplevelId() |
1189 | 1162 | */ |
1190 | - protected function _getToplevelId() |
|
1191 | - { |
|
1163 | + protected function _getToplevelId() { |
|
1192 | 1164 | if (empty($this->toplevelId)) { |
1193 | 1165 | // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
1194 | 1166 | $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'); |
@@ -1217,8 +1189,7 @@ discard block |
||
1217 | 1189 | * |
1218 | 1190 | * @return string|null |
1219 | 1191 | */ |
1220 | - public function _getParentHref() |
|
1221 | - { |
|
1192 | + public function _getParentHref() { |
|
1222 | 1193 | if ($this->parentHref === null) { |
1223 | 1194 | $this->parentHref = ''; |
1224 | 1195 | |
@@ -1240,8 +1211,7 @@ discard block |
||
1240 | 1211 | * |
1241 | 1212 | * @return array Properties to be serialized |
1242 | 1213 | */ |
1243 | - public function __sleep() |
|
1244 | - { |
|
1214 | + public function __sleep() { |
|
1245 | 1215 | // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
1246 | 1216 | $this->asXML = $this->xml->asXML(); |
1247 | 1217 | return ['uid', 'pid', 'recordId', 'parentId', 'asXML']; |
@@ -1254,8 +1224,7 @@ discard block |
||
1254 | 1224 | * |
1255 | 1225 | * @return string String representing the METS object |
1256 | 1226 | */ |
1257 | - public function __toString() |
|
1258 | - { |
|
1227 | + public function __toString() { |
|
1259 | 1228 | $xml = new \DOMDocument('1.0', 'utf-8'); |
1260 | 1229 | $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true)); |
1261 | 1230 | $xml->formatOutput = true; |
@@ -1270,8 +1239,7 @@ discard block |
||
1270 | 1239 | * |
1271 | 1240 | * @return void |
1272 | 1241 | */ |
1273 | - public function __wakeup() |
|
1274 | - { |
|
1242 | + public function __wakeup() { |
|
1275 | 1243 | $xml = Helper::getXmlFileAsString($this->asXML); |
1276 | 1244 | if ($xml !== false) { |
1277 | 1245 | $this->asXML = ''; |
@@ -33,8 +33,7 @@ discard block |
||
33 | 33 | * @param array $searchParams |
34 | 34 | * @param QueryResult $listedMetadata |
35 | 35 | */ |
36 | - public function __construct($documentRepository, $collection, $settings, $searchParams, $listedMetadata = null) |
|
37 | - { |
|
36 | + public function __construct($documentRepository, $collection, $settings, $searchParams, $listedMetadata = null) { |
|
38 | 37 | $this->documentRepository = $documentRepository; |
39 | 38 | $this->collection = $collection; |
40 | 39 | $this->settings = $settings; |
@@ -42,13 +41,11 @@ discard block |
||
42 | 41 | $this->listedMetadata = $listedMetadata; |
43 | 42 | } |
44 | 43 | |
45 | - public function getNumLoadedDocuments() |
|
46 | - { |
|
44 | + public function getNumLoadedDocuments() { |
|
47 | 45 | return count($this->result['documents']); |
48 | 46 | } |
49 | 47 | |
50 | - public function count() |
|
51 | - { |
|
48 | + public function count() { |
|
52 | 49 | if ($this->result === null) { |
53 | 50 | return 0; |
54 | 51 | } |
@@ -56,39 +53,32 @@ discard block |
||
56 | 53 | return $this->result['numberOfToplevels']; |
57 | 54 | } |
58 | 55 | |
59 | - public function current() |
|
60 | - { |
|
56 | + public function current() { |
|
61 | 57 | return $this[$this->position]; |
62 | 58 | } |
63 | 59 | |
64 | - public function key() |
|
65 | - { |
|
60 | + public function key() { |
|
66 | 61 | return $this->position; |
67 | 62 | } |
68 | 63 | |
69 | - public function next() |
|
70 | - { |
|
64 | + public function next() { |
|
71 | 65 | $this->position++; |
72 | 66 | } |
73 | 67 | |
74 | - public function rewind() |
|
75 | - { |
|
68 | + public function rewind() { |
|
76 | 69 | $this->position = 0; |
77 | 70 | } |
78 | 71 | |
79 | - public function valid() |
|
80 | - { |
|
72 | + public function valid() { |
|
81 | 73 | return isset($this[$this->position]); |
82 | 74 | } |
83 | 75 | |
84 | - public function offsetExists($offset) |
|
85 | - { |
|
76 | + public function offsetExists($offset) { |
|
86 | 77 | $idx = $this->result['document_keys'][$offset]; |
87 | 78 | return isset($this->result['documents'][$idx]); |
88 | 79 | } |
89 | 80 | |
90 | - public function offsetGet($offset) |
|
91 | - { |
|
81 | + public function offsetGet($offset) { |
|
92 | 82 | $idx = $this->result['document_keys'][$offset]; |
93 | 83 | $document = $this->result['documents'][$idx] ?? null; |
94 | 84 | |
@@ -116,38 +106,31 @@ discard block |
||
116 | 106 | return $document; |
117 | 107 | } |
118 | 108 | |
119 | - public function offsetSet($offset, $value) |
|
120 | - { |
|
109 | + public function offsetSet($offset, $value) { |
|
121 | 110 | throw new \Exception("SolrSearch: Modifying result list is not supported"); |
122 | 111 | } |
123 | 112 | |
124 | - public function offsetUnset($offset) |
|
125 | - { |
|
113 | + public function offsetUnset($offset) { |
|
126 | 114 | throw new \Exception("SolrSearch: Modifying result list is not supported"); |
127 | 115 | } |
128 | 116 | |
129 | - public function getSolrResults() |
|
130 | - { |
|
117 | + public function getSolrResults() { |
|
131 | 118 | return $this->result['solrResults']; |
132 | 119 | } |
133 | 120 | |
134 | - public function getByUid($uid) |
|
135 | - { |
|
121 | + public function getByUid($uid) { |
|
136 | 122 | return $this->result['documents'][$uid]; |
137 | 123 | } |
138 | 124 | |
139 | - public function getQuery() |
|
140 | - { |
|
125 | + public function getQuery() { |
|
141 | 126 | return new SolrSearchQuery($this); |
142 | 127 | } |
143 | 128 | |
144 | - public function getFirst() |
|
145 | - { |
|
129 | + public function getFirst() { |
|
146 | 130 | return $this[0]; |
147 | 131 | } |
148 | 132 | |
149 | - public function toArray() |
|
150 | - { |
|
133 | + public function toArray() { |
|
151 | 134 | return array_values($this->result['documents']); |
152 | 135 | } |
153 | 136 | |
@@ -156,13 +139,11 @@ discard block |
||
156 | 139 | * |
157 | 140 | * This can be accessed in Fluid template using `.numFound`. |
158 | 141 | */ |
159 | - public function getNumFound() |
|
160 | - { |
|
142 | + public function getNumFound() { |
|
161 | 143 | return $this->result['numFound']; |
162 | 144 | } |
163 | 145 | |
164 | - public function prepare() |
|
165 | - { |
|
146 | + public function prepare() { |
|
166 | 147 | // Prepare query parameters. |
167 | 148 | $params = []; |
168 | 149 | $matches = []; |
@@ -285,8 +266,7 @@ discard block |
||
285 | 266 | $this->submit(0, 1, false); |
286 | 267 | } |
287 | 268 | |
288 | - public function submit($start, $rows, $processResults = true) |
|
289 | - { |
|
269 | + public function submit($start, $rows, $processResults = true) { |
|
290 | 270 | $params = $this->params; |
291 | 271 | $params['start'] = $start; |
292 | 272 | $params['rows'] = $rows; |
@@ -383,8 +363,7 @@ discard block |
||
383 | 363 | * @param int $queryParams |
384 | 364 | * @return array |
385 | 365 | */ |
386 | - protected function fetchToplevelMetadataFromSolr($queryParams) |
|
387 | - { |
|
366 | + protected function fetchToplevelMetadataFromSolr($queryParams) { |
|
388 | 367 | // Prepare query parameters. |
389 | 368 | $params = $queryParams; |
390 | 369 | $metadataArray = []; |
@@ -427,8 +406,7 @@ discard block |
||
427 | 406 | * |
428 | 407 | * @return array The Apache Solr Documents that were fetched |
429 | 408 | */ |
430 | - protected function searchSolr($parameters = [], $enableCache = true) |
|
431 | - { |
|
409 | + protected function searchSolr($parameters = [], $enableCache = true) { |
|
432 | 410 | // Set query. |
433 | 411 | $parameters['query'] = isset($parameters['query']) ? $parameters['query'] : '*'; |
434 | 412 | $parameters['filterquery'] = isset($parameters['filterquery']) ? $parameters['filterquery'] : []; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $searchParams |
35 | 35 | * @param QueryResult $listedMetadata |
36 | 36 | */ |
37 | - public function __construct($documentRepository, $collection, $settings, $searchParams, $listedMetadata = null) |
|
37 | + public function __construct($documentRepository, $collection, $settings, $searchParams, $listedMetadata = NULL) |
|
38 | 38 | { |
39 | 39 | $this->documentRepository = $documentRepository; |
40 | 40 | $this->collection = $collection; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | public function count() |
52 | 52 | { |
53 | - if ($this->result === null) { |
|
53 | + if ($this->result === NULL) { |
|
54 | 54 | return 0; |
55 | 55 | } |
56 | 56 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | public function offsetGet($offset) |
92 | 92 | { |
93 | 93 | $idx = $this->result['document_keys'][$offset]; |
94 | - $document = $this->result['documents'][$idx] ?? null; |
|
94 | + $document = $this->result['documents'][$idx] ?? NULL; |
|
95 | 95 | |
96 | - if ($document !== null) { |
|
96 | + if ($document !== NULL) { |
|
97 | 97 | // It may happen that a Solr group only includes non-toplevel results, |
98 | 98 | // in which case metadata of toplevel entry isn't yet filled. |
99 | 99 | if (empty($document['metadata'])) { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | // get title of parent/grandparent/... if empty |
109 | 109 | if (empty($document['title']) && $document['partOf'] > 0) { |
110 | - $superiorTitle = Doc::getTitle($document['partOf'], true); |
|
110 | + $superiorTitle = Doc::getTitle($document['partOf'], TRUE); |
|
111 | 111 | if (!empty($superiorTitle)) { |
112 | 112 | $document['title'] = '[' . $superiorTitle . ']'; |
113 | 113 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if (!empty($this->searchParams['query'])) { |
181 | 181 | $query = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($this->searchParams['query'])) . ')'; |
182 | 182 | } |
183 | - $params['fulltext'] = true; |
|
183 | + $params['fulltext'] = TRUE; |
|
184 | 184 | } else { |
185 | 185 | // Retain given search field if valid. |
186 | 186 | if (!empty($this->searchParams['query'])) { |
@@ -289,17 +289,17 @@ discard block |
||
289 | 289 | $this->params = $params; |
290 | 290 | |
291 | 291 | // Send off query to get total number of search results in advance |
292 | - $this->submit(0, 1, false); |
|
292 | + $this->submit(0, 1, FALSE); |
|
293 | 293 | } |
294 | 294 | |
295 | - public function submit($start, $rows, $processResults = true) |
|
295 | + public function submit($start, $rows, $processResults = TRUE) |
|
296 | 296 | { |
297 | 297 | $params = $this->params; |
298 | 298 | $params['start'] = $start; |
299 | 299 | $params['rows'] = $rows; |
300 | 300 | |
301 | 301 | // Perform search. |
302 | - $result = $this->searchSolr($params, true); |
|
302 | + $result = $this->searchSolr($params, TRUE); |
|
303 | 303 | |
304 | 304 | // Initialize values |
305 | 305 | $documents = []; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $doc['metadata']['language'][$indexName] = Helper::getLanguageName($doc['metadata']['language'][$indexName]); |
330 | 330 | } |
331 | 331 | } |
332 | - if ($doc['toplevel'] === false) { |
|
332 | + if ($doc['toplevel'] === FALSE) { |
|
333 | 333 | // this maybe a chapter, article, ..., year |
334 | 334 | if ($doc['type'] === 'year') { |
335 | 335 | continue; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | $documents[$doc['uid']]['searchResults'][] = $searchResult; |
355 | 355 | } |
356 | - } else if ($doc['toplevel'] === true) { |
|
356 | + } else if ($doc['toplevel'] === TRUE) { |
|
357 | 357 | foreach ($params['listMetadataRecords'] as $indexName => $solrField) { |
358 | 358 | if (isset($doc['metadata'][$indexName])) { |
359 | 359 | $documents[$doc['uid']]['metadata'][$indexName] = $doc['metadata'][$indexName]; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $params['filterquery'][] = ['query' => 'toplevel:true']; |
422 | 422 | |
423 | 423 | // Perform search. |
424 | - $result = $this->searchSolr($params, true); |
|
424 | + $result = $this->searchSolr($params, TRUE); |
|
425 | 425 | |
426 | 426 | foreach ($result['documents'] as $doc) { |
427 | 427 | // translate language code if applicable |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return array The Apache Solr Documents that were fetched |
448 | 448 | */ |
449 | - protected function searchSolr($parameters = [], $enableCache = true) |
|
449 | + protected function searchSolr($parameters = [], $enableCache = TRUE) |
|
450 | 450 | { |
451 | 451 | // Set query. |
452 | 452 | $parameters['query'] = isset($parameters['query']) ? $parameters['query'] : '*'; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | $cacheIdentifier = ''; |
468 | - $cache = null; |
|
468 | + $cache = NULL; |
|
469 | 469 | // Calculate cache identifier. |
470 | - if ($enableCache === true) { |
|
471 | - $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, true)); |
|
470 | + if ($enableCache === TRUE) { |
|
471 | + $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, TRUE)); |
|
472 | 472 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
473 | 473 | } |
474 | 474 | $resultSet = [ |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | 'numberOfToplevels' => 0, |
477 | 477 | 'numFound' => 0, |
478 | 478 | ]; |
479 | - if ($enableCache === false || ($entry = $cache->get($cacheIdentifier)) === false) { |
|
479 | + if ($enableCache === FALSE || ($entry = $cache->get($cacheIdentifier)) === FALSE) { |
|
480 | 480 | $selectQuery = $solr->service->createSelect($parameters); |
481 | 481 | |
482 | 482 | $grouping = $selectQuery->getGrouping(); |
483 | 483 | $grouping->addField('uid'); |
484 | 484 | $grouping->setLimit(100); // Results in group (TODO: check) |
485 | - $grouping->setNumberOfGroups(true); |
|
485 | + $grouping->setNumberOfGroups(TRUE); |
|
486 | 486 | |
487 | - if ($parameters['fulltext'] === true) { |
|
487 | + if ($parameters['fulltext'] === TRUE) { |
|
488 | 488 | // get highlighting component and apply settings |
489 | 489 | $selectQuery->getHighlighting(); |
490 | 490 | } |
491 | 491 | |
492 | 492 | $solrRequest = $solr->service->createRequest($selectQuery); |
493 | 493 | |
494 | - if ($parameters['fulltext'] === true) { |
|
494 | + if ($parameters['fulltext'] === TRUE) { |
|
495 | 495 | // If it is a fulltext search, enable highlighting. |
496 | 496 | // field for which highlighting is going to be performed, |
497 | 497 | // is required if you want to have OCR highlighting |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $resultSet['numberOfToplevels'] = $uidGroup->getNumberOfGroups(); |
513 | 513 | $resultSet['numFound'] = $uidGroup->getMatches(); |
514 | 514 | $highlighting = []; |
515 | - if ($parameters['fulltext'] === true) { |
|
515 | + if ($parameters['fulltext'] === TRUE) { |
|
516 | 516 | $data = $result->getData(); |
517 | 517 | $highlighting = $data['ocrHighlighting']; |
518 | 518 | } |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | } |
544 | 544 | |
545 | 545 | // Save value in cache. |
546 | - if (!empty($resultSet) && $enableCache === true) { |
|
546 | + if (!empty($resultSet) && $enableCache === TRUE) { |
|
547 | 547 | $cache->set($cacheIdentifier, $resultSet); |
548 | 548 | } |
549 | 549 | } else { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // in which case metadata of toplevel entry isn't yet filled. |
99 | 99 | if (empty($document['metadata'])) { |
100 | 100 | $document['metadata'] = $this->fetchToplevelMetadataFromSolr([ |
101 | - 'query' => 'uid:' . $document['uid'], |
|
101 | + 'query' => 'uid:'.$document['uid'], |
|
102 | 102 | 'start' => 0, |
103 | 103 | 'rows' => 1, |
104 | 104 | 'sort' => ['score' => 'desc'], |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | if (empty($document['title']) && $document['partOf'] > 0) { |
110 | 110 | $superiorTitle = Doc::getTitle($document['partOf'], true); |
111 | 111 | if (!empty($superiorTitle)) { |
112 | - $document['title'] = '[' . $superiorTitle . ']'; |
|
112 | + $document['title'] = '['.$superiorTitle.']'; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | // Set search query. |
173 | 173 | if ( |
174 | 174 | (!empty($this->searchParams['fulltext'])) |
175 | - || preg_match('/' . $fields['fulltext'] . ':\((.*)\)/', trim($this->searchParams['query']), $matches) |
|
175 | + || preg_match('/'.$fields['fulltext'].':\((.*)\)/', trim($this->searchParams['query']), $matches) |
|
176 | 176 | ) { |
177 | 177 | // If the query already is a fulltext query e.g using the facets |
178 | 178 | $this->searchParams['query'] = empty($matches[1]) ? $this->searchParams['query'] : $matches[1]; |
179 | 179 | // Search in fulltext field if applicable. Query must not be empty! |
180 | 180 | if (!empty($this->searchParams['query'])) { |
181 | - $query = $fields['fulltext'] . ':(' . Solr::escapeQuery(trim($this->searchParams['query'])) . ')'; |
|
181 | + $query = $fields['fulltext'].':('.Solr::escapeQuery(trim($this->searchParams['query'])).')'; |
|
182 | 182 | } |
183 | 183 | $params['fulltext'] = true; |
184 | 184 | } else { |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | in_array($this->searchParams['extOperator'][$i], $allowedOperators) |
202 | 202 | ) { |
203 | 203 | if (!empty($query)) { |
204 | - $query .= ' ' . $this->searchParams['extOperator'][$i] . ' '; |
|
204 | + $query .= ' '.$this->searchParams['extOperator'][$i].' '; |
|
205 | 205 | } |
206 | - $query .= Indexer::getIndexFieldName($this->searchParams['extField'][$i], $this->settings['storagePid']) . ':(' . Solr::escapeQuery($this->searchParams['extQuery'][$i]) . ')'; |
|
206 | + $query .= Indexer::getIndexFieldName($this->searchParams['extField'][$i], $this->settings['storagePid']).':('.Solr::escapeQuery($this->searchParams['extQuery'][$i]).')'; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | // Add filter query for date search |
213 | 213 | if (!empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) { |
214 | 214 | // combine dateFrom and dateTo into range search |
215 | - $params['filterquery'][]['query'] = '{!join from=' . $fields['uid'] . ' to=' . $fields['uid'] . '}'. $fields['date'] . ':[' . $this->searchParams['dateFrom'] . ' TO ' . $this->searchParams['dateTo'] . ']'; |
|
215 | + $params['filterquery'][]['query'] = '{!join from='.$fields['uid'].' to='.$fields['uid'].'}'.$fields['date'].':['.$this->searchParams['dateFrom'].' TO '.$this->searchParams['dateTo'].']'; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | // Add filter query for faceting. |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | ) { |
230 | 230 | // Search in document and all subordinates (valid for up to three levels of hierarchy). |
231 | 231 | $params['filterquery'][]['query'] = '_query_:"{!join from=' |
232 | - . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
233 | - . $fields['uid'] . ':{!join from=' . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
234 | - . $fields['uid'] . ':' . $this->searchParams['documentId'] . '"' . ' OR {!join from=' |
|
235 | - . $fields['uid'] . ' to=' . $fields['partof'] . '}' |
|
236 | - . $fields['uid'] . ':' . $this->searchParams['documentId'] . ' OR ' |
|
237 | - . $fields['uid'] . ':' . $this->searchParams['documentId']; |
|
232 | + . $fields['uid'].' to='.$fields['partof'].'}' |
|
233 | + . $fields['uid'].':{!join from='.$fields['uid'].' to='.$fields['partof'].'}' |
|
234 | + . $fields['uid'].':'.$this->searchParams['documentId'].'"'.' OR {!join from=' |
|
235 | + . $fields['uid'].' to='.$fields['partof'].'}' |
|
236 | + . $fields['uid'].':'.$this->searchParams['documentId'].' OR ' |
|
237 | + . $fields['uid'].':'.$this->searchParams['documentId']; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | // if collections are given, we prepare the collection query string |
@@ -243,25 +243,25 @@ discard block |
||
243 | 243 | $virtualCollectionsQueryString = ''; |
244 | 244 | foreach ($this->collection as $collectionEntry) { |
245 | 245 | // check for virtual collections query string |
246 | - if($collectionEntry->getIndexSearch()) { |
|
247 | - $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '(' . $collectionEntry->getIndexSearch() . ')' : ' OR ('. $collectionEntry->getIndexSearch() . ')' ; |
|
246 | + if ($collectionEntry->getIndexSearch()) { |
|
247 | + $virtualCollectionsQueryString .= empty($virtualCollectionsQueryString) ? '('.$collectionEntry->getIndexSearch().')' : ' OR ('.$collectionEntry->getIndexSearch().')'; |
|
248 | 248 | } else { |
249 | - $collectionsQueryString .= empty($collectionsQueryString) ? '"' . $collectionEntry->getIndexName() . '"' : ' OR "' . $collectionEntry->getIndexName() . '"'; |
|
249 | + $collectionsQueryString .= empty($collectionsQueryString) ? '"'.$collectionEntry->getIndexName().'"' : ' OR "'.$collectionEntry->getIndexName().'"'; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | // distinguish between simple collection browsing and actual searching within the collection(s) |
254 | - if(!empty($collectionsQueryString)) { |
|
255 | - if(empty($query)) { |
|
256 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . ') AND toplevel:true AND partof:0)'; |
|
254 | + if (!empty($collectionsQueryString)) { |
|
255 | + if (empty($query)) { |
|
256 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.') AND toplevel:true AND partof:0)'; |
|
257 | 257 | } else { |
258 | - $collectionsQueryString = '(collection_faceting:(' . $collectionsQueryString . '))'; |
|
258 | + $collectionsQueryString = '(collection_faceting:('.$collectionsQueryString.'))'; |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | // virtual collections might query documents that are neither toplevel:true nor partof:0 and need to be searched separatly |
263 | - if(!empty($virtualCollectionsQueryString)) { |
|
264 | - $virtualCollectionsQueryString = '(' . $virtualCollectionsQueryString . ')'; |
|
263 | + if (!empty($virtualCollectionsQueryString)) { |
|
264 | + $virtualCollectionsQueryString = '('.$virtualCollectionsQueryString.')'; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // combine both querystrings into a single filterquery via OR if both are given, otherwise pass either of those |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | if ($this->listedMetadata) { |
295 | 295 | foreach ($this->listedMetadata as $metadata) { |
296 | 296 | if ($metadata->getIndexStored() || $metadata->getIndexIndexed()) { |
297 | - $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . ($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
298 | - $params['fields'] .= ',' . $listMetadataRecord; |
|
297 | + $listMetadataRecord = $metadata->getIndexName().'_'.($metadata->getIndexTokenized() ? 't' : 'u').($metadata->getIndexStored() ? 's' : 'u').($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
298 | + $params['fields'] .= ','.$listMetadataRecord; |
|
299 | 299 | $params['listMetadataRecords'][$metadata->getIndexName()] = $listMetadataRecord; |
300 | 300 | } |
301 | 301 | } |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | } |
340 | 340 | if ($documents[$doc['uid']]) { |
341 | 341 | // translate language code if applicable |
342 | - if($doc['metadata']['language']) { |
|
343 | - foreach($doc['metadata']['language'] as $indexName => $language) { |
|
342 | + if ($doc['metadata']['language']) { |
|
343 | + foreach ($doc['metadata']['language'] as $indexName => $language) { |
|
344 | 344 | $doc['metadata']['language'][$indexName] = Helper::getLanguageName($doc['metadata']['language'][$indexName]); |
345 | 345 | } |
346 | 346 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $children = $childrenOf[$doc['uid']] ?? []; |
380 | 380 | if (!empty($children)) { |
381 | 381 | $metadataOf = $this->fetchToplevelMetadataFromSolr([ |
382 | - 'query' => 'partof:' . $doc['uid'], |
|
382 | + 'query' => 'partof:'.$doc['uid'], |
|
383 | 383 | 'start' => 0, |
384 | 384 | 'rows' => 100, |
385 | 385 | ]); |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | if ($this->listedMetadata) { |
427 | 427 | foreach ($this->listedMetadata as $metadata) { |
428 | 428 | if ($metadata->getIndexStored() || $metadata->getIndexIndexed()) { |
429 | - $listMetadataRecord = $metadata->getIndexName() . '_' . ($metadata->getIndexTokenized() ? 't' : 'u') . ($metadata->getIndexStored() ? 's' : 'u') . ($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
430 | - $params['fields'] .= ',' . $listMetadataRecord; |
|
429 | + $listMetadataRecord = $metadata->getIndexName().'_'.($metadata->getIndexTokenized() ? 't' : 'u').($metadata->getIndexStored() ? 's' : 'u').($metadata->getIndexIndexed() ? 'i' : 'u'); |
|
430 | + $params['fields'] .= ','.$listMetadataRecord; |
|
431 | 431 | $params['listMetadataRecords'][$metadata->getIndexName()] = $listMetadataRecord; |
432 | 432 | } |
433 | 433 | } |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | |
441 | 441 | foreach ($result['documents'] as $doc) { |
442 | 442 | // translate language code if applicable |
443 | - if($doc['metadata']['language']) { |
|
444 | - foreach($doc['metadata']['language'] as $indexName => $language) { |
|
443 | + if ($doc['metadata']['language']) { |
|
444 | + foreach ($doc['metadata']['language'] as $indexName => $language) { |
|
445 | 445 | $doc['metadata']['language'][$indexName] = Helper::getLanguageName($doc['metadata']['language'][$indexName]); |
446 | 446 | } |
447 | 447 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | $cache = null; |
484 | 484 | // Calculate cache identifier. |
485 | 485 | if ($enableCache === true) { |
486 | - $cacheIdentifier = Helper::digest($solr->core . print_r($parameters, true)); |
|
486 | + $cacheIdentifier = Helper::digest($solr->core.print_r($parameters, true)); |
|
487 | 487 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr'); |
488 | 488 | } |
489 | 489 | $resultSet = [ |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | * @subpackage dlf |
33 | 33 | * @access public |
34 | 34 | */ |
35 | -class Helper |
|
36 | -{ |
|
35 | +class Helper { |
|
37 | 36 | /** |
38 | 37 | * The extension key |
39 | 38 | * |
@@ -81,8 +80,7 @@ discard block |
||
81 | 80 | * |
82 | 81 | * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to |
83 | 82 | */ |
84 | - public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') |
|
85 | - { |
|
83 | + public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') { |
|
86 | 84 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
87 | 85 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
88 | 86 | $flashMessage = GeneralUtility::makeInstance( |
@@ -107,8 +105,7 @@ discard block |
||
107 | 105 | * |
108 | 106 | * @return bool Is $id a valid GNL identifier of the given $type? |
109 | 107 | */ |
110 | - public static function checkIdentifier($id, $type) |
|
111 | - { |
|
108 | + public static function checkIdentifier($id, $type) { |
|
112 | 109 | $digits = substr($id, 0, 8); |
113 | 110 | $checksum = 0; |
114 | 111 | for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
@@ -172,8 +169,7 @@ discard block |
||
172 | 169 | * |
173 | 170 | * @return mixed The decrypted value or false on error |
174 | 171 | */ |
175 | - public static function decrypt($encrypted) |
|
176 | - { |
|
172 | + public static function decrypt($encrypted) { |
|
177 | 173 | if ( |
178 | 174 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
179 | 175 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -212,8 +208,7 @@ discard block |
||
212 | 208 | * |
213 | 209 | * @return \SimpleXMLElement|false |
214 | 210 | */ |
215 | - public static function getXmlFileAsString($content) |
|
216 | - { |
|
211 | + public static function getXmlFileAsString($content) { |
|
217 | 212 | // Don't make simplexml_load_string throw (when $content is an array |
218 | 213 | // or object) |
219 | 214 | if (!is_string($content)) { |
@@ -244,8 +239,7 @@ discard block |
||
244 | 239 | * |
245 | 240 | * @return void |
246 | 241 | */ |
247 | - public static function log($message, $severity = 0) |
|
248 | - { |
|
242 | + public static function log($message, $severity = 0) { |
|
249 | 243 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_called_class()); |
250 | 244 | |
251 | 245 | switch ($severity) { |
@@ -275,8 +269,7 @@ discard block |
||
275 | 269 | * |
276 | 270 | * @return mixed Hashed string or false on error |
277 | 271 | */ |
278 | - public static function digest($string) |
|
279 | - { |
|
272 | + public static function digest($string) { |
|
280 | 273 | if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
281 | 274 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
282 | 275 | return false; |
@@ -295,8 +288,7 @@ discard block |
||
295 | 288 | * |
296 | 289 | * @return mixed Encrypted string or false on error |
297 | 290 | */ |
298 | - public static function encrypt($string) |
|
299 | - { |
|
291 | + public static function encrypt($string) { |
|
300 | 292 | if ( |
301 | 293 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
302 | 294 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -329,8 +321,7 @@ discard block |
||
329 | 321 | * |
330 | 322 | * @return string The unqualified class name |
331 | 323 | */ |
332 | - public static function getUnqualifiedClassName($qualifiedClassname) |
|
333 | - { |
|
324 | + public static function getUnqualifiedClassName($qualifiedClassname) { |
|
334 | 325 | $nameParts = explode('\\', $qualifiedClassname); |
335 | 326 | return end($nameParts); |
336 | 327 | } |
@@ -344,8 +335,7 @@ discard block |
||
344 | 335 | * |
345 | 336 | * @return string The cleaned up string |
346 | 337 | */ |
347 | - public static function getCleanString($string) |
|
348 | - { |
|
338 | + public static function getCleanString($string) { |
|
349 | 339 | // Convert to lowercase. |
350 | 340 | $string = strtolower($string); |
351 | 341 | // Remove non-alphanumeric characters. |
@@ -366,8 +356,7 @@ discard block |
||
366 | 356 | * |
367 | 357 | * @return array Array of hook objects for the class |
368 | 358 | */ |
369 | - public static function getHookObjects($scriptRelPath) |
|
370 | - { |
|
359 | + public static function getHookObjects($scriptRelPath) { |
|
371 | 360 | $hookObjects = []; |
372 | 361 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
373 | 362 | foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
@@ -388,8 +377,7 @@ discard block |
||
388 | 377 | * |
389 | 378 | * @return string "index_name" for the given UID |
390 | 379 | */ |
391 | - public static function getIndexNameFromUid($uid, $table, $pid = -1) |
|
392 | - { |
|
380 | + public static function getIndexNameFromUid($uid, $table, $pid = -1) { |
|
393 | 381 | // Sanitize input. |
394 | 382 | $uid = max(intval($uid), 0); |
395 | 383 | if ( |
@@ -447,8 +435,7 @@ discard block |
||
447 | 435 | * |
448 | 436 | * @return string Localized full name of language or unchanged input |
449 | 437 | */ |
450 | - public static function getLanguageName($code) |
|
451 | - { |
|
438 | + public static function getLanguageName($code) { |
|
452 | 439 | // Analyze code and set appropriate ISO table. |
453 | 440 | $isoCode = strtolower(trim($code)); |
454 | 441 | if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
@@ -475,8 +462,7 @@ discard block |
||
475 | 462 | * |
476 | 463 | * @return array |
477 | 464 | */ |
478 | - public static function getDocumentStructures($pid = -1) |
|
479 | - { |
|
465 | + public static function getDocumentStructures($pid = -1) { |
|
480 | 466 | // TODO: Against redundancy with getIndexNameFromUid |
481 | 467 | |
482 | 468 | $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
@@ -518,8 +504,7 @@ discard block |
||
518 | 504 | * |
519 | 505 | * @return string Uniform Resource Name as string |
520 | 506 | */ |
521 | - public static function getURN($base, $id) |
|
522 | - { |
|
507 | + public static function getURN($base, $id) { |
|
523 | 508 | $concordance = [ |
524 | 509 | '0' => 1, |
525 | 510 | '1' => 2, |
@@ -586,8 +571,7 @@ discard block |
||
586 | 571 | * |
587 | 572 | * @return bool Is $id a valid PPN? |
588 | 573 | */ |
589 | - public static function isPPN($id) |
|
590 | - { |
|
574 | + public static function isPPN($id) { |
|
591 | 575 | return self::checkIdentifier($id, 'PPN'); |
592 | 576 | } |
593 | 577 | |
@@ -598,8 +582,7 @@ discard block |
||
598 | 582 | * |
599 | 583 | * @return bool |
600 | 584 | */ |
601 | - public static function isValidHttpUrl($url) |
|
602 | - { |
|
585 | + public static function isValidHttpUrl($url) { |
|
603 | 586 | if (!GeneralUtility::isValidUrl($url)) { |
604 | 587 | return false; |
605 | 588 | } |
@@ -625,8 +608,7 @@ discard block |
||
625 | 608 | * |
626 | 609 | * @return array Merged array |
627 | 610 | */ |
628 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
629 | - { |
|
611 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) { |
|
630 | 612 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
631 | 613 | return $original; |
632 | 614 | } |
@@ -640,8 +622,7 @@ discard block |
||
640 | 622 | * |
641 | 623 | * @return string All flash messages in the queue rendered as HTML. |
642 | 624 | */ |
643 | - public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') |
|
644 | - { |
|
625 | + public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') { |
|
645 | 626 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
646 | 627 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
647 | 628 | $flashMessages = $flashMessageQueue->getAllMessagesAndFlush(); |
@@ -661,8 +642,7 @@ discard block |
||
661 | 642 | * |
662 | 643 | * @return string Localized label for $index_name |
663 | 644 | */ |
664 | - public static function translate($index_name, $table, $pid) |
|
665 | - { |
|
645 | + public static function translate($index_name, $table, $pid) { |
|
666 | 646 | // Load labels into static variable for future use. |
667 | 647 | static $labels = []; |
668 | 648 | // Sanitize input. |
@@ -790,8 +770,7 @@ discard block |
||
790 | 770 | * |
791 | 771 | * @return string Additional WHERE expression |
792 | 772 | */ |
793 | - public static function whereExpression($table, $showHidden = false) |
|
794 | - { |
|
773 | + public static function whereExpression($table, $showHidden = false) { |
|
795 | 774 | if (\TYPO3_MODE === 'FE') { |
796 | 775 | // Should we ignore the record's hidden flag? |
797 | 776 | $ignoreHide = 0; |
@@ -823,8 +802,7 @@ discard block |
||
823 | 802 | * |
824 | 803 | * @access private |
825 | 804 | */ |
826 | - private function __construct() |
|
827 | - { |
|
805 | + private function __construct() { |
|
828 | 806 | // This is a static class, thus no instances should be created. |
829 | 807 | } |
830 | 808 | |
@@ -850,8 +828,7 @@ discard block |
||
850 | 828 | * |
851 | 829 | * @access public |
852 | 830 | */ |
853 | - public static function polyfillExtbaseClassesForTYPO3v9() |
|
854 | - { |
|
831 | + public static function polyfillExtbaseClassesForTYPO3v9() { |
|
855 | 832 | $classes = require __DIR__ . '/../../Configuration/Extbase/Persistence/Classes.php'; |
856 | 833 | |
857 | 834 | $objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
@@ -888,8 +865,7 @@ discard block |
||
888 | 865 | * |
889 | 866 | * @return string|bool |
890 | 867 | */ |
891 | - public static function getUrl(string $url) |
|
892 | - { |
|
868 | + public static function getUrl(string $url) { |
|
893 | 869 | if (!Helper::isValidHttpUrl($url)) { |
894 | 870 | return false; |
895 | 871 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | if (!preg_match('/\d{8}-\d{1}/i', $id)) { |
144 | 144 | return false; |
145 | 145 | } elseif ($checksum == 10) { |
146 | - return self::checkIdentifier(($digits + 1) . substr($id, -2, 2), 'SWD'); |
|
146 | + return self::checkIdentifier(($digits + 1).substr($id, -2, 2), 'SWD'); |
|
147 | 147 | } elseif (substr($id, -1, 1) != $checksum) { |
148 | 148 | return false; |
149 | 149 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $encrypted = openssl_encrypt($string, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); |
316 | 316 | // Merge initialisation vector and encrypted data. |
317 | 317 | if ($encrypted !== false) { |
318 | - $encrypted = base64_encode($iv . $encrypted); |
|
318 | + $encrypted = base64_encode($iv.$encrypted); |
|
319 | 319 | } |
320 | 320 | return $encrypted; |
321 | 321 | } |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | public static function getHookObjects($scriptRelPath) |
370 | 370 | { |
371 | 371 | $hookObjects = []; |
372 | - if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
|
373 | - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
|
372 | + if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) { |
|
373 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'] as $classRef) { |
|
374 | 374 | $hookObjects[] = GeneralUtility::makeInstance($classRef); |
375 | 375 | } |
376 | 376 | } |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | // NOTE: Only use tables that don't have too many entries! |
398 | 398 | || !in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores']) |
399 | 399 | ) { |
400 | - self::log('Invalid UID "' . $uid . '" or table "' . $table . '"', LOG_SEVERITY_ERROR); |
|
400 | + self::log('Invalid UID "'.$uid.'" or table "'.$table.'"', LOG_SEVERITY_ERROR); |
|
401 | 401 | return ''; |
402 | 402 | } |
403 | 403 | |
404 | - $makeCacheKey = function ($pid, $uid) { |
|
405 | - return $pid . '.' . $uid; |
|
404 | + $makeCacheKey = function($pid, $uid) { |
|
405 | + return $pid.'.'.$uid; |
|
406 | 406 | }; |
407 | 407 | |
408 | 408 | static $cache = []; |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | |
413 | 413 | $result = $queryBuilder |
414 | 414 | ->select( |
415 | - $table . '.index_name AS index_name', |
|
416 | - $table . '.uid AS uid', |
|
417 | - $table . '.pid AS pid', |
|
415 | + $table.'.index_name AS index_name', |
|
416 | + $table.'.uid AS uid', |
|
417 | + $table.'.pid AS pid', |
|
418 | 418 | ) |
419 | 419 | ->from($table) |
420 | 420 | ->execute(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $result = $cache[$table][$cacheKey] ?? ''; |
433 | 433 | |
434 | 434 | if ($result === '') { |
435 | - self::log('No "index_name" with UID ' . $uid . ' and PID ' . $pid . ' found in table "' . $table . '"', LOG_SEVERITY_WARNING); |
|
435 | + self::log('No "index_name" with UID '.$uid.' and PID '.$pid.' found in table "'.$table.'"', LOG_SEVERITY_WARNING); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | return $result; |
@@ -459,11 +459,11 @@ discard block |
||
459 | 459 | // No ISO code, return unchanged. |
460 | 460 | return $code; |
461 | 461 | } |
462 | - $lang = LocalizationUtility::translate('LLL:' . $file . ':' . $code); |
|
462 | + $lang = LocalizationUtility::translate('LLL:'.$file.':'.$code); |
|
463 | 463 | if (!empty($lang)) { |
464 | 464 | return $lang; |
465 | 465 | } else { |
466 | - self::log('Language code "' . $code . '" not found in ISO-639 table', LOG_SEVERITY_NOTICE); |
|
466 | + self::log('Language code "'.$code.'" not found in ISO-639 table', LOG_SEVERITY_NOTICE); |
|
467 | 467 | return $code; |
468 | 468 | } |
469 | 469 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | '-' => 39, |
561 | 561 | ':' => 17, |
562 | 562 | ]; |
563 | - $urn = strtolower($base . $id); |
|
563 | + $urn = strtolower($base.$id); |
|
564 | 564 | if (preg_match('/[^a-z\d:-]/', $urn)) { |
565 | 565 | self::log('Invalid chars in given parameters', LOG_SEVERITY_WARNING); |
566 | 566 | return ''; |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $checksum += ($i + 1) * intval(substr($digits, $i, 1)); |
575 | 575 | } |
576 | 576 | $checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1); |
577 | - return $base . $id . $checksum; |
|
577 | + return $base.$id.$checksum; |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | // Sanitize input. |
669 | 669 | $pid = max(intval($pid), 0); |
670 | 670 | if (!$pid) { |
671 | - self::log('Invalid PID ' . $pid . ' for translation', LOG_SEVERITY_WARNING); |
|
671 | + self::log('Invalid PID '.$pid.' for translation', LOG_SEVERITY_WARNING); |
|
672 | 672 | return $index_name; |
673 | 673 | } |
674 | 674 | /** @var \TYPO3\CMS\Frontend\Page\PageRepository $pageRepository */ |
@@ -690,13 +690,13 @@ discard block |
||
690 | 690 | // First fetch the uid of the received index_name |
691 | 691 | $result = $queryBuilder |
692 | 692 | ->select( |
693 | - $table . '.uid AS uid', |
|
694 | - $table . '.l18n_parent AS l18n_parent' |
|
693 | + $table.'.uid AS uid', |
|
694 | + $table.'.l18n_parent AS l18n_parent' |
|
695 | 695 | ) |
696 | 696 | ->from($table) |
697 | 697 | ->where( |
698 | - $queryBuilder->expr()->eq($table . '.pid', $pid), |
|
699 | - $queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($index_name)), |
|
698 | + $queryBuilder->expr()->eq($table.'.pid', $pid), |
|
699 | + $queryBuilder->expr()->eq($table.'.index_name', $queryBuilder->expr()->literal($index_name)), |
|
700 | 700 | self::whereExpression($table, true) |
701 | 701 | ) |
702 | 702 | ->setMaxResults(1) |
@@ -709,12 +709,12 @@ discard block |
||
709 | 709 | $resArray = $allResults[0]; |
710 | 710 | |
711 | 711 | $result = $queryBuilder |
712 | - ->select($table . '.index_name AS index_name') |
|
712 | + ->select($table.'.index_name AS index_name') |
|
713 | 713 | ->from($table) |
714 | 714 | ->where( |
715 | - $queryBuilder->expr()->eq($table . '.pid', $pid), |
|
716 | - $queryBuilder->expr()->eq($table . '.uid', $resArray['l18n_parent']), |
|
717 | - $queryBuilder->expr()->eq($table . '.sys_language_uid', intval($languageAspect->getContentId())), |
|
715 | + $queryBuilder->expr()->eq($table.'.pid', $pid), |
|
716 | + $queryBuilder->expr()->eq($table.'.uid', $resArray['l18n_parent']), |
|
717 | + $queryBuilder->expr()->eq($table.'.sys_language_uid', intval($languageAspect->getContentId())), |
|
718 | 718 | self::whereExpression($table, true) |
719 | 719 | ) |
720 | 720 | ->setMaxResults(1) |
@@ -732,14 +732,14 @@ discard block |
||
732 | 732 | if (empty($labels[$table][$pid][$languageAspect->getContentId()][$index_name])) { |
733 | 733 | // Check if this table is allowed for translation. |
734 | 734 | if (in_array($table, ['tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'])) { |
735 | - $additionalWhere = $queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]); |
|
735 | + $additionalWhere = $queryBuilder->expr()->in($table.'.sys_language_uid', [-1, 0]); |
|
736 | 736 | if ($languageAspect->getContentId() > 0) { |
737 | 737 | $additionalWhere = $queryBuilder->expr()->andX( |
738 | 738 | $queryBuilder->expr()->orX( |
739 | - $queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]), |
|
740 | - $queryBuilder->expr()->eq($table . '.sys_language_uid', intval($languageAspect->getContentId())) |
|
739 | + $queryBuilder->expr()->in($table.'.sys_language_uid', [-1, 0]), |
|
740 | + $queryBuilder->expr()->eq($table.'.sys_language_uid', intval($languageAspect->getContentId())) |
|
741 | 741 | ), |
742 | - $queryBuilder->expr()->eq($table . '.l18n_parent', 0) |
|
742 | + $queryBuilder->expr()->eq($table.'.l18n_parent', 0) |
|
743 | 743 | ); |
744 | 744 | } |
745 | 745 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | ->select('*') |
749 | 749 | ->from($table) |
750 | 750 | ->where( |
751 | - $queryBuilder->expr()->eq($table . '.pid', $pid), |
|
751 | + $queryBuilder->expr()->eq($table.'.pid', $pid), |
|
752 | 752 | $additionalWhere, |
753 | 753 | self::whereExpression($table, true) |
754 | 754 | ) |
@@ -766,10 +766,10 @@ discard block |
||
766 | 766 | } |
767 | 767 | } |
768 | 768 | } else { |
769 | - self::log('No translation with PID ' . $pid . ' available in table "' . $table . '" or translation not accessible', LOG_SEVERITY_NOTICE); |
|
769 | + self::log('No translation with PID '.$pid.' available in table "'.$table.'" or translation not accessible', LOG_SEVERITY_NOTICE); |
|
770 | 770 | } |
771 | 771 | } else { |
772 | - self::log('No translations available for table "' . $table . '"', LOG_SEVERITY_WARNING); |
|
772 | + self::log('No translations available for table "'.$table.'"', LOG_SEVERITY_WARNING); |
|
773 | 773 | } |
774 | 774 | } |
775 | 775 | |
@@ -811,9 +811,9 @@ discard block |
||
811 | 811 | return GeneralUtility::makeInstance(ConnectionPool::class) |
812 | 812 | ->getQueryBuilderForTable($table) |
813 | 813 | ->expr() |
814 | - ->eq($table . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'], 0); |
|
814 | + ->eq($table.'.'.$GLOBALS['TCA'][$table]['ctrl']['delete'], 0); |
|
815 | 815 | } else { |
816 | - self::log('Unexpected TYPO3_MODE "' . \TYPO3_MODE . '"', LOG_SEVERITY_ERROR); |
|
816 | + self::log('Unexpected TYPO3_MODE "'.\TYPO3_MODE.'"', LOG_SEVERITY_ERROR); |
|
817 | 817 | return '1=-1'; |
818 | 818 | } |
819 | 819 | } |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | */ |
853 | 853 | public static function polyfillExtbaseClassesForTYPO3v9() |
854 | 854 | { |
855 | - $classes = require __DIR__ . '/../../Configuration/Extbase/Persistence/Classes.php'; |
|
855 | + $classes = require __DIR__.'/../../Configuration/Extbase/Persistence/Classes.php'; |
|
856 | 856 | |
857 | 857 | $objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
858 | 858 | $configurationManager = $objectManager->get(ConfigurationManager::class); |
@@ -908,10 +908,10 @@ discard block |
||
908 | 908 | try { |
909 | 909 | $response = $requestFactory->request($url, 'GET', $configuration); |
910 | 910 | } catch (\Exception $e) { |
911 | - self::log('Could not fetch data from URL "' . $url . '". Error: ' . $e->getMessage() . '.', LOG_SEVERITY_WARNING); |
|
911 | + self::log('Could not fetch data from URL "'.$url.'". Error: '.$e->getMessage().'.', LOG_SEVERITY_WARNING); |
|
912 | 912 | return false; |
913 | 913 | } |
914 | - $content = $response->getBody()->getContents(); |
|
914 | + $content = $response->getBody()->getContents(); |
|
915 | 915 | |
916 | 916 | return $content; |
917 | 917 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to |
83 | 83 | */ |
84 | - public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') |
|
84 | + public static function addMessage($message, $title, $severity, $session = FALSE, $queue = 'kitodo.default.flashMessages') |
|
85 | 85 | { |
86 | 86 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
87 | 87 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | $checksum = 'X'; |
124 | 124 | } |
125 | 125 | if (!preg_match('/\d{8}[\dX]{1}/i', $id)) { |
126 | - return false; |
|
126 | + return FALSE; |
|
127 | 127 | } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
128 | - return false; |
|
128 | + return FALSE; |
|
129 | 129 | } |
130 | 130 | break; |
131 | 131 | case 'ZDB': |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | $checksum = 'X'; |
134 | 134 | } |
135 | 135 | if (!preg_match('/\d{8}-[\dX]{1}/i', $id)) { |
136 | - return false; |
|
136 | + return FALSE; |
|
137 | 137 | } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
138 | - return false; |
|
138 | + return FALSE; |
|
139 | 139 | } |
140 | 140 | break; |
141 | 141 | case 'SWD': |
142 | 142 | $checksum = 11 - $checksum; |
143 | 143 | if (!preg_match('/\d{8}-\d{1}/i', $id)) { |
144 | - return false; |
|
144 | + return FALSE; |
|
145 | 145 | } elseif ($checksum == 10) { |
146 | 146 | return self::checkIdentifier(($digits + 1) . substr($id, -2, 2), 'SWD'); |
147 | 147 | } elseif (substr($id, -1, 1) != $checksum) { |
148 | - return false; |
|
148 | + return FALSE; |
|
149 | 149 | } |
150 | 150 | break; |
151 | 151 | case 'GKD': |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | $checksum = 'X'; |
155 | 155 | } |
156 | 156 | if (!preg_match('/\d{8}-[\dX]{1}/i', $id)) { |
157 | - return false; |
|
157 | + return FALSE; |
|
158 | 158 | } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
159 | - return false; |
|
159 | + return FALSE; |
|
160 | 160 | } |
161 | 161 | break; |
162 | 162 | } |
163 | - return true; |
|
163 | + return TRUE; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -175,28 +175,28 @@ discard block |
||
175 | 175 | public static function decrypt($encrypted) |
176 | 176 | { |
177 | 177 | if ( |
178 | - !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
|
179 | - || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
|
178 | + !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(TRUE)) |
|
179 | + || !in_array(self::$hashAlgorithm, openssl_get_md_methods(TRUE)) |
|
180 | 180 | ) { |
181 | 181 | self::log('OpenSSL library doesn\'t support cipher and/or hash algorithm', LOG_SEVERITY_ERROR); |
182 | - return false; |
|
182 | + return FALSE; |
|
183 | 183 | } |
184 | 184 | if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
185 | 185 | self::log('No encryption key set in TYPO3 configuration', LOG_SEVERITY_ERROR); |
186 | - return false; |
|
186 | + return FALSE; |
|
187 | 187 | } |
188 | 188 | if ( |
189 | 189 | empty($encrypted) |
190 | 190 | || strlen($encrypted) < openssl_cipher_iv_length(self::$cipherAlgorithm) |
191 | 191 | ) { |
192 | 192 | self::log('Invalid parameters given for decryption', LOG_SEVERITY_ERROR); |
193 | - return false; |
|
193 | + return FALSE; |
|
194 | 194 | } |
195 | 195 | // Split initialisation vector and encrypted data. |
196 | 196 | $binary = base64_decode($encrypted); |
197 | 197 | $iv = substr($binary, 0, openssl_cipher_iv_length(self::$cipherAlgorithm)); |
198 | 198 | $data = substr($binary, openssl_cipher_iv_length(self::$cipherAlgorithm)); |
199 | - $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true); |
|
199 | + $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, TRUE); |
|
200 | 200 | // Decrypt data. |
201 | 201 | $decrypted = openssl_decrypt($data, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); |
202 | 202 | return $decrypted; |
@@ -217,13 +217,13 @@ discard block |
||
217 | 217 | // Don't make simplexml_load_string throw (when $content is an array |
218 | 218 | // or object) |
219 | 219 | if (!is_string($content)) { |
220 | - return false; |
|
220 | + return FALSE; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | // Turn off libxml's error logging. |
224 | - $libxmlErrors = libxml_use_internal_errors(true); |
|
224 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
225 | 225 | // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
226 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(true); |
|
226 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
227 | 227 | // Try to load XML from file. |
228 | 228 | $xml = simplexml_load_string($content); |
229 | 229 | // reset entity loader setting |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function digest($string) |
279 | 279 | { |
280 | - if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
|
280 | + if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(TRUE))) { |
|
281 | 281 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
282 | - return false; |
|
282 | + return FALSE; |
|
283 | 283 | } |
284 | 284 | // Hash string. |
285 | 285 | $hashed = openssl_digest($string, self::$hashAlgorithm); |
@@ -298,23 +298,23 @@ discard block |
||
298 | 298 | public static function encrypt($string) |
299 | 299 | { |
300 | 300 | if ( |
301 | - !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
|
302 | - || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
|
301 | + !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(TRUE)) |
|
302 | + || !in_array(self::$hashAlgorithm, openssl_get_md_methods(TRUE)) |
|
303 | 303 | ) { |
304 | 304 | self::log('OpenSSL library doesn\'t support cipher and/or hash algorithm', LOG_SEVERITY_ERROR); |
305 | - return false; |
|
305 | + return FALSE; |
|
306 | 306 | } |
307 | 307 | if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
308 | 308 | self::log('No encryption key set in TYPO3 configuration', LOG_SEVERITY_ERROR); |
309 | - return false; |
|
309 | + return FALSE; |
|
310 | 310 | } |
311 | 311 | // Generate random initialisation vector. |
312 | 312 | $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::$cipherAlgorithm)); |
313 | - $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, true); |
|
313 | + $key = openssl_digest($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], self::$hashAlgorithm, TRUE); |
|
314 | 314 | // Encrypt data. |
315 | 315 | $encrypted = openssl_encrypt($string, self::$cipherAlgorithm, $key, OPENSSL_RAW_DATA, $iv); |
316 | 316 | // Merge initialisation vector and encrypted data. |
317 | - if ($encrypted !== false) { |
|
317 | + if ($encrypted !== FALSE) { |
|
318 | 318 | $encrypted = base64_encode($iv . $encrypted); |
319 | 319 | } |
320 | 320 | return $encrypted; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | public static function isValidHttpUrl($url) |
602 | 602 | { |
603 | 603 | if (!GeneralUtility::isValidUrl($url)) { |
604 | - return false; |
|
604 | + return FALSE; |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | $parsed = parse_url($url); |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return array Merged array |
627 | 627 | */ |
628 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
628 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = TRUE, $includeEmptyValues = TRUE, $enableUnsetFeature = TRUE) |
|
629 | 629 | { |
630 | 630 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
631 | 631 | return $original; |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | ->where( |
698 | 698 | $queryBuilder->expr()->eq($table . '.pid', $pid), |
699 | 699 | $queryBuilder->expr()->eq($table . '.index_name', $queryBuilder->expr()->literal($index_name)), |
700 | - self::whereExpression($table, true) |
|
700 | + self::whereExpression($table, TRUE) |
|
701 | 701 | ) |
702 | 702 | ->setMaxResults(1) |
703 | 703 | ->execute(); |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | $queryBuilder->expr()->eq($table . '.pid', $pid), |
716 | 716 | $queryBuilder->expr()->eq($table . '.uid', $resArray['l18n_parent']), |
717 | 717 | $queryBuilder->expr()->eq($table . '.sys_language_uid', intval($languageAspect->getContentId())), |
718 | - self::whereExpression($table, true) |
|
718 | + self::whereExpression($table, TRUE) |
|
719 | 719 | ) |
720 | 720 | ->setMaxResults(1) |
721 | 721 | ->execute(); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | ->where( |
751 | 751 | $queryBuilder->expr()->eq($table . '.pid', $pid), |
752 | 752 | $additionalWhere, |
753 | - self::whereExpression($table, true) |
|
753 | + self::whereExpression($table, TRUE) |
|
754 | 754 | ) |
755 | 755 | ->setMaxResults(10000) |
756 | 756 | ->execute(); |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @return string Additional WHERE expression |
792 | 792 | */ |
793 | - public static function whereExpression($table, $showHidden = false) |
|
793 | + public static function whereExpression($table, $showHidden = FALSE) |
|
794 | 794 | { |
795 | 795 | if (\TYPO3_MODE === 'FE') { |
796 | 796 | // Should we ignore the record's hidden flag? |
@@ -859,13 +859,13 @@ discard block |
||
859 | 859 | $frameworkConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); |
860 | 860 | |
861 | 861 | $extbaseClassmap = &$frameworkConfiguration['persistence']['classes']; |
862 | - if ($extbaseClassmap === null) { |
|
862 | + if ($extbaseClassmap === NULL) { |
|
863 | 863 | $extbaseClassmap = []; |
864 | 864 | } |
865 | 865 | |
866 | 866 | foreach ($classes as $className => $classConfig) { |
867 | 867 | $extbaseClass = &$extbaseClassmap[$className]; |
868 | - if ($extbaseClass === null) { |
|
868 | + if ($extbaseClass === NULL) { |
|
869 | 869 | $extbaseClass = []; |
870 | 870 | } |
871 | 871 | if (!isset($extbaseClass['mapping'])) { |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | public static function getUrl(string $url) |
892 | 892 | { |
893 | 893 | if (!Helper::isValidHttpUrl($url)) { |
894 | - return false; |
|
894 | + return FALSE; |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | // Get extension configuration. |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | $response = $requestFactory->request($url, 'GET', $configuration); |
910 | 910 | } catch (\Exception $e) { |
911 | 911 | self::log('Could not fetch data from URL "' . $url . '". Error: ' . $e->getMessage() . '.', LOG_SEVERITY_WARNING); |
912 | - return false; |
|
912 | + return FALSE; |
|
913 | 913 | } |
914 | 914 | $content = $response->getBody()->getContents(); |
915 | 915 |
@@ -10,10 +10,8 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * Targeted towards being used in ``PaginateController`` (``<f:widget.paginate>``). |
12 | 12 | */ |
13 | -class SolrSearchQuery implements QueryInterface |
|
14 | -{ |
|
15 | - public function __construct($solrSearch) |
|
16 | - { |
|
13 | +class SolrSearchQuery implements QueryInterface { |
|
14 | + public function __construct($solrSearch) { |
|
17 | 15 | $this->solrSearch = $solrSearch; |
18 | 16 | |
19 | 17 | $this->offset = 0; |
@@ -22,8 +20,7 @@ discard block |
||
22 | 20 | |
23 | 21 | public function getSource() {} |
24 | 22 | |
25 | - public function execute($returnRawQueryResult = false) |
|
26 | - { |
|
23 | + public function execute($returnRawQueryResult = false) { |
|
27 | 24 | $this->solrSearch->submit($this->offset, $this->limit); |
28 | 25 | |
29 | 26 | // solrSearch now only contains the results in range, indexed in [0, n) |
@@ -37,14 +34,12 @@ discard block |
||
37 | 34 | |
38 | 35 | public function setOrderings(array $orderings) {} |
39 | 36 | |
40 | - public function setLimit($limit) |
|
41 | - { |
|
37 | + public function setLimit($limit) { |
|
42 | 38 | $this->limit = $limit; |
43 | 39 | return $this; |
44 | 40 | } |
45 | 41 | |
46 | - public function setOffset($offset) |
|
47 | - { |
|
42 | + public function setOffset($offset) { |
|
48 | 43 | $this->offset = $offset; |
49 | 44 | return $this; |
50 | 45 | } |
@@ -65,20 +60,17 @@ discard block |
||
65 | 60 | public function setQuerySettings(QuerySettingsInterface $querySettings) {} |
66 | 61 | public function getQuerySettings() {} |
67 | 62 | |
68 | - public function count() |
|
69 | - { |
|
63 | + public function count() { |
|
70 | 64 | // TODO? |
71 | 65 | } |
72 | 66 | |
73 | 67 | public function getOrderings() {} |
74 | 68 | |
75 | - public function getLimit() |
|
76 | - { |
|
69 | + public function getLimit() { |
|
77 | 70 | return $this->limit; |
78 | 71 | } |
79 | 72 | |
80 | - public function getOffset() |
|
81 | - { |
|
73 | + public function getOffset() { |
|
82 | 74 | return $this->offset; |
83 | 75 | } |
84 | 76 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function getSource() {} |
24 | 24 | |
25 | - public function execute($returnRawQueryResult = false) |
|
25 | + public function execute($returnRawQueryResult = FALSE) |
|
26 | 26 | { |
27 | 27 | $this->solrSearch->submit($this->offset, $this->limit); |
28 | 28 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function logicalAnd($constraint1) {} |
54 | 54 | public function logicalOr($constraint1) {} |
55 | 55 | public function logicalNot(ConstraintInterface $constraint) {} |
56 | - public function equals($propertyName, $operand, $caseSensitive = true) {} |
|
56 | + public function equals($propertyName, $operand, $caseSensitive = TRUE) {} |
|
57 | 57 | public function like($propertyName, $operand) {} |
58 | 58 | public function contains($propertyName, $operand) {} |
59 | 59 | public function in($propertyName, $operand) {} |
@@ -12,8 +12,8 @@ |
||
12 | 12 | { |
13 | 13 | parent::setUp(); |
14 | 14 | |
15 | - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml'); |
|
16 | - $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); |
|
15 | + $this->importDataSet(__DIR__.'/../../Fixtures/Common/libraries.xml'); |
|
16 | + $this->importDataSet(__DIR__.'/../../Fixtures/Common/metadata.xml'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; |
7 | 7 | use TYPO3\CMS\Core\Localization\LanguageService; |
8 | 8 | |
9 | -class HelperTest extends FunctionalTestCase |
|
10 | -{ |
|
9 | +class HelperTest extends FunctionalTestCase { |
|
11 | 10 | public function setUp(): void |
12 | 11 | { |
13 | 12 | parent::setUp(); |
@@ -19,8 +18,7 @@ discard block |
||
19 | 18 | /** |
20 | 19 | * @test |
21 | 20 | */ |
22 | - public function canGetIndexNameFromUid() |
|
23 | - { |
|
21 | + public function canGetIndexNameFromUid() { |
|
24 | 22 | // Repeat to make sure caching isn't broken |
25 | 23 | for ($n = 0; $n < 2; $n++) { |
26 | 24 | // Good UID, no PID |
@@ -69,8 +67,7 @@ discard block |
||
69 | 67 | * @test |
70 | 68 | * @group getLanguageName |
71 | 69 | */ |
72 | - public function canTranslateLanguageNameToEnglish() |
|
73 | - { |
|
70 | + public function canTranslateLanguageNameToEnglish() { |
|
74 | 71 | // NOTE: This only tests in BE mode |
75 | 72 | |
76 | 73 | $this->initLanguageService('default'); |
@@ -84,8 +81,7 @@ discard block |
||
84 | 81 | * @test |
85 | 82 | * @group getLanguageName |
86 | 83 | */ |
87 | - public function canTranslateLanguageNameToGerman() |
|
88 | - { |
|
84 | + public function canTranslateLanguageNameToGerman() { |
|
89 | 85 | // NOTE: This only tests in BE mode |
90 | 86 | |
91 | 87 | $this->initLanguageService('de'); |