[BUGFIX] Use correct extension name for labels in indexed search
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / Classes / ViewHelpers / PageBrowsingResultsViewHelper.php
1 <?php
2 namespace TYPO3\CMS\IndexedSearch\ViewHelpers;
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
17 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
18 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
20 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
21
22 /**
23 * renders the header of the results page
24 * @internal
25 */
26 class PageBrowsingResultsViewHelper extends AbstractViewHelper implements CompilableInterface {
27
28 /**
29 * main render function
30 *
31 * @param int $numberOfResults
32 * @param int $resultsPerPage
33 * @param int $currentPage
34 * @return string the content
35 */
36 public function render($numberOfResults, $resultsPerPage, $currentPage = 1) {
37 return static::renderStatic(
38 array(
39 'numberOfResults' => $numberOfResults,
40 'resultsPerPage' => $resultsPerPage,
41 'currentPage' => $currentPage,
42 ),
43 $this->buildRenderChildrenClosure(),
44 $this->renderingContext
45 );
46 }
47
48 /**
49 * @param array $arguments
50 * @param callable|\Closure $renderChildrenClosure
51 * @param RenderingContextInterface $renderingContext
52 * @return string
53 */
54 static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
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(array($numberOfResults, $lastResultOnPage)), $numberOfResults);
63 }
64
65 }