Skip to content
115 changes: 70 additions & 45 deletions Classes/Controller/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,54 +133,34 @@ public function showAction(Collection $collection): ResponseInterface
return $this->htmlResponse();
}

// Pagination of Results: Pass the currentPage to the fluid template to calculate current index of search result.
$currentPage = $this->getIntParameterSafely('page');
if ($currentPage == 0) {
$currentPage = 1;
if ($this->settings['showOverview']) {
$this->view->assign('collection', $collection);
}

$search['collection'] = $collection->getUid();
// If a targetPid is given, the results will be shown by ListView on the target page.
if (!empty($this->settings['targetPid'])) {
return $this->redirect(
'main',
'ListView',
null,
[
'search' => $search,
'page' => $currentPage
],
$this->settings['targetPid']
);
}

// get all metadata records to be shown in results
$listedMetadata = $this->metadataRepository->findBy(['isListed' => true]);

// get all indexed metadata fields
$indexedMetadata = $this->metadataRepository->findBy(['indexIndexed' => true]);

// get all sortable metadata records
$sortableMetadata = $this->metadataRepository->findBy(['isSortable' => true]);

// get all documents of given collection
$solrResults = $this->documentRepository->findSolrByCollection($collection, $this->settings, $search, $listedMetadata, $indexedMetadata);

$itemsPerPage = $this->settings['list']['paginate']['itemsPerPage'] ?? 25;
$solrPaginator = new SolrPaginator($solrResults, $currentPage, $itemsPerPage);
$simplePagination = new SimplePagination($solrPaginator);
if ($this->settings['showDocuments']) {
// Pagination of Results: Pass the currentPage to the fluid template to calculate current index of search result.
$currentPage = $this->getIntParameterSafely('page');
if ($currentPage == 0) {
$currentPage = 1;
}

$pagination = $this->buildSimplePagination($simplePagination, $solrPaginator);
$this->view->assignMultiple([ 'pagination' => $pagination, 'paginator' => $solrPaginator ]);
$search['collection'] = $collection->getUid();
// If a targetPid is given, the results will be shown by ListView on the target page.
if (!empty($this->settings['targetPid'])) {
return $this->redirect(
'main',
'ListView',
null,
[
'search' => $search,
'page' => $currentPage
],
$this->settings['targetPid']
);
}

$this->view->assign('documents', $solrResults);
$this->view->assign('collection', $collection);
$this->view->assign('page', $currentPage);
$this->view->assign('lastSearch', $search);
$this->view->assign('sortableMetadata', $sortableMetadata);
$this->view->assign('listedMetadata', $listedMetadata);
$this->view->assign('requestData', $this->requestData);
$this->view->assign('uniqueId', $this->uniqueId);
$this->showDocuments($collection, $search, $currentPage);
}

return $this->htmlResponse();
}
Expand Down Expand Up @@ -226,7 +206,7 @@ public function showSortedAction(): ResponseInterface
*
* @return array<int,array{collection:Collection,info:array<string,mixed>}> Processed collections keyed by priority-based integer
*/
private function processCollections(array$collections, Solr $solr): array
private function processCollections(array $collections, Solr $solr): array
{
$processedCollections = [];

Expand Down Expand Up @@ -289,4 +269,49 @@ private function processCollections(array$collections, Solr $solr): array

return $processedCollections;
}

/**
* Show documents for the given collection.
*
* @access private
*
* @param Collection $collection
* @param mixed[] $search
* @param int $currentPage
*
* @return void
*/
private function showDocuments(Collection $collection, array $search, int $currentPage): void
{
// get all metadata records to be shown in results
$listedMetadata = $this->metadataRepository->findBy(['isListed' => true]);

// get all indexed metadata fields
$indexedMetadata = $this->metadataRepository->findBy(['indexIndexed' => true]);

// get all sortable metadata records
$sortableMetadata = $this->metadataRepository->findBy(['isSortable' => true]);

// get all documents of given collection
$solrResults = $this->documentRepository->findSolrByCollection($collection, $this->settings, $search, $listedMetadata, $indexedMetadata);

$itemsPerPage = $this->settings['list']['paginate']['itemsPerPage'] ?? 25;
$solrPaginator = new SolrPaginator($solrResults, $currentPage, $itemsPerPage);
$simplePagination = new SimplePagination($solrPaginator);

$pagination = $this->buildSimplePagination($simplePagination, $solrPaginator);
$this->view->assignMultiple(
[
'documents' => $solrResults,
'page' => $currentPage,
'pagination' => $pagination,
'paginator' => $solrPaginator,
'lastSearch' => $search,
'listedMetadata' => $listedMetadata,
'sortableMetadata' => $sortableMetadata,
'requestData' => $this->requestData,
'uniqueId' => $this->uniqueId
]
);
}
}
16 changes: 16 additions & 0 deletions Configuration/FlexForms/Collection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@
<default>0</default>
</config>
</settings.showSingle>
<settings.showOverview>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:collection.flexForm.showOverview</label>
<config>
<type>check</type>
<default>1</default>
</config>
</settings.showOverview>
<settings.showDocuments>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:collection.flexForm.showDocuments</label>
<config>
<type>check</type>
<default>1</default>
</config>
</settings.showDocuments>
<settings.randomize>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:collection.flexForm.randomize</label>
Expand Down
14 changes: 14 additions & 0 deletions Documentation/Plugins/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ FlexForm Configuration
:Default:
0

- :Property:
showOverview
:Data Type:
:ref:`t3tsref:data-type-boolean`
:Default:
1

- :Property:
showDocuments
:Data Type:
:ref:`t3tsref:data-type-boolean`
:Default:
1

- :Property:
randomize
:Data Type:
Expand Down
12 changes: 10 additions & 2 deletions Resources/Private/Language/de.locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,17 @@
<source><![CDATA[Randomize sorting?]]></source>
<target><![CDATA[Zufällige Sortierung?]]></target>
</trans-unit>
<trans-unit id="collection.flexForm.showDocuments" approved="yes">
<source><![CDATA[Show documents in the single collection view?]]></source>
<target><![CDATA[Dokumente in der Einzelansicht der Sammlung anzeigen?]]></target>
</trans-unit>
<trans-unit id="collection.flexForm.showOverview" approved="yes">
<source><![CDATA[Show overview in the single collection view?]]></source>
<target><![CDATA[Übersicht in der Einzelansicht der Sammlung anzeigen?]]></target>
</trans-unit>
<trans-unit id="collection.flexForm.showSingle" approved="yes">
<source><![CDATA[Show single collection in overview?]]></source>
<target><![CDATA[Einzelne Kollektion in Übersicht anzeigen?]]></target>
<source><![CDATA[Show the single collection view?]]></source>
<target><![CDATA[Die Einzelansicht der Sammlung anzeigen?]]></target>
</trans-unit>
<trans-unit id="collection.flexForm.showUserDefined" approved="yes">
<source><![CDATA[Show user-defined collections?]]></source>
Expand Down
8 changes: 7 additions & 1 deletion Resources/Private/Language/locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@
<trans-unit id="collection.flexForm.randomize">
<source><![CDATA[Randomize sorting?]]></source>
</trans-unit>
<trans-unit id="collection.flexForm.showDocuments">
<source><![CDATA[Show documents in the single collection view?]]></source>
</trans-unit>
<trans-unit id="collection.flexForm.showOverview">
<source><![CDATA[Show overview in the single collection view?]]></source>
</trans-unit>
<trans-unit id="collection.flexForm.showSingle">
<source><![CDATA[Show single collection in overview?]]></source>
<source><![CDATA[Show the single collection in the single collection view?]]></source>
</trans-unit>
<trans-unit id="collection.flexForm.showUserDefined">
<source><![CDATA[Show user-defined collections?]]></source>
Expand Down
34 changes: 34 additions & 0 deletions Resources/Private/Partials/Collection/Overview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">

<f:comment>
(c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>

This file is part of the Kitodo and TYPO3 projects.

@license GNU General Public License version 3 or later.
For the full copyright and license information, please read the
LICENSE.txt file that was distributed with this source code.
</f:comment>

<f:if condition="{debugActive}">
<f:debug title="all">{_all}</f:debug>
</f:if>

<h2 class="tx-dlf-listview-label">{collection.label}</h2>

<f:if condition="{collection.thumbnail}">
<div class="tx-dlf-collection-thumbnail">
<f:if condition="{collection.thumbnail}">
<f:image image="{collection.thumbnail}" alt="{f:translate(key: 'general.thumbnail')} {collection.label}" title="{collection.label}" maxWidth="250" />
</f:if>
</div>
</f:if>

<f:if condition="{collection.description}">
<div class="tx-dlf-collection-description">
<f:format.html>{collection.description}</f:format.html>
</div>
</f:if>

</html>
26 changes: 8 additions & 18 deletions Resources/Private/Templates/Collection/Show.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,17 @@
<f:debug title="all">{_all}</f:debug>
</f:if>

<div class="tx-dlf-listview">
<h2 class="tx-dlf-listview-label">{collection.label}</h2>

<f:if condition="{collection.thumbnail}">
<div class="tx-dlf-collection-thumbnail">
<f:if condition="{collection.thumbnail}">
<f:image image="{collection.thumbnail}" alt="{f:translate(key: 'general.thumbnail')} {collection.label}" title="{collection.label}" maxWidth="250" />
</f:if>
</div>
<div class="tx-dlf-listview">\
<f:if condition="{settings.showOverview}">
<f:render partial="Collection/Overview" arguments="{_all}" />
</f:if>

<f:if condition="{collection.description}">
<div class="tx-dlf-collection-description">
<f:format.html>{collection.description}</f:format.html>
</div>
<f:if condition="{settings.showDocuments}">
<f:variable name="action" value="showSorted" />
<f:variable name="controller" value="Collection" />
<f:render partial="ListView/SortingForm" arguments="{_all}" />
<f:render partial="ListView/Results" arguments="{_all}" />
</f:if>

<f:variable name="action" value="showSorted" />
<f:variable name="controller" value="Collection" />
<f:render partial="ListView/SortingForm" arguments="{_all}" />
<f:render partial="ListView/Results" arguments="{_all}" />
</div>

</html>
4 changes: 3 additions & 1 deletion Tests/Functional/Controller/CollectionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public function canShowAction()
'storagePid' => self::$storagePid,
'solrcore' => self::$solrCoreId,
'collections' => '1',
'showSingle' => '0',
'showSingle' => '1',
'showOverview' => '1',
'showDocuments' => '1',
'randomize' => ''
];
$templateHtml = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"><f:for each="{documents.solrResults.documents}" as="page" iteration="docIterator">{page.title},</f:for></html>';
Expand Down