|
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
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
|
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
18
|
|
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; |
|
19
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Helper for Flexform's custom "itemsProcFunc" |
|
23
|
|
|
* |
|
24
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
25
|
|
|
* @package TYPO3 |
|
26
|
|
|
* @subpackage dlf |
|
27
|
|
|
* @access public |
|
28
|
|
|
*/ |
|
29
|
|
|
class ItemsProcFunc |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @var int |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $storagePid; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Helper to get flexform's items array for plugin "Toolbox" |
|
38
|
|
|
* |
|
39
|
|
|
* @access public |
|
40
|
|
|
* |
|
41
|
|
|
* @param array &$params: An array with parameters |
|
42
|
|
|
* |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function toolList(&$params) |
|
46
|
|
|
{ |
|
47
|
|
|
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] as $class => $label) { |
|
48
|
|
|
$params['items'][] = [Helper::getLanguageService()->getLL($label), $class]; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* The constructor to access TypoScript configuration |
|
54
|
|
|
* |
|
55
|
|
|
* @access public |
|
56
|
|
|
* |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
|
|
public function __construct() |
|
60
|
|
|
{ |
|
61
|
|
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
62
|
|
|
$configurationManager = $objectManager->get(ConfigurationManager::class); |
|
63
|
|
|
// we must get the storagePid from full TypoScript setup at this point. |
|
64
|
|
|
$fullTyposcriptSetup = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); |
|
65
|
|
|
$this->storagePid = $fullTyposcriptSetup["plugin."]["tx_dlf."]["persistence."]["storagePid"]; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Helper to get flexform's items array for plugin "Search" |
|
70
|
|
|
* |
|
71
|
|
|
* @access public |
|
72
|
|
|
* |
|
73
|
|
|
* @param array &$params: An array with parameters |
|
74
|
|
|
* |
|
75
|
|
|
* @return void |
|
76
|
|
|
*/ |
|
77
|
|
|
public function extendedSearchList(&$params) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->generateList( |
|
80
|
|
|
$params, |
|
81
|
|
|
'label,index_name', |
|
82
|
|
|
'tx_dlf_metadata', |
|
83
|
|
|
'label', |
|
84
|
|
|
'index_indexed=1' |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Helper to get flexform's items array for plugin "Search" |
|
90
|
|
|
* |
|
91
|
|
|
* @access public |
|
92
|
|
|
* |
|
93
|
|
|
* @param array &$params: An array with parameters |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getFacetsList(array &$params): void |
|
96
|
|
|
{ |
|
97
|
|
|
$this->generateList( |
|
98
|
|
|
$params, |
|
99
|
|
|
'label,index_name', |
|
100
|
|
|
'tx_dlf_metadata', |
|
101
|
|
|
'label', |
|
102
|
|
|
'is_facet=1' |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Get list items from database |
|
108
|
|
|
* |
|
109
|
|
|
* @access protected |
|
110
|
|
|
* |
|
111
|
|
|
* @param array &$params: An array with parameters |
|
112
|
|
|
* @param string $fields: Comma-separated list of fields to fetch |
|
113
|
|
|
* @param string $table: Table name to fetch the items from |
|
114
|
|
|
* @param string $sorting: Field to sort items by (optionally appended by 'ASC' or 'DESC') |
|
115
|
|
|
* @param string $andWhere: Additional AND WHERE clause |
|
116
|
|
|
* |
|
117
|
|
|
* @return void |
|
118
|
|
|
*/ |
|
119
|
|
|
protected function generateList(&$params, $fields, $table, $sorting, $andWhere = '') |
|
120
|
|
|
{ |
|
121
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
122
|
|
|
->getQueryBuilderForTable($table); |
|
123
|
|
|
|
|
124
|
|
|
// Get $fields from $table on given pid. |
|
125
|
|
|
$result = $queryBuilder |
|
126
|
|
|
->select(...explode(',', $fields)) |
|
127
|
|
|
->from($table) |
|
128
|
|
|
->where( |
|
129
|
|
|
$queryBuilder->expr()->eq($table . '.pid', intval($this->storagePid)), |
|
130
|
|
|
$queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]), |
|
131
|
|
|
$andWhere |
|
132
|
|
|
) |
|
133
|
|
|
->orderBy($sorting) |
|
134
|
|
|
->execute(); |
|
135
|
|
|
|
|
136
|
|
|
while ($resArray = $result->fetch(\PDO::FETCH_NUM)) { |
|
137
|
|
|
if ($resArray) { |
|
138
|
|
|
$params['items'][] = $resArray; |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|