‪TYPO3CMS  ‪main
PagePathViewHelper.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;
26 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
27 
46 {
52  protected ‪$escapeOutput = false;
53 
54  public function ‪render(): string
55  {
56  return ‪self::renderStatic([], $this->buildRenderChildrenClosure(), $this->renderingContext);
57  }
58 
59  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
60  {
62  $request = $renderingContext->getRequest();
63  $id = 0;
64  if ($request instanceof ServerRequestInterface) {
65  $id = $request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0;
66  }
67  $pageRecord = BackendUtility::readPageAccess($id, ‪$GLOBALS['BE_USER']->getPagePermsClause(‪Permission::PAGE_SHOW));
68  // Is this a real page
69  if ($pageRecord['_thePathFull'] ?? false) {
70  $title = (string)$pageRecord['_thePathFull'];
71  } else {
72  $title = (string)‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
73  }
74  // Setting the path of the page
75  $pagePath = htmlspecialchars(self::getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
76  // crop the title to title limit (or 50, if not defined)
77  $cropLength = empty(‪$GLOBALS['BE_USER']->uc['titleLen']) ? 50 : ‪$GLOBALS['BE_USER']->uc['titleLen'];
78  $cropLength = (int)$cropLength;
79  $croppedTitle = ‪GeneralUtility::fixed_lgd_cs($title, -$cropLength);
80  if ($croppedTitle !== $title) {
81  $pagePath .= '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
82  } else {
83  $pagePath .= htmlspecialchars($title);
84  }
85  $pagePath .= '</span>';
86  return $pagePath;
87  }
88 
89  protected static function ‪getLanguageService(): ‪LanguageService
90  {
91  return ‪$GLOBALS['LANG'];
92  }
93 }
‪TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs
‪static string fixed_lgd_cs(string $string, int $chars, string $appendString='...')
Definition: GeneralUtility.php:92
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PagePathViewHelper
Definition: PagePathViewHelper.php:46
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PagePathViewHelper\getLanguageService
‪static getLanguageService()
Definition: PagePathViewHelper.php:88
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PagePathViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: PagePathViewHelper.php:51
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:30
‪TYPO3\CMS\Fluid\ViewHelpers\Be
Definition: AbstractBackendViewHelper.php:18
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PagePathViewHelper\render
‪render()
Definition: PagePathViewHelper.php:53
‪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\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
Definition: RenderingContext.php:35
‪TYPO3\CMS\Fluid\ViewHelpers\Be\PagePathViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PagePathViewHelper.php:58