‪TYPO3CMS  ‪main
PageBrowsingResultsViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
24 
30 final class ‪PageBrowsingResultsViewHelper extends AbstractViewHelper
31 {
32  use CompileWithRenderStatic;
33 
39  protected ‪$escapeOutput = false;
40 
41  public function ‪initializeArguments(): void
42  {
43  $this->registerArgument('numberOfResults', 'int', '', true);
44  $this->registerArgument('resultsPerPage', 'int', '', true);
45  $this->registerArgument('currentPage', 'int', '', false, 1);
46  }
47 
48  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
49  {
50  $numberOfResults = $arguments['numberOfResults'];
51  $resultsPerPage = $arguments['resultsPerPage'];
52  $currentPage = $arguments['currentPage'];
53 
54  $firstResultOnPage = $currentPage * $resultsPerPage + 1;
55  $lastResultOnPage = $currentPage * $resultsPerPage + $resultsPerPage;
56  $label = ‪LocalizationUtility::translate('displayResults', 'IndexedSearch') ?? '';
57  return sprintf($label, $firstResultOnPage, min([$numberOfResults, $lastResultOnPage]), $numberOfResults);
58  }
59 }
‪TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PageBrowsingResultsViewHelper.php:46
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:35
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate(string $key, ?string $extensionName=null, array $arguments=null, Locale|string $languageKey=null)
Definition: LocalizationUtility.php:47
‪TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\initializeArguments
‪initializeArguments()
Definition: PageBrowsingResultsViewHelper.php:39
‪TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper
Definition: PageBrowsingResultsViewHelper.php:31
‪TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: PageBrowsingResultsViewHelper.php:37
‪TYPO3\CMS\IndexedSearch\ViewHelpers