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