TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
fluid/Classes/ViewHelpers/Be/PageRendererViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\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 
20 
37 {
41  protected $pageRenderer;
42 
47  {
48  $this->pageRenderer = $pageRenderer;
49  }
50 
56  public function initializeArguments()
57  {
58  parent::initializeArguments();
59  $this->registerArgument('pageTitle', 'string', 'title tag of the module. Not required by default, as BE modules are shown in a frame', false, '');
60  $this->registerArgument('loadExtJs', 'bool', 'specifies whether to load ExtJS library. Defaults to FALSE', false, false);
61  $this->registerArgument('loadExtJsTheme', 'bool', 'whether to load ExtJS "grey" theme. Defaults to FALSE', false, true);
62  $this->registerArgument('enableExtJsDebug', 'bool', 'if TRUE, debug version of ExtJS is loaded. Use this for development only', false, false);
63  $this->registerArgument('loadJQuery', 'bool', 'whether to load jQuery library. Defaults to FALSE', false, false);
64  $this->registerArgument('includeCssFiles', 'array', 'List of custom CSS file to be loaded');
65  $this->registerArgument('includeJsFiles', 'array', 'List of custom JavaScript file to be loaded');
66  $this->registerArgument('addJsInlineLabels', 'array', 'Custom labels to add to JavaScript inline labels');
67  $this->registerArgument('includeRequireJsModules', 'array', 'List of RequireJS modules to be loaded');
68  $this->registerArgument('jQueryNamespace', 'string', 'Store the jQuery object in a specific namespace');
69  }
70 
74  public function render()
75  {
76  $pageTitle = $this->arguments['pageTitle'];
77  $loadExtJs = $this->arguments['loadExtJs'];
78  $loadExtJsTheme = $this->arguments['loadExtJsTheme'];
79  $enableExtJsDebug = $this->arguments['enableExtJsDebug'];
80  $loadJQuery = $this->arguments['loadJQuery'];
81  $includeCssFiles = $this->arguments['includeCssFiles'];
82  $includeJsFiles = $this->arguments['includeJsFiles'];
83  $addJsInlineLabels = $this->arguments['addJsInlineLabels'];
84  $includeRequireJsModules = $this->arguments['includeRequireJsModules'];
85  $jQueryNamespace = $this->arguments['jQueryNamespace'];
86 
87  if ($pageTitle) {
88  $this->pageRenderer->setTitle($pageTitle);
89  }
90  if ($loadExtJs) {
91  $this->pageRenderer->loadExtJS(true, $loadExtJsTheme);
92  if ($enableExtJsDebug) {
93  $this->pageRenderer->enableExtJsDebug();
94  }
95  }
96  if ($loadJQuery) {
97  $jQueryNamespace = $jQueryNamespace ?: PageRenderer::JQUERY_NAMESPACE_DEFAULT;
98  $this->pageRenderer->loadJquery(null, null, $jQueryNamespace);
99  }
100  // Include custom CSS and JS files
101  if (is_array($includeCssFiles) && count($includeCssFiles) > 0) {
102  foreach ($includeCssFiles as $addCssFile) {
103  $this->pageRenderer->addCssFile($addCssFile);
104  }
105  }
106  if (is_array($includeJsFiles) && count($includeJsFiles) > 0) {
107  foreach ($includeJsFiles as $addJsFile) {
108  $this->pageRenderer->addJsFile($addJsFile);
109  }
110  }
111  if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) {
112  foreach ($includeRequireJsModules as $addRequireJsFile) {
113  $this->pageRenderer->loadRequireJsModule($addRequireJsFile);
114  }
115  }
116  // Add inline language labels
117  if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
118  $extensionKey = $this->controllerContext->getRequest()->getControllerExtensionKey();
119  foreach ($addJsInlineLabels as $key) {
120  $label = LocalizationUtility::translate($key, $extensionKey);
121  $this->pageRenderer->addInlineLanguageLabel($key, $label);
122  }
123  }
124  }
125 }
static translate($key, $extensionName, $arguments=null)