[CLEANUP] Rework/simplify copyright header and remove @package
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / PagePathViewHelper.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 backported from the TYPO3 Flow package "TYPO3.Fluid".
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 /**
20 * View helper which returns the current page path as known from TYPO3 backend modules
21 * Note: This view helper is experimental!
22 *
23 * = Examples =
24 *
25 * <code>
26 * <f:be.pagePath />
27 * </code>
28 * <output>
29 * Current page path, prefixed with "Path:" and wrapped in a span with the class "typo3-docheader-pagePath"
30 * </output>
31 */
32 class PagePathViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
33
34 /**
35 * Renders the current page path
36 *
37 * @return string the rendered page path
38 * @see template::getPagePath() Note: can't call this method as it's protected!
39 */
40 public function render() {
41 $id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
42 $pageRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1));
43 // Is this a real page
44 if ($pageRecord['uid']) {
45 $title = $pageRecord['_thePathFull'];
46 } else {
47 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
48 }
49 // Setting the path of the page
50 $pagePath = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.path', TRUE) . ': <span class="typo3-docheader-pagePath">';
51 // crop the title to title limit (or 50, if not defined)
52 $cropLength = empty($GLOBALS['BE_USER']->uc['titleLen']) ? 50 : $GLOBALS['BE_USER']->uc['titleLen'];
53 $croppedTitle = \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($title, -$cropLength);
54 if ($croppedTitle !== $title) {
55 $pagePath .= '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
56 } else {
57 $pagePath .= htmlspecialchars($title);
58 }
59 $pagePath .= '</span>';
60 return $pagePath;
61 }
62 }