TYPO3 API  SVNRelease
ShortcutViewHelper.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 returns shortcut button with icon
00024  * Note: This view helper is experimental!
00025  *
00026  * = Examples =
00027  *
00028  * <code title="Default">
00029  * <f:be.buttons.shortcut />
00030  * </code>
00031  * <output>
00032  * Shortcut button as known from the TYPO3 backend.
00033  * By default the current page id, module name and all module arguments will be stored
00034  * </output>
00035  *
00036  * <code title="Explicitly set parameters to be stored in the shortcut">
00037  * <f:be.buttons.shortcut getVars="{0: 'M', 1: 'myOwnPrefix'}" setVars="{0: 'function'}" />
00038  * </code>
00039  * <output>
00040  * Shortcut button as known from the TYPO3 backend.
00041  * This time only the specified GET parameters and SET[]-settings will be stored.
00042  * Note:
00043  * Normally you won't need to set getVars & setVars parameters in Extbase modules
00044  * </output>
00045  *
00046  * @author Steffen Kamper <info@sk-typo3.de>
00047  * @author Bastian Waidelich <bastian@typo3.org>
00048  * @license http://www.gnu.org/copyleft/gpl.html
00049  */
00050 class Tx_Fluid_ViewHelpers_Be_Buttons_ShortcutViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
00051 
00052 
00053     /**
00054      * Renders a shortcut button as known from the TYPO3 backend
00055      *
00056      * @param array $getVars list of GET variables to store. By default the current id, module and all module arguments will be stored
00057      * @param array $setVars list of SET[] variables to store. See template::makeShortcutIcon(). Normally won't be used by Extbase modules
00058      * @return string the rendered shortcut button
00059      * @see template::makeShortcutIcon()
00060      */
00061     public function render(array $getVars = array(), array $setVars = array()) {
00062         $doc = $this->getDocInstance();
00063         $currentRequest = $this->controllerContext->getRequest();
00064         $extensionName = $currentRequest->getControllerExtensionName();
00065         $moduleName = $currentRequest->getPluginName();
00066 
00067         if (count($getVars) === 0) {
00068             $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
00069             $getVars = array('id', 'M', $modulePrefix);
00070         }
00071         $getList = implode(',', $getVars);
00072         $setList = implode(',', $setVars);
00073 
00074         return $doc->makeShortcutIcon($getList, $setList, $moduleName);
00075     }
00076 }
00077 ?>