Merge "[TASK] Increase version number"
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / Buttons / ShortcutViewHelper.php
1 <?php
2 /* *
3 * This script is backported from the FLOW3 package "TYPO3.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, either version 3 *
7 * of the License, or (at your option) any later version. *
8 * *
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 */
47 class Tx_Fluid_ViewHelpers_Be_Buttons_ShortcutViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
48
49
50 /**
51 * Renders a shortcut button as known from the TYPO3 backend
52 *
53 * @param array $getVars list of GET variables to store. By default the current id, module and all module arguments will be stored
54 * @param array $setVars list of SET[] variables to store. See template::makeShortcutIcon(). Normally won't be used by Extbase modules
55 * @return string the rendered shortcut button
56 * @see template::makeShortcutIcon()
57 */
58 public function render(array $getVars = array(), array $setVars = array()) {
59 $doc = $this->getDocInstance();
60 $currentRequest = $this->controllerContext->getRequest();
61 $extensionName = $currentRequest->getControllerExtensionName();
62 $moduleName = $currentRequest->getPluginName();
63
64 if (count($getVars) === 0) {
65 $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
66 $getVars = array('id', 'M', $modulePrefix);
67 }
68 $getList = implode(',', $getVars);
69 $setList = implode(',', $setVars);
70
71 return $doc->makeShortcutIcon($getList, $setList, $moduleName);
72 }
73 }
74 ?>