|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU General Public License version 3 or later. |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Plugin 'DLF: List View' for the 'dlf' extension. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
16
|
|
|
* @author Henrik Lochmann <[email protected]> |
|
17
|
|
|
* @package TYPO3 |
|
18
|
|
|
* @subpackage tx_dlf |
|
19
|
|
|
* @access public |
|
20
|
|
|
*/ |
|
21
|
|
|
class tx_dlf_listview extends tx_dlf_plugin { |
|
22
|
|
|
|
|
23
|
|
|
public $scriptRelPath = 'plugins/listview/class.tx_dlf_listview.php'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* This holds the field wrap of the metadata |
|
27
|
|
|
* |
|
28
|
|
|
* @var array |
|
29
|
|
|
* @access private |
|
30
|
|
|
*/ |
|
31
|
|
|
private $fieldwrap = array (); |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* This holds the list |
|
35
|
|
|
* |
|
36
|
|
|
* @var tx_dlf_list |
|
37
|
|
|
* @access protected |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $list; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Array of sorted metadata |
|
43
|
|
|
* |
|
44
|
|
|
* @var array |
|
45
|
|
|
* @access protected |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $metadata = array (); |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Array of sortable metadata |
|
51
|
|
|
* |
|
52
|
|
|
* @var array |
|
53
|
|
|
* @access protected |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $sortables = array (); |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Renders the page browser |
|
59
|
|
|
* |
|
60
|
|
|
* @access protected |
|
61
|
|
|
* |
|
62
|
|
|
* @return string The rendered page browser ready for output |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function getPageBrowser() { |
|
65
|
|
|
|
|
66
|
|
|
// Get overall number of pages. |
|
67
|
|
|
$maxPages = intval(ceil(count($this->list) / $this->conf['limit'])); |
|
68
|
|
|
|
|
69
|
|
|
// Return empty pagebrowser if there is just one page. |
|
70
|
|
|
if ($maxPages < 2) { |
|
71
|
|
|
|
|
72
|
|
|
return ''; |
|
73
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
// Get separator. |
|
77
|
|
|
$separator = $this->pi_getLL('separator', ' - ', TRUE); |
|
78
|
|
|
|
|
79
|
|
|
// Add link to previous page. |
|
80
|
|
|
if ($this->piVars['pointer'] > 0) { |
|
81
|
|
|
|
|
82
|
|
|
$output = $this->pi_linkTP_keepPIvars($this->pi_getLL('prevPage', '<', TRUE), array ('pointer' => $this->piVars['pointer'] - 1), TRUE).$separator; |
|
83
|
|
|
|
|
84
|
|
|
} else { |
|
85
|
|
|
|
|
86
|
|
|
$output = $this->pi_getLL('prevPage', '<', TRUE).$separator; |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
$i = 0; |
|
91
|
|
|
|
|
92
|
|
|
$skip = NULL; |
|
93
|
|
|
|
|
94
|
|
|
// Add links to pages. |
|
95
|
|
|
while ($i < $maxPages) { |
|
96
|
|
|
|
|
97
|
|
|
if ($i < 3 || ($i > $this->piVars['pointer'] - 3 && $i < $this->piVars['pointer'] + 3) || $i > $maxPages - 4) { |
|
98
|
|
|
|
|
99
|
|
|
if ($this->piVars['pointer'] != $i) { |
|
100
|
|
|
|
|
101
|
|
|
$output .= $this->pi_linkTP_keepPIvars(sprintf($this->pi_getLL('page', '%d', TRUE), $i + 1), array ('pointer' => $i), TRUE).$separator; |
|
102
|
|
|
|
|
103
|
|
|
} else { |
|
104
|
|
|
|
|
105
|
|
|
$output .= sprintf($this->pi_getLL('page', '%d', TRUE), $i + 1).$separator; |
|
106
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
$skip = TRUE; |
|
110
|
|
|
|
|
111
|
|
|
} elseif ($skip === TRUE) { |
|
112
|
|
|
|
|
113
|
|
|
$output .= $this->pi_getLL('skip', '...', TRUE).$separator; |
|
114
|
|
|
|
|
115
|
|
|
$skip = FALSE; |
|
116
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
$i++; |
|
120
|
|
|
|
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
// Add link to next page. |
|
124
|
|
|
if ($this->piVars['pointer'] < $maxPages - 1) { |
|
125
|
|
|
|
|
126
|
|
|
$output .= $this->pi_linkTP_keepPIvars($this->pi_getLL('nextPage', '>', TRUE), array ('pointer' => $this->piVars['pointer'] + 1), TRUE); |
|
127
|
|
|
|
|
128
|
|
|
} else { |
|
129
|
|
|
|
|
130
|
|
|
$output .= $this->pi_getLL('nextPage', '>', TRUE); |
|
131
|
|
|
|
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
return $output; |
|
135
|
|
|
|
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Renders one entry of the list |
|
140
|
|
|
* |
|
141
|
|
|
* @access protected |
|
142
|
|
|
* |
|
143
|
|
|
* @param integer $number: The number of the entry |
|
144
|
|
|
* @param string $template: Parsed template subpart |
|
145
|
|
|
* |
|
146
|
|
|
* @return string The rendered entry ready for output |
|
147
|
|
|
*/ |
|
148
|
|
|
protected function getEntry($number, $template) { |
|
149
|
|
|
|
|
150
|
|
|
$markerArray['###NUMBER###'] = $number + 1; |
|
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
$markerArray['###METADATA###'] = ''; |
|
153
|
|
|
|
|
154
|
|
|
$markerArray['###THUMBNAIL###'] = ''; |
|
155
|
|
|
|
|
156
|
|
|
$markerArray['###PREVIEW###'] = ''; |
|
157
|
|
|
|
|
158
|
|
|
$subpart = ''; |
|
159
|
|
|
|
|
160
|
|
|
$imgAlt = ''; |
|
161
|
|
|
|
|
162
|
|
|
$noTitle = $this->pi_getLL('noTitle'); |
|
163
|
|
|
|
|
164
|
|
|
$metadata = $this->list[$number]['metadata']; |
|
165
|
|
|
|
|
166
|
|
|
foreach ($this->metadata as $index_name => $metaConf) { |
|
167
|
|
|
|
|
168
|
|
|
$parsedValue = ''; |
|
169
|
|
|
|
|
170
|
|
|
$fieldwrap = $this->getFieldWrap($index_name, $metaConf['wrap']); |
|
171
|
|
|
|
|
172
|
|
|
do { |
|
173
|
|
|
|
|
174
|
|
|
$value = @array_shift($metadata[$index_name]); |
|
175
|
|
|
|
|
176
|
|
|
// Link title to pageview. |
|
177
|
|
|
if ($index_name == 'title') { |
|
178
|
|
|
|
|
179
|
|
|
// Get title of parent document if needed. |
|
180
|
|
|
if (empty($value) && $this->conf['getTitle']) { |
|
181
|
|
|
|
|
182
|
|
|
$superiorTitle = tx_dlf_document::getTitle($this->list[$number]['uid'], TRUE); |
|
183
|
|
|
|
|
184
|
|
|
if (!empty($superiorTitle)) { |
|
185
|
|
|
|
|
186
|
|
|
$value = '['.$superiorTitle.']'; |
|
187
|
|
|
|
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
// Set fake title if still not present. |
|
193
|
|
|
if (empty($value)) { |
|
194
|
|
|
|
|
195
|
|
|
$value = $noTitle; |
|
196
|
|
|
|
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
$imgAlt = htmlspecialchars($value); |
|
200
|
|
|
|
|
201
|
|
|
$additionalParams = array ( |
|
202
|
|
|
'id' => $this->list[$number]['uid'], |
|
203
|
|
|
'page' => $this->list[$number]['page'] |
|
204
|
|
|
); |
|
205
|
|
|
|
|
206
|
|
|
if (!empty($this->piVars['logicalPage'])) { |
|
207
|
|
|
|
|
208
|
|
|
$additionalParams['logicalPage'] = $this->piVars['logicalPage']; |
|
209
|
|
|
|
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
$conf = array ( |
|
213
|
|
|
'useCacheHash' => 1, |
|
214
|
|
|
'parameter' => $this->conf['targetPid'], |
|
215
|
|
|
'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE) |
|
216
|
|
|
); |
|
217
|
|
|
|
|
218
|
|
|
$value = $this->cObj->typoLink(htmlspecialchars($value), $conf); |
|
219
|
|
|
|
|
220
|
|
|
// Translate name of holding library. |
|
221
|
|
|
} elseif ($index_name == 'owner' && !empty($value)) { |
|
222
|
|
|
|
|
223
|
|
|
$value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_libraries', $this->conf['pages'])); |
|
224
|
|
|
|
|
225
|
|
|
// Translate document type. |
|
226
|
|
|
} elseif ($index_name == 'type' && !empty($value)) { |
|
227
|
|
|
|
|
228
|
|
|
$value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_structures', $this->conf['pages'])); |
|
229
|
|
|
|
|
230
|
|
|
// Translate ISO 639 language code. |
|
231
|
|
|
} elseif ($index_name == 'language' && !empty($value)) { |
|
232
|
|
|
|
|
233
|
|
|
$value = htmlspecialchars(tx_dlf_helper::getLanguageName($value)); |
|
234
|
|
|
|
|
235
|
|
|
} elseif (!empty($value)) { |
|
236
|
|
|
|
|
237
|
|
|
$value = htmlspecialchars($value); |
|
238
|
|
|
|
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
$value = $this->cObj->stdWrap($value, $fieldwrap['value.']); |
|
242
|
|
|
|
|
243
|
|
|
if (!empty($value)) { |
|
244
|
|
|
|
|
245
|
|
|
$parsedValue .= $value; |
|
246
|
|
|
|
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
} while (count($metadata[$index_name])); |
|
250
|
|
|
|
|
251
|
|
|
if (!empty($parsedValue)) { |
|
252
|
|
|
|
|
253
|
|
|
$field = $this->cObj->stdWrap(htmlspecialchars($metaConf['label']), $fieldwrap['key.']); |
|
254
|
|
|
|
|
255
|
|
|
$field .= $parsedValue; |
|
256
|
|
|
|
|
257
|
|
|
$markerArray['###METADATA###'] .= $this->cObj->stdWrap($field, $fieldwrap['all.']); |
|
258
|
|
|
|
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
// Add thumbnail. |
|
264
|
|
|
if (!empty($this->list[$number]['thumbnail'])) { |
|
265
|
|
|
|
|
266
|
|
|
$markerArray['###THUMBNAIL###'] = '<img alt="'.$imgAlt.'" src="'.$this->list[$number]['thumbnail'].'" />'; |
|
267
|
|
|
|
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
// Add preview. |
|
271
|
|
|
if (!empty($this->list[$number]['preview'])) { |
|
272
|
|
|
|
|
273
|
|
|
$markerArray['###PREVIEW###'] = $this->list[$number]['preview']; |
|
274
|
|
|
|
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
if (!empty($this->list[$number]['subparts'])) { |
|
278
|
|
|
|
|
279
|
|
|
$subpart = $this->getSubEntries($number, $template); |
|
280
|
|
|
|
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
// basket button |
|
284
|
|
|
$markerArray['###BASKETBUTTON###'] = ''; |
|
285
|
|
|
|
|
286
|
|
|
if (!empty($this->conf['basketButton']) && !empty($this->conf['targetBasket'])) { |
|
287
|
|
|
|
|
288
|
|
|
$additionalParams = array ('id' => $this->list[$number]['uid'], 'startpage' => $this->list[$number]['page'], 'addToBasket' => 'list'); |
|
289
|
|
|
|
|
290
|
|
|
$conf = array ( |
|
291
|
|
|
'useCacheHash' => 1, |
|
292
|
|
|
'parameter' => $this->conf['targetBasket'], |
|
293
|
|
|
'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE) |
|
294
|
|
|
); |
|
295
|
|
|
|
|
296
|
|
|
$link = $this->cObj->typoLink($this->pi_getLL('addBasket', '', TRUE), $conf); |
|
297
|
|
|
|
|
298
|
|
|
$markerArray['###BASKETBUTTON###'] = $link; |
|
299
|
|
|
|
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
return $this->cObj->substituteMarkerArray($this->cObj->substituteSubpart($template['entry'], '###SUBTEMPLATE###', $subpart, TRUE), $markerArray); |
|
303
|
|
|
|
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
/** |
|
307
|
|
|
* Returns the parsed fieldwrap of a metadata |
|
308
|
|
|
* |
|
309
|
|
|
* @access private |
|
310
|
|
|
* |
|
311
|
|
|
* @param string $index_name: The index name of a metadata |
|
312
|
|
|
* @param string $wrap: The configured metadata wrap |
|
313
|
|
|
* |
|
314
|
|
|
* @return array The parsed fieldwrap |
|
315
|
|
|
*/ |
|
316
|
|
|
private function getFieldWrap($index_name, $wrap) { |
|
317
|
|
|
|
|
318
|
|
|
if (isset($this->fieldwrap[$index_name])) { |
|
319
|
|
|
|
|
320
|
|
|
return $this->fieldwrap[$index_name]; |
|
321
|
|
|
|
|
322
|
|
|
} else { |
|
323
|
|
|
|
|
324
|
|
|
return $this->fieldwrap[$index_name] = $this->parseTS($wrap); |
|
325
|
|
|
|
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* Renders sorting dialog |
|
332
|
|
|
* |
|
333
|
|
|
* @access protected |
|
334
|
|
|
* |
|
335
|
|
|
* @return string The rendered sorting dialog ready for output |
|
336
|
|
|
*/ |
|
337
|
|
|
protected function getSortingForm() { |
|
338
|
|
|
|
|
339
|
|
|
// Return nothing if there are no sortable metadata fields. |
|
340
|
|
|
if (!count($this->sortables)) { |
|
341
|
|
|
|
|
342
|
|
|
return ''; |
|
343
|
|
|
|
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
// Set class prefix. |
|
347
|
|
|
$prefix = str_replace('_', '-', get_class($this)); |
|
348
|
|
|
|
|
349
|
|
|
// Configure @action URL for form. |
|
350
|
|
|
$linkConf = array ( |
|
351
|
|
|
'parameter' => $GLOBALS['TSFE']->id, |
|
352
|
|
|
'forceAbsoluteUrl' => 1 |
|
353
|
|
|
); |
|
354
|
|
|
|
|
355
|
|
|
if (!empty($this->piVars['logicalPage'])) { |
|
356
|
|
|
|
|
357
|
|
|
$linkConf['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, array ('logicalPage' => $this->piVars['logicalPage']), '', TRUE, FALSE); |
|
358
|
|
|
|
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
// Build HTML form. |
|
362
|
|
|
$sorting = '<form action="'.$this->cObj->typoLink_URL($linkConf).'" method="get"><div><input type="hidden" name="id" value="'.$GLOBALS['TSFE']->id.'" />'; |
|
363
|
|
|
|
|
364
|
|
|
foreach ($this->piVars as $piVar => $value) { |
|
365
|
|
|
|
|
366
|
|
|
if ($piVar != 'order' && $piVar != 'DATA' && !empty($value)) { |
|
367
|
|
|
|
|
368
|
|
|
$sorting .= '<input type="hidden" name="'.$this->prefixId.'['.$piVar.']" value="'.$value.'" />'; |
|
369
|
|
|
|
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
// Select sort field. |
|
375
|
|
|
$uniqId = uniqid($prefix.'-'); |
|
376
|
|
|
|
|
377
|
|
|
$sorting .= '<label for="'.$uniqId.'">'.$this->pi_getLL('orderBy', '', TRUE).'</label><select id="'.$uniqId.'" name="'.$this->prefixId.'[order]" onchange="javascript:this.form.submit();">'; |
|
378
|
|
|
|
|
379
|
|
|
// Add relevance sorting if this is a search result list. |
|
380
|
|
|
if ($this->list->metadata['options']['source'] == 'search') { |
|
|
|
|
|
|
381
|
|
|
|
|
382
|
|
|
$sorting .= '<option value="relevance"'.(($this->list->metadata['options']['order'] == 'relevance') ? ' selected="selected"' : '').'>'.$this->pi_getLL('relevance', '', TRUE).'</option>'; |
|
383
|
|
|
|
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
foreach ($this->sortables as $index_name => $label) { |
|
387
|
|
|
|
|
388
|
|
|
$sorting .= '<option value="'.$index_name.'"'.(($this->list->metadata['options']['order'] == $index_name) ? ' selected="selected"' : '').'>'.htmlspecialchars($label).'</option>'; |
|
389
|
|
|
|
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
$sorting .= '</select>'; |
|
393
|
|
|
|
|
394
|
|
|
// Select sort direction. |
|
395
|
|
|
$uniqId = uniqid($prefix.'-'); |
|
396
|
|
|
|
|
397
|
|
|
$sorting .= '<label for="'.$uniqId.'">'.$this->pi_getLL('direction', '', TRUE).'</label><select id="'.$uniqId.'" name="'.$this->prefixId.'[asc]" onchange="javascript:this.form.submit();">'; |
|
398
|
|
|
|
|
399
|
|
|
$sorting .= '<option value="1" '.($this->list->metadata['options']['order.asc'] ? ' selected="selected"' : '').'>'.$this->pi_getLL('direction.asc', '', TRUE).'</option>'; |
|
400
|
|
|
|
|
401
|
|
|
$sorting .= '<option value="0" '.(!$this->list->metadata['options']['order.asc'] ? ' selected="selected"' : '').'>'.$this->pi_getLL('direction.desc', '', TRUE).'</option>'; |
|
402
|
|
|
|
|
403
|
|
|
$sorting .= '</select></div></form>'; |
|
404
|
|
|
|
|
405
|
|
|
return $sorting; |
|
406
|
|
|
|
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
/** |
|
410
|
|
|
* Renders all sub-entries of one entry |
|
411
|
|
|
* |
|
412
|
|
|
* @access protected |
|
413
|
|
|
* |
|
414
|
|
|
* @param integer $number: The number of the entry |
|
415
|
|
|
* @param string $template: Parsed template subpart |
|
416
|
|
|
* |
|
417
|
|
|
* @return string The rendered entries ready for output |
|
418
|
|
|
*/ |
|
419
|
|
|
protected function getSubEntries($number, $template) { |
|
420
|
|
|
|
|
421
|
|
|
$content = ''; |
|
422
|
|
|
|
|
423
|
|
|
$noTitle = $this->pi_getLL('noTitle'); |
|
424
|
|
|
|
|
425
|
|
|
$highlight_word = preg_replace('/\s\s+/', ';', $this->list->metadata['searchString']); |
|
|
|
|
|
|
426
|
|
|
|
|
427
|
|
|
foreach ($this->list[$number]['subparts'] as $subpart) { |
|
428
|
|
|
|
|
429
|
|
|
$markerArray['###SUBMETADATA###'] = ''; |
|
430
|
|
|
|
|
431
|
|
|
$markerArray['###SUBTHUMBNAIL###'] = ''; |
|
432
|
|
|
|
|
433
|
|
|
$markerArray['###SUBPREVIEW###'] = ''; |
|
434
|
|
|
|
|
435
|
|
|
$imgAlt = ''; |
|
436
|
|
|
|
|
437
|
|
|
foreach ($this->metadata as $index_name => $metaConf) { |
|
438
|
|
|
|
|
439
|
|
|
$parsedValue = ''; |
|
440
|
|
|
|
|
441
|
|
|
$fieldwrap = $this->getFieldWrap($index_name, $metaConf['wrap']); |
|
442
|
|
|
|
|
443
|
|
|
do { |
|
444
|
|
|
|
|
445
|
|
|
$value = @array_shift($subpart['metadata'][$index_name]); |
|
446
|
|
|
|
|
447
|
|
|
// Link title to pageview. |
|
448
|
|
|
if ($index_name == 'title') { |
|
449
|
|
|
|
|
450
|
|
|
// Get title of parent document if needed. |
|
451
|
|
|
if (empty($value) && $this->conf['getTitle']) { |
|
452
|
|
|
|
|
453
|
|
|
$superiorTitle = tx_dlf_document::getTitle($subpart['uid'], TRUE); |
|
454
|
|
|
|
|
455
|
|
|
if (!empty($superiorTitle)) { |
|
456
|
|
|
|
|
457
|
|
|
$value = '['.$superiorTitle.']'; |
|
458
|
|
|
|
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
// Set fake title if still not present. |
|
464
|
|
|
if (empty($value)) { |
|
465
|
|
|
|
|
466
|
|
|
$value = $noTitle; |
|
467
|
|
|
|
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
$imgAlt = htmlspecialchars($value); |
|
471
|
|
|
|
|
472
|
|
|
$additionalParams = array ( |
|
473
|
|
|
'id' => $subpart['uid'], |
|
474
|
|
|
'page' => $subpart['page'], |
|
475
|
|
|
'highlight_word' => $highlight_word |
|
476
|
|
|
); |
|
477
|
|
|
|
|
478
|
|
|
if (!empty($this->piVars['logicalPage'])) { |
|
479
|
|
|
|
|
480
|
|
|
$additionalParams['logicalPage'] = $this->piVars['logicalPage']; |
|
481
|
|
|
|
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
$conf = array ( |
|
485
|
|
|
// we don't want cHash in case of search parameters |
|
486
|
|
|
'useCacheHash' => empty($this->list->metadata['searchString']) ? 1 : 0, |
|
487
|
|
|
'parameter' => $this->conf['targetPid'], |
|
488
|
|
|
'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE) |
|
489
|
|
|
); |
|
490
|
|
|
|
|
491
|
|
|
$value = $this->cObj->typoLink(htmlspecialchars($value), $conf); |
|
492
|
|
|
|
|
493
|
|
|
// Translate name of holding library. |
|
494
|
|
|
} elseif ($index_name == 'owner' && !empty($value)) { |
|
495
|
|
|
|
|
496
|
|
|
$value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_libraries', $this->conf['pages'])); |
|
497
|
|
|
|
|
498
|
|
|
// Translate document type. |
|
499
|
|
|
} elseif ($index_name == 'type' && !empty($value)) { |
|
500
|
|
|
|
|
501
|
|
|
$_value = $value; |
|
502
|
|
|
|
|
503
|
|
|
$value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_structures', $this->conf['pages'])); |
|
504
|
|
|
|
|
505
|
|
|
// Add page number for single pages. |
|
506
|
|
|
if ($_value == 'page') { |
|
507
|
|
|
|
|
508
|
|
|
$value .= ' '.intval($subpart['page']); |
|
509
|
|
|
|
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
// Translate ISO 639 language code. |
|
513
|
|
|
} elseif ($index_name == 'language' && !empty($value)) { |
|
514
|
|
|
|
|
515
|
|
|
$value = htmlspecialchars(tx_dlf_helper::getLanguageName($value)); |
|
516
|
|
|
|
|
517
|
|
|
} elseif (!empty($value)) { |
|
518
|
|
|
|
|
519
|
|
|
$value = htmlspecialchars($value); |
|
520
|
|
|
|
|
521
|
|
|
} |
|
522
|
|
|
|
|
523
|
|
|
$value = $this->cObj->stdWrap($value, $fieldwrap['value.']); |
|
524
|
|
|
|
|
525
|
|
|
if (!empty($value)) { |
|
526
|
|
|
|
|
527
|
|
|
$parsedValue .= $value; |
|
528
|
|
|
|
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
} while (count($subpart['metadata'][$index_name])); |
|
532
|
|
|
|
|
533
|
|
|
if (!empty($parsedValue)) { |
|
534
|
|
|
|
|
535
|
|
|
$field = $this->cObj->stdWrap(htmlspecialchars($metaConf['label']), $fieldwrap['key.']); |
|
536
|
|
|
|
|
537
|
|
|
$field .= $parsedValue; |
|
538
|
|
|
|
|
539
|
|
|
$markerArray['###SUBMETADATA###'] .= $this->cObj->stdWrap($field, $fieldwrap['all.']); |
|
540
|
|
|
|
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
} |
|
544
|
|
|
|
|
545
|
|
|
// Add thumbnail. |
|
546
|
|
|
if (!empty($subpart['thumbnail'])) { |
|
547
|
|
|
|
|
548
|
|
|
$markerArray['###SUBTHUMBNAIL###'] = '<img alt="'.$imgAlt.'" src="'.$subpart['thumbnail'].'" />'; |
|
549
|
|
|
|
|
550
|
|
|
} |
|
551
|
|
|
|
|
552
|
|
|
// Add preview. |
|
553
|
|
|
if (!empty($subpart['preview'])) { |
|
554
|
|
|
|
|
555
|
|
|
$markerArray['###SUBPREVIEW###'] = $subpart['preview']; |
|
556
|
|
|
|
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
|
|
// basket button |
|
560
|
|
|
$markerArray['###SUBBASKETBUTTON###'] = ''; |
|
561
|
|
|
|
|
562
|
|
|
if (!empty($this->conf['basketButton']) && !empty($this->conf['targetBasket'])) { |
|
563
|
|
|
|
|
564
|
|
|
$additionalParams = array ('id' => $this->list[$number]['uid'], 'startpage' => $subpart['page'], 'endpage' => $subpart['page'], 'logId' => $subpart['sid'], 'addToBasket' => 'subentry'); |
|
565
|
|
|
|
|
566
|
|
|
$conf = array ( |
|
567
|
|
|
'useCacheHash' => 1, |
|
568
|
|
|
'parameter' => $this->conf['targetBasket'], |
|
569
|
|
|
'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE) |
|
570
|
|
|
); |
|
571
|
|
|
|
|
572
|
|
|
$link = $this->cObj->typoLink($this->pi_getLL('addBasket', '', TRUE), $conf); |
|
573
|
|
|
|
|
574
|
|
|
$markerArray['###SUBBASKETBUTTON###'] = $link; |
|
575
|
|
|
|
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
$content .= $this->cObj->substituteMarkerArray($template['subentry'], $markerArray); |
|
579
|
|
|
|
|
580
|
|
|
} |
|
581
|
|
|
|
|
582
|
|
|
return $this->cObj->substituteSubpart($this->cObj->getSubpart($this->template, '###SUBTEMPLATE###'), '###SUBENTRY###', $content, TRUE); |
|
583
|
|
|
|
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
/** |
|
587
|
|
|
* Get metadata configuration from database |
|
588
|
|
|
* |
|
589
|
|
|
* @access protected |
|
590
|
|
|
* |
|
591
|
|
|
* @return void |
|
592
|
|
|
*/ |
|
593
|
|
|
protected function loadConfig() { |
|
594
|
|
|
|
|
595
|
|
|
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
596
|
|
|
'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', |
|
597
|
|
|
'tx_dlf_metadata', |
|
598
|
|
|
'(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'), |
|
599
|
|
|
'', |
|
600
|
|
|
'tx_dlf_metadata.sorting ASC', |
|
601
|
|
|
'' |
|
602
|
|
|
); |
|
603
|
|
|
|
|
604
|
|
|
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
605
|
|
|
|
|
606
|
|
|
if ($resArray['is_listed']) { |
|
607
|
|
|
|
|
608
|
|
|
$this->metadata[$resArray['index_name']] = array ( |
|
609
|
|
|
'wrap' => $resArray['wrap'], |
|
610
|
|
|
'label' => tx_dlf_helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->conf['pages']) |
|
611
|
|
|
); |
|
612
|
|
|
|
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
if ($resArray['is_sortable']) { |
|
616
|
|
|
|
|
617
|
|
|
$this->sortables[$resArray['index_name']] = tx_dlf_helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->conf['pages']); |
|
618
|
|
|
|
|
619
|
|
|
} |
|
620
|
|
|
|
|
621
|
|
|
} |
|
622
|
|
|
|
|
623
|
|
|
} |
|
624
|
|
|
|
|
625
|
|
|
/** |
|
626
|
|
|
* The main method of the PlugIn |
|
627
|
|
|
* |
|
628
|
|
|
* @access public |
|
629
|
|
|
* |
|
630
|
|
|
* @param string $content: The PlugIn content |
|
631
|
|
|
* @param array $conf: The PlugIn configuration |
|
632
|
|
|
* |
|
633
|
|
|
* @return string The content that is displayed on the website |
|
634
|
|
|
*/ |
|
635
|
|
|
public function main($content, $conf) { |
|
636
|
|
|
|
|
637
|
|
|
$this->init($conf); |
|
638
|
|
|
|
|
639
|
|
|
// Don't cache the output. |
|
640
|
|
|
$this->setCache(FALSE); |
|
641
|
|
|
|
|
642
|
|
|
// Load the list. |
|
643
|
|
|
$this->list = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_dlf_list'); |
|
644
|
|
|
|
|
645
|
|
|
// Sort the list if applicable. |
|
646
|
|
|
if ((!empty($this->piVars['order']) && $this->piVars['order'] != $this->list->metadata['options']['order']) |
|
647
|
|
|
|| (isset($this->piVars['asc']) && $this->piVars['asc'] != $this->list->metadata['options']['order.asc'])) { |
|
648
|
|
|
|
|
649
|
|
|
// Order list by given field. |
|
650
|
|
|
$this->list->sort($this->piVars['order'], (boolean) $this->piVars['asc']); |
|
651
|
|
|
|
|
652
|
|
|
// Update list's metadata. |
|
653
|
|
|
$listMetadata = $this->list->metadata; |
|
654
|
|
|
|
|
655
|
|
|
$listMetadata['options']['order'] = $this->piVars['order']; |
|
656
|
|
|
|
|
657
|
|
|
$listMetadata['options']['order.asc'] = (boolean) $this->piVars['asc']; |
|
658
|
|
|
|
|
659
|
|
|
$this->list->metadata = $listMetadata; |
|
660
|
|
|
|
|
661
|
|
|
// Save updated list. |
|
662
|
|
|
$this->list->save(); |
|
663
|
|
|
|
|
664
|
|
|
// Reset pointer. |
|
665
|
|
|
$this->piVars['pointer'] = 0; |
|
666
|
|
|
|
|
667
|
|
|
} |
|
668
|
|
|
|
|
669
|
|
|
// Load template file. |
|
670
|
|
|
if (!empty($this->conf['templateFile'])) { |
|
671
|
|
|
|
|
672
|
|
|
$this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###'); |
|
673
|
|
|
|
|
674
|
|
|
} else { |
|
675
|
|
|
|
|
676
|
|
|
$this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/listview/template.tmpl'), '###TEMPLATE###'); |
|
677
|
|
|
|
|
678
|
|
|
} |
|
679
|
|
|
|
|
680
|
|
|
$subpartArray['entry'] = $this->cObj->getSubpart($this->template, '###ENTRY###'); |
|
|
|
|
|
|
681
|
|
|
|
|
682
|
|
|
$subpartArray['subentry'] = $this->cObj->getSubpart($this->template, '###SUBENTRY###'); |
|
683
|
|
|
|
|
684
|
|
|
// Set some variable defaults. |
|
685
|
|
|
if (!empty($this->piVars['pointer']) && (($this->piVars['pointer'] * $this->conf['limit']) + 1) <= count($this->list)) { |
|
686
|
|
|
|
|
687
|
|
|
$this->piVars['pointer'] = max(intval($this->piVars['pointer']), 0); |
|
688
|
|
|
|
|
689
|
|
|
} else { |
|
690
|
|
|
|
|
691
|
|
|
$this->piVars['pointer'] = 0; |
|
692
|
|
|
|
|
693
|
|
|
} |
|
694
|
|
|
|
|
695
|
|
|
// Load metadata configuration. |
|
696
|
|
|
$this->loadConfig(); |
|
697
|
|
|
|
|
698
|
|
|
$currentEntry = $this->piVars['pointer'] * $this->conf['limit']; |
|
699
|
|
|
$lastEntry = ($this->piVars['pointer'] + 1) * $this->conf['limit']; |
|
700
|
|
|
|
|
701
|
|
|
for ($currentEntry, $lastEntry; $currentEntry < $lastEntry; $currentEntry++) { |
|
702
|
|
|
|
|
703
|
|
|
if (empty($this->list[$currentEntry])) { |
|
704
|
|
|
|
|
705
|
|
|
break; |
|
706
|
|
|
|
|
707
|
|
|
} else { |
|
708
|
|
|
|
|
709
|
|
|
$content .= $this->getEntry($currentEntry, $subpartArray); |
|
710
|
|
|
|
|
711
|
|
|
} |
|
712
|
|
|
|
|
713
|
|
|
} |
|
714
|
|
|
|
|
715
|
|
|
$markerArray['###LISTTITLE###'] = $this->list->metadata['label']; |
|
|
|
|
|
|
716
|
|
|
|
|
717
|
|
|
$markerArray['###LISTDESCRIPTION###'] = $this->list->metadata['description']; |
|
718
|
|
|
|
|
719
|
|
|
if (!empty($this->list->metadata['thumbnail'])) { |
|
720
|
|
|
|
|
721
|
|
|
$markerArray['###LISTTHUMBNAIL###'] = '<img alt="" src="'.$this->list->metadata['thumbnail'].'" />'; |
|
722
|
|
|
|
|
723
|
|
|
} else { |
|
724
|
|
|
|
|
725
|
|
|
$markerArray['###LISTTHUMBNAIL###'] = ''; |
|
726
|
|
|
|
|
727
|
|
|
} |
|
728
|
|
|
|
|
729
|
|
|
if ($currentEntry) { |
|
730
|
|
|
|
|
731
|
|
|
$markerArray['###COUNT###'] = htmlspecialchars(sprintf($this->pi_getLL('count'), ($this->piVars['pointer'] * $this->conf['limit']) + 1, $currentEntry, count($this->list))); |
|
732
|
|
|
|
|
733
|
|
|
} else { |
|
734
|
|
|
|
|
735
|
|
|
$markerArray['###COUNT###'] = $this->pi_getLL('nohits', '', TRUE); |
|
736
|
|
|
|
|
737
|
|
|
} |
|
738
|
|
|
|
|
739
|
|
|
$markerArray['###PAGEBROWSER###'] = $this->getPageBrowser(); |
|
740
|
|
|
|
|
741
|
|
|
$markerArray['###SORTING###'] = $this->getSortingForm(); |
|
742
|
|
|
|
|
743
|
|
|
$content = $this->cObj->substituteMarkerArray($this->cObj->substituteSubpart($this->template, '###ENTRY###', $content, TRUE), $markerArray); |
|
744
|
|
|
|
|
745
|
|
|
return $this->pi_wrapInBaseClass($content); |
|
746
|
|
|
|
|
747
|
|
|
} |
|
748
|
|
|
|
|
749
|
|
|
} |
|
750
|
|
|
|