Revert "[CLEANUP] Rework/simplify copyright header and remove @package"
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / PageInfoViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Be;
3
4 use \TYPO3\CMS\Backend\Utility\BackendUtility;
5 use \TYPO3\CMS\Backend\Utility\IconUtility;
6
7 /* *
8 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
9 * *
10 * It is free software; you can redistribute it and/or modify it under *
11 * the terms of the GNU Lesser General Public License, either version 3 *
12 * of the License, or (at your option) any later version. *
13 * *
14 * *
15 * This script is distributed in the hope that it will be useful, but *
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
17 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
18 * General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU Lesser General Public *
21 * License along with the script. *
22 * If not, see http://www.gnu.org/licenses/lgpl.html *
23 * *
24 * The TYPO3 project - inspiring people to share! *
25 * */
26 /**
27 * View helper which return page info icon as known from TYPO3 backend modules
28 * Note: This view helper is experimental!
29 *
30 * = Examples =
31 *
32 * <code>
33 * <f:be.pageInfo />
34 * </code>
35 * <output>
36 * Page info icon with context menu
37 * </output>
38 */
39 class PageInfoViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
40
41 /**
42 * Render javascript in header
43 *
44 * @return string the rendered page info icon
45 * @see template::getPageInfo() Note: can't call this method as it's protected!
46 */
47 public function render() {
48 $doc = $this->getDocInstance();
49 $id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
50 $pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1));
51 // Add icon with clickmenu, etc:
52 if ($pageRecord['uid']) {
53 // If there IS a real page
54 $alttext = BackendUtility::getRecordIconAltText($pageRecord, 'pages');
55 $iconImg = IconUtility::getSpriteIconForRecord('pages', $pageRecord, array('title' => htmlspecialchars($alttext)));
56 // Make Icon:
57 $theIcon = $doc->wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
58 } else {
59 // On root-level of page tree
60 // Make Icon
61 $iconImg = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_website.gif') . ' alt="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '" />';
62 if ($GLOBALS['BE_USER']->user['admin']) {
63 $theIcon = $doc->wrapClickMenuOnIcon($iconImg, 'pages', 0);
64 } else {
65 $theIcon = $iconImg;
66 }
67 }
68 // Setting icon with clickmenu + uid
69 $pageInfo = $theIcon . '<em>[pid: ' . $pageRecord['uid'] . ']</em>';
70 return $pageInfo;
71 }
72 }