Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#250)
by Sebastian
03:10
created
dlf/common/class.tx_dlf_document.php 1 patch
Indentation   +1797 added lines, -1797 removed lines patch added patch discarded remove patch
@@ -20,2614 +20,2614 @@
 block discarded – undo
20 20
  */
21 21
 final class tx_dlf_document {
22 22
 
23
-	/**
24
-	 * This holds the whole XML file as string for serialization purposes
25
-	 * @see __sleep() / __wakeup()
26
-	 *
27
-	 * @var	string
28
-	 * @access protected
29
-	 */
30
-	protected $asXML = '';
31
-
32
-	/**
33
-	 * This holds the PID for the configuration
34
-	 *
35
-	 * @var	integer
36
-	 * @access protected
37
-	 */
38
-	protected $cPid = 0;
39
-
40
-	/**
41
-	 * This holds the XML file's dmdSec parts with their IDs as array key
42
-	 *
43
-	 * @var	array
44
-	 * @access protected
45
-	 */
46
-	protected $dmdSec = array ();
47
-
48
-	/**
49
-	 * Are the METS file's dmdSecs loaded?
50
-	 * @see $dmdSec
51
-	 *
52
-	 * @var	boolean
53
-	 * @access protected
54
-	 */
55
-	protected $dmdSecLoaded = FALSE;
56
-
57
-	/**
58
-	 * The extension key
59
-	 *
60
-	 * @var	string
61
-	 * @access public
62
-	 */
63
-	public static $extKey = 'dlf';
64
-
65
-	/**
66
-	 * This holds the file ID -> USE concordance
67
-	 * @see _getFileGrps()
68
-	 *
69
-	 * @var	array
70
-	 * @access protected
71
-	 */
72
-	protected $fileGrps = array ();
73
-
74
-	/**
75
-	 * Are the file groups loaded?
76
-	 * @see $fileGrps
77
-	 *
78
-	 * @var	boolean
79
-	 * @access protected
80
-	 */
81
-	protected $fileGrpsLoaded = FALSE;
82
-
83
-	/**
84
-	 * This holds the configuration for all supported metadata encodings
85
-	 * @see loadFormats()
86
-	 *
87
-	 * @var	array
88
-	 * @access protected
89
-	 */
90
-	protected $formats = array (
91
-		'METS' => array (
92
-			'rootElement' => 'mets',
93
-			'namespaceURI' => 'http://www.loc.gov/METS/',
94
-		),
95
-		'XLINK' => array (
96
-			'rootElement' => 'xlink',
97
-			'namespaceURI' => 'http://www.w3.org/1999/xlink',
98
-		)
99
-	);
100
-
101
-	/**
102
-	 * Are the available metadata formats loaded?
103
-	 * @see $formats
104
-	 *
105
-	 * @var	boolean
106
-	 * @access protected
107
-	 */
108
-	protected $formatsLoaded = FALSE;
109
-
110
-	/**
111
-	 * Are there any fulltext files available?
112
-	 *
113
-	 * @var boolean
114
-	 * @access protected
115
-	 */
116
-	protected $hasFulltext = FALSE;
117
-
118
-	/**
119
-	 * This holds the documents location
120
-	 *
121
-	 * @var	string
122
-	 * @access protected
123
-	 */
124
-	protected $location = '';
125
-
126
-	/**
127
-	 * This holds the logical units
128
-	 *
129
-	 * @var	array
130
-	 * @access protected
131
-	 */
132
-	protected $logicalUnits = array ();
133
-
134
-	/**
135
-	 * This holds the documents' parsed metadata array with their corresponding structMap//div's ID as array key
136
-	 *
137
-	 * @var	array
138
-	 * @access protected
139
-	 */
140
-	protected $metadataArray = array ();
141
-
142
-	/**
143
-	 * Is the metadata array loaded?
144
-	 * @see $metadataArray
145
-	 *
146
-	 * @var	boolean
147
-	 * @access protected
148
-	 */
149
-	protected $metadataArrayLoaded = FALSE;
150
-
151
-	/**
152
-	 * This holds the XML file's METS part as SimpleXMLElement object
153
-	 *
154
-	 * @var	SimpleXMLElement
155
-	 * @access protected
156
-	 */
157
-	protected $mets;
158
-
159
-	/**
160
-	 * The holds the total number of pages
161
-	 *
162
-	 * @var	integer
163
-	 * @access protected
164
-	 */
165
-	protected $numPages = 0;
166
-
167
-	/**
168
-	 * This holds the UID of the parent document or zero if not multi-volumed
169
-	 *
170
-	 * @var	integer
171
-	 * @access protected
172
-	 */
173
-	protected $parentId = 0;
174
-
175
-	/**
176
-	 * This holds the physical structure
177
-	 *
178
-	 * @var	array
179
-	 * @access protected
180
-	 */
181
-	protected $physicalStructure = array ();
182
-
183
-	/**
184
-	 * This holds the physical structure metadata
185
-	 *
186
-	 * @var	array
187
-	 * @access protected
188
-	 */
189
-	protected $physicalStructureInfo = array ();
190
-
191
-	/**
192
-	 * Is the physical structure loaded?
193
-	 * @see $physicalStructure
194
-	 *
195
-	 * @var	boolean
196
-	 * @access protected
197
-	 */
198
-	protected $physicalStructureLoaded = FALSE;
199
-
200
-	/**
201
-	 * This holds the PID of the document or zero if not in database
202
-	 *
203
-	 * @var	integer
204
-	 * @access protected
205
-	 */
206
-	protected $pid = 0;
207
-
208
-	/**
209
-	 * Is the document instantiated successfully?
210
-	 *
211
-	 * @var	boolean
212
-	 * @access protected
213
-	 */
214
-	protected $ready = FALSE;
215
-
216
-	/**
217
-	 * The METS file's record identifier
218
-	 *
219
-	 * @var	string
220
-	 * @access protected
221
-	 */
222
-	protected $recordId;
223
-
224
-	/**
225
-	 * This holds the singleton object of the document
226
-	 *
227
-	 * @var	array (tx_dlf_document)
228
-	 * @access protected
229
-	 */
230
-	protected static $registry = array ();
231
-
232
-	/**
233
-	 * This holds the UID of the root document or zero if not multi-volumed
234
-	 *
235
-	 * @var	integer
236
-	 * @access protected
237
-	 */
238
-	protected $rootId = 0;
239
-
240
-	/**
241
-	 * Is the root id loaded?
242
-	 * @see $rootId
243
-	 *
244
-	 * @var	boolean
245
-	 * @access protected
246
-	 */
247
-	protected $rootIdLoaded = FALSE;
248
-
249
-	/**
250
-	 * This holds the smLinks between logical and physical structMap
251
-	 *
252
-	 * @var	array
253
-	 * @access protected
254
-	 */
255
-	protected $smLinks = array ('l2p' => array (), 'p2l' => array ());
256
-
257
-	/**
258
-	 * Are the smLinks loaded?
259
-	 * @see $smLinks
260
-	 *
261
-	 * @var	boolean
262
-	 * @access protected
263
-	 */
264
-	protected $smLinksLoaded = FALSE;
265
-
266
-	/**
267
-	 * This holds the logical structure
268
-	 *
269
-	 * @var	array
270
-	 * @access protected
271
-	 */
272
-	protected $tableOfContents = array ();
273
-
274
-	/**
275
-	 * Is the table of contents loaded?
276
-	 * @see $tableOfContents
277
-	 *
278
-	 * @var	boolean
279
-	 * @access protected
280
-	 */
281
-	protected $tableOfContentsLoaded = FALSE;
282
-
283
-	/**
284
-	 * This holds the document's thumbnail location.
285
-	 *
286
-	 * @var	string
287
-	 * @access protected
288
-	 */
289
-	protected $thumbnail = '';
290
-
291
-	/**
292
-	 * Is the document's thumbnail location loaded?
293
-	 * @see $thumbnail
294
-	 *
295
-	 * @var	boolean
296
-	 * @access protected
297
-	 */
298
-	protected $thumbnailLoaded = FALSE;
299
-
300
-	/**
301
-	 * This holds the toplevel structure's @ID
302
-	 *
303
-	 * @var	string
304
-	 * @access protected
305
-	 */
306
-	protected $toplevelId = '';
307
-
308
-	/**
309
-	 * This holds the UID or the URL of the document
310
-	 *
311
-	 * @var	mixed
312
-	 * @access protected
313
-	 */
314
-	protected $uid = 0;
315
-
316
-	/**
317
-	 * This holds the whole XML file as SimpleXMLElement object
318
-	 *
319
-	 * @var	SimpleXMLElement
320
-	 * @access protected
321
-	 */
322
-	protected $xml;
323
-
324
-	/**
325
-	 * This clears the static registry to prevent memory exhaustion
326
-	 *
327
-	 * @access	public
328
-	 *
329
-	 * @return	void
330
-	 */
331
-	public static function clearRegistry() {
332
-
333
-		// Reset registry array.
334
-		self::$registry = array ();
335
-
336
-	}
337
-
338
-	/**
339
-	 * This gets the location of a file representing a physical page or track
340
-	 *
341
-	 * @access	public
342
-	 *
343
-	 * @param	string		$id: The @ID attribute of the file node
344
-	 *
345
-	 * @return	string		The file's location as URL
346
-	 */
347
-	public function getFileLocation($id) {
23
+    /**
24
+     * This holds the whole XML file as string for serialization purposes
25
+     * @see __sleep() / __wakeup()
26
+     *
27
+     * @var	string
28
+     * @access protected
29
+     */
30
+    protected $asXML = '';
31
+
32
+    /**
33
+     * This holds the PID for the configuration
34
+     *
35
+     * @var	integer
36
+     * @access protected
37
+     */
38
+    protected $cPid = 0;
39
+
40
+    /**
41
+     * This holds the XML file's dmdSec parts with their IDs as array key
42
+     *
43
+     * @var	array
44
+     * @access protected
45
+     */
46
+    protected $dmdSec = array ();
47
+
48
+    /**
49
+     * Are the METS file's dmdSecs loaded?
50
+     * @see $dmdSec
51
+     *
52
+     * @var	boolean
53
+     * @access protected
54
+     */
55
+    protected $dmdSecLoaded = FALSE;
56
+
57
+    /**
58
+     * The extension key
59
+     *
60
+     * @var	string
61
+     * @access public
62
+     */
63
+    public static $extKey = 'dlf';
64
+
65
+    /**
66
+     * This holds the file ID -> USE concordance
67
+     * @see _getFileGrps()
68
+     *
69
+     * @var	array
70
+     * @access protected
71
+     */
72
+    protected $fileGrps = array ();
73
+
74
+    /**
75
+     * Are the file groups loaded?
76
+     * @see $fileGrps
77
+     *
78
+     * @var	boolean
79
+     * @access protected
80
+     */
81
+    protected $fileGrpsLoaded = FALSE;
82
+
83
+    /**
84
+     * This holds the configuration for all supported metadata encodings
85
+     * @see loadFormats()
86
+     *
87
+     * @var	array
88
+     * @access protected
89
+     */
90
+    protected $formats = array (
91
+        'METS' => array (
92
+            'rootElement' => 'mets',
93
+            'namespaceURI' => 'http://www.loc.gov/METS/',
94
+        ),
95
+        'XLINK' => array (
96
+            'rootElement' => 'xlink',
97
+            'namespaceURI' => 'http://www.w3.org/1999/xlink',
98
+        )
99
+    );
100
+
101
+    /**
102
+     * Are the available metadata formats loaded?
103
+     * @see $formats
104
+     *
105
+     * @var	boolean
106
+     * @access protected
107
+     */
108
+    protected $formatsLoaded = FALSE;
109
+
110
+    /**
111
+     * Are there any fulltext files available?
112
+     *
113
+     * @var boolean
114
+     * @access protected
115
+     */
116
+    protected $hasFulltext = FALSE;
117
+
118
+    /**
119
+     * This holds the documents location
120
+     *
121
+     * @var	string
122
+     * @access protected
123
+     */
124
+    protected $location = '';
125
+
126
+    /**
127
+     * This holds the logical units
128
+     *
129
+     * @var	array
130
+     * @access protected
131
+     */
132
+    protected $logicalUnits = array ();
133
+
134
+    /**
135
+     * This holds the documents' parsed metadata array with their corresponding structMap//div's ID as array key
136
+     *
137
+     * @var	array
138
+     * @access protected
139
+     */
140
+    protected $metadataArray = array ();
141
+
142
+    /**
143
+     * Is the metadata array loaded?
144
+     * @see $metadataArray
145
+     *
146
+     * @var	boolean
147
+     * @access protected
148
+     */
149
+    protected $metadataArrayLoaded = FALSE;
150
+
151
+    /**
152
+     * This holds the XML file's METS part as SimpleXMLElement object
153
+     *
154
+     * @var	SimpleXMLElement
155
+     * @access protected
156
+     */
157
+    protected $mets;
158
+
159
+    /**
160
+     * The holds the total number of pages
161
+     *
162
+     * @var	integer
163
+     * @access protected
164
+     */
165
+    protected $numPages = 0;
166
+
167
+    /**
168
+     * This holds the UID of the parent document or zero if not multi-volumed
169
+     *
170
+     * @var	integer
171
+     * @access protected
172
+     */
173
+    protected $parentId = 0;
174
+
175
+    /**
176
+     * This holds the physical structure
177
+     *
178
+     * @var	array
179
+     * @access protected
180
+     */
181
+    protected $physicalStructure = array ();
182
+
183
+    /**
184
+     * This holds the physical structure metadata
185
+     *
186
+     * @var	array
187
+     * @access protected
188
+     */
189
+    protected $physicalStructureInfo = array ();
190
+
191
+    /**
192
+     * Is the physical structure loaded?
193
+     * @see $physicalStructure
194
+     *
195
+     * @var	boolean
196
+     * @access protected
197
+     */
198
+    protected $physicalStructureLoaded = FALSE;
199
+
200
+    /**
201
+     * This holds the PID of the document or zero if not in database
202
+     *
203
+     * @var	integer
204
+     * @access protected
205
+     */
206
+    protected $pid = 0;
207
+
208
+    /**
209
+     * Is the document instantiated successfully?
210
+     *
211
+     * @var	boolean
212
+     * @access protected
213
+     */
214
+    protected $ready = FALSE;
215
+
216
+    /**
217
+     * The METS file's record identifier
218
+     *
219
+     * @var	string
220
+     * @access protected
221
+     */
222
+    protected $recordId;
223
+
224
+    /**
225
+     * This holds the singleton object of the document
226
+     *
227
+     * @var	array (tx_dlf_document)
228
+     * @access protected
229
+     */
230
+    protected static $registry = array ();
231
+
232
+    /**
233
+     * This holds the UID of the root document or zero if not multi-volumed
234
+     *
235
+     * @var	integer
236
+     * @access protected
237
+     */
238
+    protected $rootId = 0;
239
+
240
+    /**
241
+     * Is the root id loaded?
242
+     * @see $rootId
243
+     *
244
+     * @var	boolean
245
+     * @access protected
246
+     */
247
+    protected $rootIdLoaded = FALSE;
248
+
249
+    /**
250
+     * This holds the smLinks between logical and physical structMap
251
+     *
252
+     * @var	array
253
+     * @access protected
254
+     */
255
+    protected $smLinks = array ('l2p' => array (), 'p2l' => array ());
256
+
257
+    /**
258
+     * Are the smLinks loaded?
259
+     * @see $smLinks
260
+     *
261
+     * @var	boolean
262
+     * @access protected
263
+     */
264
+    protected $smLinksLoaded = FALSE;
265
+
266
+    /**
267
+     * This holds the logical structure
268
+     *
269
+     * @var	array
270
+     * @access protected
271
+     */
272
+    protected $tableOfContents = array ();
273
+
274
+    /**
275
+     * Is the table of contents loaded?
276
+     * @see $tableOfContents
277
+     *
278
+     * @var	boolean
279
+     * @access protected
280
+     */
281
+    protected $tableOfContentsLoaded = FALSE;
282
+
283
+    /**
284
+     * This holds the document's thumbnail location.
285
+     *
286
+     * @var	string
287
+     * @access protected
288
+     */
289
+    protected $thumbnail = '';
290
+
291
+    /**
292
+     * Is the document's thumbnail location loaded?
293
+     * @see $thumbnail
294
+     *
295
+     * @var	boolean
296
+     * @access protected
297
+     */
298
+    protected $thumbnailLoaded = FALSE;
299
+
300
+    /**
301
+     * This holds the toplevel structure's @ID
302
+     *
303
+     * @var	string
304
+     * @access protected
305
+     */
306
+    protected $toplevelId = '';
307
+
308
+    /**
309
+     * This holds the UID or the URL of the document
310
+     *
311
+     * @var	mixed
312
+     * @access protected
313
+     */
314
+    protected $uid = 0;
315
+
316
+    /**
317
+     * This holds the whole XML file as SimpleXMLElement object
318
+     *
319
+     * @var	SimpleXMLElement
320
+     * @access protected
321
+     */
322
+    protected $xml;
323
+
324
+    /**
325
+     * This clears the static registry to prevent memory exhaustion
326
+     *
327
+     * @access	public
328
+     *
329
+     * @return	void
330
+     */
331
+    public static function clearRegistry() {
332
+
333
+        // Reset registry array.
334
+        self::$registry = array ();
335
+
336
+    }
337
+
338
+    /**
339
+     * This gets the location of a file representing a physical page or track
340
+     *
341
+     * @access	public
342
+     *
343
+     * @param	string		$id: The @ID attribute of the file node
344
+     *
345
+     * @return	string		The file's location as URL
346
+     */
347
+    public function getFileLocation($id) {
348 348
 
349
-		if (!empty($id) && ($location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/mets:FLocat[@LOCTYPE="URL"]'))) {
349
+        if (!empty($id) && ($location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/mets:FLocat[@LOCTYPE="URL"]'))) {
350 350
 
351
-			return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href;
351
+            return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href;
352 352
 
353
-		} else {
353
+        } else {
354 354
 
355
-			if (TYPO3_DLOG) {
355
+            if (TYPO3_DLOG) {
356 356
 
357
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getFileLocation('.$id.')] There is no file node with @ID "'.$id.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
357
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getFileLocation('.$id.')] There is no file node with @ID "'.$id.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
358 358
 
359
-			}
359
+            }
360 360
 
361
-			return '';
361
+            return '';
362 362
 
363
-		}
363
+        }
364 364
 
365
-	}
365
+    }
366 366
 
367
-	/**
368
-	 * This gets the MIME type of a file representing a physical page or track
369
-	 *
370
-	 * @access	public
371
-	 *
372
-	 * @param	string		$id: The @ID attribute of the file node
373
-	 *
374
-	 * @return	string		The file's MIME type
375
-	 */
376
-	public function getFileMimeType($id) {
367
+    /**
368
+     * This gets the MIME type of a file representing a physical page or track
369
+     *
370
+     * @access	public
371
+     *
372
+     * @param	string		$id: The @ID attribute of the file node
373
+     *
374
+     * @return	string		The file's MIME type
375
+     */
376
+    public function getFileMimeType($id) {
377 377
 
378
-		if (!empty($id) && ($mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/@MIMETYPE'))) {
378
+        if (!empty($id) && ($mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/@MIMETYPE'))) {
379 379
 
380
-			return (string) $mimetype[0];
380
+            return (string) $mimetype[0];
381 381
 
382
-		} else {
382
+        } else {
383 383
 
384
-			if (TYPO3_DLOG) {
384
+            if (TYPO3_DLOG) {
385 385
 
386
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getFileMimeType('.$id.')] There is no file node with @ID "'.$id.'" or no MIME type specified', self::$extKey, SYSLOG_SEVERITY_WARNING);
386
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getFileMimeType('.$id.')] There is no file node with @ID "'.$id.'" or no MIME type specified', self::$extKey, SYSLOG_SEVERITY_WARNING);
387 387
 
388
-			}
388
+            }
389 389
 
390
-			return '';
390
+            return '';
391 391
 
392
-		}
392
+        }
393 393
 
394
-	}
394
+    }
395 395
 
396
-	/**
397
-	 * This is a singleton class, thus an instance must be created by this method
398
-	 *
399
-	 * @access	public
400
-	 *
401
-	 * @param	mixed		$uid: The unique identifier of the document to parse or URL of XML file
402
-	 * @param	integer		$pid: If > 0, then only document with this PID gets loaded
403
-	 * @param	boolean		$forceReload: Force reloading the document instead of returning the cached instance
404
-	 *
405
-	 * @return	&tx_dlf_document		Instance of this class
406
-	 */
407
-	public static function &getInstance($uid, $pid = 0, $forceReload = FALSE) {
396
+    /**
397
+     * This is a singleton class, thus an instance must be created by this method
398
+     *
399
+     * @access	public
400
+     *
401
+     * @param	mixed		$uid: The unique identifier of the document to parse or URL of XML file
402
+     * @param	integer		$pid: If > 0, then only document with this PID gets loaded
403
+     * @param	boolean		$forceReload: Force reloading the document instead of returning the cached instance
404
+     *
405
+     * @return	&tx_dlf_document		Instance of this class
406
+     */
407
+    public static function &getInstance($uid, $pid = 0, $forceReload = FALSE) {
408 408
 
409
-		// Sanitize input.
410
-		$pid = max(intval($pid), 0);
409
+        // Sanitize input.
410
+        $pid = max(intval($pid), 0);
411 411
 
412
-		if (!$forceReload) {
412
+        if (!$forceReload) {
413 413
 
414
-			$regObj = md5($uid);
414
+            $regObj = md5($uid);
415 415
 
416
-			if (is_object(self::$registry[$regObj]) && self::$registry[$regObj] instanceof self) {
416
+            if (is_object(self::$registry[$regObj]) && self::$registry[$regObj] instanceof self) {
417 417
 
418
-				// Check if instance has given PID.
419
-				if (!$pid || !self::$registry[$regObj]->pid || $pid == self::$registry[$regObj]->pid) {
418
+                // Check if instance has given PID.
419
+                if (!$pid || !self::$registry[$regObj]->pid || $pid == self::$registry[$regObj]->pid) {
420 420
 
421
-					// Return singleton instance if available.
422
-					return self::$registry[$regObj];
421
+                    // Return singleton instance if available.
422
+                    return self::$registry[$regObj];
423 423
 
424
-				}
424
+                }
425 425
 
426
-			} else {
426
+            } else {
427 427
 
428
-				// Check the user's session...
429
-				$sessionData = tx_dlf_helper::loadFromSession(get_called_class());
428
+                // Check the user's session...
429
+                $sessionData = tx_dlf_helper::loadFromSession(get_called_class());
430 430
 
431
-				if (is_object($sessionData[$regObj]) && $sessionData[$regObj] instanceof self) {
431
+                if (is_object($sessionData[$regObj]) && $sessionData[$regObj] instanceof self) {
432 432
 
433
-					// Check if instance has given PID.
434
-					if (!$pid || !$sessionData[$regObj]->pid || $pid == $sessionData[$regObj]->pid) {
433
+                    // Check if instance has given PID.
434
+                    if (!$pid || !$sessionData[$regObj]->pid || $pid == $sessionData[$regObj]->pid) {
435 435
 
436
-						// ...and restore registry.
437
-						self::$registry[$regObj] = $sessionData[$regObj];
436
+                        // ...and restore registry.
437
+                        self::$registry[$regObj] = $sessionData[$regObj];
438 438
 
439
-						return self::$registry[$regObj];
439
+                        return self::$registry[$regObj];
440 440
 
441
-					}
441
+                    }
442 442
 
443
-				}
443
+                }
444 444
 
445
-			}
445
+            }
446 446
 
447
-		}
447
+        }
448 448
 
449
-		// Create new instance...
450
-		$instance = new self($uid, $pid);
449
+        // Create new instance...
450
+        $instance = new self($uid, $pid);
451 451
 
452
-		// ...and save it to registry.
453
-		if ($instance->ready) {
452
+        // ...and save it to registry.
453
+        if ($instance->ready) {
454 454
 
455
-			self::$registry[md5($instance->uid)] = $instance;
455
+            self::$registry[md5($instance->uid)] = $instance;
456 456
 
457
-			if ($instance->uid != $instance->location) {
457
+            if ($instance->uid != $instance->location) {
458 458
 
459
-				self::$registry[md5($instance->location)] = $instance;
459
+                self::$registry[md5($instance->location)] = $instance;
460 460
 
461
-			}
461
+            }
462 462
 
463
-			// Load extension configuration
464
-			$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
463
+            // Load extension configuration
464
+            $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
465 465
 
466
-			// Save registry to session if caching is enabled.
467
-			if (!empty($extConf['caching'])) {
466
+            // Save registry to session if caching is enabled.
467
+            if (!empty($extConf['caching'])) {
468 468
 
469
-				tx_dlf_helper::saveToSession(self::$registry, get_class($instance));
469
+                tx_dlf_helper::saveToSession(self::$registry, get_class($instance));
470 470
 
471
-			}
471
+            }
472 472
 
473
-		}
473
+        }
474 474
 
475
-		// Return new instance.
476
-		return $instance;
475
+        // Return new instance.
476
+        return $instance;
477 477
 
478
-	}
478
+    }
479 479
 
480
-	/**
481
-	 * This gets details about a logical structure element
482
-	 *
483
-	 * @access	public
484
-	 *
485
-	 * @param	string		$id: The @ID attribute of the logical structure node
486
-	 * @param	boolean		$recursive: Whether to include the child elements
487
-	 *
488
-	 * @return	array		Array of the element's id, label, type and physical page indexes/mptr link
489
-	 */
490
-	public function getLogicalStructure($id, $recursive = FALSE) {
480
+    /**
481
+     * This gets details about a logical structure element
482
+     *
483
+     * @access	public
484
+     *
485
+     * @param	string		$id: The @ID attribute of the logical structure node
486
+     * @param	boolean		$recursive: Whether to include the child elements
487
+     *
488
+     * @return	array		Array of the element's id, label, type and physical page indexes/mptr link
489
+     */
490
+    public function getLogicalStructure($id, $recursive = FALSE) {
491 491
 
492
-		$details = array ();
492
+        $details = array ();
493 493
 
494
-		// Is the requested logical unit already loaded?
495
-		if (!$recursive && !empty($this->logicalUnits[$id])) {
494
+        // Is the requested logical unit already loaded?
495
+        if (!$recursive && !empty($this->logicalUnits[$id])) {
496 496
 
497
-			// Yes. Return it.
498
-			return $this->logicalUnits[$id];
497
+            // Yes. Return it.
498
+            return $this->logicalUnits[$id];
499 499
 
500
-		} elseif (!empty($id)) {
500
+        } elseif (!empty($id)) {
501 501
 
502
-			// Get specified logical unit.
503
-			$divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]');
502
+            // Get specified logical unit.
503
+            $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]');
504 504
 
505
-		} else {
505
+        } else {
506 506
 
507
-			// Get all logical units at top level.
508
-			$divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]/mets:div');
507
+            // Get all logical units at top level.
508
+            $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]/mets:div');
509 509
 
510
-		}
510
+        }
511 511
 
512
-		if (!empty($divs)) {
512
+        if (!empty($divs)) {
513 513
 
514
-			if (!$recursive) {
514
+            if (!$recursive) {
515 515
 
516
-				// Get the details for the first xpath hit.
517
-				$details = $this->getLogicalStructureInfo($divs[0]);
516
+                // Get the details for the first xpath hit.
517
+                $details = $this->getLogicalStructureInfo($divs[0]);
518 518
 
519
-			} else {
519
+            } else {
520 520
 
521
-				// Walk the logical structure recursively and fill the whole table of contents.
522
-				foreach ($divs as $div) {
521
+                // Walk the logical structure recursively and fill the whole table of contents.
522
+                foreach ($divs as $div) {
523 523
 
524
-					$this->tableOfContents[] = $this->getLogicalStructureInfo($div, TRUE);
524
+                    $this->tableOfContents[] = $this->getLogicalStructureInfo($div, TRUE);
525 525
 
526
-				}
526
+                }
527 527
 
528
-			}
528
+            }
529 529
 
530
-		}
530
+        }
531 531
 
532
-		return $details;
532
+        return $details;
533 533
 
534
-	}
534
+    }
535 535
 
536
-	/**
537
-	 * This gets details about a logical structure element
538
-	 *
539
-	 * @access	protected
540
-	 *
541
-	 * @param	SimpleXMLElement		$structure: The logical structure node
542
-	 * @param	boolean		$recursive: Whether to include the child elements
543
-	 *
544
-	 * @return	array		Array of the element's id, label, type and physical page indexes/mptr link
545
-	 */
546
-	protected function getLogicalStructureInfo(SimpleXMLElement $structure, $recursive = FALSE) {
536
+    /**
537
+     * This gets details about a logical structure element
538
+     *
539
+     * @access	protected
540
+     *
541
+     * @param	SimpleXMLElement		$structure: The logical structure node
542
+     * @param	boolean		$recursive: Whether to include the child elements
543
+     *
544
+     * @return	array		Array of the element's id, label, type and physical page indexes/mptr link
545
+     */
546
+    protected function getLogicalStructureInfo(SimpleXMLElement $structure, $recursive = FALSE) {
547 547
 
548
-		// Get attributes.
549
-		foreach ($structure->attributes() as $attribute => $value) {
548
+        // Get attributes.
549
+        foreach ($structure->attributes() as $attribute => $value) {
550 550
 
551
-			$attributes[$attribute] = (string) $value;
551
+            $attributes[$attribute] = (string) $value;
552 552
 
553
-		}
553
+        }
554 554
 
555
-		// Load plugin configuration.
556
-		$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
555
+        // Load plugin configuration.
556
+        $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
557 557
 
558
-		// Extract identity information.
559
-		$details = array ();
558
+        // Extract identity information.
559
+        $details = array ();
560 560
 
561
-		$details['id'] = $attributes['ID'];
561
+        $details['id'] = $attributes['ID'];
562 562
 
563
-		$details['dmdId'] = (isset($attributes['DMDID']) ?  $attributes['DMDID'] : '');
563
+        $details['dmdId'] = (isset($attributes['DMDID']) ?  $attributes['DMDID'] : '');
564 564
 
565
-		$details['label'] = (isset($attributes['LABEL']) ? $attributes['LABEL'] : '');
565
+        $details['label'] = (isset($attributes['LABEL']) ? $attributes['LABEL'] : '');
566 566
 
567
-		$details['orderlabel'] = (isset($attributes['ORDERLABEL']) ? $attributes['ORDERLABEL'] : '');
567
+        $details['orderlabel'] = (isset($attributes['ORDERLABEL']) ? $attributes['ORDERLABEL'] : '');
568 568
 
569
-		$details['contentIds'] = (isset($attributes['CONTENTIDS']) ? $attributes['CONTENTIDS'] : '');
569
+        $details['contentIds'] = (isset($attributes['CONTENTIDS']) ? $attributes['CONTENTIDS'] : '');
570 570
 
571
-		$details['volume'] = '';
571
+        $details['volume'] = '';
572 572
 
573
-		// Set volume information only if no label is set and this is the toplevel structure element.
574
-		if (empty($details['label']) && $details['id'] == $this->_getToplevelId()) {
573
+        // Set volume information only if no label is set and this is the toplevel structure element.
574
+        if (empty($details['label']) && $details['id'] == $this->_getToplevelId()) {
575 575
 
576
-			$metadata = $this->getMetadata($details['id']);
576
+            $metadata = $this->getMetadata($details['id']);
577 577
 
578
-			if (!empty($metadata['volume'][0])) {
578
+            if (!empty($metadata['volume'][0])) {
579 579
 
580
-				$details['volume'] = $metadata['volume'][0];
580
+                $details['volume'] = $metadata['volume'][0];
581 581
 
582
-			}
582
+            }
583 583
 
584
-		}
584
+        }
585 585
 
586
-		$details['pagination'] = '';
586
+        $details['pagination'] = '';
587 587
 
588
-		$details['type'] = $attributes['TYPE'];
588
+        $details['type'] = $attributes['TYPE'];
589 589
 
590
-		$details['thumbnailId'] = '';
590
+        $details['thumbnailId'] = '';
591 591
 
592
-		// Load smLinks.
593
-		$this->_getSmLinks();
592
+        // Load smLinks.
593
+        $this->_getSmLinks();
594 594
 
595
-		// Load physical structure.
596
-		$this->_getPhysicalStructure();
595
+        // Load physical structure.
596
+        $this->_getPhysicalStructure();
597 597
 
598
-		// Get the physical page or external file this structure element is pointing at.
599
-		$details['points'] = '';
598
+        // Get the physical page or external file this structure element is pointing at.
599
+        $details['points'] = '';
600 600
 
601
-		// Is there a mptr node?
602
-		if (count($structure->children('http://www.loc.gov/METS/')->mptr)) {
601
+        // Is there a mptr node?
602
+        if (count($structure->children('http://www.loc.gov/METS/')->mptr)) {
603 603
 
604
-			// Yes. Get the file reference.
605
-			$details['points'] = (string) $structure->children('http://www.loc.gov/METS/')->mptr[0]->attributes('http://www.w3.org/1999/xlink')->href;
604
+            // Yes. Get the file reference.
605
+            $details['points'] = (string) $structure->children('http://www.loc.gov/METS/')->mptr[0]->attributes('http://www.w3.org/1999/xlink')->href;
606 606
 
607
-		// Are there any physical elements and is this logical unit linked to at least one of them?
608
-		} elseif (!empty($this->physicalStructure) && array_key_exists($details['id'], $this->smLinks['l2p'])) {
607
+        // Are there any physical elements and is this logical unit linked to at least one of them?
608
+        } elseif (!empty($this->physicalStructure) && array_key_exists($details['id'], $this->smLinks['l2p'])) {
609 609
 
610
-			$details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE)), 1);
610
+            $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE)), 1);
611 611
 
612
-			if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']])) {
612
+            if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']])) {
613 613
 
614
-				$details['thumbnailId'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']];
614
+                $details['thumbnailId'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']];
615 615
 
616
-			}
616
+            }
617 617
 
618
-			// Get page/track number of the first page/track related to this structure element.
619
-			$details['pagination'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['orderlabel'];
618
+            // Get page/track number of the first page/track related to this structure element.
619
+            $details['pagination'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['orderlabel'];
620 620
 
621
-		// Is this the toplevel structure element?
622
-		} elseif ($details['id'] == $this->_getToplevelId()) {
621
+        // Is this the toplevel structure element?
622
+        } elseif ($details['id'] == $this->_getToplevelId()) {
623 623
 
624
-			// Yes. Point to itself.
625
-			$details['points'] = 1;
624
+            // Yes. Point to itself.
625
+            $details['points'] = 1;
626 626
 
627
-			if (!empty($this->physicalStructure) && !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']])) {
627
+            if (!empty($this->physicalStructure) && !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']])) {
628 628
 
629
-				$details['thumbnailId'] = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']];
629
+                $details['thumbnailId'] = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']];
630 630
 
631
-			}
631
+            }
632 632
 
633
-		}
633
+        }
634 634
 
635
-		// Get the files this structure element is pointing at.
636
-		$details['files'] = array ();
635
+        // Get the files this structure element is pointing at.
636
+        $details['files'] = array ();
637 637
 
638
-		$fileUse = $this->_getFileGrps();
638
+        $fileUse = $this->_getFileGrps();
639 639
 
640
-		// Get the file representations from fileSec node.
641
-		foreach ($structure->children('http://www.loc.gov/METS/')->fptr as $fptr) {
640
+        // Get the file representations from fileSec node.
641
+        foreach ($structure->children('http://www.loc.gov/METS/')->fptr as $fptr) {
642 642
 
643
-			// Check if file has valid @USE attribute.
644
-			if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) {
643
+            // Check if file has valid @USE attribute.
644
+            if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) {
645 645
 
646
-				$details['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID;
646
+                $details['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID;
647 647
 
648
-			}
648
+            }
649 649
 
650
-		}
650
+        }
651 651
 
652
-		// Keep for later usage.
653
-		$this->logicalUnits[$details['id']] = $details;
652
+        // Keep for later usage.
653
+        $this->logicalUnits[$details['id']] = $details;
654 654
 
655
-		// Walk the structure recursively? And are there any children of the current element?
656
-		if ($recursive && count($structure->children('http://www.loc.gov/METS/')->div)) {
655
+        // Walk the structure recursively? And are there any children of the current element?
656
+        if ($recursive && count($structure->children('http://www.loc.gov/METS/')->div)) {
657 657
 
658
-			$details['children'] = array ();
658
+            $details['children'] = array ();
659 659
 
660
-			foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) {
660
+            foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) {
661 661
 
662
-				// Repeat for all children.
663
-				$details['children'][] = $this->getLogicalStructureInfo($child, TRUE);
662
+                // Repeat for all children.
663
+                $details['children'][] = $this->getLogicalStructureInfo($child, TRUE);
664 664
 
665
-			}
665
+            }
666 666
 
667
-		}
667
+        }
668 668
 
669
-		return $details;
669
+        return $details;
670 670
 
671
-	}
671
+    }
672 672
 
673
-	/**
674
-	 * This extracts all the metadata for a logical structure node
675
-	 *
676
-	 * @access	public
677
-	 *
678
-	 * @param	string		$id: The @ID attribute of the logical structure node
679
-	 * @param	integer		$cPid: The PID for the metadata definitions
680
-	 * 						(defaults to $this->cPid or $this->pid)
681
-	 *
682
-	 * @return	array		The logical structure node's parsed metadata array
683
-	 */
684
-	public function getMetadata($id, $cPid = 0) {
673
+    /**
674
+     * This extracts all the metadata for a logical structure node
675
+     *
676
+     * @access	public
677
+     *
678
+     * @param	string		$id: The @ID attribute of the logical structure node
679
+     * @param	integer		$cPid: The PID for the metadata definitions
680
+     * 						(defaults to $this->cPid or $this->pid)
681
+     *
682
+     * @return	array		The logical structure node's parsed metadata array
683
+     */
684
+    public function getMetadata($id, $cPid = 0) {
685 685
 
686
-		// Save parameter for logging purposes.
687
-		$_cPid = $cPid;
686
+        // Save parameter for logging purposes.
687
+        $_cPid = $cPid;
688 688
 
689
-		// Make sure $cPid is a non-negative integer.
690
-		$cPid = max(intval($cPid), 0);
689
+        // Make sure $cPid is a non-negative integer.
690
+        $cPid = max(intval($cPid), 0);
691 691
 
692
-		// If $cPid is not given, try to get it elsewhere.
693
-		if (!$cPid && ($this->cPid || $this->pid)) {
692
+        // If $cPid is not given, try to get it elsewhere.
693
+        if (!$cPid && ($this->cPid || $this->pid)) {
694 694
 
695
-			// Retain current PID.
696
-			$cPid = ($this->cPid ? $this->cPid : $this->pid);
695
+            // Retain current PID.
696
+            $cPid = ($this->cPid ? $this->cPid : $this->pid);
697 697
 
698
-		} elseif (!$cPid) {
698
+        } elseif (!$cPid) {
699 699
 
700
-			if (TYPO3_DLOG) {
700
+            if (TYPO3_DLOG) {
701 701
 
702
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR);
702
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR);
703 703
 
704
-			}
704
+            }
705 705
 
706
-			return array ();
706
+            return array ();
707 707
 
708
-		}
708
+        }
709 709
 
710
-		// Get metadata from parsed metadata array if available.
711
-		if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) {
710
+        // Get metadata from parsed metadata array if available.
711
+        if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) {
712 712
 
713
-			return $this->metadataArray[$id];
713
+            return $this->metadataArray[$id];
714 714
 
715
-		}
715
+        }
716 716
 
717
-		// Initialize metadata array with empty values.
718
-		$metadata = array (
719
-			'title' => array (),
720
-			'title_sorting' => array (),
721
-			'author' => array (),
722
-			'place' => array (),
723
-			'year' => array (),
724
-			'prod_id' => array (),
725
-			'record_id' => array (),
726
-			'opac_id' => array (),
727
-			'union_id' => array (),
728
-			'urn' => array (),
729
-			'purl' => array (),
730
-			'type' => array (),
731
-			'volume' => array (),
732
-			'volume_sorting' => array (),
733
-			'collection' => array (),
734
-			'owner' => array (),
735
-		);
717
+        // Initialize metadata array with empty values.
718
+        $metadata = array (
719
+            'title' => array (),
720
+            'title_sorting' => array (),
721
+            'author' => array (),
722
+            'place' => array (),
723
+            'year' => array (),
724
+            'prod_id' => array (),
725
+            'record_id' => array (),
726
+            'opac_id' => array (),
727
+            'union_id' => array (),
728
+            'urn' => array (),
729
+            'purl' => array (),
730
+            'type' => array (),
731
+            'volume' => array (),
732
+            'volume_sorting' => array (),
733
+            'collection' => array (),
734
+            'owner' => array (),
735
+        );
736 736
 
737
-		// Get the logical structure node's DMDID.
738
-		if (!empty($this->logicalUnits[$id])) {
737
+        // Get the logical structure node's DMDID.
738
+        if (!empty($this->logicalUnits[$id])) {
739 739
 
740
-			$dmdId = $this->logicalUnits[$id]['dmdId'];
740
+            $dmdId = $this->logicalUnits[$id]['dmdId'];
741 741
 
742
-		} else {
742
+        } else {
743 743
 
744
-			$dmdId = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@DMDID');
744
+            $dmdId = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@DMDID');
745 745
 
746
-			$dmdId = (string) $dmdId[0];
746
+            $dmdId = (string) $dmdId[0];
747 747
 
748
-		}
748
+        }
749 749
 
750
-		if (!empty($dmdId)) {
750
+        if (!empty($dmdId)) {
751 751
 
752
-			// Load available metadata formats and dmdSecs.
753
-			$this->loadFormats();
752
+            // Load available metadata formats and dmdSecs.
753
+            $this->loadFormats();
754 754
 
755
-			$this->_getDmdSec();
755
+            $this->_getDmdSec();
756 756
 
757
-			// Is this metadata format supported?
758
-			if (!empty($this->formats[$this->dmdSec[$dmdId]['type']])) {
757
+            // Is this metadata format supported?
758
+            if (!empty($this->formats[$this->dmdSec[$dmdId]['type']])) {
759 759
 
760
-				if (!empty($this->formats[$this->dmdSec[$dmdId]['type']]['class'])) {
760
+                if (!empty($this->formats[$this->dmdSec[$dmdId]['type']]['class'])) {
761 761
 
762
-					$class = $this->formats[$this->dmdSec[$dmdId]['type']]['class'];
762
+                    $class = $this->formats[$this->dmdSec[$dmdId]['type']]['class'];
763 763
 
764
-					// Get the metadata from class.
765
-					if (class_exists($class) && ($obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class)) instanceof tx_dlf_format) {
764
+                    // Get the metadata from class.
765
+                    if (class_exists($class) && ($obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class)) instanceof tx_dlf_format) {
766 766
 
767
-						$obj->extractMetadata($this->dmdSec[$dmdId]['xml'], $metadata);
767
+                        $obj->extractMetadata($this->dmdSec[$dmdId]['xml'], $metadata);
768 768
 
769
-					} else {
769
+                    } else {
770 770
 
771
-						if (TYPO3_DLOG) {
771
+                        if (TYPO3_DLOG) {
772 772
 
773
-							\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Invalid class/method "'.$class.'->extractMetadata()" for metadata format "'.$this->dmdSec[$dmdId]['type'].'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
773
+                            \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Invalid class/method "'.$class.'->extractMetadata()" for metadata format "'.$this->dmdSec[$dmdId]['type'].'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
774 774
 
775
-						}
775
+                        }
776 776
 
777
-					}
777
+                    }
778 778
 
779
-				}
779
+                }
780 780
 
781
-			} else {
781
+            } else {
782 782
 
783
-				if (TYPO3_DLOG) {
783
+                if (TYPO3_DLOG) {
784 784
 
785
-					\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Unsupported metadata format "'.$this->dmdSec[$dmdId]['type'].'" in dmdSec with @ID "'.$dmdId.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
785
+                    \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Unsupported metadata format "'.$this->dmdSec[$dmdId]['type'].'" in dmdSec with @ID "'.$dmdId.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
786 786
 
787
-				}
787
+                }
788 788
 
789
-				return array ();
789
+                return array ();
790 790
 
791
-			}
791
+            }
792 792
 
793
-			// Get the structure's type.
794
-			if (!empty($this->logicalUnits[$id])) {
793
+            // Get the structure's type.
794
+            if (!empty($this->logicalUnits[$id])) {
795 795
 
796
-				$metadata['type'] = array ($this->logicalUnits[$id]['type']);
796
+                $metadata['type'] = array ($this->logicalUnits[$id]['type']);
797 797
 
798
-			} else {
798
+            } else {
799 799
 
800
-				$struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE');
800
+                $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE');
801 801
 
802
-				$metadata['type'] = array ((string) $struct[0]);
802
+                $metadata['type'] = array ((string) $struct[0]);
803 803
 
804
-			}
804
+            }
805 805
 
806
-			// Get the additional metadata from database.
807
-			$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
808
-				'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadataformat.xpath AS xpath,tx_dlf_metadataformat.xpath_sorting AS xpath_sorting,tx_dlf_metadata.is_sortable AS is_sortable,tx_dlf_metadata.default_value AS default_value,tx_dlf_metadata.format AS format',
809
-				'tx_dlf_metadata,tx_dlf_metadataformat,tx_dlf_formats',
810
-				'tx_dlf_metadata.pid='.$cPid.' AND tx_dlf_metadataformat.pid='.$cPid.' AND ((tx_dlf_metadata.uid=tx_dlf_metadataformat.parent_id AND tx_dlf_metadataformat.encoded=tx_dlf_formats.uid AND tx_dlf_formats.type='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->dmdSec[$dmdId]['type'], 'tx_dlf_formats').') OR tx_dlf_metadata.format=0)'.tx_dlf_helper::whereClause('tx_dlf_metadata', TRUE).tx_dlf_helper::whereClause('tx_dlf_metadataformat').tx_dlf_helper::whereClause('tx_dlf_formats'),
811
-				'',
812
-				'',
813
-				''
814
-			);
806
+            // Get the additional metadata from database.
807
+            $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
808
+                'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadataformat.xpath AS xpath,tx_dlf_metadataformat.xpath_sorting AS xpath_sorting,tx_dlf_metadata.is_sortable AS is_sortable,tx_dlf_metadata.default_value AS default_value,tx_dlf_metadata.format AS format',
809
+                'tx_dlf_metadata,tx_dlf_metadataformat,tx_dlf_formats',
810
+                'tx_dlf_metadata.pid='.$cPid.' AND tx_dlf_metadataformat.pid='.$cPid.' AND ((tx_dlf_metadata.uid=tx_dlf_metadataformat.parent_id AND tx_dlf_metadataformat.encoded=tx_dlf_formats.uid AND tx_dlf_formats.type='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->dmdSec[$dmdId]['type'], 'tx_dlf_formats').') OR tx_dlf_metadata.format=0)'.tx_dlf_helper::whereClause('tx_dlf_metadata', TRUE).tx_dlf_helper::whereClause('tx_dlf_metadataformat').tx_dlf_helper::whereClause('tx_dlf_formats'),
811
+                '',
812
+                '',
813
+                ''
814
+            );
815 815
 
816
-			// We need a DOMDocument here, because SimpleXML doesn't support XPath functions properly.
817
-			$domNode = dom_import_simplexml($this->dmdSec[$dmdId]['xml']);
816
+            // We need a DOMDocument here, because SimpleXML doesn't support XPath functions properly.
817
+            $domNode = dom_import_simplexml($this->dmdSec[$dmdId]['xml']);
818 818
 
819
-			$domXPath = new DOMXPath($domNode->ownerDocument);
819
+            $domXPath = new DOMXPath($domNode->ownerDocument);
820 820
 
821
-			$this->registerNamespaces($domXPath);
821
+            $this->registerNamespaces($domXPath);
822 822
 
823
-			// OK, now make the XPath queries.
824
-			while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
823
+            // OK, now make the XPath queries.
824
+            while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
825 825
 
826
-				// Set metadata field's value(s).
827
-				if ($resArray['format'] > 0 && !empty($resArray['xpath']) && ($values = $domXPath->evaluate($resArray['xpath'], $domNode))) {
826
+                // Set metadata field's value(s).
827
+                if ($resArray['format'] > 0 && !empty($resArray['xpath']) && ($values = $domXPath->evaluate($resArray['xpath'], $domNode))) {
828 828
 
829
-					if ($values instanceof DOMNodeList && $values->length > 0) {
829
+                    if ($values instanceof DOMNodeList && $values->length > 0) {
830 830
 
831
-						$metadata[$resArray['index_name']] = array ();
831
+                        $metadata[$resArray['index_name']] = array ();
832 832
 
833
-						foreach ($values as $value) {
833
+                        foreach ($values as $value) {
834 834
 
835
-							$metadata[$resArray['index_name']][] = trim((string) $value->nodeValue);
835
+                            $metadata[$resArray['index_name']][] = trim((string) $value->nodeValue);
836 836
 
837
-						}
837
+                        }
838 838
 
839
-					} elseif (!($values instanceof DOMNodeList)) {
839
+                    } elseif (!($values instanceof DOMNodeList)) {
840 840
 
841
-						$metadata[$resArray['index_name']] = array (trim((string) $values));
841
+                        $metadata[$resArray['index_name']] = array (trim((string) $values));
842 842
 
843
-					}
843
+                    }
844 844
 
845
-				}
845
+                }
846 846
 
847
-				// Set default value if applicable.
848
-				if (empty($metadata[$resArray['index_name']][0]) && $resArray['default_value']) {
847
+                // Set default value if applicable.
848
+                if (empty($metadata[$resArray['index_name']][0]) && $resArray['default_value']) {
849 849
 
850
-					$metadata[$resArray['index_name']] = array ($resArray['default_value']);
850
+                    $metadata[$resArray['index_name']] = array ($resArray['default_value']);
851 851
 
852
-				}
852
+                }
853 853
 
854
-				// Set sorting value if applicable.
855
-				if (!empty($metadata[$resArray['index_name']]) && $resArray['is_sortable']) {
854
+                // Set sorting value if applicable.
855
+                if (!empty($metadata[$resArray['index_name']]) && $resArray['is_sortable']) {
856 856
 
857
-					if ($resArray['format'] > 0 && !empty($resArray['xpath_sorting']) && ($values = $domXPath->evaluate($resArray['xpath_sorting'], $domNode))) {
857
+                    if ($resArray['format'] > 0 && !empty($resArray['xpath_sorting']) && ($values = $domXPath->evaluate($resArray['xpath_sorting'], $domNode))) {
858 858
 
859
-						if ($values instanceof DOMNodeList && $values->length > 0) {
859
+                        if ($values instanceof DOMNodeList && $values->length > 0) {
860 860
 
861
-							$metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values->item(0)->nodeValue);
861
+                            $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values->item(0)->nodeValue);
862 862
 
863
-						} elseif (!($values instanceof DOMNodeList)) {
863
+                        } elseif (!($values instanceof DOMNodeList)) {
864 864
 
865
-							$metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values);
865
+                            $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values);
866 866
 
867
-						}
867
+                        }
868 868
 
869
-					}
869
+                    }
870 870
 
871
-					if (empty($metadata[$resArray['index_name'].'_sorting'][0])) {
871
+                    if (empty($metadata[$resArray['index_name'].'_sorting'][0])) {
872 872
 
873
-						$metadata[$resArray['index_name'].'_sorting'][0] = $metadata[$resArray['index_name']][0];
873
+                        $metadata[$resArray['index_name'].'_sorting'][0] = $metadata[$resArray['index_name']][0];
874 874
 
875
-					}
875
+                    }
876 876
 
877
-				}
877
+                }
878 878
 
879
-			}
879
+            }
880 880
 
881
-			// Set title to empty string if not present.
882
-			if (empty($metadata['title'][0])) {
881
+            // Set title to empty string if not present.
882
+            if (empty($metadata['title'][0])) {
883 883
 
884
-				$metadata['title'][0] = '';
884
+                $metadata['title'][0] = '';
885 885
 
886
-				$metadata['title_sorting'][0] = '';
886
+                $metadata['title_sorting'][0] = '';
887 887
 
888
-			}
888
+            }
889 889
 
890
-		} else {
890
+        } else {
891 891
 
892
-			// There is no dmdSec for this structure node.
893
-			return array ();
892
+            // There is no dmdSec for this structure node.
893
+            return array ();
894 894
 
895
-		}
895
+        }
896 896
 
897
-		return $metadata;
897
+        return $metadata;
898 898
 
899
-	}
899
+    }
900 900
 
901
-	/**
902
-	 * This determines a title for the given document
903
-	 *
904
-	 * @access	public
905
-	 *
906
-	 * @param	integer		$uid: The UID of the document
907
-	 * @param	boolean		$recursive: Search superior documents for a title, too?
908
-	 *
909
-	 * @return	string		The title of the document itself or a parent document
910
-	 */
911
-	public static function getTitle($uid, $recursive = FALSE) {
901
+    /**
902
+     * This determines a title for the given document
903
+     *
904
+     * @access	public
905
+     *
906
+     * @param	integer		$uid: The UID of the document
907
+     * @param	boolean		$recursive: Search superior documents for a title, too?
908
+     *
909
+     * @return	string		The title of the document itself or a parent document
910
+     */
911
+    public static function getTitle($uid, $recursive = FALSE) {
912 912
 
913
-		// Save parameter for logging purposes.
914
-		$_uid = $uid;
913
+        // Save parameter for logging purposes.
914
+        $_uid = $uid;
915 915
 
916
-		$title = '';
916
+        $title = '';
917 917
 
918
-		// Sanitize input.
919
-		$uid = max(intval($uid), 0);
918
+        // Sanitize input.
919
+        $uid = max(intval($uid), 0);
920 920
 
921
-		if ($uid) {
921
+        if ($uid) {
922 922
 
923
-			$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
924
-				'tx_dlf_documents.title,tx_dlf_documents.partof',
925
-				'tx_dlf_documents',
926
-				'tx_dlf_documents.uid='.$uid.tx_dlf_helper::whereClause('tx_dlf_documents'),
927
-				'',
928
-				'',
929
-				'1'
930
-			);
923
+            $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
924
+                'tx_dlf_documents.title,tx_dlf_documents.partof',
925
+                'tx_dlf_documents',
926
+                'tx_dlf_documents.uid='.$uid.tx_dlf_helper::whereClause('tx_dlf_documents'),
927
+                '',
928
+                '',
929
+                '1'
930
+            );
931 931
 
932
-			if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
932
+            if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
933 933
 
934
-				// Get title information.
935
-				list ($title, $partof) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
934
+                // Get title information.
935
+                list ($title, $partof) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
936 936
 
937
-				// Search parent documents recursively for a title?
938
-				if ($recursive && empty($title) && intval($partof) && $partof != $uid) {
937
+                // Search parent documents recursively for a title?
938
+                if ($recursive && empty($title) && intval($partof) && $partof != $uid) {
939 939
 
940
-					$title = self::getTitle($partof, TRUE);
940
+                    $title = self::getTitle($partof, TRUE);
941 941
 
942
-				}
942
+                }
943 943
 
944
-			} else {
944
+            } else {
945 945
 
946
-				if (TYPO3_DLOG) {
946
+                if (TYPO3_DLOG) {
947 947
 
948
-					\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getTitle('.$_uid.', ['.($recursive ? 'TRUE' : 'FALSE').'])] No document with UID "'.$uid.'" found or document not accessible', self::$extKey, SYSLOG_SEVERITY_WARNING);
948
+                    \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getTitle('.$_uid.', ['.($recursive ? 'TRUE' : 'FALSE').'])] No document with UID "'.$uid.'" found or document not accessible', self::$extKey, SYSLOG_SEVERITY_WARNING);
949 949
 
950
-				}
950
+                }
951 951
 
952
-			}
952
+            }
953 953
 
954
-		} else {
954
+        } else {
955 955
 
956
-			if (TYPO3_DLOG) {
956
+            if (TYPO3_DLOG) {
957 957
 
958
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getTitle('.$_uid.', ['.($recursive ? 'TRUE' : 'FALSE').'])] Invalid UID "'.$uid.'" for document', self::$extKey, SYSLOG_SEVERITY_ERROR);
958
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getTitle('.$_uid.', ['.($recursive ? 'TRUE' : 'FALSE').'])] Invalid UID "'.$uid.'" for document', self::$extKey, SYSLOG_SEVERITY_ERROR);
959 959
 
960
-			}
960
+            }
961 961
 
962
-		}
962
+        }
963 963
 
964
-		return $title;
964
+        return $title;
965 965
 
966
-	}
966
+    }
967 967
 
968
-	/**
969
-	 * This extracts all the metadata for the toplevel logical structure node
970
-	 *
971
-	 * @access	public
972
-	 *
973
-	 * @param	integer		$cPid: The PID for the metadata definitions
974
-	 *
975
-	 * @return	array		The logical structure node's parsed metadata array
976
-	 */
977
-	public function getTitledata($cPid = 0) {
968
+    /**
969
+     * This extracts all the metadata for the toplevel logical structure node
970
+     *
971
+     * @access	public
972
+     *
973
+     * @param	integer		$cPid: The PID for the metadata definitions
974
+     *
975
+     * @return	array		The logical structure node's parsed metadata array
976
+     */
977
+    public function getTitledata($cPid = 0) {
978 978
 
979
-		$titledata = $this->getMetadata($this->_getToplevelId(), $cPid);
979
+        $titledata = $this->getMetadata($this->_getToplevelId(), $cPid);
980 980
 
981
-		// Set record identifier for METS file if not present.
982
-		if (is_array($titledata) && array_key_exists('record_id', $titledata)) {
981
+        // Set record identifier for METS file if not present.
982
+        if (is_array($titledata) && array_key_exists('record_id', $titledata)) {
983 983
 
984
-			if (!in_array($this->recordId, $titledata['record_id'])) {
984
+            if (!in_array($this->recordId, $titledata['record_id'])) {
985 985
 
986
-				array_unshift($titledata['record_id'], $this->recordId);
986
+                array_unshift($titledata['record_id'], $this->recordId);
987 987
 
988
-			}
988
+            }
989 989
 
990
-		};
990
+        };
991 991
 
992
-		return $titledata;
992
+        return $titledata;
993 993
 
994
-	}
994
+    }
995 995
 
996
-	/**
997
-	 * This sets some basic class properties
998
-	 *
999
-	 * @access	protected
1000
-	 *
1001
-	 * @return	void
1002
-	 */
1003
-	protected function init() {
996
+    /**
997
+     * This sets some basic class properties
998
+     *
999
+     * @access	protected
1000
+     *
1001
+     * @return	void
1002
+     */
1003
+    protected function init() {
1004 1004
 
1005
-		// Get METS node from XML file.
1006
-		$this->registerNamespaces($this->xml);
1005
+        // Get METS node from XML file.
1006
+        $this->registerNamespaces($this->xml);
1007 1007
 
1008
-		$mets = $this->xml->xpath('//mets:mets');
1008
+        $mets = $this->xml->xpath('//mets:mets');
1009 1009
 
1010
-		if ($mets) {
1010
+        if ($mets) {
1011 1011
 
1012
-			$this->mets = $mets[0];
1012
+            $this->mets = $mets[0];
1013 1013
 
1014
-			// Register namespaces.
1015
-			$this->registerNamespaces($this->mets);
1014
+            // Register namespaces.
1015
+            $this->registerNamespaces($this->mets);
1016 1016
 
1017
-		} else {
1017
+        } else {
1018 1018
 
1019
-			if (TYPO3_DLOG) {
1019
+            if (TYPO3_DLOG) {
1020 1020
 
1021
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->init()] No METS part found in document with UID "'.$this->uid.'"', self::$extKey, SYSLOG_SEVERITY_ERROR);
1021
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->init()] No METS part found in document with UID "'.$this->uid.'"', self::$extKey, SYSLOG_SEVERITY_ERROR);
1022 1022
 
1023
-			}
1023
+            }
1024 1024
 
1025
-		}
1025
+        }
1026 1026
 
1027
-	}
1027
+    }
1028 1028
 
1029
-	/**
1030
-	 * Load XML file from URL
1031
-	 *
1032
-	 * @access	protected
1033
-	 *
1034
-	 * @param	string		$location: The URL of the file to load
1035
-	 *
1036
-	 * @return	boolean		TRUE on success or FALSE on failure
1037
-	 */
1038
-	protected function load($location) {
1029
+    /**
1030
+     * Load XML file from URL
1031
+     *
1032
+     * @access	protected
1033
+     *
1034
+     * @param	string		$location: The URL of the file to load
1035
+     *
1036
+     * @return	boolean		TRUE on success or FALSE on failure
1037
+     */
1038
+    protected function load($location) {
1039 1039
 
1040
-		// Load XML file.
1041
-		if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location)) {
1040
+        // Load XML file.
1041
+        if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location)) {
1042 1042
 
1043
-			// Load extension configuration
1044
-			$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
1043
+            // Load extension configuration
1044
+            $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
1045 1045
 
1046
-			// Set user-agent to identify self when fetching XML data.
1047
-			if (!empty($extConf['useragent'])) {
1046
+            // Set user-agent to identify self when fetching XML data.
1047
+            if (!empty($extConf['useragent'])) {
1048 1048
 
1049
-				@ini_set('user_agent', $extConf['useragent']);
1049
+                @ini_set('user_agent', $extConf['useragent']);
1050 1050
 
1051
-			}
1051
+            }
1052 1052
 
1053
-			// Turn off libxml's error logging.
1054
-			$libxmlErrors = libxml_use_internal_errors(TRUE);
1053
+            // Turn off libxml's error logging.
1054
+            $libxmlErrors = libxml_use_internal_errors(TRUE);
1055 1055
 
1056
-			// Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
1057
-			$previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
1056
+            // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
1057
+            $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
1058 1058
 
1059
-			// Load XML from file.
1060
-			$xml = simplexml_load_string(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($location));
1059
+            // Load XML from file.
1060
+            $xml = simplexml_load_string(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($location));
1061 1061
 
1062
-			// reset entity loader setting
1063
-			libxml_disable_entity_loader($previousValueOfEntityLoader);
1062
+            // reset entity loader setting
1063
+            libxml_disable_entity_loader($previousValueOfEntityLoader);
1064 1064
 
1065
-			// Reset libxml's error logging.
1066
-			libxml_use_internal_errors($libxmlErrors);
1065
+            // Reset libxml's error logging.
1066
+            libxml_use_internal_errors($libxmlErrors);
1067 1067
 
1068
-			// Set some basic properties.
1069
-			if ($xml !== FALSE) {
1068
+            // Set some basic properties.
1069
+            if ($xml !== FALSE) {
1070 1070
 
1071
-				$this->xml = $xml;
1071
+                $this->xml = $xml;
1072 1072
 
1073
-				return TRUE;
1073
+                return TRUE;
1074 1074
 
1075
-			} else {
1075
+            } else {
1076 1076
 
1077
-				if (TYPO3_DLOG) {
1077
+                if (TYPO3_DLOG) {
1078 1078
 
1079
-					\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Could not load XML file from "'.$location.'"', self::$extKey, SYSLOG_SEVERITY_ERROR);
1079
+                    \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Could not load XML file from "'.$location.'"', self::$extKey, SYSLOG_SEVERITY_ERROR);
1080 1080
 
1081
-				}
1081
+                }
1082 1082
 
1083
-			}
1083
+            }
1084 1084
 
1085
-		} else {
1085
+        } else {
1086 1086
 
1087
-			if (TYPO3_DLOG) {
1087
+            if (TYPO3_DLOG) {
1088 1088
 
1089
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Invalid file location "'.$location.'" for document loading', self::$extKey, SYSLOG_SEVERITY_ERROR);
1089
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Invalid file location "'.$location.'" for document loading', self::$extKey, SYSLOG_SEVERITY_ERROR);
1090 1090
 
1091
-			}
1091
+            }
1092 1092
 
1093
-		}
1093
+        }
1094 1094
 
1095
-		return FALSE;
1095
+        return FALSE;
1096 1096
 
1097
-	}
1097
+    }
1098 1098
 
1099
-	/**
1100
-	 * Register all available data formats
1101
-	 *
1102
-	 * @access	protected
1103
-	 *
1104
-	 * @return	void
1105
-	 */
1106
-	protected function loadFormats() {
1099
+    /**
1100
+     * Register all available data formats
1101
+     *
1102
+     * @access	protected
1103
+     *
1104
+     * @return	void
1105
+     */
1106
+    protected function loadFormats() {
1107 1107
 
1108
-		if (!$this->formatsLoaded) {
1108
+        if (!$this->formatsLoaded) {
1109 1109
 
1110
-			// Get available data formats from database.
1111
-			$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1112
-				'tx_dlf_formats.type AS type,tx_dlf_formats.root AS root,tx_dlf_formats.namespace AS namespace,tx_dlf_formats.class AS class',
1113
-				'tx_dlf_formats',
1114
-				'tx_dlf_formats.pid=0'.tx_dlf_helper::whereClause('tx_dlf_formats'),
1115
-				'',
1116
-				'',
1117
-				''
1118
-			);
1110
+            // Get available data formats from database.
1111
+            $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1112
+                'tx_dlf_formats.type AS type,tx_dlf_formats.root AS root,tx_dlf_formats.namespace AS namespace,tx_dlf_formats.class AS class',
1113
+                'tx_dlf_formats',
1114
+                'tx_dlf_formats.pid=0'.tx_dlf_helper::whereClause('tx_dlf_formats'),
1115
+                '',
1116
+                '',
1117
+                ''
1118
+            );
1119 1119
 
1120
-			while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1120
+            while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1121 1121
 
1122
-				// Update format registry.
1123
-				$this->formats[$resArray['type']] = array (
1124
-					'rootElement' => $resArray['root'],
1125
-					'namespaceURI' => $resArray['namespace'],
1126
-					'class' => $resArray['class']
1127
-				);
1122
+                // Update format registry.
1123
+                $this->formats[$resArray['type']] = array (
1124
+                    'rootElement' => $resArray['root'],
1125
+                    'namespaceURI' => $resArray['namespace'],
1126
+                    'class' => $resArray['class']
1127
+                );
1128 1128
 
1129
-			}
1129
+            }
1130 1130
 
1131
-			$this->formatsLoaded = TRUE;
1131
+            $this->formatsLoaded = TRUE;
1132 1132
 
1133
-		}
1133
+        }
1134 1134
 
1135
-	}
1135
+    }
1136 1136
 
1137
-	/**
1138
-	 * Register all available namespaces for a SimpleXMLElement object
1139
-	 *
1140
-	 * @access	public
1141
-	 *
1142
-	 * @param	SimpleXMLElement|DOMXPath		&$obj: SimpleXMLElement or DOMXPath object
1143
-	 *
1144
-	 * @return	void
1145
-	 */
1146
-	public function registerNamespaces(&$obj) {
1137
+    /**
1138
+     * Register all available namespaces for a SimpleXMLElement object
1139
+     *
1140
+     * @access	public
1141
+     *
1142
+     * @param	SimpleXMLElement|DOMXPath		&$obj: SimpleXMLElement or DOMXPath object
1143
+     *
1144
+     * @return	void
1145
+     */
1146
+    public function registerNamespaces(&$obj) {
1147 1147
 
1148
-		$this->loadFormats();
1148
+        $this->loadFormats();
1149 1149
 
1150
-		// Do we have a SimpleXMLElement or DOMXPath object?
1151
-		if ($obj instanceof SimpleXMLElement) {
1150
+        // Do we have a SimpleXMLElement or DOMXPath object?
1151
+        if ($obj instanceof SimpleXMLElement) {
1152 1152
 
1153
-			$method = 'registerXPathNamespace';
1153
+            $method = 'registerXPathNamespace';
1154 1154
 
1155
-		} elseif ($obj instanceof DOMXPath) {
1155
+        } elseif ($obj instanceof DOMXPath) {
1156 1156
 
1157
-			$method = 'registerNamespace';
1157
+            $method = 'registerNamespace';
1158 1158
 
1159
-		} else {
1159
+        } else {
1160 1160
 
1161
-			if (TYPO3_DLOG) {
1161
+            if (TYPO3_DLOG) {
1162 1162
 
1163
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->registerNamespaces(['.get_class($obj).'])] Given object is neither a SimpleXMLElement nor a DOMXPath instance', self::$extKey, SYSLOG_SEVERITY_ERROR);
1163
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->registerNamespaces(['.get_class($obj).'])] Given object is neither a SimpleXMLElement nor a DOMXPath instance', self::$extKey, SYSLOG_SEVERITY_ERROR);
1164 1164
 
1165
-			}
1165
+            }
1166 1166
 
1167
-			return;
1167
+            return;
1168 1168
 
1169
-		}
1169
+        }
1170 1170
 
1171
-		// Register metadata format's namespaces.
1172
-		foreach ($this->formats as $enc => $conf) {
1171
+        // Register metadata format's namespaces.
1172
+        foreach ($this->formats as $enc => $conf) {
1173 1173
 
1174
-			$obj->$method(strtolower($enc), $conf['namespaceURI']);
1174
+            $obj->$method(strtolower($enc), $conf['namespaceURI']);
1175 1175
 
1176
-		}
1176
+        }
1177 1177
 
1178
-	}
1178
+    }
1179 1179
 
1180
-	/**
1181
-	 * This saves the document to the database and index
1182
-	 *
1183
-	 * @access	public
1184
-	 *
1185
-	 * @param	integer		$pid: The PID of the saved record
1186
-	 * @param	integer		$core: The UID of the Solr core for indexing
1187
-	 *
1188
-	 * @return	boolean		TRUE on success or FALSE on failure
1189
-	 */
1190
-	public function save($pid = 0, $core = 0) {
1180
+    /**
1181
+     * This saves the document to the database and index
1182
+     *
1183
+     * @access	public
1184
+     *
1185
+     * @param	integer		$pid: The PID of the saved record
1186
+     * @param	integer		$core: The UID of the Solr core for indexing
1187
+     *
1188
+     * @return	boolean		TRUE on success or FALSE on failure
1189
+     */
1190
+    public function save($pid = 0, $core = 0) {
1191 1191
 
1192
-		// Save parameters for logging purposes.
1193
-		$_pid = $pid;
1192
+        // Save parameters for logging purposes.
1193
+        $_pid = $pid;
1194 1194
 
1195
-		$_core = $core;
1195
+        $_core = $core;
1196 1196
 
1197
-		if (TYPO3_MODE !== 'BE') {
1197
+        if (TYPO3_MODE !== 'BE') {
1198 1198
 
1199
-			if (TYPO3_DLOG) {
1199
+            if (TYPO3_DLOG) {
1200 1200
 
1201
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Saving a document is only allowed in the backend', self::$extKey, SYSLOG_SEVERITY_ERROR);
1201
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Saving a document is only allowed in the backend', self::$extKey, SYSLOG_SEVERITY_ERROR);
1202 1202
 
1203
-			}
1203
+            }
1204 1204
 
1205
-			return FALSE;
1205
+            return FALSE;
1206 1206
 
1207
-		}
1207
+        }
1208 1208
 
1209
-		// Make sure $pid is a non-negative integer.
1210
-		$pid = max(intval($pid), 0);
1209
+        // Make sure $pid is a non-negative integer.
1210
+        $pid = max(intval($pid), 0);
1211 1211
 
1212
-		// Make sure $core is a non-negative integer.
1213
-		$core = max(intval($core), 0);
1212
+        // Make sure $core is a non-negative integer.
1213
+        $core = max(intval($core), 0);
1214 1214
 
1215
-		// If $pid is not given, try to get it elsewhere.
1216
-		if (!$pid && $this->pid) {
1215
+        // If $pid is not given, try to get it elsewhere.
1216
+        if (!$pid && $this->pid) {
1217 1217
 
1218
-			// Retain current PID.
1219
-			$pid = $this->pid;
1218
+            // Retain current PID.
1219
+            $pid = $this->pid;
1220 1220
 
1221
-		} elseif (!$pid) {
1221
+        } elseif (!$pid) {
1222 1222
 
1223
-			if (TYPO3_DLOG) {
1223
+            if (TYPO3_DLOG) {
1224 1224
 
1225
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid PID "'.$pid.'" for document saving', self::$extKey, SYSLOG_SEVERITY_ERROR);
1225
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid PID "'.$pid.'" for document saving', self::$extKey, SYSLOG_SEVERITY_ERROR);
1226 1226
 
1227
-			}
1227
+            }
1228 1228
 
1229
-			return FALSE;
1229
+            return FALSE;
1230 1230
 
1231
-		}
1231
+        }
1232 1232
 
1233
-		// Set PID for metadata definitions.
1234
-		$this->cPid = $pid;
1233
+        // Set PID for metadata definitions.
1234
+        $this->cPid = $pid;
1235 1235
 
1236
-		// Set UID placeholder if not updating existing record.
1237
-		if ($pid != $this->pid) {
1236
+        // Set UID placeholder if not updating existing record.
1237
+        if ($pid != $this->pid) {
1238 1238
 
1239
-			$this->uid = uniqid('NEW');
1239
+            $this->uid = uniqid('NEW');
1240 1240
 
1241
-		}
1241
+        }
1242 1242
 
1243
-		// Get metadata array.
1244
-		$metadata = $this->getTitledata($pid);
1243
+        // Get metadata array.
1244
+        $metadata = $this->getTitledata($pid);
1245 1245
 
1246
-		// Check for record identifier.
1247
-		if (empty($metadata['record_id'][0])) {
1246
+        // Check for record identifier.
1247
+        if (empty($metadata['record_id'][0])) {
1248 1248
 
1249
-			if (TYPO3_DLOG) {
1249
+            if (TYPO3_DLOG) {
1250 1250
 
1251
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] No record identifier found to avoid duplication', self::$extKey, SYSLOG_SEVERITY_ERROR);
1251
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] No record identifier found to avoid duplication', self::$extKey, SYSLOG_SEVERITY_ERROR);
1252 1252
 
1253
-			}
1253
+            }
1254 1254
 
1255
-			return FALSE;
1255
+            return FALSE;
1256 1256
 
1257
-		}
1257
+        }
1258 1258
 
1259
-		// Load plugin configuration.
1260
-		$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
1259
+        // Load plugin configuration.
1260
+        $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
1261 1261
 
1262
-		// Get UID for user "_cli_dlf".
1263
-		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1264
-			'be_users.uid AS uid',
1265
-			'be_users',
1266
-			'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_users').\TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('be_users').\TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('be_users'),
1267
-			'',
1268
-			'',
1269
-			'1'
1270
-		);
1262
+        // Get UID for user "_cli_dlf".
1263
+        $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1264
+            'be_users.uid AS uid',
1265
+            'be_users',
1266
+            'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_users').\TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('be_users').\TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('be_users'),
1267
+            '',
1268
+            '',
1269
+            '1'
1270
+        );
1271 1271
 
1272
-		if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
1272
+        if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
1273 1273
 
1274
-			list ($be_user) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1274
+            list ($be_user) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1275 1275
 
1276
-		} else {
1276
+        } else {
1277 1277
 
1278
-			if (TYPO3_DLOG) {
1278
+            if (TYPO3_DLOG) {
1279 1279
 
1280
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Backend user "_cli_dlf" not found or disabled', self::$extKey, SYSLOG_SEVERITY_ERROR);
1280
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Backend user "_cli_dlf" not found or disabled', self::$extKey, SYSLOG_SEVERITY_ERROR);
1281 1281
 
1282
-			}
1282
+            }
1283 1283
 
1284
-			return FALSE;
1284
+            return FALSE;
1285 1285
 
1286
-		}
1286
+        }
1287 1287
 
1288
-		// Get UID for structure type.
1289
-		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1290
-			'tx_dlf_structures.uid AS uid',
1291
-			'tx_dlf_structures',
1292
-			'tx_dlf_structures.pid='.intval($pid).' AND tx_dlf_structures.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['type'][0], 'tx_dlf_structures').tx_dlf_helper::whereClause('tx_dlf_structures'),
1293
-			'',
1294
-			'',
1295
-			'1'
1296
-		);
1288
+        // Get UID for structure type.
1289
+        $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1290
+            'tx_dlf_structures.uid AS uid',
1291
+            'tx_dlf_structures',
1292
+            'tx_dlf_structures.pid='.intval($pid).' AND tx_dlf_structures.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['type'][0], 'tx_dlf_structures').tx_dlf_helper::whereClause('tx_dlf_structures'),
1293
+            '',
1294
+            '',
1295
+            '1'
1296
+        );
1297 1297
 
1298
-		if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
1298
+        if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
1299 1299
 
1300
-			list ($structure) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1300
+            list ($structure) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1301 1301
 
1302
-		} else {
1302
+        } else {
1303 1303
 
1304
-			if (TYPO3_DLOG) {
1304
+            if (TYPO3_DLOG) {
1305 1305
 
1306
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Could not identify document/structure type ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['type'][0], 'tx_dlf_structures'),
1307
-									       self::$extKey, SYSLOG_SEVERITY_ERROR);
1306
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Could not identify document/structure type ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['type'][0], 'tx_dlf_structures'),
1307
+                                            self::$extKey, SYSLOG_SEVERITY_ERROR);
1308 1308
 
1309
-			}
1309
+            }
1310 1310
 
1311
-			return FALSE;
1311
+            return FALSE;
1312 1312
 
1313
-		}
1313
+        }
1314 1314
 
1315
-		$metadata['type'][0] = $structure;
1315
+        $metadata['type'][0] = $structure;
1316 1316
 
1317
-		// Get UIDs for collections.
1318
-		$collections = array ();
1317
+        // Get UIDs for collections.
1318
+        $collections = array ();
1319 1319
 
1320
-		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1321
-			'tx_dlf_collections.index_name AS index_name,tx_dlf_collections.uid AS uid',
1322
-			'tx_dlf_collections',
1323
-			'tx_dlf_collections.pid='.intval($pid).' AND tx_dlf_collections.cruser_id='.intval($be_user).' AND tx_dlf_collections.fe_cruser_id=0'.tx_dlf_helper::whereClause('tx_dlf_collections'),
1324
-			'',
1325
-			'',
1326
-			''
1327
-		);
1320
+        $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1321
+            'tx_dlf_collections.index_name AS index_name,tx_dlf_collections.uid AS uid',
1322
+            'tx_dlf_collections',
1323
+            'tx_dlf_collections.pid='.intval($pid).' AND tx_dlf_collections.cruser_id='.intval($be_user).' AND tx_dlf_collections.fe_cruser_id=0'.tx_dlf_helper::whereClause('tx_dlf_collections'),
1324
+            '',
1325
+            '',
1326
+            ''
1327
+        );
1328 1328
 
1329
-		for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) {
1329
+        for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) {
1330 1330
 
1331
-			$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
1331
+            $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
1332 1332
 
1333
-			$collUid[$resArray['index_name']] = $resArray['uid'];
1333
+            $collUid[$resArray['index_name']] = $resArray['uid'];
1334 1334
 
1335
-		}
1335
+        }
1336 1336
 
1337
-		foreach ($metadata['collection'] as $collection) {
1337
+        foreach ($metadata['collection'] as $collection) {
1338 1338
 
1339
-			if (!empty($collUid[$collection])) {
1339
+            if (!empty($collUid[$collection])) {
1340 1340
 
1341
-				// Add existing collection's UID.
1342
-				$collections[] = $collUid[$collection];
1341
+                // Add existing collection's UID.
1342
+                $collections[] = $collUid[$collection];
1343 1343
 
1344
-			} else {
1344
+            } else {
1345 1345
 
1346
-				// Insert new collection.
1347
-				$collNewUid = uniqid('NEW');
1346
+                // Insert new collection.
1347
+                $collNewUid = uniqid('NEW');
1348 1348
 
1349
-				$collData['tx_dlf_collections'][$collNewUid] = array (
1350
-					'pid' => $pid,
1351
-					'label' => $collection,
1352
-					'index_name' => $collection,
1353
-					'oai_name' => (!empty($conf['publishNewCollections']) ? $collection : ''),
1354
-					'description' => '',
1355
-					'documents' => 0,
1356
-					'owner' => 0,
1357
-					'status' => 0,
1358
-				);
1349
+                $collData['tx_dlf_collections'][$collNewUid] = array (
1350
+                    'pid' => $pid,
1351
+                    'label' => $collection,
1352
+                    'index_name' => $collection,
1353
+                    'oai_name' => (!empty($conf['publishNewCollections']) ? $collection : ''),
1354
+                    'description' => '',
1355
+                    'documents' => 0,
1356
+                    'owner' => 0,
1357
+                    'status' => 0,
1358
+                );
1359 1359
 
1360
-				$substUid = tx_dlf_helper::processDB($collData);
1360
+                $substUid = tx_dlf_helper::processDB($collData);
1361 1361
 
1362
-				// Prevent double insertion.
1363
-				unset ($collData);
1362
+                // Prevent double insertion.
1363
+                unset ($collData);
1364 1364
 
1365
-				// Add new collection's UID.
1366
-				$collections[] = $substUid[$collNewUid];
1365
+                // Add new collection's UID.
1366
+                $collections[] = $substUid[$collNewUid];
1367 1367
 
1368
-				if (!defined('TYPO3_cliMode')) {
1368
+                if (!defined('TYPO3_cliMode')) {
1369 1369
 
1370
-					$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
1371
-						'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1372
-						htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newCollection'), $collection, $substUid[$collNewUid])),
1373
-						tx_dlf_helper::getLL('flash.attention', TRUE),
1374
-						\TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
1375
-						TRUE
1376
-					);
1370
+                    $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
1371
+                        'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1372
+                        htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newCollection'), $collection, $substUid[$collNewUid])),
1373
+                        tx_dlf_helper::getLL('flash.attention', TRUE),
1374
+                        \TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
1375
+                        TRUE
1376
+                    );
1377 1377
 
1378
-					tx_dlf_helper::addMessage($message);
1378
+                    tx_dlf_helper::addMessage($message);
1379 1379
 
1380
-				}
1380
+                }
1381 1381
 
1382
-			}
1382
+            }
1383 1383
 
1384
-		}
1384
+        }
1385 1385
 
1386
-		// Preserve user-defined collections.
1387
-		$result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
1388
-			'tx_dlf_collections.uid AS uid',
1389
-			'tx_dlf_documents',
1390
-			'tx_dlf_relations',
1391
-			'tx_dlf_collections',
1392
-			'AND tx_dlf_documents.pid='.intval($pid).' AND tx_dlf_collections.pid='.intval($pid).' AND tx_dlf_documents.uid='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->uid, 'tx_dlf_documents').' AND NOT (tx_dlf_collections.cruser_id='.intval($be_user).' AND tx_dlf_collections.fe_cruser_id=0) AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations'),
1393
-			'',
1394
-			'',
1395
-			''
1396
-		);
1386
+        // Preserve user-defined collections.
1387
+        $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
1388
+            'tx_dlf_collections.uid AS uid',
1389
+            'tx_dlf_documents',
1390
+            'tx_dlf_relations',
1391
+            'tx_dlf_collections',
1392
+            'AND tx_dlf_documents.pid='.intval($pid).' AND tx_dlf_collections.pid='.intval($pid).' AND tx_dlf_documents.uid='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->uid, 'tx_dlf_documents').' AND NOT (tx_dlf_collections.cruser_id='.intval($be_user).' AND tx_dlf_collections.fe_cruser_id=0) AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations'),
1393
+            '',
1394
+            '',
1395
+            ''
1396
+        );
1397 1397
 
1398
-		for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) {
1398
+        for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) {
1399 1399
 
1400
-			list ($collections[]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1400
+            list ($collections[]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1401 1401
 
1402
-		}
1402
+        }
1403 1403
 
1404
-		$metadata['collection'] = $collections;
1404
+        $metadata['collection'] = $collections;
1405 1405
 
1406
-		// Get UID for owner.
1407
-		$owner = !empty($metadata['owner'][0]) ? $metadata['owner'][0] : 'default';
1406
+        // Get UID for owner.
1407
+        $owner = !empty($metadata['owner'][0]) ? $metadata['owner'][0] : 'default';
1408 1408
 
1409
-		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1410
-			'tx_dlf_libraries.uid AS uid',
1411
-			'tx_dlf_libraries',
1412
-			'tx_dlf_libraries.pid='.intval($pid).' AND tx_dlf_libraries.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($owner, 'tx_dlf_libraries').tx_dlf_helper::whereClause('tx_dlf_libraries'),
1413
-			'',
1414
-			'',
1415
-			'1'
1416
-		);
1409
+        $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1410
+            'tx_dlf_libraries.uid AS uid',
1411
+            'tx_dlf_libraries',
1412
+            'tx_dlf_libraries.pid='.intval($pid).' AND tx_dlf_libraries.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($owner, 'tx_dlf_libraries').tx_dlf_helper::whereClause('tx_dlf_libraries'),
1413
+            '',
1414
+            '',
1415
+            '1'
1416
+        );
1417 1417
 
1418
-		if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
1418
+        if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
1419 1419
 
1420
-			list ($ownerUid) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1420
+            list ($ownerUid) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
1421 1421
 
1422
-		} else {
1422
+        } else {
1423 1423
 
1424
-			// Insert new library.
1425
-			$libNewUid = uniqid('NEW');
1424
+            // Insert new library.
1425
+            $libNewUid = uniqid('NEW');
1426 1426
 
1427
-			$libData['tx_dlf_libraries'][$libNewUid] = array (
1428
-				'pid' => $pid,
1429
-				'label' => $owner,
1430
-				'index_name' => $owner,
1431
-				'website' => '',
1432
-				'contact' => '',
1433
-				'image' => '',
1434
-				'oai_label' => '',
1435
-				'oai_base' => '',
1436
-				'opac_label' => '',
1437
-				'opac_base' => '',
1438
-				'union_label' => '',
1439
-				'union_base' => '',
1440
-			);
1427
+            $libData['tx_dlf_libraries'][$libNewUid] = array (
1428
+                'pid' => $pid,
1429
+                'label' => $owner,
1430
+                'index_name' => $owner,
1431
+                'website' => '',
1432
+                'contact' => '',
1433
+                'image' => '',
1434
+                'oai_label' => '',
1435
+                'oai_base' => '',
1436
+                'opac_label' => '',
1437
+                'opac_base' => '',
1438
+                'union_label' => '',
1439
+                'union_base' => '',
1440
+            );
1441 1441
 
1442
-			$substUid = tx_dlf_helper::processDB($libData);
1442
+            $substUid = tx_dlf_helper::processDB($libData);
1443 1443
 
1444
-			// Add new library's UID.
1445
-			$ownerUid = $substUid[$libNewUid];
1444
+            // Add new library's UID.
1445
+            $ownerUid = $substUid[$libNewUid];
1446 1446
 
1447
-			if (!defined('TYPO3_cliMode')) {
1447
+            if (!defined('TYPO3_cliMode')) {
1448 1448
 
1449
-				$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
1450
-					'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1451
-					htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newLibrary'), $owner, $ownerUid)),
1452
-					tx_dlf_helper::getLL('flash.attention', TRUE),
1453
-					\TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
1454
-					TRUE
1455
-				);
1449
+                $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
1450
+                    'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1451
+                    htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newLibrary'), $owner, $ownerUid)),
1452
+                    tx_dlf_helper::getLL('flash.attention', TRUE),
1453
+                    \TYPO3\CMS\Core\Messaging\FlashMessage::INFO,
1454
+                    TRUE
1455
+                );
1456 1456
 
1457
-				tx_dlf_helper::addMessage($message);
1457
+                tx_dlf_helper::addMessage($message);
1458 1458
 
1459
-			}
1459
+            }
1460 1460
 
1461
-		}
1461
+        }
1462 1462
 
1463
-		$metadata['owner'][0] = $ownerUid;
1463
+        $metadata['owner'][0] = $ownerUid;
1464 1464
 
1465
-		// Get UID of parent document.
1466
-		$partof = 0;
1465
+        // Get UID of parent document.
1466
+        $partof = 0;
1467 1467
 
1468
-		// Get the closest ancestor of the current document which has a MPTR child.
1469
-		$parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$this->_getToplevelId().'"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr');
1468
+        // Get the closest ancestor of the current document which has a MPTR child.
1469
+        $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$this->_getToplevelId().'"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr');
1470 1470
 
1471
-		if (!empty($parentMptr[0])) {
1471
+        if (!empty($parentMptr[0])) {
1472 1472
 
1473
-			$parentLocation = (string) $parentMptr[0]->attributes('http://www.w3.org/1999/xlink')->href;
1473
+            $parentLocation = (string) $parentMptr[0]->attributes('http://www.w3.org/1999/xlink')->href;
1474 1474
 
1475
-			if ($parentLocation != $this->location) {
1475
+            if ($parentLocation != $this->location) {
1476 1476
 
1477
-				$parentDoc =& tx_dlf_document::getInstance($parentLocation, $pid);
1477
+                $parentDoc =& tx_dlf_document::getInstance($parentLocation, $pid);
1478 1478
 
1479
-				if ($parentDoc->ready) {
1479
+                if ($parentDoc->ready) {
1480 1480
 
1481
-					if ($parentDoc->pid != $pid) {
1481
+                    if ($parentDoc->pid != $pid) {
1482 1482
 
1483
-						$parentDoc->save($pid, $core);
1483
+                        $parentDoc->save($pid, $core);
1484 1484
 
1485
-					}
1485
+                    }
1486 1486
 
1487
-					$partof = $parentDoc->uid;
1487
+                    $partof = $parentDoc->uid;
1488 1488
 
1489
-				}
1489
+                }
1490 1490
 
1491
-			}
1491
+            }
1492 1492
 
1493
-		}
1493
+        }
1494 1494
 
1495
-		// Use the date of publication or title as alternative sorting metric for parts of multi-part works.
1496
-		if (!empty($partof)) {
1495
+        // Use the date of publication or title as alternative sorting metric for parts of multi-part works.
1496
+        if (!empty($partof)) {
1497 1497
 
1498
-			if (empty($metadata['volume'][0]) && !empty($metadata['year'][0])) {
1498
+            if (empty($metadata['volume'][0]) && !empty($metadata['year'][0])) {
1499 1499
 
1500
-				$metadata['volume'] = $metadata['year'];
1500
+                $metadata['volume'] = $metadata['year'];
1501 1501
 
1502
-			}
1502
+            }
1503 1503
 
1504
-			if (empty($metadata['volume_sorting'][0])) {
1504
+            if (empty($metadata['volume_sorting'][0])) {
1505 1505
 
1506
-				if (!empty($metadata['year_sorting'][0])) {
1506
+                if (!empty($metadata['year_sorting'][0])) {
1507 1507
 
1508
-					$metadata['volume_sorting'][0] = $metadata['year_sorting'][0];
1508
+                    $metadata['volume_sorting'][0] = $metadata['year_sorting'][0];
1509 1509
 
1510
-				} elseif (!empty($metadata['year'][0])) {
1510
+                } elseif (!empty($metadata['year'][0])) {
1511 1511
 
1512
-					$metadata['volume_sorting'][0] = $metadata['year'][0];
1512
+                    $metadata['volume_sorting'][0] = $metadata['year'][0];
1513 1513
 
1514
-				}
1514
+                }
1515 1515
 
1516
-			}
1516
+            }
1517 1517
 
1518
-			// If volume_sorting is still empty, try to use title_sorting finally (workaround for newspapers)
1519
-			if (empty($metadata['volume_sorting'][0])) {
1518
+            // If volume_sorting is still empty, try to use title_sorting finally (workaround for newspapers)
1519
+            if (empty($metadata['volume_sorting'][0])) {
1520 1520
 
1521
-				if (!empty($metadata['title_sorting'][0])) {
1521
+                if (!empty($metadata['title_sorting'][0])) {
1522 1522
 
1523
-					$metadata['volume_sorting'][0] = $metadata['title_sorting'][0];
1523
+                    $metadata['volume_sorting'][0] = $metadata['title_sorting'][0];
1524 1524
 
1525
-				}
1526
-			}
1525
+                }
1526
+            }
1527 1527
 
1528
-		}
1528
+        }
1529 1529
 
1530
-		// Get metadata for lists and sorting.
1531
-		$listed = array ();
1530
+        // Get metadata for lists and sorting.
1531
+        $listed = array ();
1532 1532
 
1533
-		$sortable = array ();
1533
+        $sortable = array ();
1534 1534
 
1535
-		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1536
-			'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable',
1537
-			'tx_dlf_metadata',
1538
-			'(tx_dlf_metadata.is_listed=1 OR tx_dlf_metadata.is_sortable=1) AND tx_dlf_metadata.pid='.intval($pid).tx_dlf_helper::whereClause('tx_dlf_metadata'),
1539
-			'',
1540
-			'',
1541
-			''
1542
-		);
1535
+        $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1536
+            'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable',
1537
+            'tx_dlf_metadata',
1538
+            '(tx_dlf_metadata.is_listed=1 OR tx_dlf_metadata.is_sortable=1) AND tx_dlf_metadata.pid='.intval($pid).tx_dlf_helper::whereClause('tx_dlf_metadata'),
1539
+            '',
1540
+            '',
1541
+            ''
1542
+        );
1543 1543
 
1544
-		while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1544
+        while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1545 1545
 
1546
-			if (!empty($metadata[$resArray['index_name']])) {
1546
+            if (!empty($metadata[$resArray['index_name']])) {
1547 1547
 
1548
-				if ($resArray['is_listed']) {
1548
+                if ($resArray['is_listed']) {
1549 1549
 
1550
-					$listed[$resArray['index_name']] = $metadata[$resArray['index_name']];
1550
+                    $listed[$resArray['index_name']] = $metadata[$resArray['index_name']];
1551 1551
 
1552
-				}
1552
+                }
1553 1553
 
1554
-				if ($resArray['is_sortable']) {
1554
+                if ($resArray['is_sortable']) {
1555 1555
 
1556
-					$sortable[$resArray['index_name']] = $metadata[$resArray['index_name']][0];
1556
+                    $sortable[$resArray['index_name']] = $metadata[$resArray['index_name']][0];
1557 1557
 
1558
-				}
1558
+                }
1559 1559
 
1560
-			}
1560
+            }
1561 1561
 
1562
-		}
1562
+        }
1563 1563
 
1564
-		// Fill data array.
1565
-		$data['tx_dlf_documents'][$this->uid] = array (
1566
-			'pid' => $pid,
1567
-			$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['starttime'] => 0,
1568
-			$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['endtime'] => 0,
1569
-			'prod_id' => $metadata['prod_id'][0],
1570
-			'location' => $this->location,
1571
-			'record_id' => $metadata['record_id'][0],
1572
-			'opac_id' => $metadata['opac_id'][0],
1573
-			'union_id' => $metadata['union_id'][0],
1574
-			'urn' => $metadata['urn'][0],
1575
-			'purl' => $metadata['purl'][0],
1576
-			'title' => $metadata['title'][0],
1577
-			'title_sorting' => $metadata['title_sorting'][0],
1578
-			'author' => implode('; ', $metadata['author']),
1579
-			'year' => implode('; ', $metadata['year']),
1580
-			'place' => implode('; ', $metadata['place']),
1581
-			'thumbnail' => $this->_getThumbnail(TRUE),
1582
-			'metadata' => serialize($listed),
1583
-			'metadata_sorting' => serialize($sortable),
1584
-			'structure' => $metadata['type'][0],
1585
-			'partof' => $partof,
1586
-			'volume' => $metadata['volume'][0],
1587
-			'volume_sorting' => $metadata['volume_sorting'][0],
1588
-			'collections' => $metadata['collection'],
1589
-			'owner' => $metadata['owner'][0],
1590
-			'solrcore' => $core,
1591
-			'status' => 0,
1592
-		);
1564
+        // Fill data array.
1565
+        $data['tx_dlf_documents'][$this->uid] = array (
1566
+            'pid' => $pid,
1567
+            $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['starttime'] => 0,
1568
+            $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['endtime'] => 0,
1569
+            'prod_id' => $metadata['prod_id'][0],
1570
+            'location' => $this->location,
1571
+            'record_id' => $metadata['record_id'][0],
1572
+            'opac_id' => $metadata['opac_id'][0],
1573
+            'union_id' => $metadata['union_id'][0],
1574
+            'urn' => $metadata['urn'][0],
1575
+            'purl' => $metadata['purl'][0],
1576
+            'title' => $metadata['title'][0],
1577
+            'title_sorting' => $metadata['title_sorting'][0],
1578
+            'author' => implode('; ', $metadata['author']),
1579
+            'year' => implode('; ', $metadata['year']),
1580
+            'place' => implode('; ', $metadata['place']),
1581
+            'thumbnail' => $this->_getThumbnail(TRUE),
1582
+            'metadata' => serialize($listed),
1583
+            'metadata_sorting' => serialize($sortable),
1584
+            'structure' => $metadata['type'][0],
1585
+            'partof' => $partof,
1586
+            'volume' => $metadata['volume'][0],
1587
+            'volume_sorting' => $metadata['volume_sorting'][0],
1588
+            'collections' => $metadata['collection'],
1589
+            'owner' => $metadata['owner'][0],
1590
+            'solrcore' => $core,
1591
+            'status' => 0,
1592
+        );
1593 1593
 
1594
-		// Unhide hidden documents.
1595
-		if (!empty($conf['unhideOnIndex'])) {
1594
+        // Unhide hidden documents.
1595
+        if (!empty($conf['unhideOnIndex'])) {
1596 1596
 
1597
-			$data['tx_dlf_documents'][$this->uid][$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['disabled']] = 0;
1597
+            $data['tx_dlf_documents'][$this->uid][$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['disabled']] = 0;
1598 1598
 
1599
-		}
1599
+        }
1600 1600
 
1601
-		// Process data.
1602
-		$newIds = tx_dlf_helper::processDB($data);
1601
+        // Process data.
1602
+        $newIds = tx_dlf_helper::processDB($data);
1603 1603
 
1604
-		// Replace placeholder with actual UID.
1605
-		if (strpos($this->uid, 'NEW') === 0) {
1604
+        // Replace placeholder with actual UID.
1605
+        if (strpos($this->uid, 'NEW') === 0) {
1606 1606
 
1607
-			$this->uid = $newIds[$this->uid];
1607
+            $this->uid = $newIds[$this->uid];
1608 1608
 
1609
-			$this->pid = $pid;
1609
+            $this->pid = $pid;
1610 1610
 
1611
-			$this->parentId = $partof;
1611
+            $this->parentId = $partof;
1612 1612
 
1613
-		}
1613
+        }
1614 1614
 
1615
-		if (!defined('TYPO3_cliMode')) {
1615
+        if (!defined('TYPO3_cliMode')) {
1616 1616
 
1617
-			$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
1618
-				'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1619
-				htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.documentSaved'), $metadata['title'][0], $this->uid)),
1620
-				tx_dlf_helper::getLL('flash.done', TRUE),
1621
-				\TYPO3\CMS\Core\Messaging\FlashMessage::OK,
1622
-				TRUE
1623
-			);
1617
+            $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
1618
+                'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
1619
+                htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.documentSaved'), $metadata['title'][0], $this->uid)),
1620
+                tx_dlf_helper::getLL('flash.done', TRUE),
1621
+                \TYPO3\CMS\Core\Messaging\FlashMessage::OK,
1622
+                TRUE
1623
+            );
1624 1624
 
1625
-			tx_dlf_helper::addMessage($message);
1625
+            tx_dlf_helper::addMessage($message);
1626 1626
 
1627
-		}
1627
+        }
1628 1628
 
1629
-		// Add document to index.
1630
-		if ($core) {
1629
+        // Add document to index.
1630
+        if ($core) {
1631 1631
 
1632
-			tx_dlf_indexing::add($this, $core);
1632
+            tx_dlf_indexing::add($this, $core);
1633 1633
 
1634
-		} else {
1634
+        } else {
1635 1635
 
1636
-			if (TYPO3_DLOG) {
1636
+            if (TYPO3_DLOG) {
1637 1637
 
1638
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid UID "'.$core.'" for Solr core', self::$extKey, SYSLOG_SEVERITY_NOTICE);
1638
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid UID "'.$core.'" for Solr core', self::$extKey, SYSLOG_SEVERITY_NOTICE);
1639 1639
 
1640
-			}
1640
+            }
1641 1641
 
1642
-		}
1642
+        }
1643 1643
 
1644
-		return TRUE;
1644
+        return TRUE;
1645 1645
 
1646
-	}
1646
+    }
1647 1647
 
1648
-	/**
1649
-	 * This returns $this->cPid via __get()
1650
-	 *
1651
-	 * @access	protected
1652
-	 *
1653
-	 * @return	integer		The PID of the metadata definitions
1654
-	 */
1655
-	protected function _getCPid() {
1648
+    /**
1649
+     * This returns $this->cPid via __get()
1650
+     *
1651
+     * @access	protected
1652
+     *
1653
+     * @return	integer		The PID of the metadata definitions
1654
+     */
1655
+    protected function _getCPid() {
1656 1656
 
1657
-		return $this->cPid;
1657
+        return $this->cPid;
1658 1658
 
1659
-	}
1659
+    }
1660 1660
 
1661
-	/**
1662
-	 * This builds an array of the document's dmdSecs
1663
-	 *
1664
-	 * @access	protected
1665
-	 *
1666
-	 * @return	array		Array of dmdSecs with their IDs as array key
1667
-	 */
1668
-	protected function _getDmdSec() {
1661
+    /**
1662
+     * This builds an array of the document's dmdSecs
1663
+     *
1664
+     * @access	protected
1665
+     *
1666
+     * @return	array		Array of dmdSecs with their IDs as array key
1667
+     */
1668
+    protected function _getDmdSec() {
1669 1669
 
1670
-		if (!$this->dmdSecLoaded) {
1670
+        if (!$this->dmdSecLoaded) {
1671 1671
 
1672
-			// Get available data formats.
1673
-			$this->loadFormats();
1672
+            // Get available data formats.
1673
+            $this->loadFormats();
1674 1674
 
1675
-			// Get dmdSec nodes from METS.
1676
-			$dmdIds = $this->mets->xpath('./mets:dmdSec/@ID');
1675
+            // Get dmdSec nodes from METS.
1676
+            $dmdIds = $this->mets->xpath('./mets:dmdSec/@ID');
1677 1677
 
1678
-			foreach ($dmdIds as $dmdId) {
1678
+            foreach ($dmdIds as $dmdId) {
1679 1679
 
1680
-				if ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[not(@MDTYPE="OTHER")]/@MDTYPE')) {
1680
+                if ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[not(@MDTYPE="OTHER")]/@MDTYPE')) {
1681 1681
 
1682
-					if (!empty($this->formats[(string) $type[0]])) {
1682
+                    if (!empty($this->formats[(string) $type[0]])) {
1683 1683
 
1684
-						$type = (string) $type[0];
1684
+                        $type = (string) $type[0];
1685 1685
 
1686
-						$xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']);
1686
+                        $xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']);
1687 1687
 
1688
-					}
1688
+                    }
1689 1689
 
1690
-				} elseif ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"]/@OTHERMDTYPE')) {
1690
+                } elseif ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"]/@OTHERMDTYPE')) {
1691 1691
 
1692
-					if (!empty($this->formats[(string) $type[0]])) {
1692
+                    if (!empty($this->formats[(string) $type[0]])) {
1693 1693
 
1694
-						$type = (string) $type[0];
1694
+                        $type = (string) $type[0];
1695 1695
 
1696
-						$xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']);
1696
+                        $xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']);
1697 1697
 
1698
-					}
1698
+                    }
1699 1699
 
1700
-				}
1700
+                }
1701 1701
 
1702
-				if ($xml) {
1702
+                if ($xml) {
1703 1703
 
1704
-					$this->dmdSec[(string) $dmdId]['type'] = $type;
1704
+                    $this->dmdSec[(string) $dmdId]['type'] = $type;
1705 1705
 
1706
-					$this->dmdSec[(string) $dmdId]['xml'] = $xml[0];
1706
+                    $this->dmdSec[(string) $dmdId]['xml'] = $xml[0];
1707 1707
 
1708
-					$this->registerNamespaces($this->dmdSec[(string) $dmdId]['xml']);
1708
+                    $this->registerNamespaces($this->dmdSec[(string) $dmdId]['xml']);
1709 1709
 
1710
-				}
1710
+                }
1711 1711
 
1712
-			}
1712
+            }
1713 1713
 
1714
-			$this->dmdSecLoaded = TRUE;
1714
+            $this->dmdSecLoaded = TRUE;
1715 1715
 
1716
-		}
1716
+        }
1717 1717
 
1718
-		return $this->dmdSec;
1718
+        return $this->dmdSec;
1719 1719
 
1720
-	}
1720
+    }
1721 1721
 
1722
-	/**
1723
-	 * This builds the file ID -> USE concordance
1724
-	 *
1725
-	 * @access	protected
1726
-	 *
1727
-	 * @return	array		Array of file use groups with file IDs
1728
-	 */
1729
-	protected function _getFileGrps() {
1722
+    /**
1723
+     * This builds the file ID -> USE concordance
1724
+     *
1725
+     * @access	protected
1726
+     *
1727
+     * @return	array		Array of file use groups with file IDs
1728
+     */
1729
+    protected function _getFileGrps() {
1730 1730
 
1731
-		if (!$this->fileGrpsLoaded) {
1731
+        if (!$this->fileGrpsLoaded) {
1732 1732
 
1733
-			// Get configured USE attributes.
1734
-			$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
1733
+            // Get configured USE attributes.
1734
+            $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
1735 1735
 
1736
-			$useGrps = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $extConf['fileGrps']);
1736
+            $useGrps = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $extConf['fileGrps']);
1737 1737
 
1738
-			if (!empty($extConf['fileGrpThumbs'])) {
1738
+            if (!empty($extConf['fileGrpThumbs'])) {
1739 1739
 
1740
-				$useGrps[] = $extConf['fileGrpThumbs'];
1740
+                $useGrps[] = $extConf['fileGrpThumbs'];
1741 1741
 
1742
-			}
1742
+            }
1743 1743
 
1744
-			if (!empty($extConf['fileGrpDownload'])) {
1744
+            if (!empty($extConf['fileGrpDownload'])) {
1745 1745
 
1746
-				$useGrps[] = $extConf['fileGrpDownload'];
1746
+                $useGrps[] = $extConf['fileGrpDownload'];
1747 1747
 
1748
-			}
1748
+            }
1749 1749
 
1750
-			if (!empty($extConf['fileGrpFulltext'])) {
1750
+            if (!empty($extConf['fileGrpFulltext'])) {
1751 1751
 
1752
-				$useGrps[] = $extConf['fileGrpFulltext'];
1752
+                $useGrps[] = $extConf['fileGrpFulltext'];
1753 1753
 
1754
-			}
1754
+            }
1755 1755
 
1756
-			if (!empty($extConf['fileGrpAudio'])) {
1756
+            if (!empty($extConf['fileGrpAudio'])) {
1757 1757
 
1758
-				$useGrps[] = $extConf['fileGrpAudio'];
1758
+                $useGrps[] = $extConf['fileGrpAudio'];
1759 1759
 
1760
-			}
1760
+            }
1761 1761
 
1762
-			// Get all file groups.
1763
-			$fileGrps = $this->mets->xpath('./mets:fileSec/mets:fileGrp');
1762
+            // Get all file groups.
1763
+            $fileGrps = $this->mets->xpath('./mets:fileSec/mets:fileGrp');
1764 1764
 
1765
-			// Build concordance for configured USE attributes.
1766
-			foreach ($fileGrps as $fileGrp) {
1765
+            // Build concordance for configured USE attributes.
1766
+            foreach ($fileGrps as $fileGrp) {
1767 1767
 
1768
-				if (in_array((string) $fileGrp['USE'], $useGrps)) {
1768
+                if (in_array((string) $fileGrp['USE'], $useGrps)) {
1769 1769
 
1770
-					foreach ($fileGrp->children('http://www.loc.gov/METS/')->file as $file) {
1770
+                    foreach ($fileGrp->children('http://www.loc.gov/METS/')->file as $file) {
1771 1771
 
1772
-						$this->fileGrps[(string) $file->attributes()->ID] = (string) $fileGrp['USE'];
1772
+                        $this->fileGrps[(string) $file->attributes()->ID] = (string) $fileGrp['USE'];
1773 1773
 
1774
-					}
1774
+                    }
1775 1775
 
1776
-				}
1776
+                }
1777 1777
 
1778
-			}
1778
+            }
1779 1779
 
1780
-			// Are there any fulltext files available?
1781
-			if (!empty($extConf['fileGrpFulltext']) && in_array($extConf['fileGrpFulltext'], $this->fileGrps)) {
1780
+            // Are there any fulltext files available?
1781
+            if (!empty($extConf['fileGrpFulltext']) && in_array($extConf['fileGrpFulltext'], $this->fileGrps)) {
1782 1782
 
1783
-				$this->hasFulltext = TRUE;
1783
+                $this->hasFulltext = TRUE;
1784 1784
 
1785
-			}
1785
+            }
1786 1786
 
1787
-			$this->fileGrpsLoaded = TRUE;
1787
+            $this->fileGrpsLoaded = TRUE;
1788 1788
 
1789
-		}
1789
+        }
1790 1790
 
1791
-		return $this->fileGrps;
1791
+        return $this->fileGrps;
1792 1792
 
1793
-	}
1793
+    }
1794 1794
 
1795
-	/**
1796
-	 * This returns $this->hasFulltext via __get()
1797
-	 *
1798
-	 * @access	protected
1799
-	 *
1800
-	 * @return	boolean		Are there any fulltext files available?
1801
-	 */
1802
-	protected function _getHasFulltext() {
1795
+    /**
1796
+     * This returns $this->hasFulltext via __get()
1797
+     *
1798
+     * @access	protected
1799
+     *
1800
+     * @return	boolean		Are there any fulltext files available?
1801
+     */
1802
+    protected function _getHasFulltext() {
1803 1803
 
1804
-		// Are the fileGrps already loaded?
1805
-		if (!$this->fileGrpsLoaded) {
1804
+        // Are the fileGrps already loaded?
1805
+        if (!$this->fileGrpsLoaded) {
1806 1806
 
1807
-			$this->_getFileGrps();
1807
+            $this->_getFileGrps();
1808 1808
 
1809
-		}
1809
+        }
1810 1810
 
1811
-		return $this->hasFulltext;
1811
+        return $this->hasFulltext;
1812 1812
 
1813
-	}
1813
+    }
1814 1814
 
1815
-	/**
1816
-	 * This returns $this->location via __get()
1817
-	 *
1818
-	 * @access	protected
1819
-	 *
1820
-	 * @return	string		The location of the document
1821
-	 */
1822
-	protected function _getLocation() {
1815
+    /**
1816
+     * This returns $this->location via __get()
1817
+     *
1818
+     * @access	protected
1819
+     *
1820
+     * @return	string		The location of the document
1821
+     */
1822
+    protected function _getLocation() {
1823 1823
 
1824
-		return $this->location;
1824
+        return $this->location;
1825 1825
 
1826
-	}
1826
+    }
1827 1827
 
1828
-	/**
1829
-	 * This builds an array of the document's metadata
1830
-	 *
1831
-	 * @access	protected
1832
-	 *
1833
-	 * @return	array		Array of metadata with their corresponding logical structure node ID as key
1834
-	 */
1835
-	protected function _getMetadataArray() {
1828
+    /**
1829
+     * This builds an array of the document's metadata
1830
+     *
1831
+     * @access	protected
1832
+     *
1833
+     * @return	array		Array of metadata with their corresponding logical structure node ID as key
1834
+     */
1835
+    protected function _getMetadataArray() {
1836 1836
 
1837
-		// Set metadata definitions' PID.
1838
-		$cPid = ($this->cPid ? $this->cPid : $this->pid);
1837
+        // Set metadata definitions' PID.
1838
+        $cPid = ($this->cPid ? $this->cPid : $this->pid);
1839 1839
 
1840
-		if (!$cPid) {
1840
+        if (!$cPid) {
1841 1841
 
1842
-			if (TYPO3_DLOG) {
1842
+            if (TYPO3_DLOG) {
1843 1843
 
1844
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadataArray()] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR);
1844
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadataArray()] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR);
1845 1845
 
1846
-			}
1846
+            }
1847 1847
 
1848
-			return array ();
1848
+            return array ();
1849 1849
 
1850
-		}
1850
+        }
1851 1851
 
1852
-		if (!$this->metadataArrayLoaded || $this->metadataArray[0] != $cPid) {
1852
+        if (!$this->metadataArrayLoaded || $this->metadataArray[0] != $cPid) {
1853 1853
 
1854
-			// Get all logical structure nodes with metadata.
1855
-			if (($ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'))) {
1854
+            // Get all logical structure nodes with metadata.
1855
+            if (($ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'))) {
1856 1856
 
1857
-				foreach ($ids as $id) {
1857
+                foreach ($ids as $id) {
1858 1858
 
1859
-					$this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid);
1859
+                    $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid);
1860 1860
 
1861
-				}
1861
+                }
1862 1862
 
1863
-			}
1863
+            }
1864 1864
 
1865
-			// Set current PID for metadata definitions.
1866
-			$this->metadataArray[0] = $cPid;
1865
+            // Set current PID for metadata definitions.
1866
+            $this->metadataArray[0] = $cPid;
1867 1867
 
1868
-			$this->metadataArrayLoaded = TRUE;
1868
+            $this->metadataArrayLoaded = TRUE;
1869 1869
 
1870
-		}
1870
+        }
1871 1871
 
1872
-		return $this->metadataArray;
1872
+        return $this->metadataArray;
1873 1873
 
1874
-	}
1874
+    }
1875 1875
 
1876
-	/**
1877
-	 * This returns $this->mets via __get()
1878
-	 *
1879
-	 * @access	protected
1880
-	 *
1881
-	 * @return	SimpleXMLElement		The XML's METS part as SimpleXMLElement object
1882
-	 */
1883
-	protected function _getMets() {
1876
+    /**
1877
+     * This returns $this->mets via __get()
1878
+     *
1879
+     * @access	protected
1880
+     *
1881
+     * @return	SimpleXMLElement		The XML's METS part as SimpleXMLElement object
1882
+     */
1883
+    protected function _getMets() {
1884 1884
 
1885
-		return $this->mets;
1885
+        return $this->mets;
1886 1886
 
1887
-	}
1887
+    }
1888 1888
 
1889
-	/**
1890
-	 * This returns $this->numPages via __get()
1891
-	 *
1892
-	 * @access	protected
1893
-	 *
1894
-	 * @return	integer		The total number of pages and/or tracks
1895
-	 */
1896
-	protected function _getNumPages() {
1889
+    /**
1890
+     * This returns $this->numPages via __get()
1891
+     *
1892
+     * @access	protected
1893
+     *
1894
+     * @return	integer		The total number of pages and/or tracks
1895
+     */
1896
+    protected function _getNumPages() {
1897 1897
 
1898
-		$this->_getPhysicalStructure();
1898
+        $this->_getPhysicalStructure();
1899 1899
 
1900
-		return $this->numPages;
1900
+        return $this->numPages;
1901 1901
 
1902
-	}
1902
+    }
1903 1903
 
1904
-	/**
1905
-	 * This returns $this->parentId via __get()
1906
-	 *
1907
-	 * @access	protected
1908
-	 *
1909
-	 * @return	integer		The UID of the parent document or zero if not applicable
1910
-	 */
1911
-	protected function _getParentId() {
1904
+    /**
1905
+     * This returns $this->parentId via __get()
1906
+     *
1907
+     * @access	protected
1908
+     *
1909
+     * @return	integer		The UID of the parent document or zero if not applicable
1910
+     */
1911
+    protected function _getParentId() {
1912 1912
 
1913
-		return $this->parentId;
1913
+        return $this->parentId;
1914 1914
 
1915
-	}
1915
+    }
1916 1916
 
1917
-	/**
1918
-	 * This builds an array of the document's physical structure
1919
-	 *
1920
-	 * @access	protected
1921
-	 *
1922
-	 * @return	array		Array of physical elements' id, type, label and file representations ordered by @ORDER attribute
1923
-	 */
1924
-	protected function _getPhysicalStructure() {
1917
+    /**
1918
+     * This builds an array of the document's physical structure
1919
+     *
1920
+     * @access	protected
1921
+     *
1922
+     * @return	array		Array of physical elements' id, type, label and file representations ordered by @ORDER attribute
1923
+     */
1924
+    protected function _getPhysicalStructure() {
1925 1925
 
1926
-		// Is there no physical structure array yet?
1927
-		if (!$this->physicalStructureLoaded) {
1926
+        // Is there no physical structure array yet?
1927
+        if (!$this->physicalStructureLoaded) {
1928 1928
 
1929
-			// Does the document have a structMap node of type "PHYSICAL"?
1930
-			$elementNodes = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div');
1929
+            // Does the document have a structMap node of type "PHYSICAL"?
1930
+            $elementNodes = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div');
1931 1931
 
1932
-			if ($elementNodes) {
1932
+            if ($elementNodes) {
1933 1933
 
1934
-				// Get file groups.
1935
-				$fileUse = $this->_getFileGrps();
1934
+                // Get file groups.
1935
+                $fileUse = $this->_getFileGrps();
1936 1936
 
1937
-				// Get the physical sequence's metadata.
1938
-				$physNode = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]');
1937
+                // Get the physical sequence's metadata.
1938
+                $physNode = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]');
1939 1939
 
1940
-				$physSeq[0] = (string) $physNode[0]['ID'];
1940
+                $physSeq[0] = (string) $physNode[0]['ID'];
1941 1941
 
1942
-				$this->physicalStructureInfo[$physSeq[0]]['id'] = $physNode[0]['ID'];
1942
+                $this->physicalStructureInfo[$physSeq[0]]['id'] = $physNode[0]['ID'];
1943 1943
 
1944
-				$this->physicalStructureInfo[$physSeq[0]]['dmdId'] = (isset($physNode[0]['DMDID']) ? (string) $physNode[0]['DMDID'] : '');
1944
+                $this->physicalStructureInfo[$physSeq[0]]['dmdId'] = (isset($physNode[0]['DMDID']) ? (string) $physNode[0]['DMDID'] : '');
1945 1945
 
1946
-				$this->physicalStructureInfo[$physSeq[0]]['label'] = (isset($physNode[0]['LABEL']) ? (string) $physNode[0]['LABEL'] : '');
1946
+                $this->physicalStructureInfo[$physSeq[0]]['label'] = (isset($physNode[0]['LABEL']) ? (string) $physNode[0]['LABEL'] : '');
1947 1947
 
1948
-				$this->physicalStructureInfo[$physSeq[0]]['orderlabel'] = (isset($physNode[0]['ORDERLABEL']) ? (string) $physNode[0]['ORDERLABEL'] : '');
1948
+                $this->physicalStructureInfo[$physSeq[0]]['orderlabel'] = (isset($physNode[0]['ORDERLABEL']) ? (string) $physNode[0]['ORDERLABEL'] : '');
1949 1949
 
1950
-				$this->physicalStructureInfo[$physSeq[0]]['type'] = (string) $physNode[0]['TYPE'];
1950
+                $this->physicalStructureInfo[$physSeq[0]]['type'] = (string) $physNode[0]['TYPE'];
1951 1951
 
1952
-				$this->physicalStructureInfo[$physSeq[0]]['contentIds'] = (isset($physNode[0]['CONTENTIDS']) ? (string) $physNode[0]['CONTENTIDS'] : '');
1952
+                $this->physicalStructureInfo[$physSeq[0]]['contentIds'] = (isset($physNode[0]['CONTENTIDS']) ? (string) $physNode[0]['CONTENTIDS'] : '');
1953 1953
 
1954
-				// Get the file representations from fileSec node.
1955
-				foreach ($physNode[0]->children('http://www.loc.gov/METS/')->fptr as $fptr) {
1954
+                // Get the file representations from fileSec node.
1955
+                foreach ($physNode[0]->children('http://www.loc.gov/METS/')->fptr as $fptr) {
1956 1956
 
1957
-					// Check if file has valid @USE attribute.
1958
-					if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) {
1957
+                    // Check if file has valid @USE attribute.
1958
+                    if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) {
1959 1959
 
1960
-						$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID;
1960
+                        $this->physicalStructureInfo[$physSeq[0]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID;
1961 1961
 
1962
-					}
1962
+                    }
1963 1963
 
1964
-				}
1964
+                }
1965 1965
 
1966
-				// Build the physical elements' array from the physical structMap node.
1967
-				foreach ($elementNodes as $elementNode) {
1966
+                // Build the physical elements' array from the physical structMap node.
1967
+                foreach ($elementNodes as $elementNode) {
1968 1968
 
1969
-					$elements[(int) $elementNode['ORDER']] = (string) $elementNode['ID'];
1969
+                    $elements[(int) $elementNode['ORDER']] = (string) $elementNode['ID'];
1970 1970
 
1971
-					$this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['id'] = $elementNode['ID'];
1971
+                    $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['id'] = $elementNode['ID'];
1972 1972
 
1973
-					$this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['dmdId'] = (isset($elementNode['DMDID']) ? (string) $elementNode['DMDID'] : '');
1973
+                    $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['dmdId'] = (isset($elementNode['DMDID']) ? (string) $elementNode['DMDID'] : '');
1974 1974
 
1975
-					$this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['label'] = (isset($elementNode['LABEL']) ? (string) $elementNode['LABEL'] : '');
1975
+                    $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['label'] = (isset($elementNode['LABEL']) ? (string) $elementNode['LABEL'] : '');
1976 1976
 
1977
-					$this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['orderlabel'] = (isset($elementNode['ORDERLABEL']) ? (string) $elementNode['ORDERLABEL'] : '');
1977
+                    $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['orderlabel'] = (isset($elementNode['ORDERLABEL']) ? (string) $elementNode['ORDERLABEL'] : '');
1978 1978
 
1979
-					$this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['type'] = (string) $elementNode['TYPE'];
1979
+                    $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['type'] = (string) $elementNode['TYPE'];
1980 1980
 
1981
-					$this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['contentIds'] = (isset($elementNode['CONTENTIDS']) ? (string) $elementNode['CONTENTIDS'] : '');
1981
+                    $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['contentIds'] = (isset($elementNode['CONTENTIDS']) ? (string) $elementNode['CONTENTIDS'] : '');
1982 1982
 
1983
-					// Get the file representations from fileSec node.
1984
-					foreach ($elementNode->children('http://www.loc.gov/METS/')->fptr as $fptr) {
1983
+                    // Get the file representations from fileSec node.
1984
+                    foreach ($elementNode->children('http://www.loc.gov/METS/')->fptr as $fptr) {
1985 1985
 
1986
-						// Check if file has valid @USE attribute.
1987
-						if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) {
1986
+                        // Check if file has valid @USE attribute.
1987
+                        if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) {
1988 1988
 
1989
-							$this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID;
1989
+                            $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID;
1990 1990
 
1991
-						}
1991
+                        }
1992 1992
 
1993
-					}
1993
+                    }
1994 1994
 
1995
-				}
1995
+                }
1996 1996
 
1997
-				// Sort array by keys (= @ORDER).
1998
-				if (ksort($elements)) {
1997
+                // Sort array by keys (= @ORDER).
1998
+                if (ksort($elements)) {
1999 1999
 
2000
-					// Set total number of pages/tracks.
2001
-					$this->numPages = count($elements);
2000
+                    // Set total number of pages/tracks.
2001
+                    $this->numPages = count($elements);
2002 2002
 
2003
-					// Merge and re-index the array to get nice numeric indexes.
2004
-					$this->physicalStructure = array_merge($physSeq, $elements);
2003
+                    // Merge and re-index the array to get nice numeric indexes.
2004
+                    $this->physicalStructure = array_merge($physSeq, $elements);
2005 2005
 
2006
-				}
2006
+                }
2007 2007
 
2008
-			}
2008
+            }
2009 2009
 
2010
-			$this->physicalStructureLoaded = TRUE;
2010
+            $this->physicalStructureLoaded = TRUE;
2011 2011
 
2012
-		}
2012
+        }
2013 2013
 
2014
-		return $this->physicalStructure;
2014
+        return $this->physicalStructure;
2015 2015
 
2016
-	}
2016
+    }
2017 2017
 
2018
-	/**
2019
-	 * This gives an array of the document's physical structure metadata
2020
-	 *
2021
-	 * @access	protected
2022
-	 *
2023
-	 * @return	array		Array of elements' type, label and file representations ordered by @ID attribute
2024
-	 */
2025
-	protected function _getPhysicalStructureInfo() {
2018
+    /**
2019
+     * This gives an array of the document's physical structure metadata
2020
+     *
2021
+     * @access	protected
2022
+     *
2023
+     * @return	array		Array of elements' type, label and file representations ordered by @ID attribute
2024
+     */
2025
+    protected function _getPhysicalStructureInfo() {
2026 2026
 
2027
-		// Is there no physical structure array yet?
2028
-		if (!$this->physicalStructureLoaded) {
2027
+        // Is there no physical structure array yet?
2028
+        if (!$this->physicalStructureLoaded) {
2029 2029
 
2030
-			// Build physical structure array.
2031
-			$this->_getPhysicalStructure();
2030
+            // Build physical structure array.
2031
+            $this->_getPhysicalStructure();
2032 2032
 
2033
-		}
2033
+        }
2034 2034
 
2035
-		return $this->physicalStructureInfo;
2035
+        return $this->physicalStructureInfo;
2036 2036
 
2037
-	}
2037
+    }
2038 2038
 
2039
-	/**
2040
-	 * This returns $this->pid via __get()
2041
-	 *
2042
-	 * @access	protected
2043
-	 *
2044
-	 * @return	integer		The PID of the document or zero if not in database
2045
-	 */
2046
-	protected function _getPid() {
2039
+    /**
2040
+     * This returns $this->pid via __get()
2041
+     *
2042
+     * @access	protected
2043
+     *
2044
+     * @return	integer		The PID of the document or zero if not in database
2045
+     */
2046
+    protected function _getPid() {
2047 2047
 
2048
-		return $this->pid;
2048
+        return $this->pid;
2049 2049
 
2050
-	}
2050
+    }
2051 2051
 
2052
-	/**
2053
-	 * This returns $this->ready via __get()
2054
-	 *
2055
-	 * @access	protected
2056
-	 *
2057
-	 * @return	boolean		Is the document instantiated successfully?
2058
-	 */
2059
-	protected function _getReady() {
2052
+    /**
2053
+     * This returns $this->ready via __get()
2054
+     *
2055
+     * @access	protected
2056
+     *
2057
+     * @return	boolean		Is the document instantiated successfully?
2058
+     */
2059
+    protected function _getReady() {
2060 2060
 
2061
-		return $this->ready;
2061
+        return $this->ready;
2062 2062
 
2063
-	}
2063
+    }
2064 2064
 
2065
-	/**
2066
-	 * This returns $this->recordId via __get()
2067
-	 *
2068
-	 * @access	protected
2069
-	 *
2070
-	 * @return	mixed		The METS file's record identifier
2071
-	 */
2072
-	protected function _getRecordId() {
2065
+    /**
2066
+     * This returns $this->recordId via __get()
2067
+     *
2068
+     * @access	protected
2069
+     *
2070
+     * @return	mixed		The METS file's record identifier
2071
+     */
2072
+    protected function _getRecordId() {
2073 2073
 
2074
-		return $this->recordId;
2074
+        return $this->recordId;
2075 2075
 
2076
-	}
2076
+    }
2077 2077
 
2078
-	/**
2079
-	 * This returns $this->rootId via __get()
2080
-	 *
2081
-	 * @access	protected
2082
-	 *
2083
-	 * @return	integer		The UID of the root document or zero if not applicable
2084
-	 */
2085
-	protected function _getRootId() {
2078
+    /**
2079
+     * This returns $this->rootId via __get()
2080
+     *
2081
+     * @access	protected
2082
+     *
2083
+     * @return	integer		The UID of the root document or zero if not applicable
2084
+     */
2085
+    protected function _getRootId() {
2086 2086
 
2087
-		if (!$this->rootIdLoaded) {
2087
+        if (!$this->rootIdLoaded) {
2088 2088
 
2089
-			if ($this->parentId) {
2089
+            if ($this->parentId) {
2090 2090
 
2091
-				$parent = self::getInstance($this->parentId, $this->pid);
2091
+                $parent = self::getInstance($this->parentId, $this->pid);
2092 2092
 
2093
-				$this->rootId = $parent->rootId;
2093
+                $this->rootId = $parent->rootId;
2094 2094
 
2095
-			}
2095
+            }
2096 2096
 
2097
-			$this->rootIdLoaded = TRUE;
2097
+            $this->rootIdLoaded = TRUE;
2098 2098
 
2099
-		}
2099
+        }
2100 2100
 
2101
-		return $this->rootId;
2101
+        return $this->rootId;
2102 2102
 
2103
-	}
2103
+    }
2104 2104
 
2105
-	/**
2106
-	 * This returns the smLinks between logical and physical structMap
2107
-	 *
2108
-	 * @access	protected
2109
-	 *
2110
-	 * @return	array		The links between logical and physical nodes
2111
-	 */
2112
-	protected function _getSmLinks() {
2105
+    /**
2106
+     * This returns the smLinks between logical and physical structMap
2107
+     *
2108
+     * @access	protected
2109
+     *
2110
+     * @return	array		The links between logical and physical nodes
2111
+     */
2112
+    protected function _getSmLinks() {
2113 2113
 
2114
-		if (!$this->smLinksLoaded) {
2114
+        if (!$this->smLinksLoaded) {
2115 2115
 
2116
-			$smLinks = $this->mets->xpath('./mets:structLink/mets:smLink');
2116
+            $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink');
2117 2117
 
2118
-			foreach ($smLinks as $smLink) {
2118
+            foreach ($smLinks as $smLink) {
2119 2119
 
2120
-				$this->smLinks['l2p'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->from][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->to;
2120
+                $this->smLinks['l2p'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->from][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->to;
2121 2121
 
2122
-				$this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from;
2122
+                $this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from;
2123 2123
 
2124
-			}
2124
+            }
2125 2125
 
2126
-			$this->smLinksLoaded = TRUE;
2126
+            $this->smLinksLoaded = TRUE;
2127 2127
 
2128
-		}
2128
+        }
2129 2129
 
2130
-		return $this->smLinks;
2130
+        return $this->smLinks;
2131 2131
 
2132
-	}
2132
+    }
2133 2133
 
2134
-	/**
2135
-	 * This builds an array of the document's logical structure
2136
-	 *
2137
-	 * @access	protected
2138
-	 *
2139
-	 * @return	array		Array of structure nodes' id, label, type and physical page indexes/mptr link with original hierarchy preserved
2140
-	 */
2141
-	protected function _getTableOfContents() {
2134
+    /**
2135
+     * This builds an array of the document's logical structure
2136
+     *
2137
+     * @access	protected
2138
+     *
2139
+     * @return	array		Array of structure nodes' id, label, type and physical page indexes/mptr link with original hierarchy preserved
2140
+     */
2141
+    protected function _getTableOfContents() {
2142 2142
 
2143
-		// Is there no logical structure array yet?
2144
-		if (!$this->tableOfContentsLoaded) {
2143
+        // Is there no logical structure array yet?
2144
+        if (!$this->tableOfContentsLoaded) {
2145 2145
 
2146
-			// Get all logical structures.
2147
-			$this->getLogicalStructure('', TRUE);
2146
+            // Get all logical structures.
2147
+            $this->getLogicalStructure('', TRUE);
2148 2148
 
2149
-			$this->tableOfContentsLoaded = TRUE;
2149
+            $this->tableOfContentsLoaded = TRUE;
2150 2150
 
2151
-		}
2151
+        }
2152 2152
 
2153
-		return $this->tableOfContents;
2153
+        return $this->tableOfContents;
2154 2154
 
2155
-	}
2155
+    }
2156 2156
 
2157
-	/**
2158
-	 * This returns the document's thumbnail location
2159
-	 *
2160
-	 * @access	protected
2161
-	 *
2162
-	 * @param	boolean		$forceReload: Force reloading the thumbnail instead of returning the cached value
2163
-	 *
2164
-	 * @return	string		The document's thumbnail location
2165
-	 */
2166
-	protected function _getThumbnail($forceReload = FALSE) {
2157
+    /**
2158
+     * This returns the document's thumbnail location
2159
+     *
2160
+     * @access	protected
2161
+     *
2162
+     * @param	boolean		$forceReload: Force reloading the thumbnail instead of returning the cached value
2163
+     *
2164
+     * @return	string		The document's thumbnail location
2165
+     */
2166
+    protected function _getThumbnail($forceReload = FALSE) {
2167 2167
 
2168
-		if (!$this->thumbnailLoaded || $forceReload) {
2168
+        if (!$this->thumbnailLoaded || $forceReload) {
2169 2169
 
2170
-			// Retain current PID.
2171
-			$cPid = ($this->cPid ? $this->cPid : $this->pid);
2170
+            // Retain current PID.
2171
+            $cPid = ($this->cPid ? $this->cPid : $this->pid);
2172 2172
 
2173
-			if (!$cPid) {
2173
+            if (!$cPid) {
2174 2174
 
2175
-				if (TYPO3_DLOG) {
2175
+                if (TYPO3_DLOG) {
2176 2176
 
2177
-					\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] Invalid PID "'.$cPid.'" for structure definitions', self::$extKey, SYSLOG_SEVERITY_ERROR);
2177
+                    \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] Invalid PID "'.$cPid.'" for structure definitions', self::$extKey, SYSLOG_SEVERITY_ERROR);
2178 2178
 
2179
-				}
2179
+                }
2180 2180
 
2181
-				$this->thumbnailLoaded = TRUE;
2181
+                $this->thumbnailLoaded = TRUE;
2182 2182
 
2183
-				return $this->thumbnail;
2183
+                return $this->thumbnail;
2184 2184
 
2185
-			}
2185
+            }
2186 2186
 
2187
-			// Load extension configuration.
2188
-			$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
2187
+            // Load extension configuration.
2188
+            $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
2189 2189
 
2190
-			if (empty($extConf['fileGrpThumbs'])) {
2190
+            if (empty($extConf['fileGrpThumbs'])) {
2191 2191
 
2192
-				if (TYPO3_DLOG) {
2192
+                if (TYPO3_DLOG) {
2193 2193
 
2194
-					\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] No fileGrp for thumbnails specified', self::$extKey, SYSLOG_SEVERITY_WARNING);
2194
+                    \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] No fileGrp for thumbnails specified', self::$extKey, SYSLOG_SEVERITY_WARNING);
2195 2195
 
2196
-				}
2196
+                }
2197 2197
 
2198
-				$this->thumbnailLoaded = TRUE;
2198
+                $this->thumbnailLoaded = TRUE;
2199 2199
 
2200
-				return $this->thumbnail;
2200
+                return $this->thumbnail;
2201 2201
 
2202
-			}
2202
+            }
2203 2203
 
2204
-			$strctId = $this->_getToplevelId();
2204
+            $strctId = $this->_getToplevelId();
2205 2205
 
2206
-			$metadata = $this->getTitledata($cPid);
2206
+            $metadata = $this->getTitledata($cPid);
2207 2207
 
2208
-			// Get structure element to get thumbnail from.
2209
-			$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
2210
-				'tx_dlf_structures.thumbnail AS thumbnail',
2211
-				'tx_dlf_structures',
2212
-				'tx_dlf_structures.pid='.intval($cPid).' AND tx_dlf_structures.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['type'][0], 'tx_dlf_structures').tx_dlf_helper::whereClause('tx_dlf_structures'),
2213
-				'',
2214
-				'',
2215
-				'1'
2216
-			);
2208
+            // Get structure element to get thumbnail from.
2209
+            $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
2210
+                'tx_dlf_structures.thumbnail AS thumbnail',
2211
+                'tx_dlf_structures',
2212
+                'tx_dlf_structures.pid='.intval($cPid).' AND tx_dlf_structures.index_name='.$GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['type'][0], 'tx_dlf_structures').tx_dlf_helper::whereClause('tx_dlf_structures'),
2213
+                '',
2214
+                '',
2215
+                '1'
2216
+            );
2217 2217
 
2218
-			if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
2218
+            if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
2219 2219
 
2220
-				$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
2220
+                $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
2221 2221
 
2222
-				// Get desired thumbnail structure if not the toplevel structure itself.
2223
-				if (!empty($resArray['thumbnail'])) {
2222
+                // Get desired thumbnail structure if not the toplevel structure itself.
2223
+                if (!empty($resArray['thumbnail'])) {
2224 2224
 
2225
-					$strctType = tx_dlf_helper::getIndexName($resArray['thumbnail'], 'tx_dlf_structures', $cPid);
2225
+                    $strctType = tx_dlf_helper::getIndexName($resArray['thumbnail'], 'tx_dlf_structures', $cPid);
2226 2226
 
2227
-					// Check if this document has a structure element of the desired type.
2228
-					$strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="'.$strctType.'"]/@ID');
2227
+                    // Check if this document has a structure element of the desired type.
2228
+                    $strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="'.$strctType.'"]/@ID');
2229 2229
 
2230
-					if (!empty($strctIds)) {
2230
+                    if (!empty($strctIds)) {
2231 2231
 
2232
-						$strctId = (string) $strctIds[0];
2232
+                        $strctId = (string) $strctIds[0];
2233 2233
 
2234
-					}
2234
+                    }
2235 2235
 
2236
-				}
2236
+                }
2237 2237
 
2238
-				// Load smLinks.
2239
-				$this->_getSmLinks();
2238
+                // Load smLinks.
2239
+                $this->_getSmLinks();
2240 2240
 
2241
-				// Get thumbnail location.
2242
-				if ($this->_getPhysicalStructure() && !empty($this->smLinks['l2p'][$strctId])) {
2241
+                // Get thumbnail location.
2242
+                if ($this->_getPhysicalStructure() && !empty($this->smLinks['l2p'][$strctId])) {
2243 2243
 
2244
-					$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$extConf['fileGrpThumbs']]);
2244
+                    $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$extConf['fileGrpThumbs']]);
2245 2245
 
2246
-				} else {
2246
+                } else {
2247 2247
 
2248
-					$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']]);
2248
+                    $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']]);
2249 2249
 
2250
-				}
2250
+                }
2251 2251
 
2252
-			} elseif (TYPO3_DLOG) {
2252
+            } elseif (TYPO3_DLOG) {
2253 2253
 
2254
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] No structure of type "'.$metadata['type'][0].'" found in database', self::$extKey, SYSLOG_SEVERITY_ERROR);
2254
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] No structure of type "'.$metadata['type'][0].'" found in database', self::$extKey, SYSLOG_SEVERITY_ERROR);
2255 2255
 
2256
-			}
2256
+            }
2257 2257
 
2258
-			$this->thumbnailLoaded = TRUE;
2258
+            $this->thumbnailLoaded = TRUE;
2259 2259
 
2260
-		}
2260
+        }
2261 2261
 
2262
-		return $this->thumbnail;
2262
+        return $this->thumbnail;
2263 2263
 
2264
-	}
2264
+    }
2265 2265
 
2266
-	/**
2267
-	 * This returns the ID of the toplevel logical structure node
2268
-	 *
2269
-	 * @access	protected
2270
-	 *
2271
-	 * @return	string		The logical structure node's ID
2272
-	 */
2273
-	protected function _getToplevelId() {
2266
+    /**
2267
+     * This returns the ID of the toplevel logical structure node
2268
+     *
2269
+     * @access	protected
2270
+     *
2271
+     * @return	string		The logical structure node's ID
2272
+     */
2273
+    protected function _getToplevelId() {
2274 2274
 
2275
-		if (empty($this->toplevelId)) {
2275
+        if (empty($this->toplevelId)) {
2276 2276
 
2277
-			// Get all logical structure nodes with metadata, but without associated METS-Pointers.
2278
-			if (($divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) {
2277
+            // Get all logical structure nodes with metadata, but without associated METS-Pointers.
2278
+            if (($divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) {
2279 2279
 
2280
-				// Load smLinks.
2281
-				$this->_getSmLinks();
2280
+                // Load smLinks.
2281
+                $this->_getSmLinks();
2282 2282
 
2283
-				foreach ($divs as $div) {
2283
+                foreach ($divs as $div) {
2284 2284
 
2285
-					$id = (string) $div['ID'];
2285
+                    $id = (string) $div['ID'];
2286 2286
 
2287
-					// Are there physical structure nodes for this logical structure?
2288
-					if (array_key_exists($id, $this->smLinks['l2p'])) {
2287
+                    // Are there physical structure nodes for this logical structure?
2288
+                    if (array_key_exists($id, $this->smLinks['l2p'])) {
2289 2289
 
2290
-						// Yes. That's what we're looking for.
2291
-						$this->toplevelId = $id;
2290
+                        // Yes. That's what we're looking for.
2291
+                        $this->toplevelId = $id;
2292 2292
 
2293
-						break;
2293
+                        break;
2294 2294
 
2295
-					} elseif (empty($this->toplevelId)) {
2295
+                    } elseif (empty($this->toplevelId)) {
2296 2296
 
2297
-						// No. Remember this anyway, but keep looking for a better one.
2298
-						$this->toplevelId = $id;
2297
+                        // No. Remember this anyway, but keep looking for a better one.
2298
+                        $this->toplevelId = $id;
2299 2299
 
2300
-					}
2300
+                    }
2301 2301
 
2302
-				}
2302
+                }
2303 2303
 
2304
-			}
2304
+            }
2305 2305
 
2306
-		}
2306
+        }
2307 2307
 
2308
-		return $this->toplevelId;
2308
+        return $this->toplevelId;
2309 2309
 
2310
-	}
2310
+    }
2311 2311
 
2312
-	/**
2313
-	 * This returns $this->uid via __get()
2314
-	 *
2315
-	 * @access	protected
2316
-	 *
2317
-	 * @return	mixed		The UID or the URL of the document
2318
-	 */
2319
-	protected function _getUid() {
2312
+    /**
2313
+     * This returns $this->uid via __get()
2314
+     *
2315
+     * @access	protected
2316
+     *
2317
+     * @return	mixed		The UID or the URL of the document
2318
+     */
2319
+    protected function _getUid() {
2320 2320
 
2321
-		return $this->uid;
2321
+        return $this->uid;
2322 2322
 
2323
-	}
2323
+    }
2324 2324
 
2325
-	/**
2326
-	 * This sets $this->cPid via __set()
2327
-	 *
2328
-	 * @access	protected
2329
-	 *
2330
-	 * @param	integer		$value: The new PID for the metadata definitions
2331
-	 *
2332
-	 * @return	void
2333
-	 */
2334
-	protected function _setCPid($value) {
2325
+    /**
2326
+     * This sets $this->cPid via __set()
2327
+     *
2328
+     * @access	protected
2329
+     *
2330
+     * @param	integer		$value: The new PID for the metadata definitions
2331
+     *
2332
+     * @return	void
2333
+     */
2334
+    protected function _setCPid($value) {
2335 2335
 
2336
-		$this->cPid = max(intval($value), 0);
2336
+        $this->cPid = max(intval($value), 0);
2337 2337
 
2338
-	}
2338
+    }
2339 2339
 
2340
-	/**
2341
-	 * This magic method is invoked each time a clone is called on the object variable
2342
-	 * (This method is defined as private/protected because singleton objects should not be cloned)
2343
-	 *
2344
-	 * @access	protected
2345
-	 *
2346
-	 * @return	void
2347
-	 */
2348
-	protected function __clone() {}
2340
+    /**
2341
+     * This magic method is invoked each time a clone is called on the object variable
2342
+     * (This method is defined as private/protected because singleton objects should not be cloned)
2343
+     *
2344
+     * @access	protected
2345
+     *
2346
+     * @return	void
2347
+     */
2348
+    protected function __clone() {}
2349 2349
 
2350
-	/**
2351
-	 * This is a singleton class, thus the constructor should be private/protected
2352
-	 *
2353
-	 * @access	protected
2354
-	 *
2355
-	 * @param	integer		$uid: The UID of the document to parse or URL to XML file
2356
-	 * @param	integer		$pid: If > 0, then only document with this PID gets loaded
2357
-	 *
2358
-	 * @return	void
2359
-	 */
2360
-	protected function __construct($uid, $pid) {
2350
+    /**
2351
+     * This is a singleton class, thus the constructor should be private/protected
2352
+     *
2353
+     * @access	protected
2354
+     *
2355
+     * @param	integer		$uid: The UID of the document to parse or URL to XML file
2356
+     * @param	integer		$pid: If > 0, then only document with this PID gets loaded
2357
+     *
2358
+     * @return	void
2359
+     */
2360
+    protected function __construct($uid, $pid) {
2361 2361
 
2362
-		// Prepare to check database for the requested document.
2363
-		if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($uid)) {
2362
+        // Prepare to check database for the requested document.
2363
+        if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($uid)) {
2364 2364
 
2365
-			$whereClause = 'tx_dlf_documents.uid='.intval($uid).tx_dlf_helper::whereClause('tx_dlf_documents');
2365
+            $whereClause = 'tx_dlf_documents.uid='.intval($uid).tx_dlf_helper::whereClause('tx_dlf_documents');
2366 2366
 
2367
-		} else {
2367
+        } else {
2368 2368
 
2369
-			// Cast to string for safety reasons.
2370
-			$location = (string) $uid;
2369
+            // Cast to string for safety reasons.
2370
+            $location = (string) $uid;
2371 2371
 
2372
-			// Try to load METS file.
2373
-			if ($this->load($location)) {
2372
+            // Try to load METS file.
2373
+            if ($this->load($location)) {
2374 2374
 
2375
-				// Initialize core METS object.
2376
-				$this->init();
2375
+                // Initialize core METS object.
2376
+                $this->init();
2377 2377
 
2378
-				if ($this->mets !== NULL) {
2378
+                if ($this->mets !== NULL) {
2379 2379
 
2380
-					// Check for METS object @ID.
2381
-					if (!empty($this->mets['OBJID'])) {
2380
+                    // Check for METS object @ID.
2381
+                    if (!empty($this->mets['OBJID'])) {
2382 2382
 
2383
-						$this->recordId = (string) $this->mets['OBJID'];
2383
+                        $this->recordId = (string) $this->mets['OBJID'];
2384 2384
 
2385
-					}
2385
+                    }
2386 2386
 
2387
-					// Get hook objects.
2388
-					$hookObjects = tx_dlf_helper::getHookObjects('common/class.tx_dlf_document.php');
2387
+                    // Get hook objects.
2388
+                    $hookObjects = tx_dlf_helper::getHookObjects('common/class.tx_dlf_document.php');
2389 2389
 
2390
-					// Apply hooks.
2391
-					foreach($hookObjects as $hookObj) {
2390
+                    // Apply hooks.
2391
+                    foreach($hookObjects as $hookObj) {
2392 2392
 
2393
-						if (method_exists($hookObj, 'construct_postProcessRecordId')) {
2393
+                        if (method_exists($hookObj, 'construct_postProcessRecordId')) {
2394 2394
 
2395
-							$hookObj->construct_postProcessRecordId($this->xml, $this->recordId);
2395
+                            $hookObj->construct_postProcessRecordId($this->xml, $this->recordId);
2396 2396
 
2397
-						}
2397
+                        }
2398 2398
 
2399
-					}
2399
+                    }
2400 2400
 
2401
-				} else {
2401
+                } else {
2402 2402
 
2403
-					// No METS part found.
2404
-					return;
2403
+                    // No METS part found.
2404
+                    return;
2405 2405
 
2406
-				}
2406
+                }
2407 2407
 
2408
-			} else {
2408
+            } else {
2409 2409
 
2410
-				// Loading failed.
2411
-				return;
2410
+                // Loading failed.
2411
+                return;
2412 2412
 
2413
-			}
2413
+            }
2414 2414
 
2415
-			if (!empty($this->recordId)) {
2415
+            if (!empty($this->recordId)) {
2416 2416
 
2417
-				$whereClause = 'tx_dlf_documents.record_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->recordId, 'tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_documents');
2417
+                $whereClause = 'tx_dlf_documents.record_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->recordId, 'tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_documents');
2418 2418
 
2419
-			} else {
2419
+            } else {
2420 2420
 
2421
-				// There is no record identifier and there should be no hit in the database.
2422
-				$whereClause = '1=-1';
2421
+                // There is no record identifier and there should be no hit in the database.
2422
+                $whereClause = '1=-1';
2423 2423
 
2424
-			}
2424
+            }
2425 2425
 
2426
-		}
2426
+        }
2427 2427
 
2428
-		// Check for PID if needed.
2429
-		if ($pid) {
2428
+        // Check for PID if needed.
2429
+        if ($pid) {
2430 2430
 
2431
-			$whereClause .= ' AND tx_dlf_documents.pid='.intval($pid);
2431
+            $whereClause .= ' AND tx_dlf_documents.pid='.intval($pid);
2432 2432
 
2433
-		}
2433
+        }
2434 2434
 
2435
-		// Get document PID and location from database.
2436
-		$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
2437
-			'tx_dlf_documents.uid AS uid,tx_dlf_documents.pid AS pid,tx_dlf_documents.record_id AS record_id,tx_dlf_documents.partof AS partof,tx_dlf_documents.thumbnail AS thumbnail,tx_dlf_documents.location AS location',
2438
-			'tx_dlf_documents',
2439
-			$whereClause,
2440
-			'',
2441
-			'',
2442
-			'1'
2443
-		);
2435
+        // Get document PID and location from database.
2436
+        $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
2437
+            'tx_dlf_documents.uid AS uid,tx_dlf_documents.pid AS pid,tx_dlf_documents.record_id AS record_id,tx_dlf_documents.partof AS partof,tx_dlf_documents.thumbnail AS thumbnail,tx_dlf_documents.location AS location',
2438
+            'tx_dlf_documents',
2439
+            $whereClause,
2440
+            '',
2441
+            '',
2442
+            '1'
2443
+        );
2444 2444
 
2445
-		if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
2445
+        if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
2446 2446
 
2447
-			list ($this->uid, $this->pid, $this->recordId, $this->parentId, $this->thumbnail, $this->location) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
2447
+            list ($this->uid, $this->pid, $this->recordId, $this->parentId, $this->thumbnail, $this->location) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
2448 2448
 
2449
-			$this->thumbnailLoaded = TRUE;
2449
+            $this->thumbnailLoaded = TRUE;
2450 2450
 
2451
-			// Load XML file if necessary...
2452
-			if ($this->mets === NULL && $this->load($this->location)) {
2451
+            // Load XML file if necessary...
2452
+            if ($this->mets === NULL && $this->load($this->location)) {
2453 2453
 
2454
-				// ...and set some basic properties.
2455
-				$this->init();
2454
+                // ...and set some basic properties.
2455
+                $this->init();
2456 2456
 
2457
-			}
2457
+            }
2458 2458
 
2459
-			// Do we have a METS object now?
2460
-			if ($this->mets !== NULL) {
2459
+            // Do we have a METS object now?
2460
+            if ($this->mets !== NULL) {
2461 2461
 
2462
-				// Set new location if necessary.
2463
-				if (!empty($location)) {
2462
+                // Set new location if necessary.
2463
+                if (!empty($location)) {
2464 2464
 
2465
-					$this->location = $location;
2465
+                    $this->location = $location;
2466 2466
 
2467
-				}
2467
+                }
2468 2468
 
2469
-				// Document ready!
2470
-				$this->ready = TRUE;
2469
+                // Document ready!
2470
+                $this->ready = TRUE;
2471 2471
 
2472
-			}
2472
+            }
2473 2473
 
2474
-		} elseif ($this->mets !== NULL) {
2474
+        } elseif ($this->mets !== NULL) {
2475 2475
 
2476
-			// Set location as UID for documents not in database.
2477
-			$this->uid = $location;
2476
+            // Set location as UID for documents not in database.
2477
+            $this->uid = $location;
2478 2478
 
2479
-			$this->location = $location;
2479
+            $this->location = $location;
2480 2480
 
2481
-			// Document ready!
2482
-			$this->ready = TRUE;
2481
+            // Document ready!
2482
+            $this->ready = TRUE;
2483 2483
 
2484
-		} else {
2484
+        } else {
2485 2485
 
2486
-			if (TYPO3_DLOG) {
2486
+            if (TYPO3_DLOG) {
2487 2487
 
2488
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__construct('.$uid.', '.$pid.')] No document with UID "'.$uid.'" found or document not accessible', self::$extKey, SYSLOG_SEVERITY_ERROR);
2488
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__construct('.$uid.', '.$pid.')] No document with UID "'.$uid.'" found or document not accessible', self::$extKey, SYSLOG_SEVERITY_ERROR);
2489 2489
 
2490
-			}
2490
+            }
2491 2491
 
2492
-		}
2492
+        }
2493 2493
 
2494
-	}
2494
+    }
2495 2495
 
2496
-	/**
2497
-	 * This magic method is called each time an invisible property is referenced from the object
2498
-	 *
2499
-	 * @access	public
2500
-	 *
2501
-	 * @param	string		$var: Name of variable to get
2502
-	 *
2503
-	 * @return	mixed		Value of $this->$var
2504
-	 */
2505
-	public function __get($var) {
2496
+    /**
2497
+     * This magic method is called each time an invisible property is referenced from the object
2498
+     *
2499
+     * @access	public
2500
+     *
2501
+     * @param	string		$var: Name of variable to get
2502
+     *
2503
+     * @return	mixed		Value of $this->$var
2504
+     */
2505
+    public function __get($var) {
2506 2506
 
2507
-		$method = '_get'.ucfirst($var);
2507
+        $method = '_get'.ucfirst($var);
2508 2508
 
2509
-		if (!property_exists($this, $var) || !method_exists($this, $method)) {
2509
+        if (!property_exists($this, $var) || !method_exists($this, $method)) {
2510 2510
 
2511
-			if (TYPO3_DLOG) {
2511
+            if (TYPO3_DLOG) {
2512 2512
 
2513
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__get('.$var.')] There is no getter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
2513
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__get('.$var.')] There is no getter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
2514 2514
 
2515
-			}
2515
+            }
2516 2516
 
2517
-			return;
2517
+            return;
2518 2518
 
2519
-		} else {
2519
+        } else {
2520 2520
 
2521
-			return $this->$method();
2521
+            return $this->$method();
2522 2522
 
2523
-		}
2523
+        }
2524 2524
 
2525
-	}
2525
+    }
2526 2526
 
2527
-	/**
2528
-	 * This magic method is called each time an invisible property is referenced from the object
2529
-	 *
2530
-	 * @access	public
2531
-	 *
2532
-	 * @param	string		$var: Name of variable to set
2533
-	 * @param	mixed		$value: New value of variable
2534
-	 *
2535
-	 * @return	void
2536
-	 */
2537
-	public function __set($var, $value) {
2527
+    /**
2528
+     * This magic method is called each time an invisible property is referenced from the object
2529
+     *
2530
+     * @access	public
2531
+     *
2532
+     * @param	string		$var: Name of variable to set
2533
+     * @param	mixed		$value: New value of variable
2534
+     *
2535
+     * @return	void
2536
+     */
2537
+    public function __set($var, $value) {
2538 2538
 
2539
-		$method = '_set'.ucfirst($var);
2539
+        $method = '_set'.ucfirst($var);
2540 2540
 
2541
-		if (!property_exists($this, $var) || !method_exists($this, $method)) {
2541
+        if (!property_exists($this, $var) || !method_exists($this, $method)) {
2542 2542
 
2543
-			if (TYPO3_DLOG) {
2543
+            if (TYPO3_DLOG) {
2544 2544
 
2545
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__set('.$var.', '.$value.')] There is no setter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
2545
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__set('.$var.', '.$value.')] There is no setter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
2546 2546
 
2547
-			}
2547
+            }
2548 2548
 
2549
-		} else {
2549
+        } else {
2550 2550
 
2551
-			$this->$method($value);
2551
+            $this->$method($value);
2552 2552
 
2553
-		}
2553
+        }
2554 2554
 
2555
-	}
2555
+    }
2556 2556
 
2557
-	/**
2558
-	 * This magic method is executed prior to any serialization of the object
2559
-	 * @see __wakeup()
2560
-	 *
2561
-	 * @access	public
2562
-	 *
2563
-	 * @return	array		Properties to be serialized
2564
-	 */
2565
-	public function __sleep() {
2557
+    /**
2558
+     * This magic method is executed prior to any serialization of the object
2559
+     * @see __wakeup()
2560
+     *
2561
+     * @access	public
2562
+     *
2563
+     * @return	array		Properties to be serialized
2564
+     */
2565
+    public function __sleep() {
2566 2566
 
2567
-		// SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization
2568
-		$this->asXML = $this->xml->asXML();
2567
+        // SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization
2568
+        $this->asXML = $this->xml->asXML();
2569 2569
 
2570
-		return array ('uid', 'pid', 'recordId', 'parentId', 'asXML');
2570
+        return array ('uid', 'pid', 'recordId', 'parentId', 'asXML');
2571 2571
 
2572
-	}
2572
+    }
2573 2573
 
2574
-	/**
2575
-	 * This magic method is used for setting a string value for the object
2576
-	 *
2577
-	 * @access	public
2578
-	 *
2579
-	 * @return	string		String representing the METS object
2580
-	 */
2581
-	public function __toString() {
2574
+    /**
2575
+     * This magic method is used for setting a string value for the object
2576
+     *
2577
+     * @access	public
2578
+     *
2579
+     * @return	string		String representing the METS object
2580
+     */
2581
+    public function __toString() {
2582 2582
 
2583
-		$xml = new DOMDocument('1.0', 'utf-8');
2583
+        $xml = new DOMDocument('1.0', 'utf-8');
2584 2584
 
2585
-		$xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE));
2585
+        $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE));
2586 2586
 
2587
-		$xml->formatOutput = TRUE;
2587
+        $xml->formatOutput = TRUE;
2588 2588
 
2589
-		return $xml->saveXML();
2589
+        return $xml->saveXML();
2590 2590
 
2591
-	}
2591
+    }
2592 2592
 
2593
-	/**
2594
-	 * This magic method is executed after the object is deserialized
2595
-	 * @see __sleep()
2596
-	 *
2597
-	 * @access	public
2598
-	 *
2599
-	 * @return	void
2600
-	 */
2601
-	public function __wakeup() {
2593
+    /**
2594
+     * This magic method is executed after the object is deserialized
2595
+     * @see __sleep()
2596
+     *
2597
+     * @access	public
2598
+     *
2599
+     * @return	void
2600
+     */
2601
+    public function __wakeup() {
2602 2602
 
2603
-		// Turn off libxml's error logging.
2604
-		$libxmlErrors = libxml_use_internal_errors(TRUE);
2603
+        // Turn off libxml's error logging.
2604
+        $libxmlErrors = libxml_use_internal_errors(TRUE);
2605 2605
 
2606
-		// Reload XML from string.
2607
-		$xml = @simplexml_load_string($this->asXML);
2606
+        // Reload XML from string.
2607
+        $xml = @simplexml_load_string($this->asXML);
2608 2608
 
2609
-		// Reset libxml's error logging.
2610
-		libxml_use_internal_errors($libxmlErrors);
2609
+        // Reset libxml's error logging.
2610
+        libxml_use_internal_errors($libxmlErrors);
2611 2611
 
2612
-		if ($xml !== FALSE) {
2612
+        if ($xml !== FALSE) {
2613 2613
 
2614
-			$this->asXML = '';
2614
+            $this->asXML = '';
2615 2615
 
2616
-			$this->xml = $xml;
2616
+            $this->xml = $xml;
2617 2617
 
2618
-			// Rebuild the unserializable properties.
2619
-			$this->init();
2618
+            // Rebuild the unserializable properties.
2619
+            $this->init();
2620 2620
 
2621
-		} else {
2621
+        } else {
2622 2622
 
2623
-			if (TYPO3_DLOG) {
2623
+            if (TYPO3_DLOG) {
2624 2624
 
2625
-				\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__wakeup()] Could not load XML after deserialization', self::$extKey, SYSLOG_SEVERITY_ERROR);
2625
+                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__wakeup()] Could not load XML after deserialization', self::$extKey, SYSLOG_SEVERITY_ERROR);
2626 2626
 
2627
-			}
2627
+            }
2628 2628
 
2629
-		}
2629
+        }
2630 2630
 
2631
-	}
2631
+    }
2632 2632
 
2633 2633
 }
Please login to merge, or discard this patch.