@@ -20,2666 +20,2666 @@ |
||
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 | - 'OAI' => array ( |
|
92 | - 'rootElement' => 'OAI-PMH', |
|
93 | - 'namespaceURI' => 'http://www.openarchives.org/OAI/2.0/', |
|
94 | - ), |
|
95 | - 'METS' => array ( |
|
96 | - 'rootElement' => 'mets', |
|
97 | - 'namespaceURI' => 'http://www.loc.gov/METS/', |
|
98 | - ), |
|
99 | - 'XLINK' => array ( |
|
100 | - 'rootElement' => 'xlink', |
|
101 | - 'namespaceURI' => 'http://www.w3.org/1999/xlink', |
|
102 | - ) |
|
103 | - ); |
|
104 | - |
|
105 | - /** |
|
106 | - * Are the available metadata formats loaded? |
|
107 | - * @see $formats |
|
108 | - * |
|
109 | - * @var boolean |
|
110 | - * @access protected |
|
111 | - */ |
|
112 | - protected $formatsLoaded = FALSE; |
|
113 | - |
|
114 | - /** |
|
115 | - * Are there any fulltext files available? |
|
116 | - * |
|
117 | - * @var boolean |
|
118 | - * @access protected |
|
119 | - */ |
|
120 | - protected $hasFulltext = FALSE; |
|
121 | - |
|
122 | - /** |
|
123 | - * Last searched logical and physical page |
|
124 | - * |
|
125 | - * @var array |
|
126 | - * @access protected |
|
127 | - */ |
|
128 | - protected $lastSearchedPhysicalPage = array ('logicalPage' => NULL, 'physicalPage' => NULL); |
|
129 | - |
|
130 | - /** |
|
131 | - * This holds the documents location |
|
132 | - * |
|
133 | - * @var string |
|
134 | - * @access protected |
|
135 | - */ |
|
136 | - protected $location = ''; |
|
137 | - |
|
138 | - /** |
|
139 | - * This holds the logical units |
|
140 | - * |
|
141 | - * @var array |
|
142 | - * @access protected |
|
143 | - */ |
|
144 | - protected $logicalUnits = array (); |
|
145 | - |
|
146 | - /** |
|
147 | - * This holds the documents' parsed metadata array with their corresponding structMap//div's ID as array key |
|
148 | - * |
|
149 | - * @var array |
|
150 | - * @access protected |
|
151 | - */ |
|
152 | - protected $metadataArray = array (); |
|
153 | - |
|
154 | - /** |
|
155 | - * Is the metadata array loaded? |
|
156 | - * @see $metadataArray |
|
157 | - * |
|
158 | - * @var boolean |
|
159 | - * @access protected |
|
160 | - */ |
|
161 | - protected $metadataArrayLoaded = FALSE; |
|
162 | - |
|
163 | - /** |
|
164 | - * This holds the XML file's METS part as SimpleXMLElement object |
|
165 | - * |
|
166 | - * @var SimpleXMLElement |
|
167 | - * @access protected |
|
168 | - */ |
|
169 | - protected $mets; |
|
170 | - |
|
171 | - /** |
|
172 | - * The holds the total number of pages |
|
173 | - * |
|
174 | - * @var integer |
|
175 | - * @access protected |
|
176 | - */ |
|
177 | - protected $numPages = 0; |
|
178 | - |
|
179 | - /** |
|
180 | - * This holds the UID of the parent document or zero if not multi-volumed |
|
181 | - * |
|
182 | - * @var integer |
|
183 | - * @access protected |
|
184 | - */ |
|
185 | - protected $parentId = 0; |
|
186 | - |
|
187 | - /** |
|
188 | - * This holds the physical structure |
|
189 | - * |
|
190 | - * @var array |
|
191 | - * @access protected |
|
192 | - */ |
|
193 | - protected $physicalStructure = array (); |
|
194 | - |
|
195 | - /** |
|
196 | - * This holds the physical structure metadata |
|
197 | - * |
|
198 | - * @var array |
|
199 | - * @access protected |
|
200 | - */ |
|
201 | - protected $physicalStructureInfo = array (); |
|
202 | - |
|
203 | - /** |
|
204 | - * Is the physical structure loaded? |
|
205 | - * @see $physicalStructure |
|
206 | - * |
|
207 | - * @var boolean |
|
208 | - * @access protected |
|
209 | - */ |
|
210 | - protected $physicalStructureLoaded = FALSE; |
|
211 | - |
|
212 | - /** |
|
213 | - * This holds the PID of the document or zero if not in database |
|
214 | - * |
|
215 | - * @var integer |
|
216 | - * @access protected |
|
217 | - */ |
|
218 | - protected $pid = 0; |
|
219 | - |
|
220 | - /** |
|
221 | - * Is the document instantiated successfully? |
|
222 | - * |
|
223 | - * @var boolean |
|
224 | - * @access protected |
|
225 | - */ |
|
226 | - protected $ready = FALSE; |
|
227 | - |
|
228 | - /** |
|
229 | - * The METS file's record identifier |
|
230 | - * |
|
231 | - * @var string |
|
232 | - * @access protected |
|
233 | - */ |
|
234 | - protected $recordId; |
|
235 | - |
|
236 | - /** |
|
237 | - * This holds the singleton object of the document |
|
238 | - * |
|
239 | - * @var array (tx_dlf_document) |
|
240 | - * @access protected |
|
241 | - */ |
|
242 | - protected static $registry = array (); |
|
243 | - |
|
244 | - /** |
|
245 | - * This holds the UID of the root document or zero if not multi-volumed |
|
246 | - * |
|
247 | - * @var integer |
|
248 | - * @access protected |
|
249 | - */ |
|
250 | - protected $rootId = 0; |
|
251 | - |
|
252 | - /** |
|
253 | - * Is the root id loaded? |
|
254 | - * @see $rootId |
|
255 | - * |
|
256 | - * @var boolean |
|
257 | - * @access protected |
|
258 | - */ |
|
259 | - protected $rootIdLoaded = FALSE; |
|
260 | - |
|
261 | - /** |
|
262 | - * This holds the smLinks between logical and physical structMap |
|
263 | - * |
|
264 | - * @var array |
|
265 | - * @access protected |
|
266 | - */ |
|
267 | - protected $smLinks = array ('l2p' => array (), 'p2l' => array ()); |
|
268 | - |
|
269 | - /** |
|
270 | - * Are the smLinks loaded? |
|
271 | - * @see $smLinks |
|
272 | - * |
|
273 | - * @var boolean |
|
274 | - * @access protected |
|
275 | - */ |
|
276 | - protected $smLinksLoaded = FALSE; |
|
277 | - |
|
278 | - /** |
|
279 | - * This holds the logical structure |
|
280 | - * |
|
281 | - * @var array |
|
282 | - * @access protected |
|
283 | - */ |
|
284 | - protected $tableOfContents = array (); |
|
285 | - |
|
286 | - /** |
|
287 | - * Is the table of contents loaded? |
|
288 | - * @see $tableOfContents |
|
289 | - * |
|
290 | - * @var boolean |
|
291 | - * @access protected |
|
292 | - */ |
|
293 | - protected $tableOfContentsLoaded = FALSE; |
|
294 | - |
|
295 | - /** |
|
296 | - * This holds the document's thumbnail location. |
|
297 | - * |
|
298 | - * @var string |
|
299 | - * @access protected |
|
300 | - */ |
|
301 | - protected $thumbnail = ''; |
|
302 | - |
|
303 | - /** |
|
304 | - * Is the document's thumbnail location loaded? |
|
305 | - * @see $thumbnail |
|
306 | - * |
|
307 | - * @var boolean |
|
308 | - * @access protected |
|
309 | - */ |
|
310 | - protected $thumbnailLoaded = FALSE; |
|
311 | - |
|
312 | - /** |
|
313 | - * This holds the toplevel structure's @ID |
|
314 | - * |
|
315 | - * @var string |
|
316 | - * @access protected |
|
317 | - */ |
|
318 | - protected $toplevelId = ''; |
|
319 | - |
|
320 | - /** |
|
321 | - * This holds the UID or the URL of the document |
|
322 | - * |
|
323 | - * @var mixed |
|
324 | - * @access protected |
|
325 | - */ |
|
326 | - protected $uid = 0; |
|
327 | - |
|
328 | - /** |
|
329 | - * This holds the whole XML file as SimpleXMLElement object |
|
330 | - * |
|
331 | - * @var SimpleXMLElement |
|
332 | - * @access protected |
|
333 | - */ |
|
334 | - protected $xml; |
|
335 | - |
|
336 | - /** |
|
337 | - * This clears the static registry to prevent memory exhaustion |
|
338 | - * |
|
339 | - * @access public |
|
340 | - * |
|
341 | - * @return void |
|
342 | - */ |
|
343 | - public static function clearRegistry() { |
|
344 | - |
|
345 | - // Reset registry array. |
|
346 | - self::$registry = array (); |
|
347 | - |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * This gets the location of a file representing a physical page or track |
|
352 | - * |
|
353 | - * @access public |
|
354 | - * |
|
355 | - * @param string $id: The @ID attribute of the file node |
|
356 | - * |
|
357 | - * @return string The file's location as URL |
|
358 | - */ |
|
359 | - 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 | + 'OAI' => array ( |
|
92 | + 'rootElement' => 'OAI-PMH', |
|
93 | + 'namespaceURI' => 'http://www.openarchives.org/OAI/2.0/', |
|
94 | + ), |
|
95 | + 'METS' => array ( |
|
96 | + 'rootElement' => 'mets', |
|
97 | + 'namespaceURI' => 'http://www.loc.gov/METS/', |
|
98 | + ), |
|
99 | + 'XLINK' => array ( |
|
100 | + 'rootElement' => 'xlink', |
|
101 | + 'namespaceURI' => 'http://www.w3.org/1999/xlink', |
|
102 | + ) |
|
103 | + ); |
|
104 | + |
|
105 | + /** |
|
106 | + * Are the available metadata formats loaded? |
|
107 | + * @see $formats |
|
108 | + * |
|
109 | + * @var boolean |
|
110 | + * @access protected |
|
111 | + */ |
|
112 | + protected $formatsLoaded = FALSE; |
|
113 | + |
|
114 | + /** |
|
115 | + * Are there any fulltext files available? |
|
116 | + * |
|
117 | + * @var boolean |
|
118 | + * @access protected |
|
119 | + */ |
|
120 | + protected $hasFulltext = FALSE; |
|
121 | + |
|
122 | + /** |
|
123 | + * Last searched logical and physical page |
|
124 | + * |
|
125 | + * @var array |
|
126 | + * @access protected |
|
127 | + */ |
|
128 | + protected $lastSearchedPhysicalPage = array ('logicalPage' => NULL, 'physicalPage' => NULL); |
|
129 | + |
|
130 | + /** |
|
131 | + * This holds the documents location |
|
132 | + * |
|
133 | + * @var string |
|
134 | + * @access protected |
|
135 | + */ |
|
136 | + protected $location = ''; |
|
137 | + |
|
138 | + /** |
|
139 | + * This holds the logical units |
|
140 | + * |
|
141 | + * @var array |
|
142 | + * @access protected |
|
143 | + */ |
|
144 | + protected $logicalUnits = array (); |
|
145 | + |
|
146 | + /** |
|
147 | + * This holds the documents' parsed metadata array with their corresponding structMap//div's ID as array key |
|
148 | + * |
|
149 | + * @var array |
|
150 | + * @access protected |
|
151 | + */ |
|
152 | + protected $metadataArray = array (); |
|
153 | + |
|
154 | + /** |
|
155 | + * Is the metadata array loaded? |
|
156 | + * @see $metadataArray |
|
157 | + * |
|
158 | + * @var boolean |
|
159 | + * @access protected |
|
160 | + */ |
|
161 | + protected $metadataArrayLoaded = FALSE; |
|
162 | + |
|
163 | + /** |
|
164 | + * This holds the XML file's METS part as SimpleXMLElement object |
|
165 | + * |
|
166 | + * @var SimpleXMLElement |
|
167 | + * @access protected |
|
168 | + */ |
|
169 | + protected $mets; |
|
170 | + |
|
171 | + /** |
|
172 | + * The holds the total number of pages |
|
173 | + * |
|
174 | + * @var integer |
|
175 | + * @access protected |
|
176 | + */ |
|
177 | + protected $numPages = 0; |
|
178 | + |
|
179 | + /** |
|
180 | + * This holds the UID of the parent document or zero if not multi-volumed |
|
181 | + * |
|
182 | + * @var integer |
|
183 | + * @access protected |
|
184 | + */ |
|
185 | + protected $parentId = 0; |
|
186 | + |
|
187 | + /** |
|
188 | + * This holds the physical structure |
|
189 | + * |
|
190 | + * @var array |
|
191 | + * @access protected |
|
192 | + */ |
|
193 | + protected $physicalStructure = array (); |
|
194 | + |
|
195 | + /** |
|
196 | + * This holds the physical structure metadata |
|
197 | + * |
|
198 | + * @var array |
|
199 | + * @access protected |
|
200 | + */ |
|
201 | + protected $physicalStructureInfo = array (); |
|
202 | + |
|
203 | + /** |
|
204 | + * Is the physical structure loaded? |
|
205 | + * @see $physicalStructure |
|
206 | + * |
|
207 | + * @var boolean |
|
208 | + * @access protected |
|
209 | + */ |
|
210 | + protected $physicalStructureLoaded = FALSE; |
|
211 | + |
|
212 | + /** |
|
213 | + * This holds the PID of the document or zero if not in database |
|
214 | + * |
|
215 | + * @var integer |
|
216 | + * @access protected |
|
217 | + */ |
|
218 | + protected $pid = 0; |
|
219 | + |
|
220 | + /** |
|
221 | + * Is the document instantiated successfully? |
|
222 | + * |
|
223 | + * @var boolean |
|
224 | + * @access protected |
|
225 | + */ |
|
226 | + protected $ready = FALSE; |
|
227 | + |
|
228 | + /** |
|
229 | + * The METS file's record identifier |
|
230 | + * |
|
231 | + * @var string |
|
232 | + * @access protected |
|
233 | + */ |
|
234 | + protected $recordId; |
|
235 | + |
|
236 | + /** |
|
237 | + * This holds the singleton object of the document |
|
238 | + * |
|
239 | + * @var array (tx_dlf_document) |
|
240 | + * @access protected |
|
241 | + */ |
|
242 | + protected static $registry = array (); |
|
243 | + |
|
244 | + /** |
|
245 | + * This holds the UID of the root document or zero if not multi-volumed |
|
246 | + * |
|
247 | + * @var integer |
|
248 | + * @access protected |
|
249 | + */ |
|
250 | + protected $rootId = 0; |
|
251 | + |
|
252 | + /** |
|
253 | + * Is the root id loaded? |
|
254 | + * @see $rootId |
|
255 | + * |
|
256 | + * @var boolean |
|
257 | + * @access protected |
|
258 | + */ |
|
259 | + protected $rootIdLoaded = FALSE; |
|
260 | + |
|
261 | + /** |
|
262 | + * This holds the smLinks between logical and physical structMap |
|
263 | + * |
|
264 | + * @var array |
|
265 | + * @access protected |
|
266 | + */ |
|
267 | + protected $smLinks = array ('l2p' => array (), 'p2l' => array ()); |
|
268 | + |
|
269 | + /** |
|
270 | + * Are the smLinks loaded? |
|
271 | + * @see $smLinks |
|
272 | + * |
|
273 | + * @var boolean |
|
274 | + * @access protected |
|
275 | + */ |
|
276 | + protected $smLinksLoaded = FALSE; |
|
277 | + |
|
278 | + /** |
|
279 | + * This holds the logical structure |
|
280 | + * |
|
281 | + * @var array |
|
282 | + * @access protected |
|
283 | + */ |
|
284 | + protected $tableOfContents = array (); |
|
285 | + |
|
286 | + /** |
|
287 | + * Is the table of contents loaded? |
|
288 | + * @see $tableOfContents |
|
289 | + * |
|
290 | + * @var boolean |
|
291 | + * @access protected |
|
292 | + */ |
|
293 | + protected $tableOfContentsLoaded = FALSE; |
|
294 | + |
|
295 | + /** |
|
296 | + * This holds the document's thumbnail location. |
|
297 | + * |
|
298 | + * @var string |
|
299 | + * @access protected |
|
300 | + */ |
|
301 | + protected $thumbnail = ''; |
|
302 | + |
|
303 | + /** |
|
304 | + * Is the document's thumbnail location loaded? |
|
305 | + * @see $thumbnail |
|
306 | + * |
|
307 | + * @var boolean |
|
308 | + * @access protected |
|
309 | + */ |
|
310 | + protected $thumbnailLoaded = FALSE; |
|
311 | + |
|
312 | + /** |
|
313 | + * This holds the toplevel structure's @ID |
|
314 | + * |
|
315 | + * @var string |
|
316 | + * @access protected |
|
317 | + */ |
|
318 | + protected $toplevelId = ''; |
|
319 | + |
|
320 | + /** |
|
321 | + * This holds the UID or the URL of the document |
|
322 | + * |
|
323 | + * @var mixed |
|
324 | + * @access protected |
|
325 | + */ |
|
326 | + protected $uid = 0; |
|
327 | + |
|
328 | + /** |
|
329 | + * This holds the whole XML file as SimpleXMLElement object |
|
330 | + * |
|
331 | + * @var SimpleXMLElement |
|
332 | + * @access protected |
|
333 | + */ |
|
334 | + protected $xml; |
|
335 | + |
|
336 | + /** |
|
337 | + * This clears the static registry to prevent memory exhaustion |
|
338 | + * |
|
339 | + * @access public |
|
340 | + * |
|
341 | + * @return void |
|
342 | + */ |
|
343 | + public static function clearRegistry() { |
|
344 | + |
|
345 | + // Reset registry array. |
|
346 | + self::$registry = array (); |
|
347 | + |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * This gets the location of a file representing a physical page or track |
|
352 | + * |
|
353 | + * @access public |
|
354 | + * |
|
355 | + * @param string $id: The @ID attribute of the file node |
|
356 | + * |
|
357 | + * @return string The file's location as URL |
|
358 | + */ |
|
359 | + public function getFileLocation($id) { |
|
360 | 360 | |
361 | - if (!empty($id) && ($location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/mets:FLocat[@LOCTYPE="URL"]'))) { |
|
361 | + if (!empty($id) && ($location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/mets:FLocat[@LOCTYPE="URL"]'))) { |
|
362 | 362 | |
363 | - return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href; |
|
363 | + return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href; |
|
364 | 364 | |
365 | - } else { |
|
365 | + } else { |
|
366 | 366 | |
367 | - if (TYPO3_DLOG) { |
|
367 | + if (TYPO3_DLOG) { |
|
368 | 368 | |
369 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getFileLocation('.$id.')] There is no file node with @ID "'.$id.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
369 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getFileLocation('.$id.')] There is no file node with @ID "'.$id.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
370 | 370 | |
371 | - } |
|
371 | + } |
|
372 | 372 | |
373 | - return ''; |
|
373 | + return ''; |
|
374 | 374 | |
375 | - } |
|
375 | + } |
|
376 | 376 | |
377 | - } |
|
377 | + } |
|
378 | 378 | |
379 | - /** |
|
380 | - * This gets the MIME type of a file representing a physical page or track |
|
381 | - * |
|
382 | - * @access public |
|
383 | - * |
|
384 | - * @param string $id: The @ID attribute of the file node |
|
385 | - * |
|
386 | - * @return string The file's MIME type |
|
387 | - */ |
|
388 | - public function getFileMimeType($id) { |
|
379 | + /** |
|
380 | + * This gets the MIME type of a file representing a physical page or track |
|
381 | + * |
|
382 | + * @access public |
|
383 | + * |
|
384 | + * @param string $id: The @ID attribute of the file node |
|
385 | + * |
|
386 | + * @return string The file's MIME type |
|
387 | + */ |
|
388 | + public function getFileMimeType($id) { |
|
389 | 389 | |
390 | - if (!empty($id) && ($mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/@MIMETYPE'))) { |
|
390 | + if (!empty($id) && ($mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="'.$id.'"]/@MIMETYPE'))) { |
|
391 | 391 | |
392 | - return (string) $mimetype[0]; |
|
392 | + return (string) $mimetype[0]; |
|
393 | 393 | |
394 | - } else { |
|
394 | + } else { |
|
395 | 395 | |
396 | - if (TYPO3_DLOG) { |
|
396 | + if (TYPO3_DLOG) { |
|
397 | 397 | |
398 | - \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); |
|
398 | + \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); |
|
399 | 399 | |
400 | - } |
|
400 | + } |
|
401 | 401 | |
402 | - return ''; |
|
402 | + return ''; |
|
403 | 403 | |
404 | - } |
|
404 | + } |
|
405 | 405 | |
406 | - } |
|
406 | + } |
|
407 | 407 | |
408 | - /** |
|
409 | - * This is a singleton class, thus an instance must be created by this method |
|
410 | - * |
|
411 | - * @access public |
|
412 | - * |
|
413 | - * @param mixed $uid: The unique identifier of the document to parse or URL of XML file |
|
414 | - * @param integer $pid: If > 0, then only document with this PID gets loaded |
|
415 | - * @param boolean $forceReload: Force reloading the document instead of returning the cached instance |
|
416 | - * |
|
417 | - * @return &tx_dlf_document Instance of this class |
|
418 | - */ |
|
419 | - public static function &getInstance($uid, $pid = 0, $forceReload = FALSE) { |
|
408 | + /** |
|
409 | + * This is a singleton class, thus an instance must be created by this method |
|
410 | + * |
|
411 | + * @access public |
|
412 | + * |
|
413 | + * @param mixed $uid: The unique identifier of the document to parse or URL of XML file |
|
414 | + * @param integer $pid: If > 0, then only document with this PID gets loaded |
|
415 | + * @param boolean $forceReload: Force reloading the document instead of returning the cached instance |
|
416 | + * |
|
417 | + * @return &tx_dlf_document Instance of this class |
|
418 | + */ |
|
419 | + public static function &getInstance($uid, $pid = 0, $forceReload = FALSE) { |
|
420 | 420 | |
421 | - // Sanitize input. |
|
422 | - $pid = max(intval($pid), 0); |
|
421 | + // Sanitize input. |
|
422 | + $pid = max(intval($pid), 0); |
|
423 | 423 | |
424 | - if (!$forceReload) { |
|
424 | + if (!$forceReload) { |
|
425 | 425 | |
426 | - $regObj = md5($uid); |
|
426 | + $regObj = md5($uid); |
|
427 | 427 | |
428 | - if (is_object(self::$registry[$regObj]) && self::$registry[$regObj] instanceof self) { |
|
428 | + if (is_object(self::$registry[$regObj]) && self::$registry[$regObj] instanceof self) { |
|
429 | 429 | |
430 | - // Check if instance has given PID. |
|
431 | - if (!$pid || !self::$registry[$regObj]->pid || $pid == self::$registry[$regObj]->pid) { |
|
430 | + // Check if instance has given PID. |
|
431 | + if (!$pid || !self::$registry[$regObj]->pid || $pid == self::$registry[$regObj]->pid) { |
|
432 | 432 | |
433 | - // Return singleton instance if available. |
|
434 | - return self::$registry[$regObj]; |
|
433 | + // Return singleton instance if available. |
|
434 | + return self::$registry[$regObj]; |
|
435 | 435 | |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | - } else { |
|
438 | + } else { |
|
439 | 439 | |
440 | - // Check the user's session... |
|
441 | - $sessionData = tx_dlf_helper::loadFromSession(get_called_class()); |
|
440 | + // Check the user's session... |
|
441 | + $sessionData = tx_dlf_helper::loadFromSession(get_called_class()); |
|
442 | 442 | |
443 | - if (is_object($sessionData[$regObj]) && $sessionData[$regObj] instanceof self) { |
|
443 | + if (is_object($sessionData[$regObj]) && $sessionData[$regObj] instanceof self) { |
|
444 | 444 | |
445 | - // Check if instance has given PID. |
|
446 | - if (!$pid || !$sessionData[$regObj]->pid || $pid == $sessionData[$regObj]->pid) { |
|
445 | + // Check if instance has given PID. |
|
446 | + if (!$pid || !$sessionData[$regObj]->pid || $pid == $sessionData[$regObj]->pid) { |
|
447 | 447 | |
448 | - // ...and restore registry. |
|
449 | - self::$registry[$regObj] = $sessionData[$regObj]; |
|
448 | + // ...and restore registry. |
|
449 | + self::$registry[$regObj] = $sessionData[$regObj]; |
|
450 | 450 | |
451 | - return self::$registry[$regObj]; |
|
451 | + return self::$registry[$regObj]; |
|
452 | 452 | |
453 | - } |
|
453 | + } |
|
454 | 454 | |
455 | - } |
|
455 | + } |
|
456 | 456 | |
457 | - } |
|
457 | + } |
|
458 | 458 | |
459 | - } |
|
459 | + } |
|
460 | 460 | |
461 | - // Create new instance... |
|
462 | - $instance = new self($uid, $pid); |
|
461 | + // Create new instance... |
|
462 | + $instance = new self($uid, $pid); |
|
463 | 463 | |
464 | - // ...and save it to registry. |
|
465 | - if ($instance->ready) { |
|
464 | + // ...and save it to registry. |
|
465 | + if ($instance->ready) { |
|
466 | 466 | |
467 | - self::$registry[md5($instance->uid)] = $instance; |
|
467 | + self::$registry[md5($instance->uid)] = $instance; |
|
468 | 468 | |
469 | - if ($instance->uid != $instance->location) { |
|
469 | + if ($instance->uid != $instance->location) { |
|
470 | 470 | |
471 | - self::$registry[md5($instance->location)] = $instance; |
|
471 | + self::$registry[md5($instance->location)] = $instance; |
|
472 | 472 | |
473 | - } |
|
473 | + } |
|
474 | 474 | |
475 | - // Load extension configuration |
|
476 | - $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']); |
|
475 | + // Load extension configuration |
|
476 | + $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']); |
|
477 | 477 | |
478 | - // Save registry to session if caching is enabled. |
|
479 | - if (!empty($extConf['caching'])) { |
|
478 | + // Save registry to session if caching is enabled. |
|
479 | + if (!empty($extConf['caching'])) { |
|
480 | 480 | |
481 | - tx_dlf_helper::saveToSession(self::$registry, get_class($instance)); |
|
481 | + tx_dlf_helper::saveToSession(self::$registry, get_class($instance)); |
|
482 | 482 | |
483 | - } |
|
483 | + } |
|
484 | 484 | |
485 | - } |
|
485 | + } |
|
486 | 486 | |
487 | - // Return new instance. |
|
488 | - return $instance; |
|
487 | + // Return new instance. |
|
488 | + return $instance; |
|
489 | 489 | |
490 | - } |
|
490 | + } |
|
491 | 491 | |
492 | - /** |
|
493 | - * This gets details about a logical structure element |
|
494 | - * |
|
495 | - * @access public |
|
496 | - * |
|
497 | - * @param string $id: The @ID attribute of the logical structure node |
|
498 | - * @param boolean $recursive: Whether to include the child elements |
|
499 | - * |
|
500 | - * @return array Array of the element's id, label, type and physical page indexes/mptr link |
|
501 | - */ |
|
502 | - public function getLogicalStructure($id, $recursive = FALSE) { |
|
492 | + /** |
|
493 | + * This gets details about a logical structure element |
|
494 | + * |
|
495 | + * @access public |
|
496 | + * |
|
497 | + * @param string $id: The @ID attribute of the logical structure node |
|
498 | + * @param boolean $recursive: Whether to include the child elements |
|
499 | + * |
|
500 | + * @return array Array of the element's id, label, type and physical page indexes/mptr link |
|
501 | + */ |
|
502 | + public function getLogicalStructure($id, $recursive = FALSE) { |
|
503 | 503 | |
504 | - $details = array (); |
|
504 | + $details = array (); |
|
505 | 505 | |
506 | - // Is the requested logical unit already loaded? |
|
507 | - if (!$recursive && !empty($this->logicalUnits[$id])) { |
|
506 | + // Is the requested logical unit already loaded? |
|
507 | + if (!$recursive && !empty($this->logicalUnits[$id])) { |
|
508 | 508 | |
509 | - // Yes. Return it. |
|
510 | - return $this->logicalUnits[$id]; |
|
509 | + // Yes. Return it. |
|
510 | + return $this->logicalUnits[$id]; |
|
511 | 511 | |
512 | - } elseif (!empty($id)) { |
|
512 | + } elseif (!empty($id)) { |
|
513 | 513 | |
514 | - // Get specified logical unit. |
|
515 | - $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]'); |
|
514 | + // Get specified logical unit. |
|
515 | + $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]'); |
|
516 | 516 | |
517 | - } else { |
|
517 | + } else { |
|
518 | 518 | |
519 | - // Get all logical units at top level. |
|
520 | - $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]/mets:div'); |
|
519 | + // Get all logical units at top level. |
|
520 | + $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]/mets:div'); |
|
521 | 521 | |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | - if (!empty($divs)) { |
|
524 | + if (!empty($divs)) { |
|
525 | 525 | |
526 | - if (!$recursive) { |
|
526 | + if (!$recursive) { |
|
527 | 527 | |
528 | - // Get the details for the first xpath hit. |
|
529 | - $details = $this->getLogicalStructureInfo($divs[0]); |
|
528 | + // Get the details for the first xpath hit. |
|
529 | + $details = $this->getLogicalStructureInfo($divs[0]); |
|
530 | 530 | |
531 | - } else { |
|
531 | + } else { |
|
532 | 532 | |
533 | - // Walk the logical structure recursively and fill the whole table of contents. |
|
534 | - foreach ($divs as $div) { |
|
533 | + // Walk the logical structure recursively and fill the whole table of contents. |
|
534 | + foreach ($divs as $div) { |
|
535 | 535 | |
536 | - $this->tableOfContents[] = $this->getLogicalStructureInfo($div, TRUE); |
|
536 | + $this->tableOfContents[] = $this->getLogicalStructureInfo($div, TRUE); |
|
537 | 537 | |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | - } |
|
540 | + } |
|
541 | 541 | |
542 | - } |
|
542 | + } |
|
543 | 543 | |
544 | - return $details; |
|
544 | + return $details; |
|
545 | 545 | |
546 | - } |
|
546 | + } |
|
547 | 547 | |
548 | - /** |
|
549 | - * This gets details about a logical structure element |
|
550 | - * |
|
551 | - * @access protected |
|
552 | - * |
|
553 | - * @param SimpleXMLElement $structure: The logical structure node |
|
554 | - * @param boolean $recursive: Whether to include the child elements |
|
555 | - * |
|
556 | - * @return array Array of the element's id, label, type and physical page indexes/mptr link |
|
557 | - */ |
|
558 | - protected function getLogicalStructureInfo(SimpleXMLElement $structure, $recursive = FALSE) { |
|
548 | + /** |
|
549 | + * This gets details about a logical structure element |
|
550 | + * |
|
551 | + * @access protected |
|
552 | + * |
|
553 | + * @param SimpleXMLElement $structure: The logical structure node |
|
554 | + * @param boolean $recursive: Whether to include the child elements |
|
555 | + * |
|
556 | + * @return array Array of the element's id, label, type and physical page indexes/mptr link |
|
557 | + */ |
|
558 | + protected function getLogicalStructureInfo(SimpleXMLElement $structure, $recursive = FALSE) { |
|
559 | 559 | |
560 | - // Get attributes. |
|
561 | - foreach ($structure->attributes() as $attribute => $value) { |
|
560 | + // Get attributes. |
|
561 | + foreach ($structure->attributes() as $attribute => $value) { |
|
562 | 562 | |
563 | - $attributes[$attribute] = (string) $value; |
|
563 | + $attributes[$attribute] = (string) $value; |
|
564 | 564 | |
565 | - } |
|
565 | + } |
|
566 | 566 | |
567 | - // Load plugin configuration. |
|
568 | - $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
567 | + // Load plugin configuration. |
|
568 | + $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
569 | 569 | |
570 | - // Extract identity information. |
|
571 | - $details = array (); |
|
570 | + // Extract identity information. |
|
571 | + $details = array (); |
|
572 | 572 | |
573 | - $details['id'] = $attributes['ID']; |
|
573 | + $details['id'] = $attributes['ID']; |
|
574 | 574 | |
575 | - $details['dmdId'] = (isset($attributes['DMDID']) ? $attributes['DMDID'] : ''); |
|
575 | + $details['dmdId'] = (isset($attributes['DMDID']) ? $attributes['DMDID'] : ''); |
|
576 | 576 | |
577 | - $details['label'] = (isset($attributes['LABEL']) ? $attributes['LABEL'] : ''); |
|
577 | + $details['label'] = (isset($attributes['LABEL']) ? $attributes['LABEL'] : ''); |
|
578 | 578 | |
579 | - $details['orderlabel'] = (isset($attributes['ORDERLABEL']) ? $attributes['ORDERLABEL'] : ''); |
|
579 | + $details['orderlabel'] = (isset($attributes['ORDERLABEL']) ? $attributes['ORDERLABEL'] : ''); |
|
580 | 580 | |
581 | - $details['contentIds'] = (isset($attributes['CONTENTIDS']) ? $attributes['CONTENTIDS'] : ''); |
|
581 | + $details['contentIds'] = (isset($attributes['CONTENTIDS']) ? $attributes['CONTENTIDS'] : ''); |
|
582 | 582 | |
583 | - $details['volume'] = ''; |
|
583 | + $details['volume'] = ''; |
|
584 | 584 | |
585 | - // Set volume information only if no label is set and this is the toplevel structure element. |
|
586 | - if (empty($details['label']) && $details['id'] == $this->_getToplevelId()) { |
|
585 | + // Set volume information only if no label is set and this is the toplevel structure element. |
|
586 | + if (empty($details['label']) && $details['id'] == $this->_getToplevelId()) { |
|
587 | 587 | |
588 | - $metadata = $this->getMetadata($details['id']); |
|
588 | + $metadata = $this->getMetadata($details['id']); |
|
589 | 589 | |
590 | - if (!empty($metadata['volume'][0])) { |
|
590 | + if (!empty($metadata['volume'][0])) { |
|
591 | 591 | |
592 | - $details['volume'] = $metadata['volume'][0]; |
|
592 | + $details['volume'] = $metadata['volume'][0]; |
|
593 | 593 | |
594 | - } |
|
594 | + } |
|
595 | 595 | |
596 | - } |
|
596 | + } |
|
597 | 597 | |
598 | - $details['pagination'] = ''; |
|
598 | + $details['pagination'] = ''; |
|
599 | 599 | |
600 | - $details['type'] = $attributes['TYPE']; |
|
600 | + $details['type'] = $attributes['TYPE']; |
|
601 | 601 | |
602 | - $details['thumbnailId'] = ''; |
|
602 | + $details['thumbnailId'] = ''; |
|
603 | 603 | |
604 | - // Load smLinks. |
|
605 | - $this->_getSmLinks(); |
|
604 | + // Load smLinks. |
|
605 | + $this->_getSmLinks(); |
|
606 | 606 | |
607 | - // Load physical structure. |
|
608 | - $this->_getPhysicalStructure(); |
|
607 | + // Load physical structure. |
|
608 | + $this->_getPhysicalStructure(); |
|
609 | 609 | |
610 | - // Get the physical page or external file this structure element is pointing at. |
|
611 | - $details['points'] = ''; |
|
610 | + // Get the physical page or external file this structure element is pointing at. |
|
611 | + $details['points'] = ''; |
|
612 | 612 | |
613 | - // Is there a mptr node? |
|
614 | - if (count($structure->children('http://www.loc.gov/METS/')->mptr)) { |
|
613 | + // Is there a mptr node? |
|
614 | + if (count($structure->children('http://www.loc.gov/METS/')->mptr)) { |
|
615 | 615 | |
616 | - // Yes. Get the file reference. |
|
617 | - $details['points'] = (string) $structure->children('http://www.loc.gov/METS/')->mptr[0]->attributes('http://www.w3.org/1999/xlink')->href; |
|
616 | + // Yes. Get the file reference. |
|
617 | + $details['points'] = (string) $structure->children('http://www.loc.gov/METS/')->mptr[0]->attributes('http://www.w3.org/1999/xlink')->href; |
|
618 | 618 | |
619 | - // Are there any physical elements and is this logical unit linked to at least one of them? |
|
620 | - } elseif (!empty($this->physicalStructure) && array_key_exists($details['id'], $this->smLinks['l2p'])) { |
|
619 | + // Are there any physical elements and is this logical unit linked to at least one of them? |
|
620 | + } elseif (!empty($this->physicalStructure) && array_key_exists($details['id'], $this->smLinks['l2p'])) { |
|
621 | 621 | |
622 | - $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE)), 1); |
|
622 | + $details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, TRUE)), 1); |
|
623 | 623 | |
624 | - if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']])) { |
|
624 | + if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']])) { |
|
625 | 625 | |
626 | - $details['thumbnailId'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']]; |
|
626 | + $details['thumbnailId'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']]; |
|
627 | 627 | |
628 | - } |
|
628 | + } |
|
629 | 629 | |
630 | - // Get page/track number of the first page/track related to this structure element. |
|
631 | - $details['pagination'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['orderlabel']; |
|
630 | + // Get page/track number of the first page/track related to this structure element. |
|
631 | + $details['pagination'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['orderlabel']; |
|
632 | 632 | |
633 | - // Is this the toplevel structure element? |
|
634 | - } elseif ($details['id'] == $this->_getToplevelId()) { |
|
633 | + // Is this the toplevel structure element? |
|
634 | + } elseif ($details['id'] == $this->_getToplevelId()) { |
|
635 | 635 | |
636 | - // Yes. Point to itself. |
|
637 | - $details['points'] = 1; |
|
636 | + // Yes. Point to itself. |
|
637 | + $details['points'] = 1; |
|
638 | 638 | |
639 | - if (!empty($this->physicalStructure) && !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']])) { |
|
639 | + if (!empty($this->physicalStructure) && !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']])) { |
|
640 | 640 | |
641 | - $details['thumbnailId'] = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']]; |
|
641 | + $details['thumbnailId'] = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']]; |
|
642 | 642 | |
643 | - } |
|
643 | + } |
|
644 | 644 | |
645 | - } |
|
645 | + } |
|
646 | 646 | |
647 | - // Get the files this structure element is pointing at. |
|
648 | - $details['files'] = array (); |
|
647 | + // Get the files this structure element is pointing at. |
|
648 | + $details['files'] = array (); |
|
649 | 649 | |
650 | - $fileUse = $this->_getFileGrps(); |
|
650 | + $fileUse = $this->_getFileGrps(); |
|
651 | 651 | |
652 | - // Get the file representations from fileSec node. |
|
653 | - foreach ($structure->children('http://www.loc.gov/METS/')->fptr as $fptr) { |
|
652 | + // Get the file representations from fileSec node. |
|
653 | + foreach ($structure->children('http://www.loc.gov/METS/')->fptr as $fptr) { |
|
654 | 654 | |
655 | - // Check if file has valid @USE attribute. |
|
656 | - if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) { |
|
655 | + // Check if file has valid @USE attribute. |
|
656 | + if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) { |
|
657 | 657 | |
658 | - $details['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID; |
|
658 | + $details['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID; |
|
659 | 659 | |
660 | - } |
|
660 | + } |
|
661 | 661 | |
662 | - } |
|
662 | + } |
|
663 | 663 | |
664 | - // Keep for later usage. |
|
665 | - $this->logicalUnits[$details['id']] = $details; |
|
664 | + // Keep for later usage. |
|
665 | + $this->logicalUnits[$details['id']] = $details; |
|
666 | 666 | |
667 | - // Walk the structure recursively? And are there any children of the current element? |
|
668 | - if ($recursive && count($structure->children('http://www.loc.gov/METS/')->div)) { |
|
667 | + // Walk the structure recursively? And are there any children of the current element? |
|
668 | + if ($recursive && count($structure->children('http://www.loc.gov/METS/')->div)) { |
|
669 | 669 | |
670 | - $details['children'] = array (); |
|
670 | + $details['children'] = array (); |
|
671 | 671 | |
672 | - foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) { |
|
672 | + foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) { |
|
673 | 673 | |
674 | - // Repeat for all children. |
|
675 | - $details['children'][] = $this->getLogicalStructureInfo($child, TRUE); |
|
674 | + // Repeat for all children. |
|
675 | + $details['children'][] = $this->getLogicalStructureInfo($child, TRUE); |
|
676 | 676 | |
677 | - } |
|
677 | + } |
|
678 | 678 | |
679 | - } |
|
679 | + } |
|
680 | 680 | |
681 | - return $details; |
|
681 | + return $details; |
|
682 | 682 | |
683 | - } |
|
683 | + } |
|
684 | 684 | |
685 | - /** |
|
686 | - * This extracts all the metadata for a logical structure node |
|
687 | - * |
|
688 | - * @access public |
|
689 | - * |
|
690 | - * @param string $id: The @ID attribute of the logical structure node |
|
691 | - * @param integer $cPid: The PID for the metadata definitions |
|
692 | - * (defaults to $this->cPid or $this->pid) |
|
693 | - * |
|
694 | - * @return array The logical structure node's parsed metadata array |
|
695 | - */ |
|
696 | - public function getMetadata($id, $cPid = 0) { |
|
685 | + /** |
|
686 | + * This extracts all the metadata for a logical structure node |
|
687 | + * |
|
688 | + * @access public |
|
689 | + * |
|
690 | + * @param string $id: The @ID attribute of the logical structure node |
|
691 | + * @param integer $cPid: The PID for the metadata definitions |
|
692 | + * (defaults to $this->cPid or $this->pid) |
|
693 | + * |
|
694 | + * @return array The logical structure node's parsed metadata array |
|
695 | + */ |
|
696 | + public function getMetadata($id, $cPid = 0) { |
|
697 | 697 | |
698 | - // Save parameter for logging purposes. |
|
699 | - $_cPid = $cPid; |
|
698 | + // Save parameter for logging purposes. |
|
699 | + $_cPid = $cPid; |
|
700 | 700 | |
701 | - // Make sure $cPid is a non-negative integer. |
|
702 | - $cPid = max(intval($cPid), 0); |
|
701 | + // Make sure $cPid is a non-negative integer. |
|
702 | + $cPid = max(intval($cPid), 0); |
|
703 | 703 | |
704 | - // If $cPid is not given, try to get it elsewhere. |
|
705 | - if (!$cPid && ($this->cPid || $this->pid)) { |
|
704 | + // If $cPid is not given, try to get it elsewhere. |
|
705 | + if (!$cPid && ($this->cPid || $this->pid)) { |
|
706 | 706 | |
707 | - // Retain current PID. |
|
708 | - $cPid = ($this->cPid ? $this->cPid : $this->pid); |
|
707 | + // Retain current PID. |
|
708 | + $cPid = ($this->cPid ? $this->cPid : $this->pid); |
|
709 | 709 | |
710 | - } elseif (!$cPid) { |
|
710 | + } elseif (!$cPid) { |
|
711 | 711 | |
712 | - if (TYPO3_DLOG) { |
|
712 | + if (TYPO3_DLOG) { |
|
713 | 713 | |
714 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
714 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadata('.$id.', '.$_cPid.')] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
715 | 715 | |
716 | - } |
|
716 | + } |
|
717 | 717 | |
718 | - return array (); |
|
718 | + return array (); |
|
719 | 719 | |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | - // Get metadata from parsed metadata array if available. |
|
723 | - if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) { |
|
722 | + // Get metadata from parsed metadata array if available. |
|
723 | + if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) { |
|
724 | 724 | |
725 | - return $this->metadataArray[$id]; |
|
725 | + return $this->metadataArray[$id]; |
|
726 | 726 | |
727 | - } |
|
727 | + } |
|
728 | 728 | |
729 | - // Initialize metadata array with empty values. |
|
730 | - $metadata = array ( |
|
731 | - 'title' => array (), |
|
732 | - 'title_sorting' => array (), |
|
733 | - 'author' => array (), |
|
734 | - 'place' => array (), |
|
735 | - 'year' => array (), |
|
736 | - 'prod_id' => array (), |
|
737 | - 'record_id' => array (), |
|
738 | - 'opac_id' => array (), |
|
739 | - 'union_id' => array (), |
|
740 | - 'urn' => array (), |
|
741 | - 'purl' => array (), |
|
742 | - 'type' => array (), |
|
743 | - 'volume' => array (), |
|
744 | - 'volume_sorting' => array (), |
|
745 | - 'collection' => array (), |
|
746 | - 'owner' => array (), |
|
747 | - ); |
|
729 | + // Initialize metadata array with empty values. |
|
730 | + $metadata = array ( |
|
731 | + 'title' => array (), |
|
732 | + 'title_sorting' => array (), |
|
733 | + 'author' => array (), |
|
734 | + 'place' => array (), |
|
735 | + 'year' => array (), |
|
736 | + 'prod_id' => array (), |
|
737 | + 'record_id' => array (), |
|
738 | + 'opac_id' => array (), |
|
739 | + 'union_id' => array (), |
|
740 | + 'urn' => array (), |
|
741 | + 'purl' => array (), |
|
742 | + 'type' => array (), |
|
743 | + 'volume' => array (), |
|
744 | + 'volume_sorting' => array (), |
|
745 | + 'collection' => array (), |
|
746 | + 'owner' => array (), |
|
747 | + ); |
|
748 | 748 | |
749 | - // Get the logical structure node's DMDID. |
|
750 | - if (!empty($this->logicalUnits[$id])) { |
|
749 | + // Get the logical structure node's DMDID. |
|
750 | + if (!empty($this->logicalUnits[$id])) { |
|
751 | 751 | |
752 | - $dmdId = $this->logicalUnits[$id]['dmdId']; |
|
752 | + $dmdId = $this->logicalUnits[$id]['dmdId']; |
|
753 | 753 | |
754 | - } else { |
|
754 | + } else { |
|
755 | 755 | |
756 | - $dmdId = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@DMDID'); |
|
756 | + $dmdId = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@DMDID'); |
|
757 | 757 | |
758 | - $dmdId = (string) $dmdId[0]; |
|
758 | + $dmdId = (string) $dmdId[0]; |
|
759 | 759 | |
760 | - } |
|
760 | + } |
|
761 | 761 | |
762 | - if (!empty($dmdId)) { |
|
762 | + if (!empty($dmdId)) { |
|
763 | 763 | |
764 | - // Load available metadata formats and dmdSecs. |
|
765 | - $this->loadFormats(); |
|
764 | + // Load available metadata formats and dmdSecs. |
|
765 | + $this->loadFormats(); |
|
766 | 766 | |
767 | - $this->_getDmdSec(); |
|
767 | + $this->_getDmdSec(); |
|
768 | 768 | |
769 | - // Is this metadata format supported? |
|
770 | - if (!empty($this->formats[$this->dmdSec[$dmdId]['type']])) { |
|
769 | + // Is this metadata format supported? |
|
770 | + if (!empty($this->formats[$this->dmdSec[$dmdId]['type']])) { |
|
771 | 771 | |
772 | - if (!empty($this->formats[$this->dmdSec[$dmdId]['type']]['class'])) { |
|
772 | + if (!empty($this->formats[$this->dmdSec[$dmdId]['type']]['class'])) { |
|
773 | 773 | |
774 | - $class = $this->formats[$this->dmdSec[$dmdId]['type']]['class']; |
|
774 | + $class = $this->formats[$this->dmdSec[$dmdId]['type']]['class']; |
|
775 | 775 | |
776 | - // Get the metadata from class. |
|
777 | - if (class_exists($class) && ($obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class)) instanceof tx_dlf_format) { |
|
776 | + // Get the metadata from class. |
|
777 | + if (class_exists($class) && ($obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class)) instanceof tx_dlf_format) { |
|
778 | 778 | |
779 | - $obj->extractMetadata($this->dmdSec[$dmdId]['xml'], $metadata); |
|
779 | + $obj->extractMetadata($this->dmdSec[$dmdId]['xml'], $metadata); |
|
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.')] Invalid class/method "'.$class.'->extractMetadata()" for metadata format "'.$this->dmdSec[$dmdId]['type'].'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
785 | + \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); |
|
786 | 786 | |
787 | - } |
|
787 | + } |
|
788 | 788 | |
789 | - } |
|
789 | + } |
|
790 | 790 | |
791 | - } |
|
791 | + } |
|
792 | 792 | |
793 | - } else { |
|
793 | + } else { |
|
794 | 794 | |
795 | - if (TYPO3_DLOG) { |
|
795 | + if (TYPO3_DLOG) { |
|
796 | 796 | |
797 | - \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); |
|
797 | + \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); |
|
798 | 798 | |
799 | - } |
|
799 | + } |
|
800 | 800 | |
801 | - return array (); |
|
801 | + return array (); |
|
802 | 802 | |
803 | - } |
|
803 | + } |
|
804 | 804 | |
805 | - // Get the structure's type. |
|
806 | - if (!empty($this->logicalUnits[$id])) { |
|
805 | + // Get the structure's type. |
|
806 | + if (!empty($this->logicalUnits[$id])) { |
|
807 | 807 | |
808 | - $metadata['type'] = array ($this->logicalUnits[$id]['type']); |
|
808 | + $metadata['type'] = array ($this->logicalUnits[$id]['type']); |
|
809 | 809 | |
810 | - } else { |
|
810 | + } else { |
|
811 | 811 | |
812 | - $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE'); |
|
812 | + $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE'); |
|
813 | 813 | |
814 | - $metadata['type'] = array ((string) $struct[0]); |
|
814 | + $metadata['type'] = array ((string) $struct[0]); |
|
815 | 815 | |
816 | - } |
|
816 | + } |
|
817 | 817 | |
818 | - // Get the additional metadata from database. |
|
819 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
820 | - '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', |
|
821 | - 'tx_dlf_metadata,tx_dlf_metadataformat,tx_dlf_formats', |
|
822 | - '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'), |
|
823 | - '', |
|
824 | - '', |
|
825 | - '' |
|
826 | - ); |
|
818 | + // Get the additional metadata from database. |
|
819 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
820 | + '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', |
|
821 | + 'tx_dlf_metadata,tx_dlf_metadataformat,tx_dlf_formats', |
|
822 | + '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'), |
|
823 | + '', |
|
824 | + '', |
|
825 | + '' |
|
826 | + ); |
|
827 | 827 | |
828 | - // We need a DOMDocument here, because SimpleXML doesn't support XPath functions properly. |
|
829 | - $domNode = dom_import_simplexml($this->dmdSec[$dmdId]['xml']); |
|
828 | + // We need a DOMDocument here, because SimpleXML doesn't support XPath functions properly. |
|
829 | + $domNode = dom_import_simplexml($this->dmdSec[$dmdId]['xml']); |
|
830 | 830 | |
831 | - $domXPath = new DOMXPath($domNode->ownerDocument); |
|
831 | + $domXPath = new DOMXPath($domNode->ownerDocument); |
|
832 | 832 | |
833 | - $this->registerNamespaces($domXPath); |
|
833 | + $this->registerNamespaces($domXPath); |
|
834 | 834 | |
835 | - // OK, now make the XPath queries. |
|
836 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
835 | + // OK, now make the XPath queries. |
|
836 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
837 | 837 | |
838 | - // Set metadata field's value(s). |
|
839 | - if ($resArray['format'] > 0 && !empty($resArray['xpath']) && ($values = $domXPath->evaluate($resArray['xpath'], $domNode))) { |
|
838 | + // Set metadata field's value(s). |
|
839 | + if ($resArray['format'] > 0 && !empty($resArray['xpath']) && ($values = $domXPath->evaluate($resArray['xpath'], $domNode))) { |
|
840 | 840 | |
841 | - if ($values instanceof DOMNodeList && $values->length > 0) { |
|
841 | + if ($values instanceof DOMNodeList && $values->length > 0) { |
|
842 | 842 | |
843 | - $metadata[$resArray['index_name']] = array (); |
|
843 | + $metadata[$resArray['index_name']] = array (); |
|
844 | 844 | |
845 | - foreach ($values as $value) { |
|
845 | + foreach ($values as $value) { |
|
846 | 846 | |
847 | - $metadata[$resArray['index_name']][] = trim((string) $value->nodeValue); |
|
847 | + $metadata[$resArray['index_name']][] = trim((string) $value->nodeValue); |
|
848 | 848 | |
849 | - } |
|
849 | + } |
|
850 | 850 | |
851 | - } elseif (!($values instanceof DOMNodeList)) { |
|
851 | + } elseif (!($values instanceof DOMNodeList)) { |
|
852 | 852 | |
853 | - $metadata[$resArray['index_name']] = array (trim((string) $values)); |
|
853 | + $metadata[$resArray['index_name']] = array (trim((string) $values)); |
|
854 | 854 | |
855 | - } |
|
855 | + } |
|
856 | 856 | |
857 | - } |
|
857 | + } |
|
858 | 858 | |
859 | - // Set default value if applicable. |
|
860 | - if (empty($metadata[$resArray['index_name']][0])) { |
|
859 | + // Set default value if applicable. |
|
860 | + if (empty($metadata[$resArray['index_name']][0])) { |
|
861 | 861 | |
862 | - $metadata[$resArray['index_name']] = array ($resArray['default_value']); |
|
862 | + $metadata[$resArray['index_name']] = array ($resArray['default_value']); |
|
863 | 863 | |
864 | - } |
|
864 | + } |
|
865 | 865 | |
866 | - // Set sorting value if applicable. |
|
867 | - if (!empty($metadata[$resArray['index_name']]) && $resArray['is_sortable']) { |
|
866 | + // Set sorting value if applicable. |
|
867 | + if (!empty($metadata[$resArray['index_name']]) && $resArray['is_sortable']) { |
|
868 | 868 | |
869 | - if ($resArray['format'] > 0 && !empty($resArray['xpath_sorting']) && ($values = $domXPath->evaluate($resArray['xpath_sorting'], $domNode))) { |
|
869 | + if ($resArray['format'] > 0 && !empty($resArray['xpath_sorting']) && ($values = $domXPath->evaluate($resArray['xpath_sorting'], $domNode))) { |
|
870 | 870 | |
871 | - if ($values instanceof DOMNodeList && $values->length > 0) { |
|
871 | + if ($values instanceof DOMNodeList && $values->length > 0) { |
|
872 | 872 | |
873 | - $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values->item(0)->nodeValue); |
|
873 | + $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values->item(0)->nodeValue); |
|
874 | 874 | |
875 | - } elseif (!($values instanceof DOMNodeList)) { |
|
875 | + } elseif (!($values instanceof DOMNodeList)) { |
|
876 | 876 | |
877 | - $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values); |
|
877 | + $metadata[$resArray['index_name'].'_sorting'][0] = trim((string) $values); |
|
878 | 878 | |
879 | - } |
|
879 | + } |
|
880 | 880 | |
881 | - } |
|
881 | + } |
|
882 | 882 | |
883 | - if (empty($metadata[$resArray['index_name'].'_sorting'][0])) { |
|
883 | + if (empty($metadata[$resArray['index_name'].'_sorting'][0])) { |
|
884 | 884 | |
885 | - $metadata[$resArray['index_name'].'_sorting'][0] = $metadata[$resArray['index_name']][0]; |
|
885 | + $metadata[$resArray['index_name'].'_sorting'][0] = $metadata[$resArray['index_name']][0]; |
|
886 | 886 | |
887 | - } |
|
887 | + } |
|
888 | 888 | |
889 | - } |
|
889 | + } |
|
890 | 890 | |
891 | - } |
|
891 | + } |
|
892 | 892 | |
893 | - // Set title to empty string if not present. |
|
894 | - if (empty($metadata['title'][0])) { |
|
893 | + // Set title to empty string if not present. |
|
894 | + if (empty($metadata['title'][0])) { |
|
895 | 895 | |
896 | - $metadata['title'][0] = ''; |
|
896 | + $metadata['title'][0] = ''; |
|
897 | 897 | |
898 | - $metadata['title_sorting'][0] = ''; |
|
898 | + $metadata['title_sorting'][0] = ''; |
|
899 | 899 | |
900 | - } |
|
900 | + } |
|
901 | 901 | |
902 | - } else { |
|
902 | + } else { |
|
903 | 903 | |
904 | - // There is no dmdSec for this structure node. |
|
905 | - return array (); |
|
904 | + // There is no dmdSec for this structure node. |
|
905 | + return array (); |
|
906 | 906 | |
907 | - } |
|
907 | + } |
|
908 | 908 | |
909 | - return $metadata; |
|
909 | + return $metadata; |
|
910 | 910 | |
911 | - } |
|
911 | + } |
|
912 | 912 | |
913 | - /** |
|
914 | - * This returns the first corresponding physical page number of a given logical page label |
|
915 | - * |
|
916 | - * @access public |
|
917 | - * |
|
918 | - * @param string $logicalPage: The label (or a part of the label) of the logical page |
|
919 | - * |
|
920 | - * @return integer The physical page number |
|
921 | - */ |
|
922 | - public function getPhysicalPage($logicalPage) { |
|
913 | + /** |
|
914 | + * This returns the first corresponding physical page number of a given logical page label |
|
915 | + * |
|
916 | + * @access public |
|
917 | + * |
|
918 | + * @param string $logicalPage: The label (or a part of the label) of the logical page |
|
919 | + * |
|
920 | + * @return integer The physical page number |
|
921 | + */ |
|
922 | + public function getPhysicalPage($logicalPage) { |
|
923 | 923 | |
924 | - if (!empty($this->lastSearchedPhysicalPage['logicalPage']) && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage) { |
|
924 | + if (!empty($this->lastSearchedPhysicalPage['logicalPage']) && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage) { |
|
925 | 925 | |
926 | - return $this->lastSearchedPhysicalPage['physicalPage']; |
|
926 | + return $this->lastSearchedPhysicalPage['physicalPage']; |
|
927 | 927 | |
928 | - } else { |
|
928 | + } else { |
|
929 | 929 | |
930 | - $physicalPage = 0; |
|
930 | + $physicalPage = 0; |
|
931 | 931 | |
932 | - foreach ($this->physicalStructureInfo as $page) { |
|
932 | + foreach ($this->physicalStructureInfo as $page) { |
|
933 | 933 | |
934 | - if (strpos($page['orderlabel'], $logicalPage) !== FALSE) { |
|
934 | + if (strpos($page['orderlabel'], $logicalPage) !== FALSE) { |
|
935 | 935 | |
936 | - $this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage; |
|
937 | - $this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage; |
|
936 | + $this->lastSearchedPhysicalPage['logicalPage'] = $logicalPage; |
|
937 | + $this->lastSearchedPhysicalPage['physicalPage'] = $physicalPage; |
|
938 | 938 | |
939 | - return $physicalPage; |
|
939 | + return $physicalPage; |
|
940 | 940 | |
941 | - } |
|
941 | + } |
|
942 | 942 | |
943 | - $physicalPage++; |
|
943 | + $physicalPage++; |
|
944 | 944 | |
945 | - } |
|
945 | + } |
|
946 | 946 | |
947 | - } |
|
947 | + } |
|
948 | 948 | |
949 | - return 1; |
|
949 | + return 1; |
|
950 | 950 | |
951 | - } |
|
951 | + } |
|
952 | 952 | |
953 | - /** |
|
954 | - * This determines a title for the given document |
|
955 | - * |
|
956 | - * @access public |
|
957 | - * |
|
958 | - * @param integer $uid: The UID of the document |
|
959 | - * @param boolean $recursive: Search superior documents for a title, too? |
|
960 | - * |
|
961 | - * @return string The title of the document itself or a parent document |
|
962 | - */ |
|
963 | - public static function getTitle($uid, $recursive = FALSE) { |
|
953 | + /** |
|
954 | + * This determines a title for the given document |
|
955 | + * |
|
956 | + * @access public |
|
957 | + * |
|
958 | + * @param integer $uid: The UID of the document |
|
959 | + * @param boolean $recursive: Search superior documents for a title, too? |
|
960 | + * |
|
961 | + * @return string The title of the document itself or a parent document |
|
962 | + */ |
|
963 | + public static function getTitle($uid, $recursive = FALSE) { |
|
964 | 964 | |
965 | - // Save parameter for logging purposes. |
|
966 | - $_uid = $uid; |
|
965 | + // Save parameter for logging purposes. |
|
966 | + $_uid = $uid; |
|
967 | 967 | |
968 | - $title = ''; |
|
968 | + $title = ''; |
|
969 | 969 | |
970 | - // Sanitize input. |
|
971 | - $uid = max(intval($uid), 0); |
|
970 | + // Sanitize input. |
|
971 | + $uid = max(intval($uid), 0); |
|
972 | 972 | |
973 | - if ($uid) { |
|
973 | + if ($uid) { |
|
974 | 974 | |
975 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
976 | - 'tx_dlf_documents.title,tx_dlf_documents.partof', |
|
977 | - 'tx_dlf_documents', |
|
978 | - 'tx_dlf_documents.uid='.$uid.tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
979 | - '', |
|
980 | - '', |
|
981 | - '1' |
|
982 | - ); |
|
975 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
976 | + 'tx_dlf_documents.title,tx_dlf_documents.partof', |
|
977 | + 'tx_dlf_documents', |
|
978 | + 'tx_dlf_documents.uid='.$uid.tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
979 | + '', |
|
980 | + '', |
|
981 | + '1' |
|
982 | + ); |
|
983 | 983 | |
984 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
984 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
985 | 985 | |
986 | - // Get title information. |
|
987 | - list ($title, $partof) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
986 | + // Get title information. |
|
987 | + list ($title, $partof) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
988 | 988 | |
989 | - // Search parent documents recursively for a title? |
|
990 | - if ($recursive && empty($title) && intval($partof) && $partof != $uid) { |
|
989 | + // Search parent documents recursively for a title? |
|
990 | + if ($recursive && empty($title) && intval($partof) && $partof != $uid) { |
|
991 | 991 | |
992 | - $title = self::getTitle($partof, TRUE); |
|
992 | + $title = self::getTitle($partof, TRUE); |
|
993 | 993 | |
994 | - } |
|
994 | + } |
|
995 | 995 | |
996 | - } else { |
|
996 | + } else { |
|
997 | 997 | |
998 | - if (TYPO3_DLOG) { |
|
998 | + if (TYPO3_DLOG) { |
|
999 | 999 | |
1000 | - \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); |
|
1000 | + \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); |
|
1001 | 1001 | |
1002 | - } |
|
1002 | + } |
|
1003 | 1003 | |
1004 | - } |
|
1004 | + } |
|
1005 | 1005 | |
1006 | - } else { |
|
1006 | + } else { |
|
1007 | 1007 | |
1008 | - if (TYPO3_DLOG) { |
|
1008 | + if (TYPO3_DLOG) { |
|
1009 | 1009 | |
1010 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getTitle('.$_uid.', ['.($recursive ? 'TRUE' : 'FALSE').'])] Invalid UID "'.$uid.'" for document', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1010 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getTitle('.$_uid.', ['.($recursive ? 'TRUE' : 'FALSE').'])] Invalid UID "'.$uid.'" for document', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1011 | 1011 | |
1012 | - } |
|
1012 | + } |
|
1013 | 1013 | |
1014 | - } |
|
1014 | + } |
|
1015 | 1015 | |
1016 | - return $title; |
|
1016 | + return $title; |
|
1017 | 1017 | |
1018 | - } |
|
1018 | + } |
|
1019 | 1019 | |
1020 | - /** |
|
1021 | - * This extracts all the metadata for the toplevel logical structure node |
|
1022 | - * |
|
1023 | - * @access public |
|
1024 | - * |
|
1025 | - * @param integer $cPid: The PID for the metadata definitions |
|
1026 | - * |
|
1027 | - * @return array The logical structure node's parsed metadata array |
|
1028 | - */ |
|
1029 | - public function getTitledata($cPid = 0) { |
|
1020 | + /** |
|
1021 | + * This extracts all the metadata for the toplevel logical structure node |
|
1022 | + * |
|
1023 | + * @access public |
|
1024 | + * |
|
1025 | + * @param integer $cPid: The PID for the metadata definitions |
|
1026 | + * |
|
1027 | + * @return array The logical structure node's parsed metadata array |
|
1028 | + */ |
|
1029 | + public function getTitledata($cPid = 0) { |
|
1030 | 1030 | |
1031 | - $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
|
1031 | + $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
|
1032 | 1032 | |
1033 | - // Set record identifier for METS file if not present. |
|
1034 | - if (is_array($titledata) && array_key_exists('record_id', $titledata)) { |
|
1033 | + // Set record identifier for METS file if not present. |
|
1034 | + if (is_array($titledata) && array_key_exists('record_id', $titledata)) { |
|
1035 | 1035 | |
1036 | - if (!empty($this->recordId) && !in_array($this->recordId, $titledata['record_id'])) { |
|
1036 | + if (!empty($this->recordId) && !in_array($this->recordId, $titledata['record_id'])) { |
|
1037 | 1037 | |
1038 | - array_unshift($titledata['record_id'], $this->recordId); |
|
1038 | + array_unshift($titledata['record_id'], $this->recordId); |
|
1039 | 1039 | |
1040 | - } |
|
1040 | + } |
|
1041 | 1041 | |
1042 | - }; |
|
1042 | + }; |
|
1043 | 1043 | |
1044 | - return $titledata; |
|
1044 | + return $titledata; |
|
1045 | 1045 | |
1046 | - } |
|
1046 | + } |
|
1047 | 1047 | |
1048 | - /** |
|
1049 | - * This sets some basic class properties |
|
1050 | - * |
|
1051 | - * @access protected |
|
1052 | - * |
|
1053 | - * @return void |
|
1054 | - */ |
|
1055 | - protected function init() { |
|
1048 | + /** |
|
1049 | + * This sets some basic class properties |
|
1050 | + * |
|
1051 | + * @access protected |
|
1052 | + * |
|
1053 | + * @return void |
|
1054 | + */ |
|
1055 | + protected function init() { |
|
1056 | 1056 | |
1057 | - // Get METS node from XML file. |
|
1058 | - $this->registerNamespaces($this->xml); |
|
1057 | + // Get METS node from XML file. |
|
1058 | + $this->registerNamespaces($this->xml); |
|
1059 | 1059 | |
1060 | - $mets = $this->xml->xpath('//mets:mets'); |
|
1060 | + $mets = $this->xml->xpath('//mets:mets'); |
|
1061 | 1061 | |
1062 | - if ($mets) { |
|
1062 | + if ($mets) { |
|
1063 | 1063 | |
1064 | - $this->mets = $mets[0]; |
|
1064 | + $this->mets = $mets[0]; |
|
1065 | 1065 | |
1066 | - // Register namespaces. |
|
1067 | - $this->registerNamespaces($this->mets); |
|
1066 | + // Register namespaces. |
|
1067 | + $this->registerNamespaces($this->mets); |
|
1068 | 1068 | |
1069 | - } else { |
|
1069 | + } else { |
|
1070 | 1070 | |
1071 | - if (TYPO3_DLOG) { |
|
1071 | + if (TYPO3_DLOG) { |
|
1072 | 1072 | |
1073 | - \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); |
|
1073 | + \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); |
|
1074 | 1074 | |
1075 | - } |
|
1075 | + } |
|
1076 | 1076 | |
1077 | - } |
|
1077 | + } |
|
1078 | 1078 | |
1079 | - } |
|
1079 | + } |
|
1080 | 1080 | |
1081 | - /** |
|
1082 | - * Load XML file from URL |
|
1083 | - * |
|
1084 | - * @access protected |
|
1085 | - * |
|
1086 | - * @param string $location: The URL of the file to load |
|
1087 | - * |
|
1088 | - * @return boolean TRUE on success or FALSE on failure |
|
1089 | - */ |
|
1090 | - protected function load($location) { |
|
1081 | + /** |
|
1082 | + * Load XML file from URL |
|
1083 | + * |
|
1084 | + * @access protected |
|
1085 | + * |
|
1086 | + * @param string $location: The URL of the file to load |
|
1087 | + * |
|
1088 | + * @return boolean TRUE on success or FALSE on failure |
|
1089 | + */ |
|
1090 | + protected function load($location) { |
|
1091 | 1091 | |
1092 | - // Load XML file. |
|
1093 | - if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location)) { |
|
1092 | + // Load XML file. |
|
1093 | + if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location)) { |
|
1094 | 1094 | |
1095 | - // Load extension configuration |
|
1096 | - $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']); |
|
1095 | + // Load extension configuration |
|
1096 | + $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']); |
|
1097 | 1097 | |
1098 | - // Set user-agent to identify self when fetching XML data. |
|
1099 | - if (!empty($extConf['useragent'])) { |
|
1098 | + // Set user-agent to identify self when fetching XML data. |
|
1099 | + if (!empty($extConf['useragent'])) { |
|
1100 | 1100 | |
1101 | - @ini_set('user_agent', $extConf['useragent']); |
|
1101 | + @ini_set('user_agent', $extConf['useragent']); |
|
1102 | 1102 | |
1103 | - } |
|
1103 | + } |
|
1104 | 1104 | |
1105 | - // Turn off libxml's error logging. |
|
1106 | - $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
1105 | + // Turn off libxml's error logging. |
|
1106 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
1107 | 1107 | |
1108 | - // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
|
1109 | - $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
1108 | + // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept |
|
1109 | + $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); |
|
1110 | 1110 | |
1111 | - // Load XML from file. |
|
1112 | - $xml = simplexml_load_string(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($location)); |
|
1111 | + // Load XML from file. |
|
1112 | + $xml = simplexml_load_string(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($location)); |
|
1113 | 1113 | |
1114 | - // reset entity loader setting |
|
1115 | - libxml_disable_entity_loader($previousValueOfEntityLoader); |
|
1114 | + // reset entity loader setting |
|
1115 | + libxml_disable_entity_loader($previousValueOfEntityLoader); |
|
1116 | 1116 | |
1117 | - // Reset libxml's error logging. |
|
1118 | - libxml_use_internal_errors($libxmlErrors); |
|
1117 | + // Reset libxml's error logging. |
|
1118 | + libxml_use_internal_errors($libxmlErrors); |
|
1119 | 1119 | |
1120 | - // Set some basic properties. |
|
1121 | - if ($xml !== FALSE) { |
|
1120 | + // Set some basic properties. |
|
1121 | + if ($xml !== FALSE) { |
|
1122 | 1122 | |
1123 | - $this->xml = $xml; |
|
1123 | + $this->xml = $xml; |
|
1124 | 1124 | |
1125 | - return TRUE; |
|
1125 | + return TRUE; |
|
1126 | 1126 | |
1127 | - } else { |
|
1127 | + } else { |
|
1128 | 1128 | |
1129 | - if (TYPO3_DLOG) { |
|
1129 | + if (TYPO3_DLOG) { |
|
1130 | 1130 | |
1131 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Could not load XML file from "'.$location.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1131 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Could not load XML file from "'.$location.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1132 | 1132 | |
1133 | - } |
|
1133 | + } |
|
1134 | 1134 | |
1135 | - } |
|
1135 | + } |
|
1136 | 1136 | |
1137 | - } else { |
|
1137 | + } else { |
|
1138 | 1138 | |
1139 | - if (TYPO3_DLOG) { |
|
1139 | + if (TYPO3_DLOG) { |
|
1140 | 1140 | |
1141 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Invalid file location "'.$location.'" for document loading', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1141 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->load('.$location.')] Invalid file location "'.$location.'" for document loading', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1142 | 1142 | |
1143 | - } |
|
1143 | + } |
|
1144 | 1144 | |
1145 | - } |
|
1145 | + } |
|
1146 | 1146 | |
1147 | - return FALSE; |
|
1147 | + return FALSE; |
|
1148 | 1148 | |
1149 | - } |
|
1149 | + } |
|
1150 | 1150 | |
1151 | - /** |
|
1152 | - * Register all available data formats |
|
1153 | - * |
|
1154 | - * @access protected |
|
1155 | - * |
|
1156 | - * @return void |
|
1157 | - */ |
|
1158 | - protected function loadFormats() { |
|
1151 | + /** |
|
1152 | + * Register all available data formats |
|
1153 | + * |
|
1154 | + * @access protected |
|
1155 | + * |
|
1156 | + * @return void |
|
1157 | + */ |
|
1158 | + protected function loadFormats() { |
|
1159 | 1159 | |
1160 | - if (!$this->formatsLoaded) { |
|
1160 | + if (!$this->formatsLoaded) { |
|
1161 | 1161 | |
1162 | - // Get available data formats from database. |
|
1163 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1164 | - 'tx_dlf_formats.type AS type,tx_dlf_formats.root AS root,tx_dlf_formats.namespace AS namespace,tx_dlf_formats.class AS class', |
|
1165 | - 'tx_dlf_formats', |
|
1166 | - 'tx_dlf_formats.pid=0'.tx_dlf_helper::whereClause('tx_dlf_formats'), |
|
1167 | - '', |
|
1168 | - '', |
|
1169 | - '' |
|
1170 | - ); |
|
1162 | + // Get available data formats from database. |
|
1163 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1164 | + 'tx_dlf_formats.type AS type,tx_dlf_formats.root AS root,tx_dlf_formats.namespace AS namespace,tx_dlf_formats.class AS class', |
|
1165 | + 'tx_dlf_formats', |
|
1166 | + 'tx_dlf_formats.pid=0'.tx_dlf_helper::whereClause('tx_dlf_formats'), |
|
1167 | + '', |
|
1168 | + '', |
|
1169 | + '' |
|
1170 | + ); |
|
1171 | 1171 | |
1172 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
1172 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
1173 | 1173 | |
1174 | - // Update format registry. |
|
1175 | - $this->formats[$resArray['type']] = array ( |
|
1176 | - 'rootElement' => $resArray['root'], |
|
1177 | - 'namespaceURI' => $resArray['namespace'], |
|
1178 | - 'class' => $resArray['class'] |
|
1179 | - ); |
|
1174 | + // Update format registry. |
|
1175 | + $this->formats[$resArray['type']] = array ( |
|
1176 | + 'rootElement' => $resArray['root'], |
|
1177 | + 'namespaceURI' => $resArray['namespace'], |
|
1178 | + 'class' => $resArray['class'] |
|
1179 | + ); |
|
1180 | 1180 | |
1181 | - } |
|
1181 | + } |
|
1182 | 1182 | |
1183 | - $this->formatsLoaded = TRUE; |
|
1183 | + $this->formatsLoaded = TRUE; |
|
1184 | 1184 | |
1185 | - } |
|
1185 | + } |
|
1186 | 1186 | |
1187 | - } |
|
1187 | + } |
|
1188 | 1188 | |
1189 | - /** |
|
1190 | - * Register all available namespaces for a SimpleXMLElement object |
|
1191 | - * |
|
1192 | - * @access public |
|
1193 | - * |
|
1194 | - * @param SimpleXMLElement|DOMXPath &$obj: SimpleXMLElement or DOMXPath object |
|
1195 | - * |
|
1196 | - * @return void |
|
1197 | - */ |
|
1198 | - public function registerNamespaces(&$obj) { |
|
1189 | + /** |
|
1190 | + * Register all available namespaces for a SimpleXMLElement object |
|
1191 | + * |
|
1192 | + * @access public |
|
1193 | + * |
|
1194 | + * @param SimpleXMLElement|DOMXPath &$obj: SimpleXMLElement or DOMXPath object |
|
1195 | + * |
|
1196 | + * @return void |
|
1197 | + */ |
|
1198 | + public function registerNamespaces(&$obj) { |
|
1199 | 1199 | |
1200 | - $this->loadFormats(); |
|
1200 | + $this->loadFormats(); |
|
1201 | 1201 | |
1202 | - // Do we have a SimpleXMLElement or DOMXPath object? |
|
1203 | - if ($obj instanceof SimpleXMLElement) { |
|
1202 | + // Do we have a SimpleXMLElement or DOMXPath object? |
|
1203 | + if ($obj instanceof SimpleXMLElement) { |
|
1204 | 1204 | |
1205 | - $method = 'registerXPathNamespace'; |
|
1205 | + $method = 'registerXPathNamespace'; |
|
1206 | 1206 | |
1207 | - } elseif ($obj instanceof DOMXPath) { |
|
1207 | + } elseif ($obj instanceof DOMXPath) { |
|
1208 | 1208 | |
1209 | - $method = 'registerNamespace'; |
|
1209 | + $method = 'registerNamespace'; |
|
1210 | 1210 | |
1211 | - } else { |
|
1211 | + } else { |
|
1212 | 1212 | |
1213 | - if (TYPO3_DLOG) { |
|
1213 | + if (TYPO3_DLOG) { |
|
1214 | 1214 | |
1215 | - \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); |
|
1215 | + \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); |
|
1216 | 1216 | |
1217 | - } |
|
1217 | + } |
|
1218 | 1218 | |
1219 | - return; |
|
1219 | + return; |
|
1220 | 1220 | |
1221 | - } |
|
1221 | + } |
|
1222 | 1222 | |
1223 | - // Register metadata format's namespaces. |
|
1224 | - foreach ($this->formats as $enc => $conf) { |
|
1223 | + // Register metadata format's namespaces. |
|
1224 | + foreach ($this->formats as $enc => $conf) { |
|
1225 | 1225 | |
1226 | - $obj->$method(strtolower($enc), $conf['namespaceURI']); |
|
1226 | + $obj->$method(strtolower($enc), $conf['namespaceURI']); |
|
1227 | 1227 | |
1228 | - } |
|
1228 | + } |
|
1229 | 1229 | |
1230 | - } |
|
1230 | + } |
|
1231 | 1231 | |
1232 | - /** |
|
1233 | - * This saves the document to the database and index |
|
1234 | - * |
|
1235 | - * @access public |
|
1236 | - * |
|
1237 | - * @param integer $pid: The PID of the saved record |
|
1238 | - * @param integer $core: The UID of the Solr core for indexing |
|
1239 | - * |
|
1240 | - * @return boolean TRUE on success or FALSE on failure |
|
1241 | - */ |
|
1242 | - public function save($pid = 0, $core = 0) { |
|
1232 | + /** |
|
1233 | + * This saves the document to the database and index |
|
1234 | + * |
|
1235 | + * @access public |
|
1236 | + * |
|
1237 | + * @param integer $pid: The PID of the saved record |
|
1238 | + * @param integer $core: The UID of the Solr core for indexing |
|
1239 | + * |
|
1240 | + * @return boolean TRUE on success or FALSE on failure |
|
1241 | + */ |
|
1242 | + public function save($pid = 0, $core = 0) { |
|
1243 | 1243 | |
1244 | - // Save parameters for logging purposes. |
|
1245 | - $_pid = $pid; |
|
1244 | + // Save parameters for logging purposes. |
|
1245 | + $_pid = $pid; |
|
1246 | 1246 | |
1247 | - $_core = $core; |
|
1247 | + $_core = $core; |
|
1248 | 1248 | |
1249 | - if (TYPO3_MODE !== 'BE') { |
|
1249 | + if (TYPO3_MODE !== 'BE') { |
|
1250 | 1250 | |
1251 | - if (TYPO3_DLOG) { |
|
1251 | + if (TYPO3_DLOG) { |
|
1252 | 1252 | |
1253 | - \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); |
|
1253 | + \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); |
|
1254 | 1254 | |
1255 | - } |
|
1255 | + } |
|
1256 | 1256 | |
1257 | - return FALSE; |
|
1257 | + return FALSE; |
|
1258 | 1258 | |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | |
1261 | - // Make sure $pid is a non-negative integer. |
|
1262 | - $pid = max(intval($pid), 0); |
|
1261 | + // Make sure $pid is a non-negative integer. |
|
1262 | + $pid = max(intval($pid), 0); |
|
1263 | 1263 | |
1264 | - // Make sure $core is a non-negative integer. |
|
1265 | - $core = max(intval($core), 0); |
|
1264 | + // Make sure $core is a non-negative integer. |
|
1265 | + $core = max(intval($core), 0); |
|
1266 | 1266 | |
1267 | - // If $pid is not given, try to get it elsewhere. |
|
1268 | - if (!$pid && $this->pid) { |
|
1267 | + // If $pid is not given, try to get it elsewhere. |
|
1268 | + if (!$pid && $this->pid) { |
|
1269 | 1269 | |
1270 | - // Retain current PID. |
|
1271 | - $pid = $this->pid; |
|
1270 | + // Retain current PID. |
|
1271 | + $pid = $this->pid; |
|
1272 | 1272 | |
1273 | - } elseif (!$pid) { |
|
1273 | + } elseif (!$pid) { |
|
1274 | 1274 | |
1275 | - if (TYPO3_DLOG) { |
|
1275 | + if (TYPO3_DLOG) { |
|
1276 | 1276 | |
1277 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid PID "'.$pid.'" for document saving', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1277 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid PID "'.$pid.'" for document saving', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1278 | 1278 | |
1279 | - } |
|
1279 | + } |
|
1280 | 1280 | |
1281 | - return FALSE; |
|
1281 | + return FALSE; |
|
1282 | 1282 | |
1283 | - } |
|
1283 | + } |
|
1284 | 1284 | |
1285 | - // Set PID for metadata definitions. |
|
1286 | - $this->cPid = $pid; |
|
1285 | + // Set PID for metadata definitions. |
|
1286 | + $this->cPid = $pid; |
|
1287 | 1287 | |
1288 | - // Set UID placeholder if not updating existing record. |
|
1289 | - if ($pid != $this->pid) { |
|
1288 | + // Set UID placeholder if not updating existing record. |
|
1289 | + if ($pid != $this->pid) { |
|
1290 | 1290 | |
1291 | - $this->uid = uniqid('NEW'); |
|
1291 | + $this->uid = uniqid('NEW'); |
|
1292 | 1292 | |
1293 | - } |
|
1293 | + } |
|
1294 | 1294 | |
1295 | - // Get metadata array. |
|
1296 | - $metadata = $this->getTitledata($pid); |
|
1295 | + // Get metadata array. |
|
1296 | + $metadata = $this->getTitledata($pid); |
|
1297 | 1297 | |
1298 | - // Check for record identifier. |
|
1299 | - if (empty($metadata['record_id'][0])) { |
|
1298 | + // Check for record identifier. |
|
1299 | + if (empty($metadata['record_id'][0])) { |
|
1300 | 1300 | |
1301 | - if (TYPO3_DLOG) { |
|
1301 | + if (TYPO3_DLOG) { |
|
1302 | 1302 | |
1303 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] No record identifier found to avoid duplication', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1303 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] No record identifier found to avoid duplication', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1304 | 1304 | |
1305 | - } |
|
1305 | + } |
|
1306 | 1306 | |
1307 | - return FALSE; |
|
1307 | + return FALSE; |
|
1308 | 1308 | |
1309 | - } |
|
1309 | + } |
|
1310 | 1310 | |
1311 | - // Load plugin configuration. |
|
1312 | - $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
1311 | + // Load plugin configuration. |
|
1312 | + $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
1313 | 1313 | |
1314 | - // Get UID for user "_cli_dlf". |
|
1315 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1316 | - 'be_users.uid AS uid', |
|
1317 | - 'be_users', |
|
1318 | - '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'), |
|
1319 | - '', |
|
1320 | - '', |
|
1321 | - '1' |
|
1322 | - ); |
|
1314 | + // Get UID for user "_cli_dlf". |
|
1315 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1316 | + 'be_users.uid AS uid', |
|
1317 | + 'be_users', |
|
1318 | + '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'), |
|
1319 | + '', |
|
1320 | + '', |
|
1321 | + '1' |
|
1322 | + ); |
|
1323 | 1323 | |
1324 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
1324 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
1325 | 1325 | |
1326 | - list ($be_user) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1326 | + list ($be_user) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1327 | 1327 | |
1328 | - } else { |
|
1328 | + } else { |
|
1329 | 1329 | |
1330 | - if (TYPO3_DLOG) { |
|
1330 | + if (TYPO3_DLOG) { |
|
1331 | 1331 | |
1332 | - \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); |
|
1332 | + \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); |
|
1333 | 1333 | |
1334 | - } |
|
1334 | + } |
|
1335 | 1335 | |
1336 | - return FALSE; |
|
1336 | + return FALSE; |
|
1337 | 1337 | |
1338 | - } |
|
1338 | + } |
|
1339 | 1339 | |
1340 | - // Get UID for structure type. |
|
1341 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1342 | - 'tx_dlf_structures.uid AS uid', |
|
1343 | - 'tx_dlf_structures', |
|
1344 | - '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'), |
|
1345 | - '', |
|
1346 | - '', |
|
1347 | - '1' |
|
1348 | - ); |
|
1340 | + // Get UID for structure type. |
|
1341 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1342 | + 'tx_dlf_structures.uid AS uid', |
|
1343 | + 'tx_dlf_structures', |
|
1344 | + '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'), |
|
1345 | + '', |
|
1346 | + '', |
|
1347 | + '1' |
|
1348 | + ); |
|
1349 | 1349 | |
1350 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
1350 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
1351 | 1351 | |
1352 | - list ($structure) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1352 | + list ($structure) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1353 | 1353 | |
1354 | - } else { |
|
1354 | + } else { |
|
1355 | 1355 | |
1356 | - if (TYPO3_DLOG) { |
|
1356 | + if (TYPO3_DLOG) { |
|
1357 | 1357 | |
1358 | - \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'), |
|
1359 | - self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1358 | + \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'), |
|
1359 | + self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1360 | 1360 | |
1361 | - } |
|
1361 | + } |
|
1362 | 1362 | |
1363 | - return FALSE; |
|
1363 | + return FALSE; |
|
1364 | 1364 | |
1365 | - } |
|
1365 | + } |
|
1366 | 1366 | |
1367 | - $metadata['type'][0] = $structure; |
|
1367 | + $metadata['type'][0] = $structure; |
|
1368 | 1368 | |
1369 | - // Get UIDs for collections. |
|
1370 | - $collections = array (); |
|
1369 | + // Get UIDs for collections. |
|
1370 | + $collections = array (); |
|
1371 | 1371 | |
1372 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1373 | - 'tx_dlf_collections.index_name AS index_name,tx_dlf_collections.uid AS uid', |
|
1374 | - 'tx_dlf_collections', |
|
1375 | - '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'), |
|
1376 | - '', |
|
1377 | - '', |
|
1378 | - '' |
|
1379 | - ); |
|
1372 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1373 | + 'tx_dlf_collections.index_name AS index_name,tx_dlf_collections.uid AS uid', |
|
1374 | + 'tx_dlf_collections', |
|
1375 | + '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'), |
|
1376 | + '', |
|
1377 | + '', |
|
1378 | + '' |
|
1379 | + ); |
|
1380 | 1380 | |
1381 | - for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) { |
|
1381 | + for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) { |
|
1382 | 1382 | |
1383 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
1383 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
1384 | 1384 | |
1385 | - $collUid[$resArray['index_name']] = $resArray['uid']; |
|
1385 | + $collUid[$resArray['index_name']] = $resArray['uid']; |
|
1386 | 1386 | |
1387 | - } |
|
1387 | + } |
|
1388 | 1388 | |
1389 | - foreach ($metadata['collection'] as $collection) { |
|
1389 | + foreach ($metadata['collection'] as $collection) { |
|
1390 | 1390 | |
1391 | - if (!empty($collUid[$collection])) { |
|
1391 | + if (!empty($collUid[$collection])) { |
|
1392 | 1392 | |
1393 | - // Add existing collection's UID. |
|
1394 | - $collections[] = $collUid[$collection]; |
|
1393 | + // Add existing collection's UID. |
|
1394 | + $collections[] = $collUid[$collection]; |
|
1395 | 1395 | |
1396 | - } else { |
|
1396 | + } else { |
|
1397 | 1397 | |
1398 | - // Insert new collection. |
|
1399 | - $collNewUid = uniqid('NEW'); |
|
1398 | + // Insert new collection. |
|
1399 | + $collNewUid = uniqid('NEW'); |
|
1400 | 1400 | |
1401 | - $collData['tx_dlf_collections'][$collNewUid] = array ( |
|
1402 | - 'pid' => $pid, |
|
1403 | - 'label' => $collection, |
|
1404 | - 'index_name' => $collection, |
|
1405 | - 'oai_name' => (!empty($conf['publishNewCollections']) ? $collection : ''), |
|
1406 | - 'description' => '', |
|
1407 | - 'documents' => 0, |
|
1408 | - 'owner' => 0, |
|
1409 | - 'status' => 0, |
|
1410 | - ); |
|
1401 | + $collData['tx_dlf_collections'][$collNewUid] = array ( |
|
1402 | + 'pid' => $pid, |
|
1403 | + 'label' => $collection, |
|
1404 | + 'index_name' => $collection, |
|
1405 | + 'oai_name' => (!empty($conf['publishNewCollections']) ? $collection : ''), |
|
1406 | + 'description' => '', |
|
1407 | + 'documents' => 0, |
|
1408 | + 'owner' => 0, |
|
1409 | + 'status' => 0, |
|
1410 | + ); |
|
1411 | 1411 | |
1412 | - $substUid = tx_dlf_helper::processDB($collData); |
|
1412 | + $substUid = tx_dlf_helper::processDB($collData); |
|
1413 | 1413 | |
1414 | - // Prevent double insertion. |
|
1415 | - unset ($collData); |
|
1414 | + // Prevent double insertion. |
|
1415 | + unset ($collData); |
|
1416 | 1416 | |
1417 | - // Add new collection's UID. |
|
1418 | - $collections[] = $substUid[$collNewUid]; |
|
1417 | + // Add new collection's UID. |
|
1418 | + $collections[] = $substUid[$collNewUid]; |
|
1419 | 1419 | |
1420 | - if (!defined('TYPO3_cliMode')) { |
|
1420 | + if (!defined('TYPO3_cliMode')) { |
|
1421 | 1421 | |
1422 | - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1423 | - 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
1424 | - htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newCollection'), $collection, $substUid[$collNewUid])), |
|
1425 | - tx_dlf_helper::getLL('flash.attention', TRUE), |
|
1426 | - \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
1427 | - TRUE |
|
1428 | - ); |
|
1422 | + $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1423 | + 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
1424 | + htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newCollection'), $collection, $substUid[$collNewUid])), |
|
1425 | + tx_dlf_helper::getLL('flash.attention', TRUE), |
|
1426 | + \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
1427 | + TRUE |
|
1428 | + ); |
|
1429 | 1429 | |
1430 | - tx_dlf_helper::addMessage($message); |
|
1430 | + tx_dlf_helper::addMessage($message); |
|
1431 | 1431 | |
1432 | - } |
|
1432 | + } |
|
1433 | 1433 | |
1434 | - } |
|
1434 | + } |
|
1435 | 1435 | |
1436 | - } |
|
1436 | + } |
|
1437 | 1437 | |
1438 | - // Preserve user-defined collections. |
|
1439 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
|
1440 | - 'tx_dlf_collections.uid AS uid', |
|
1441 | - 'tx_dlf_documents', |
|
1442 | - 'tx_dlf_relations', |
|
1443 | - 'tx_dlf_collections', |
|
1444 | - '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'), |
|
1445 | - '', |
|
1446 | - '', |
|
1447 | - '' |
|
1448 | - ); |
|
1438 | + // Preserve user-defined collections. |
|
1439 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
|
1440 | + 'tx_dlf_collections.uid AS uid', |
|
1441 | + 'tx_dlf_documents', |
|
1442 | + 'tx_dlf_relations', |
|
1443 | + 'tx_dlf_collections', |
|
1444 | + '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'), |
|
1445 | + '', |
|
1446 | + '', |
|
1447 | + '' |
|
1448 | + ); |
|
1449 | 1449 | |
1450 | - for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) { |
|
1450 | + for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) { |
|
1451 | 1451 | |
1452 | - list ($collections[]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1452 | + list ($collections[]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1453 | 1453 | |
1454 | - } |
|
1454 | + } |
|
1455 | 1455 | |
1456 | - $metadata['collection'] = $collections; |
|
1456 | + $metadata['collection'] = $collections; |
|
1457 | 1457 | |
1458 | - // Get UID for owner. |
|
1459 | - $owner = !empty($metadata['owner'][0]) ? $metadata['owner'][0] : 'default'; |
|
1458 | + // Get UID for owner. |
|
1459 | + $owner = !empty($metadata['owner'][0]) ? $metadata['owner'][0] : 'default'; |
|
1460 | 1460 | |
1461 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1462 | - 'tx_dlf_libraries.uid AS uid', |
|
1463 | - 'tx_dlf_libraries', |
|
1464 | - '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'), |
|
1465 | - '', |
|
1466 | - '', |
|
1467 | - '1' |
|
1468 | - ); |
|
1461 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1462 | + 'tx_dlf_libraries.uid AS uid', |
|
1463 | + 'tx_dlf_libraries', |
|
1464 | + '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'), |
|
1465 | + '', |
|
1466 | + '', |
|
1467 | + '1' |
|
1468 | + ); |
|
1469 | 1469 | |
1470 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
1470 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
1471 | 1471 | |
1472 | - list ($ownerUid) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1472 | + list ($ownerUid) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
1473 | 1473 | |
1474 | - } else { |
|
1474 | + } else { |
|
1475 | 1475 | |
1476 | - // Insert new library. |
|
1477 | - $libNewUid = uniqid('NEW'); |
|
1476 | + // Insert new library. |
|
1477 | + $libNewUid = uniqid('NEW'); |
|
1478 | 1478 | |
1479 | - $libData['tx_dlf_libraries'][$libNewUid] = array ( |
|
1480 | - 'pid' => $pid, |
|
1481 | - 'label' => $owner, |
|
1482 | - 'index_name' => $owner, |
|
1483 | - 'website' => '', |
|
1484 | - 'contact' => '', |
|
1485 | - 'image' => '', |
|
1486 | - 'oai_label' => '', |
|
1487 | - 'oai_base' => '', |
|
1488 | - 'opac_label' => '', |
|
1489 | - 'opac_base' => '', |
|
1490 | - 'union_label' => '', |
|
1491 | - 'union_base' => '', |
|
1492 | - ); |
|
1479 | + $libData['tx_dlf_libraries'][$libNewUid] = array ( |
|
1480 | + 'pid' => $pid, |
|
1481 | + 'label' => $owner, |
|
1482 | + 'index_name' => $owner, |
|
1483 | + 'website' => '', |
|
1484 | + 'contact' => '', |
|
1485 | + 'image' => '', |
|
1486 | + 'oai_label' => '', |
|
1487 | + 'oai_base' => '', |
|
1488 | + 'opac_label' => '', |
|
1489 | + 'opac_base' => '', |
|
1490 | + 'union_label' => '', |
|
1491 | + 'union_base' => '', |
|
1492 | + ); |
|
1493 | 1493 | |
1494 | - $substUid = tx_dlf_helper::processDB($libData); |
|
1494 | + $substUid = tx_dlf_helper::processDB($libData); |
|
1495 | 1495 | |
1496 | - // Add new library's UID. |
|
1497 | - $ownerUid = $substUid[$libNewUid]; |
|
1496 | + // Add new library's UID. |
|
1497 | + $ownerUid = $substUid[$libNewUid]; |
|
1498 | 1498 | |
1499 | - if (!defined('TYPO3_cliMode')) { |
|
1499 | + if (!defined('TYPO3_cliMode')) { |
|
1500 | 1500 | |
1501 | - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1502 | - 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
1503 | - htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newLibrary'), $owner, $ownerUid)), |
|
1504 | - tx_dlf_helper::getLL('flash.attention', TRUE), |
|
1505 | - \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
1506 | - TRUE |
|
1507 | - ); |
|
1501 | + $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1502 | + 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
1503 | + htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newLibrary'), $owner, $ownerUid)), |
|
1504 | + tx_dlf_helper::getLL('flash.attention', TRUE), |
|
1505 | + \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, |
|
1506 | + TRUE |
|
1507 | + ); |
|
1508 | 1508 | |
1509 | - tx_dlf_helper::addMessage($message); |
|
1509 | + tx_dlf_helper::addMessage($message); |
|
1510 | 1510 | |
1511 | - } |
|
1511 | + } |
|
1512 | 1512 | |
1513 | - } |
|
1513 | + } |
|
1514 | 1514 | |
1515 | - $metadata['owner'][0] = $ownerUid; |
|
1515 | + $metadata['owner'][0] = $ownerUid; |
|
1516 | 1516 | |
1517 | - // Get UID of parent document. |
|
1518 | - $partof = 0; |
|
1517 | + // Get UID of parent document. |
|
1518 | + $partof = 0; |
|
1519 | 1519 | |
1520 | - // Get the closest ancestor of the current document which has a MPTR child. |
|
1521 | - $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$this->_getToplevelId().'"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
|
1520 | + // Get the closest ancestor of the current document which has a MPTR child. |
|
1521 | + $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$this->_getToplevelId().'"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr'); |
|
1522 | 1522 | |
1523 | - if (!empty($parentMptr[0])) { |
|
1523 | + if (!empty($parentMptr[0])) { |
|
1524 | 1524 | |
1525 | - $parentLocation = (string) $parentMptr[0]->attributes('http://www.w3.org/1999/xlink')->href; |
|
1525 | + $parentLocation = (string) $parentMptr[0]->attributes('http://www.w3.org/1999/xlink')->href; |
|
1526 | 1526 | |
1527 | - if ($parentLocation != $this->location) { |
|
1527 | + if ($parentLocation != $this->location) { |
|
1528 | 1528 | |
1529 | - $parentDoc =& tx_dlf_document::getInstance($parentLocation, $pid); |
|
1529 | + $parentDoc =& tx_dlf_document::getInstance($parentLocation, $pid); |
|
1530 | 1530 | |
1531 | - if ($parentDoc->ready) { |
|
1531 | + if ($parentDoc->ready) { |
|
1532 | 1532 | |
1533 | - if ($parentDoc->pid != $pid) { |
|
1533 | + if ($parentDoc->pid != $pid) { |
|
1534 | 1534 | |
1535 | - $parentDoc->save($pid, $core); |
|
1535 | + $parentDoc->save($pid, $core); |
|
1536 | 1536 | |
1537 | - } |
|
1537 | + } |
|
1538 | 1538 | |
1539 | - $partof = $parentDoc->uid; |
|
1539 | + $partof = $parentDoc->uid; |
|
1540 | 1540 | |
1541 | - } |
|
1541 | + } |
|
1542 | 1542 | |
1543 | - } |
|
1543 | + } |
|
1544 | 1544 | |
1545 | - } |
|
1545 | + } |
|
1546 | 1546 | |
1547 | - // Use the date of publication or title as alternative sorting metric for parts of multi-part works. |
|
1548 | - if (!empty($partof)) { |
|
1547 | + // Use the date of publication or title as alternative sorting metric for parts of multi-part works. |
|
1548 | + if (!empty($partof)) { |
|
1549 | 1549 | |
1550 | - if (empty($metadata['volume'][0]) && !empty($metadata['year'][0])) { |
|
1550 | + if (empty($metadata['volume'][0]) && !empty($metadata['year'][0])) { |
|
1551 | 1551 | |
1552 | - $metadata['volume'] = $metadata['year']; |
|
1552 | + $metadata['volume'] = $metadata['year']; |
|
1553 | 1553 | |
1554 | - } |
|
1554 | + } |
|
1555 | 1555 | |
1556 | - if (empty($metadata['volume_sorting'][0])) { |
|
1556 | + if (empty($metadata['volume_sorting'][0])) { |
|
1557 | 1557 | |
1558 | - if (!empty($metadata['year_sorting'][0])) { |
|
1558 | + if (!empty($metadata['year_sorting'][0])) { |
|
1559 | 1559 | |
1560 | - $metadata['volume_sorting'][0] = $metadata['year_sorting'][0]; |
|
1560 | + $metadata['volume_sorting'][0] = $metadata['year_sorting'][0]; |
|
1561 | 1561 | |
1562 | - } elseif (!empty($metadata['year'][0])) { |
|
1562 | + } elseif (!empty($metadata['year'][0])) { |
|
1563 | 1563 | |
1564 | - $metadata['volume_sorting'][0] = $metadata['year'][0]; |
|
1564 | + $metadata['volume_sorting'][0] = $metadata['year'][0]; |
|
1565 | 1565 | |
1566 | - } |
|
1566 | + } |
|
1567 | 1567 | |
1568 | - } |
|
1568 | + } |
|
1569 | 1569 | |
1570 | - // If volume_sorting is still empty, try to use title_sorting finally (workaround for newspapers) |
|
1571 | - if (empty($metadata['volume_sorting'][0])) { |
|
1570 | + // If volume_sorting is still empty, try to use title_sorting finally (workaround for newspapers) |
|
1571 | + if (empty($metadata['volume_sorting'][0])) { |
|
1572 | 1572 | |
1573 | - if (!empty($metadata['title_sorting'][0])) { |
|
1573 | + if (!empty($metadata['title_sorting'][0])) { |
|
1574 | 1574 | |
1575 | - $metadata['volume_sorting'][0] = $metadata['title_sorting'][0]; |
|
1575 | + $metadata['volume_sorting'][0] = $metadata['title_sorting'][0]; |
|
1576 | 1576 | |
1577 | - } |
|
1578 | - } |
|
1577 | + } |
|
1578 | + } |
|
1579 | 1579 | |
1580 | - } |
|
1580 | + } |
|
1581 | 1581 | |
1582 | - // Get metadata for lists and sorting. |
|
1583 | - $listed = array (); |
|
1582 | + // Get metadata for lists and sorting. |
|
1583 | + $listed = array (); |
|
1584 | 1584 | |
1585 | - $sortable = array (); |
|
1585 | + $sortable = array (); |
|
1586 | 1586 | |
1587 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1588 | - 'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable', |
|
1589 | - 'tx_dlf_metadata', |
|
1590 | - '(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'), |
|
1591 | - '', |
|
1592 | - '', |
|
1593 | - '' |
|
1594 | - ); |
|
1587 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1588 | + 'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable', |
|
1589 | + 'tx_dlf_metadata', |
|
1590 | + '(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'), |
|
1591 | + '', |
|
1592 | + '', |
|
1593 | + '' |
|
1594 | + ); |
|
1595 | 1595 | |
1596 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
1596 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
1597 | 1597 | |
1598 | - if (!empty($metadata[$resArray['index_name']])) { |
|
1598 | + if (!empty($metadata[$resArray['index_name']])) { |
|
1599 | 1599 | |
1600 | - if ($resArray['is_listed']) { |
|
1600 | + if ($resArray['is_listed']) { |
|
1601 | 1601 | |
1602 | - $listed[$resArray['index_name']] = $metadata[$resArray['index_name']]; |
|
1602 | + $listed[$resArray['index_name']] = $metadata[$resArray['index_name']]; |
|
1603 | 1603 | |
1604 | - } |
|
1604 | + } |
|
1605 | 1605 | |
1606 | - if ($resArray['is_sortable']) { |
|
1606 | + if ($resArray['is_sortable']) { |
|
1607 | 1607 | |
1608 | - $sortable[$resArray['index_name']] = $metadata[$resArray['index_name']][0]; |
|
1608 | + $sortable[$resArray['index_name']] = $metadata[$resArray['index_name']][0]; |
|
1609 | 1609 | |
1610 | - } |
|
1610 | + } |
|
1611 | 1611 | |
1612 | - } |
|
1612 | + } |
|
1613 | 1613 | |
1614 | - } |
|
1614 | + } |
|
1615 | 1615 | |
1616 | - // Fill data array. |
|
1617 | - $data['tx_dlf_documents'][$this->uid] = array ( |
|
1618 | - 'pid' => $pid, |
|
1619 | - $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['starttime'] => 0, |
|
1620 | - $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['endtime'] => 0, |
|
1621 | - 'prod_id' => $metadata['prod_id'][0], |
|
1622 | - 'location' => $this->location, |
|
1623 | - 'record_id' => $metadata['record_id'][0], |
|
1624 | - 'opac_id' => $metadata['opac_id'][0], |
|
1625 | - 'union_id' => $metadata['union_id'][0], |
|
1626 | - 'urn' => $metadata['urn'][0], |
|
1627 | - 'purl' => $metadata['purl'][0], |
|
1628 | - 'title' => $metadata['title'][0], |
|
1629 | - 'title_sorting' => $metadata['title_sorting'][0], |
|
1630 | - 'author' => implode('; ', $metadata['author']), |
|
1631 | - 'year' => implode('; ', $metadata['year']), |
|
1632 | - 'place' => implode('; ', $metadata['place']), |
|
1633 | - 'thumbnail' => $this->_getThumbnail(TRUE), |
|
1634 | - 'metadata' => serialize($listed), |
|
1635 | - 'metadata_sorting' => serialize($sortable), |
|
1636 | - 'structure' => $metadata['type'][0], |
|
1637 | - 'partof' => $partof, |
|
1638 | - 'volume' => $metadata['volume'][0], |
|
1639 | - 'volume_sorting' => $metadata['volume_sorting'][0], |
|
1640 | - 'collections' => $metadata['collection'], |
|
1641 | - 'owner' => $metadata['owner'][0], |
|
1642 | - 'solrcore' => $core, |
|
1643 | - 'status' => 0, |
|
1644 | - ); |
|
1616 | + // Fill data array. |
|
1617 | + $data['tx_dlf_documents'][$this->uid] = array ( |
|
1618 | + 'pid' => $pid, |
|
1619 | + $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['starttime'] => 0, |
|
1620 | + $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['endtime'] => 0, |
|
1621 | + 'prod_id' => $metadata['prod_id'][0], |
|
1622 | + 'location' => $this->location, |
|
1623 | + 'record_id' => $metadata['record_id'][0], |
|
1624 | + 'opac_id' => $metadata['opac_id'][0], |
|
1625 | + 'union_id' => $metadata['union_id'][0], |
|
1626 | + 'urn' => $metadata['urn'][0], |
|
1627 | + 'purl' => $metadata['purl'][0], |
|
1628 | + 'title' => $metadata['title'][0], |
|
1629 | + 'title_sorting' => $metadata['title_sorting'][0], |
|
1630 | + 'author' => implode('; ', $metadata['author']), |
|
1631 | + 'year' => implode('; ', $metadata['year']), |
|
1632 | + 'place' => implode('; ', $metadata['place']), |
|
1633 | + 'thumbnail' => $this->_getThumbnail(TRUE), |
|
1634 | + 'metadata' => serialize($listed), |
|
1635 | + 'metadata_sorting' => serialize($sortable), |
|
1636 | + 'structure' => $metadata['type'][0], |
|
1637 | + 'partof' => $partof, |
|
1638 | + 'volume' => $metadata['volume'][0], |
|
1639 | + 'volume_sorting' => $metadata['volume_sorting'][0], |
|
1640 | + 'collections' => $metadata['collection'], |
|
1641 | + 'owner' => $metadata['owner'][0], |
|
1642 | + 'solrcore' => $core, |
|
1643 | + 'status' => 0, |
|
1644 | + ); |
|
1645 | 1645 | |
1646 | - // Unhide hidden documents. |
|
1647 | - if (!empty($conf['unhideOnIndex'])) { |
|
1646 | + // Unhide hidden documents. |
|
1647 | + if (!empty($conf['unhideOnIndex'])) { |
|
1648 | 1648 | |
1649 | - $data['tx_dlf_documents'][$this->uid][$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['disabled']] = 0; |
|
1649 | + $data['tx_dlf_documents'][$this->uid][$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['disabled']] = 0; |
|
1650 | 1650 | |
1651 | - } |
|
1651 | + } |
|
1652 | 1652 | |
1653 | - // Process data. |
|
1654 | - $newIds = tx_dlf_helper::processDB($data); |
|
1653 | + // Process data. |
|
1654 | + $newIds = tx_dlf_helper::processDB($data); |
|
1655 | 1655 | |
1656 | - // Replace placeholder with actual UID. |
|
1657 | - if (strpos($this->uid, 'NEW') === 0) { |
|
1656 | + // Replace placeholder with actual UID. |
|
1657 | + if (strpos($this->uid, 'NEW') === 0) { |
|
1658 | 1658 | |
1659 | - $this->uid = $newIds[$this->uid]; |
|
1659 | + $this->uid = $newIds[$this->uid]; |
|
1660 | 1660 | |
1661 | - $this->pid = $pid; |
|
1661 | + $this->pid = $pid; |
|
1662 | 1662 | |
1663 | - $this->parentId = $partof; |
|
1663 | + $this->parentId = $partof; |
|
1664 | 1664 | |
1665 | - } |
|
1665 | + } |
|
1666 | 1666 | |
1667 | - if (!defined('TYPO3_cliMode')) { |
|
1667 | + if (!defined('TYPO3_cliMode')) { |
|
1668 | 1668 | |
1669 | - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1670 | - 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
1671 | - htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.documentSaved'), $metadata['title'][0], $this->uid)), |
|
1672 | - tx_dlf_helper::getLL('flash.done', TRUE), |
|
1673 | - \TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
|
1674 | - TRUE |
|
1675 | - ); |
|
1669 | + $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1670 | + 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage', |
|
1671 | + htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.documentSaved'), $metadata['title'][0], $this->uid)), |
|
1672 | + tx_dlf_helper::getLL('flash.done', TRUE), |
|
1673 | + \TYPO3\CMS\Core\Messaging\FlashMessage::OK, |
|
1674 | + TRUE |
|
1675 | + ); |
|
1676 | 1676 | |
1677 | - tx_dlf_helper::addMessage($message); |
|
1677 | + tx_dlf_helper::addMessage($message); |
|
1678 | 1678 | |
1679 | - } |
|
1679 | + } |
|
1680 | 1680 | |
1681 | - // Add document to index. |
|
1682 | - if ($core) { |
|
1681 | + // Add document to index. |
|
1682 | + if ($core) { |
|
1683 | 1683 | |
1684 | - tx_dlf_indexing::add($this, $core); |
|
1684 | + tx_dlf_indexing::add($this, $core); |
|
1685 | 1685 | |
1686 | - } else { |
|
1686 | + } else { |
|
1687 | 1687 | |
1688 | - if (TYPO3_DLOG) { |
|
1688 | + if (TYPO3_DLOG) { |
|
1689 | 1689 | |
1690 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid UID "'.$core.'" for Solr core', self::$extKey, SYSLOG_SEVERITY_NOTICE); |
|
1690 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->save('.$_pid.', '.$_core.')] Invalid UID "'.$core.'" for Solr core', self::$extKey, SYSLOG_SEVERITY_NOTICE); |
|
1691 | 1691 | |
1692 | - } |
|
1692 | + } |
|
1693 | 1693 | |
1694 | - } |
|
1694 | + } |
|
1695 | 1695 | |
1696 | - return TRUE; |
|
1696 | + return TRUE; |
|
1697 | 1697 | |
1698 | - } |
|
1698 | + } |
|
1699 | 1699 | |
1700 | - /** |
|
1701 | - * This returns $this->cPid via __get() |
|
1702 | - * |
|
1703 | - * @access protected |
|
1704 | - * |
|
1705 | - * @return integer The PID of the metadata definitions |
|
1706 | - */ |
|
1707 | - protected function _getCPid() { |
|
1700 | + /** |
|
1701 | + * This returns $this->cPid via __get() |
|
1702 | + * |
|
1703 | + * @access protected |
|
1704 | + * |
|
1705 | + * @return integer The PID of the metadata definitions |
|
1706 | + */ |
|
1707 | + protected function _getCPid() { |
|
1708 | 1708 | |
1709 | - return $this->cPid; |
|
1709 | + return $this->cPid; |
|
1710 | 1710 | |
1711 | - } |
|
1711 | + } |
|
1712 | 1712 | |
1713 | - /** |
|
1714 | - * This builds an array of the document's dmdSecs |
|
1715 | - * |
|
1716 | - * @access protected |
|
1717 | - * |
|
1718 | - * @return array Array of dmdSecs with their IDs as array key |
|
1719 | - */ |
|
1720 | - protected function _getDmdSec() { |
|
1713 | + /** |
|
1714 | + * This builds an array of the document's dmdSecs |
|
1715 | + * |
|
1716 | + * @access protected |
|
1717 | + * |
|
1718 | + * @return array Array of dmdSecs with their IDs as array key |
|
1719 | + */ |
|
1720 | + protected function _getDmdSec() { |
|
1721 | 1721 | |
1722 | - if (!$this->dmdSecLoaded) { |
|
1722 | + if (!$this->dmdSecLoaded) { |
|
1723 | 1723 | |
1724 | - // Get available data formats. |
|
1725 | - $this->loadFormats(); |
|
1724 | + // Get available data formats. |
|
1725 | + $this->loadFormats(); |
|
1726 | 1726 | |
1727 | - // Get dmdSec nodes from METS. |
|
1728 | - $dmdIds = $this->mets->xpath('./mets:dmdSec/@ID'); |
|
1727 | + // Get dmdSec nodes from METS. |
|
1728 | + $dmdIds = $this->mets->xpath('./mets:dmdSec/@ID'); |
|
1729 | 1729 | |
1730 | - foreach ($dmdIds as $dmdId) { |
|
1730 | + foreach ($dmdIds as $dmdId) { |
|
1731 | 1731 | |
1732 | - if ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[not(@MDTYPE="OTHER")]/@MDTYPE')) { |
|
1732 | + if ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[not(@MDTYPE="OTHER")]/@MDTYPE')) { |
|
1733 | 1733 | |
1734 | - if (!empty($this->formats[(string) $type[0]])) { |
|
1734 | + if (!empty($this->formats[(string) $type[0]])) { |
|
1735 | 1735 | |
1736 | - $type = (string) $type[0]; |
|
1736 | + $type = (string) $type[0]; |
|
1737 | 1737 | |
1738 | - $xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
1738 | + $xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
1739 | 1739 | |
1740 | - } |
|
1740 | + } |
|
1741 | 1741 | |
1742 | - } elseif ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"]/@OTHERMDTYPE')) { |
|
1742 | + } elseif ($type = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"]/@OTHERMDTYPE')) { |
|
1743 | 1743 | |
1744 | - if (!empty($this->formats[(string) $type[0]])) { |
|
1744 | + if (!empty($this->formats[(string) $type[0]])) { |
|
1745 | 1745 | |
1746 | - $type = (string) $type[0]; |
|
1746 | + $type = (string) $type[0]; |
|
1747 | 1747 | |
1748 | - $xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
1748 | + $xml = $this->mets->xpath('./mets:dmdSec[@ID="'.(string) $dmdId.'"]/mets:mdWrap[@MDTYPE="OTHER"][@OTHERMDTYPE="'.$type.'"]/mets:xmlData/'.strtolower($type).':'.$this->formats[$type]['rootElement']); |
|
1749 | 1749 | |
1750 | - } |
|
1750 | + } |
|
1751 | 1751 | |
1752 | - } |
|
1752 | + } |
|
1753 | 1753 | |
1754 | - if ($xml) { |
|
1754 | + if ($xml) { |
|
1755 | 1755 | |
1756 | - $this->dmdSec[(string) $dmdId]['type'] = $type; |
|
1756 | + $this->dmdSec[(string) $dmdId]['type'] = $type; |
|
1757 | 1757 | |
1758 | - $this->dmdSec[(string) $dmdId]['xml'] = $xml[0]; |
|
1758 | + $this->dmdSec[(string) $dmdId]['xml'] = $xml[0]; |
|
1759 | 1759 | |
1760 | - $this->registerNamespaces($this->dmdSec[(string) $dmdId]['xml']); |
|
1760 | + $this->registerNamespaces($this->dmdSec[(string) $dmdId]['xml']); |
|
1761 | 1761 | |
1762 | - } |
|
1762 | + } |
|
1763 | 1763 | |
1764 | - } |
|
1764 | + } |
|
1765 | 1765 | |
1766 | - $this->dmdSecLoaded = TRUE; |
|
1766 | + $this->dmdSecLoaded = TRUE; |
|
1767 | 1767 | |
1768 | - } |
|
1768 | + } |
|
1769 | 1769 | |
1770 | - return $this->dmdSec; |
|
1770 | + return $this->dmdSec; |
|
1771 | 1771 | |
1772 | - } |
|
1772 | + } |
|
1773 | 1773 | |
1774 | - /** |
|
1775 | - * This builds the file ID -> USE concordance |
|
1776 | - * |
|
1777 | - * @access protected |
|
1778 | - * |
|
1779 | - * @return array Array of file use groups with file IDs |
|
1780 | - */ |
|
1781 | - protected function _getFileGrps() { |
|
1774 | + /** |
|
1775 | + * This builds the file ID -> USE concordance |
|
1776 | + * |
|
1777 | + * @access protected |
|
1778 | + * |
|
1779 | + * @return array Array of file use groups with file IDs |
|
1780 | + */ |
|
1781 | + protected function _getFileGrps() { |
|
1782 | 1782 | |
1783 | - if (!$this->fileGrpsLoaded) { |
|
1783 | + if (!$this->fileGrpsLoaded) { |
|
1784 | 1784 | |
1785 | - // Get configured USE attributes. |
|
1786 | - $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
1785 | + // Get configured USE attributes. |
|
1786 | + $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
1787 | 1787 | |
1788 | - $useGrps = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $extConf['fileGrps']); |
|
1788 | + $useGrps = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $extConf['fileGrps']); |
|
1789 | 1789 | |
1790 | - if (!empty($extConf['fileGrpThumbs'])) { |
|
1790 | + if (!empty($extConf['fileGrpThumbs'])) { |
|
1791 | 1791 | |
1792 | - $useGrps[] = $extConf['fileGrpThumbs']; |
|
1792 | + $useGrps[] = $extConf['fileGrpThumbs']; |
|
1793 | 1793 | |
1794 | - } |
|
1794 | + } |
|
1795 | 1795 | |
1796 | - if (!empty($extConf['fileGrpDownload'])) { |
|
1796 | + if (!empty($extConf['fileGrpDownload'])) { |
|
1797 | 1797 | |
1798 | - $useGrps[] = $extConf['fileGrpDownload']; |
|
1798 | + $useGrps[] = $extConf['fileGrpDownload']; |
|
1799 | 1799 | |
1800 | - } |
|
1800 | + } |
|
1801 | 1801 | |
1802 | - if (!empty($extConf['fileGrpFulltext'])) { |
|
1802 | + if (!empty($extConf['fileGrpFulltext'])) { |
|
1803 | 1803 | |
1804 | - $useGrps[] = $extConf['fileGrpFulltext']; |
|
1804 | + $useGrps[] = $extConf['fileGrpFulltext']; |
|
1805 | 1805 | |
1806 | - } |
|
1806 | + } |
|
1807 | 1807 | |
1808 | - if (!empty($extConf['fileGrpAudio'])) { |
|
1808 | + if (!empty($extConf['fileGrpAudio'])) { |
|
1809 | 1809 | |
1810 | - $useGrps[] = $extConf['fileGrpAudio']; |
|
1810 | + $useGrps[] = $extConf['fileGrpAudio']; |
|
1811 | 1811 | |
1812 | - } |
|
1812 | + } |
|
1813 | 1813 | |
1814 | - // Get all file groups. |
|
1815 | - $fileGrps = $this->mets->xpath('./mets:fileSec/mets:fileGrp'); |
|
1814 | + // Get all file groups. |
|
1815 | + $fileGrps = $this->mets->xpath('./mets:fileSec/mets:fileGrp'); |
|
1816 | 1816 | |
1817 | - // Build concordance for configured USE attributes. |
|
1818 | - foreach ($fileGrps as $fileGrp) { |
|
1817 | + // Build concordance for configured USE attributes. |
|
1818 | + foreach ($fileGrps as $fileGrp) { |
|
1819 | 1819 | |
1820 | - if (in_array((string) $fileGrp['USE'], $useGrps)) { |
|
1820 | + if (in_array((string) $fileGrp['USE'], $useGrps)) { |
|
1821 | 1821 | |
1822 | - foreach ($fileGrp->children('http://www.loc.gov/METS/')->file as $file) { |
|
1822 | + foreach ($fileGrp->children('http://www.loc.gov/METS/')->file as $file) { |
|
1823 | 1823 | |
1824 | - $this->fileGrps[(string) $file->attributes()->ID] = (string) $fileGrp['USE']; |
|
1824 | + $this->fileGrps[(string) $file->attributes()->ID] = (string) $fileGrp['USE']; |
|
1825 | 1825 | |
1826 | - } |
|
1826 | + } |
|
1827 | 1827 | |
1828 | - } |
|
1828 | + } |
|
1829 | 1829 | |
1830 | - } |
|
1830 | + } |
|
1831 | 1831 | |
1832 | - // Are there any fulltext files available? |
|
1833 | - if (!empty($extConf['fileGrpFulltext']) && in_array($extConf['fileGrpFulltext'], $this->fileGrps)) { |
|
1832 | + // Are there any fulltext files available? |
|
1833 | + if (!empty($extConf['fileGrpFulltext']) && in_array($extConf['fileGrpFulltext'], $this->fileGrps)) { |
|
1834 | 1834 | |
1835 | - $this->hasFulltext = TRUE; |
|
1835 | + $this->hasFulltext = TRUE; |
|
1836 | 1836 | |
1837 | - } |
|
1837 | + } |
|
1838 | 1838 | |
1839 | - $this->fileGrpsLoaded = TRUE; |
|
1839 | + $this->fileGrpsLoaded = TRUE; |
|
1840 | 1840 | |
1841 | - } |
|
1841 | + } |
|
1842 | 1842 | |
1843 | - return $this->fileGrps; |
|
1843 | + return $this->fileGrps; |
|
1844 | 1844 | |
1845 | - } |
|
1845 | + } |
|
1846 | 1846 | |
1847 | - /** |
|
1848 | - * This returns $this->hasFulltext via __get() |
|
1849 | - * |
|
1850 | - * @access protected |
|
1851 | - * |
|
1852 | - * @return boolean Are there any fulltext files available? |
|
1853 | - */ |
|
1854 | - protected function _getHasFulltext() { |
|
1847 | + /** |
|
1848 | + * This returns $this->hasFulltext via __get() |
|
1849 | + * |
|
1850 | + * @access protected |
|
1851 | + * |
|
1852 | + * @return boolean Are there any fulltext files available? |
|
1853 | + */ |
|
1854 | + protected function _getHasFulltext() { |
|
1855 | 1855 | |
1856 | - // Are the fileGrps already loaded? |
|
1857 | - if (!$this->fileGrpsLoaded) { |
|
1856 | + // Are the fileGrps already loaded? |
|
1857 | + if (!$this->fileGrpsLoaded) { |
|
1858 | 1858 | |
1859 | - $this->_getFileGrps(); |
|
1859 | + $this->_getFileGrps(); |
|
1860 | 1860 | |
1861 | - } |
|
1861 | + } |
|
1862 | 1862 | |
1863 | - return $this->hasFulltext; |
|
1863 | + return $this->hasFulltext; |
|
1864 | 1864 | |
1865 | - } |
|
1865 | + } |
|
1866 | 1866 | |
1867 | - /** |
|
1868 | - * This returns $this->location via __get() |
|
1869 | - * |
|
1870 | - * @access protected |
|
1871 | - * |
|
1872 | - * @return string The location of the document |
|
1873 | - */ |
|
1874 | - protected function _getLocation() { |
|
1867 | + /** |
|
1868 | + * This returns $this->location via __get() |
|
1869 | + * |
|
1870 | + * @access protected |
|
1871 | + * |
|
1872 | + * @return string The location of the document |
|
1873 | + */ |
|
1874 | + protected function _getLocation() { |
|
1875 | 1875 | |
1876 | - return $this->location; |
|
1876 | + return $this->location; |
|
1877 | 1877 | |
1878 | - } |
|
1878 | + } |
|
1879 | 1879 | |
1880 | - /** |
|
1881 | - * This builds an array of the document's metadata |
|
1882 | - * |
|
1883 | - * @access protected |
|
1884 | - * |
|
1885 | - * @return array Array of metadata with their corresponding logical structure node ID as key |
|
1886 | - */ |
|
1887 | - protected function _getMetadataArray() { |
|
1880 | + /** |
|
1881 | + * This builds an array of the document's metadata |
|
1882 | + * |
|
1883 | + * @access protected |
|
1884 | + * |
|
1885 | + * @return array Array of metadata with their corresponding logical structure node ID as key |
|
1886 | + */ |
|
1887 | + protected function _getMetadataArray() { |
|
1888 | 1888 | |
1889 | - // Set metadata definitions' PID. |
|
1890 | - $cPid = ($this->cPid ? $this->cPid : $this->pid); |
|
1889 | + // Set metadata definitions' PID. |
|
1890 | + $cPid = ($this->cPid ? $this->cPid : $this->pid); |
|
1891 | 1891 | |
1892 | - if (!$cPid) { |
|
1892 | + if (!$cPid) { |
|
1893 | 1893 | |
1894 | - if (TYPO3_DLOG) { |
|
1894 | + if (TYPO3_DLOG) { |
|
1895 | 1895 | |
1896 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadataArray()] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1896 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->getMetadataArray()] Invalid PID "'.$cPid.'" for metadata definitions', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1897 | 1897 | |
1898 | - } |
|
1898 | + } |
|
1899 | 1899 | |
1900 | - return array (); |
|
1900 | + return array (); |
|
1901 | 1901 | |
1902 | - } |
|
1902 | + } |
|
1903 | 1903 | |
1904 | - if (!$this->metadataArrayLoaded || $this->metadataArray[0] != $cPid) { |
|
1904 | + if (!$this->metadataArrayLoaded || $this->metadataArray[0] != $cPid) { |
|
1905 | 1905 | |
1906 | - // Get all logical structure nodes with metadata. |
|
1907 | - if (($ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'))) { |
|
1906 | + // Get all logical structure nodes with metadata. |
|
1907 | + if (($ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID'))) { |
|
1908 | 1908 | |
1909 | - foreach ($ids as $id) { |
|
1909 | + foreach ($ids as $id) { |
|
1910 | 1910 | |
1911 | - $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid); |
|
1911 | + $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid); |
|
1912 | 1912 | |
1913 | - } |
|
1913 | + } |
|
1914 | 1914 | |
1915 | - } |
|
1915 | + } |
|
1916 | 1916 | |
1917 | - // Set current PID for metadata definitions. |
|
1918 | - $this->metadataArray[0] = $cPid; |
|
1917 | + // Set current PID for metadata definitions. |
|
1918 | + $this->metadataArray[0] = $cPid; |
|
1919 | 1919 | |
1920 | - $this->metadataArrayLoaded = TRUE; |
|
1920 | + $this->metadataArrayLoaded = TRUE; |
|
1921 | 1921 | |
1922 | - } |
|
1922 | + } |
|
1923 | 1923 | |
1924 | - return $this->metadataArray; |
|
1924 | + return $this->metadataArray; |
|
1925 | 1925 | |
1926 | - } |
|
1926 | + } |
|
1927 | 1927 | |
1928 | - /** |
|
1929 | - * This returns $this->mets via __get() |
|
1930 | - * |
|
1931 | - * @access protected |
|
1932 | - * |
|
1933 | - * @return SimpleXMLElement The XML's METS part as SimpleXMLElement object |
|
1934 | - */ |
|
1935 | - protected function _getMets() { |
|
1928 | + /** |
|
1929 | + * This returns $this->mets via __get() |
|
1930 | + * |
|
1931 | + * @access protected |
|
1932 | + * |
|
1933 | + * @return SimpleXMLElement The XML's METS part as SimpleXMLElement object |
|
1934 | + */ |
|
1935 | + protected function _getMets() { |
|
1936 | 1936 | |
1937 | - return $this->mets; |
|
1937 | + return $this->mets; |
|
1938 | 1938 | |
1939 | - } |
|
1939 | + } |
|
1940 | 1940 | |
1941 | - /** |
|
1942 | - * This returns $this->numPages via __get() |
|
1943 | - * |
|
1944 | - * @access protected |
|
1945 | - * |
|
1946 | - * @return integer The total number of pages and/or tracks |
|
1947 | - */ |
|
1948 | - protected function _getNumPages() { |
|
1941 | + /** |
|
1942 | + * This returns $this->numPages via __get() |
|
1943 | + * |
|
1944 | + * @access protected |
|
1945 | + * |
|
1946 | + * @return integer The total number of pages and/or tracks |
|
1947 | + */ |
|
1948 | + protected function _getNumPages() { |
|
1949 | 1949 | |
1950 | - $this->_getPhysicalStructure(); |
|
1950 | + $this->_getPhysicalStructure(); |
|
1951 | 1951 | |
1952 | - return $this->numPages; |
|
1952 | + return $this->numPages; |
|
1953 | 1953 | |
1954 | - } |
|
1954 | + } |
|
1955 | 1955 | |
1956 | - /** |
|
1957 | - * This returns $this->parentId via __get() |
|
1958 | - * |
|
1959 | - * @access protected |
|
1960 | - * |
|
1961 | - * @return integer The UID of the parent document or zero if not applicable |
|
1962 | - */ |
|
1963 | - protected function _getParentId() { |
|
1956 | + /** |
|
1957 | + * This returns $this->parentId via __get() |
|
1958 | + * |
|
1959 | + * @access protected |
|
1960 | + * |
|
1961 | + * @return integer The UID of the parent document or zero if not applicable |
|
1962 | + */ |
|
1963 | + protected function _getParentId() { |
|
1964 | 1964 | |
1965 | - return $this->parentId; |
|
1965 | + return $this->parentId; |
|
1966 | 1966 | |
1967 | - } |
|
1967 | + } |
|
1968 | 1968 | |
1969 | - /** |
|
1970 | - * This builds an array of the document's physical structure |
|
1971 | - * |
|
1972 | - * @access protected |
|
1973 | - * |
|
1974 | - * @return array Array of physical elements' id, type, label and file representations ordered by @ORDER attribute |
|
1975 | - */ |
|
1976 | - protected function _getPhysicalStructure() { |
|
1969 | + /** |
|
1970 | + * This builds an array of the document's physical structure |
|
1971 | + * |
|
1972 | + * @access protected |
|
1973 | + * |
|
1974 | + * @return array Array of physical elements' id, type, label and file representations ordered by @ORDER attribute |
|
1975 | + */ |
|
1976 | + protected function _getPhysicalStructure() { |
|
1977 | 1977 | |
1978 | - // Is there no physical structure array yet? |
|
1979 | - if (!$this->physicalStructureLoaded) { |
|
1978 | + // Is there no physical structure array yet? |
|
1979 | + if (!$this->physicalStructureLoaded) { |
|
1980 | 1980 | |
1981 | - // Does the document have a structMap node of type "PHYSICAL"? |
|
1982 | - $elementNodes = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div'); |
|
1981 | + // Does the document have a structMap node of type "PHYSICAL"? |
|
1982 | + $elementNodes = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div'); |
|
1983 | 1983 | |
1984 | - if ($elementNodes) { |
|
1984 | + if ($elementNodes) { |
|
1985 | 1985 | |
1986 | - // Get file groups. |
|
1987 | - $fileUse = $this->_getFileGrps(); |
|
1986 | + // Get file groups. |
|
1987 | + $fileUse = $this->_getFileGrps(); |
|
1988 | 1988 | |
1989 | - // Get the physical sequence's metadata. |
|
1990 | - $physNode = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]'); |
|
1989 | + // Get the physical sequence's metadata. |
|
1990 | + $physNode = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]'); |
|
1991 | 1991 | |
1992 | - $physSeq[0] = (string) $physNode[0]['ID']; |
|
1992 | + $physSeq[0] = (string) $physNode[0]['ID']; |
|
1993 | 1993 | |
1994 | - $this->physicalStructureInfo[$physSeq[0]]['id'] = $physNode[0]['ID']; |
|
1994 | + $this->physicalStructureInfo[$physSeq[0]]['id'] = $physNode[0]['ID']; |
|
1995 | 1995 | |
1996 | - $this->physicalStructureInfo[$physSeq[0]]['dmdId'] = (isset($physNode[0]['DMDID']) ? (string) $physNode[0]['DMDID'] : ''); |
|
1996 | + $this->physicalStructureInfo[$physSeq[0]]['dmdId'] = (isset($physNode[0]['DMDID']) ? (string) $physNode[0]['DMDID'] : ''); |
|
1997 | 1997 | |
1998 | - $this->physicalStructureInfo[$physSeq[0]]['label'] = (isset($physNode[0]['LABEL']) ? (string) $physNode[0]['LABEL'] : ''); |
|
1998 | + $this->physicalStructureInfo[$physSeq[0]]['label'] = (isset($physNode[0]['LABEL']) ? (string) $physNode[0]['LABEL'] : ''); |
|
1999 | 1999 | |
2000 | - $this->physicalStructureInfo[$physSeq[0]]['orderlabel'] = (isset($physNode[0]['ORDERLABEL']) ? (string) $physNode[0]['ORDERLABEL'] : ''); |
|
2000 | + $this->physicalStructureInfo[$physSeq[0]]['orderlabel'] = (isset($physNode[0]['ORDERLABEL']) ? (string) $physNode[0]['ORDERLABEL'] : ''); |
|
2001 | 2001 | |
2002 | - $this->physicalStructureInfo[$physSeq[0]]['type'] = (string) $physNode[0]['TYPE']; |
|
2002 | + $this->physicalStructureInfo[$physSeq[0]]['type'] = (string) $physNode[0]['TYPE']; |
|
2003 | 2003 | |
2004 | - $this->physicalStructureInfo[$physSeq[0]]['contentIds'] = (isset($physNode[0]['CONTENTIDS']) ? (string) $physNode[0]['CONTENTIDS'] : ''); |
|
2004 | + $this->physicalStructureInfo[$physSeq[0]]['contentIds'] = (isset($physNode[0]['CONTENTIDS']) ? (string) $physNode[0]['CONTENTIDS'] : ''); |
|
2005 | 2005 | |
2006 | - // Get the file representations from fileSec node. |
|
2007 | - foreach ($physNode[0]->children('http://www.loc.gov/METS/')->fptr as $fptr) { |
|
2006 | + // Get the file representations from fileSec node. |
|
2007 | + foreach ($physNode[0]->children('http://www.loc.gov/METS/')->fptr as $fptr) { |
|
2008 | 2008 | |
2009 | - // Check if file has valid @USE attribute. |
|
2010 | - if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) { |
|
2009 | + // Check if file has valid @USE attribute. |
|
2010 | + if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) { |
|
2011 | 2011 | |
2012 | - $this->physicalStructureInfo[$physSeq[0]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID; |
|
2012 | + $this->physicalStructureInfo[$physSeq[0]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID; |
|
2013 | 2013 | |
2014 | - } |
|
2014 | + } |
|
2015 | 2015 | |
2016 | - } |
|
2016 | + } |
|
2017 | 2017 | |
2018 | - // Build the physical elements' array from the physical structMap node. |
|
2019 | - foreach ($elementNodes as $elementNode) { |
|
2018 | + // Build the physical elements' array from the physical structMap node. |
|
2019 | + foreach ($elementNodes as $elementNode) { |
|
2020 | 2020 | |
2021 | - $elements[(int) $elementNode['ORDER']] = (string) $elementNode['ID']; |
|
2021 | + $elements[(int) $elementNode['ORDER']] = (string) $elementNode['ID']; |
|
2022 | 2022 | |
2023 | - $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['id'] = $elementNode['ID']; |
|
2023 | + $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['id'] = $elementNode['ID']; |
|
2024 | 2024 | |
2025 | - $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['dmdId'] = (isset($elementNode['DMDID']) ? (string) $elementNode['DMDID'] : ''); |
|
2025 | + $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['dmdId'] = (isset($elementNode['DMDID']) ? (string) $elementNode['DMDID'] : ''); |
|
2026 | 2026 | |
2027 | - $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['label'] = (isset($elementNode['LABEL']) ? (string) $elementNode['LABEL'] : ''); |
|
2027 | + $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['label'] = (isset($elementNode['LABEL']) ? (string) $elementNode['LABEL'] : ''); |
|
2028 | 2028 | |
2029 | - $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['orderlabel'] = (isset($elementNode['ORDERLABEL']) ? (string) $elementNode['ORDERLABEL'] : ''); |
|
2029 | + $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['orderlabel'] = (isset($elementNode['ORDERLABEL']) ? (string) $elementNode['ORDERLABEL'] : ''); |
|
2030 | 2030 | |
2031 | - $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['type'] = (string) $elementNode['TYPE']; |
|
2031 | + $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['type'] = (string) $elementNode['TYPE']; |
|
2032 | 2032 | |
2033 | - $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['contentIds'] = (isset($elementNode['CONTENTIDS']) ? (string) $elementNode['CONTENTIDS'] : ''); |
|
2033 | + $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['contentIds'] = (isset($elementNode['CONTENTIDS']) ? (string) $elementNode['CONTENTIDS'] : ''); |
|
2034 | 2034 | |
2035 | - // Get the file representations from fileSec node. |
|
2036 | - foreach ($elementNode->children('http://www.loc.gov/METS/')->fptr as $fptr) { |
|
2035 | + // Get the file representations from fileSec node. |
|
2036 | + foreach ($elementNode->children('http://www.loc.gov/METS/')->fptr as $fptr) { |
|
2037 | 2037 | |
2038 | - // Check if file has valid @USE attribute. |
|
2039 | - if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) { |
|
2038 | + // Check if file has valid @USE attribute. |
|
2039 | + if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) { |
|
2040 | 2040 | |
2041 | - $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID; |
|
2041 | + $this->physicalStructureInfo[$elements[(int) $elementNode['ORDER']]]['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID; |
|
2042 | 2042 | |
2043 | - } |
|
2043 | + } |
|
2044 | 2044 | |
2045 | - } |
|
2045 | + } |
|
2046 | 2046 | |
2047 | - } |
|
2047 | + } |
|
2048 | 2048 | |
2049 | - // Sort array by keys (= @ORDER). |
|
2050 | - if (ksort($elements)) { |
|
2049 | + // Sort array by keys (= @ORDER). |
|
2050 | + if (ksort($elements)) { |
|
2051 | 2051 | |
2052 | - // Set total number of pages/tracks. |
|
2053 | - $this->numPages = count($elements); |
|
2052 | + // Set total number of pages/tracks. |
|
2053 | + $this->numPages = count($elements); |
|
2054 | 2054 | |
2055 | - // Merge and re-index the array to get nice numeric indexes. |
|
2056 | - $this->physicalStructure = array_merge($physSeq, $elements); |
|
2055 | + // Merge and re-index the array to get nice numeric indexes. |
|
2056 | + $this->physicalStructure = array_merge($physSeq, $elements); |
|
2057 | 2057 | |
2058 | - } |
|
2058 | + } |
|
2059 | 2059 | |
2060 | - } |
|
2060 | + } |
|
2061 | 2061 | |
2062 | - $this->physicalStructureLoaded = TRUE; |
|
2062 | + $this->physicalStructureLoaded = TRUE; |
|
2063 | 2063 | |
2064 | - } |
|
2064 | + } |
|
2065 | 2065 | |
2066 | - return $this->physicalStructure; |
|
2066 | + return $this->physicalStructure; |
|
2067 | 2067 | |
2068 | - } |
|
2068 | + } |
|
2069 | 2069 | |
2070 | - /** |
|
2071 | - * This gives an array of the document's physical structure metadata |
|
2072 | - * |
|
2073 | - * @access protected |
|
2074 | - * |
|
2075 | - * @return array Array of elements' type, label and file representations ordered by @ID attribute |
|
2076 | - */ |
|
2077 | - protected function _getPhysicalStructureInfo() { |
|
2070 | + /** |
|
2071 | + * This gives an array of the document's physical structure metadata |
|
2072 | + * |
|
2073 | + * @access protected |
|
2074 | + * |
|
2075 | + * @return array Array of elements' type, label and file representations ordered by @ID attribute |
|
2076 | + */ |
|
2077 | + protected function _getPhysicalStructureInfo() { |
|
2078 | 2078 | |
2079 | - // Is there no physical structure array yet? |
|
2080 | - if (!$this->physicalStructureLoaded) { |
|
2079 | + // Is there no physical structure array yet? |
|
2080 | + if (!$this->physicalStructureLoaded) { |
|
2081 | 2081 | |
2082 | - // Build physical structure array. |
|
2083 | - $this->_getPhysicalStructure(); |
|
2082 | + // Build physical structure array. |
|
2083 | + $this->_getPhysicalStructure(); |
|
2084 | 2084 | |
2085 | - } |
|
2085 | + } |
|
2086 | 2086 | |
2087 | - return $this->physicalStructureInfo; |
|
2087 | + return $this->physicalStructureInfo; |
|
2088 | 2088 | |
2089 | - } |
|
2089 | + } |
|
2090 | 2090 | |
2091 | - /** |
|
2092 | - * This returns $this->pid via __get() |
|
2093 | - * |
|
2094 | - * @access protected |
|
2095 | - * |
|
2096 | - * @return integer The PID of the document or zero if not in database |
|
2097 | - */ |
|
2098 | - protected function _getPid() { |
|
2091 | + /** |
|
2092 | + * This returns $this->pid via __get() |
|
2093 | + * |
|
2094 | + * @access protected |
|
2095 | + * |
|
2096 | + * @return integer The PID of the document or zero if not in database |
|
2097 | + */ |
|
2098 | + protected function _getPid() { |
|
2099 | 2099 | |
2100 | - return $this->pid; |
|
2100 | + return $this->pid; |
|
2101 | 2101 | |
2102 | - } |
|
2102 | + } |
|
2103 | 2103 | |
2104 | - /** |
|
2105 | - * This returns $this->ready via __get() |
|
2106 | - * |
|
2107 | - * @access protected |
|
2108 | - * |
|
2109 | - * @return boolean Is the document instantiated successfully? |
|
2110 | - */ |
|
2111 | - protected function _getReady() { |
|
2104 | + /** |
|
2105 | + * This returns $this->ready via __get() |
|
2106 | + * |
|
2107 | + * @access protected |
|
2108 | + * |
|
2109 | + * @return boolean Is the document instantiated successfully? |
|
2110 | + */ |
|
2111 | + protected function _getReady() { |
|
2112 | 2112 | |
2113 | - return $this->ready; |
|
2113 | + return $this->ready; |
|
2114 | 2114 | |
2115 | - } |
|
2115 | + } |
|
2116 | 2116 | |
2117 | - /** |
|
2118 | - * This returns $this->recordId via __get() |
|
2119 | - * |
|
2120 | - * @access protected |
|
2121 | - * |
|
2122 | - * @return mixed The METS file's record identifier |
|
2123 | - */ |
|
2124 | - protected function _getRecordId() { |
|
2117 | + /** |
|
2118 | + * This returns $this->recordId via __get() |
|
2119 | + * |
|
2120 | + * @access protected |
|
2121 | + * |
|
2122 | + * @return mixed The METS file's record identifier |
|
2123 | + */ |
|
2124 | + protected function _getRecordId() { |
|
2125 | 2125 | |
2126 | - return $this->recordId; |
|
2126 | + return $this->recordId; |
|
2127 | 2127 | |
2128 | - } |
|
2128 | + } |
|
2129 | 2129 | |
2130 | - /** |
|
2131 | - * This returns $this->rootId via __get() |
|
2132 | - * |
|
2133 | - * @access protected |
|
2134 | - * |
|
2135 | - * @return integer The UID of the root document or zero if not applicable |
|
2136 | - */ |
|
2137 | - protected function _getRootId() { |
|
2130 | + /** |
|
2131 | + * This returns $this->rootId via __get() |
|
2132 | + * |
|
2133 | + * @access protected |
|
2134 | + * |
|
2135 | + * @return integer The UID of the root document or zero if not applicable |
|
2136 | + */ |
|
2137 | + protected function _getRootId() { |
|
2138 | 2138 | |
2139 | - if (!$this->rootIdLoaded) { |
|
2139 | + if (!$this->rootIdLoaded) { |
|
2140 | 2140 | |
2141 | - if ($this->parentId) { |
|
2141 | + if ($this->parentId) { |
|
2142 | 2142 | |
2143 | - $parent = self::getInstance($this->parentId, $this->pid); |
|
2143 | + $parent = self::getInstance($this->parentId, $this->pid); |
|
2144 | 2144 | |
2145 | - $this->rootId = $parent->rootId; |
|
2145 | + $this->rootId = $parent->rootId; |
|
2146 | 2146 | |
2147 | - } |
|
2147 | + } |
|
2148 | 2148 | |
2149 | - $this->rootIdLoaded = TRUE; |
|
2149 | + $this->rootIdLoaded = TRUE; |
|
2150 | 2150 | |
2151 | - } |
|
2151 | + } |
|
2152 | 2152 | |
2153 | - return $this->rootId; |
|
2153 | + return $this->rootId; |
|
2154 | 2154 | |
2155 | - } |
|
2155 | + } |
|
2156 | 2156 | |
2157 | - /** |
|
2158 | - * This returns the smLinks between logical and physical structMap |
|
2159 | - * |
|
2160 | - * @access protected |
|
2161 | - * |
|
2162 | - * @return array The links between logical and physical nodes |
|
2163 | - */ |
|
2164 | - protected function _getSmLinks() { |
|
2157 | + /** |
|
2158 | + * This returns the smLinks between logical and physical structMap |
|
2159 | + * |
|
2160 | + * @access protected |
|
2161 | + * |
|
2162 | + * @return array The links between logical and physical nodes |
|
2163 | + */ |
|
2164 | + protected function _getSmLinks() { |
|
2165 | 2165 | |
2166 | - if (!$this->smLinksLoaded) { |
|
2166 | + if (!$this->smLinksLoaded) { |
|
2167 | 2167 | |
2168 | - $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
|
2168 | + $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink'); |
|
2169 | 2169 | |
2170 | - foreach ($smLinks as $smLink) { |
|
2170 | + foreach ($smLinks as $smLink) { |
|
2171 | 2171 | |
2172 | - $this->smLinks['l2p'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->from][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->to; |
|
2172 | + $this->smLinks['l2p'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->from][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->to; |
|
2173 | 2173 | |
2174 | - $this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from; |
|
2174 | + $this->smLinks['p2l'][(string) $smLink->attributes('http://www.w3.org/1999/xlink')->to][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->from; |
|
2175 | 2175 | |
2176 | - } |
|
2176 | + } |
|
2177 | 2177 | |
2178 | - $this->smLinksLoaded = TRUE; |
|
2178 | + $this->smLinksLoaded = TRUE; |
|
2179 | 2179 | |
2180 | - } |
|
2180 | + } |
|
2181 | 2181 | |
2182 | - return $this->smLinks; |
|
2182 | + return $this->smLinks; |
|
2183 | 2183 | |
2184 | - } |
|
2184 | + } |
|
2185 | 2185 | |
2186 | - /** |
|
2187 | - * This builds an array of the document's logical structure |
|
2188 | - * |
|
2189 | - * @access protected |
|
2190 | - * |
|
2191 | - * @return array Array of structure nodes' id, label, type and physical page indexes/mptr link with original hierarchy preserved |
|
2192 | - */ |
|
2193 | - protected function _getTableOfContents() { |
|
2186 | + /** |
|
2187 | + * This builds an array of the document's logical structure |
|
2188 | + * |
|
2189 | + * @access protected |
|
2190 | + * |
|
2191 | + * @return array Array of structure nodes' id, label, type and physical page indexes/mptr link with original hierarchy preserved |
|
2192 | + */ |
|
2193 | + protected function _getTableOfContents() { |
|
2194 | 2194 | |
2195 | - // Is there no logical structure array yet? |
|
2196 | - if (!$this->tableOfContentsLoaded) { |
|
2195 | + // Is there no logical structure array yet? |
|
2196 | + if (!$this->tableOfContentsLoaded) { |
|
2197 | 2197 | |
2198 | - // Get all logical structures. |
|
2199 | - $this->getLogicalStructure('', TRUE); |
|
2198 | + // Get all logical structures. |
|
2199 | + $this->getLogicalStructure('', TRUE); |
|
2200 | 2200 | |
2201 | - $this->tableOfContentsLoaded = TRUE; |
|
2201 | + $this->tableOfContentsLoaded = TRUE; |
|
2202 | 2202 | |
2203 | - } |
|
2203 | + } |
|
2204 | 2204 | |
2205 | - return $this->tableOfContents; |
|
2205 | + return $this->tableOfContents; |
|
2206 | 2206 | |
2207 | - } |
|
2207 | + } |
|
2208 | 2208 | |
2209 | - /** |
|
2210 | - * This returns the document's thumbnail location |
|
2211 | - * |
|
2212 | - * @access protected |
|
2213 | - * |
|
2214 | - * @param boolean $forceReload: Force reloading the thumbnail instead of returning the cached value |
|
2215 | - * |
|
2216 | - * @return string The document's thumbnail location |
|
2217 | - */ |
|
2218 | - protected function _getThumbnail($forceReload = FALSE) { |
|
2209 | + /** |
|
2210 | + * This returns the document's thumbnail location |
|
2211 | + * |
|
2212 | + * @access protected |
|
2213 | + * |
|
2214 | + * @param boolean $forceReload: Force reloading the thumbnail instead of returning the cached value |
|
2215 | + * |
|
2216 | + * @return string The document's thumbnail location |
|
2217 | + */ |
|
2218 | + protected function _getThumbnail($forceReload = FALSE) { |
|
2219 | 2219 | |
2220 | - if (!$this->thumbnailLoaded || $forceReload) { |
|
2220 | + if (!$this->thumbnailLoaded || $forceReload) { |
|
2221 | 2221 | |
2222 | - // Retain current PID. |
|
2223 | - $cPid = ($this->cPid ? $this->cPid : $this->pid); |
|
2222 | + // Retain current PID. |
|
2223 | + $cPid = ($this->cPid ? $this->cPid : $this->pid); |
|
2224 | 2224 | |
2225 | - if (!$cPid) { |
|
2225 | + if (!$cPid) { |
|
2226 | 2226 | |
2227 | - if (TYPO3_DLOG) { |
|
2227 | + if (TYPO3_DLOG) { |
|
2228 | 2228 | |
2229 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] Invalid PID "'.$cPid.'" for structure definitions', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
2229 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] Invalid PID "'.$cPid.'" for structure definitions', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
2230 | 2230 | |
2231 | - } |
|
2231 | + } |
|
2232 | 2232 | |
2233 | - $this->thumbnailLoaded = TRUE; |
|
2233 | + $this->thumbnailLoaded = TRUE; |
|
2234 | 2234 | |
2235 | - return $this->thumbnail; |
|
2235 | + return $this->thumbnail; |
|
2236 | 2236 | |
2237 | - } |
|
2237 | + } |
|
2238 | 2238 | |
2239 | - // Load extension configuration. |
|
2240 | - $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
2239 | + // Load extension configuration. |
|
2240 | + $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
2241 | 2241 | |
2242 | - if (empty($extConf['fileGrpThumbs'])) { |
|
2242 | + if (empty($extConf['fileGrpThumbs'])) { |
|
2243 | 2243 | |
2244 | - if (TYPO3_DLOG) { |
|
2244 | + if (TYPO3_DLOG) { |
|
2245 | 2245 | |
2246 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] No fileGrp for thumbnails specified', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
2246 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->_getThumbnail()] No fileGrp for thumbnails specified', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
2247 | 2247 | |
2248 | - } |
|
2248 | + } |
|
2249 | 2249 | |
2250 | - $this->thumbnailLoaded = TRUE; |
|
2250 | + $this->thumbnailLoaded = TRUE; |
|
2251 | 2251 | |
2252 | - return $this->thumbnail; |
|
2252 | + return $this->thumbnail; |
|
2253 | 2253 | |
2254 | - } |
|
2254 | + } |
|
2255 | 2255 | |
2256 | - $strctId = $this->_getToplevelId(); |
|
2256 | + $strctId = $this->_getToplevelId(); |
|
2257 | 2257 | |
2258 | - $metadata = $this->getTitledata($cPid); |
|
2258 | + $metadata = $this->getTitledata($cPid); |
|
2259 | 2259 | |
2260 | - // Get structure element to get thumbnail from. |
|
2261 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
2262 | - 'tx_dlf_structures.thumbnail AS thumbnail', |
|
2263 | - 'tx_dlf_structures', |
|
2264 | - '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'), |
|
2265 | - '', |
|
2266 | - '', |
|
2267 | - '1' |
|
2268 | - ); |
|
2260 | + // Get structure element to get thumbnail from. |
|
2261 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
2262 | + 'tx_dlf_structures.thumbnail AS thumbnail', |
|
2263 | + 'tx_dlf_structures', |
|
2264 | + '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'), |
|
2265 | + '', |
|
2266 | + '', |
|
2267 | + '1' |
|
2268 | + ); |
|
2269 | 2269 | |
2270 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
2270 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
2271 | 2271 | |
2272 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
2272 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
2273 | 2273 | |
2274 | - // Get desired thumbnail structure if not the toplevel structure itself. |
|
2275 | - if (!empty($resArray['thumbnail'])) { |
|
2274 | + // Get desired thumbnail structure if not the toplevel structure itself. |
|
2275 | + if (!empty($resArray['thumbnail'])) { |
|
2276 | 2276 | |
2277 | - $strctType = tx_dlf_helper::getIndexName($resArray['thumbnail'], 'tx_dlf_structures', $cPid); |
|
2277 | + $strctType = tx_dlf_helper::getIndexName($resArray['thumbnail'], 'tx_dlf_structures', $cPid); |
|
2278 | 2278 | |
2279 | - // Check if this document has a structure element of the desired type. |
|
2280 | - $strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="'.$strctType.'"]/@ID'); |
|
2279 | + // Check if this document has a structure element of the desired type. |
|
2280 | + $strctIds = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@TYPE="'.$strctType.'"]/@ID'); |
|
2281 | 2281 | |
2282 | - if (!empty($strctIds)) { |
|
2282 | + if (!empty($strctIds)) { |
|
2283 | 2283 | |
2284 | - $strctId = (string) $strctIds[0]; |
|
2284 | + $strctId = (string) $strctIds[0]; |
|
2285 | 2285 | |
2286 | - } |
|
2286 | + } |
|
2287 | 2287 | |
2288 | - } |
|
2288 | + } |
|
2289 | 2289 | |
2290 | - // Load smLinks. |
|
2291 | - $this->_getSmLinks(); |
|
2290 | + // Load smLinks. |
|
2291 | + $this->_getSmLinks(); |
|
2292 | 2292 | |
2293 | - // Get thumbnail location. |
|
2294 | - if ($this->_getPhysicalStructure() && !empty($this->smLinks['l2p'][$strctId])) { |
|
2293 | + // Get thumbnail location. |
|
2294 | + if ($this->_getPhysicalStructure() && !empty($this->smLinks['l2p'][$strctId])) { |
|
2295 | 2295 | |
2296 | - $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$extConf['fileGrpThumbs']]); |
|
2296 | + $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$extConf['fileGrpThumbs']]); |
|
2297 | 2297 | |
2298 | - } else { |
|
2298 | + } else { |
|
2299 | 2299 | |
2300 | - $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']]); |
|
2300 | + $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']]); |
|
2301 | 2301 | |
2302 | - } |
|
2302 | + } |
|
2303 | 2303 | |
2304 | - } elseif (TYPO3_DLOG) { |
|
2304 | + } elseif (TYPO3_DLOG) { |
|
2305 | 2305 | |
2306 | - \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); |
|
2306 | + \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); |
|
2307 | 2307 | |
2308 | - } |
|
2308 | + } |
|
2309 | 2309 | |
2310 | - $this->thumbnailLoaded = TRUE; |
|
2310 | + $this->thumbnailLoaded = TRUE; |
|
2311 | 2311 | |
2312 | - } |
|
2312 | + } |
|
2313 | 2313 | |
2314 | - return $this->thumbnail; |
|
2314 | + return $this->thumbnail; |
|
2315 | 2315 | |
2316 | - } |
|
2316 | + } |
|
2317 | 2317 | |
2318 | - /** |
|
2319 | - * This returns the ID of the toplevel logical structure node |
|
2320 | - * |
|
2321 | - * @access protected |
|
2322 | - * |
|
2323 | - * @return string The logical structure node's ID |
|
2324 | - */ |
|
2325 | - protected function _getToplevelId() { |
|
2318 | + /** |
|
2319 | + * This returns the ID of the toplevel logical structure node |
|
2320 | + * |
|
2321 | + * @access protected |
|
2322 | + * |
|
2323 | + * @return string The logical structure node's ID |
|
2324 | + */ |
|
2325 | + protected function _getToplevelId() { |
|
2326 | 2326 | |
2327 | - if (empty($this->toplevelId)) { |
|
2327 | + if (empty($this->toplevelId)) { |
|
2328 | 2328 | |
2329 | - // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
|
2330 | - if (($divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) { |
|
2329 | + // Get all logical structure nodes with metadata, but without associated METS-Pointers. |
|
2330 | + if (($divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) { |
|
2331 | 2331 | |
2332 | - // Load smLinks. |
|
2333 | - $this->_getSmLinks(); |
|
2332 | + // Load smLinks. |
|
2333 | + $this->_getSmLinks(); |
|
2334 | 2334 | |
2335 | - foreach ($divs as $div) { |
|
2335 | + foreach ($divs as $div) { |
|
2336 | 2336 | |
2337 | - $id = (string) $div['ID']; |
|
2337 | + $id = (string) $div['ID']; |
|
2338 | 2338 | |
2339 | - // Are there physical structure nodes for this logical structure? |
|
2340 | - if (array_key_exists($id, $this->smLinks['l2p'])) { |
|
2339 | + // Are there physical structure nodes for this logical structure? |
|
2340 | + if (array_key_exists($id, $this->smLinks['l2p'])) { |
|
2341 | 2341 | |
2342 | - // Yes. That's what we're looking for. |
|
2343 | - $this->toplevelId = $id; |
|
2342 | + // Yes. That's what we're looking for. |
|
2343 | + $this->toplevelId = $id; |
|
2344 | 2344 | |
2345 | - break; |
|
2345 | + break; |
|
2346 | 2346 | |
2347 | - } elseif (empty($this->toplevelId)) { |
|
2347 | + } elseif (empty($this->toplevelId)) { |
|
2348 | 2348 | |
2349 | - // No. Remember this anyway, but keep looking for a better one. |
|
2350 | - $this->toplevelId = $id; |
|
2349 | + // No. Remember this anyway, but keep looking for a better one. |
|
2350 | + $this->toplevelId = $id; |
|
2351 | 2351 | |
2352 | - } |
|
2352 | + } |
|
2353 | 2353 | |
2354 | - } |
|
2354 | + } |
|
2355 | 2355 | |
2356 | - } |
|
2356 | + } |
|
2357 | 2357 | |
2358 | - } |
|
2358 | + } |
|
2359 | 2359 | |
2360 | - return $this->toplevelId; |
|
2360 | + return $this->toplevelId; |
|
2361 | 2361 | |
2362 | - } |
|
2362 | + } |
|
2363 | 2363 | |
2364 | - /** |
|
2365 | - * This returns $this->uid via __get() |
|
2366 | - * |
|
2367 | - * @access protected |
|
2368 | - * |
|
2369 | - * @return mixed The UID or the URL of the document |
|
2370 | - */ |
|
2371 | - protected function _getUid() { |
|
2364 | + /** |
|
2365 | + * This returns $this->uid via __get() |
|
2366 | + * |
|
2367 | + * @access protected |
|
2368 | + * |
|
2369 | + * @return mixed The UID or the URL of the document |
|
2370 | + */ |
|
2371 | + protected function _getUid() { |
|
2372 | 2372 | |
2373 | - return $this->uid; |
|
2373 | + return $this->uid; |
|
2374 | 2374 | |
2375 | - } |
|
2375 | + } |
|
2376 | 2376 | |
2377 | - /** |
|
2378 | - * This sets $this->cPid via __set() |
|
2379 | - * |
|
2380 | - * @access protected |
|
2381 | - * |
|
2382 | - * @param integer $value: The new PID for the metadata definitions |
|
2383 | - * |
|
2384 | - * @return void |
|
2385 | - */ |
|
2386 | - protected function _setCPid($value) { |
|
2377 | + /** |
|
2378 | + * This sets $this->cPid via __set() |
|
2379 | + * |
|
2380 | + * @access protected |
|
2381 | + * |
|
2382 | + * @param integer $value: The new PID for the metadata definitions |
|
2383 | + * |
|
2384 | + * @return void |
|
2385 | + */ |
|
2386 | + protected function _setCPid($value) { |
|
2387 | 2387 | |
2388 | - $this->cPid = max(intval($value), 0); |
|
2388 | + $this->cPid = max(intval($value), 0); |
|
2389 | 2389 | |
2390 | - } |
|
2390 | + } |
|
2391 | 2391 | |
2392 | - /** |
|
2393 | - * This magic method is invoked each time a clone is called on the object variable |
|
2394 | - * (This method is defined as private/protected because singleton objects should not be cloned) |
|
2395 | - * |
|
2396 | - * @access protected |
|
2397 | - * |
|
2398 | - * @return void |
|
2399 | - */ |
|
2400 | - protected function __clone() {} |
|
2392 | + /** |
|
2393 | + * This magic method is invoked each time a clone is called on the object variable |
|
2394 | + * (This method is defined as private/protected because singleton objects should not be cloned) |
|
2395 | + * |
|
2396 | + * @access protected |
|
2397 | + * |
|
2398 | + * @return void |
|
2399 | + */ |
|
2400 | + protected function __clone() {} |
|
2401 | 2401 | |
2402 | - /** |
|
2403 | - * This is a singleton class, thus the constructor should be private/protected |
|
2404 | - * |
|
2405 | - * @access protected |
|
2406 | - * |
|
2407 | - * @param integer $uid: The UID of the document to parse or URL to XML file |
|
2408 | - * @param integer $pid: If > 0, then only document with this PID gets loaded |
|
2409 | - * |
|
2410 | - * @return void |
|
2411 | - */ |
|
2412 | - protected function __construct($uid, $pid) { |
|
2402 | + /** |
|
2403 | + * This is a singleton class, thus the constructor should be private/protected |
|
2404 | + * |
|
2405 | + * @access protected |
|
2406 | + * |
|
2407 | + * @param integer $uid: The UID of the document to parse or URL to XML file |
|
2408 | + * @param integer $pid: If > 0, then only document with this PID gets loaded |
|
2409 | + * |
|
2410 | + * @return void |
|
2411 | + */ |
|
2412 | + protected function __construct($uid, $pid) { |
|
2413 | 2413 | |
2414 | - // Prepare to check database for the requested document. |
|
2415 | - if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($uid)) { |
|
2414 | + // Prepare to check database for the requested document. |
|
2415 | + if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($uid)) { |
|
2416 | 2416 | |
2417 | - $whereClause = 'tx_dlf_documents.uid='.intval($uid).tx_dlf_helper::whereClause('tx_dlf_documents'); |
|
2417 | + $whereClause = 'tx_dlf_documents.uid='.intval($uid).tx_dlf_helper::whereClause('tx_dlf_documents'); |
|
2418 | 2418 | |
2419 | - } else { |
|
2419 | + } else { |
|
2420 | 2420 | |
2421 | - // Cast to string for safety reasons. |
|
2422 | - $location = (string) $uid; |
|
2421 | + // Cast to string for safety reasons. |
|
2422 | + $location = (string) $uid; |
|
2423 | 2423 | |
2424 | - // Try to load METS file. |
|
2425 | - if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location) && $this->load($location)) { |
|
2424 | + // Try to load METS file. |
|
2425 | + if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location) && $this->load($location)) { |
|
2426 | 2426 | |
2427 | - // Initialize core METS object. |
|
2428 | - $this->init(); |
|
2427 | + // Initialize core METS object. |
|
2428 | + $this->init(); |
|
2429 | 2429 | |
2430 | - if ($this->mets !== NULL) { |
|
2430 | + if ($this->mets !== NULL) { |
|
2431 | 2431 | |
2432 | - // Check for METS object @ID. |
|
2433 | - if (!empty($this->mets['OBJID'])) { |
|
2432 | + // Check for METS object @ID. |
|
2433 | + if (!empty($this->mets['OBJID'])) { |
|
2434 | 2434 | |
2435 | - $this->recordId = (string) $this->mets['OBJID']; |
|
2435 | + $this->recordId = (string) $this->mets['OBJID']; |
|
2436 | 2436 | |
2437 | - } |
|
2437 | + } |
|
2438 | 2438 | |
2439 | - // Get hook objects. |
|
2440 | - $hookObjects = tx_dlf_helper::getHookObjects('common/class.tx_dlf_document.php'); |
|
2439 | + // Get hook objects. |
|
2440 | + $hookObjects = tx_dlf_helper::getHookObjects('common/class.tx_dlf_document.php'); |
|
2441 | 2441 | |
2442 | - // Apply hooks. |
|
2443 | - foreach ($hookObjects as $hookObj) { |
|
2442 | + // Apply hooks. |
|
2443 | + foreach ($hookObjects as $hookObj) { |
|
2444 | 2444 | |
2445 | - if (method_exists($hookObj, 'construct_postProcessRecordId')) { |
|
2445 | + if (method_exists($hookObj, 'construct_postProcessRecordId')) { |
|
2446 | 2446 | |
2447 | - $hookObj->construct_postProcessRecordId($this->xml, $this->recordId); |
|
2447 | + $hookObj->construct_postProcessRecordId($this->xml, $this->recordId); |
|
2448 | 2448 | |
2449 | - } |
|
2449 | + } |
|
2450 | 2450 | |
2451 | - } |
|
2451 | + } |
|
2452 | 2452 | |
2453 | - } else { |
|
2453 | + } else { |
|
2454 | 2454 | |
2455 | - // No METS part found. |
|
2456 | - return; |
|
2455 | + // No METS part found. |
|
2456 | + return; |
|
2457 | 2457 | |
2458 | - } |
|
2458 | + } |
|
2459 | 2459 | |
2460 | - } else { |
|
2460 | + } else { |
|
2461 | 2461 | |
2462 | - // Loading failed. |
|
2463 | - return; |
|
2462 | + // Loading failed. |
|
2463 | + return; |
|
2464 | 2464 | |
2465 | - } |
|
2465 | + } |
|
2466 | 2466 | |
2467 | - if (!empty($this->recordId)) { |
|
2467 | + if (!empty($this->recordId)) { |
|
2468 | 2468 | |
2469 | - $whereClause = 'tx_dlf_documents.record_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->recordId, 'tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_documents'); |
|
2469 | + $whereClause = 'tx_dlf_documents.record_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->recordId, 'tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_documents'); |
|
2470 | 2470 | |
2471 | - } else { |
|
2471 | + } else { |
|
2472 | 2472 | |
2473 | - // There is no record identifier and there should be no hit in the database. |
|
2474 | - $whereClause = '1=-1'; |
|
2473 | + // There is no record identifier and there should be no hit in the database. |
|
2474 | + $whereClause = '1=-1'; |
|
2475 | 2475 | |
2476 | - } |
|
2476 | + } |
|
2477 | 2477 | |
2478 | - } |
|
2478 | + } |
|
2479 | 2479 | |
2480 | - // Check for PID if needed. |
|
2481 | - if ($pid) { |
|
2480 | + // Check for PID if needed. |
|
2481 | + if ($pid) { |
|
2482 | 2482 | |
2483 | - $whereClause .= ' AND tx_dlf_documents.pid='.intval($pid); |
|
2483 | + $whereClause .= ' AND tx_dlf_documents.pid='.intval($pid); |
|
2484 | 2484 | |
2485 | - } |
|
2485 | + } |
|
2486 | 2486 | |
2487 | - // Get document PID and location from database. |
|
2488 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
2489 | - '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', |
|
2490 | - 'tx_dlf_documents', |
|
2491 | - $whereClause, |
|
2492 | - '', |
|
2493 | - '', |
|
2494 | - '1' |
|
2495 | - ); |
|
2487 | + // Get document PID and location from database. |
|
2488 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
2489 | + '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', |
|
2490 | + 'tx_dlf_documents', |
|
2491 | + $whereClause, |
|
2492 | + '', |
|
2493 | + '', |
|
2494 | + '1' |
|
2495 | + ); |
|
2496 | 2496 | |
2497 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
2497 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
2498 | 2498 | |
2499 | - list ($this->uid, $this->pid, $this->recordId, $this->parentId, $this->thumbnail, $this->location) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
2499 | + list ($this->uid, $this->pid, $this->recordId, $this->parentId, $this->thumbnail, $this->location) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
2500 | 2500 | |
2501 | - $this->thumbnailLoaded = TRUE; |
|
2501 | + $this->thumbnailLoaded = TRUE; |
|
2502 | 2502 | |
2503 | - // Load XML file if necessary... |
|
2504 | - if ($this->mets === NULL && $this->load($this->location)) { |
|
2503 | + // Load XML file if necessary... |
|
2504 | + if ($this->mets === NULL && $this->load($this->location)) { |
|
2505 | 2505 | |
2506 | - // ...and set some basic properties. |
|
2507 | - $this->init(); |
|
2506 | + // ...and set some basic properties. |
|
2507 | + $this->init(); |
|
2508 | 2508 | |
2509 | - } |
|
2509 | + } |
|
2510 | 2510 | |
2511 | - // Do we have a METS object now? |
|
2512 | - if ($this->mets !== NULL) { |
|
2511 | + // Do we have a METS object now? |
|
2512 | + if ($this->mets !== NULL) { |
|
2513 | 2513 | |
2514 | - // Set new location if necessary. |
|
2515 | - if (!empty($location)) { |
|
2514 | + // Set new location if necessary. |
|
2515 | + if (!empty($location)) { |
|
2516 | 2516 | |
2517 | - $this->location = $location; |
|
2517 | + $this->location = $location; |
|
2518 | 2518 | |
2519 | - } |
|
2519 | + } |
|
2520 | 2520 | |
2521 | - // Document ready! |
|
2522 | - $this->ready = TRUE; |
|
2521 | + // Document ready! |
|
2522 | + $this->ready = TRUE; |
|
2523 | 2523 | |
2524 | - } |
|
2524 | + } |
|
2525 | 2525 | |
2526 | - } elseif ($this->mets !== NULL) { |
|
2526 | + } elseif ($this->mets !== NULL) { |
|
2527 | 2527 | |
2528 | - // Set location as UID for documents not in database. |
|
2529 | - $this->uid = $location; |
|
2528 | + // Set location as UID for documents not in database. |
|
2529 | + $this->uid = $location; |
|
2530 | 2530 | |
2531 | - $this->location = $location; |
|
2531 | + $this->location = $location; |
|
2532 | 2532 | |
2533 | - // Document ready! |
|
2534 | - $this->ready = TRUE; |
|
2533 | + // Document ready! |
|
2534 | + $this->ready = TRUE; |
|
2535 | 2535 | |
2536 | - } else { |
|
2536 | + } else { |
|
2537 | 2537 | |
2538 | - if (TYPO3_DLOG) { |
|
2538 | + if (TYPO3_DLOG) { |
|
2539 | 2539 | |
2540 | - \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); |
|
2540 | + \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); |
|
2541 | 2541 | |
2542 | - } |
|
2542 | + } |
|
2543 | 2543 | |
2544 | - } |
|
2544 | + } |
|
2545 | 2545 | |
2546 | - } |
|
2546 | + } |
|
2547 | 2547 | |
2548 | - /** |
|
2549 | - * This magic method is called each time an invisible property is referenced from the object |
|
2550 | - * |
|
2551 | - * @access public |
|
2552 | - * |
|
2553 | - * @param string $var: Name of variable to get |
|
2554 | - * |
|
2555 | - * @return mixed Value of $this->$var |
|
2556 | - */ |
|
2557 | - public function __get($var) { |
|
2548 | + /** |
|
2549 | + * This magic method is called each time an invisible property is referenced from the object |
|
2550 | + * |
|
2551 | + * @access public |
|
2552 | + * |
|
2553 | + * @param string $var: Name of variable to get |
|
2554 | + * |
|
2555 | + * @return mixed Value of $this->$var |
|
2556 | + */ |
|
2557 | + public function __get($var) { |
|
2558 | 2558 | |
2559 | - $method = '_get'.ucfirst($var); |
|
2559 | + $method = '_get'.ucfirst($var); |
|
2560 | 2560 | |
2561 | - if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
2561 | + if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
2562 | 2562 | |
2563 | - if (TYPO3_DLOG) { |
|
2563 | + if (TYPO3_DLOG) { |
|
2564 | 2564 | |
2565 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__get('.$var.')] There is no getter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
2565 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__get('.$var.')] There is no getter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
2566 | 2566 | |
2567 | - } |
|
2567 | + } |
|
2568 | 2568 | |
2569 | - return; |
|
2569 | + return; |
|
2570 | 2570 | |
2571 | - } else { |
|
2571 | + } else { |
|
2572 | 2572 | |
2573 | - return $this->$method(); |
|
2573 | + return $this->$method(); |
|
2574 | 2574 | |
2575 | - } |
|
2575 | + } |
|
2576 | 2576 | |
2577 | - } |
|
2577 | + } |
|
2578 | 2578 | |
2579 | - /** |
|
2580 | - * This magic method is called each time an invisible property is referenced from the object |
|
2581 | - * |
|
2582 | - * @access public |
|
2583 | - * |
|
2584 | - * @param string $var: Name of variable to set |
|
2585 | - * @param mixed $value: New value of variable |
|
2586 | - * |
|
2587 | - * @return void |
|
2588 | - */ |
|
2589 | - public function __set($var, $value) { |
|
2579 | + /** |
|
2580 | + * This magic method is called each time an invisible property is referenced from the object |
|
2581 | + * |
|
2582 | + * @access public |
|
2583 | + * |
|
2584 | + * @param string $var: Name of variable to set |
|
2585 | + * @param mixed $value: New value of variable |
|
2586 | + * |
|
2587 | + * @return void |
|
2588 | + */ |
|
2589 | + public function __set($var, $value) { |
|
2590 | 2590 | |
2591 | - $method = '_set'.ucfirst($var); |
|
2591 | + $method = '_set'.ucfirst($var); |
|
2592 | 2592 | |
2593 | - if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
2593 | + if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
2594 | 2594 | |
2595 | - if (TYPO3_DLOG) { |
|
2595 | + if (TYPO3_DLOG) { |
|
2596 | 2596 | |
2597 | - \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); |
|
2597 | + \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); |
|
2598 | 2598 | |
2599 | - } |
|
2599 | + } |
|
2600 | 2600 | |
2601 | - } else { |
|
2601 | + } else { |
|
2602 | 2602 | |
2603 | - $this->$method($value); |
|
2603 | + $this->$method($value); |
|
2604 | 2604 | |
2605 | - } |
|
2605 | + } |
|
2606 | 2606 | |
2607 | - } |
|
2607 | + } |
|
2608 | 2608 | |
2609 | - /** |
|
2610 | - * This magic method is executed prior to any serialization of the object |
|
2611 | - * @see __wakeup() |
|
2612 | - * |
|
2613 | - * @access public |
|
2614 | - * |
|
2615 | - * @return array Properties to be serialized |
|
2616 | - */ |
|
2617 | - public function __sleep() { |
|
2609 | + /** |
|
2610 | + * This magic method is executed prior to any serialization of the object |
|
2611 | + * @see __wakeup() |
|
2612 | + * |
|
2613 | + * @access public |
|
2614 | + * |
|
2615 | + * @return array Properties to be serialized |
|
2616 | + */ |
|
2617 | + public function __sleep() { |
|
2618 | 2618 | |
2619 | - // SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
|
2620 | - $this->asXML = $this->xml->asXML(); |
|
2619 | + // SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
|
2620 | + $this->asXML = $this->xml->asXML(); |
|
2621 | 2621 | |
2622 | - return array ('uid', 'pid', 'recordId', 'parentId', 'asXML'); |
|
2622 | + return array ('uid', 'pid', 'recordId', 'parentId', 'asXML'); |
|
2623 | 2623 | |
2624 | - } |
|
2624 | + } |
|
2625 | 2625 | |
2626 | - /** |
|
2627 | - * This magic method is used for setting a string value for the object |
|
2628 | - * |
|
2629 | - * @access public |
|
2630 | - * |
|
2631 | - * @return string String representing the METS object |
|
2632 | - */ |
|
2633 | - public function __toString() { |
|
2626 | + /** |
|
2627 | + * This magic method is used for setting a string value for the object |
|
2628 | + * |
|
2629 | + * @access public |
|
2630 | + * |
|
2631 | + * @return string String representing the METS object |
|
2632 | + */ |
|
2633 | + public function __toString() { |
|
2634 | 2634 | |
2635 | - $xml = new DOMDocument('1.0', 'utf-8'); |
|
2635 | + $xml = new DOMDocument('1.0', 'utf-8'); |
|
2636 | 2636 | |
2637 | - $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE)); |
|
2637 | + $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), TRUE)); |
|
2638 | 2638 | |
2639 | - $xml->formatOutput = TRUE; |
|
2639 | + $xml->formatOutput = TRUE; |
|
2640 | 2640 | |
2641 | - return $xml->saveXML(); |
|
2641 | + return $xml->saveXML(); |
|
2642 | 2642 | |
2643 | - } |
|
2643 | + } |
|
2644 | 2644 | |
2645 | - /** |
|
2646 | - * This magic method is executed after the object is deserialized |
|
2647 | - * @see __sleep() |
|
2648 | - * |
|
2649 | - * @access public |
|
2650 | - * |
|
2651 | - * @return void |
|
2652 | - */ |
|
2653 | - public function __wakeup() { |
|
2645 | + /** |
|
2646 | + * This magic method is executed after the object is deserialized |
|
2647 | + * @see __sleep() |
|
2648 | + * |
|
2649 | + * @access public |
|
2650 | + * |
|
2651 | + * @return void |
|
2652 | + */ |
|
2653 | + public function __wakeup() { |
|
2654 | 2654 | |
2655 | - // Turn off libxml's error logging. |
|
2656 | - $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
2655 | + // Turn off libxml's error logging. |
|
2656 | + $libxmlErrors = libxml_use_internal_errors(TRUE); |
|
2657 | 2657 | |
2658 | - // Reload XML from string. |
|
2659 | - $xml = @simplexml_load_string($this->asXML); |
|
2658 | + // Reload XML from string. |
|
2659 | + $xml = @simplexml_load_string($this->asXML); |
|
2660 | 2660 | |
2661 | - // Reset libxml's error logging. |
|
2662 | - libxml_use_internal_errors($libxmlErrors); |
|
2661 | + // Reset libxml's error logging. |
|
2662 | + libxml_use_internal_errors($libxmlErrors); |
|
2663 | 2663 | |
2664 | - if ($xml !== FALSE) { |
|
2664 | + if ($xml !== FALSE) { |
|
2665 | 2665 | |
2666 | - $this->asXML = ''; |
|
2666 | + $this->asXML = ''; |
|
2667 | 2667 | |
2668 | - $this->xml = $xml; |
|
2668 | + $this->xml = $xml; |
|
2669 | 2669 | |
2670 | - // Rebuild the unserializable properties. |
|
2671 | - $this->init(); |
|
2670 | + // Rebuild the unserializable properties. |
|
2671 | + $this->init(); |
|
2672 | 2672 | |
2673 | - } else { |
|
2673 | + } else { |
|
2674 | 2674 | |
2675 | - if (TYPO3_DLOG) { |
|
2675 | + if (TYPO3_DLOG) { |
|
2676 | 2676 | |
2677 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__wakeup()] Could not load XML after deserialization', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
2677 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_document->__wakeup()] Could not load XML after deserialization', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
2678 | 2678 | |
2679 | - } |
|
2679 | + } |
|
2680 | 2680 | |
2681 | - } |
|
2681 | + } |
|
2682 | 2682 | |
2683 | - } |
|
2683 | + } |
|
2684 | 2684 | |
2685 | 2685 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @var array |
44 | 44 | * @access protected |
45 | 45 | */ |
46 | - protected $dmdSec = array (); |
|
46 | + protected $dmdSec = array(); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Are the METS file's dmdSecs loaded? |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @var array |
70 | 70 | * @access protected |
71 | 71 | */ |
72 | - protected $fileGrps = array (); |
|
72 | + protected $fileGrps = array(); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Are the file groups loaded? |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | * @var array |
88 | 88 | * @access protected |
89 | 89 | */ |
90 | - protected $formats = array ( |
|
91 | - 'OAI' => array ( |
|
90 | + protected $formats = array( |
|
91 | + 'OAI' => array( |
|
92 | 92 | 'rootElement' => 'OAI-PMH', |
93 | 93 | 'namespaceURI' => 'http://www.openarchives.org/OAI/2.0/', |
94 | 94 | ), |
95 | - 'METS' => array ( |
|
95 | + 'METS' => array( |
|
96 | 96 | 'rootElement' => 'mets', |
97 | 97 | 'namespaceURI' => 'http://www.loc.gov/METS/', |
98 | 98 | ), |
99 | - 'XLINK' => array ( |
|
99 | + 'XLINK' => array( |
|
100 | 100 | 'rootElement' => 'xlink', |
101 | 101 | 'namespaceURI' => 'http://www.w3.org/1999/xlink', |
102 | 102 | ) |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @var array |
126 | 126 | * @access protected |
127 | 127 | */ |
128 | - protected $lastSearchedPhysicalPage = array ('logicalPage' => NULL, 'physicalPage' => NULL); |
|
128 | + protected $lastSearchedPhysicalPage = array('logicalPage' => NULL, 'physicalPage' => NULL); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * This holds the documents location |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @var array |
142 | 142 | * @access protected |
143 | 143 | */ |
144 | - protected $logicalUnits = array (); |
|
144 | + protected $logicalUnits = array(); |
|
145 | 145 | |
146 | 146 | /** |
147 | 147 | * This holds the documents' parsed metadata array with their corresponding structMap//div's ID as array key |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @var array |
150 | 150 | * @access protected |
151 | 151 | */ |
152 | - protected $metadataArray = array (); |
|
152 | + protected $metadataArray = array(); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Is the metadata array loaded? |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @var array |
191 | 191 | * @access protected |
192 | 192 | */ |
193 | - protected $physicalStructure = array (); |
|
193 | + protected $physicalStructure = array(); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * This holds the physical structure metadata |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @var array |
199 | 199 | * @access protected |
200 | 200 | */ |
201 | - protected $physicalStructureInfo = array (); |
|
201 | + protected $physicalStructureInfo = array(); |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Is the physical structure loaded? |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @var array (tx_dlf_document) |
240 | 240 | * @access protected |
241 | 241 | */ |
242 | - protected static $registry = array (); |
|
242 | + protected static $registry = array(); |
|
243 | 243 | |
244 | 244 | /** |
245 | 245 | * This holds the UID of the root document or zero if not multi-volumed |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @var array |
265 | 265 | * @access protected |
266 | 266 | */ |
267 | - protected $smLinks = array ('l2p' => array (), 'p2l' => array ()); |
|
267 | + protected $smLinks = array('l2p' => array(), 'p2l' => array()); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Are the smLinks loaded? |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @var array |
282 | 282 | * @access protected |
283 | 283 | */ |
284 | - protected $tableOfContents = array (); |
|
284 | + protected $tableOfContents = array(); |
|
285 | 285 | |
286 | 286 | /** |
287 | 287 | * Is the table of contents loaded? |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | public static function clearRegistry() { |
344 | 344 | |
345 | 345 | // Reset registry array. |
346 | - self::$registry = array (); |
|
346 | + self::$registry = array(); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | */ |
502 | 502 | public function getLogicalStructure($id, $recursive = FALSE) { |
503 | 503 | |
504 | - $details = array (); |
|
504 | + $details = array(); |
|
505 | 505 | |
506 | 506 | // Is the requested logical unit already loaded? |
507 | 507 | if (!$recursive && !empty($this->logicalUnits[$id])) { |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
569 | 569 | |
570 | 570 | // Extract identity information. |
571 | - $details = array (); |
|
571 | + $details = array(); |
|
572 | 572 | |
573 | 573 | $details['id'] = $attributes['ID']; |
574 | 574 | |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | } |
646 | 646 | |
647 | 647 | // Get the files this structure element is pointing at. |
648 | - $details['files'] = array (); |
|
648 | + $details['files'] = array(); |
|
649 | 649 | |
650 | 650 | $fileUse = $this->_getFileGrps(); |
651 | 651 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | // Walk the structure recursively? And are there any children of the current element? |
668 | 668 | if ($recursive && count($structure->children('http://www.loc.gov/METS/')->div)) { |
669 | 669 | |
670 | - $details['children'] = array (); |
|
670 | + $details['children'] = array(); |
|
671 | 671 | |
672 | 672 | foreach ($structure->children('http://www.loc.gov/METS/')->div as $child) { |
673 | 673 | |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | } |
717 | 717 | |
718 | - return array (); |
|
718 | + return array(); |
|
719 | 719 | |
720 | 720 | } |
721 | 721 | |
@@ -727,23 +727,23 @@ discard block |
||
727 | 727 | } |
728 | 728 | |
729 | 729 | // Initialize metadata array with empty values. |
730 | - $metadata = array ( |
|
731 | - 'title' => array (), |
|
732 | - 'title_sorting' => array (), |
|
733 | - 'author' => array (), |
|
734 | - 'place' => array (), |
|
735 | - 'year' => array (), |
|
736 | - 'prod_id' => array (), |
|
737 | - 'record_id' => array (), |
|
738 | - 'opac_id' => array (), |
|
739 | - 'union_id' => array (), |
|
740 | - 'urn' => array (), |
|
741 | - 'purl' => array (), |
|
742 | - 'type' => array (), |
|
743 | - 'volume' => array (), |
|
744 | - 'volume_sorting' => array (), |
|
745 | - 'collection' => array (), |
|
746 | - 'owner' => array (), |
|
730 | + $metadata = array( |
|
731 | + 'title' => array(), |
|
732 | + 'title_sorting' => array(), |
|
733 | + 'author' => array(), |
|
734 | + 'place' => array(), |
|
735 | + 'year' => array(), |
|
736 | + 'prod_id' => array(), |
|
737 | + 'record_id' => array(), |
|
738 | + 'opac_id' => array(), |
|
739 | + 'union_id' => array(), |
|
740 | + 'urn' => array(), |
|
741 | + 'purl' => array(), |
|
742 | + 'type' => array(), |
|
743 | + 'volume' => array(), |
|
744 | + 'volume_sorting' => array(), |
|
745 | + 'collection' => array(), |
|
746 | + 'owner' => array(), |
|
747 | 747 | ); |
748 | 748 | |
749 | 749 | // Get the logical structure node's DMDID. |
@@ -798,20 +798,20 @@ discard block |
||
798 | 798 | |
799 | 799 | } |
800 | 800 | |
801 | - return array (); |
|
801 | + return array(); |
|
802 | 802 | |
803 | 803 | } |
804 | 804 | |
805 | 805 | // Get the structure's type. |
806 | 806 | if (!empty($this->logicalUnits[$id])) { |
807 | 807 | |
808 | - $metadata['type'] = array ($this->logicalUnits[$id]['type']); |
|
808 | + $metadata['type'] = array($this->logicalUnits[$id]['type']); |
|
809 | 809 | |
810 | 810 | } else { |
811 | 811 | |
812 | 812 | $struct = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$id.'"]/@TYPE'); |
813 | 813 | |
814 | - $metadata['type'] = array ((string) $struct[0]); |
|
814 | + $metadata['type'] = array((string) $struct[0]); |
|
815 | 815 | |
816 | 816 | } |
817 | 817 | |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | |
841 | 841 | if ($values instanceof DOMNodeList && $values->length > 0) { |
842 | 842 | |
843 | - $metadata[$resArray['index_name']] = array (); |
|
843 | + $metadata[$resArray['index_name']] = array(); |
|
844 | 844 | |
845 | 845 | foreach ($values as $value) { |
846 | 846 | |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | |
851 | 851 | } elseif (!($values instanceof DOMNodeList)) { |
852 | 852 | |
853 | - $metadata[$resArray['index_name']] = array (trim((string) $values)); |
|
853 | + $metadata[$resArray['index_name']] = array(trim((string) $values)); |
|
854 | 854 | |
855 | 855 | } |
856 | 856 | |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | // Set default value if applicable. |
860 | 860 | if (empty($metadata[$resArray['index_name']][0])) { |
861 | 861 | |
862 | - $metadata[$resArray['index_name']] = array ($resArray['default_value']); |
|
862 | + $metadata[$resArray['index_name']] = array($resArray['default_value']); |
|
863 | 863 | |
864 | 864 | } |
865 | 865 | |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | } else { |
903 | 903 | |
904 | 904 | // There is no dmdSec for this structure node. |
905 | - return array (); |
|
905 | + return array(); |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
1173 | 1173 | |
1174 | 1174 | // Update format registry. |
1175 | - $this->formats[$resArray['type']] = array ( |
|
1175 | + $this->formats[$resArray['type']] = array( |
|
1176 | 1176 | 'rootElement' => $resArray['root'], |
1177 | 1177 | 'namespaceURI' => $resArray['namespace'], |
1178 | 1178 | 'class' => $resArray['class'] |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | $metadata['type'][0] = $structure; |
1368 | 1368 | |
1369 | 1369 | // Get UIDs for collections. |
1370 | - $collections = array (); |
|
1370 | + $collections = array(); |
|
1371 | 1371 | |
1372 | 1372 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
1373 | 1373 | 'tx_dlf_collections.index_name AS index_name,tx_dlf_collections.uid AS uid', |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | // Insert new collection. |
1399 | 1399 | $collNewUid = uniqid('NEW'); |
1400 | 1400 | |
1401 | - $collData['tx_dlf_collections'][$collNewUid] = array ( |
|
1401 | + $collData['tx_dlf_collections'][$collNewUid] = array( |
|
1402 | 1402 | 'pid' => $pid, |
1403 | 1403 | 'label' => $collection, |
1404 | 1404 | 'index_name' => $collection, |
@@ -1476,7 +1476,7 @@ discard block |
||
1476 | 1476 | // Insert new library. |
1477 | 1477 | $libNewUid = uniqid('NEW'); |
1478 | 1478 | |
1479 | - $libData['tx_dlf_libraries'][$libNewUid] = array ( |
|
1479 | + $libData['tx_dlf_libraries'][$libNewUid] = array( |
|
1480 | 1480 | 'pid' => $pid, |
1481 | 1481 | 'label' => $owner, |
1482 | 1482 | 'index_name' => $owner, |
@@ -1526,7 +1526,7 @@ discard block |
||
1526 | 1526 | |
1527 | 1527 | if ($parentLocation != $this->location) { |
1528 | 1528 | |
1529 | - $parentDoc =& tx_dlf_document::getInstance($parentLocation, $pid); |
|
1529 | + $parentDoc = & tx_dlf_document::getInstance($parentLocation, $pid); |
|
1530 | 1530 | |
1531 | 1531 | if ($parentDoc->ready) { |
1532 | 1532 | |
@@ -1580,9 +1580,9 @@ discard block |
||
1580 | 1580 | } |
1581 | 1581 | |
1582 | 1582 | // Get metadata for lists and sorting. |
1583 | - $listed = array (); |
|
1583 | + $listed = array(); |
|
1584 | 1584 | |
1585 | - $sortable = array (); |
|
1585 | + $sortable = array(); |
|
1586 | 1586 | |
1587 | 1587 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
1588 | 1588 | 'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable', |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | } |
1615 | 1615 | |
1616 | 1616 | // Fill data array. |
1617 | - $data['tx_dlf_documents'][$this->uid] = array ( |
|
1617 | + $data['tx_dlf_documents'][$this->uid] = array( |
|
1618 | 1618 | 'pid' => $pid, |
1619 | 1619 | $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['starttime'] => 0, |
1620 | 1620 | $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['endtime'] => 0, |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | |
1898 | 1898 | } |
1899 | 1899 | |
1900 | - return array (); |
|
1900 | + return array(); |
|
1901 | 1901 | |
1902 | 1902 | } |
1903 | 1903 | |
@@ -2619,7 +2619,7 @@ discard block |
||
2619 | 2619 | // SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization |
2620 | 2620 | $this->asXML = $this->xml->asXML(); |
2621 | 2621 | |
2622 | - return array ('uid', 'pid', 'recordId', 'parentId', 'asXML'); |
|
2622 | + return array('uid', 'pid', 'recordId', 'parentId', 'asXML'); |
|
2623 | 2623 | |
2624 | 2624 | } |
2625 | 2625 |
@@ -20,15 +20,15 @@ |
||
20 | 20 | */ |
21 | 21 | interface tx_dlf_fulltext { |
22 | 22 | |
23 | - /** |
|
24 | - * This extracts raw fulltext data from XML |
|
25 | - * |
|
26 | - * @access public |
|
27 | - * |
|
28 | - * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
29 | - * |
|
30 | - * @return string The raw unformatted fulltext |
|
31 | - */ |
|
32 | - public static function getRawText(SimpleXMLElement $xml); |
|
23 | + /** |
|
24 | + * This extracts raw fulltext data from XML |
|
25 | + * |
|
26 | + * @access public |
|
27 | + * |
|
28 | + * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
29 | + * |
|
30 | + * @return string The raw unformatted fulltext |
|
31 | + */ |
|
32 | + public static function getRawText(SimpleXMLElement $xml); |
|
33 | 33 | |
34 | 34 | } |
@@ -20,1318 +20,1318 @@ |
||
20 | 20 | */ |
21 | 21 | class tx_dlf_helper { |
22 | 22 | |
23 | - /** |
|
24 | - * The extension key |
|
25 | - * |
|
26 | - * @var string |
|
27 | - * @access public |
|
28 | - */ |
|
29 | - public static $extKey = 'dlf'; |
|
30 | - |
|
31 | - /** |
|
32 | - * The locallang array for common use |
|
33 | - * |
|
34 | - * @var array |
|
35 | - * @access protected |
|
36 | - */ |
|
37 | - protected static $locallang = array (); |
|
23 | + /** |
|
24 | + * The extension key |
|
25 | + * |
|
26 | + * @var string |
|
27 | + * @access public |
|
28 | + */ |
|
29 | + public static $extKey = 'dlf'; |
|
30 | + |
|
31 | + /** |
|
32 | + * The locallang array for common use |
|
33 | + * |
|
34 | + * @var array |
|
35 | + * @access protected |
|
36 | + */ |
|
37 | + protected static $locallang = array (); |
|
38 | 38 | |
39 | - /** |
|
40 | - * Adds a message to the message queue. |
|
41 | - * |
|
42 | - * @access public |
|
43 | - * |
|
44 | - * @param \TYPO3\CMS\Core\Messaging\FlashMessage $message: Instance of \TYPO3\CMS\Core\Messaging\FlashMessage |
|
45 | - * |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - public static function addMessage($message) { |
|
39 | + /** |
|
40 | + * Adds a message to the message queue. |
|
41 | + * |
|
42 | + * @access public |
|
43 | + * |
|
44 | + * @param \TYPO3\CMS\Core\Messaging\FlashMessage $message: Instance of \TYPO3\CMS\Core\Messaging\FlashMessage |
|
45 | + * |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + public static function addMessage($message) { |
|
49 | 49 | |
50 | - $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
50 | + $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
51 | 51 | |
52 | - $flashMessageService->getMessageQueueByIdentifier()->enqueue($message); |
|
52 | + $flashMessageService->getMessageQueueByIdentifier()->enqueue($message); |
|
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Implements array_merge_recursive_overrule() in a cross-version way |
|
58 | - * This code is a copy from realurl, written by Dmitry Dulepov <[email protected]>. |
|
59 | - * |
|
60 | - * @access public |
|
61 | - * |
|
62 | - * @param array $array1: First array |
|
63 | - * @param array $array2: Second array |
|
64 | - * |
|
65 | - * @return array Merged array with second array overruling first one |
|
66 | - */ |
|
67 | - static public function array_merge_recursive_overrule($array1, $array2) { |
|
56 | + /** |
|
57 | + * Implements array_merge_recursive_overrule() in a cross-version way |
|
58 | + * This code is a copy from realurl, written by Dmitry Dulepov <[email protected]>. |
|
59 | + * |
|
60 | + * @access public |
|
61 | + * |
|
62 | + * @param array $array1: First array |
|
63 | + * @param array $array2: Second array |
|
64 | + * |
|
65 | + * @return array Merged array with second array overruling first one |
|
66 | + */ |
|
67 | + static public function array_merge_recursive_overrule($array1, $array2) { |
|
68 | 68 | |
69 | - if (class_exists('\\TYPO3\\CMS\\Core\\Utility\\ArrayUtility')) { |
|
69 | + if (class_exists('\\TYPO3\\CMS\\Core\\Utility\\ArrayUtility')) { |
|
70 | 70 | |
71 | - \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($array1, $array2); |
|
71 | + \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($array1, $array2); |
|
72 | 72 | |
73 | - } else { |
|
73 | + } else { |
|
74 | 74 | |
75 | - $array1 = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($array1, $array2); |
|
75 | + $array1 = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($array1, $array2); |
|
76 | 76 | |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | - return $array1; |
|
79 | + return $array1; |
|
80 | 80 | |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Searches the array recursively for a given value and returns the corresponding key if successful |
|
85 | - * @see http://php.net/array_search |
|
86 | - * |
|
87 | - * @access public |
|
88 | - * |
|
89 | - * @param mixed $needle: The searched value |
|
90 | - * @param array $haystack: The array to search in |
|
91 | - * @param boolean $strict: Check needle's type, too? |
|
92 | - * |
|
93 | - * @return mixed Returns the needle's key if found and FALSE otherwise |
|
94 | - * |
|
95 | - * @deprecated because of its inefficiency |
|
96 | - */ |
|
97 | - public static function array_search_recursive($needle, $haystack, $strict = FALSE) { |
|
83 | + /** |
|
84 | + * Searches the array recursively for a given value and returns the corresponding key if successful |
|
85 | + * @see http://php.net/array_search |
|
86 | + * |
|
87 | + * @access public |
|
88 | + * |
|
89 | + * @param mixed $needle: The searched value |
|
90 | + * @param array $haystack: The array to search in |
|
91 | + * @param boolean $strict: Check needle's type, too? |
|
92 | + * |
|
93 | + * @return mixed Returns the needle's key if found and FALSE otherwise |
|
94 | + * |
|
95 | + * @deprecated because of its inefficiency |
|
96 | + */ |
|
97 | + public static function array_search_recursive($needle, $haystack, $strict = FALSE) { |
|
98 | 98 | |
99 | - foreach ($haystack as $key => $value) { |
|
99 | + foreach ($haystack as $key => $value) { |
|
100 | 100 | |
101 | - if (($strict && $value === $needle) || (!$strict && $value == $needle) || (is_array($value) && self::array_search_recursive($needle, $value, $strict) !== FALSE)) { |
|
101 | + if (($strict && $value === $needle) || (!$strict && $value == $needle) || (is_array($value) && self::array_search_recursive($needle, $value, $strict) !== FALSE)) { |
|
102 | 102 | |
103 | - return $key; |
|
103 | + return $key; |
|
104 | 104 | |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - return FALSE; |
|
109 | + return FALSE; |
|
110 | 110 | |
111 | - } |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Check if given identifier is a valid identifier of the German National Library |
|
115 | - * @see http://support.d-nb.de/iltis/onlineRoutinen/Pruefziffernberechnung.htm |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * |
|
119 | - * @param string $id: The identifier to check |
|
120 | - * @param string $type: What type is the identifier supposed to be? |
|
121 | - * Possible values: PPN, IDN, PND, ZDB, SWD, GKD |
|
122 | - * |
|
123 | - * @return boolean Is $id a valid GNL identifier of the given $type? |
|
124 | - */ |
|
125 | - public static function checkIdentifier($id, $type) { |
|
113 | + /** |
|
114 | + * Check if given identifier is a valid identifier of the German National Library |
|
115 | + * @see http://support.d-nb.de/iltis/onlineRoutinen/Pruefziffernberechnung.htm |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * |
|
119 | + * @param string $id: The identifier to check |
|
120 | + * @param string $type: What type is the identifier supposed to be? |
|
121 | + * Possible values: PPN, IDN, PND, ZDB, SWD, GKD |
|
122 | + * |
|
123 | + * @return boolean Is $id a valid GNL identifier of the given $type? |
|
124 | + */ |
|
125 | + public static function checkIdentifier($id, $type) { |
|
126 | 126 | |
127 | - $digits = substr($id, 0, 8); |
|
127 | + $digits = substr($id, 0, 8); |
|
128 | 128 | |
129 | - $checksum = 0; |
|
129 | + $checksum = 0; |
|
130 | 130 | |
131 | - for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
131 | + for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
132 | 132 | |
133 | - $checksum += (9 - $i) * intval(substr($digits, $i, 1)); |
|
133 | + $checksum += (9 - $i) * intval(substr($digits, $i, 1)); |
|
134 | 134 | |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - $checksum = (11 - ($checksum % 11)) % 11; |
|
137 | + $checksum = (11 - ($checksum % 11)) % 11; |
|
138 | 138 | |
139 | - switch (strtoupper($type)) { |
|
139 | + switch (strtoupper($type)) { |
|
140 | 140 | |
141 | - case 'PPN': |
|
142 | - case 'IDN': |
|
143 | - case 'PND': |
|
141 | + case 'PPN': |
|
142 | + case 'IDN': |
|
143 | + case 'PND': |
|
144 | 144 | |
145 | - if ($checksum == 10) { |
|
145 | + if ($checksum == 10) { |
|
146 | 146 | |
147 | - $checksum = 'X'; |
|
147 | + $checksum = 'X'; |
|
148 | 148 | |
149 | - } |
|
149 | + } |
|
150 | 150 | |
151 | - if (!preg_match('/[0-9]{8}[0-9X]{1}/i', $id)) { |
|
151 | + if (!preg_match('/[0-9]{8}[0-9X]{1}/i', $id)) { |
|
152 | 152 | |
153 | - return FALSE; |
|
153 | + return FALSE; |
|
154 | 154 | |
155 | - } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
155 | + } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
156 | 156 | |
157 | - return FALSE; |
|
157 | + return FALSE; |
|
158 | 158 | |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | - break; |
|
161 | + break; |
|
162 | 162 | |
163 | - case 'ZDB': |
|
163 | + case 'ZDB': |
|
164 | 164 | |
165 | - if ($checksum == 10) { |
|
165 | + if ($checksum == 10) { |
|
166 | 166 | |
167 | - $checksum = 'X'; |
|
167 | + $checksum = 'X'; |
|
168 | 168 | |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
171 | + if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
172 | 172 | |
173 | - return FALSE; |
|
173 | + return FALSE; |
|
174 | 174 | |
175 | - } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
175 | + } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
176 | 176 | |
177 | - return FALSE; |
|
177 | + return FALSE; |
|
178 | 178 | |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | - break; |
|
181 | + break; |
|
182 | 182 | |
183 | - case 'SWD': |
|
183 | + case 'SWD': |
|
184 | 184 | |
185 | - $checksum = 11 - $checksum; |
|
185 | + $checksum = 11 - $checksum; |
|
186 | 186 | |
187 | - if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) { |
|
187 | + if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) { |
|
188 | 188 | |
189 | - return FALSE; |
|
189 | + return FALSE; |
|
190 | 190 | |
191 | - } elseif ($checksum == 10) { |
|
191 | + } elseif ($checksum == 10) { |
|
192 | 192 | |
193 | - return self::checkIdentifier(($digits + 1).substr($id, -2, 2), 'SWD'); |
|
193 | + return self::checkIdentifier(($digits + 1).substr($id, -2, 2), 'SWD'); |
|
194 | 194 | |
195 | - } elseif (substr($id, -1, 1) != $checksum) { |
|
195 | + } elseif (substr($id, -1, 1) != $checksum) { |
|
196 | 196 | |
197 | - return FALSE; |
|
197 | + return FALSE; |
|
198 | 198 | |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | - break; |
|
201 | + break; |
|
202 | 202 | |
203 | - case 'GKD': |
|
203 | + case 'GKD': |
|
204 | 204 | |
205 | - $checksum = 11 - $checksum; |
|
205 | + $checksum = 11 - $checksum; |
|
206 | 206 | |
207 | - if ($checksum == 10) { |
|
207 | + if ($checksum == 10) { |
|
208 | 208 | |
209 | - $checksum = 'X'; |
|
209 | + $checksum = 'X'; |
|
210 | 210 | |
211 | - } |
|
211 | + } |
|
212 | 212 | |
213 | - if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
213 | + if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
214 | 214 | |
215 | - return FALSE; |
|
215 | + return FALSE; |
|
216 | 216 | |
217 | - } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
217 | + } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
218 | 218 | |
219 | - return FALSE; |
|
219 | + return FALSE; |
|
220 | 220 | |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - break; |
|
223 | + break; |
|
224 | 224 | |
225 | - } |
|
225 | + } |
|
226 | 226 | |
227 | - return TRUE; |
|
227 | + return TRUE; |
|
228 | 228 | |
229 | - } |
|
229 | + } |
|
230 | 230 | |
231 | - /** |
|
232 | - * Decrypt encrypted value with given control hash |
|
233 | - * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
234 | - * |
|
235 | - * @access public |
|
236 | - * |
|
237 | - * @param string $encrypted: The encrypted value to decrypt |
|
238 | - * @param string $hash: The control hash for decrypting |
|
239 | - * |
|
240 | - * @return mixed The decrypted value or NULL on error |
|
241 | - */ |
|
242 | - public static function decrypt($encrypted, $hash) { |
|
231 | + /** |
|
232 | + * Decrypt encrypted value with given control hash |
|
233 | + * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
234 | + * |
|
235 | + * @access public |
|
236 | + * |
|
237 | + * @param string $encrypted: The encrypted value to decrypt |
|
238 | + * @param string $hash: The control hash for decrypting |
|
239 | + * |
|
240 | + * @return mixed The decrypted value or NULL on error |
|
241 | + */ |
|
242 | + public static function decrypt($encrypted, $hash) { |
|
243 | 243 | |
244 | - $decrypted = NULL; |
|
244 | + $decrypted = NULL; |
|
245 | 245 | |
246 | - // Check for PHP extension "mcrypt". |
|
247 | - if (!extension_loaded('mcrypt')) { |
|
246 | + // Check for PHP extension "mcrypt". |
|
247 | + if (!extension_loaded('mcrypt')) { |
|
248 | 248 | |
249 | - if (TYPO3_DLOG) { |
|
249 | + if (TYPO3_DLOG) { |
|
250 | 250 | |
251 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
251 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
252 | 252 | |
253 | - } |
|
253 | + } |
|
254 | 254 | |
255 | - return; |
|
255 | + return; |
|
256 | 256 | |
257 | - } |
|
257 | + } |
|
258 | 258 | |
259 | - if (empty($encrypted) || empty($hash)) { |
|
259 | + if (empty($encrypted) || empty($hash)) { |
|
260 | 260 | |
261 | - if (TYPO3_DLOG) { |
|
261 | + if (TYPO3_DLOG) { |
|
262 | 262 | |
263 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid parameters given for decryption', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
263 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid parameters given for decryption', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
264 | 264 | |
265 | - } |
|
265 | + } |
|
266 | 266 | |
267 | - return; |
|
267 | + return; |
|
268 | 268 | |
269 | - } |
|
269 | + } |
|
270 | 270 | |
271 | - if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
271 | + if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
272 | 272 | |
273 | - if (TYPO3_DLOG) { |
|
273 | + if (TYPO3_DLOG) { |
|
274 | 274 | |
275 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
275 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
276 | 276 | |
277 | - } |
|
277 | + } |
|
278 | 278 | |
279 | - return; |
|
279 | + return; |
|
280 | 280 | |
281 | - } |
|
281 | + } |
|
282 | 282 | |
283 | - $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
283 | + $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
284 | 284 | |
285 | - $decrypted = mcrypt_decrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), base64_decode($encrypted), MCRYPT_MODE_CFB, $iv); |
|
285 | + $decrypted = mcrypt_decrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), base64_decode($encrypted), MCRYPT_MODE_CFB, $iv); |
|
286 | 286 | |
287 | - $salt = substr($hash, 0, 10); |
|
287 | + $salt = substr($hash, 0, 10); |
|
288 | 288 | |
289 | - $hashed = $salt.substr(sha1($salt.$decrypted), -10); |
|
289 | + $hashed = $salt.substr(sha1($salt.$decrypted), -10); |
|
290 | 290 | |
291 | - if ($hashed !== $hash) { |
|
291 | + if ($hashed !== $hash) { |
|
292 | 292 | |
293 | - if (TYPO3_DLOG) { |
|
293 | + if (TYPO3_DLOG) { |
|
294 | 294 | |
295 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid hash "'.$hash.'" given for decryption', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
295 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid hash "'.$hash.'" given for decryption', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
296 | 296 | |
297 | - } |
|
297 | + } |
|
298 | 298 | |
299 | - return; |
|
299 | + return; |
|
300 | 300 | |
301 | - } |
|
301 | + } |
|
302 | 302 | |
303 | - return $decrypted; |
|
303 | + return $decrypted; |
|
304 | 304 | |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | - /** |
|
308 | - * Encrypt the given string |
|
309 | - * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
310 | - * |
|
311 | - * @access public |
|
312 | - * |
|
313 | - * @param string $string: The string to encrypt |
|
314 | - * |
|
315 | - * @return array Array with encrypted string and control hash |
|
316 | - */ |
|
317 | - public static function encrypt($string) { |
|
307 | + /** |
|
308 | + * Encrypt the given string |
|
309 | + * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
310 | + * |
|
311 | + * @access public |
|
312 | + * |
|
313 | + * @param string $string: The string to encrypt |
|
314 | + * |
|
315 | + * @return array Array with encrypted string and control hash |
|
316 | + */ |
|
317 | + public static function encrypt($string) { |
|
318 | 318 | |
319 | - // Check for PHP extension "mcrypt". |
|
320 | - if (!extension_loaded('mcrypt')) { |
|
319 | + // Check for PHP extension "mcrypt". |
|
320 | + if (!extension_loaded('mcrypt')) { |
|
321 | 321 | |
322 | - if (TYPO3_DLOG) { |
|
322 | + if (TYPO3_DLOG) { |
|
323 | 323 | |
324 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
324 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
325 | 325 | |
326 | - } |
|
326 | + } |
|
327 | 327 | |
328 | - return; |
|
328 | + return; |
|
329 | 329 | |
330 | - } |
|
330 | + } |
|
331 | 331 | |
332 | - if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
332 | + if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
333 | 333 | |
334 | - if (TYPO3_DLOG) { |
|
334 | + if (TYPO3_DLOG) { |
|
335 | 335 | |
336 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
336 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
337 | 337 | |
338 | - } |
|
338 | + } |
|
339 | 339 | |
340 | - return; |
|
340 | + return; |
|
341 | 341 | |
342 | - } |
|
342 | + } |
|
343 | 343 | |
344 | - $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
344 | + $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
345 | 345 | |
346 | - $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), $string, MCRYPT_MODE_CFB, $iv)); |
|
346 | + $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), $string, MCRYPT_MODE_CFB, $iv)); |
|
347 | 347 | |
348 | - $salt = substr(md5(uniqid(rand(), TRUE)), 0, 10); |
|
348 | + $salt = substr(md5(uniqid(rand(), TRUE)), 0, 10); |
|
349 | 349 | |
350 | - $hash = $salt.substr(sha1($salt.$string), -10); |
|
350 | + $hash = $salt.substr(sha1($salt.$string), -10); |
|
351 | 351 | |
352 | - return array ('encrypted' => $encrypted, 'hash' => $hash); |
|
352 | + return array ('encrypted' => $encrypted, 'hash' => $hash); |
|
353 | 353 | |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * Get a backend user object (even in frontend mode) |
|
358 | - * |
|
359 | - * @access public |
|
360 | - * |
|
361 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication Instance of \TYPO3\CMS\Core\Authentication\BackendUserAuthentication or NULL on failure |
|
362 | - */ |
|
363 | - public static function getBeUser() { |
|
356 | + /** |
|
357 | + * Get a backend user object (even in frontend mode) |
|
358 | + * |
|
359 | + * @access public |
|
360 | + * |
|
361 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication Instance of \TYPO3\CMS\Core\Authentication\BackendUserAuthentication or NULL on failure |
|
362 | + */ |
|
363 | + public static function getBeUser() { |
|
364 | 364 | |
365 | - if (TYPO3_MODE === 'FE' || TYPO3_MODE === 'BE') { |
|
365 | + if (TYPO3_MODE === 'FE' || TYPO3_MODE === 'BE') { |
|
366 | 366 | |
367 | - // Initialize backend session with CLI user's rights. |
|
368 | - $userObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication'); |
|
367 | + // Initialize backend session with CLI user's rights. |
|
368 | + $userObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication'); |
|
369 | 369 | |
370 | - $userObj->dontSetCookie = TRUE; |
|
370 | + $userObj->dontSetCookie = TRUE; |
|
371 | 371 | |
372 | - $userObj->start(); |
|
372 | + $userObj->start(); |
|
373 | 373 | |
374 | - $userObj->setBeUserByName('_cli_dlf'); |
|
374 | + $userObj->setBeUserByName('_cli_dlf'); |
|
375 | 375 | |
376 | - $userObj->backendCheckLogin(); |
|
376 | + $userObj->backendCheckLogin(); |
|
377 | 377 | |
378 | - return $userObj; |
|
378 | + return $userObj; |
|
379 | 379 | |
380 | - } else { |
|
380 | + } else { |
|
381 | 381 | |
382 | - if (TYPO3_DLOG) { |
|
382 | + if (TYPO3_DLOG) { |
|
383 | 383 | |
384 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getBeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
384 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getBeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
385 | 385 | |
386 | - } |
|
386 | + } |
|
387 | 387 | |
388 | - return; |
|
388 | + return; |
|
389 | 389 | |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | - } |
|
392 | + } |
|
393 | 393 | |
394 | - /** |
|
395 | - * Get the current frontend user object |
|
396 | - * |
|
397 | - * @access public |
|
398 | - * |
|
399 | - * @return \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication Instance of \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication or NULL on failure |
|
400 | - */ |
|
401 | - public static function getFeUser() { |
|
394 | + /** |
|
395 | + * Get the current frontend user object |
|
396 | + * |
|
397 | + * @access public |
|
398 | + * |
|
399 | + * @return \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication Instance of \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication or NULL on failure |
|
400 | + */ |
|
401 | + public static function getFeUser() { |
|
402 | 402 | |
403 | - if (TYPO3_MODE === 'FE') { |
|
403 | + if (TYPO3_MODE === 'FE') { |
|
404 | 404 | |
405 | - // Check if a user is currently logged in. |
|
406 | - if (!empty($GLOBALS['TSFE']->loginUser)) { |
|
405 | + // Check if a user is currently logged in. |
|
406 | + if (!empty($GLOBALS['TSFE']->loginUser)) { |
|
407 | 407 | |
408 | - return $GLOBALS['TSFE']->fe_user; |
|
408 | + return $GLOBALS['TSFE']->fe_user; |
|
409 | 409 | |
410 | - } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('eID') !== NULL) { |
|
410 | + } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('eID') !== NULL) { |
|
411 | 411 | |
412 | - return \TYPO3\CMS\Frontend\Utility\EidUtility::initFeUser(); |
|
412 | + return \TYPO3\CMS\Frontend\Utility\EidUtility::initFeUser(); |
|
413 | 413 | |
414 | - } |
|
414 | + } |
|
415 | 415 | |
416 | - } else { |
|
416 | + } else { |
|
417 | 417 | |
418 | - if (TYPO3_DLOG) { |
|
418 | + if (TYPO3_DLOG) { |
|
419 | 419 | |
420 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getFeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
420 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getFeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
421 | 421 | |
422 | - } |
|
422 | + } |
|
423 | 423 | |
424 | - } |
|
424 | + } |
|
425 | 425 | |
426 | - return; |
|
426 | + return; |
|
427 | 427 | |
428 | - } |
|
428 | + } |
|
429 | 429 | |
430 | - /** |
|
431 | - * Get the registered hook objects for a class |
|
432 | - * |
|
433 | - * @access public |
|
434 | - * |
|
435 | - * @param string $scriptRelPath: The path to the class file |
|
436 | - * |
|
437 | - * @return array Array of hook objects for the class |
|
438 | - */ |
|
439 | - public static function getHookObjects($scriptRelPath) { |
|
430 | + /** |
|
431 | + * Get the registered hook objects for a class |
|
432 | + * |
|
433 | + * @access public |
|
434 | + * |
|
435 | + * @param string $scriptRelPath: The path to the class file |
|
436 | + * |
|
437 | + * @return array Array of hook objects for the class |
|
438 | + */ |
|
439 | + public static function getHookObjects($scriptRelPath) { |
|
440 | 440 | |
441 | - $hookObjects = array (); |
|
441 | + $hookObjects = array (); |
|
442 | 442 | |
443 | - if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) { |
|
443 | + if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) { |
|
444 | 444 | |
445 | - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'] as $classRef) { |
|
445 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'] as $classRef) { |
|
446 | 446 | |
447 | - $hookObjects[] = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); |
|
447 | + $hookObjects[] = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); |
|
448 | 448 | |
449 | - } |
|
449 | + } |
|
450 | 450 | |
451 | - } |
|
451 | + } |
|
452 | 452 | |
453 | - return $hookObjects; |
|
453 | + return $hookObjects; |
|
454 | 454 | |
455 | - } |
|
455 | + } |
|
456 | 456 | |
457 | - /** |
|
458 | - * Get the "index_name" for an UID |
|
459 | - * |
|
460 | - * @access public |
|
461 | - * |
|
462 | - * @param integer $uid: The UID of the record |
|
463 | - * @param string $table: Get the "index_name" from this table |
|
464 | - * @param integer $pid: Get the "index_name" from this page |
|
465 | - * |
|
466 | - * @return string "index_name" for the given UID |
|
467 | - */ |
|
468 | - public static function getIndexName($uid, $table, $pid = -1) { |
|
457 | + /** |
|
458 | + * Get the "index_name" for an UID |
|
459 | + * |
|
460 | + * @access public |
|
461 | + * |
|
462 | + * @param integer $uid: The UID of the record |
|
463 | + * @param string $table: Get the "index_name" from this table |
|
464 | + * @param integer $pid: Get the "index_name" from this page |
|
465 | + * |
|
466 | + * @return string "index_name" for the given UID |
|
467 | + */ |
|
468 | + public static function getIndexName($uid, $table, $pid = -1) { |
|
469 | 469 | |
470 | - // Save parameters for logging purposes. |
|
471 | - $_uid = $uid; |
|
470 | + // Save parameters for logging purposes. |
|
471 | + $_uid = $uid; |
|
472 | 472 | |
473 | - $_pid = $pid; |
|
473 | + $_pid = $pid; |
|
474 | 474 | |
475 | - // Sanitize input. |
|
476 | - $uid = max(intval($uid), 0); |
|
475 | + // Sanitize input. |
|
476 | + $uid = max(intval($uid), 0); |
|
477 | 477 | |
478 | - if (!$uid || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
478 | + if (!$uid || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
479 | 479 | |
480 | - if (TYPO3_DLOG) { |
|
480 | + if (TYPO3_DLOG) { |
|
481 | 481 | |
482 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] Invalid UID "'.$uid.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
482 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] Invalid UID "'.$uid.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
483 | 483 | |
484 | - } |
|
484 | + } |
|
485 | 485 | |
486 | - return ''; |
|
486 | + return ''; |
|
487 | 487 | |
488 | - } |
|
488 | + } |
|
489 | 489 | |
490 | - $where = ''; |
|
490 | + $where = ''; |
|
491 | 491 | |
492 | - // Should we check for a specific PID, too? |
|
493 | - if ($pid !== -1) { |
|
492 | + // Should we check for a specific PID, too? |
|
493 | + if ($pid !== -1) { |
|
494 | 494 | |
495 | - $pid = max(intval($pid), 0); |
|
495 | + $pid = max(intval($pid), 0); |
|
496 | 496 | |
497 | - $where = ' AND '.$table.'.pid='.$pid; |
|
497 | + $where = ' AND '.$table.'.pid='.$pid; |
|
498 | 498 | |
499 | - } |
|
499 | + } |
|
500 | 500 | |
501 | - // Get index_name from database. |
|
502 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
503 | - $table.'.index_name AS index_name', |
|
504 | - $table, |
|
505 | - $table.'.uid='.$uid.$where.self::whereClause($table), |
|
506 | - '', |
|
507 | - '', |
|
508 | - '1' |
|
509 | - ); |
|
501 | + // Get index_name from database. |
|
502 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
503 | + $table.'.index_name AS index_name', |
|
504 | + $table, |
|
505 | + $table.'.uid='.$uid.$where.self::whereClause($table), |
|
506 | + '', |
|
507 | + '', |
|
508 | + '1' |
|
509 | + ); |
|
510 | 510 | |
511 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
511 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
512 | 512 | |
513 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
513 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
514 | 514 | |
515 | - return $resArray['index_name']; |
|
515 | + return $resArray['index_name']; |
|
516 | 516 | |
517 | - } else { |
|
517 | + } else { |
|
518 | 518 | |
519 | - if (TYPO3_DLOG) { |
|
519 | + if (TYPO3_DLOG) { |
|
520 | 520 | |
521 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] No "index_name" with UID "'.$uid.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
521 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] No "index_name" with UID "'.$uid.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
522 | 522 | |
523 | - } |
|
523 | + } |
|
524 | 524 | |
525 | - return ''; |
|
525 | + return ''; |
|
526 | 526 | |
527 | - } |
|
527 | + } |
|
528 | 528 | |
529 | - } |
|
529 | + } |
|
530 | 530 | |
531 | - /** |
|
532 | - * Get the UID for a given "index_name" |
|
533 | - * |
|
534 | - * @access public |
|
535 | - * |
|
536 | - * @param integer $index_name: The index_name of the record |
|
537 | - * @param string $table: Get the "index_name" from this table |
|
538 | - * @param integer $pid: Get the "index_name" from this page |
|
539 | - * |
|
540 | - * @return string "uid" for the given index_name |
|
541 | - */ |
|
542 | - public static function getIdFromIndexName($index_name, $table, $pid = -1) { |
|
531 | + /** |
|
532 | + * Get the UID for a given "index_name" |
|
533 | + * |
|
534 | + * @access public |
|
535 | + * |
|
536 | + * @param integer $index_name: The index_name of the record |
|
537 | + * @param string $table: Get the "index_name" from this table |
|
538 | + * @param integer $pid: Get the "index_name" from this page |
|
539 | + * |
|
540 | + * @return string "uid" for the given index_name |
|
541 | + */ |
|
542 | + public static function getIdFromIndexName($index_name, $table, $pid = -1) { |
|
543 | 543 | |
544 | - // Save parameters for logging purposes. |
|
545 | - $_index_name = $index_name; |
|
544 | + // Save parameters for logging purposes. |
|
545 | + $_index_name = $index_name; |
|
546 | 546 | |
547 | - $_pid = $pid; |
|
547 | + $_pid = $pid; |
|
548 | 548 | |
549 | - if (!$index_name || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
549 | + if (!$index_name || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
550 | 550 | |
551 | - if (TYPO3_DLOG) { |
|
551 | + if (TYPO3_DLOG) { |
|
552 | 552 | |
553 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] Invalid UID "'.$index_name.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
553 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] Invalid UID "'.$index_name.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
554 | 554 | |
555 | - } |
|
555 | + } |
|
556 | 556 | |
557 | - return ''; |
|
557 | + return ''; |
|
558 | 558 | |
559 | - } |
|
559 | + } |
|
560 | 560 | |
561 | - $where = ''; |
|
561 | + $where = ''; |
|
562 | 562 | |
563 | - // Should we check for a specific PID, too? |
|
564 | - if ($pid !== -1) { |
|
563 | + // Should we check for a specific PID, too? |
|
564 | + if ($pid !== -1) { |
|
565 | 565 | |
566 | - $pid = max(intval($pid), 0); |
|
566 | + $pid = max(intval($pid), 0); |
|
567 | 567 | |
568 | - $where = ' AND '.$table.'.pid='.$pid; |
|
568 | + $where = ' AND '.$table.'.pid='.$pid; |
|
569 | 569 | |
570 | - } |
|
570 | + } |
|
571 | 571 | |
572 | - // Get index_name from database. |
|
573 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
574 | - $table.'.uid AS uid', |
|
575 | - $table, |
|
576 | - $table.'.index_name="'.$index_name.'"'.$where.self::whereClause($table), |
|
577 | - '', |
|
578 | - '', |
|
579 | - '1' |
|
580 | - ); |
|
572 | + // Get index_name from database. |
|
573 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
574 | + $table.'.uid AS uid', |
|
575 | + $table, |
|
576 | + $table.'.index_name="'.$index_name.'"'.$where.self::whereClause($table), |
|
577 | + '', |
|
578 | + '', |
|
579 | + '1' |
|
580 | + ); |
|
581 | 581 | |
582 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
582 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
583 | 583 | |
584 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
584 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
585 | 585 | |
586 | - return $resArray['uid']; |
|
586 | + return $resArray['uid']; |
|
587 | 587 | |
588 | - } else { |
|
588 | + } else { |
|
589 | 589 | |
590 | - if (TYPO3_DLOG) { |
|
590 | + if (TYPO3_DLOG) { |
|
591 | 591 | |
592 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] No UID for given "index_name" "'.$index_name.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
592 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] No UID for given "index_name" "'.$index_name.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
593 | 593 | |
594 | - } |
|
594 | + } |
|
595 | 595 | |
596 | - return ''; |
|
596 | + return ''; |
|
597 | 597 | |
598 | - } |
|
598 | + } |
|
599 | 599 | |
600 | - } |
|
600 | + } |
|
601 | 601 | |
602 | - /** |
|
603 | - * Get language name from ISO code |
|
604 | - * |
|
605 | - * @access public |
|
606 | - * |
|
607 | - * @param string $code: ISO 639-1 or ISO 639-2/B language code |
|
608 | - * |
|
609 | - * @return string Localized full name of language or unchanged input |
|
610 | - */ |
|
611 | - public static function getLanguageName($code) { |
|
602 | + /** |
|
603 | + * Get language name from ISO code |
|
604 | + * |
|
605 | + * @access public |
|
606 | + * |
|
607 | + * @param string $code: ISO 639-1 or ISO 639-2/B language code |
|
608 | + * |
|
609 | + * @return string Localized full name of language or unchanged input |
|
610 | + */ |
|
611 | + public static function getLanguageName($code) { |
|
612 | 612 | |
613 | - // Analyze code and set appropriate ISO table. |
|
614 | - $isoCode = strtolower(trim($code)); |
|
613 | + // Analyze code and set appropriate ISO table. |
|
614 | + $isoCode = strtolower(trim($code)); |
|
615 | 615 | |
616 | - if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
|
616 | + if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
|
617 | 617 | |
618 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-2b.xml'; |
|
618 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-2b.xml'; |
|
619 | 619 | |
620 | - } elseif (preg_match('/^[a-z]{2}$/', $isoCode)) { |
|
620 | + } elseif (preg_match('/^[a-z]{2}$/', $isoCode)) { |
|
621 | 621 | |
622 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-1.xml'; |
|
622 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-1.xml'; |
|
623 | 623 | |
624 | - } else { |
|
624 | + } else { |
|
625 | 625 | |
626 | - // No ISO code, return unchanged. |
|
627 | - return $code; |
|
626 | + // No ISO code, return unchanged. |
|
627 | + return $code; |
|
628 | 628 | |
629 | - } |
|
629 | + } |
|
630 | 630 | |
631 | - // Load ISO table and get localized full name of language. |
|
632 | - if (TYPO3_MODE === 'FE') { |
|
631 | + // Load ISO table and get localized full name of language. |
|
632 | + if (TYPO3_MODE === 'FE') { |
|
633 | 633 | |
634 | - $iso639 = $GLOBALS['TSFE']->readLLfile($file); |
|
634 | + $iso639 = $GLOBALS['TSFE']->readLLfile($file); |
|
635 | 635 | |
636 | - if (!empty($iso639['default'][$isoCode])) { |
|
636 | + if (!empty($iso639['default'][$isoCode])) { |
|
637 | 637 | |
638 | - $lang = $GLOBALS['TSFE']->getLLL($isoCode, $iso639); |
|
638 | + $lang = $GLOBALS['TSFE']->getLLL($isoCode, $iso639); |
|
639 | 639 | |
640 | - } |
|
640 | + } |
|
641 | 641 | |
642 | - } elseif (TYPO3_MODE === 'BE') { |
|
642 | + } elseif (TYPO3_MODE === 'BE') { |
|
643 | 643 | |
644 | - $iso639 = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
644 | + $iso639 = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
645 | 645 | |
646 | - if (!empty($iso639['default'][$isoCode])) { |
|
646 | + if (!empty($iso639['default'][$isoCode])) { |
|
647 | 647 | |
648 | - $lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639, FALSE); |
|
648 | + $lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639, FALSE); |
|
649 | 649 | |
650 | - } |
|
650 | + } |
|
651 | 651 | |
652 | - } else { |
|
652 | + } else { |
|
653 | 653 | |
654 | - if (TYPO3_DLOG) { |
|
654 | + if (TYPO3_DLOG) { |
|
655 | 655 | |
656 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
656 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
657 | 657 | |
658 | - } |
|
658 | + } |
|
659 | 659 | |
660 | - return $code; |
|
660 | + return $code; |
|
661 | 661 | |
662 | - } |
|
662 | + } |
|
663 | 663 | |
664 | - if (!empty($lang)) { |
|
664 | + if (!empty($lang)) { |
|
665 | 665 | |
666 | - return $lang; |
|
666 | + return $lang; |
|
667 | 667 | |
668 | - } else { |
|
668 | + } else { |
|
669 | 669 | |
670 | - if (TYPO3_DLOG) { |
|
670 | + if (TYPO3_DLOG) { |
|
671 | 671 | |
672 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Language code "'.$code.'" not found in ISO-639 table', self::$extKey, SYSLOG_SEVERITY_NOTICE); |
|
672 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Language code "'.$code.'" not found in ISO-639 table', self::$extKey, SYSLOG_SEVERITY_NOTICE); |
|
673 | 673 | |
674 | - } |
|
674 | + } |
|
675 | 675 | |
676 | - return $code; |
|
676 | + return $code; |
|
677 | 677 | |
678 | - } |
|
678 | + } |
|
679 | 679 | |
680 | - } |
|
680 | + } |
|
681 | 681 | |
682 | - /** |
|
683 | - * Wrapper function for getting localizations in frontend and backend |
|
684 | - * |
|
685 | - * @param string $key: The locallang key to translate |
|
686 | - * @param boolean $hsc: Should the result be htmlspecialchar()'ed? |
|
687 | - * @param string $default: Default return value if no translation is available |
|
688 | - * |
|
689 | - * @return string The translated string or the given key on failure |
|
690 | - */ |
|
691 | - public static function getLL($key, $hsc = FALSE, $default = '') { |
|
682 | + /** |
|
683 | + * Wrapper function for getting localizations in frontend and backend |
|
684 | + * |
|
685 | + * @param string $key: The locallang key to translate |
|
686 | + * @param boolean $hsc: Should the result be htmlspecialchar()'ed? |
|
687 | + * @param string $default: Default return value if no translation is available |
|
688 | + * |
|
689 | + * @return string The translated string or the given key on failure |
|
690 | + */ |
|
691 | + public static function getLL($key, $hsc = FALSE, $default = '') { |
|
692 | 692 | |
693 | - // Set initial output to default value. |
|
694 | - $translated = (string) $default; |
|
693 | + // Set initial output to default value. |
|
694 | + $translated = (string) $default; |
|
695 | 695 | |
696 | - // Load common locallang file. |
|
697 | - if (empty(self::$locallang)) { |
|
696 | + // Load common locallang file. |
|
697 | + if (empty(self::$locallang)) { |
|
698 | 698 | |
699 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey, 'common/locallang.xml'); |
|
699 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey, 'common/locallang.xml'); |
|
700 | 700 | |
701 | - if (TYPO3_MODE === 'FE') { |
|
701 | + if (TYPO3_MODE === 'FE') { |
|
702 | 702 | |
703 | - self::$locallang = $GLOBALS['TSFE']->readLLfile($file); |
|
703 | + self::$locallang = $GLOBALS['TSFE']->readLLfile($file); |
|
704 | 704 | |
705 | - } elseif (TYPO3_MODE === 'BE') { |
|
705 | + } elseif (TYPO3_MODE === 'BE') { |
|
706 | 706 | |
707 | - self::$locallang = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
707 | + self::$locallang = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
708 | 708 | |
709 | - } elseif (TYPO3_DLOG) { |
|
709 | + } elseif (TYPO3_DLOG) { |
|
710 | 710 | |
711 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
711 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
712 | 712 | |
713 | - } |
|
713 | + } |
|
714 | 714 | |
715 | - } |
|
715 | + } |
|
716 | 716 | |
717 | - // Get translation. |
|
718 | - if (!empty(self::$locallang['default'][$key])) { |
|
717 | + // Get translation. |
|
718 | + if (!empty(self::$locallang['default'][$key])) { |
|
719 | 719 | |
720 | - if (TYPO3_MODE === 'FE') { |
|
720 | + if (TYPO3_MODE === 'FE') { |
|
721 | 721 | |
722 | - $translated = $GLOBALS['TSFE']->getLLL($key, self::$locallang); |
|
722 | + $translated = $GLOBALS['TSFE']->getLLL($key, self::$locallang); |
|
723 | 723 | |
724 | - } elseif (TYPO3_MODE === 'BE') { |
|
724 | + } elseif (TYPO3_MODE === 'BE') { |
|
725 | 725 | |
726 | - $translated = $GLOBALS['LANG']->getLLL($key, self::$locallang, FALSE); |
|
726 | + $translated = $GLOBALS['LANG']->getLLL($key, self::$locallang, FALSE); |
|
727 | 727 | |
728 | - } elseif (TYPO3_DLOG) { |
|
728 | + } elseif (TYPO3_DLOG) { |
|
729 | 729 | |
730 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
730 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
731 | 731 | |
732 | - } |
|
732 | + } |
|
733 | 733 | |
734 | - } |
|
734 | + } |
|
735 | 735 | |
736 | - // Escape HTML characters if applicable. |
|
737 | - if ($hsc) { |
|
736 | + // Escape HTML characters if applicable. |
|
737 | + if ($hsc) { |
|
738 | 738 | |
739 | - $translated = htmlspecialchars($translated); |
|
739 | + $translated = htmlspecialchars($translated); |
|
740 | 740 | |
741 | - } |
|
741 | + } |
|
742 | 742 | |
743 | - return $translated; |
|
743 | + return $translated; |
|
744 | 744 | |
745 | - } |
|
745 | + } |
|
746 | 746 | |
747 | - /** |
|
748 | - * Get the URN of an object |
|
749 | - * @see http://www.persistent-identifier.de/?link=316 |
|
750 | - * |
|
751 | - * @access public |
|
752 | - * |
|
753 | - * @param string $base: The namespace and base URN |
|
754 | - * @param string $id: The object's identifier |
|
755 | - * |
|
756 | - * @return string Uniform Resource Name as string |
|
757 | - */ |
|
758 | - public static function getURN($base, $id) { |
|
747 | + /** |
|
748 | + * Get the URN of an object |
|
749 | + * @see http://www.persistent-identifier.de/?link=316 |
|
750 | + * |
|
751 | + * @access public |
|
752 | + * |
|
753 | + * @param string $base: The namespace and base URN |
|
754 | + * @param string $id: The object's identifier |
|
755 | + * |
|
756 | + * @return string Uniform Resource Name as string |
|
757 | + */ |
|
758 | + public static function getURN($base, $id) { |
|
759 | 759 | |
760 | - $concordance = array ( |
|
761 | - '0' => 1, |
|
762 | - '1' => 2, |
|
763 | - '2' => 3, |
|
764 | - '3' => 4, |
|
765 | - '4' => 5, |
|
766 | - '5' => 6, |
|
767 | - '6' => 7, |
|
768 | - '7' => 8, |
|
769 | - '8' => 9, |
|
770 | - '9' => 41, |
|
771 | - 'a' => 18, |
|
772 | - 'b' => 14, |
|
773 | - 'c' => 19, |
|
774 | - 'd' => 15, |
|
775 | - 'e' => 16, |
|
776 | - 'f' => 21, |
|
777 | - 'g' => 22, |
|
778 | - 'h' => 23, |
|
779 | - 'i' => 24, |
|
780 | - 'j' => 25, |
|
781 | - 'k' => 42, |
|
782 | - 'l' => 26, |
|
783 | - 'm' => 27, |
|
784 | - 'n' => 13, |
|
785 | - 'o' => 28, |
|
786 | - 'p' => 29, |
|
787 | - 'q' => 31, |
|
788 | - 'r' => 12, |
|
789 | - 's' => 32, |
|
790 | - 't' => 33, |
|
791 | - 'u' => 11, |
|
792 | - 'v' => 34, |
|
793 | - 'w' => 35, |
|
794 | - 'x' => 36, |
|
795 | - 'y' => 37, |
|
796 | - 'z' => 38, |
|
797 | - '-' => 39, |
|
798 | - ':' => 17, |
|
799 | - ); |
|
760 | + $concordance = array ( |
|
761 | + '0' => 1, |
|
762 | + '1' => 2, |
|
763 | + '2' => 3, |
|
764 | + '3' => 4, |
|
765 | + '4' => 5, |
|
766 | + '5' => 6, |
|
767 | + '6' => 7, |
|
768 | + '7' => 8, |
|
769 | + '8' => 9, |
|
770 | + '9' => 41, |
|
771 | + 'a' => 18, |
|
772 | + 'b' => 14, |
|
773 | + 'c' => 19, |
|
774 | + 'd' => 15, |
|
775 | + 'e' => 16, |
|
776 | + 'f' => 21, |
|
777 | + 'g' => 22, |
|
778 | + 'h' => 23, |
|
779 | + 'i' => 24, |
|
780 | + 'j' => 25, |
|
781 | + 'k' => 42, |
|
782 | + 'l' => 26, |
|
783 | + 'm' => 27, |
|
784 | + 'n' => 13, |
|
785 | + 'o' => 28, |
|
786 | + 'p' => 29, |
|
787 | + 'q' => 31, |
|
788 | + 'r' => 12, |
|
789 | + 's' => 32, |
|
790 | + 't' => 33, |
|
791 | + 'u' => 11, |
|
792 | + 'v' => 34, |
|
793 | + 'w' => 35, |
|
794 | + 'x' => 36, |
|
795 | + 'y' => 37, |
|
796 | + 'z' => 38, |
|
797 | + '-' => 39, |
|
798 | + ':' => 17, |
|
799 | + ); |
|
800 | 800 | |
801 | - $urn = strtolower($base.$id); |
|
801 | + $urn = strtolower($base.$id); |
|
802 | 802 | |
803 | - if (preg_match('/[^a-z0-9:-]/', $urn)) { |
|
803 | + if (preg_match('/[^a-z0-9:-]/', $urn)) { |
|
804 | 804 | |
805 | - if (TYPO3_DLOG) { |
|
805 | + if (TYPO3_DLOG) { |
|
806 | 806 | |
807 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getURN('.$base.', '.$id.')] Invalid chars in given parameters', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
807 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getURN('.$base.', '.$id.')] Invalid chars in given parameters', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
808 | 808 | |
809 | - } |
|
809 | + } |
|
810 | 810 | |
811 | - return ''; |
|
811 | + return ''; |
|
812 | 812 | |
813 | - } |
|
813 | + } |
|
814 | 814 | |
815 | - $digits = ''; |
|
815 | + $digits = ''; |
|
816 | 816 | |
817 | - for ($i = 0, $j = strlen($urn); $i < $j; $i++) { |
|
817 | + for ($i = 0, $j = strlen($urn); $i < $j; $i++) { |
|
818 | 818 | |
819 | - $digits .= $concordance[substr($urn, $i, 1)]; |
|
819 | + $digits .= $concordance[substr($urn, $i, 1)]; |
|
820 | 820 | |
821 | - } |
|
821 | + } |
|
822 | 822 | |
823 | - $checksum = 0; |
|
823 | + $checksum = 0; |
|
824 | 824 | |
825 | - for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
825 | + for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
826 | 826 | |
827 | - $checksum += ($i + 1) * intval(substr($digits, $i, 1)); |
|
827 | + $checksum += ($i + 1) * intval(substr($digits, $i, 1)); |
|
828 | 828 | |
829 | - } |
|
829 | + } |
|
830 | 830 | |
831 | - $checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1); |
|
831 | + $checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1); |
|
832 | 832 | |
833 | - return $base.$id.$checksum; |
|
833 | + return $base.$id.$checksum; |
|
834 | 834 | |
835 | - } |
|
835 | + } |
|
836 | 836 | |
837 | - /** |
|
838 | - * Check if given ID is a valid Pica Production Number (PPN) |
|
839 | - * |
|
840 | - * @access public |
|
841 | - * |
|
842 | - * @param string $ppn: The identifier to check |
|
843 | - * |
|
844 | - * @return boolean Is $id a valid PPN? |
|
845 | - */ |
|
846 | - public static function isPPN($id) { |
|
837 | + /** |
|
838 | + * Check if given ID is a valid Pica Production Number (PPN) |
|
839 | + * |
|
840 | + * @access public |
|
841 | + * |
|
842 | + * @param string $ppn: The identifier to check |
|
843 | + * |
|
844 | + * @return boolean Is $id a valid PPN? |
|
845 | + */ |
|
846 | + public static function isPPN($id) { |
|
847 | 847 | |
848 | - return self::checkIdentifier($id, 'PPN'); |
|
848 | + return self::checkIdentifier($id, 'PPN'); |
|
849 | 849 | |
850 | - } |
|
850 | + } |
|
851 | 851 | |
852 | - /** |
|
853 | - * Load value from user's session. |
|
854 | - * |
|
855 | - * @access public |
|
856 | - * |
|
857 | - * @param string $key: Session data key for retrieval |
|
858 | - * |
|
859 | - * @return mixed Session value for given key or NULL on failure |
|
860 | - */ |
|
861 | - public static function loadFromSession($key) { |
|
852 | + /** |
|
853 | + * Load value from user's session. |
|
854 | + * |
|
855 | + * @access public |
|
856 | + * |
|
857 | + * @param string $key: Session data key for retrieval |
|
858 | + * |
|
859 | + * @return mixed Session value for given key or NULL on failure |
|
860 | + */ |
|
861 | + public static function loadFromSession($key) { |
|
862 | 862 | |
863 | - // Save parameter for logging purposes. |
|
864 | - $_key = $key; |
|
863 | + // Save parameter for logging purposes. |
|
864 | + $_key = $key; |
|
865 | 865 | |
866 | - // Cast to string for security reasons. |
|
867 | - $key = (string) $key; |
|
866 | + // Cast to string for security reasons. |
|
867 | + $key = (string) $key; |
|
868 | 868 | |
869 | - if (!$key) { |
|
869 | + if (!$key) { |
|
870 | 870 | |
871 | - if (TYPO3_DLOG) { |
|
871 | + if (TYPO3_DLOG) { |
|
872 | 872 | |
873 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Invalid key "'.$key.'" for session data retrieval', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
873 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Invalid key "'.$key.'" for session data retrieval', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
874 | 874 | |
875 | - } |
|
875 | + } |
|
876 | 876 | |
877 | - return; |
|
877 | + return; |
|
878 | 878 | |
879 | - } |
|
879 | + } |
|
880 | 880 | |
881 | - // Get the session data. |
|
882 | - if (TYPO3_MODE === 'FE') { |
|
881 | + // Get the session data. |
|
882 | + if (TYPO3_MODE === 'FE') { |
|
883 | 883 | |
884 | - return $GLOBALS['TSFE']->fe_user->getKey('ses', $key); |
|
884 | + return $GLOBALS['TSFE']->fe_user->getKey('ses', $key); |
|
885 | 885 | |
886 | - } elseif (TYPO3_MODE === 'BE') { |
|
886 | + } elseif (TYPO3_MODE === 'BE') { |
|
887 | 887 | |
888 | - return $GLOBALS['BE_USER']->getSessionData($key); |
|
888 | + return $GLOBALS['BE_USER']->getSessionData($key); |
|
889 | 889 | |
890 | - } else { |
|
890 | + } else { |
|
891 | 891 | |
892 | - if (TYPO3_DLOG) { |
|
892 | + if (TYPO3_DLOG) { |
|
893 | 893 | |
894 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
894 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
895 | 895 | |
896 | - } |
|
896 | + } |
|
897 | 897 | |
898 | - return; |
|
898 | + return; |
|
899 | 899 | |
900 | - } |
|
900 | + } |
|
901 | 901 | |
902 | - } |
|
902 | + } |
|
903 | 903 | |
904 | - /** |
|
905 | - * Process a data and/or command map with TYPO3 core engine. |
|
906 | - * |
|
907 | - * @access public |
|
908 | - * |
|
909 | - * @param array $data: Data map |
|
910 | - * @param array $cmd: Command map |
|
911 | - * @param boolean $reverseOrder: Should the command map be processed first? |
|
912 | - * @param boolean $be_user: Use current backend user's rights for processing? |
|
913 | - * |
|
914 | - * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
915 | - */ |
|
916 | - public static function processDB(array $data = array (), array $cmd = array (), $reverseOrder = FALSE, $be_user = FALSE) { |
|
904 | + /** |
|
905 | + * Process a data and/or command map with TYPO3 core engine. |
|
906 | + * |
|
907 | + * @access public |
|
908 | + * |
|
909 | + * @param array $data: Data map |
|
910 | + * @param array $cmd: Command map |
|
911 | + * @param boolean $reverseOrder: Should the command map be processed first? |
|
912 | + * @param boolean $be_user: Use current backend user's rights for processing? |
|
913 | + * |
|
914 | + * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
915 | + */ |
|
916 | + public static function processDB(array $data = array (), array $cmd = array (), $reverseOrder = FALSE, $be_user = FALSE) { |
|
917 | 917 | |
918 | - // Instantiate TYPO3 core engine. |
|
919 | - $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); |
|
918 | + // Instantiate TYPO3 core engine. |
|
919 | + $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); |
|
920 | 920 | |
921 | - // Set some configuration variables. |
|
922 | - $tce->stripslashes_values = FALSE; |
|
921 | + // Set some configuration variables. |
|
922 | + $tce->stripslashes_values = FALSE; |
|
923 | 923 | |
924 | - // Get backend user for processing. |
|
925 | - if ($be_user && isset($GLOBALS['BE_USER'])) { |
|
924 | + // Get backend user for processing. |
|
925 | + if ($be_user && isset($GLOBALS['BE_USER'])) { |
|
926 | 926 | |
927 | - $user = $GLOBALS['BE_USER']; |
|
927 | + $user = $GLOBALS['BE_USER']; |
|
928 | 928 | |
929 | - } else { |
|
929 | + } else { |
|
930 | 930 | |
931 | - $user = self::getBeUser(); |
|
931 | + $user = self::getBeUser(); |
|
932 | 932 | |
933 | - } |
|
933 | + } |
|
934 | 934 | |
935 | - // Load data and command arrays. |
|
936 | - $tce->start($data, $cmd, $user); |
|
935 | + // Load data and command arrays. |
|
936 | + $tce->start($data, $cmd, $user); |
|
937 | 937 | |
938 | - // Process command map first if default order is reversed. |
|
939 | - if ($cmd && $reverseOrder) { |
|
938 | + // Process command map first if default order is reversed. |
|
939 | + if ($cmd && $reverseOrder) { |
|
940 | 940 | |
941 | - $tce->process_cmdmap(); |
|
941 | + $tce->process_cmdmap(); |
|
942 | 942 | |
943 | - } |
|
943 | + } |
|
944 | 944 | |
945 | - // Process data map. |
|
946 | - if ($data) { |
|
945 | + // Process data map. |
|
946 | + if ($data) { |
|
947 | 947 | |
948 | - $tce->process_datamap(); |
|
948 | + $tce->process_datamap(); |
|
949 | 949 | |
950 | - } |
|
950 | + } |
|
951 | 951 | |
952 | - // Process command map if processing order is not reversed. |
|
953 | - if ($cmd && !$reverseOrder) { |
|
952 | + // Process command map if processing order is not reversed. |
|
953 | + if ($cmd && !$reverseOrder) { |
|
954 | 954 | |
955 | - $tce->process_cmdmap(); |
|
955 | + $tce->process_cmdmap(); |
|
956 | 956 | |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | - return $tce->substNEWwithIDs; |
|
959 | + return $tce->substNEWwithIDs; |
|
960 | 960 | |
961 | - } |
|
961 | + } |
|
962 | 962 | |
963 | - /** |
|
964 | - * Process a data and/or command map with TYPO3 core engine as admin. |
|
965 | - * |
|
966 | - * @access public |
|
967 | - * |
|
968 | - * @param array $data: Data map |
|
969 | - * @param array $cmd: Command map |
|
970 | - * @param boolean $reverseOrder: Should the command map be processed first? |
|
971 | - * |
|
972 | - * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
973 | - */ |
|
974 | - public static function processDBasAdmin(array $data = array (), array $cmd = array (), $reverseOrder = FALSE) { |
|
963 | + /** |
|
964 | + * Process a data and/or command map with TYPO3 core engine as admin. |
|
965 | + * |
|
966 | + * @access public |
|
967 | + * |
|
968 | + * @param array $data: Data map |
|
969 | + * @param array $cmd: Command map |
|
970 | + * @param boolean $reverseOrder: Should the command map be processed first? |
|
971 | + * |
|
972 | + * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
973 | + */ |
|
974 | + public static function processDBasAdmin(array $data = array (), array $cmd = array (), $reverseOrder = FALSE) { |
|
975 | 975 | |
976 | - if (TYPO3_MODE === 'BE' && $GLOBALS['BE_USER']->isAdmin()) { |
|
976 | + if (TYPO3_MODE === 'BE' && $GLOBALS['BE_USER']->isAdmin()) { |
|
977 | 977 | |
978 | - return self::processDB($data, $cmd, $reverseOrder, TRUE); |
|
978 | + return self::processDB($data, $cmd, $reverseOrder, TRUE); |
|
979 | 979 | |
980 | - } else { |
|
980 | + } else { |
|
981 | 981 | |
982 | - if (TYPO3_DLOG) { |
|
982 | + if (TYPO3_DLOG) { |
|
983 | 983 | |
984 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, array ('data' => $data, 'cmd' => $cmd)); |
|
984 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, array ('data' => $data, 'cmd' => $cmd)); |
|
985 | 985 | |
986 | - } |
|
986 | + } |
|
987 | 987 | |
988 | - return array (); |
|
988 | + return array (); |
|
989 | 989 | |
990 | - } |
|
990 | + } |
|
991 | 991 | |
992 | - } |
|
992 | + } |
|
993 | 993 | |
994 | - /** |
|
995 | - * Fetches and renders all available flash messages from the queue. |
|
996 | - * |
|
997 | - * @return string All flash messages in the queue rendered as HTML. |
|
998 | - */ |
|
999 | - public static function renderFlashMessages() { |
|
994 | + /** |
|
995 | + * Fetches and renders all available flash messages from the queue. |
|
996 | + * |
|
997 | + * @return string All flash messages in the queue rendered as HTML. |
|
998 | + */ |
|
999 | + public static function renderFlashMessages() { |
|
1000 | 1000 | |
1001 | - $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
1001 | + $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
1002 | 1002 | |
1003 | - $content = ''; |
|
1003 | + $content = ''; |
|
1004 | 1004 | |
1005 | - if (version_compare(TYPO3_branch, '7.4', '<')) { |
|
1005 | + if (version_compare(TYPO3_branch, '7.4', '<')) { |
|
1006 | 1006 | |
1007 | - // For TYPO3 6.2 - 7.3, we can use the existing method. |
|
1008 | - $content .= $flashMessageService->getMessageQueueByIdentifier()->renderFlashMessages(); |
|
1007 | + // For TYPO3 6.2 - 7.3, we can use the existing method. |
|
1008 | + $content .= $flashMessageService->getMessageQueueByIdentifier()->renderFlashMessages(); |
|
1009 | 1009 | |
1010 | - } else { |
|
1010 | + } else { |
|
1011 | 1011 | |
1012 | - // Since TYPO3 7.4.0, \TYPO3\CMS\Core\Messaging\FlashMessageQueue::renderFlashMessages |
|
1013 | - // uses htmlspecialchars on all texts, but we have message text with HTML tags. |
|
1014 | - // Therefore we copy the implementation from 7.4.0, but remove the htmlspecialchars call. |
|
1015 | - $flashMessages = $flashMessageService->getMessageQueueByIdentifier()->getAllMessagesAndFlush(); |
|
1012 | + // Since TYPO3 7.4.0, \TYPO3\CMS\Core\Messaging\FlashMessageQueue::renderFlashMessages |
|
1013 | + // uses htmlspecialchars on all texts, but we have message text with HTML tags. |
|
1014 | + // Therefore we copy the implementation from 7.4.0, but remove the htmlspecialchars call. |
|
1015 | + $flashMessages = $flashMessageService->getMessageQueueByIdentifier()->getAllMessagesAndFlush(); |
|
1016 | 1016 | |
1017 | - if (!empty($flashMessages)) { |
|
1017 | + if (!empty($flashMessages)) { |
|
1018 | 1018 | |
1019 | - $content .= '<ul class="typo3-messages">'; |
|
1019 | + $content .= '<ul class="typo3-messages">'; |
|
1020 | 1020 | |
1021 | - foreach ($flashMessages as $flashMessage) { |
|
1021 | + foreach ($flashMessages as $flashMessage) { |
|
1022 | 1022 | |
1023 | - $severityClass = sprintf('alert %s', $flashMessage->getClass()); |
|
1023 | + $severityClass = sprintf('alert %s', $flashMessage->getClass()); |
|
1024 | 1024 | |
1025 | - //~ $messageContent = htmlspecialchars($flashMessage->getMessage()); |
|
1025 | + //~ $messageContent = htmlspecialchars($flashMessage->getMessage()); |
|
1026 | 1026 | |
1027 | - $messageContent = $flashMessage->getMessage(); |
|
1027 | + $messageContent = $flashMessage->getMessage(); |
|
1028 | 1028 | |
1029 | - if ($flashMessage->getTitle() !== '') { |
|
1029 | + if ($flashMessage->getTitle() !== '') { |
|
1030 | 1030 | |
1031 | - $messageContent = sprintf('<h4>%s</h4>', htmlspecialchars($flashMessage->getTitle())).$messageContent; |
|
1031 | + $messageContent = sprintf('<h4>%s</h4>', htmlspecialchars($flashMessage->getTitle())).$messageContent; |
|
1032 | 1032 | |
1033 | - } |
|
1033 | + } |
|
1034 | 1034 | |
1035 | - $content .= sprintf('<li class="%s">%s</li>', htmlspecialchars($severityClass), $messageContent); |
|
1035 | + $content .= sprintf('<li class="%s">%s</li>', htmlspecialchars($severityClass), $messageContent); |
|
1036 | 1036 | |
1037 | - } |
|
1037 | + } |
|
1038 | 1038 | |
1039 | - $content .= '</ul>'; |
|
1039 | + $content .= '</ul>'; |
|
1040 | 1040 | |
1041 | - } |
|
1041 | + } |
|
1042 | 1042 | |
1043 | - } |
|
1043 | + } |
|
1044 | 1044 | |
1045 | - return $content; |
|
1045 | + return $content; |
|
1046 | 1046 | |
1047 | - } |
|
1047 | + } |
|
1048 | 1048 | |
1049 | - /** |
|
1050 | - * Save given value to user's session. |
|
1051 | - * |
|
1052 | - * @access public |
|
1053 | - * |
|
1054 | - * @param mixed $value: Value to save |
|
1055 | - * @param string $key: Session data key for saving |
|
1056 | - * |
|
1057 | - * @return boolean TRUE on success, FALSE on failure |
|
1058 | - */ |
|
1059 | - public static function saveToSession($value, $key) { |
|
1049 | + /** |
|
1050 | + * Save given value to user's session. |
|
1051 | + * |
|
1052 | + * @access public |
|
1053 | + * |
|
1054 | + * @param mixed $value: Value to save |
|
1055 | + * @param string $key: Session data key for saving |
|
1056 | + * |
|
1057 | + * @return boolean TRUE on success, FALSE on failure |
|
1058 | + */ |
|
1059 | + public static function saveToSession($value, $key) { |
|
1060 | 1060 | |
1061 | - // Save parameter for logging purposes. |
|
1062 | - $_key = $key; |
|
1061 | + // Save parameter for logging purposes. |
|
1062 | + $_key = $key; |
|
1063 | 1063 | |
1064 | - // Cast to string for security reasons. |
|
1065 | - $key = (string) $key; |
|
1064 | + // Cast to string for security reasons. |
|
1065 | + $key = (string) $key; |
|
1066 | 1066 | |
1067 | - if (!$key) { |
|
1067 | + if (!$key) { |
|
1068 | 1068 | |
1069 | - if (TYPO3_DLOG) { |
|
1069 | + if (TYPO3_DLOG) { |
|
1070 | 1070 | |
1071 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Invalid key "'.$key.'" for session data saving', self::$extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
1071 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Invalid key "'.$key.'" for session data saving', self::$extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
1072 | 1072 | |
1073 | - } |
|
1073 | + } |
|
1074 | 1074 | |
1075 | - return FALSE; |
|
1075 | + return FALSE; |
|
1076 | 1076 | |
1077 | - } |
|
1077 | + } |
|
1078 | 1078 | |
1079 | - // Save value in session data. |
|
1080 | - if (TYPO3_MODE === 'FE') { |
|
1079 | + // Save value in session data. |
|
1080 | + if (TYPO3_MODE === 'FE') { |
|
1081 | 1081 | |
1082 | - $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value); |
|
1082 | + $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value); |
|
1083 | 1083 | |
1084 | - $GLOBALS['TSFE']->fe_user->storeSessionData(); |
|
1084 | + $GLOBALS['TSFE']->fe_user->storeSessionData(); |
|
1085 | 1085 | |
1086 | - return TRUE; |
|
1086 | + return TRUE; |
|
1087 | 1087 | |
1088 | - } elseif (TYPO3_MODE === 'BE') { |
|
1088 | + } elseif (TYPO3_MODE === 'BE') { |
|
1089 | 1089 | |
1090 | - $GLOBALS['BE_USER']->setAndSaveSessionData($key, $value); |
|
1090 | + $GLOBALS['BE_USER']->setAndSaveSessionData($key, $value); |
|
1091 | 1091 | |
1092 | - return TRUE; |
|
1092 | + return TRUE; |
|
1093 | 1093 | |
1094 | - } else { |
|
1094 | + } else { |
|
1095 | 1095 | |
1096 | - if (TYPO3_DLOG) { |
|
1096 | + if (TYPO3_DLOG) { |
|
1097 | 1097 | |
1098 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR, $data); |
|
1098 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR, $data); |
|
1099 | 1099 | |
1100 | - } |
|
1100 | + } |
|
1101 | 1101 | |
1102 | - return FALSE; |
|
1102 | + return FALSE; |
|
1103 | 1103 | |
1104 | - } |
|
1104 | + } |
|
1105 | 1105 | |
1106 | - } |
|
1106 | + } |
|
1107 | 1107 | |
1108 | - /** |
|
1109 | - * This translates an internal "index_name" |
|
1110 | - * |
|
1111 | - * @access public |
|
1112 | - * |
|
1113 | - * @param string $index_name: The internal "index_name" to translate |
|
1114 | - * @param string $table: Get the translation from this table |
|
1115 | - * @param string $pid: Get the translation from this page |
|
1116 | - * |
|
1117 | - * @return string Localized label for $index_name |
|
1118 | - */ |
|
1119 | - public static function translate($index_name, $table, $pid) { |
|
1108 | + /** |
|
1109 | + * This translates an internal "index_name" |
|
1110 | + * |
|
1111 | + * @access public |
|
1112 | + * |
|
1113 | + * @param string $index_name: The internal "index_name" to translate |
|
1114 | + * @param string $table: Get the translation from this table |
|
1115 | + * @param string $pid: Get the translation from this page |
|
1116 | + * |
|
1117 | + * @return string Localized label for $index_name |
|
1118 | + */ |
|
1119 | + public static function translate($index_name, $table, $pid) { |
|
1120 | 1120 | |
1121 | - // Save parameters for logging purposes. |
|
1122 | - $_index_name = $index_name; |
|
1121 | + // Save parameters for logging purposes. |
|
1122 | + $_index_name = $index_name; |
|
1123 | 1123 | |
1124 | - $_pid = $pid; |
|
1124 | + $_pid = $pid; |
|
1125 | 1125 | |
1126 | - // Load labels into static variable for future use. |
|
1127 | - static $labels = array (); |
|
1126 | + // Load labels into static variable for future use. |
|
1127 | + static $labels = array (); |
|
1128 | 1128 | |
1129 | - // Sanitize input. |
|
1130 | - $pid = max(intval($pid), 0); |
|
1129 | + // Sanitize input. |
|
1130 | + $pid = max(intval($pid), 0); |
|
1131 | 1131 | |
1132 | - if (!$pid) { |
|
1132 | + if (!$pid) { |
|
1133 | 1133 | |
1134 | - if (TYPO3_DLOG) { |
|
1134 | + if (TYPO3_DLOG) { |
|
1135 | 1135 | |
1136 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] Invalid PID "'.$pid.'" for translation', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
1136 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] Invalid PID "'.$pid.'" for translation', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
1137 | 1137 | |
1138 | - } |
|
1138 | + } |
|
1139 | 1139 | |
1140 | - return $index_name; |
|
1140 | + return $index_name; |
|
1141 | 1141 | |
1142 | - } |
|
1142 | + } |
|
1143 | 1143 | |
1144 | - // Check if "index_name" is an UID. |
|
1145 | - if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($index_name)) { |
|
1144 | + // Check if "index_name" is an UID. |
|
1145 | + if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($index_name)) { |
|
1146 | 1146 | |
1147 | - $index_name = self::getIndexName($index_name, $table, $pid); |
|
1147 | + $index_name = self::getIndexName($index_name, $table, $pid); |
|
1148 | 1148 | |
1149 | - } |
|
1149 | + } |
|
1150 | 1150 | |
1151 | - /* $labels already contains the translated content element, but with the index_name of the translated content element itself |
|
1151 | + /* $labels already contains the translated content element, but with the index_name of the translated content element itself |
|
1152 | 1152 | * and not with the $index_name of the original that we receive here. So we have to determine the index_name of the |
1153 | 1153 | * associated translated content element. E.g. $labels['title0'] != $index_name = title. */ |
1154 | 1154 | |
1155 | - // First fetch the uid of the received index_name |
|
1156 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1157 | - 'uid, l18n_parent', |
|
1158 | - $table, |
|
1159 | - 'pid='.$pid.' AND index_name="'.$index_name.'"'.self::whereClause($table, TRUE), |
|
1160 | - '', |
|
1161 | - '', |
|
1162 | - '' |
|
1163 | - ); |
|
1155 | + // First fetch the uid of the received index_name |
|
1156 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1157 | + 'uid, l18n_parent', |
|
1158 | + $table, |
|
1159 | + 'pid='.$pid.' AND index_name="'.$index_name.'"'.self::whereClause($table, TRUE), |
|
1160 | + '', |
|
1161 | + '', |
|
1162 | + '' |
|
1163 | + ); |
|
1164 | 1164 | |
1165 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
1165 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
1166 | 1166 | |
1167 | - // Now we use the uid of the l18_parent to fetch the index_name of the translated content element. |
|
1168 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
1167 | + // Now we use the uid of the l18_parent to fetch the index_name of the translated content element. |
|
1168 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
1169 | 1169 | |
1170 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1171 | - 'index_name', |
|
1172 | - $table, |
|
1173 | - 'pid='.$pid.' AND uid='.$resArray['l18n_parent'].' AND sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).self::whereClause($table, TRUE), |
|
1174 | - '', |
|
1175 | - '', |
|
1176 | - '' |
|
1177 | - ); |
|
1170 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1171 | + 'index_name', |
|
1172 | + $table, |
|
1173 | + 'pid='.$pid.' AND uid='.$resArray['l18n_parent'].' AND sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).self::whereClause($table, TRUE), |
|
1174 | + '', |
|
1175 | + '', |
|
1176 | + '' |
|
1177 | + ); |
|
1178 | 1178 | |
1179 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
1179 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
1180 | 1180 | |
1181 | - // If there is an translated content element, overwrite the received $index_name. |
|
1182 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
1181 | + // If there is an translated content element, overwrite the received $index_name. |
|
1182 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
1183 | 1183 | |
1184 | - $index_name = $resArray['index_name']; |
|
1184 | + $index_name = $resArray['index_name']; |
|
1185 | 1185 | |
1186 | - } |
|
1186 | + } |
|
1187 | 1187 | |
1188 | - } |
|
1188 | + } |
|
1189 | 1189 | |
1190 | - // Check if we already got a translation. |
|
1191 | - if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
1190 | + // Check if we already got a translation. |
|
1191 | + if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
1192 | 1192 | |
1193 | - // Check if this table is allowed for translation. |
|
1194 | - if (in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) { |
|
1193 | + // Check if this table is allowed for translation. |
|
1194 | + if (in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) { |
|
1195 | 1195 | |
1196 | - $additionalWhere = ' AND sys_language_uid IN (-1,0)'; |
|
1196 | + $additionalWhere = ' AND sys_language_uid IN (-1,0)'; |
|
1197 | 1197 | |
1198 | - if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
1198 | + if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
1199 | 1199 | |
1200 | - $additionalWhere = ' AND (sys_language_uid IN (-1,0) OR (sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).' AND l18n_parent=0))'; |
|
1200 | + $additionalWhere = ' AND (sys_language_uid IN (-1,0) OR (sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).' AND l18n_parent=0))'; |
|
1201 | 1201 | |
1202 | - } |
|
1202 | + } |
|
1203 | 1203 | |
1204 | - // Get labels from database. |
|
1205 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1206 | - '*', |
|
1207 | - $table, |
|
1208 | - 'pid='.$pid.$additionalWhere.self::whereClause($table, TRUE), |
|
1209 | - '', |
|
1210 | - '', |
|
1211 | - '' |
|
1212 | - ); |
|
1204 | + // Get labels from database. |
|
1205 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
1206 | + '*', |
|
1207 | + $table, |
|
1208 | + 'pid='.$pid.$additionalWhere.self::whereClause($table, TRUE), |
|
1209 | + '', |
|
1210 | + '', |
|
1211 | + '' |
|
1212 | + ); |
|
1213 | 1213 | |
1214 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
1214 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
1215 | 1215 | |
1216 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
1216 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
1217 | 1217 | |
1218 | - // Overlay localized labels if available. |
|
1219 | - if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
1218 | + // Overlay localized labels if available. |
|
1219 | + if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
1220 | 1220 | |
1221 | - $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay($table, $resArray, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); |
|
1221 | + $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay($table, $resArray, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); |
|
1222 | 1222 | |
1223 | - } |
|
1223 | + } |
|
1224 | 1224 | |
1225 | - if ($resArray) { |
|
1225 | + if ($resArray) { |
|
1226 | 1226 | |
1227 | - $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$resArray['index_name']] = $resArray['label']; |
|
1227 | + $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$resArray['index_name']] = $resArray['label']; |
|
1228 | 1228 | |
1229 | - } |
|
1229 | + } |
|
1230 | 1230 | |
1231 | - } |
|
1231 | + } |
|
1232 | 1232 | |
1233 | - } else { |
|
1233 | + } else { |
|
1234 | 1234 | |
1235 | - if (TYPO3_DLOG) { |
|
1235 | + if (TYPO3_DLOG) { |
|
1236 | 1236 | |
1237 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translation with PID "'.$pid.'" available in table "'.$table.'" or translation not accessible', self::extKey, SYSLOG_SEVERITY_NOTICE); |
|
1237 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translation with PID "'.$pid.'" available in table "'.$table.'" or translation not accessible', self::extKey, SYSLOG_SEVERITY_NOTICE); |
|
1238 | 1238 | |
1239 | - } |
|
1239 | + } |
|
1240 | 1240 | |
1241 | - } |
|
1241 | + } |
|
1242 | 1242 | |
1243 | - } else { |
|
1243 | + } else { |
|
1244 | 1244 | |
1245 | - if (TYPO3_DLOG) { |
|
1245 | + if (TYPO3_DLOG) { |
|
1246 | 1246 | |
1247 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translations available for table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
1247 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translations available for table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
1248 | 1248 | |
1249 | - } |
|
1249 | + } |
|
1250 | 1250 | |
1251 | - } |
|
1251 | + } |
|
1252 | 1252 | |
1253 | - } |
|
1253 | + } |
|
1254 | 1254 | |
1255 | - if (!empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
1255 | + if (!empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
1256 | 1256 | |
1257 | - return $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name]; |
|
1257 | + return $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name]; |
|
1258 | 1258 | |
1259 | - } else { |
|
1259 | + } else { |
|
1260 | 1260 | |
1261 | - return $index_name; |
|
1261 | + return $index_name; |
|
1262 | 1262 | |
1263 | - } |
|
1263 | + } |
|
1264 | 1264 | |
1265 | - } |
|
1265 | + } |
|
1266 | 1266 | |
1267 | - /** |
|
1268 | - * This returns the additional WHERE clause of a table based on its TCA configuration |
|
1269 | - * |
|
1270 | - * @access public |
|
1271 | - * |
|
1272 | - * @param string $table: Table name as defined in TCA |
|
1273 | - * @param boolean $showHidden: Ignore the hidden flag? |
|
1274 | - * |
|
1275 | - * @return string Additional WHERE clause |
|
1276 | - */ |
|
1277 | - public static function whereClause($table, $showHidden = FALSE) { |
|
1267 | + /** |
|
1268 | + * This returns the additional WHERE clause of a table based on its TCA configuration |
|
1269 | + * |
|
1270 | + * @access public |
|
1271 | + * |
|
1272 | + * @param string $table: Table name as defined in TCA |
|
1273 | + * @param boolean $showHidden: Ignore the hidden flag? |
|
1274 | + * |
|
1275 | + * @return string Additional WHERE clause |
|
1276 | + */ |
|
1277 | + public static function whereClause($table, $showHidden = FALSE) { |
|
1278 | 1278 | |
1279 | - if (TYPO3_MODE === 'FE') { |
|
1279 | + if (TYPO3_MODE === 'FE') { |
|
1280 | 1280 | |
1281 | - // Table "tx_dlf_formats" always has PID 0. |
|
1282 | - if ($table == 'tx_dlf_formats') { |
|
1281 | + // Table "tx_dlf_formats" always has PID 0. |
|
1282 | + if ($table == 'tx_dlf_formats') { |
|
1283 | 1283 | |
1284 | - return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
1284 | + return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
1285 | 1285 | |
1286 | - } |
|
1286 | + } |
|
1287 | 1287 | |
1288 | - // Should we ignore the record's hidden flag? |
|
1289 | - $ignoreHide = -1; |
|
1288 | + // Should we ignore the record's hidden flag? |
|
1289 | + $ignoreHide = -1; |
|
1290 | 1290 | |
1291 | - if ($showHidden) { |
|
1291 | + if ($showHidden) { |
|
1292 | 1292 | |
1293 | - $ignoreHide = 1; |
|
1293 | + $ignoreHide = 1; |
|
1294 | 1294 | |
1295 | - } |
|
1295 | + } |
|
1296 | 1296 | |
1297 | - // $GLOBALS['TSFE']->sys_page is not always available in frontend. |
|
1298 | - if (is_object($GLOBALS['TSFE']->sys_page)) { |
|
1297 | + // $GLOBALS['TSFE']->sys_page is not always available in frontend. |
|
1298 | + if (is_object($GLOBALS['TSFE']->sys_page)) { |
|
1299 | 1299 | |
1300 | - return $GLOBALS['TSFE']->sys_page->enableFields($table, $ignoreHide); |
|
1300 | + return $GLOBALS['TSFE']->sys_page->enableFields($table, $ignoreHide); |
|
1301 | 1301 | |
1302 | - } else { |
|
1302 | + } else { |
|
1303 | 1303 | |
1304 | - $pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); |
|
1304 | + $pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); |
|
1305 | 1305 | |
1306 | - $GLOBALS['TSFE']->includeTCA(); |
|
1306 | + $GLOBALS['TSFE']->includeTCA(); |
|
1307 | 1307 | |
1308 | - return $pageRepository->enableFields($table, $ignoreHide); |
|
1308 | + return $pageRepository->enableFields($table, $ignoreHide); |
|
1309 | 1309 | |
1310 | - } |
|
1310 | + } |
|
1311 | 1311 | |
1312 | - } elseif (TYPO3_MODE === 'BE') { |
|
1312 | + } elseif (TYPO3_MODE === 'BE') { |
|
1313 | 1313 | |
1314 | - return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
1314 | + return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
1315 | 1315 | |
1316 | - } else { |
|
1316 | + } else { |
|
1317 | 1317 | |
1318 | - if (TYPO3_DLOG) { |
|
1318 | + if (TYPO3_DLOG) { |
|
1319 | 1319 | |
1320 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->whereClause('.$table.', ['.($showHidden ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1320 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->whereClause('.$table.', ['.($showHidden ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
1321 | 1321 | |
1322 | - } |
|
1322 | + } |
|
1323 | 1323 | |
1324 | - return ' AND 1=-1'; |
|
1324 | + return ' AND 1=-1'; |
|
1325 | 1325 | |
1326 | - } |
|
1326 | + } |
|
1327 | 1327 | |
1328 | - } |
|
1328 | + } |
|
1329 | 1329 | |
1330 | - /** |
|
1331 | - * This is a static class, thus no instances should be created |
|
1332 | - * |
|
1333 | - * @access private |
|
1334 | - */ |
|
1335 | - private function __construct() {} |
|
1330 | + /** |
|
1331 | + * This is a static class, thus no instances should be created |
|
1332 | + * |
|
1333 | + * @access private |
|
1334 | + */ |
|
1335 | + private function __construct() {} |
|
1336 | 1336 | |
1337 | 1337 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @var array |
35 | 35 | * @access protected |
36 | 36 | */ |
37 | - protected static $locallang = array (); |
|
37 | + protected static $locallang = array(); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Adds a message to the message queue. |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | $hash = $salt.substr(sha1($salt.$string), -10); |
351 | 351 | |
352 | - return array ('encrypted' => $encrypted, 'hash' => $hash); |
|
352 | + return array('encrypted' => $encrypted, 'hash' => $hash); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public static function getHookObjects($scriptRelPath) { |
440 | 440 | |
441 | - $hookObjects = array (); |
|
441 | + $hookObjects = array(); |
|
442 | 442 | |
443 | 443 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) { |
444 | 444 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | // Sanitize input. |
476 | 476 | $uid = max(intval($uid), 0); |
477 | 477 | |
478 | - if (!$uid || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
478 | + if (!$uid || !in_array($table, array('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
479 | 479 | |
480 | 480 | if (TYPO3_DLOG) { |
481 | 481 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | |
547 | 547 | $_pid = $pid; |
548 | 548 | |
549 | - if (!$index_name || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
549 | + if (!$index_name || !in_array($table, array('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
550 | 550 | |
551 | 551 | if (TYPO3_DLOG) { |
552 | 552 | |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | */ |
758 | 758 | public static function getURN($base, $id) { |
759 | 759 | |
760 | - $concordance = array ( |
|
760 | + $concordance = array( |
|
761 | 761 | '0' => 1, |
762 | 762 | '1' => 2, |
763 | 763 | '2' => 3, |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | * |
914 | 914 | * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
915 | 915 | */ |
916 | - public static function processDB(array $data = array (), array $cmd = array (), $reverseOrder = FALSE, $be_user = FALSE) { |
|
916 | + public static function processDB(array $data = array(), array $cmd = array(), $reverseOrder = FALSE, $be_user = FALSE) { |
|
917 | 917 | |
918 | 918 | // Instantiate TYPO3 core engine. |
919 | 919 | $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | * |
972 | 972 | * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
973 | 973 | */ |
974 | - public static function processDBasAdmin(array $data = array (), array $cmd = array (), $reverseOrder = FALSE) { |
|
974 | + public static function processDBasAdmin(array $data = array(), array $cmd = array(), $reverseOrder = FALSE) { |
|
975 | 975 | |
976 | 976 | if (TYPO3_MODE === 'BE' && $GLOBALS['BE_USER']->isAdmin()) { |
977 | 977 | |
@@ -981,11 +981,11 @@ discard block |
||
981 | 981 | |
982 | 982 | if (TYPO3_DLOG) { |
983 | 983 | |
984 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, array ('data' => $data, 'cmd' => $cmd)); |
|
984 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, array('data' => $data, 'cmd' => $cmd)); |
|
985 | 985 | |
986 | 986 | } |
987 | 987 | |
988 | - return array (); |
|
988 | + return array(); |
|
989 | 989 | |
990 | 990 | } |
991 | 991 | |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | $_pid = $pid; |
1125 | 1125 | |
1126 | 1126 | // Load labels into static variable for future use. |
1127 | - static $labels = array (); |
|
1127 | + static $labels = array(); |
|
1128 | 1128 | |
1129 | 1129 | // Sanitize input. |
1130 | 1130 | $pid = max(intval($pid), 0); |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
1192 | 1192 | |
1193 | 1193 | // Check if this table is allowed for translation. |
1194 | - if (in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) { |
|
1194 | + if (in_array($table, array('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) { |
|
1195 | 1195 | |
1196 | 1196 | $additionalWhere = ' AND sys_language_uid IN (-1,0)'; |
1197 | 1197 |
@@ -19,24 +19,24 @@ |
||
19 | 19 | */ |
20 | 20 | class tx_dlf_alto implements tx_dlf_fulltext { |
21 | 21 | |
22 | - /** |
|
23 | - * This extracts the fulltext data from ALTO XML |
|
24 | - * |
|
25 | - * @access public |
|
26 | - * |
|
27 | - * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
28 | - * |
|
29 | - * @return string The raw unformatted fulltext |
|
30 | - */ |
|
31 | - public static function getRawText(SimpleXMLElement $xml) { |
|
22 | + /** |
|
23 | + * This extracts the fulltext data from ALTO XML |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * |
|
27 | + * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
28 | + * |
|
29 | + * @return string The raw unformatted fulltext |
|
30 | + */ |
|
31 | + public static function getRawText(SimpleXMLElement $xml) { |
|
32 | 32 | |
33 | - $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); |
|
33 | + $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); |
|
34 | 34 | |
35 | - // Get all (presumed) words of the text. |
|
36 | - $words = $xml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String/@CONTENT'); |
|
35 | + // Get all (presumed) words of the text. |
|
36 | + $words = $xml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String/@CONTENT'); |
|
37 | 37 | |
38 | - return implode(' ', $words); |
|
38 | + return implode(' ', $words); |
|
39 | 39 | |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -20,320 +20,320 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class tx_dlf_plugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { |
22 | 22 | |
23 | - public $extKey = 'dlf'; |
|
23 | + public $extKey = 'dlf'; |
|
24 | 24 | |
25 | - public $prefixId = 'tx_dlf'; |
|
25 | + public $prefixId = 'tx_dlf'; |
|
26 | 26 | |
27 | - public $scriptRelPath = 'common/class.tx_dlf_plugin.php'; |
|
27 | + public $scriptRelPath = 'common/class.tx_dlf_plugin.php'; |
|
28 | 28 | |
29 | - // Plugins are cached by default (@see setCache()). |
|
30 | - public $pi_USER_INT_obj = FALSE; |
|
29 | + // Plugins are cached by default (@see setCache()). |
|
30 | + public $pi_USER_INT_obj = FALSE; |
|
31 | 31 | |
32 | - public $pi_checkCHash = TRUE; |
|
32 | + public $pi_checkCHash = TRUE; |
|
33 | 33 | |
34 | - /** |
|
35 | - * This holds the current document |
|
36 | - * |
|
37 | - * @var tx_dlf_document |
|
38 | - * @access protected |
|
39 | - */ |
|
40 | - protected $doc; |
|
34 | + /** |
|
35 | + * This holds the current document |
|
36 | + * |
|
37 | + * @var tx_dlf_document |
|
38 | + * @access protected |
|
39 | + */ |
|
40 | + protected $doc; |
|
41 | 41 | |
42 | - /** |
|
43 | - * This holds the plugin's parsed template |
|
44 | - * |
|
45 | - * @var string |
|
46 | - * @access protected |
|
47 | - */ |
|
48 | - protected $template = ''; |
|
42 | + /** |
|
43 | + * This holds the plugin's parsed template |
|
44 | + * |
|
45 | + * @var string |
|
46 | + * @access protected |
|
47 | + */ |
|
48 | + protected $template = ''; |
|
49 | 49 | |
50 | - /** |
|
51 | - * All the needed configuration values are stored in class variables |
|
52 | - * Priority: Flexforms > TS-Templates > Extension Configuration > ext_localconf.php |
|
53 | - * |
|
54 | - * @access protected |
|
55 | - * |
|
56 | - * @param array $conf: configuration array from TS-Template |
|
57 | - * |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - protected function init(array $conf) { |
|
50 | + /** |
|
51 | + * All the needed configuration values are stored in class variables |
|
52 | + * Priority: Flexforms > TS-Templates > Extension Configuration > ext_localconf.php |
|
53 | + * |
|
54 | + * @access protected |
|
55 | + * |
|
56 | + * @param array $conf: configuration array from TS-Template |
|
57 | + * |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + protected function init(array $conf) { |
|
61 | 61 | |
62 | - // Read FlexForm configuration. |
|
63 | - $flexFormConf = array (); |
|
62 | + // Read FlexForm configuration. |
|
63 | + $flexFormConf = array (); |
|
64 | 64 | |
65 | - $this->cObj->readFlexformIntoConf($this->cObj->data['pi_flexform'], $flexFormConf); |
|
65 | + $this->cObj->readFlexformIntoConf($this->cObj->data['pi_flexform'], $flexFormConf); |
|
66 | 66 | |
67 | - if (!empty($flexFormConf)) { |
|
67 | + if (!empty($flexFormConf)) { |
|
68 | 68 | |
69 | - $conf = tx_dlf_helper::array_merge_recursive_overrule($flexFormConf, $conf); |
|
69 | + $conf = tx_dlf_helper::array_merge_recursive_overrule($flexFormConf, $conf); |
|
70 | 70 | |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | - // Read plugin TS configuration. |
|
74 | - $pluginConf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][get_class($this).'.']; |
|
73 | + // Read plugin TS configuration. |
|
74 | + $pluginConf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][get_class($this).'.']; |
|
75 | 75 | |
76 | - if (is_array($pluginConf)) { |
|
76 | + if (is_array($pluginConf)) { |
|
77 | 77 | |
78 | - $conf = tx_dlf_helper::array_merge_recursive_overrule($pluginConf, $conf); |
|
78 | + $conf = tx_dlf_helper::array_merge_recursive_overrule($pluginConf, $conf); |
|
79 | 79 | |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | - // Read general TS configuration. |
|
83 | - $generalConf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId.'.']; |
|
82 | + // Read general TS configuration. |
|
83 | + $generalConf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId.'.']; |
|
84 | 84 | |
85 | - if (is_array($generalConf)) { |
|
85 | + if (is_array($generalConf)) { |
|
86 | 86 | |
87 | - $conf = tx_dlf_helper::array_merge_recursive_overrule($generalConf, $conf); |
|
87 | + $conf = tx_dlf_helper::array_merge_recursive_overrule($generalConf, $conf); |
|
88 | 88 | |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | - // Read extension configuration. |
|
92 | - $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); |
|
91 | + // Read extension configuration. |
|
92 | + $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); |
|
93 | 93 | |
94 | - if (is_array($extConf)) { |
|
94 | + if (is_array($extConf)) { |
|
95 | 95 | |
96 | - $conf = tx_dlf_helper::array_merge_recursive_overrule($extConf, $conf); |
|
96 | + $conf = tx_dlf_helper::array_merge_recursive_overrule($extConf, $conf); |
|
97 | 97 | |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | - // Read TYPO3_CONF_VARS configuration. |
|
101 | - $varsConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]; |
|
100 | + // Read TYPO3_CONF_VARS configuration. |
|
101 | + $varsConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]; |
|
102 | 102 | |
103 | - if (is_array($varsConf)) { |
|
103 | + if (is_array($varsConf)) { |
|
104 | 104 | |
105 | - $conf = tx_dlf_helper::array_merge_recursive_overrule($varsConf, $conf); |
|
105 | + $conf = tx_dlf_helper::array_merge_recursive_overrule($varsConf, $conf); |
|
106 | 106 | |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - $this->conf = $conf; |
|
109 | + $this->conf = $conf; |
|
110 | 110 | |
111 | - // Set default plugin variables. |
|
112 | - $this->pi_setPiVarDefaults(); |
|
111 | + // Set default plugin variables. |
|
112 | + $this->pi_setPiVarDefaults(); |
|
113 | 113 | |
114 | - // Load translation files. |
|
115 | - $this->pi_loadLL(); |
|
114 | + // Load translation files. |
|
115 | + $this->pi_loadLL(); |
|
116 | 116 | |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Loads the current document into $this->doc |
|
121 | - * |
|
122 | - * @access protected |
|
123 | - * |
|
124 | - * @return void |
|
125 | - */ |
|
126 | - protected function loadDocument() { |
|
119 | + /** |
|
120 | + * Loads the current document into $this->doc |
|
121 | + * |
|
122 | + * @access protected |
|
123 | + * |
|
124 | + * @return void |
|
125 | + */ |
|
126 | + protected function loadDocument() { |
|
127 | 127 | |
128 | - // Check for required variable. |
|
129 | - if (!empty($this->piVars['id']) && !empty($this->conf['pages'])) { |
|
128 | + // Check for required variable. |
|
129 | + if (!empty($this->piVars['id']) && !empty($this->conf['pages'])) { |
|
130 | 130 | |
131 | - // Should we exclude documents from other pages than $this->conf['pages']? |
|
132 | - $pid = (!empty($this->conf['excludeOther']) ? intval($this->conf['pages']) : 0); |
|
131 | + // Should we exclude documents from other pages than $this->conf['pages']? |
|
132 | + $pid = (!empty($this->conf['excludeOther']) ? intval($this->conf['pages']) : 0); |
|
133 | 133 | |
134 | - // Get instance of tx_dlf_document. |
|
135 | - $this->doc =& tx_dlf_document::getInstance($this->piVars['id'], $pid); |
|
134 | + // Get instance of tx_dlf_document. |
|
135 | + $this->doc =& tx_dlf_document::getInstance($this->piVars['id'], $pid); |
|
136 | 136 | |
137 | - if (!$this->doc->ready) { |
|
137 | + if (!$this->doc->ready) { |
|
138 | 138 | |
139 | - // Destroy the incomplete object. |
|
140 | - $this->doc = NULL; |
|
139 | + // Destroy the incomplete object. |
|
140 | + $this->doc = NULL; |
|
141 | 141 | |
142 | - if (TYPO3_DLOG) { |
|
142 | + if (TYPO3_DLOG) { |
|
143 | 143 | |
144 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_plugin->loadDocument()] Failed to load document with UID "'.$this->piVars['id'].'"', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
144 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_plugin->loadDocument()] Failed to load document with UID "'.$this->piVars['id'].'"', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - } else { |
|
148 | + } else { |
|
149 | 149 | |
150 | - // Set configuration PID. |
|
151 | - $this->doc->cPid = $this->conf['pages']; |
|
150 | + // Set configuration PID. |
|
151 | + $this->doc->cPid = $this->conf['pages']; |
|
152 | 152 | |
153 | - } |
|
153 | + } |
|
154 | 154 | |
155 | - } elseif (!empty($this->piVars['recordId'])) { |
|
155 | + } elseif (!empty($this->piVars['recordId'])) { |
|
156 | 156 | |
157 | - // Get UID of document with given record identifier. |
|
158 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
159 | - 'tx_dlf_documents.uid', |
|
160 | - 'tx_dlf_documents', |
|
161 | - 'tx_dlf_documents.record_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->piVars['recordId'], 'tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
162 | - '', |
|
163 | - '', |
|
164 | - '1' |
|
165 | - ); |
|
157 | + // Get UID of document with given record identifier. |
|
158 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
159 | + 'tx_dlf_documents.uid', |
|
160 | + 'tx_dlf_documents', |
|
161 | + 'tx_dlf_documents.record_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->piVars['recordId'], 'tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
162 | + '', |
|
163 | + '', |
|
164 | + '1' |
|
165 | + ); |
|
166 | 166 | |
167 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) == 1) { |
|
167 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) == 1) { |
|
168 | 168 | |
169 | - list ($this->piVars['id']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
169 | + list ($this->piVars['id']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); |
|
170 | 170 | |
171 | - // Set superglobal $_GET array. |
|
172 | - $_GET[$this->prefixId]['id'] = $this->piVars['id']; |
|
171 | + // Set superglobal $_GET array. |
|
172 | + $_GET[$this->prefixId]['id'] = $this->piVars['id']; |
|
173 | 173 | |
174 | - // Unset variable to avoid infinite looping. |
|
175 | - unset ($this->piVars['recordId'], $_GET[$this->prefixId]['recordId']); |
|
174 | + // Unset variable to avoid infinite looping. |
|
175 | + unset ($this->piVars['recordId'], $_GET[$this->prefixId]['recordId']); |
|
176 | 176 | |
177 | - // Try to load document. |
|
178 | - $this->loadDocument(); |
|
177 | + // Try to load document. |
|
178 | + $this->loadDocument(); |
|
179 | 179 | |
180 | - } else { |
|
180 | + } else { |
|
181 | 181 | |
182 | - if (TYPO3_DLOG) { |
|
182 | + if (TYPO3_DLOG) { |
|
183 | 183 | |
184 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_plugin->loadDocument()] Failed to load document with record ID "'.$this->piVars['recordId'].'"', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
184 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_plugin->loadDocument()] Failed to load document with record ID "'.$this->piVars['recordId'].'"', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
185 | 185 | |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - } |
|
188 | + } |
|
189 | 189 | |
190 | - } else { |
|
190 | + } else { |
|
191 | 191 | |
192 | - if (TYPO3_DLOG) { |
|
192 | + if (TYPO3_DLOG) { |
|
193 | 193 | |
194 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_plugin->loadDocument()] Invalid UID "'.$this->piVars['id'].'" or PID "'.$this->conf['pages'].'" for document loading', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
194 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_plugin->loadDocument()] Invalid UID "'.$this->piVars['id'].'" or PID "'.$this->conf['pages'].'" for document loading', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
195 | 195 | |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - } |
|
198 | + } |
|
199 | 199 | |
200 | - } |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * The main method of the PlugIn |
|
204 | - * |
|
205 | - * @access public |
|
206 | - * |
|
207 | - * @param string $content: The PlugIn content |
|
208 | - * @param array $conf: The PlugIn configuration |
|
209 | - * |
|
210 | - * @abstract |
|
211 | - * |
|
212 | - * @return string The content that is displayed on the website |
|
213 | - */ |
|
214 | - abstract public function main($content, $conf); |
|
202 | + /** |
|
203 | + * The main method of the PlugIn |
|
204 | + * |
|
205 | + * @access public |
|
206 | + * |
|
207 | + * @param string $content: The PlugIn content |
|
208 | + * @param array $conf: The PlugIn configuration |
|
209 | + * |
|
210 | + * @abstract |
|
211 | + * |
|
212 | + * @return string The content that is displayed on the website |
|
213 | + */ |
|
214 | + abstract public function main($content, $conf); |
|
215 | 215 | |
216 | - /** |
|
217 | - * Sets default plugin variables from Typoscript |
|
218 | - * (stdWrap backport from TYPO3 6.2) |
|
219 | - * @see http://forge.typo3.org/issues/22045 |
|
220 | - * |
|
221 | - * @access public |
|
222 | - * |
|
223 | - * @return void |
|
224 | - */ |
|
225 | - public function pi_setPiVarDefaults() { |
|
216 | + /** |
|
217 | + * Sets default plugin variables from Typoscript |
|
218 | + * (stdWrap backport from TYPO3 6.2) |
|
219 | + * @see http://forge.typo3.org/issues/22045 |
|
220 | + * |
|
221 | + * @access public |
|
222 | + * |
|
223 | + * @return void |
|
224 | + */ |
|
225 | + public function pi_setPiVarDefaults() { |
|
226 | 226 | |
227 | - if (is_array($this->conf['_DEFAULT_PI_VARS.'])) { |
|
227 | + if (is_array($this->conf['_DEFAULT_PI_VARS.'])) { |
|
228 | 228 | |
229 | - foreach ($this->conf['_DEFAULT_PI_VARS.'] as $GPkey => $GPval) { |
|
229 | + foreach ($this->conf['_DEFAULT_PI_VARS.'] as $GPkey => $GPval) { |
|
230 | 230 | |
231 | - if (strpos($GPkey, '.')) { |
|
231 | + if (strpos($GPkey, '.')) { |
|
232 | 232 | |
233 | - $GPkey = substr($GPkey, 0, -1); |
|
233 | + $GPkey = substr($GPkey, 0, -1); |
|
234 | 234 | |
235 | - } |
|
235 | + } |
|
236 | 236 | |
237 | - if (is_array($this->conf['_DEFAULT_PI_VARS.'][$GPkey.'.']['stdWrap.'])) { |
|
237 | + if (is_array($this->conf['_DEFAULT_PI_VARS.'][$GPkey.'.']['stdWrap.'])) { |
|
238 | 238 | |
239 | - $GPval = $GPval ? $GPval : ''; |
|
239 | + $GPval = $GPval ? $GPval : ''; |
|
240 | 240 | |
241 | - $this->conf['_DEFAULT_PI_VARS.'][$GPkey] = $this->cObj->stdWrap($GPval, $this->conf['_DEFAULT_PI_VARS.'][$GPkey.'.']['stdWrap.']); |
|
241 | + $this->conf['_DEFAULT_PI_VARS.'][$GPkey] = $this->cObj->stdWrap($GPval, $this->conf['_DEFAULT_PI_VARS.'][$GPkey.'.']['stdWrap.']); |
|
242 | 242 | |
243 | - unset ($this->conf['_DEFAULT_PI_VARS.'][$GPkey.'.']['stdWrap.']); |
|
243 | + unset ($this->conf['_DEFAULT_PI_VARS.'][$GPkey.'.']['stdWrap.']); |
|
244 | 244 | |
245 | - } |
|
245 | + } |
|
246 | 246 | |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | - $this->piVars = tx_dlf_helper::array_merge_recursive_overrule($this->conf['_DEFAULT_PI_VARS.'], is_array($this->piVars) ? $this->piVars : array ()); |
|
249 | + $this->piVars = tx_dlf_helper::array_merge_recursive_overrule($this->conf['_DEFAULT_PI_VARS.'], is_array($this->piVars) ? $this->piVars : array ()); |
|
250 | 250 | |
251 | - } |
|
251 | + } |
|
252 | 252 | |
253 | - } |
|
253 | + } |
|
254 | 254 | |
255 | - /** |
|
256 | - * Wraps the input string in a tag with the class attribute set to the class name |
|
257 | - * |
|
258 | - * @access public |
|
259 | - * |
|
260 | - * @param string $content: HTML content to wrap in the div-tags with the "main class" of the plugin |
|
261 | - * |
|
262 | - * @return string HTML content wrapped, ready to return to the parent object. |
|
263 | - */ |
|
264 | - public function pi_wrapInBaseClass($content) { |
|
255 | + /** |
|
256 | + * Wraps the input string in a tag with the class attribute set to the class name |
|
257 | + * |
|
258 | + * @access public |
|
259 | + * |
|
260 | + * @param string $content: HTML content to wrap in the div-tags with the "main class" of the plugin |
|
261 | + * |
|
262 | + * @return string HTML content wrapped, ready to return to the parent object. |
|
263 | + */ |
|
264 | + public function pi_wrapInBaseClass($content) { |
|
265 | 265 | |
266 | - if (!$GLOBALS['TSFE']->config['config']['disableWrapInBaseClass']) { |
|
267 | - // Use get_class($this) instead of $this->prefixId for content wrapping because $this->prefixId is the same for all plugins. |
|
268 | - $content = '<div class="'.str_replace('_', '-', get_class($this)).'">'.$content.'</div>'; |
|
266 | + if (!$GLOBALS['TSFE']->config['config']['disableWrapInBaseClass']) { |
|
267 | + // Use get_class($this) instead of $this->prefixId for content wrapping because $this->prefixId is the same for all plugins. |
|
268 | + $content = '<div class="'.str_replace('_', '-', get_class($this)).'">'.$content.'</div>'; |
|
269 | 269 | |
270 | - if (!$GLOBALS['TSFE']->config['config']['disablePrefixComment']) { |
|
270 | + if (!$GLOBALS['TSFE']->config['config']['disablePrefixComment']) { |
|
271 | 271 | |
272 | - $content = "\n\n<!-- BEGIN: Content of extension '".$this->extKey."', plugin '".get_class($this)."' -->\n\n".$content."\n\n<!-- END: Content of extension '".$this->extKey."', plugin '".get_class($this)."' -->\n\n"; |
|
272 | + $content = "\n\n<!-- BEGIN: Content of extension '".$this->extKey."', plugin '".get_class($this)."' -->\n\n".$content."\n\n<!-- END: Content of extension '".$this->extKey."', plugin '".get_class($this)."' -->\n\n"; |
|
273 | 273 | |
274 | - } |
|
275 | - } |
|
274 | + } |
|
275 | + } |
|
276 | 276 | |
277 | - return $content; |
|
277 | + return $content; |
|
278 | 278 | |
279 | - } |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Parses a string into a Typoscript array |
|
283 | - * |
|
284 | - * @access protected |
|
285 | - * |
|
286 | - * @param string $string: The string to parse |
|
287 | - * |
|
288 | - * @return array The resulting typoscript array |
|
289 | - */ |
|
290 | - protected function parseTS($string = '') { |
|
281 | + /** |
|
282 | + * Parses a string into a Typoscript array |
|
283 | + * |
|
284 | + * @access protected |
|
285 | + * |
|
286 | + * @param string $string: The string to parse |
|
287 | + * |
|
288 | + * @return array The resulting typoscript array |
|
289 | + */ |
|
290 | + protected function parseTS($string = '') { |
|
291 | 291 | |
292 | - $parser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser'); |
|
292 | + $parser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser'); |
|
293 | 293 | |
294 | - $parser->parse($string); |
|
294 | + $parser->parse($string); |
|
295 | 295 | |
296 | - return $parser->setup; |
|
296 | + return $parser->setup; |
|
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * Sets some configuration variables if the plugin is cached. |
|
302 | - * |
|
303 | - * @access protected |
|
304 | - * |
|
305 | - * @param boolean $cache: Should the plugin be cached? |
|
306 | - * |
|
307 | - * @return void |
|
308 | - */ |
|
309 | - protected function setCache($cache = TRUE) { |
|
300 | + /** |
|
301 | + * Sets some configuration variables if the plugin is cached. |
|
302 | + * |
|
303 | + * @access protected |
|
304 | + * |
|
305 | + * @param boolean $cache: Should the plugin be cached? |
|
306 | + * |
|
307 | + * @return void |
|
308 | + */ |
|
309 | + protected function setCache($cache = TRUE) { |
|
310 | 310 | |
311 | - if ($cache) { |
|
311 | + if ($cache) { |
|
312 | 312 | |
313 | - // Set cObject type to "USER" (default). |
|
314 | - $this->pi_USER_INT_obj = FALSE; |
|
313 | + // Set cObject type to "USER" (default). |
|
314 | + $this->pi_USER_INT_obj = FALSE; |
|
315 | 315 | |
316 | - $this->pi_checkCHash = TRUE; |
|
316 | + $this->pi_checkCHash = TRUE; |
|
317 | 317 | |
318 | - if (count($this->piVars)) { |
|
318 | + if (count($this->piVars)) { |
|
319 | 319 | |
320 | - // Check cHash or disable caching. |
|
321 | - $GLOBALS['TSFE']->reqCHash(); |
|
320 | + // Check cHash or disable caching. |
|
321 | + $GLOBALS['TSFE']->reqCHash(); |
|
322 | 322 | |
323 | - } |
|
323 | + } |
|
324 | 324 | |
325 | - } else { |
|
325 | + } else { |
|
326 | 326 | |
327 | - // Set cObject type to "USER_INT". |
|
328 | - $this->pi_USER_INT_obj = TRUE; |
|
327 | + // Set cObject type to "USER_INT". |
|
328 | + $this->pi_USER_INT_obj = TRUE; |
|
329 | 329 | |
330 | - $this->pi_checkCHash = FALSE; |
|
330 | + $this->pi_checkCHash = FALSE; |
|
331 | 331 | |
332 | - // Plugins are of type "USER" by default, so convert it to "USER_INT". |
|
333 | - $this->cObj->convertToUserIntObject(); |
|
332 | + // Plugins are of type "USER" by default, so convert it to "USER_INT". |
|
333 | + $this->cObj->convertToUserIntObject(); |
|
334 | 334 | |
335 | - } |
|
335 | + } |
|
336 | 336 | |
337 | - } |
|
337 | + } |
|
338 | 338 | |
339 | 339 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | protected function init(array $conf) { |
61 | 61 | |
62 | 62 | // Read FlexForm configuration. |
63 | - $flexFormConf = array (); |
|
63 | + $flexFormConf = array(); |
|
64 | 64 | |
65 | 65 | $this->cObj->readFlexformIntoConf($this->cObj->data['pi_flexform'], $flexFormConf); |
66 | 66 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $pid = (!empty($this->conf['excludeOther']) ? intval($this->conf['pages']) : 0); |
133 | 133 | |
134 | 134 | // Get instance of tx_dlf_document. |
135 | - $this->doc =& tx_dlf_document::getInstance($this->piVars['id'], $pid); |
|
135 | + $this->doc = & tx_dlf_document::getInstance($this->piVars['id'], $pid); |
|
136 | 136 | |
137 | 137 | if (!$this->doc->ready) { |
138 | 138 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - $this->piVars = tx_dlf_helper::array_merge_recursive_overrule($this->conf['_DEFAULT_PI_VARS.'], is_array($this->piVars) ? $this->piVars : array ()); |
|
249 | + $this->piVars = tx_dlf_helper::array_merge_recursive_overrule($this->conf['_DEFAULT_PI_VARS.'], is_array($this->piVars) ? $this->piVars : array()); |
|
250 | 250 | |
251 | 251 | } |
252 | 252 |
@@ -20,16 +20,16 @@ |
||
20 | 20 | */ |
21 | 21 | interface tx_dlf_format { |
22 | 22 | |
23 | - /** |
|
24 | - * This extracts metadata from XML |
|
25 | - * |
|
26 | - * @access public |
|
27 | - * |
|
28 | - * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
29 | - * @param array &$metadata: The metadata array to fill |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function extractMetadata(SimpleXMLElement $xml, array &$metadata); |
|
23 | + /** |
|
24 | + * This extracts metadata from XML |
|
25 | + * |
|
26 | + * @access public |
|
27 | + * |
|
28 | + * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
29 | + * @param array &$metadata: The metadata array to fill |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function extractMetadata(SimpleXMLElement $xml, array &$metadata); |
|
34 | 34 | |
35 | 35 | } |
@@ -19,928 +19,928 @@ |
||
19 | 19 | */ |
20 | 20 | class tx_dlf_list implements ArrayAccess, Countable, Iterator, \TYPO3\CMS\Core\SingletonInterface { |
21 | 21 | |
22 | - /** |
|
23 | - * This holds the number of documents in the list |
|
24 | - * @see Countable |
|
25 | - * |
|
26 | - * @var integer |
|
27 | - * @access protected |
|
28 | - */ |
|
29 | - protected $count = 0; |
|
30 | - |
|
31 | - /** |
|
32 | - * This holds the list entries in sorted order |
|
33 | - * @see ArrayAccess |
|
34 | - * |
|
35 | - * @var array() |
|
36 | - * @access protected |
|
37 | - */ |
|
38 | - protected $elements = array (); |
|
39 | - |
|
40 | - /** |
|
41 | - * This holds the list's metadata |
|
42 | - * |
|
43 | - * @var array |
|
44 | - * @access protected |
|
45 | - */ |
|
46 | - protected $metadata = array (); |
|
47 | - |
|
48 | - /** |
|
49 | - * This holds the current list position |
|
50 | - * @see Iterator |
|
51 | - * |
|
52 | - * @var integer |
|
53 | - * @access protected |
|
54 | - */ |
|
55 | - protected $position = 0; |
|
56 | - |
|
57 | - /** |
|
58 | - * This holds the full records of already processed list elements |
|
59 | - * |
|
60 | - * @var array() |
|
61 | - * @access protected |
|
62 | - */ |
|
63 | - protected $records = array (); |
|
64 | - |
|
65 | - /** |
|
66 | - * Instance of Apache_Solr_Service class |
|
67 | - * |
|
68 | - * @var Apache_Solr_Service |
|
69 | - * @access protected |
|
70 | - */ |
|
71 | - protected $solr; |
|
72 | - |
|
73 | - /** |
|
74 | - * This holds the Solr metadata configuration |
|
75 | - * |
|
76 | - * @var array |
|
77 | - * @access protected |
|
78 | - */ |
|
79 | - protected $solrConfig = array (); |
|
80 | - |
|
81 | - /** |
|
82 | - * This adds an array of elements at the given position to the list |
|
83 | - * |
|
84 | - * @access public |
|
85 | - * |
|
86 | - * @param array $elements: Array of elements to add to list |
|
87 | - * @param integer $position: Numeric position for including |
|
88 | - * |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - public function add(array $elements, $position = -1) { |
|
92 | - |
|
93 | - $position = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($position, 0, $this->count, $this->count); |
|
94 | - |
|
95 | - if (!empty($elements)) { |
|
96 | - |
|
97 | - array_splice($this->elements, $position, 0, $elements); |
|
98 | - |
|
99 | - $this->count = count($this->elements); |
|
100 | - |
|
101 | - } |
|
102 | - |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * This counts the elements |
|
107 | - * @see Countable::count() |
|
108 | - * |
|
109 | - * @access public |
|
110 | - * |
|
111 | - * @return integer The number of elements in the list |
|
112 | - */ |
|
113 | - public function count() { |
|
22 | + /** |
|
23 | + * This holds the number of documents in the list |
|
24 | + * @see Countable |
|
25 | + * |
|
26 | + * @var integer |
|
27 | + * @access protected |
|
28 | + */ |
|
29 | + protected $count = 0; |
|
30 | + |
|
31 | + /** |
|
32 | + * This holds the list entries in sorted order |
|
33 | + * @see ArrayAccess |
|
34 | + * |
|
35 | + * @var array() |
|
36 | + * @access protected |
|
37 | + */ |
|
38 | + protected $elements = array (); |
|
39 | + |
|
40 | + /** |
|
41 | + * This holds the list's metadata |
|
42 | + * |
|
43 | + * @var array |
|
44 | + * @access protected |
|
45 | + */ |
|
46 | + protected $metadata = array (); |
|
47 | + |
|
48 | + /** |
|
49 | + * This holds the current list position |
|
50 | + * @see Iterator |
|
51 | + * |
|
52 | + * @var integer |
|
53 | + * @access protected |
|
54 | + */ |
|
55 | + protected $position = 0; |
|
56 | + |
|
57 | + /** |
|
58 | + * This holds the full records of already processed list elements |
|
59 | + * |
|
60 | + * @var array() |
|
61 | + * @access protected |
|
62 | + */ |
|
63 | + protected $records = array (); |
|
64 | + |
|
65 | + /** |
|
66 | + * Instance of Apache_Solr_Service class |
|
67 | + * |
|
68 | + * @var Apache_Solr_Service |
|
69 | + * @access protected |
|
70 | + */ |
|
71 | + protected $solr; |
|
72 | + |
|
73 | + /** |
|
74 | + * This holds the Solr metadata configuration |
|
75 | + * |
|
76 | + * @var array |
|
77 | + * @access protected |
|
78 | + */ |
|
79 | + protected $solrConfig = array (); |
|
80 | + |
|
81 | + /** |
|
82 | + * This adds an array of elements at the given position to the list |
|
83 | + * |
|
84 | + * @access public |
|
85 | + * |
|
86 | + * @param array $elements: Array of elements to add to list |
|
87 | + * @param integer $position: Numeric position for including |
|
88 | + * |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + public function add(array $elements, $position = -1) { |
|
92 | + |
|
93 | + $position = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($position, 0, $this->count, $this->count); |
|
94 | + |
|
95 | + if (!empty($elements)) { |
|
96 | + |
|
97 | + array_splice($this->elements, $position, 0, $elements); |
|
98 | + |
|
99 | + $this->count = count($this->elements); |
|
100 | + |
|
101 | + } |
|
102 | + |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * This counts the elements |
|
107 | + * @see Countable::count() |
|
108 | + * |
|
109 | + * @access public |
|
110 | + * |
|
111 | + * @return integer The number of elements in the list |
|
112 | + */ |
|
113 | + public function count() { |
|
114 | 114 | |
115 | - return $this->count; |
|
115 | + return $this->count; |
|
116 | 116 | |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * This returns the current element |
|
121 | - * @see Iterator::current() |
|
122 | - * |
|
123 | - * @access public |
|
124 | - * |
|
125 | - * @return array The current element |
|
126 | - */ |
|
127 | - public function current() { |
|
119 | + /** |
|
120 | + * This returns the current element |
|
121 | + * @see Iterator::current() |
|
122 | + * |
|
123 | + * @access public |
|
124 | + * |
|
125 | + * @return array The current element |
|
126 | + */ |
|
127 | + public function current() { |
|
128 | 128 | |
129 | - if ($this->valid()) { |
|
129 | + if ($this->valid()) { |
|
130 | 130 | |
131 | - return $this->getRecord($this->elements[$this->position]); |
|
131 | + return $this->getRecord($this->elements[$this->position]); |
|
132 | 132 | |
133 | - } else { |
|
133 | + } else { |
|
134 | 134 | |
135 | - if (TYPO3_DLOG) { |
|
135 | + if (TYPO3_DLOG) { |
|
136 | 136 | |
137 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->current()] Invalid position "'.$this->position.'" for list element', $this->extKey, SYSLOG_SEVERITY_NOTICE); |
|
137 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->current()] Invalid position "'.$this->position.'" for list element', $this->extKey, SYSLOG_SEVERITY_NOTICE); |
|
138 | 138 | |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | - return; |
|
141 | + return; |
|
142 | 142 | |
143 | - } |
|
143 | + } |
|
144 | 144 | |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * This returns the full record of any list element |
|
149 | - * |
|
150 | - * @access protected |
|
151 | - * |
|
152 | - * @param mixed $element: The list element |
|
153 | - * |
|
154 | - * @return mixed The element's full record |
|
155 | - */ |
|
156 | - protected function getRecord($element) { |
|
147 | + /** |
|
148 | + * This returns the full record of any list element |
|
149 | + * |
|
150 | + * @access protected |
|
151 | + * |
|
152 | + * @param mixed $element: The list element |
|
153 | + * |
|
154 | + * @return mixed The element's full record |
|
155 | + */ |
|
156 | + protected function getRecord($element) { |
|
157 | 157 | |
158 | - if (is_array($element) && array_keys($element) == array ('u', 'h', 's', 'p')) { |
|
158 | + if (is_array($element) && array_keys($element) == array ('u', 'h', 's', 'p')) { |
|
159 | 159 | |
160 | - // Return already processed record if possible. |
|
161 | - if (!empty($this->records[$element['u']])) { |
|
160 | + // Return already processed record if possible. |
|
161 | + if (!empty($this->records[$element['u']])) { |
|
162 | 162 | |
163 | - return $this->records[$element['u']]; |
|
163 | + return $this->records[$element['u']]; |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | - $record = array ( |
|
168 | - 'uid' => $element['u'], |
|
169 | - 'page' => 1, |
|
170 | - 'preview' => '', |
|
171 | - 'subparts' => $element['p'] |
|
172 | - ); |
|
167 | + $record = array ( |
|
168 | + 'uid' => $element['u'], |
|
169 | + 'page' => 1, |
|
170 | + 'preview' => '', |
|
171 | + 'subparts' => $element['p'] |
|
172 | + ); |
|
173 | 173 | |
174 | - // Check if it's a list of database records or Solr documents. |
|
175 | - if (!empty($this->metadata['options']['source']) && $this->metadata['options']['source'] == 'collection') { |
|
174 | + // Check if it's a list of database records or Solr documents. |
|
175 | + if (!empty($this->metadata['options']['source']) && $this->metadata['options']['source'] == 'collection') { |
|
176 | 176 | |
177 | - // Get document's thumbnail and metadata from database. |
|
178 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
179 | - 'tx_dlf_documents.uid AS uid,tx_dlf_documents.thumbnail AS thumbnail,tx_dlf_documents.metadata AS metadata', |
|
180 | - 'tx_dlf_documents', |
|
181 | - '(tx_dlf_documents.uid='.intval($record['uid']).' OR tx_dlf_documents.partof='.intval($record['uid']).')'.tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
182 | - '', |
|
183 | - '', |
|
184 | - '' |
|
185 | - ); |
|
177 | + // Get document's thumbnail and metadata from database. |
|
178 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
179 | + 'tx_dlf_documents.uid AS uid,tx_dlf_documents.thumbnail AS thumbnail,tx_dlf_documents.metadata AS metadata', |
|
180 | + 'tx_dlf_documents', |
|
181 | + '(tx_dlf_documents.uid='.intval($record['uid']).' OR tx_dlf_documents.partof='.intval($record['uid']).')'.tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
182 | + '', |
|
183 | + '', |
|
184 | + '' |
|
185 | + ); |
|
186 | 186 | |
187 | - // Process results. |
|
188 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
187 | + // Process results. |
|
188 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
189 | 189 | |
190 | - // Prepare document's metadata. |
|
191 | - $metadata = unserialize($resArray['metadata']); |
|
190 | + // Prepare document's metadata. |
|
191 | + $metadata = unserialize($resArray['metadata']); |
|
192 | 192 | |
193 | - if (!empty($metadata['type'][0]) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($metadata['type'][0])) { |
|
193 | + if (!empty($metadata['type'][0]) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($metadata['type'][0])) { |
|
194 | 194 | |
195 | - $metadata['type'][0] = tx_dlf_helper::getIndexName($metadata['type'][0], 'tx_dlf_structures', $this->metadata['options']['pid']); |
|
195 | + $metadata['type'][0] = tx_dlf_helper::getIndexName($metadata['type'][0], 'tx_dlf_structures', $this->metadata['options']['pid']); |
|
196 | 196 | |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - if (!empty($metadata['owner'][0]) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($metadata['owner'][0])) { |
|
199 | + if (!empty($metadata['owner'][0]) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($metadata['owner'][0])) { |
|
200 | 200 | |
201 | - $metadata['owner'][0] = tx_dlf_helper::getIndexName($metadata['owner'][0], 'tx_dlf_libraries', $this->metadata['options']['pid']); |
|
201 | + $metadata['owner'][0] = tx_dlf_helper::getIndexName($metadata['owner'][0], 'tx_dlf_libraries', $this->metadata['options']['pid']); |
|
202 | 202 | |
203 | - } |
|
203 | + } |
|
204 | 204 | |
205 | - if (!empty($metadata['collection']) && is_array($metadata['collection'])) { |
|
205 | + if (!empty($metadata['collection']) && is_array($metadata['collection'])) { |
|
206 | 206 | |
207 | - foreach ($metadata['collection'] as $i => $collection) { |
|
207 | + foreach ($metadata['collection'] as $i => $collection) { |
|
208 | 208 | |
209 | - if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($collection)) { |
|
209 | + if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($collection)) { |
|
210 | 210 | |
211 | - $metadata['collection'][$i] = tx_dlf_helper::getIndexName($metadata['collection'][$i], 'tx_dlf_collections', $this->metadata['options']['pid']); |
|
211 | + $metadata['collection'][$i] = tx_dlf_helper::getIndexName($metadata['collection'][$i], 'tx_dlf_collections', $this->metadata['options']['pid']); |
|
212 | 212 | |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - } |
|
215 | + } |
|
216 | 216 | |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - // Add metadata to list element. |
|
220 | - if ($resArray['uid'] == $record['uid']) { |
|
219 | + // Add metadata to list element. |
|
220 | + if ($resArray['uid'] == $record['uid']) { |
|
221 | 221 | |
222 | - $record['thumbnail'] = $resArray['thumbnail']; |
|
222 | + $record['thumbnail'] = $resArray['thumbnail']; |
|
223 | 223 | |
224 | - $record['metadata'] = $metadata; |
|
224 | + $record['metadata'] = $metadata; |
|
225 | 225 | |
226 | - } elseif (($key = tx_dlf_helper::array_search_recursive($resArray['uid'], $record['subparts'], TRUE)) !== FALSE) { |
|
226 | + } elseif (($key = tx_dlf_helper::array_search_recursive($resArray['uid'], $record['subparts'], TRUE)) !== FALSE) { |
|
227 | 227 | |
228 | - $record['subparts'][$key] = array ( |
|
229 | - 'uid' => $resArray['uid'], |
|
230 | - 'page' => 1, |
|
231 | - 'preview' => (!empty($record['subparts'][$key]['h']) ? $record['subparts'][$key]['h'] : ''), |
|
232 | - 'thumbnail' => $resArray['thumbnail'], |
|
233 | - 'metadata' => $metadata |
|
234 | - ); |
|
228 | + $record['subparts'][$key] = array ( |
|
229 | + 'uid' => $resArray['uid'], |
|
230 | + 'page' => 1, |
|
231 | + 'preview' => (!empty($record['subparts'][$key]['h']) ? $record['subparts'][$key]['h'] : ''), |
|
232 | + 'thumbnail' => $resArray['thumbnail'], |
|
233 | + 'metadata' => $metadata |
|
234 | + ); |
|
235 | 235 | |
236 | - } |
|
236 | + } |
|
237 | 237 | |
238 | - } |
|
238 | + } |
|
239 | 239 | |
240 | - } elseif (!empty($this->metadata['options']['source']) && $this->metadata['options']['source'] == 'search') { |
|
240 | + } elseif (!empty($this->metadata['options']['source']) && $this->metadata['options']['source'] == 'search') { |
|
241 | 241 | |
242 | - if ($this->solrConnect()) { |
|
242 | + if ($this->solrConnect()) { |
|
243 | 243 | |
244 | - // Get document's thumbnail and metadata from Solr index. |
|
245 | - $result = $this->solr->service->search('uid:'.tx_dlf_solr::escapeQuery($record['uid']), 0, $this->solr->limit); |
|
244 | + // Get document's thumbnail and metadata from Solr index. |
|
245 | + $result = $this->solr->service->search('uid:'.tx_dlf_solr::escapeQuery($record['uid']), 0, $this->solr->limit); |
|
246 | 246 | |
247 | - // Process results. |
|
248 | - foreach ($result->response->docs as $resArray) { |
|
247 | + // Process results. |
|
248 | + foreach ($result->response->docs as $resArray) { |
|
249 | 249 | |
250 | - // Prepare document's metadata. |
|
251 | - $metadata = array (); |
|
250 | + // Prepare document's metadata. |
|
251 | + $metadata = array (); |
|
252 | 252 | |
253 | - foreach ($this->solrConfig as $index_name => $solr_name) { |
|
253 | + foreach ($this->solrConfig as $index_name => $solr_name) { |
|
254 | 254 | |
255 | - if (!empty($resArray->$solr_name)) { |
|
255 | + if (!empty($resArray->$solr_name)) { |
|
256 | 256 | |
257 | - $metadata[$index_name] = (is_array($resArray->$solr_name) ? $resArray->$solr_name : array ($resArray->$solr_name)); |
|
257 | + $metadata[$index_name] = (is_array($resArray->$solr_name) ? $resArray->$solr_name : array ($resArray->$solr_name)); |
|
258 | 258 | |
259 | - } |
|
259 | + } |
|
260 | 260 | |
261 | - } |
|
261 | + } |
|
262 | 262 | |
263 | - // Add metadata to list elements. |
|
264 | - if ($resArray->toplevel) { |
|
263 | + // Add metadata to list elements. |
|
264 | + if ($resArray->toplevel) { |
|
265 | 265 | |
266 | - $record['thumbnail'] = $resArray->thumbnail; |
|
266 | + $record['thumbnail'] = $resArray->thumbnail; |
|
267 | 267 | |
268 | - $record['metadata'] = $metadata; |
|
268 | + $record['metadata'] = $metadata; |
|
269 | 269 | |
270 | - } elseif (($key = tx_dlf_helper::array_search_recursive($resArray->id, $record['subparts'], TRUE)) !== FALSE) { |
|
270 | + } elseif (($key = tx_dlf_helper::array_search_recursive($resArray->id, $record['subparts'], TRUE)) !== FALSE) { |
|
271 | 271 | |
272 | - $record['subparts'][$key] = array ( |
|
273 | - 'uid' => $resArray->uid, |
|
274 | - 'page' => $resArray->page, |
|
275 | - 'preview' => (!empty($record['subparts'][$key]['h']) ? $record['subparts'][$key]['h'] : ''), |
|
276 | - 'thumbnail' => $resArray->thumbnail, |
|
277 | - 'metadata' => $metadata |
|
278 | - ); |
|
272 | + $record['subparts'][$key] = array ( |
|
273 | + 'uid' => $resArray->uid, |
|
274 | + 'page' => $resArray->page, |
|
275 | + 'preview' => (!empty($record['subparts'][$key]['h']) ? $record['subparts'][$key]['h'] : ''), |
|
276 | + 'thumbnail' => $resArray->thumbnail, |
|
277 | + 'metadata' => $metadata |
|
278 | + ); |
|
279 | 279 | |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - } |
|
282 | + } |
|
283 | 283 | |
284 | - } |
|
284 | + } |
|
285 | 285 | |
286 | - } |
|
286 | + } |
|
287 | 287 | |
288 | - // Save record for later usage. |
|
289 | - $this->records[$element['u']] = $record; |
|
288 | + // Save record for later usage. |
|
289 | + $this->records[$element['u']] = $record; |
|
290 | 290 | |
291 | - } else { |
|
291 | + } else { |
|
292 | 292 | |
293 | - if (TYPO3_DLOG) { |
|
293 | + if (TYPO3_DLOG) { |
|
294 | 294 | |
295 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->getRecord([data])] No UID of list element to fetch full record', $this->extKey, SYSLOG_SEVERITY_NOTICE, $element); |
|
295 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->getRecord([data])] No UID of list element to fetch full record', $this->extKey, SYSLOG_SEVERITY_NOTICE, $element); |
|
296 | 296 | |
297 | - } |
|
297 | + } |
|
298 | 298 | |
299 | - $record = $element; |
|
299 | + $record = $element; |
|
300 | 300 | |
301 | - } |
|
301 | + } |
|
302 | 302 | |
303 | - return $record; |
|
303 | + return $record; |
|
304 | 304 | |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | - /** |
|
308 | - * This returns the current position |
|
309 | - * @see Iterator::key() |
|
310 | - * |
|
311 | - * @access public |
|
312 | - * |
|
313 | - * @return integer The current position |
|
314 | - */ |
|
315 | - public function key() { |
|
307 | + /** |
|
308 | + * This returns the current position |
|
309 | + * @see Iterator::key() |
|
310 | + * |
|
311 | + * @access public |
|
312 | + * |
|
313 | + * @return integer The current position |
|
314 | + */ |
|
315 | + public function key() { |
|
316 | 316 | |
317 | - return $this->position; |
|
317 | + return $this->position; |
|
318 | 318 | |
319 | - } |
|
319 | + } |
|
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | - /** |
|
324 | - * This moves the element at the given position up or down |
|
325 | - * |
|
326 | - * @access public |
|
327 | - * |
|
328 | - * @param integer $position: Numeric position for moving |
|
329 | - * @param integer $steps: Amount of steps to move up or down |
|
330 | - * |
|
331 | - * @return void |
|
332 | - */ |
|
333 | - public function move($position, $steps) { |
|
323 | + /** |
|
324 | + * This moves the element at the given position up or down |
|
325 | + * |
|
326 | + * @access public |
|
327 | + * |
|
328 | + * @param integer $position: Numeric position for moving |
|
329 | + * @param integer $steps: Amount of steps to move up or down |
|
330 | + * |
|
331 | + * @return void |
|
332 | + */ |
|
333 | + public function move($position, $steps) { |
|
334 | 334 | |
335 | - // Save parameters for logging purposes. |
|
336 | - $_position = $position; |
|
335 | + // Save parameters for logging purposes. |
|
336 | + $_position = $position; |
|
337 | 337 | |
338 | - $_steps = $steps; |
|
338 | + $_steps = $steps; |
|
339 | 339 | |
340 | - $position = intval($position); |
|
340 | + $position = intval($position); |
|
341 | 341 | |
342 | - // Check if list position is valid. |
|
343 | - if ($position < 0 || $position >= $this->count) { |
|
342 | + // Check if list position is valid. |
|
343 | + if ($position < 0 || $position >= $this->count) { |
|
344 | 344 | |
345 | - if (TYPO3_DLOG) { |
|
345 | + if (TYPO3_DLOG) { |
|
346 | 346 | |
347 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->move('.$_position.', '.$_steps.')] Invalid position "'.$position.'" for element moving', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
347 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->move('.$_position.', '.$_steps.')] Invalid position "'.$position.'" for element moving', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
348 | 348 | |
349 | - } |
|
349 | + } |
|
350 | 350 | |
351 | - return; |
|
351 | + return; |
|
352 | 352 | |
353 | - } |
|
353 | + } |
|
354 | 354 | |
355 | - $steps = intval($steps); |
|
355 | + $steps = intval($steps); |
|
356 | 356 | |
357 | - // Check if moving given amount of steps is possible. |
|
358 | - if (($position + $steps) < 0 || ($position + $steps) >= $this->count) { |
|
357 | + // Check if moving given amount of steps is possible. |
|
358 | + if (($position + $steps) < 0 || ($position + $steps) >= $this->count) { |
|
359 | 359 | |
360 | - if (TYPO3_DLOG) { |
|
360 | + if (TYPO3_DLOG) { |
|
361 | 361 | |
362 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->move('.$_position.', '.$_steps.')] Invalid steps "'.$steps.'" for moving element at position "'.$position.'"', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
362 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->move('.$_position.', '.$_steps.')] Invalid steps "'.$steps.'" for moving element at position "'.$position.'"', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
363 | 363 | |
364 | - } |
|
364 | + } |
|
365 | 365 | |
366 | - return; |
|
366 | + return; |
|
367 | 367 | |
368 | - } |
|
368 | + } |
|
369 | 369 | |
370 | - $element = $this->remove($position); |
|
370 | + $element = $this->remove($position); |
|
371 | 371 | |
372 | - $this->add(array ($element), $position + $steps); |
|
372 | + $this->add(array ($element), $position + $steps); |
|
373 | 373 | |
374 | - } |
|
374 | + } |
|
375 | 375 | |
376 | - /** |
|
377 | - * This moves the element at the given position up |
|
378 | - * |
|
379 | - * @access public |
|
380 | - * |
|
381 | - * @param integer $position: Numeric position for moving |
|
382 | - * |
|
383 | - * @return void |
|
384 | - */ |
|
385 | - public function moveUp($position) { |
|
376 | + /** |
|
377 | + * This moves the element at the given position up |
|
378 | + * |
|
379 | + * @access public |
|
380 | + * |
|
381 | + * @param integer $position: Numeric position for moving |
|
382 | + * |
|
383 | + * @return void |
|
384 | + */ |
|
385 | + public function moveUp($position) { |
|
386 | 386 | |
387 | - $this->move($position, -1); |
|
387 | + $this->move($position, -1); |
|
388 | 388 | |
389 | - } |
|
389 | + } |
|
390 | 390 | |
391 | - /** |
|
392 | - * This moves the element at the given position down |
|
393 | - * |
|
394 | - * @access public |
|
395 | - * |
|
396 | - * @param integer $position: Numeric position for moving |
|
397 | - * |
|
398 | - * @return void |
|
399 | - */ |
|
400 | - public function moveDown($position) { |
|
391 | + /** |
|
392 | + * This moves the element at the given position down |
|
393 | + * |
|
394 | + * @access public |
|
395 | + * |
|
396 | + * @param integer $position: Numeric position for moving |
|
397 | + * |
|
398 | + * @return void |
|
399 | + */ |
|
400 | + public function moveDown($position) { |
|
401 | 401 | |
402 | - $this->move($position, 1); |
|
402 | + $this->move($position, 1); |
|
403 | 403 | |
404 | - } |
|
404 | + } |
|
405 | 405 | |
406 | - /** |
|
407 | - * This increments the current list position |
|
408 | - * @see Iterator::next() |
|
409 | - * |
|
410 | - * @access public |
|
411 | - * |
|
412 | - * @return void |
|
413 | - */ |
|
414 | - public function next() { |
|
406 | + /** |
|
407 | + * This increments the current list position |
|
408 | + * @see Iterator::next() |
|
409 | + * |
|
410 | + * @access public |
|
411 | + * |
|
412 | + * @return void |
|
413 | + */ |
|
414 | + public function next() { |
|
415 | 415 | |
416 | - $this->position++; |
|
416 | + $this->position++; |
|
417 | 417 | |
418 | - } |
|
418 | + } |
|
419 | 419 | |
420 | - /** |
|
421 | - * This checks if an offset exists |
|
422 | - * @see ArrayAccess::offsetExists() |
|
423 | - * |
|
424 | - * @access public |
|
425 | - * |
|
426 | - * @param mixed $offset: The offset to check |
|
427 | - * |
|
428 | - * @return boolean Does the given offset exist? |
|
429 | - */ |
|
430 | - public function offsetExists($offset) { |
|
420 | + /** |
|
421 | + * This checks if an offset exists |
|
422 | + * @see ArrayAccess::offsetExists() |
|
423 | + * |
|
424 | + * @access public |
|
425 | + * |
|
426 | + * @param mixed $offset: The offset to check |
|
427 | + * |
|
428 | + * @return boolean Does the given offset exist? |
|
429 | + */ |
|
430 | + public function offsetExists($offset) { |
|
431 | 431 | |
432 | - return isset($this->elements[$offset]); |
|
432 | + return isset($this->elements[$offset]); |
|
433 | 433 | |
434 | - } |
|
434 | + } |
|
435 | 435 | |
436 | - /** |
|
437 | - * This returns the element at the given offset |
|
438 | - * @see ArrayAccess::offsetGet() |
|
439 | - * |
|
440 | - * @access public |
|
441 | - * |
|
442 | - * @param mixed $offset: The offset to return |
|
443 | - * |
|
444 | - * @return array The element at the given offset |
|
445 | - */ |
|
446 | - public function offsetGet($offset) { |
|
436 | + /** |
|
437 | + * This returns the element at the given offset |
|
438 | + * @see ArrayAccess::offsetGet() |
|
439 | + * |
|
440 | + * @access public |
|
441 | + * |
|
442 | + * @param mixed $offset: The offset to return |
|
443 | + * |
|
444 | + * @return array The element at the given offset |
|
445 | + */ |
|
446 | + public function offsetGet($offset) { |
|
447 | 447 | |
448 | - if ($this->offsetExists($offset)) { |
|
448 | + if ($this->offsetExists($offset)) { |
|
449 | 449 | |
450 | - return $this->getRecord($this->elements[$offset]); |
|
450 | + return $this->getRecord($this->elements[$offset]); |
|
451 | 451 | |
452 | - } else { |
|
452 | + } else { |
|
453 | 453 | |
454 | - if (TYPO3_DLOG) { |
|
454 | + if (TYPO3_DLOG) { |
|
455 | 455 | |
456 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->offsetGet('.$offset.')] Invalid offset "'.$offset.'" for list element', $this->extKey, SYSLOG_SEVERITY_NOTICE); |
|
456 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->offsetGet('.$offset.')] Invalid offset "'.$offset.'" for list element', $this->extKey, SYSLOG_SEVERITY_NOTICE); |
|
457 | 457 | |
458 | - } |
|
458 | + } |
|
459 | 459 | |
460 | - return; |
|
460 | + return; |
|
461 | 461 | |
462 | - } |
|
462 | + } |
|
463 | 463 | |
464 | - } |
|
464 | + } |
|
465 | 465 | |
466 | - /** |
|
467 | - * This sets the element at the given offset |
|
468 | - * @see ArrayAccess::offsetSet() |
|
469 | - * |
|
470 | - * @access public |
|
471 | - * |
|
472 | - * @param mixed $offset: The offset to set (non-integer offsets will be appended) |
|
473 | - * @param mixed $value: The value to set |
|
474 | - * |
|
475 | - * @return void |
|
476 | - */ |
|
477 | - public function offsetSet($offset, $value) { |
|
466 | + /** |
|
467 | + * This sets the element at the given offset |
|
468 | + * @see ArrayAccess::offsetSet() |
|
469 | + * |
|
470 | + * @access public |
|
471 | + * |
|
472 | + * @param mixed $offset: The offset to set (non-integer offsets will be appended) |
|
473 | + * @param mixed $value: The value to set |
|
474 | + * |
|
475 | + * @return void |
|
476 | + */ |
|
477 | + public function offsetSet($offset, $value) { |
|
478 | 478 | |
479 | - if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($offset)) { |
|
479 | + if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($offset)) { |
|
480 | 480 | |
481 | - $this->elements[$offset] = $value; |
|
481 | + $this->elements[$offset] = $value; |
|
482 | 482 | |
483 | - } else { |
|
483 | + } else { |
|
484 | 484 | |
485 | - $this->elements[] = $value; |
|
485 | + $this->elements[] = $value; |
|
486 | 486 | |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | - // Re-number the elements. |
|
490 | - $this->elements = array_values($this->elements); |
|
489 | + // Re-number the elements. |
|
490 | + $this->elements = array_values($this->elements); |
|
491 | 491 | |
492 | - $this->count = count($this->elements); |
|
492 | + $this->count = count($this->elements); |
|
493 | 493 | |
494 | - } |
|
494 | + } |
|
495 | 495 | |
496 | - /** |
|
497 | - * This removes the element at the given position from the list |
|
498 | - * |
|
499 | - * @access public |
|
500 | - * |
|
501 | - * @param integer $position: Numeric position for removing |
|
502 | - * |
|
503 | - * @return array The removed element |
|
504 | - */ |
|
505 | - public function remove($position) { |
|
496 | + /** |
|
497 | + * This removes the element at the given position from the list |
|
498 | + * |
|
499 | + * @access public |
|
500 | + * |
|
501 | + * @param integer $position: Numeric position for removing |
|
502 | + * |
|
503 | + * @return array The removed element |
|
504 | + */ |
|
505 | + public function remove($position) { |
|
506 | 506 | |
507 | - // Save parameter for logging purposes. |
|
508 | - $_position = $position; |
|
507 | + // Save parameter for logging purposes. |
|
508 | + $_position = $position; |
|
509 | 509 | |
510 | - $position = intval($position); |
|
510 | + $position = intval($position); |
|
511 | 511 | |
512 | - if ($position < 0 || $position >= $this->count) { |
|
512 | + if ($position < 0 || $position >= $this->count) { |
|
513 | 513 | |
514 | - if (TYPO3_DLOG) { |
|
514 | + if (TYPO3_DLOG) { |
|
515 | 515 | |
516 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->remove('.$_position.')] Invalid position "'.$position.'" for element removing', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
516 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->remove('.$_position.')] Invalid position "'.$position.'" for element removing', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
517 | 517 | |
518 | - } |
|
518 | + } |
|
519 | 519 | |
520 | - return; |
|
520 | + return; |
|
521 | 521 | |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | - $removed = array_splice($this->elements, $position, 1); |
|
524 | + $removed = array_splice($this->elements, $position, 1); |
|
525 | 525 | |
526 | - $this->count = count($this->elements); |
|
526 | + $this->count = count($this->elements); |
|
527 | 527 | |
528 | - return $this->getRecord($removed[0]); |
|
528 | + return $this->getRecord($removed[0]); |
|
529 | 529 | |
530 | - } |
|
530 | + } |
|
531 | 531 | |
532 | - /** |
|
533 | - * This removes elements at the given range from the list |
|
534 | - * |
|
535 | - * @access public |
|
536 | - * |
|
537 | - * @param integer $position: Numeric position for start of range |
|
538 | - * |
|
539 | - * @param integer $length: Numeric position for length of range |
|
540 | - * |
|
541 | - * @return array The indizes of the removed elements |
|
542 | - */ |
|
543 | - public function removeRange($position, $length) { |
|
532 | + /** |
|
533 | + * This removes elements at the given range from the list |
|
534 | + * |
|
535 | + * @access public |
|
536 | + * |
|
537 | + * @param integer $position: Numeric position for start of range |
|
538 | + * |
|
539 | + * @param integer $length: Numeric position for length of range |
|
540 | + * |
|
541 | + * @return array The indizes of the removed elements |
|
542 | + */ |
|
543 | + public function removeRange($position, $length) { |
|
544 | 544 | |
545 | - // Save parameter for logging purposes. |
|
546 | - $_position = $position; |
|
545 | + // Save parameter for logging purposes. |
|
546 | + $_position = $position; |
|
547 | 547 | |
548 | - $position = intval($position); |
|
548 | + $position = intval($position); |
|
549 | 549 | |
550 | - if ($position < 0 || $position >= $this->count) { |
|
550 | + if ($position < 0 || $position >= $this->count) { |
|
551 | 551 | |
552 | - if (TYPO3_DLOG) { |
|
552 | + if (TYPO3_DLOG) { |
|
553 | 553 | |
554 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->remove('.$_position.')] Invalid position "'.$position.'" for element removing', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
555 | - } |
|
554 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->remove('.$_position.')] Invalid position "'.$position.'" for element removing', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
555 | + } |
|
556 | 556 | |
557 | - return; |
|
558 | - } |
|
557 | + return; |
|
558 | + } |
|
559 | 559 | |
560 | - $removed = array_splice($this->elements, $position, $length); |
|
560 | + $removed = array_splice($this->elements, $position, $length); |
|
561 | 561 | |
562 | - $this->count = count($this->elements); |
|
562 | + $this->count = count($this->elements); |
|
563 | 563 | |
564 | - return $removed; |
|
565 | - } |
|
564 | + return $removed; |
|
565 | + } |
|
566 | 566 | |
567 | - /** |
|
568 | - * This clears the current list |
|
569 | - * |
|
570 | - * @access public |
|
571 | - * |
|
572 | - * @return void |
|
573 | - */ |
|
574 | - public function reset() { |
|
567 | + /** |
|
568 | + * This clears the current list |
|
569 | + * |
|
570 | + * @access public |
|
571 | + * |
|
572 | + * @return void |
|
573 | + */ |
|
574 | + public function reset() { |
|
575 | 575 | |
576 | - $this->elements = array (); |
|
576 | + $this->elements = array (); |
|
577 | 577 | |
578 | - $this->records = array (); |
|
578 | + $this->records = array (); |
|
579 | 579 | |
580 | - $this->metadata = array (); |
|
580 | + $this->metadata = array (); |
|
581 | 581 | |
582 | - $this->count = 0; |
|
582 | + $this->count = 0; |
|
583 | 583 | |
584 | - $this->position = 0; |
|
584 | + $this->position = 0; |
|
585 | 585 | |
586 | - } |
|
586 | + } |
|
587 | 587 | |
588 | - /** |
|
589 | - * This resets the list position |
|
590 | - * @see Iterator::rewind() |
|
591 | - * |
|
592 | - * @access public |
|
593 | - * |
|
594 | - * @return void |
|
595 | - */ |
|
596 | - public function rewind() { |
|
588 | + /** |
|
589 | + * This resets the list position |
|
590 | + * @see Iterator::rewind() |
|
591 | + * |
|
592 | + * @access public |
|
593 | + * |
|
594 | + * @return void |
|
595 | + */ |
|
596 | + public function rewind() { |
|
597 | 597 | |
598 | - $this->position = 0; |
|
598 | + $this->position = 0; |
|
599 | 599 | |
600 | - } |
|
600 | + } |
|
601 | 601 | |
602 | - /** |
|
603 | - * This saves the current list |
|
604 | - * |
|
605 | - * @access public |
|
606 | - * |
|
607 | - * @param integer $pid: PID for saving in database |
|
608 | - * |
|
609 | - * @return void |
|
610 | - */ |
|
611 | - public function save($pid = 0) { |
|
602 | + /** |
|
603 | + * This saves the current list |
|
604 | + * |
|
605 | + * @access public |
|
606 | + * |
|
607 | + * @param integer $pid: PID for saving in database |
|
608 | + * |
|
609 | + * @return void |
|
610 | + */ |
|
611 | + public function save($pid = 0) { |
|
612 | 612 | |
613 | - $pid = max(intval($pid), 0); |
|
613 | + $pid = max(intval($pid), 0); |
|
614 | 614 | |
615 | - // If no PID is given, save to the user's session instead |
|
616 | - if ($pid > 0) { |
|
615 | + // If no PID is given, save to the user's session instead |
|
616 | + if ($pid > 0) { |
|
617 | 617 | |
618 | - // TODO: Liste in Datenbank speichern (inkl. Sichtbarkeit, Beschreibung, etc.) |
|
618 | + // TODO: Liste in Datenbank speichern (inkl. Sichtbarkeit, Beschreibung, etc.) |
|
619 | 619 | |
620 | - } else { |
|
620 | + } else { |
|
621 | 621 | |
622 | - tx_dlf_helper::saveToSession(array ($this->elements, $this->metadata), get_class($this)); |
|
622 | + tx_dlf_helper::saveToSession(array ($this->elements, $this->metadata), get_class($this)); |
|
623 | 623 | |
624 | - } |
|
624 | + } |
|
625 | 625 | |
626 | - } |
|
626 | + } |
|
627 | 627 | |
628 | - /** |
|
629 | - * Connects to Solr server. |
|
630 | - * |
|
631 | - * @access protected |
|
632 | - * |
|
633 | - * @return boolean TRUE on success or FALSE on failure |
|
634 | - */ |
|
635 | - protected function solrConnect() { |
|
628 | + /** |
|
629 | + * Connects to Solr server. |
|
630 | + * |
|
631 | + * @access protected |
|
632 | + * |
|
633 | + * @return boolean TRUE on success or FALSE on failure |
|
634 | + */ |
|
635 | + protected function solrConnect() { |
|
636 | 636 | |
637 | - // Get Solr instance. |
|
638 | - if (!$this->solr) { |
|
637 | + // Get Solr instance. |
|
638 | + if (!$this->solr) { |
|
639 | 639 | |
640 | - // Connect to Solr server. |
|
641 | - if ($this->solr = tx_dlf_solr::getInstance($this->metadata['options']['core'])) { |
|
640 | + // Connect to Solr server. |
|
641 | + if ($this->solr = tx_dlf_solr::getInstance($this->metadata['options']['core'])) { |
|
642 | 642 | |
643 | - // Load index configuration. |
|
644 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
645 | - 'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.index_tokenized AS index_tokenized,tx_dlf_metadata.index_indexed AS index_indexed', |
|
646 | - 'tx_dlf_metadata', |
|
647 | - 'tx_dlf_metadata.is_listed=1 AND tx_dlf_metadata.pid='.intval($this->metadata['options']['pid']).tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
648 | - '', |
|
649 | - 'tx_dlf_metadata.sorting ASC', |
|
650 | - '' |
|
651 | - ); |
|
643 | + // Load index configuration. |
|
644 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
645 | + 'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.index_tokenized AS index_tokenized,tx_dlf_metadata.index_indexed AS index_indexed', |
|
646 | + 'tx_dlf_metadata', |
|
647 | + 'tx_dlf_metadata.is_listed=1 AND tx_dlf_metadata.pid='.intval($this->metadata['options']['pid']).tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
648 | + '', |
|
649 | + 'tx_dlf_metadata.sorting ASC', |
|
650 | + '' |
|
651 | + ); |
|
652 | 652 | |
653 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
653 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
654 | 654 | |
655 | - $this->solrConfig[$resArray['index_name']] = $resArray['index_name'].'_'.($resArray['index_tokenized'] ? 't' : 'u').'s'.($resArray['index_indexed'] ? 'i' : 'u'); |
|
655 | + $this->solrConfig[$resArray['index_name']] = $resArray['index_name'].'_'.($resArray['index_tokenized'] ? 't' : 'u').'s'.($resArray['index_indexed'] ? 'i' : 'u'); |
|
656 | 656 | |
657 | - } |
|
657 | + } |
|
658 | 658 | |
659 | - // Add static fields. |
|
660 | - $this->solrConfig['type'] = 'type'; |
|
659 | + // Add static fields. |
|
660 | + $this->solrConfig['type'] = 'type'; |
|
661 | 661 | |
662 | - } else { |
|
662 | + } else { |
|
663 | 663 | |
664 | - return FALSE; |
|
664 | + return FALSE; |
|
665 | 665 | |
666 | - } |
|
666 | + } |
|
667 | 667 | |
668 | - } |
|
668 | + } |
|
669 | 669 | |
670 | - return TRUE; |
|
670 | + return TRUE; |
|
671 | 671 | |
672 | - } |
|
672 | + } |
|
673 | 673 | |
674 | - /** |
|
675 | - * This sorts the current list by the given field |
|
676 | - * |
|
677 | - * @access public |
|
678 | - * |
|
679 | - * @param string $by: Sort the list by this field |
|
680 | - * @param boolean $asc: Sort ascending? |
|
681 | - * |
|
682 | - * @return void |
|
683 | - */ |
|
684 | - public function sort($by, $asc = TRUE) { |
|
674 | + /** |
|
675 | + * This sorts the current list by the given field |
|
676 | + * |
|
677 | + * @access public |
|
678 | + * |
|
679 | + * @param string $by: Sort the list by this field |
|
680 | + * @param boolean $asc: Sort ascending? |
|
681 | + * |
|
682 | + * @return void |
|
683 | + */ |
|
684 | + public function sort($by, $asc = TRUE) { |
|
685 | 685 | |
686 | - $newOrder = array (); |
|
686 | + $newOrder = array (); |
|
687 | 687 | |
688 | - $nonSortable = array (); |
|
688 | + $nonSortable = array (); |
|
689 | 689 | |
690 | - foreach ($this->elements as $num => $element) { |
|
690 | + foreach ($this->elements as $num => $element) { |
|
691 | 691 | |
692 | - // Is this element sortable? |
|
693 | - if (!empty($element['s'][$by])) { |
|
692 | + // Is this element sortable? |
|
693 | + if (!empty($element['s'][$by])) { |
|
694 | 694 | |
695 | - $newOrder[$element['s'][$by].str_pad($num, 6, '0', STR_PAD_LEFT)] = $element; |
|
695 | + $newOrder[$element['s'][$by].str_pad($num, 6, '0', STR_PAD_LEFT)] = $element; |
|
696 | 696 | |
697 | - } else { |
|
697 | + } else { |
|
698 | 698 | |
699 | - $nonSortable[] = $element; |
|
699 | + $nonSortable[] = $element; |
|
700 | 700 | |
701 | - } |
|
701 | + } |
|
702 | 702 | |
703 | - } |
|
703 | + } |
|
704 | 704 | |
705 | - // Reorder elements. |
|
706 | - if ($asc) { |
|
705 | + // Reorder elements. |
|
706 | + if ($asc) { |
|
707 | 707 | |
708 | - ksort($newOrder, SORT_LOCALE_STRING); |
|
708 | + ksort($newOrder, SORT_LOCALE_STRING); |
|
709 | 709 | |
710 | - } else { |
|
710 | + } else { |
|
711 | 711 | |
712 | - krsort($newOrder, SORT_LOCALE_STRING); |
|
712 | + krsort($newOrder, SORT_LOCALE_STRING); |
|
713 | 713 | |
714 | - } |
|
714 | + } |
|
715 | 715 | |
716 | - // Add non sortable elements to the end of the list. |
|
717 | - $newOrder = array_merge(array_values($newOrder), $nonSortable); |
|
716 | + // Add non sortable elements to the end of the list. |
|
717 | + $newOrder = array_merge(array_values($newOrder), $nonSortable); |
|
718 | 718 | |
719 | - // Check if something is missing. |
|
720 | - if ($this->count == count($newOrder)) { |
|
719 | + // Check if something is missing. |
|
720 | + if ($this->count == count($newOrder)) { |
|
721 | 721 | |
722 | - $this->elements = $newOrder; |
|
722 | + $this->elements = $newOrder; |
|
723 | 723 | |
724 | - } else { |
|
724 | + } else { |
|
725 | 725 | |
726 | - if (TYPO3_DLOG) { |
|
726 | + if (TYPO3_DLOG) { |
|
727 | 727 | |
728 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->sort('.$by.', ['.($asc ? 'TRUE' : 'FALSE').'])] Sorted list elements do not match unsorted elements', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
728 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->sort('.$by.', ['.($asc ? 'TRUE' : 'FALSE').'])] Sorted list elements do not match unsorted elements', $this->extKey, SYSLOG_SEVERITY_ERROR); |
|
729 | 729 | |
730 | - } |
|
730 | + } |
|
731 | 731 | |
732 | - } |
|
732 | + } |
|
733 | 733 | |
734 | - } |
|
734 | + } |
|
735 | 735 | |
736 | - /** |
|
737 | - * This unsets the element at the given offset |
|
738 | - * @see ArrayAccess::offsetUnset() |
|
739 | - * |
|
740 | - * @access public |
|
741 | - * |
|
742 | - * @param mixed $offset: The offset to unset |
|
743 | - * |
|
744 | - * @return void |
|
745 | - */ |
|
746 | - public function offsetUnset($offset) { |
|
736 | + /** |
|
737 | + * This unsets the element at the given offset |
|
738 | + * @see ArrayAccess::offsetUnset() |
|
739 | + * |
|
740 | + * @access public |
|
741 | + * |
|
742 | + * @param mixed $offset: The offset to unset |
|
743 | + * |
|
744 | + * @return void |
|
745 | + */ |
|
746 | + public function offsetUnset($offset) { |
|
747 | 747 | |
748 | - unset ($this->elements[$offset]); |
|
748 | + unset ($this->elements[$offset]); |
|
749 | 749 | |
750 | - // Re-number the elements. |
|
751 | - $this->elements = array_values($this->elements); |
|
750 | + // Re-number the elements. |
|
751 | + $this->elements = array_values($this->elements); |
|
752 | 752 | |
753 | - $this->count = count($this->elements); |
|
753 | + $this->count = count($this->elements); |
|
754 | 754 | |
755 | - } |
|
755 | + } |
|
756 | 756 | |
757 | - /** |
|
758 | - * This checks if the current list position is valid |
|
759 | - * @see Iterator::valid() |
|
760 | - * |
|
761 | - * @access public |
|
762 | - * |
|
763 | - * @return boolean Is the current list position valid? |
|
764 | - */ |
|
765 | - public function valid() { |
|
757 | + /** |
|
758 | + * This checks if the current list position is valid |
|
759 | + * @see Iterator::valid() |
|
760 | + * |
|
761 | + * @access public |
|
762 | + * |
|
763 | + * @return boolean Is the current list position valid? |
|
764 | + */ |
|
765 | + public function valid() { |
|
766 | 766 | |
767 | - return isset($this->elements[$this->position]); |
|
767 | + return isset($this->elements[$this->position]); |
|
768 | 768 | |
769 | - } |
|
769 | + } |
|
770 | 770 | |
771 | - /** |
|
772 | - * This returns $this->metadata via __get() |
|
773 | - * |
|
774 | - * @access protected |
|
775 | - * |
|
776 | - * @return array The list's metadata |
|
777 | - */ |
|
778 | - protected function _getMetadata() { |
|
771 | + /** |
|
772 | + * This returns $this->metadata via __get() |
|
773 | + * |
|
774 | + * @access protected |
|
775 | + * |
|
776 | + * @return array The list's metadata |
|
777 | + */ |
|
778 | + protected function _getMetadata() { |
|
779 | 779 | |
780 | - return $this->metadata; |
|
780 | + return $this->metadata; |
|
781 | 781 | |
782 | - } |
|
782 | + } |
|
783 | 783 | |
784 | - /** |
|
785 | - * This sets $this->metadata via __set() |
|
786 | - * |
|
787 | - * @access protected |
|
788 | - * |
|
789 | - * @param array $metadata: Array of new metadata |
|
790 | - * |
|
791 | - * @return void |
|
792 | - */ |
|
793 | - protected function _setMetadata(array $metadata = array ()) { |
|
784 | + /** |
|
785 | + * This sets $this->metadata via __set() |
|
786 | + * |
|
787 | + * @access protected |
|
788 | + * |
|
789 | + * @param array $metadata: Array of new metadata |
|
790 | + * |
|
791 | + * @return void |
|
792 | + */ |
|
793 | + protected function _setMetadata(array $metadata = array ()) { |
|
794 | 794 | |
795 | - $this->metadata = $metadata; |
|
795 | + $this->metadata = $metadata; |
|
796 | 796 | |
797 | - } |
|
797 | + } |
|
798 | 798 | |
799 | - /** |
|
800 | - * This is the constructor |
|
801 | - * |
|
802 | - * @access public |
|
803 | - * |
|
804 | - * @param array $elements: Array of documents initially setting up the list |
|
805 | - * @param array $metadata: Array of initial metadata |
|
806 | - * |
|
807 | - * @return void |
|
808 | - */ |
|
809 | - public function __construct(array $elements = array (), array $metadata = array ()) { |
|
799 | + /** |
|
800 | + * This is the constructor |
|
801 | + * |
|
802 | + * @access public |
|
803 | + * |
|
804 | + * @param array $elements: Array of documents initially setting up the list |
|
805 | + * @param array $metadata: Array of initial metadata |
|
806 | + * |
|
807 | + * @return void |
|
808 | + */ |
|
809 | + public function __construct(array $elements = array (), array $metadata = array ()) { |
|
810 | 810 | |
811 | - if (empty($elements) && empty($metadata)) { |
|
811 | + if (empty($elements) && empty($metadata)) { |
|
812 | 812 | |
813 | - // Let's check the user's session. |
|
814 | - $sessionData = tx_dlf_helper::loadFromSession(get_class($this)); |
|
813 | + // Let's check the user's session. |
|
814 | + $sessionData = tx_dlf_helper::loadFromSession(get_class($this)); |
|
815 | 815 | |
816 | - // Restore list from session data. |
|
817 | - if (is_array($sessionData)) { |
|
816 | + // Restore list from session data. |
|
817 | + if (is_array($sessionData)) { |
|
818 | 818 | |
819 | - if (is_array($sessionData[0])) { |
|
819 | + if (is_array($sessionData[0])) { |
|
820 | 820 | |
821 | - $this->elements = $sessionData[0]; |
|
821 | + $this->elements = $sessionData[0]; |
|
822 | 822 | |
823 | - } |
|
823 | + } |
|
824 | 824 | |
825 | - if (is_array($sessionData[1])) { |
|
825 | + if (is_array($sessionData[1])) { |
|
826 | 826 | |
827 | - $this->metadata = $sessionData[1]; |
|
827 | + $this->metadata = $sessionData[1]; |
|
828 | 828 | |
829 | - } |
|
829 | + } |
|
830 | 830 | |
831 | - } |
|
831 | + } |
|
832 | 832 | |
833 | - } else { |
|
833 | + } else { |
|
834 | 834 | |
835 | - // Add metadata to the list. |
|
836 | - $this->metadata = $metadata; |
|
835 | + // Add metadata to the list. |
|
836 | + $this->metadata = $metadata; |
|
837 | 837 | |
838 | - // Add initial set of elements to the list. |
|
839 | - $this->elements = $elements; |
|
838 | + // Add initial set of elements to the list. |
|
839 | + $this->elements = $elements; |
|
840 | 840 | |
841 | - } |
|
841 | + } |
|
842 | 842 | |
843 | - $this->count = count($this->elements); |
|
843 | + $this->count = count($this->elements); |
|
844 | 844 | |
845 | - } |
|
845 | + } |
|
846 | 846 | |
847 | - /** |
|
848 | - * This magic method is invoked each time a clone is called on the object variable |
|
849 | - * (This method is defined as private/protected because singleton objects should not be cloned) |
|
850 | - * |
|
851 | - * @access protected |
|
852 | - * |
|
853 | - * @return void |
|
854 | - */ |
|
855 | - protected function __clone() {} |
|
847 | + /** |
|
848 | + * This magic method is invoked each time a clone is called on the object variable |
|
849 | + * (This method is defined as private/protected because singleton objects should not be cloned) |
|
850 | + * |
|
851 | + * @access protected |
|
852 | + * |
|
853 | + * @return void |
|
854 | + */ |
|
855 | + protected function __clone() {} |
|
856 | 856 | |
857 | - /** |
|
858 | - * This magic method is called each time an invisible property is referenced from the object |
|
859 | - * |
|
860 | - * @access public |
|
861 | - * |
|
862 | - * @param string $var: Name of variable to get |
|
863 | - * |
|
864 | - * @return mixed Value of $this->$var |
|
865 | - */ |
|
866 | - public function __get($var) { |
|
857 | + /** |
|
858 | + * This magic method is called each time an invisible property is referenced from the object |
|
859 | + * |
|
860 | + * @access public |
|
861 | + * |
|
862 | + * @param string $var: Name of variable to get |
|
863 | + * |
|
864 | + * @return mixed Value of $this->$var |
|
865 | + */ |
|
866 | + public function __get($var) { |
|
867 | 867 | |
868 | - $method = '_get'.ucfirst($var); |
|
868 | + $method = '_get'.ucfirst($var); |
|
869 | 869 | |
870 | - if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
870 | + if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
871 | 871 | |
872 | - if (TYPO3_DLOG) { |
|
872 | + if (TYPO3_DLOG) { |
|
873 | 873 | |
874 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->__get('.$var.')] There is no getter function for property "'.$var.'"', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
874 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->__get('.$var.')] There is no getter function for property "'.$var.'"', $this->extKey, SYSLOG_SEVERITY_WARNING); |
|
875 | 875 | |
876 | - } |
|
876 | + } |
|
877 | 877 | |
878 | - return; |
|
878 | + return; |
|
879 | 879 | |
880 | - } else { |
|
880 | + } else { |
|
881 | 881 | |
882 | - return $this->$method(); |
|
882 | + return $this->$method(); |
|
883 | 883 | |
884 | - } |
|
884 | + } |
|
885 | 885 | |
886 | - } |
|
886 | + } |
|
887 | 887 | |
888 | - /** |
|
889 | - * This magic method is called each time an invisible property is referenced from the object |
|
890 | - * |
|
891 | - * @access public |
|
892 | - * |
|
893 | - * @param string $var: Name of variable to set |
|
894 | - * @param mixed $value: New value of variable |
|
895 | - * |
|
896 | - * @return void |
|
897 | - */ |
|
898 | - public function __set($var, $value) { |
|
888 | + /** |
|
889 | + * This magic method is called each time an invisible property is referenced from the object |
|
890 | + * |
|
891 | + * @access public |
|
892 | + * |
|
893 | + * @param string $var: Name of variable to set |
|
894 | + * @param mixed $value: New value of variable |
|
895 | + * |
|
896 | + * @return void |
|
897 | + */ |
|
898 | + public function __set($var, $value) { |
|
899 | 899 | |
900 | - $method = '_set'.ucfirst($var); |
|
900 | + $method = '_set'.ucfirst($var); |
|
901 | 901 | |
902 | - if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
902 | + if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
903 | 903 | |
904 | - if (TYPO3_DLOG) { |
|
904 | + if (TYPO3_DLOG) { |
|
905 | 905 | |
906 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->__set('.$var.', [data])] There is no setter function for property "'.$var.'"', $this->extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
906 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_list->__set('.$var.', [data])] There is no setter function for property "'.$var.'"', $this->extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
907 | 907 | |
908 | - } |
|
908 | + } |
|
909 | 909 | |
910 | - } else { |
|
910 | + } else { |
|
911 | 911 | |
912 | - $this->$method($value); |
|
912 | + $this->$method($value); |
|
913 | 913 | |
914 | - } |
|
914 | + } |
|
915 | 915 | |
916 | - } |
|
916 | + } |
|
917 | 917 | |
918 | - /** |
|
919 | - * This magic method is executed prior to any serialization of the object |
|
920 | - * @see __wakeup() |
|
921 | - * |
|
922 | - * @access public |
|
923 | - * |
|
924 | - * @return array Properties to be serialized |
|
925 | - */ |
|
926 | - public function __sleep() { |
|
918 | + /** |
|
919 | + * This magic method is executed prior to any serialization of the object |
|
920 | + * @see __wakeup() |
|
921 | + * |
|
922 | + * @access public |
|
923 | + * |
|
924 | + * @return array Properties to be serialized |
|
925 | + */ |
|
926 | + public function __sleep() { |
|
927 | 927 | |
928 | - return array ('elements', 'metadata'); |
|
928 | + return array ('elements', 'metadata'); |
|
929 | 929 | |
930 | - } |
|
930 | + } |
|
931 | 931 | |
932 | - /** |
|
933 | - * This magic method is executed after the object is deserialized |
|
934 | - * @see __sleep() |
|
935 | - * |
|
936 | - * @access public |
|
937 | - * |
|
938 | - * @return void |
|
939 | - */ |
|
940 | - public function __wakeup() { |
|
932 | + /** |
|
933 | + * This magic method is executed after the object is deserialized |
|
934 | + * @see __sleep() |
|
935 | + * |
|
936 | + * @access public |
|
937 | + * |
|
938 | + * @return void |
|
939 | + */ |
|
940 | + public function __wakeup() { |
|
941 | 941 | |
942 | - $this->count = count($this->elements); |
|
942 | + $this->count = count($this->elements); |
|
943 | 943 | |
944 | - } |
|
944 | + } |
|
945 | 945 | |
946 | 946 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @var array() |
36 | 36 | * @access protected |
37 | 37 | */ |
38 | - protected $elements = array (); |
|
38 | + protected $elements = array(); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * This holds the list's metadata |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @var array |
44 | 44 | * @access protected |
45 | 45 | */ |
46 | - protected $metadata = array (); |
|
46 | + protected $metadata = array(); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * This holds the current list position |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @var array() |
61 | 61 | * @access protected |
62 | 62 | */ |
63 | - protected $records = array (); |
|
63 | + protected $records = array(); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Instance of Apache_Solr_Service class |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @var array |
77 | 77 | * @access protected |
78 | 78 | */ |
79 | - protected $solrConfig = array (); |
|
79 | + protected $solrConfig = array(); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * This adds an array of elements at the given position to the list |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function getRecord($element) { |
157 | 157 | |
158 | - if (is_array($element) && array_keys($element) == array ('u', 'h', 's', 'p')) { |
|
158 | + if (is_array($element) && array_keys($element) == array('u', 'h', 's', 'p')) { |
|
159 | 159 | |
160 | 160 | // Return already processed record if possible. |
161 | 161 | if (!empty($this->records[$element['u']])) { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | - $record = array ( |
|
167 | + $record = array( |
|
168 | 168 | 'uid' => $element['u'], |
169 | 169 | 'page' => 1, |
170 | 170 | 'preview' => '', |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | } elseif (($key = tx_dlf_helper::array_search_recursive($resArray['uid'], $record['subparts'], TRUE)) !== FALSE) { |
227 | 227 | |
228 | - $record['subparts'][$key] = array ( |
|
228 | + $record['subparts'][$key] = array( |
|
229 | 229 | 'uid' => $resArray['uid'], |
230 | 230 | 'page' => 1, |
231 | 231 | 'preview' => (!empty($record['subparts'][$key]['h']) ? $record['subparts'][$key]['h'] : ''), |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | foreach ($result->response->docs as $resArray) { |
249 | 249 | |
250 | 250 | // Prepare document's metadata. |
251 | - $metadata = array (); |
|
251 | + $metadata = array(); |
|
252 | 252 | |
253 | 253 | foreach ($this->solrConfig as $index_name => $solr_name) { |
254 | 254 | |
255 | 255 | if (!empty($resArray->$solr_name)) { |
256 | 256 | |
257 | - $metadata[$index_name] = (is_array($resArray->$solr_name) ? $resArray->$solr_name : array ($resArray->$solr_name)); |
|
257 | + $metadata[$index_name] = (is_array($resArray->$solr_name) ? $resArray->$solr_name : array($resArray->$solr_name)); |
|
258 | 258 | |
259 | 259 | } |
260 | 260 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | } elseif (($key = tx_dlf_helper::array_search_recursive($resArray->id, $record['subparts'], TRUE)) !== FALSE) { |
271 | 271 | |
272 | - $record['subparts'][$key] = array ( |
|
272 | + $record['subparts'][$key] = array( |
|
273 | 273 | 'uid' => $resArray->uid, |
274 | 274 | 'page' => $resArray->page, |
275 | 275 | 'preview' => (!empty($record['subparts'][$key]['h']) ? $record['subparts'][$key]['h'] : ''), |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | $element = $this->remove($position); |
371 | 371 | |
372 | - $this->add(array ($element), $position + $steps); |
|
372 | + $this->add(array($element), $position + $steps); |
|
373 | 373 | |
374 | 374 | } |
375 | 375 | |
@@ -573,11 +573,11 @@ discard block |
||
573 | 573 | */ |
574 | 574 | public function reset() { |
575 | 575 | |
576 | - $this->elements = array (); |
|
576 | + $this->elements = array(); |
|
577 | 577 | |
578 | - $this->records = array (); |
|
578 | + $this->records = array(); |
|
579 | 579 | |
580 | - $this->metadata = array (); |
|
580 | + $this->metadata = array(); |
|
581 | 581 | |
582 | 582 | $this->count = 0; |
583 | 583 | |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | |
620 | 620 | } else { |
621 | 621 | |
622 | - tx_dlf_helper::saveToSession(array ($this->elements, $this->metadata), get_class($this)); |
|
622 | + tx_dlf_helper::saveToSession(array($this->elements, $this->metadata), get_class($this)); |
|
623 | 623 | |
624 | 624 | } |
625 | 625 | |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | */ |
684 | 684 | public function sort($by, $asc = TRUE) { |
685 | 685 | |
686 | - $newOrder = array (); |
|
686 | + $newOrder = array(); |
|
687 | 687 | |
688 | - $nonSortable = array (); |
|
688 | + $nonSortable = array(); |
|
689 | 689 | |
690 | 690 | foreach ($this->elements as $num => $element) { |
691 | 691 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @return void |
792 | 792 | */ |
793 | - protected function _setMetadata(array $metadata = array ()) { |
|
793 | + protected function _setMetadata(array $metadata = array()) { |
|
794 | 794 | |
795 | 795 | $this->metadata = $metadata; |
796 | 796 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @return void |
808 | 808 | */ |
809 | - public function __construct(array $elements = array (), array $metadata = array ()) { |
|
809 | + public function __construct(array $elements = array(), array $metadata = array()) { |
|
810 | 810 | |
811 | 811 | if (empty($elements) && empty($metadata)) { |
812 | 812 | |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | */ |
926 | 926 | public function __sleep() { |
927 | 927 | |
928 | - return array ('elements', 'metadata'); |
|
928 | + return array('elements', 'metadata'); |
|
929 | 929 | |
930 | 930 | } |
931 | 931 |
@@ -10,32 +10,32 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | $EM_CONF[$_EXTKEY] = array ( |
13 | - 'title' => 'Kitodo.Presentation', |
|
14 | - 'description' => 'Base plugins, modules, services and API of the Digital Library Framework. It is part of the community-based Kitodo Digitization Suite.', |
|
15 | - 'category' => 'fe', |
|
16 | - 'author' => 'Kitodo. Key to digital objects e.V.', |
|
17 | - 'author_email' => '[email protected]', |
|
18 | - 'author_company' => '<br /><a href="http://www.kitodo.org/" target="_blank">Kitodo.org</a><br /><a href="https://github.com/kitodo" target="_blank">Kitodo on GitHub</a>', |
|
19 | - 'shy' => '', |
|
20 | - 'priority' => '', |
|
21 | - 'module' => '', |
|
22 | - 'state' => 'stable', |
|
23 | - 'internal' => '', |
|
24 | - 'uploadfolder' => TRUE, |
|
25 | - 'createDirs' => '', |
|
26 | - 'modify_tables' => '', |
|
27 | - 'clearCacheOnLoad' => FALSE, |
|
28 | - 'lockType' => '', |
|
29 | - 'version' => '2.1.0', |
|
30 | - 'constraints' => array ( |
|
31 | - 'depends' => array ( |
|
32 | - 'php' => '5.3.7-', |
|
33 | - 'typo3' => '6.2.0-7.9.99', |
|
34 | - ), |
|
35 | - 'conflicts' => array ( |
|
36 | - ), |
|
37 | - 'suggests' => array ( |
|
38 | - ), |
|
39 | - ), |
|
40 | - '_md5_values_when_last_written' => '', |
|
13 | + 'title' => 'Kitodo.Presentation', |
|
14 | + 'description' => 'Base plugins, modules, services and API of the Digital Library Framework. It is part of the community-based Kitodo Digitization Suite.', |
|
15 | + 'category' => 'fe', |
|
16 | + 'author' => 'Kitodo. Key to digital objects e.V.', |
|
17 | + 'author_email' => '[email protected]', |
|
18 | + 'author_company' => '<br /><a href="http://www.kitodo.org/" target="_blank">Kitodo.org</a><br /><a href="https://github.com/kitodo" target="_blank">Kitodo on GitHub</a>', |
|
19 | + 'shy' => '', |
|
20 | + 'priority' => '', |
|
21 | + 'module' => '', |
|
22 | + 'state' => 'stable', |
|
23 | + 'internal' => '', |
|
24 | + 'uploadfolder' => TRUE, |
|
25 | + 'createDirs' => '', |
|
26 | + 'modify_tables' => '', |
|
27 | + 'clearCacheOnLoad' => FALSE, |
|
28 | + 'lockType' => '', |
|
29 | + 'version' => '2.1.0', |
|
30 | + 'constraints' => array ( |
|
31 | + 'depends' => array ( |
|
32 | + 'php' => '5.3.7-', |
|
33 | + 'typo3' => '6.2.0-7.9.99', |
|
34 | + ), |
|
35 | + 'conflicts' => array ( |
|
36 | + ), |
|
37 | + 'suggests' => array ( |
|
38 | + ), |
|
39 | + ), |
|
40 | + '_md5_values_when_last_written' => '', |
|
41 | 41 | ); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * LICENSE.txt file that was distributed with this source code. |
10 | 10 | */ |
11 | 11 | |
12 | -$EM_CONF[$_EXTKEY] = array ( |
|
12 | +$EM_CONF[$_EXTKEY] = array( |
|
13 | 13 | 'title' => 'Kitodo.Presentation', |
14 | 14 | 'description' => 'Base plugins, modules, services and API of the Digital Library Framework. It is part of the community-based Kitodo Digitization Suite.', |
15 | 15 | 'category' => 'fe', |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | 'clearCacheOnLoad' => FALSE, |
28 | 28 | 'lockType' => '', |
29 | 29 | 'version' => '2.1.0', |
30 | - 'constraints' => array ( |
|
31 | - 'depends' => array ( |
|
30 | + 'constraints' => array( |
|
31 | + 'depends' => array( |
|
32 | 32 | 'php' => '5.3.7-', |
33 | 33 | 'typo3' => '6.2.0-7.9.99', |
34 | 34 | ), |
35 | - 'conflicts' => array ( |
|
35 | + 'conflicts' => array( |
|
36 | 36 | ), |
37 | - 'suggests' => array ( |
|
37 | + 'suggests' => array( |
|
38 | 38 | ), |
39 | 39 | ), |
40 | 40 | '_md5_values_when_last_written' => '', |
@@ -10,78 +10,78 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | return array ( |
13 | - 'ctrl' => array ( |
|
14 | - 'title' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat', |
|
15 | - 'label' => 'encoded', |
|
16 | - 'tstamp' => 'tstamp', |
|
17 | - 'crdate' => 'crdate', |
|
18 | - 'cruser_id' => 'cruser_id', |
|
19 | - 'default_sortby' => 'ORDER BY encoded', |
|
20 | - 'delete' => 'deleted', |
|
21 | - 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('dlf').'res/icons/txdlfmetadata.png', |
|
22 | - 'rootLevel' => 0, |
|
23 | - 'dividers2tabs' => 2, |
|
24 | - 'searchFields' => 'encoded', |
|
25 | - 'hideTable' => 1, |
|
26 | - ), |
|
27 | - 'feInterface' => array ( |
|
28 | - 'fe_admin_fieldList' => '', |
|
29 | - ), |
|
30 | - 'interface' => array ( |
|
31 | - 'showRecordFieldList' => 'parent_id,encoded,xpath,xpath_sorting', |
|
32 | - ), |
|
33 | - 'columns' => array ( |
|
34 | - 'parent_id' => array ( |
|
35 | - 'config' => array ( |
|
36 | - 'type' => 'passthrough', |
|
37 | - ), |
|
38 | - ), |
|
39 | - 'encoded' => array ( |
|
40 | - 'exclude' => 1, |
|
41 | - 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.encoded', |
|
42 | - 'config' => array ( |
|
43 | - 'type' => 'select', |
|
44 | - 'renderType' => 'selectSingle', |
|
45 | - 'foreign_table' => 'tx_dlf_formats', |
|
46 | - 'foreign_table_where' => 'ORDER BY tx_dlf_formats.type', |
|
47 | - 'size' => 1, |
|
48 | - 'minitems' => 1, |
|
49 | - 'maxitems' => 1, |
|
50 | - ), |
|
51 | - ), |
|
52 | - 'xpath' => array ( |
|
53 | - 'exclude' => 1, |
|
54 | - 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.xpath', |
|
55 | - 'config' => array ( |
|
56 | - 'type' => 'input', |
|
57 | - 'size' => 30, |
|
58 | - 'max' => 1024, |
|
59 | - 'eval' => 'required,trim', |
|
60 | - ), |
|
61 | - ), |
|
62 | - 'xpath_sorting' => array ( |
|
63 | - 'exclude' => 1, |
|
64 | - 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.xpath_sorting', |
|
65 | - 'config' => array ( |
|
66 | - 'type' => 'input', |
|
67 | - 'size' => 30, |
|
68 | - 'max' => 1024, |
|
69 | - 'eval' => 'trim', |
|
70 | - ), |
|
71 | - ), |
|
72 | - 'mandatory' => array ( |
|
73 | - 'exclude' => 1, |
|
74 | - 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.mandatory', |
|
75 | - 'config' => array ( |
|
76 | - 'type' => 'check', |
|
77 | - 'default' => 0, |
|
78 | - ), |
|
79 | - ), |
|
80 | - ), |
|
81 | - 'types' => array ( |
|
82 | - '0' => array ('showitem' => '--div--;LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.tab1, encoded;;;;1-1-1, xpath;;;;2-2-2, xpath_sorting, mandatory;;;;3-3-3'), |
|
83 | - ), |
|
84 | - 'palettes' => array ( |
|
85 | - '1' => array ('showitem' => ''), |
|
86 | - ), |
|
13 | + 'ctrl' => array ( |
|
14 | + 'title' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat', |
|
15 | + 'label' => 'encoded', |
|
16 | + 'tstamp' => 'tstamp', |
|
17 | + 'crdate' => 'crdate', |
|
18 | + 'cruser_id' => 'cruser_id', |
|
19 | + 'default_sortby' => 'ORDER BY encoded', |
|
20 | + 'delete' => 'deleted', |
|
21 | + 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('dlf').'res/icons/txdlfmetadata.png', |
|
22 | + 'rootLevel' => 0, |
|
23 | + 'dividers2tabs' => 2, |
|
24 | + 'searchFields' => 'encoded', |
|
25 | + 'hideTable' => 1, |
|
26 | + ), |
|
27 | + 'feInterface' => array ( |
|
28 | + 'fe_admin_fieldList' => '', |
|
29 | + ), |
|
30 | + 'interface' => array ( |
|
31 | + 'showRecordFieldList' => 'parent_id,encoded,xpath,xpath_sorting', |
|
32 | + ), |
|
33 | + 'columns' => array ( |
|
34 | + 'parent_id' => array ( |
|
35 | + 'config' => array ( |
|
36 | + 'type' => 'passthrough', |
|
37 | + ), |
|
38 | + ), |
|
39 | + 'encoded' => array ( |
|
40 | + 'exclude' => 1, |
|
41 | + 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.encoded', |
|
42 | + 'config' => array ( |
|
43 | + 'type' => 'select', |
|
44 | + 'renderType' => 'selectSingle', |
|
45 | + 'foreign_table' => 'tx_dlf_formats', |
|
46 | + 'foreign_table_where' => 'ORDER BY tx_dlf_formats.type', |
|
47 | + 'size' => 1, |
|
48 | + 'minitems' => 1, |
|
49 | + 'maxitems' => 1, |
|
50 | + ), |
|
51 | + ), |
|
52 | + 'xpath' => array ( |
|
53 | + 'exclude' => 1, |
|
54 | + 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.xpath', |
|
55 | + 'config' => array ( |
|
56 | + 'type' => 'input', |
|
57 | + 'size' => 30, |
|
58 | + 'max' => 1024, |
|
59 | + 'eval' => 'required,trim', |
|
60 | + ), |
|
61 | + ), |
|
62 | + 'xpath_sorting' => array ( |
|
63 | + 'exclude' => 1, |
|
64 | + 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.xpath_sorting', |
|
65 | + 'config' => array ( |
|
66 | + 'type' => 'input', |
|
67 | + 'size' => 30, |
|
68 | + 'max' => 1024, |
|
69 | + 'eval' => 'trim', |
|
70 | + ), |
|
71 | + ), |
|
72 | + 'mandatory' => array ( |
|
73 | + 'exclude' => 1, |
|
74 | + 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.mandatory', |
|
75 | + 'config' => array ( |
|
76 | + 'type' => 'check', |
|
77 | + 'default' => 0, |
|
78 | + ), |
|
79 | + ), |
|
80 | + ), |
|
81 | + 'types' => array ( |
|
82 | + '0' => array ('showitem' => '--div--;LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.tab1, encoded;;;;1-1-1, xpath;;;;2-2-2, xpath_sorting, mandatory;;;;3-3-3'), |
|
83 | + ), |
|
84 | + 'palettes' => array ( |
|
85 | + '1' => array ('showitem' => ''), |
|
86 | + ), |
|
87 | 87 | ); |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | * LICENSE.txt file that was distributed with this source code. |
10 | 10 | */ |
11 | 11 | |
12 | -return array ( |
|
13 | - 'ctrl' => array ( |
|
12 | +return array( |
|
13 | + 'ctrl' => array( |
|
14 | 14 | 'title' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat', |
15 | 15 | 'label' => 'encoded', |
16 | 16 | 'tstamp' => 'tstamp', |
@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | 'searchFields' => 'encoded', |
25 | 25 | 'hideTable' => 1, |
26 | 26 | ), |
27 | - 'feInterface' => array ( |
|
27 | + 'feInterface' => array( |
|
28 | 28 | 'fe_admin_fieldList' => '', |
29 | 29 | ), |
30 | - 'interface' => array ( |
|
30 | + 'interface' => array( |
|
31 | 31 | 'showRecordFieldList' => 'parent_id,encoded,xpath,xpath_sorting', |
32 | 32 | ), |
33 | - 'columns' => array ( |
|
34 | - 'parent_id' => array ( |
|
35 | - 'config' => array ( |
|
33 | + 'columns' => array( |
|
34 | + 'parent_id' => array( |
|
35 | + 'config' => array( |
|
36 | 36 | 'type' => 'passthrough', |
37 | 37 | ), |
38 | 38 | ), |
39 | - 'encoded' => array ( |
|
39 | + 'encoded' => array( |
|
40 | 40 | 'exclude' => 1, |
41 | 41 | 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.encoded', |
42 | - 'config' => array ( |
|
42 | + 'config' => array( |
|
43 | 43 | 'type' => 'select', |
44 | 44 | 'renderType' => 'selectSingle', |
45 | 45 | 'foreign_table' => 'tx_dlf_formats', |
@@ -49,39 +49,39 @@ discard block |
||
49 | 49 | 'maxitems' => 1, |
50 | 50 | ), |
51 | 51 | ), |
52 | - 'xpath' => array ( |
|
52 | + 'xpath' => array( |
|
53 | 53 | 'exclude' => 1, |
54 | 54 | 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.xpath', |
55 | - 'config' => array ( |
|
55 | + 'config' => array( |
|
56 | 56 | 'type' => 'input', |
57 | 57 | 'size' => 30, |
58 | 58 | 'max' => 1024, |
59 | 59 | 'eval' => 'required,trim', |
60 | 60 | ), |
61 | 61 | ), |
62 | - 'xpath_sorting' => array ( |
|
62 | + 'xpath_sorting' => array( |
|
63 | 63 | 'exclude' => 1, |
64 | 64 | 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.xpath_sorting', |
65 | - 'config' => array ( |
|
65 | + 'config' => array( |
|
66 | 66 | 'type' => 'input', |
67 | 67 | 'size' => 30, |
68 | 68 | 'max' => 1024, |
69 | 69 | 'eval' => 'trim', |
70 | 70 | ), |
71 | 71 | ), |
72 | - 'mandatory' => array ( |
|
72 | + 'mandatory' => array( |
|
73 | 73 | 'exclude' => 1, |
74 | 74 | 'label' => 'LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.mandatory', |
75 | - 'config' => array ( |
|
75 | + 'config' => array( |
|
76 | 76 | 'type' => 'check', |
77 | 77 | 'default' => 0, |
78 | 78 | ), |
79 | 79 | ), |
80 | 80 | ), |
81 | - 'types' => array ( |
|
82 | - '0' => array ('showitem' => '--div--;LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.tab1, encoded;;;;1-1-1, xpath;;;;2-2-2, xpath_sorting, mandatory;;;;3-3-3'), |
|
81 | + 'types' => array( |
|
82 | + '0' => array('showitem' => '--div--;LLL:EXT:dlf/locallang.xml:tx_dlf_metadataformat.tab1, encoded;;;;1-1-1, xpath;;;;2-2-2, xpath_sorting, mandatory;;;;3-3-3'), |
|
83 | 83 | ), |
84 | - 'palettes' => array ( |
|
85 | - '1' => array ('showitem' => ''), |
|
84 | + 'palettes' => array( |
|
85 | + '1' => array('showitem' => ''), |
|
86 | 86 | ), |
87 | 87 | ); |