[TASK] Rebuild extension translation list in lang module
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Classes / ViewHelpers / Be / ContainerViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Lang\ViewHelpers\Be;
3 /***************************************************************
4 * Copyright notice
5 *
6 * (c) 2012 Kai Vogel <kai.vogel@speedprogs.de>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25 /**
26 * View helper which allows you to create extbase based modules in the style of TYPO3 default modules.
27 * Note: This feature is experimental!
28 *
29 * = Examples =
30 *
31 * <code title="Simple">
32 * <f:be.container>your module content</f:be.container>
33 * </code>
34 * <output>
35 * "your module content" wrapped with propper head & body tags.
36 * Default backend CSS styles and JavaScript will be included
37 * </output>
38 *
39 * <code title="All options">
40 * <f:be.container pageTitle="foo" enableJumpToUrl="false" enableClickMenu="false" loadPrototype="false" loadScriptaculous="false" loadJQuery="false" scriptaculousModule="someModule,someOtherModule" loadExtJs="true" loadExtJsTheme="false" extJsAdapter="jQuery" enableExtJsDebug="true" addCssFile="{f:uri.resource(path:'styles/backend.css')}" addJsFile="{f:uri.resource(path:'scripts/main.js')}">your module content</f:be.container>
41 * </code>
42 * <output>
43 * "your module content" wrapped with propper head & body tags.
44 * Custom CSS file EXT:your_extension/Resources/Public/styles/backend.css and JavaScript file EXT:your_extension/Resources/Public/scripts/main.js will be loaded
45 * </output>
46 */
47 class ContainerViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
48
49 /**
50 * Render start page with template.php and pageTitle
51 *
52 * @param string $pageTitle title tag of the module. Not required by default, as BE modules are shown in a frame
53 * @param boolean $enableJumpToUrl If TRUE, includes "jumpTpUrl" javascript function required by ActionMenu. Defaults to TRUE
54 * @param boolean $enableClickMenu If TRUE, loads clickmenu.js required by BE context menus. Defaults to TRUE
55 * @param boolean $loadPrototype specifies whether to load prototype library. Defaults to TRUE
56 * @param boolean $loadScriptaculous specifies whether to load scriptaculous libraries. Defaults to FALSE
57 * @param string $scriptaculousModule additionales modules for scriptaculous
58 * @param boolean $loadExtJs specifies whether to load ExtJS library. Defaults to FALSE
59 * @param boolean $loadExtJsTheme whether to load ExtJS "grey" theme. Defaults to FALSE
60 * @param string $extJsAdapter load alternative adapter (ext-base is default adapter)
61 * @param boolean $enableExtJsDebug if TRUE, debug version of ExtJS is loaded. Use this for development only
62 * @param boolean $loadJQuery whether to load jQuery library. Defaults to FALSE
63 * @param array $addCssFiles Custom CSS files to be loaded
64 * @param array $addJsFiles Custom JavaScript files to be loaded
65 * @param array $addJsInlineLabels Custom labels to add to JavaScript inline labels
66 * @return string
67 * @see template
68 * @see t3lib_PageRenderer
69 */
70 public function render($pageTitle = '', $enableJumpToUrl = TRUE, $enableClickMenu = TRUE, $loadPrototype = TRUE, $loadScriptaculous = FALSE, $scriptaculousModule = '', $loadExtJs = FALSE, $loadExtJsTheme = TRUE, $extJsAdapter = '', $enableExtJsDebug = FALSE, $loadJQuery = FALSE, $addCssFiles = NULL, $addJsFiles = NULL, $addJsInlineLabels = NULL) {
71 $doc = $this->getDocInstance();
72 $pageRenderer = $doc->getPageRenderer();
73 if ($enableJumpToUrl) {
74 $doc->JScode .= '
75 <script language="javascript" type="text/javascript">
76 script_ended = 0;
77 function jumpToUrl(URL) {
78 document.location = URL;
79 }
80 ' . $doc->redirectUrls() . '
81 </script>
82 ';
83 }
84 if ($enableClickMenu) {
85 $doc->loadJavascriptLib('js/clickmenu.js');
86 }
87 if ($loadPrototype) {
88 $pageRenderer->loadPrototype();
89 }
90 if ($loadScriptaculous) {
91 $pageRenderer->loadScriptaculous($scriptaculousModule);
92 }
93 if ($loadExtJs) {
94 $pageRenderer->loadExtJS(TRUE, $loadExtJsTheme, $extJsAdapter);
95 if ($enableExtJsDebug) {
96 $pageRenderer->enableExtJsDebug();
97 }
98 }
99 if ($loadJQuery) {
100 $pageRenderer->loadJquery();
101 }
102 if (is_array($addCssFiles)) {
103 foreach ($addCssFiles as $addCssFile) {
104 $pageRenderer->addCssFile($addCssFile);
105 }
106 }
107 if (is_array($addJsFiles)) {
108 foreach ($addJsFiles as $addJsFile) {
109 $pageRenderer->addJsFile($addJsFile);
110 }
111 }
112 if (is_array($addJsInlineLabels)) {
113 $extensionKey = $this->controllerContext->getRequest()->getControllerExtensionKey();
114 foreach ($addJsInlineLabels as $key) {
115 $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, $extensionKey);
116 $pageRenderer->addInlineLanguageLabel($key, $label);
117 }
118 }
119 $output = $this->renderChildren();
120 $output = $doc->startPage($pageTitle) . $output;
121 $output .= $doc->endPage();
122 return $output;
123 }
124
125 }
126 ?>