[CLEANUP] Add @internal to all ViewHelpers except EXT:fluid
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / ViewHelpers / Be / ContainerViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Install\ViewHelpers\Be;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * View helper which allows you to create extbase based modules in the
19 * style of TYPO3 default modules.
20 * Note: This feature is experimental!
21 *
22 * = Examples =
23 *
24 * <code title="Simple">
25 * <f:be.container>your module content</f:be.container>
26 * </code>
27 * <output>
28 * "your module content" wrapped with proper head & body tags.
29 * Default backend CSS styles and JavaScript will be included
30 * </output>
31 *
32 * <code title="All options">
33 * <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>
34 * </code>
35 * <output>
36 * "your module content" wrapped with propper head & body tags.
37 * 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
38 * </output>
39 *
40 * @internal
41 */
42 class ContainerViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
43
44 /**
45 * Render start page with \TYPO3\CMS\Backend\Template\DocumentTemplate and pageTitle
46 *
47 * @param string $pageTitle title tag of the module. Not required by default, as BE modules are shown in a frame
48 * @param bool $enableJumpToUrl If TRUE, includes "jumpTpUrl" javascript function required by ActionMenu. Defaults to TRUE, not needed anymore, as it is included all the time
49 * @param bool $enableClickMenu If TRUE, loads clickmenu.js required by BE context menus. Defaults to TRUE
50 * @param bool $loadPrototype specifies whether to load prototype library. Defaults to TRUE
51 * @param bool $loadScriptaculous specifies whether to load scriptaculous libraries. Defaults to FALSE
52 * @param string $scriptaculousModule additionales modules for scriptaculous
53 * @param bool $loadExtJs specifies whether to load ExtJS library. Defaults to FALSE
54 * @param bool $loadExtJsTheme whether to load ExtJS "grey" theme. Defaults to FALSE
55 * @param string $extJsAdapter load alternative adapter (ext-base is default adapter)
56 * @param bool $enableExtJsDebug if TRUE, debug version of ExtJS is loaded. Use this for development only
57 * @param array $addCssFiles Custom CSS files to be loaded
58 * @param array $addJsFiles Custom JavaScript files to be loaded
59 * @param array $triggers Defined triggers to be forwarded to client (e.g. refreshing backend widgets)
60 *
61 * @return string
62 * @see \TYPO3\CMS\Backend\Template\DocumentTemplate
63 * @see \TYPO3\CMS\Core\Page\PageRenderer
64 */
65 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()) {
66 $doc = $this->getDocInstance();
67 $pageRenderer = $doc->getPageRenderer();
68
69 $doc->JScode .= $doc->wrapScriptTags($doc->redirectUrls());
70 if ($enableClickMenu) {
71 $doc->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/clickmenu.js');
72 }
73 if ($loadPrototype) {
74 $pageRenderer->loadPrototype();
75 }
76 if ($loadScriptaculous) {
77 $pageRenderer->loadScriptaculous($scriptaculousModule);
78 }
79 if ($loadExtJs) {
80 $pageRenderer->loadExtJS(TRUE, $loadExtJsTheme, $extJsAdapter);
81 if ($enableExtJsDebug) {
82 $pageRenderer->enableExtJsDebug();
83 }
84 }
85 if (is_array($addCssFiles) && count($addCssFiles) > 0) {
86 foreach ($addCssFiles as $addCssFile) {
87 $pageRenderer->addCssFile($addCssFile);
88 }
89 }
90 if (is_array($addJsFiles) && count($addJsFiles) > 0) {
91 foreach ($addJsFiles as $addJsFile) {
92 $pageRenderer->addJsFile($addJsFile);
93 }
94 }
95 // Handle triggers
96 if (!empty($triggers[\TYPO3\CMS\Extensionmanager\Controller\AbstractController::TRIGGER_RefreshModuleMenu])) {
97 $pageRenderer->addJsInlineCode(
98 \TYPO3\CMS\Extensionmanager\Controller\AbstractController::TRIGGER_RefreshModuleMenu,
99 'if (top.TYPO3ModuleMenu.refreshMenu) { top.TYPO3ModuleMenu.refreshMenu(); }'
100 );
101 }
102 $output = $this->renderChildren();
103 $output = $doc->startPage($pageTitle) . $output;
104 $output .= $doc->endPage();
105 return $output;
106 }
107 }