* Raised Extbase and Fluid versions to 1.3.0alpha1. See their ChangeLog.txt for full...
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / Buttons / ShortcutViewHelper.php
1 <?php
2 /* *
3 * This script belongs to the FLOW3 package "Fluid". *
4 * *
5 * It is free software; you can redistribute it and/or modify it under *
6 * the terms of the GNU Lesser General Public License as published by the *
7 * Free Software Foundation, either version 3 of the License, or (at your *
8 * option) any later version. *
9 * *
10 * This script is distributed in the hope that it will be useful, but *
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
13 * General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with the script. *
17 * If not, see http://www.gnu.org/licenses/lgpl.html *
18 * *
19 * The TYPO3 project - inspiring people to share! *
20 * */
21
22 /**
23 * View helper which returns shortcut button with icon
24 * Note: This view helper is experimental!
25 *
26 * = Examples =
27 *
28 * <code title="Default">
29 * <f:be.buttons.shortcut />
30 * </code>
31 *
32 * Output:
33 * Shortcut button as known from the TYPO3 backend.
34 * By default the current page id, module name and all module arguments will be stored
35 *
36 * <code title="Explicitly set parameters to be stored in the shortcut">
37 * <f:be.buttons.shortcut getVars="{0: 'M', 1: 'myOwnPrefix'}" setVars="{0: 'function'}" />
38 * </code>
39 *
40 * Output:
41 * Shortcut button as known from the TYPO3 backend.
42 * This time only the specified GET parameters and SET[]-settings will be stored.
43 * Note:
44 * Normally you won't need to set getVars & setVars parameters in Extbase modules
45 *
46 * @author Steffen Kamper <info@sk-typo3.de>
47 * @author Bastian Waidelich <bastian@typo3.org>
48 * @license http://www.gnu.org/copyleft/gpl.html
49 * @version SVN: $Id:
50 *
51 */
52 class Tx_Fluid_ViewHelpers_Be_Buttons_ShortcutViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
53
54
55 /**
56 * Renders a shortcut button as known from the TYPO3 backend
57 *
58 * @param array $getVars list of GET variables to store. By default the current id, module and all module arguments will be stored
59 * @param array $setVars list of SET[] variables to store. See template::makeShortcutIcon(). Normally won't be used by Extbase modules
60 * @return string the rendered shortcut button
61 * @see template::makeShortcutIcon()
62 */
63 public function render(array $getVars = array(), array $setVars = array()) {
64 $doc = $this->getDocInstance();
65 $currentRequest = $this->controllerContext->getRequest();
66 $extensionName = $currentRequest->getControllerExtensionName();
67 $moduleName = $currentRequest->getPluginName();
68
69 if (count($getVars) === 0) {
70 $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
71 $getVars = array('id', 'M', $modulePrefix);
72 }
73 $getList = implode(',', $getVars);
74 $setList = implode(',', $setVars);
75
76 return $doc->makeShortcutIcon($getList, $setList, $moduleName);
77 }
78 }
79 ?>