/** * Renders the application defined cObject FORM * which overrides the TYPO3 default cObject FORM * * Convert FORM to COA_INT - COA_INT.10 = FORM_INT * If FORM_INT is also dedected by the ContentObjectRenderer, and now * the Extbaseplugin "Form" is initalized. At this time the * controller "Frontend" action "execute" do the rest. * * @param string $typoScriptObjectName Name of the object * @param array $typoScript TS configuration for this cObject * @param string $typoScriptKey A string label used for the internal debugging tracking. * @param ContentObjectRenderer $contentObject reference * @return string HTML output */ public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, ContentObjectRenderer $contentObject) { $content = ''; if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject']) && ExtensionManagementUtility::isLoaded('compatibility6')) { $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript); } elseif ($typoScriptObjectName === 'FORM') { $mergedTypoScript = null; if ($contentObject->data['CType'] === 'mailform') { $bodytext = $contentObject->data['bodytext']; /** @var $typoScriptParser TypoScriptParser */ $typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class); $typoScriptParser->parse($bodytext); $mergedTypoScript = (array) $typoScriptParser->setup; ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript); // Disables content elements since TypoScript is handled that could contain insecure settings: $mergedTypoScript[Configuration::DISABLE_CONTENT_ELEMENT_RENDERING] = true; } $newTypoScript = array('10' => 'FORM_INT', '10.' => is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript); $content = $contentObject->cObjGetSingle('COA_INT', $newTypoScript); // Only apply stdWrap to TypoScript that was NOT created by the wizard: if (isset($typoScript['stdWrap.'])) { $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']); } } elseif ($typoScriptObjectName === 'FORM_INT') { $extbase = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class); $content = $extbase->run('', array('pluginName' => 'Form', 'extensionName' => 'Form', 'vendorName' => 'TYPO3\\CMS', 'controller' => 'Frontend', 'action' => 'show', 'settings' => array('typoscript' => $typoScript), 'persistence' => array(), 'view' => array())); } return $content; }
/** * @test * @dataProvider getContentObjectValidContentObjectsDataProvider * @param string $name TypoScript name of content object * @param string $className Expected class name */ public function getContentObjectCallsMakeInstanceForNewContentObjectInstance($name, $className) { $fullClassName = 'TYPO3\\CMS\\Frontend\\ContentObject\\' . $className . 'ContentObject'; $contentObjectInstance = $this->getMock($fullClassName, array(), array(), '', FALSE); \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($fullClassName, $contentObjectInstance); $this->assertSame($contentObjectInstance, $this->cObj->getContentObject($name)); }
/** * Renders the application defined cObject FORM * which overrides the TYPO3 default cObject FORM * * If FORM is dedected by the ContentObjectRenderer, * the Extbase plugin "Form" is initialized. At this time, the * controller "Frontend" action "execute" does the rest. * * @param string $typoScriptObjectName Name of the object * @param array $typoScript TS configuration for this cObject * @param string $typoScriptKey A string label used for the internal debugging tracking. * @param ContentObjectRenderer $contentObject reference * @return string HTML output */ public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, ContentObjectRenderer $contentObject) { $content = ''; // render the FORM CE from TYPO3 < 4.6 if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject']) && ExtensionManagementUtility::isLoaded('compatibility6')) { $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript); } elseif ($typoScriptObjectName === 'FORM') { $mergedTypoScript = null; // If the FORM configuration comes from the database // all TypoScript interpretation will be disabled for security. if ($contentObject->data['CType'] === 'mailform') { // If the FORM configuration comes from the database // and a predefined form is selected than the TypoScript // interpretation is allowed. $renderPredefinedForm = false; if (isset($contentObject->data['tx_form_predefinedform']) && !empty($contentObject->data['tx_form_predefinedform'])) { $predefinedFormIdentifier = $contentObject->data['tx_form_predefinedform']; if (isset($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_form.']['predefinedForms.'][$predefinedFormIdentifier . '.'])) { $renderPredefinedForm = true; } else { throw new \InvalidArgumentException('No FORM configuration for identifier "' . $predefinedFormIdentifier . '" available.', 1457097250); } } if ($renderPredefinedForm) { $mergedTypoScript = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_form.']['predefinedForms.'][$predefinedFormIdentifier . '.']; ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript); } else { $bodytext = $contentObject->data['bodytext']; /** @var $typoScriptParser TypoScriptParser */ $typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class); $typoScriptParser->parse($bodytext); $mergedTypoScript = (array) $typoScriptParser->setup; ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, $typoScript); // Disables TypoScript interpretation since TypoScript is handled that could contain insecure settings: $mergedTypoScript[Configuration::DISABLE_CONTENT_ELEMENT_RENDERING] = true; } } $newTypoScript = is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript; $extbase = GeneralUtility::makeInstance(Bootstrap::class); $content = $extbase->run('', array('pluginName' => 'Form', 'extensionName' => 'Form', 'vendorName' => 'TYPO3\\CMS', 'controller' => 'Frontend', 'action' => 'show', 'settings' => array('typoscript' => $newTypoScript), 'persistence' => array(), 'view' => array())); // Only apply stdWrap to TypoScript that was NOT created by the wizard: if (isset($typoScript['stdWrap.'])) { $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']); } } return $content; }
/** * @test * @dataProvider getContentObjectValidContentObjectsDataProvider * @param string $name TypoScript name of content object * @param string $fullClassName Expected class name */ public function getContentObjectCallsMakeInstanceForNewContentObjectInstance($name, $fullClassName) { $contentObjectInstance = $this->getMock($fullClassName, array(), array(), '', false); \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($fullClassName, $contentObjectInstance); $this->assertSame($contentObjectInstance, $this->subject->getContentObject($name)); }
/** * Renders the application defined cObject FORM * which overrides the TYPO3 default cObject FORM * * First we make a COA_INT out of it, because it does not need to be cached * Then we send a FORM_INT to the COA_INT * When this is read, it will call the FORM class again. * * It simply calls execute because this function name is not really descriptive * but is needed by the core of TYPO3 * * @param string $typoScriptObjectName Name of the object * @param array $typoScript TS configuration for this cObject * @param string $typoScriptKey A string label used for the internal debugging tracking. * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject reference * @return string HTML output */ public function cObjGetSingleExt($typoScriptObjectName, array $typoScript, $typoScriptKey, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject) { $content = ''; if ($typoScriptObjectName === 'FORM' && !empty($typoScript['useDefaultContentObject'])) { $content = $contentObject->getContentObject($typoScriptObjectName)->render($typoScript); } elseif ($typoScriptObjectName === 'FORM') { if ($contentObject->data['CType'] === 'mailform') { $bodytext = $contentObject->data['bodytext']; /** @var $typoScriptParser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */ $typoScriptParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser'); $typoScriptParser->parse($bodytext); $mergedTypoScript = (array) $typoScriptParser->setup; \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, (array) $typoScript); // Disables content elements since TypoScript is handled that could contain insecure settings: $mergedTypoScript[\TYPO3\CMS\Form\Domain\Factory\TypoScriptFactory::PROPERTY_DisableContentElement] = TRUE; } $newTypoScript = array('10' => 'FORM_INT', '10.' => is_array($mergedTypoScript) ? $mergedTypoScript : $typoScript); $content = $contentObject->COBJ_ARRAY($newTypoScript, 'INT'); // Only apply stdWrap to TypoScript that was NOT created by the wizard: if (isset($typoScript['stdWrap.'])) { $content = $contentObject->stdWrap($content, $typoScript['stdWrap.']); } } elseif ($typoScriptObjectName === 'FORM_INT') { $this->initialize($typoScript); $content = $this->execute(); } return $content; }
/** * @param ContentObjectRenderer $cObj The data of the content element or page * @param array $contentObjectConfiguration The configuration of Content Object * @param array $processorConfiguration The configuration of this processor * @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View) * @return array the processed data as key/value store */ public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData) { $this->cObj = $cObj; $this->processorConfiguration = $processorConfiguration; // Get Configuration $this->menuLevels = (int) $this->getConfigurationValue('levels') ?: 1; $this->menuExpandAll = (int) $this->getConfigurationValue('expandAll'); $this->menuTargetVariableName = $this->getConfigurationValue('as'); $this->menuTitleField = $this->getConfigurationValue('titleField'); // Build Configuration $this->prepareConfiguration(); $this->prepareLevelConfiguration(); $this->prepareLevelLanguageConfiguration(); $this->buildConfiguration(); // Process Configuration $menuContentObject = $cObj->getContentObject('HMENU'); $renderedMenu = $menuContentObject->render($this->menuConfig); if (!$renderedMenu) { return $processedData; } // Process menu $menu = json_decode($renderedMenu, true); $processedMenu = array(); foreach ($menu as $key => $page) { $processedMenu[$key] = $this->processAdditionalDataProcessors($page, $processorConfiguration); } // Return processed data $processedData[$this->menuTargetVariableName] = $processedMenu; return $processedData; }
/** * Render the flag image for autorenderer * * @param array $language * @return string */ protected function getFlagImage(array $language) { $conf = ['file' => $language['flagSrc'], 'altText' => $language['label'], 'titleText' => $language['label']]; return $this->cObj->render($this->cObj->getContentObject('IMAGE'), $conf); }