‪TYPO3CMS  ‪main
PageInfoViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ServerRequestInterface;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
23 use TYPO3\CMS\Core\Imaging\IconSize;
27 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
28 
47 {
53  protected ‪$escapeOutput = false;
54 
55  public function ‪render(): string
56  {
57  return ‪self::renderStatic([], $this->buildRenderChildrenClosure(), $this->renderingContext);
58  }
59 
60  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
61  {
63  $request = $renderingContext->getRequest();
64  $id = 0;
65  if ($request instanceof ServerRequestInterface) {
66  $id = $request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0;
67  }
68  $pageRecord = BackendUtility::readPageAccess($id, ‪$GLOBALS['BE_USER']->getPagePermsClause(‪Permission::PAGE_SHOW));
69  // Add icon with context menu, etc:
70  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
71  if (is_array($pageRecord) && ($pageRecord['uid'] ?? false)) {
72  // If there IS a real page
73  $altText = BackendUtility::getRecordIconAltText($pageRecord, 'pages');
74  $theIcon = '<span title="' . $altText . '">' . $iconFactory->getIconForRecord('pages', $pageRecord, IconSize::SMALL)->render() . '</span>';
75  // Make Icon:
76  $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'pages', $pageRecord['uid']);
77 
78  // Setting icon with context menu + uid
79  $theIcon .= ' <em>[PID: ' . $pageRecord['uid'] . ']</em>';
80  } else {
81  // On root-level of page tree
82  // Make Icon
83  $theIcon = '<span title="' . htmlspecialchars(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $iconFactory->getIcon('apps-pagetree-page-domain', IconSize::SMALL)->render() . '</span>';
84  if (‪$GLOBALS['BE_USER']->isAdmin()) {
85  $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'pages');
86  }
87  }
88  return $theIcon;
89  }
90 }
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:30
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PageInfoViewHelper
Definition: PageInfoViewHelper.php:47
‪TYPO3\CMS\Fluid\ViewHelpers\Be
Definition: AbstractBackendViewHelper.php:18
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PageInfoViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PageInfoViewHelper.php:59
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:35
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PageInfoViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: PageInfoViewHelper.php:52
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PageInfoViewHelper\render
‪render()
Definition: PageInfoViewHelper.php:54
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
Definition: RenderingContext.php:35