TYPO3 CMS  TYPO3_8-7
AbstractFormEngineAjaxController.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
22 
31 {
40  {
41  if (empty($result['requireJsModules'])) {
42  return [];
43  }
44  $requireJs = [];
45  foreach ($result['requireJsModules'] as $module) {
46  $moduleName = null;
47  $callback = null;
48  if (is_string($module)) {
49  // if $module is a string, no callback
50  $moduleName = $module;
51  $callback = null;
52  } elseif (is_array($module)) {
53  // if $module is an array, callback is possible
54  foreach ($module as $key => $value) {
55  $moduleName = $key;
56  $callback = $value;
57  break;
58  }
59  }
60  if ($moduleName !== null) {
61  $inlineCodeKey = $moduleName;
62  $javaScriptCode = 'require(["' . $moduleName . '"]';
63  if ($callback !== null) {
64  $inlineCodeKey .= sha1($callback);
65  $javaScriptCode .= ', ' . $callback;
66  }
67  $javaScriptCode .= ');';
68  $requireJs[] = '/*RequireJS-Module-' . $inlineCodeKey . '*/' . LF . $javaScriptCode;
69  }
70  }
71  return $requireJs;
72  }
73 
80  protected function getRelativePathToStylesheetFile(string $stylesheetFile): string
81  {
82  if (strpos($stylesheetFile, 'EXT:') === 0) {
83  $stylesheetFile = GeneralUtility::getFileAbsFileName($stylesheetFile);
84  $stylesheetFile = PathUtility::getRelativePathTo($stylesheetFile);
85  $stylesheetFile = rtrim($stylesheetFile, '/');
86  } else {
87  $stylesheetFile = GeneralUtility::resolveBackPath($stylesheetFile);
88  }
89  $stylesheetFile = GeneralUtility::createVersionNumberedFilename($stylesheetFile);
90  return PathUtility::getAbsoluteWebPath($stylesheetFile);
91  }
92 
99  protected function getLabelsFromLocalizationFile($file)
100  {
102  $languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
103  $language = $GLOBALS['LANG']->lang;
104  $localizationArray = $languageFactory->getParsedData(
105  $file,
106  $language,
107  'utf-8',
108  1
109  );
110  if (is_array($localizationArray) && !empty($localizationArray)) {
111  if (!empty($localizationArray[$language])) {
112  $xlfLabelArray = $localizationArray['default'];
113  ArrayUtility::mergeRecursiveWithOverrule($xlfLabelArray, $localizationArray[$language], true, false);
114  } else {
115  $xlfLabelArray = $localizationArray['default'];
116  }
117  } else {
118  $xlfLabelArray = [];
119  }
120  $labelArray = [];
121  foreach ($xlfLabelArray as $key => $value) {
122  if (isset($value[0]['target'])) {
123  $labelArray[$key] = $value[0]['target'];
124  } else {
125  $labelArray[$key] = '';
126  }
127  }
128  return $labelArray;
129  }
130 }
static getRelativePathTo($targetPath)
Definition: PathUtility.php:29
static getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:40
static getFileAbsFileName($filename, $_=null, $_2=null)
static makeInstance($className,... $constructorArguments)
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']