[BUGFIX] Fix several typos in php comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / PageInfoViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Be;
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\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Imaging\Icon;
19 use TYPO3\CMS\Core\Imaging\IconFactory;
20 use TYPO3\CMS\Core\Type\Bitmask\Permission;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23
24 /**
25 * ViewHelper which return page info icon as known from TYPO3 backend modules.
26 *
27 * .. note::
28 * This ViewHelper is experimental!
29 *
30 * Examples
31 * ========
32 *
33 * Default::
34 *
35 * <f:be.pageInfo />
36 *
37 * Page info icon with context menu
38 */
39 class PageInfoViewHelper extends AbstractBackendViewHelper
40 {
41
42 /**
43 * This ViewHelper renders HTML, thus output must not be escaped
44 *
45 * @var bool
46 */
47 protected $escapeOutput = false;
48
49 /**
50 * Render javascript in header
51 *
52 * @return string the rendered page info icon
53 * @see \TYPO3\CMS\Backend\Template\DocumentTemplate::getPageInfo() Note: can't call this method as it's protected!
54 */
55 public function render()
56 {
57 return static::renderStatic(
58 [],
59 $this->buildRenderChildrenClosure(),
60 $this->renderingContext
61 );
62 }
63
64 /**
65 * @param array $arguments
66 * @param \Closure $renderChildrenClosure
67 * @param RenderingContextInterface $renderingContext
68 *
69 * @return string
70 */
71 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
72 {
73 $id = GeneralUtility::_GP('id');
74 $pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW));
75 // Add icon with context menu, etc:
76 /** @var IconFactory $iconFactory */
77 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
78 if ($pageRecord['uid']) {
79 // If there IS a real page
80 $altText = BackendUtility::getRecordIconAltText($pageRecord, 'pages');
81 $theIcon = '<span title="' . $altText . '">' . $iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>';
82 // Make Icon:
83 $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'pages', $pageRecord['uid']);
84
85 // Setting icon with context menu + uid
86 $theIcon .= ' <em>[PID: ' . $pageRecord['uid'] . ']</em>';
87 } else {
88 // On root-level of page tree
89 // Make Icon
90 $theIcon = '<span title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $iconFactory->getIcon('apps-pagetree-page-domain', Icon::SIZE_SMALL)->render() . '</span>';
91 if ($GLOBALS['BE_USER']->isAdmin()) {
92 $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'pages');
93 }
94 }
95 return $theIcon;
96 }
97 }