|
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
|
|
|
namespace Kitodo\Dlf\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Kitodo\Dlf\Common\Document; |
|
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\Utility\LocalizationUtility; |
|
19
|
|
|
|
|
20
|
|
|
class FeedsController extends AbstractController |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Initializes the current action |
|
24
|
|
|
* |
|
25
|
|
|
* @return void |
|
26
|
|
|
*/ |
|
27
|
|
|
public function initializeAction() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->request->setFormat('xml'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* The main method of the plugin |
|
34
|
|
|
* |
|
35
|
|
|
* @return void |
|
36
|
|
|
*/ |
|
37
|
|
|
public function mainAction() |
|
38
|
|
|
{ |
|
39
|
|
|
// access to GET parameter tx_dlf_feeds['collection'] |
|
40
|
|
|
$requestData = $this->request->getArguments(); |
|
41
|
|
|
|
|
42
|
|
|
// get library information |
|
43
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
44
|
|
|
->getQueryBuilderForTable('tx_dlf_libraries'); |
|
45
|
|
|
|
|
46
|
|
|
$result = $queryBuilder |
|
47
|
|
|
->select('tx_dlf_libraries.label AS label') |
|
48
|
|
|
->from('tx_dlf_libraries') |
|
49
|
|
|
->where( |
|
50
|
|
|
$queryBuilder->expr()->eq('tx_dlf_libraries.pid', (int) $this->settings['pages']), |
|
51
|
|
|
$queryBuilder->expr()->eq('tx_dlf_libraries.uid', (int) $this->settings['library']) |
|
52
|
|
|
) |
|
53
|
|
|
->setMaxResults(1) |
|
54
|
|
|
->execute(); |
|
55
|
|
|
|
|
56
|
|
|
$feedMeta = []; |
|
57
|
|
|
$documents = []; |
|
58
|
|
|
|
|
59
|
|
|
if ($resArray = $result->fetch()) { |
|
60
|
|
|
$feedMeta['copyright'] = $resArray['label']; |
|
61
|
|
|
} else { |
|
62
|
|
|
$this->logger->error('Failed to fetch label of selected library with "' . $this->settings['library'] . '"'); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if ( |
|
66
|
|
|
!$this->settings['excludeOtherCollections'] |
|
67
|
|
|
|| empty($requestData['collection']) |
|
68
|
|
|
|| GeneralUtility::inList($this->settings['collections'], $requestData['collection']) |
|
69
|
|
|
) { |
|
70
|
|
|
$additionalWhere = ''; |
|
71
|
|
|
// Check for pre-selected collections. |
|
72
|
|
|
if (!empty($requestData['collection'])) { |
|
73
|
|
|
$additionalWhere = 'tx_dlf_collections.uid=' . intval($requestData['collection']); |
|
74
|
|
|
} elseif (!empty($this->settings['collections'])) { |
|
75
|
|
|
$additionalWhere = 'tx_dlf_collections.uid IN (' . implode(',', GeneralUtility::intExplode(',', $this->settings['collections'])) . ')'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
// get documents |
|
79
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
80
|
|
|
->getQueryBuilderForTable('tx_dlf_documents'); |
|
81
|
|
|
|
|
82
|
|
|
$result = $queryBuilder |
|
83
|
|
|
->select( |
|
84
|
|
|
'tx_dlf_documents.uid AS uid', |
|
85
|
|
|
'tx_dlf_documents.partof AS partof', |
|
86
|
|
|
'tx_dlf_documents.title AS title', |
|
87
|
|
|
'tx_dlf_documents.volume AS volume', |
|
88
|
|
|
'tx_dlf_documents.author AS author', |
|
89
|
|
|
'tx_dlf_documents.record_id AS record_id', |
|
90
|
|
|
'tx_dlf_documents.tstamp AS tstamp', |
|
91
|
|
|
'tx_dlf_documents.crdate AS crdate' |
|
92
|
|
|
) |
|
93
|
|
|
->from('tx_dlf_documents') |
|
94
|
|
|
->join( |
|
95
|
|
|
'tx_dlf_documents', |
|
96
|
|
|
'tx_dlf_relations', |
|
97
|
|
|
'tx_dlf_documents_collections_mm', |
|
98
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_local')) |
|
99
|
|
|
) |
|
100
|
|
|
->join( |
|
101
|
|
|
'tx_dlf_documents_collections_mm', |
|
102
|
|
|
'tx_dlf_collections', |
|
103
|
|
|
'tx_dlf_collections', |
|
104
|
|
|
$queryBuilder->expr()->eq('tx_dlf_collections.uid', $queryBuilder->quoteIdentifier('tx_dlf_documents_collections_mm.uid_foreign')) |
|
105
|
|
|
) |
|
106
|
|
|
->where( |
|
107
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])), |
|
108
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents_collections_mm.ident', $queryBuilder->createNamedParameter('docs_colls')), |
|
109
|
|
|
$queryBuilder->expr()->eq('tx_dlf_collections.pid', $queryBuilder->createNamedParameter((int) $this->settings['pages'])), |
|
110
|
|
|
$additionalWhere |
|
111
|
|
|
) |
|
112
|
|
|
->groupBy('tx_dlf_documents.uid') |
|
113
|
|
|
->orderBy('tx_dlf_documents.tstamp', 'DESC') |
|
114
|
|
|
->setMaxResults((int) $this->settings['limit']) |
|
115
|
|
|
->execute(); |
|
116
|
|
|
|
|
117
|
|
|
$rows = $result->fetchAll(); |
|
118
|
|
|
|
|
119
|
|
|
foreach ($rows as $resArray) { |
|
120
|
|
|
|
|
121
|
|
|
$title = ''; |
|
122
|
|
|
// Get title of superior document. |
|
123
|
|
|
if ((empty($resArray['title']) || !empty($this->settings['prependSuperiorTitle'])) |
|
124
|
|
|
&& !empty($resArray['partof']) |
|
125
|
|
|
) { |
|
126
|
|
|
$superiorTitle = Document::getTitle($resArray['partof'], true); |
|
127
|
|
|
if (!empty($superiorTitle)) { |
|
128
|
|
|
$title .= '[' . $superiorTitle . ']'; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
// Get title of document. |
|
132
|
|
|
if (!empty($resArray['title'])) { |
|
133
|
|
|
$title .= ' ' . $resArray['title']; |
|
134
|
|
|
} |
|
135
|
|
|
// Set default title if empty. |
|
136
|
|
|
if (empty($title)) { |
|
137
|
|
|
$title = LocalizationUtility::translate('noTitle', 'dlf'); |
|
138
|
|
|
} |
|
139
|
|
|
// Append volume information. |
|
140
|
|
|
if (!empty($resArray['volume'])) { |
|
141
|
|
|
$title .= ', ' . LocalizationUtility::translate('volume', 'dlf') . ' ' . $resArray['volume']; |
|
142
|
|
|
} |
|
143
|
|
|
// Is this document new or updated? |
|
144
|
|
|
if ($resArray['crdate'] == $resArray['tstamp']) { |
|
145
|
|
|
$title = LocalizationUtility::translate('plugins.feeds.new', 'dlf') . ' ' . trim($title); |
|
|
|
|
|
|
146
|
|
|
} else { |
|
147
|
|
|
$title = LocalizationUtility::translate('plugins.feeds.update', 'dlf') . ' ' . trim($title); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$resArray['title'] = $title; |
|
151
|
|
|
$documents[] = $resArray; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
$this->view->assign('documents', $documents); |
|
157
|
|
|
$this->view->assign('feedMeta', $feedMeta); |
|
158
|
|
|
|
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.