‪TYPO3CMS  10.4
ContainerViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 
50 {
54  protected ‪$escapeOutput = false;
55 
61  public function ‪initializeArguments()
62  {
63  parent::initializeArguments();
64  $this->registerArgument('pageTitle', 'string', 'Title tag of the module. Not required by default, as BE modules are shown in a frame', false, '');
65  $this->registerArgument('includeCssFiles', 'array', 'List of custom CSS file to be loaded');
66  $this->registerArgument('includeJsFiles', 'array', 'List of custom JavaScript file to be loaded');
67  $this->registerArgument('addJsInlineLabels', 'array', 'Custom labels to add to JavaScript inline labels');
68  $this->registerArgument('includeRequireJsModules', 'array', 'List of RequireJS modules to be loaded');
69  $this->registerArgument('enableDocHeader', 'bool', 'Add an empty doc header', false);
70  }
71 
78  public function ‪render()
79  {
80  $pageTitle = $this->arguments['pageTitle'];
81  $includeCssFiles = $this->arguments['includeCssFiles'];
82  $includeJsFiles = $this->arguments['includeJsFiles'];
83  $addJsInlineLabels = $this->arguments['addJsInlineLabels'];
84  $includeRequireJsModules = $this->arguments['includeRequireJsModules'];
85 
86  $moduleTemplate = $this->‪getModuleTemplate();
87  $pageRenderer = $moduleTemplate->getPageRenderer();
88 
89  // Include custom CSS and JS files
90  if (is_array($includeCssFiles) && count($includeCssFiles) > 0) {
91  foreach ($includeCssFiles as $addCssFile) {
92  $pageRenderer->addCssFile($addCssFile);
93  }
94  }
95  if (is_array($includeJsFiles) && count($includeJsFiles) > 0) {
96  foreach ($includeJsFiles as $addJsFile) {
97  $pageRenderer->addJsFile($addJsFile);
98  }
99  }
100  if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) {
101  foreach ($includeRequireJsModules as $addRequireJsFile) {
102  $pageRenderer->loadRequireJsModule($addRequireJsFile);
103  }
104  }
105  // Add inline language labels
106  if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
107  $extensionKey = $this->renderingContext->getControllerContext()->getRequest()->getControllerExtensionKey();
108  foreach ($addJsInlineLabels as $key) {
109  $label = ‪LocalizationUtility::translate($key, $extensionKey);
110  $pageRenderer->addInlineLanguageLabel($key, $label);
111  }
112  }
113  // Render the content and return it
114  ‪$output = $this->renderChildren();
115  if ($this->arguments['enableDocHeader'] ?? false) {
116  $moduleTemplate->getDocHeaderComponent()->enable();
117  } else {
118  $moduleTemplate->getDocHeaderComponent()->disable();
119  $moduleTemplate->getView()->setTemplate('EmptyModule.html');
120  }
121  $moduleTemplate->setTitle($pageTitle);
122  $moduleTemplate->setContent(‪$output);
123  return $moduleTemplate->renderContent();
124  }
125 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\initializeArguments
‪initializeArguments()
Definition: ContainerViewHelper.php:60
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:33
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:28
‪TYPO3\CMS\Fluid\ViewHelpers\Be
Definition: AbstractBackendViewHelper.php:16
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ContainerViewHelper.php:53
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate(string $key, ?string $extensionName=null, array $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:67
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\render
‪string render()
Definition: ContainerViewHelper.php:77
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper
Definition: ContainerViewHelper.php:50
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper\getModuleTemplate
‪ModuleTemplate getModuleTemplate()
Definition: AbstractBackendViewHelper.php:35