|
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\Domain\Model\Metadata; |
|
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
16
|
|
|
use Kitodo\Dlf\Domain\Repository\MetadataRepository; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Plugin 'List View' for the 'dlf' extension |
|
20
|
|
|
* |
|
21
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
22
|
|
|
* @author Henrik Lochmann <[email protected]> |
|
23
|
|
|
* @author Frank Ulrich Weber <[email protected]> |
|
24
|
|
|
* @package TYPO3 |
|
25
|
|
|
* @subpackage dlf |
|
26
|
|
|
* @access public |
|
27
|
|
|
*/ |
|
28
|
|
|
class ListViewController extends AbstractController |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var MetadataRepository |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $metadataRepository; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param MetadataRepository $metadataRepository |
|
38
|
|
|
*/ |
|
39
|
|
|
public function injectMetadataRepository(MetadataRepository $metadataRepository) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->metadataRepository = $metadataRepository; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* The main method of the plugin |
|
46
|
|
|
* |
|
47
|
|
|
* @return void |
|
48
|
|
|
*/ |
|
49
|
|
|
public function mainAction() |
|
50
|
|
|
{ |
|
51
|
|
|
$searchRequestData = GeneralUtility::_GPmerged('tx_dlf_search'); |
|
52
|
|
|
$listRequestData = GeneralUtility::_GPmerged('tx_dlf_listview'); |
|
53
|
|
|
$collectionRequestData = GeneralUtility::_GPmerged('tx_dlf_collection'); |
|
54
|
|
|
|
|
55
|
|
|
$searchRequestData = array_merge($searchRequestData, $listRequestData); |
|
56
|
|
|
$searchRequestData = array_merge($searchRequestData, $collectionRequestData); |
|
57
|
|
|
|
|
58
|
|
|
// ABTODO: This plugin may be called from search and collection plugin... |
|
59
|
|
|
|
|
60
|
|
|
$searchParams = $searchRequestData['searchParameter']; |
|
61
|
|
|
$widgetPage = $searchRequestData['widgetPage']; |
|
62
|
|
|
if (empty($widgetPage)) { |
|
63
|
|
|
$widgetPage = ['currentPage' => 1]; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// get all sortable metadata records |
|
67
|
|
|
$sortableMetadata = $this->metadataRepository->findByIsSortable(true); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
// get all metadata records to be shown in results |
|
70
|
|
|
$listedMetadata = $this->metadataRepository->findByIsListed(true); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
if (is_array($searchParams) && !empty($searchParams)) { |
|
73
|
|
|
$solrResults = $this->documentRepository->findSolrByCollection('', $this->settings, $searchParams, $listedMetadata); |
|
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
$documents = $solrResults['documents'] ? : []; |
|
|
|
|
|
|
77
|
|
|
$this->view->assign('documents', $documents); |
|
78
|
|
|
$rawResults = $solrResults['solrResults']['documents'] ? : []; |
|
79
|
|
|
$this->view->assign('numResults', count($rawResults)); |
|
80
|
|
|
$this->view->assign('widgetPage', $widgetPage); |
|
81
|
|
|
$this->view->assign('lastSearch', $searchParams); |
|
82
|
|
|
|
|
83
|
|
|
$this->view->assign('sortableMetadata', $sortableMetadata); |
|
84
|
|
|
$this->view->assign('listedMetadata', $listedMetadata); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|