Skip to content

Commit

Permalink
[TASK] Fix indentation, add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudy Gnodde authored and dkd-kaehm committed Nov 27, 2021
1 parent caf706a commit 17cdf57
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 141 deletions.
27 changes: 27 additions & 0 deletions Classes/Pagination/ResultsPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function __construct(PaginatorInterface $paginator)
}

/**
* Get maximum page numbers
*
* @return int
*/
public function getMaxPageNumbers(): int
Expand All @@ -72,6 +74,8 @@ public function getMaxPageNumbers(): int
}

/**
* Set maximum page numbers
*
* @param int $maxPageNumbers
*/
public function setMaxPageNumbers(int $maxPageNumbers): void
Expand All @@ -81,6 +85,8 @@ public function setMaxPageNumbers(int $maxPageNumbers): void
}

/**
* Get has more pages
*
* @return bool
*/
public function getHasMorePages(): bool
Expand All @@ -89,6 +95,8 @@ public function getHasMorePages(): bool
}

/**
* Get has less pages
*
* @return bool
*/
public function getHasLessPages(): bool
Expand All @@ -97,6 +105,8 @@ public function getHasLessPages(): bool
}

/**
* Get previous page number
*
* @return int|null
*/
public function getPreviousPageNumber(): ?int
Expand All @@ -114,6 +124,8 @@ public function getPreviousPageNumber(): ?int
}

/**
* Get next page number
*
* @return int|null
*/
public function getNextPageNumber(): ?int
Expand All @@ -126,6 +138,8 @@ public function getNextPageNumber(): ?int
}

/**
* Get first page number
*
* @return int
*/
public function getFirstPageNumber(): int
Expand All @@ -134,6 +148,8 @@ public function getFirstPageNumber(): int
}

/**
* Get last page number
*
* @return int
*/
public function getLastPageNumber(): int
Expand All @@ -142,6 +158,8 @@ public function getLastPageNumber(): int
}

/**
* Get start record number
*
* @return int
*/
public function getStartRecordNumber(): int
Expand All @@ -154,6 +172,8 @@ public function getStartRecordNumber(): int
}

/**
* Get end record number
*
* @return int
*/
public function getEndRecordNumber(): int
Expand All @@ -166,13 +186,20 @@ public function getEndRecordNumber(): int
}

/**
* Get all page numbers
*
* @return int[]
*/
public function getAllPageNumbers(): array
{
return range($this->pageRangeFirst, $this->pageRangeLast);
}

/**
* Calculate page range
*
* @return void
*/
protected function calculatePageRange(): void
{
$this->pageRangeFirst = 1;
Expand Down
8 changes: 8 additions & 0 deletions Classes/Pagination/ResultsPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function __construct(
}

/**
* Get paginated items
*
* @return iterable
*/
public function getPaginatedItems(): iterable
Expand All @@ -55,6 +57,8 @@ public function getPaginatedItems(): iterable
}

/**
* Update paginated items
*
* @param int $itemsPerPage
* @param int $offset
*/
Expand All @@ -63,6 +67,8 @@ public function updatePaginatedItems(int $itemsPerPage, int $offset): void
}

/**
* Get amount of items on current page
*
* @return int
*/
public function getAmountOfItemsOnCurrentPage(): int
Expand All @@ -71,6 +77,8 @@ public function getAmountOfItemsOnCurrentPage(): int
}

/**
* Get total amount of items
*
* @return int
*/
public function getTotalAmountOfItems(): int
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TypoScript/Solr/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ plugin.tx_solr {

resultsPerPage = {$plugin.tx_solr.search.results.resultsPerPage}
resultsPerPageSwitchOptions = 10, 25, 50
maxPaginatorLinks = 0
maxPaginatorLinks = 0

showDocumentScoreAnalysis = 0
}
Expand Down
10 changes: 10 additions & 0 deletions Documentation/Configuration/Reference/TxSolrSearch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ results.resultsPerPageSwitchOptions

Defines the shown options of possible results per page.

results.maxPaginatorLinks
~~~~~~~~~~~~~~~~~~~~~~~~~

:Type: Integer
:TS Path: plugin.tx_solr.search.results.maxPaginatorLinks
:Since: 11.5
:Default: 0

Sets the number of shown page links in the paginator.

results.showDocumentScoreAnalysis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
12 changes: 6 additions & 6 deletions Documentation/Frontend/Results.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ The following part of the default template iterates over the results and renders

.. code-block:: xml
<ol start="{pagination.displayRangeStart}" class="results-list">
<f:for each="{resultSet.searchResults}" as="document">
<f:render partial="Result/Document" section="Document"
arguments="{resultSet:resultSet, document:document}" />
</f:for>
</ol>
<ol start="{pagination.displayRangeStart}" class="results-list">
<f:for each="{resultSet.searchResults}" as="document">
<f:render partial="Result/Document" section="Document"
arguments="{resultSet:resultSet, document:document}" />
</f:for>
</ol>
This structure allows you to use e.g. the fluid if ViewHelper to render a result with a different partial, based on a field value.
But as you see in the template above, by default the partial "Result/Document" is used.
Expand Down
132 changes: 66 additions & 66 deletions Resources/Private/Partials/Result/Pagination.html
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers"
data-namespace-typo3-fluid="true"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers"
data-namespace-typo3-fluid="true"
>

<f:section name="Pagination">

<div class="solr-pagination">
<ul class="pagination">
<f:if condition="{pagination.previousPageNumber}">
<li class="previous">
<f:if condition="{pagination.previousPageNumber} > 1">
<f:then>
<a href="{s:uri.paginate.resultPage(page: pagination.previousPageNumber)}" class="solr-ajaxified">
<f:if condition="{s:translate(key: 'paginate_previous')}">
<f:then><s:translate key="paginate_previous" /></f:then>
<f:else>&laquo;</f:else>
</f:if>
</a>
</f:then>
<f:else>
<a href="{s:uri.paginate.resultPage()}" class="solr-ajaxified">
<f:if condition="{s:translate(key: 'paginate_previous')}">
<f:then><s:translate key="paginate_previous" /></f:then>
<f:else>&laquo;</f:else>
</f:if>
</a>
</f:else>
</f:if>
</li>
</f:if>
<f:if condition="{pagination.hasLessPages}">
<li><a>....</a></li>
</f:if>
<f:for each="{pagination.allPageNumbers}" as="page">
<f:if condition="{page} == {currentPage}">
<f:then>
<li class="active">
<a href="{s:uri.paginate.resultPage()}" class="solr-ajaxified">{page}</a>
</li>
</f:then>
<f:else>
<li>
<f:if condition="{page} > 1">
<f:then>
<a href="{s:uri.paginate.resultPage(page: page)}" class="solr-ajaxified">{page}</a>
</f:then>
<f:else>
<a href="{s:uri.paginate.resultPage()}" class="solr-ajaxified">{page}</a>
</f:else>
</f:if>
</li>
</f:else>
</f:if>
</f:for>
<f:if condition="{pagination.hasMorePages}">
<li><a>....</a></li>
</f:if>
<f:if condition="{pagination.nextPageNumber}">
<li class="last next">
<a href="{s:uri.paginate.resultPage(page: pagination.nextPageNumber)}" class="solr-ajaxified">
<f:if condition="{s:translate(key: 'paginate_next')}">
<f:then><s:translate key="paginate_next" /></f:then>
<f:else>&raquo;</f:else>
</f:if>
</a>
</li>
</f:if>
</ul>
</div>
<div class="solr-pagination">
<ul class="pagination">
<f:if condition="{pagination.previousPageNumber}">
<li class="previous">
<f:if condition="{pagination.previousPageNumber} > 1">
<f:then>
<a href="{s:uri.paginate.resultPage(page: pagination.previousPageNumber)}" class="solr-ajaxified">
<f:if condition="{s:translate(key: 'paginate_previous')}">
<f:then><s:translate key="paginate_previous" /></f:then>
<f:else>&laquo;</f:else>
</f:if>
</a>
</f:then>
<f:else>
<a href="{s:uri.paginate.resultPage()}" class="solr-ajaxified">
<f:if condition="{s:translate(key: 'paginate_previous')}">
<f:then><s:translate key="paginate_previous" /></f:then>
<f:else>&laquo;</f:else>
</f:if>
</a>
</f:else>
</f:if>
</li>
</f:if>
<f:if condition="{pagination.hasLessPages}">
<li><a>....</a></li>
</f:if>
<f:for each="{pagination.allPageNumbers}" as="page">
<f:if condition="{page} == {currentPage}">
<f:then>
<li class="active">
<a href="{s:uri.paginate.resultPage()}" class="solr-ajaxified">{page}</a>
</li>
</f:then>
<f:else>
<li>
<f:if condition="{page} > 1">
<f:then>
<a href="{s:uri.paginate.resultPage(page: page)}" class="solr-ajaxified">{page}</a>
</f:then>
<f:else>
<a href="{s:uri.paginate.resultPage()}" class="solr-ajaxified">{page}</a>
</f:else>
</f:if>
</li>
</f:else>
</f:if>
</f:for>
<f:if condition="{pagination.hasMorePages}">
<li><a>....</a></li>
</f:if>
<f:if condition="{pagination.nextPageNumber}">
<li class="last next">
<a href="{s:uri.paginate.resultPage(page: pagination.nextPageNumber)}" class="solr-ajaxified">
<f:if condition="{s:translate(key: 'paginate_next')}">
<f:then><s:translate key="paginate_next" /></f:then>
<f:else>&raquo;</f:else>
</f:if>
</a>
</li>
</f:if>
</ul>
</div>

</f:section>

Expand Down
Loading

0 comments on commit 17cdf57

Please sign in to comment.