[+TASK] Fluid (ViewHelpers): Fix, cleanup and extend inline documentation of ViewHelpers
[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 * <output>
32 * Shortcut button as known from the TYPO3 backend.
33 * By default the current page id, module name and all module arguments will be stored
34 * </output>
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 * <output>
40 * Shortcut button as known from the TYPO3 backend.
41 * This time only the specified GET parameters and SET[]-settings will be stored.
42 * Note:
43 * Normally you won't need to set getVars & setVars parameters in Extbase modules
44 * </output>
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 */
50 class Tx_Fluid_ViewHelpers_Be_Buttons_ShortcutViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
51
52
53 /**
54 * Renders a shortcut button as known from the TYPO3 backend
55 *
56 * @param array $getVars list of GET variables to store. By default the current id, module and all module arguments will be stored
57 * @param array $setVars list of SET[] variables to store. See template::makeShortcutIcon(). Normally won't be used by Extbase modules
58 * @return string the rendered shortcut button
59 * @see template::makeShortcutIcon()
60 */
61 public function render(array $getVars = array(), array $setVars = array()) {
62 $doc = $this->getDocInstance();
63 $currentRequest = $this->controllerContext->getRequest();
64 $extensionName = $currentRequest->getControllerExtensionName();
65 $moduleName = $currentRequest->getPluginName();
66
67 if (count($getVars) === 0) {
68 $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
69 $getVars = array('id', 'M', $modulePrefix);
70 }
71 $getList = implode(',', $getVars);
72 $setList = implode(',', $setVars);
73
74 return $doc->makeShortcutIcon($getList, $setList, $moduleName);
75 }
76 }
77 ?>