|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU General Public License version 3 or later. |
|
9
|
|
|
* For the full copyright and license information, please read the |
|
10
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Kitodo\Dlf\Hooks; |
|
14
|
|
|
|
|
15
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Helper for Flexform's custom "itemsProcFunc" |
|
19
|
|
|
* |
|
20
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
21
|
|
|
* @package TYPO3 |
|
22
|
|
|
* @subpackage dlf |
|
23
|
|
|
* @access public |
|
24
|
|
|
*/ |
|
25
|
|
|
class ItemsProcFunc |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Helper to get flexform's items array for plugin "Collection" |
|
29
|
|
|
* |
|
30
|
|
|
* @access public |
|
31
|
|
|
* |
|
32
|
|
|
* @param array &$params: An array with parameters |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
|
|
public function collectionList(&$params) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->generateList( |
|
39
|
|
|
$params, |
|
40
|
|
|
'label,uid', |
|
41
|
|
|
'tx_dlf_collections', |
|
42
|
|
|
'label' |
|
43
|
|
|
); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Helper to get flexform's items array for plugin "Search" |
|
48
|
|
|
* |
|
49
|
|
|
* @access public |
|
50
|
|
|
* |
|
51
|
|
|
* @param array &$params: An array with parameters |
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
54
|
|
|
*/ |
|
55
|
|
|
public function extendedSearchList(&$params) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->generateList( |
|
58
|
|
|
$params, |
|
59
|
|
|
'label,index_name', |
|
60
|
|
|
'tx_dlf_metadata', |
|
61
|
|
|
'sorting', |
|
62
|
|
|
'AND index_indexed=1' |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Helper to get flexform's items array for plugin "Search" |
|
68
|
|
|
* |
|
69
|
|
|
* @access public |
|
70
|
|
|
* |
|
71
|
|
|
* @param array &$params: An array with parameters |
|
72
|
|
|
* |
|
73
|
|
|
* @return void |
|
74
|
|
|
*/ |
|
75
|
|
|
public function facetsList(&$params) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->generateList( |
|
78
|
|
|
$params, |
|
79
|
|
|
'label,index_name', |
|
80
|
|
|
'tx_dlf_metadata', |
|
81
|
|
|
'sorting', |
|
82
|
|
|
'AND is_facet=1' |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Get list items from database |
|
88
|
|
|
* |
|
89
|
|
|
* @access protected |
|
90
|
|
|
* |
|
91
|
|
|
* @param array &$params: An array with parameters |
|
92
|
|
|
* @param string $fields: Comma-separated list of fields to fetch |
|
93
|
|
|
* @param string $table: Table name to fetch the items from |
|
94
|
|
|
* @param string $sorting: Field to sort items by (optionally appended by 'ASC' or 'DESC') |
|
95
|
|
|
* @param string $where: Additional WHERE clause |
|
96
|
|
|
* @param bool $localize: Add check for localized records? |
|
97
|
|
|
* |
|
98
|
|
|
* @return void |
|
99
|
|
|
*/ |
|
100
|
|
|
protected function generateList(&$params, $fields, $table, $sorting, $where = '', $localize = true) |
|
101
|
|
|
{ |
|
102
|
|
|
$pages = $params['row']['pages']; |
|
103
|
|
|
if (!empty($pages)) { |
|
104
|
|
|
if (!is_array($pages)) { |
|
105
|
|
|
$pages = [['uid' => $pages]]; |
|
106
|
|
|
} |
|
107
|
|
|
foreach ($pages as $page) { |
|
108
|
|
|
if ($page['uid'] > 0) { |
|
109
|
|
|
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
110
|
|
|
$fields, |
|
111
|
|
|
$table, |
|
112
|
|
|
'(' . $table . '.pid=' . intval($page['uid']) . ' ' . $where . ')' |
|
113
|
|
|
. ($localize ? ' AND (' . $table . '.sys_language_uid IN (-1,0) OR ' . $table . '.l18n_parent=0)' : '') |
|
114
|
|
|
. Helper::whereClause($table), |
|
115
|
|
|
'', |
|
116
|
|
|
$sorting |
|
117
|
|
|
); |
|
118
|
|
|
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
119
|
|
|
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) { |
|
120
|
|
|
$params['items'][] = $resArray; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Helper to get flexform's items array for plugin "OaiPmh" |
|
130
|
|
|
* |
|
131
|
|
|
* @access public |
|
132
|
|
|
* |
|
133
|
|
|
* @param array &$params: An array with parameters |
|
134
|
|
|
* |
|
135
|
|
|
* @return void |
|
136
|
|
|
*/ |
|
137
|
|
|
public function libraryList(&$params) |
|
138
|
|
|
{ |
|
139
|
|
|
$this->generateList( |
|
140
|
|
|
$params, |
|
141
|
|
|
'label,uid', |
|
142
|
|
|
'tx_dlf_libraries', |
|
143
|
|
|
'label' |
|
144
|
|
|
); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* Helper to get flexform's items array for plugin "Search" |
|
149
|
|
|
* |
|
150
|
|
|
* @access public |
|
151
|
|
|
* |
|
152
|
|
|
* @param array &$params: An array with parameters |
|
153
|
|
|
* |
|
154
|
|
|
* @return void |
|
155
|
|
|
*/ |
|
156
|
|
|
public function solrList(&$params) |
|
157
|
|
|
{ |
|
158
|
|
|
$this->generateList( |
|
159
|
|
|
$params, |
|
160
|
|
|
'label,uid', |
|
161
|
|
|
'tx_dlf_solrcores', |
|
162
|
|
|
'label', |
|
163
|
|
|
'OR pid=0', |
|
164
|
|
|
false |
|
165
|
|
|
); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Helper to get flexform's items array for plugin "Toolbox" |
|
170
|
|
|
* |
|
171
|
|
|
* @access public |
|
172
|
|
|
* |
|
173
|
|
|
* @param array &$params: An array with parameters |
|
174
|
|
|
* |
|
175
|
|
|
* @return void |
|
176
|
|
|
*/ |
|
177
|
|
|
public function toolList(&$params) |
|
178
|
|
|
{ |
|
179
|
|
|
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] as $class => $label) { |
|
180
|
|
|
$params['items'][] = [$GLOBALS['LANG']->sL($label), $class]; |
|
181
|
|
|
} |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
|