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