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