TYPO3 API  SVNRelease
PageInfoViewHelper.php
Go to the documentation of this file.
00001 <?php
00002 /*                                                                        *
00003  * This script belongs to the FLOW3 package "Fluid".                      *
00004  *                                                                        *
00005  * It is free software; you can redistribute it and/or modify it under    *
00006  * the terms of the GNU Lesser General Public License as published by the *
00007  * Free Software Foundation, either version 3 of the License, or (at your *
00008  * option) any later version.                                             *
00009  *                                                                        *
00010  * This script is distributed in the hope that it will be useful, but     *
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
00012  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
00013  * General Public License for more details.                               *
00014  *                                                                        *
00015  * You should have received a copy of the GNU Lesser General Public       *
00016  * License along with the script.                                         *
00017  * If not, see http://www.gnu.org/licenses/lgpl.html                      *
00018  *                                                                        *
00019  * The TYPO3 project - inspiring people to share!                         *
00020  *                                                                        */
00021 
00022 /**
00023  * View helper which return page info icon as known from TYPO3 backend modules
00024  * Note: This view helper is experimental!
00025  *
00026  * = Examples =
00027  *
00028  * <code>
00029  * <f:be.pageInfo />
00030  * </code>
00031  * <output>
00032  * Page info icon with context menu
00033  * </output>
00034  *
00035  * @author Steffen Kamper <info@sk-typo3.de>
00036  * @author Bastian Waidelich <bastian@typo3.org>
00037  * @license http://www.gnu.org/copyleft/gpl.html
00038  */
00039 class Tx_Fluid_ViewHelpers_Be_PageInfoViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
00040 
00041 
00042     /**
00043      * Render javascript in header
00044      *
00045      * @return string the rendered page info icon
00046      * @see template::getPageInfo() Note: can't call this method as it's protected!
00047      */
00048     public function render() {
00049         $doc = $this->getDocInstance();
00050         $id = t3lib_div::_GP('id');
00051         $pageRecord = t3lib_BEfunc::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1));
00052 
00053                 // Add icon with clickmenu, etc:
00054         if ($pageRecord['uid']) {   // If there IS a real page
00055             $alttext = t3lib_BEfunc::getRecordIconAltText($pageRecord, 'pages');
00056             $iconImg = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageRecord, array('title' => htmlspecialchars($alttext)));
00057                 // Make Icon:
00058             $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
00059         } else {    // On root-level of page tree
00060                 // Make Icon
00061             $iconImg = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif') . ' alt="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '" />';
00062             if($BE_USER->user['admin']) {
00063                 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', 0);
00064             } else {
00065                 $theIcon = $iconImg;
00066             }
00067         }
00068 
00069             // Setting icon with clickmenu + uid
00070         $pageInfo = $theIcon . '<em>[pid: ' . $pageRecord['uid'] . ']</em>';
00071         return $pageInfo;
00072     }
00073 }
00074 ?>