[TASK][WIP] Move non class code back to source files
[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 * View helper which returns shortcut button with icon
23 * Note: This view helper is experimental!
24 *
25 * = Examples =
26 *
27 * <code title="Default">
28 * <f:be.buttons.shortcut />
29 * </code>
30 * <output>
31 * Shortcut button as known from the TYPO3 backend.
32 * By default the current page id, module name and all module arguments will be stored
33 * </output>
34 *
35 * <code title="Explicitly set parameters to be stored in the shortcut">
36 * <f:be.buttons.shortcut getVars="{0: 'M', 1: 'myOwnPrefix'}" setVars="{0: 'function'}" />
37 * </code>
38 * <output>
39 * Shortcut button as known from the TYPO3 backend.
40 * This time only the specified GET parameters and SET[]-settings will be stored.
41 * Note:
42 * Normally you won't need to set getVars & setVars parameters in Extbase modules
43 * </output>
44 */
45 class Tx_Fluid_ViewHelpers_Be_Buttons_ShortcutViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
46
47 /**
48 * Renders a shortcut button as known from the TYPO3 backend
49 *
50 * @param array $getVars list of GET variables to store. By default the current id, module and all module arguments will be stored
51 * @param array $setVars list of SET[] variables to store. See template::makeShortcutIcon(). Normally won't be used by Extbase modules
52 * @return string the rendered shortcut button
53 * @see template::makeShortcutIcon()
54 */
55 public function render(array $getVars = array(), array $setVars = array()) {
56 $doc = $this->getDocInstance();
57 $currentRequest = $this->controllerContext->getRequest();
58 $extensionName = $currentRequest->getControllerExtensionName();
59 $moduleName = $currentRequest->getPluginName();
60 if (count($getVars) === 0) {
61 $modulePrefix = strtolower((('tx_' . $extensionName) . '_') . $moduleName);
62 $getVars = array('id', 'M', $modulePrefix);
63 }
64 $getList = implode(',', $getVars);
65 $setList = implode(',', $setVars);
66 return $doc->makeShortcutIcon($getList, $setList, $moduleName);
67 }
68
69 }
70
71 ?>