‪TYPO3CMS  9.5
ContainerViewHelper.php
Go to the documentation of this file.
1 <?php
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 
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  }
70 
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  $pageRenderer = $this->‪getPageRenderer();
87  $doc = $this->‪getDocInstance();
88  $doc->JScode .= GeneralUtility::wrapJS($doc->redirectUrls());
89 
90  // Include custom CSS and JS files
91  if (is_array($includeCssFiles) && count($includeCssFiles) > 0) {
92  foreach ($includeCssFiles as $addCssFile) {
93  $pageRenderer->addCssFile($addCssFile);
94  }
95  }
96  if (is_array($includeJsFiles) && count($includeJsFiles) > 0) {
97  foreach ($includeJsFiles as $addJsFile) {
98  $pageRenderer->addJsFile($addJsFile);
99  }
100  }
101  if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) {
102  foreach ($includeRequireJsModules as $addRequireJsFile) {
103  $pageRenderer->loadRequireJsModule($addRequireJsFile);
104  }
105  }
106  // Add inline language labels
107  if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
108  $extensionKey = $this->renderingContext->getControllerContext()->getRequest()->getControllerExtensionKey();
109  foreach ($addJsInlineLabels as $key) {
110  $label = ‪LocalizationUtility::translate($key, $extensionKey);
111  $pageRenderer->addInlineLanguageLabel($key, $label);
112  }
113  }
114  // Render the content and return it
115  ‪$output = $this->renderChildren();
116  ‪$output = $doc->startPage($pageTitle) . ‪$output;
117  ‪$output .= $doc->endPage();
118  return ‪$output;
119  }
120 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper\getPageRenderer
‪PageRenderer getPageRenderer()
Definition: AbstractBackendViewHelper.php:54
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\initializeArguments
‪initializeArguments()
Definition: ContainerViewHelper.php:60
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:29
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:27
‪TYPO3\CMS\Fluid\ViewHelpers\Be
Definition: AbstractBackendViewHelper.php:2
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ContainerViewHelper.php:53
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate($key, $extensionName=null, $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:63
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\render
‪string render()
Definition: ContainerViewHelper.php:77
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper\getDocInstance
‪DocumentTemplate getDocInstance()
Definition: AbstractBackendViewHelper.php:34
‪$output
‪$output
Definition: annotationChecker.php:113
‪TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper
Definition: ContainerViewHelper.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45