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