TYPO3 CMS  TYPO3_7-6
ContentObjectHook.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 
23 
28 {
44  public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, ContentObjectRenderer $contentObject)
45  {
46  $content = '';
47  if (
48  $typoScriptObjectName === 'FORM'
49  && !empty($typoScript['useDefaultContentObject'])
50  && ExtensionManagementUtility::isLoaded('compatibility6')
51  ) {
52  $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript);
53  } elseif ($typoScriptObjectName === 'FORM') {
54  $mergedTypoScript = null;
55  if ($contentObject->data['CType'] === 'mailform') {
56  $bodytext = $contentObject->data['bodytext'];
58  $typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class);
59  $typoScriptParser->parse($bodytext);
60  $mergedTypoScript = (array)$typoScriptParser->setup;
61  ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript);
62  // Disables content elements since TypoScript is handled that could contain insecure settings:
63  $mergedTypoScript[Configuration::DISABLE_CONTENT_ELEMENT_RENDERING] = true;
64  }
65  $newTypoScript = [
66  '10' => 'FORM_INT',
67  '10.' => (is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript),
68  ];
69  $content = $contentObject->cObjGetSingle('COA_INT', $newTypoScript);
70  // Only apply stdWrap to TypoScript that was NOT created by the wizard:
71  if (isset($typoScript['stdWrap.'])) {
72  $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']);
73  }
74  } elseif ($typoScriptObjectName === 'FORM_INT') {
75  $extbase = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
76  $content = $extbase->run('', [
77  'pluginName' => 'Form',
78  'extensionName' => 'Form',
79  'vendorName' => 'TYPO3\\CMS',
80  'controller' => 'Frontend',
81  'action' => 'show',
82  'settings' => ['typoscript' => $typoScript],
83  'persistence' => [],
84  'view' => [],
85  ]);
86  }
87  return $content;
88  }
89 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)