[!!!][TASK] Remove auto-unpublishing of workspaces
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / Widget / PaginateViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Widget;
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 use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
17
18 /**
19 * This ViewHelper renders a Pagination of objects for the TYPO3 Backend.
20 *
21 * Examples
22 * --------
23 *
24 * required arguments::
25 *
26 * <f:be.widget.paginate objects="{blogs}" as="paginatedBlogs">
27 * use {paginatedBlogs} as you used {blogs} before, most certainly inside
28 * a <f:for> loop.
29 * </f:be.widget.paginate>
30 *
31 * full configuration::
32 *
33 * <f:be.widget.paginate objects="{blogs}" as="paginatedBlogs" configuration="{itemsPerPage: 5, insertAbove: 1, insertBelow: 0, recordsLabel: 'MyRecords'}">
34 * use {paginatedBlogs} as you used {blogs} before, most certainly inside
35 * a <f:for> loop.
36 * </f:be.widget.paginate>
37 *
38 * The recordsLabel can be used to replace the text in "Records 1 - 99" with a label of your own choice
39 *
40 * Performance characteristics
41 * ---------------------------
42 *
43 * In the above examples, it looks like {blogs} contains all Blog objects, thus
44 * you might wonder if all objects were fetched from the database.
45 * However, the blogs are NOT fetched from the database until you actually use them,
46 * so the paginate ViewHelper will adjust the query sent to the database and receive
47 * only the small subset of objects.
48 * So, there is no negative performance overhead in using the Be Paginate Widget.
49 */
50 class PaginateViewHelper extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper
51 {
52 /**
53 * @var \TYPO3\CMS\Fluid\ViewHelpers\Be\Widget\Controller\PaginateController
54 */
55 protected $controller;
56
57 /**
58 * @param \TYPO3\CMS\Fluid\ViewHelpers\Be\Widget\Controller\PaginateController $controller
59 */
60 public function injectPaginateController(\TYPO3\CMS\Fluid\ViewHelpers\Be\Widget\Controller\PaginateController $controller)
61 {
62 $this->controller = $controller;
63 }
64
65 /**
66 * Initialize arguments.
67 */
68 public function initializeArguments()
69 {
70 parent::initializeArguments();
71 $this->registerArgument('objects', QueryResultInterface::class, 'The QueryResult containing all objects.', true);
72 $this->registerArgument('as', 'string', 'as', true);
73 $this->registerArgument('configuration', 'array', 'configuration', false, ['itemsPerPage' => 10, 'insertAbove' => false, 'insertBelow' => true, 'maximumNumberOfLinks' => 99]);
74 }
75
76 /**
77 * @return string
78 */
79 public function render()
80 {
81 return $this->initiateSubRequest();
82 }
83 }