‪TYPO3CMS  9.5
PagesViewHelper.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 
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
23 
28 class ‪PagesViewHelper extends AbstractViewHelper
29 {
30  use CompileWithRenderStatic;
31 
37  protected ‪$escapeOutput = false;
38 
42  public function ‪initializeArguments()
43  {
44  $this->registerArgument('uids', 'string', '', false, '');
45  }
46 
56  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
57  {
58  $uids = $arguments['uids'];
59  if (!$uids) {
60  return '';
61  }
62 
63  $content = '';
64 
65  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
66  $queryBuilder->getRestrictions()->removeAll();
67 
68  $res = $queryBuilder
69  ->select('uid', 'title')
70  ->from('pages')
71  ->where(
72  $queryBuilder->expr()->in(
73  'uid',
74  $queryBuilder->createNamedParameter(
75  GeneralUtility::intExplode(',', $uids),
76  Connection::PARAM_INT_ARRAY
77  )
78  )
79  )
80  ->orderBy('uid', 'ASC')
81  ->execute();
82 
83  while ($row = $res->fetch()) {
84  $content .= '<li>' . htmlspecialchars($row['title']) . ' [' . htmlspecialchars($row['uid']) . ']</li>';
85  }
86  return '<ul>' . $content . '</ul>';
87  }
88 }
‪TYPO3\CMS\Beuser\ViewHelpers\Display\PagesViewHelper\initializeArguments
‪initializeArguments()
Definition: PagesViewHelper.php:40
‪TYPO3\CMS\Beuser\ViewHelpers\Display\PagesViewHelper
Definition: PagesViewHelper.php:29
‪TYPO3\CMS\Beuser\ViewHelpers\Display
Definition: PagesViewHelper.php:2
‪TYPO3\CMS\Beuser\ViewHelpers\Display\PagesViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PagesViewHelper.php:54
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:31
‪TYPO3\CMS\Beuser\ViewHelpers\Display\PagesViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: PagesViewHelper.php:35
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45