| 1 | <?php |
||
| 2 | namespace EWW\Dpf\ViewHelpers\Widget; |
||
| 3 | |||
| 4 | /* * |
||
| 5 | * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". * |
||
| 6 | * * |
||
| 7 | * It is free software; you can redistribute it and/or modify it under * |
||
| 8 | * the terms of the GNU Lesser General Public License, either version 3 * |
||
| 9 | * of the License, or (at your option) any later version. * |
||
| 10 | * * |
||
| 11 | * * |
||
| 12 | * This script is distributed in the hope that it will be useful, but * |
||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
||
| 14 | * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * |
||
| 15 | * General Public License for more details. * |
||
| 16 | * * |
||
| 17 | * You should have received a copy of the GNU Lesser General Public * |
||
| 18 | * License along with the script. * |
||
| 19 | * If not, see http://www.gnu.org/licenses/lgpl.html * |
||
| 20 | * * |
||
| 21 | * The TYPO3 project - inspiring people to share! * |
||
| 22 | * */ |
||
| 23 | |||
| 24 | /* |
||
| 25 | * This ViewHelper renders a Pagination of objects. |
||
| 26 | * |
||
| 27 | * = Examples = |
||
| 28 | * |
||
| 29 | * <code title="required arguments"> |
||
| 30 | * <f:widget.paginate objects="{blogs}" as="paginatedBlogs"> |
||
| 31 | * use {paginatedBlogs} as you used {blogs} before, most certainly inside |
||
| 32 | * a <f:for> loop. |
||
| 33 | * </f:widget.paginate> |
||
| 34 | * </code> |
||
| 35 | * |
||
| 36 | * <code title="full configuration"> |
||
| 37 | * <f:widget.paginate objects="{blogs}" as="paginatedBlogs" configuration="{itemsPerPage: 5, insertAbove: 1, insertBelow: 0, maximumNumberOfLinks: 10}"> |
||
| 38 | * use {paginatedBlogs} as you used {blogs} before, most certainly inside |
||
| 39 | * a <f:for> loop. |
||
| 40 | * </f:widget.paginate> |
||
| 41 | * </code> |
||
| 42 | * |
||
| 43 | * = Performance characteristics = |
||
| 44 | * |
||
| 45 | * In the above examples, it looks like {blogs} contains all Blog objects, thus |
||
| 46 | * you might wonder if all objects were fetched from the database. |
||
| 47 | * However, the blogs are NOT fetched from the database until you actually use them, |
||
| 48 | * so the paginate ViewHelper will adjust the query sent to the database and receive |
||
| 49 | * only the small subset of objects. |
||
| 50 | * So, there is no negative performance overhead in using the Paginate Widget. |
||
| 51 | * |
||
| 52 | */ |
||
| 53 | class PaginateViewHelper extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper |
||
| 54 | { |
||
| 55 | public function initializeArguments() |
||
| 56 | { |
||
| 57 | parent::initializeArguments(); |
||
| 58 | $this->registerArgument('objects', 'mixed', 'Object', true); |
||
| 59 | $this->registerArgument('as', 'string', 'as', true); |
||
| 60 | $this->registerArgument('configuration', 'array', |
||
| 61 | 'configuration', |
||
| 62 | false, |
||
| 63 | ['itemsPerPage' => 10, 'insertAbove' => false, 'insertBelow' => true, 'maximumNumberOfLinks' => 99] |
||
| 64 | ); |
||
| 65 | $this->registerArgument('total', 'int', 'Object', true); |
||
| 66 | $this->registerArgument('currentPage', 'int', 'as', true); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var \EWW\Dpf\ViewHelpers\Widget\Controller\PaginateController |
||
| 71 | * @TYPO3\CMS\Extbase\Annotation\Inject |
||
| 72 | */ |
||
| 73 | protected $controller; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return string |
||
| 77 | */ |
||
| 78 | public function render() |
||
| 79 | { |
||
| 80 | return $this->initiateSubRequest(); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 84 |