Revert "[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 script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * *
12 * This script is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15 * General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with the script. *
19 * If not, see http://www.gnu.org/licenses/lgpl.html *
20 * *
21 * The TYPO3 project - inspiring people to share! *
22 * */
23 /**
24 * View helper which returns the current page path as known from TYPO3 backend modules
25 * Note: This view helper is experimental!
26 *
27 * = Examples =
28 *
29 * <code>
30 * <f:be.pagePath />
31 * </code>
32 * <output>
33 * Current page path, prefixed with "Path:" and wrapped in a span with the class "typo3-docheader-pagePath"
34 * </output>
35 */
36 class PagePathViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
37
38 /**
39 * Renders the current page path
40 *
41 * @return string the rendered page path
42 * @see template::getPagePath() Note: can't call this method as it's protected!
43 */
44 public function render() {
45 $id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
46 $pageRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1));
47 // Is this a real page
48 if ($pageRecord['uid']) {
49 $title = $pageRecord['_thePathFull'];
50 } else {
51 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
52 }
53 // Setting the path of the page
54 $pagePath = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.path', TRUE) . ': <span class="typo3-docheader-pagePath">';
55 // crop the title to title limit (or 50, if not defined)
56 $cropLength = empty($GLOBALS['BE_USER']->uc['titleLen']) ? 50 : $GLOBALS['BE_USER']->uc['titleLen'];
57 $croppedTitle = \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($title, -$cropLength);
58 if ($croppedTitle !== $title) {
59 $pagePath .= '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
60 } else {
61 $pagePath .= htmlspecialchars($title);
62 }
63 $pagePath .= '</span>';
64 return $pagePath;
65 }
66 }