/** * Up. * * @return void */ public function up() { $bocPlugins = $this->query("SELECT uid, pi_flexform from tt_content WHERE CType = 'list' AND list_type = 'beautyofcode_contentrenderer'"); $flexformService = new FlexFormService(); foreach ($bocPlugins as $bocPlugin) { $flexformData = $flexformService->convertFlexFormContentToArray($bocPlugin['pi_flexform']); $subheader = $flexformData['cLabel']; $bodytext = $flexformData['cCode']; $brush = $flexformData['cLang']; $highlight = $flexformData['cHighlight']; $collapse = $flexformData['cCollapse']; $gutter = $flexformData['cGutter']; $configuration = []; if (!empty($brush)) { $configuration['brush'] = (string) $brush; } if (!empty($highlight)) { $configuration['highlight'] = (string) $highlight; } if (!empty($collapse) && 'auto' !== $collapse) { $configuration['collapse'] = (bool) $collapse; } if (!empty($gutter) && 'auto' !== $gutter) { $configuration['gutter'] = (bool) $gutter; } $rowDescription = Yaml::dump($configuration); $data = [$subheader, $bodytext, $rowDescription]; $stmt = $this->getAdapter()->getConnection()->prepare("UPDATE\n tt_content\n SET\n CType = 'vantomas_codesnippet',\n list_type = '',\n pi_flexform = NULL,\n subheader = ?,\n bodytext = ?,\n rowDescription = ?\n WHERE\n uid = " . (int) $bocPlugin['uid']); $stmt->execute($data); } }
/** * @param string $record * @param string $field * @return void */ public function render($record = "data", $field = "pi_flexform") { if ($this->templateVariableContainer->exists($record) === FALSE) { return NULL; } $data = $this->templateVariableContainer->get($record); $flexFormConfiguration = $data[$field]; if (is_string($flexFormConfiguration)) { if (strlen($flexFormConfiguration) > 0) { $flexFormConfiguration = $this->flexFormService->convertFlexFormContentToArray($flexFormConfiguration); } else { $flexFormConfiguration = array(); } } $data[$field] = $flexFormConfiguration; $this->templateVariableContainer->remove($record); $this->templateVariableContainer->add($record, $data); return NULL; }
private function loadConfiguration() { if (!array_key_exists($this->extKey, self::$settingsCache)) { $this->mergeSettings(unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey])); $this->mergeSettings($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)); $this->mergeSettings($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS)); $flexformSettings = $this->flexFormService->convertFlexFormContentToArray($this->configurationManager->getContentObject()->data['pi_flexform']); $this->mergeSettings($flexformSettings['settings']); self::$settingsCache[$this->extKey] = $this->settings; } $this->settings = self::$settingsCache[$this->extKey]; }
/** * @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) { // The field name to process $fieldName = $cObj->stdWrapValue('fieldName', $processorConfiguration); if (empty($fieldName) && !$processedData['data']['pi_flexform']) { return $processedData; } else { $fieldName = 'pi_flexform'; } // Process Flexform $originalValue = $processedData['data'][$fieldName]; if (!is_string($originalValue)) { return $processedData; } $flexformData = $this->flexFormService->convertFlexFormContentToArray($originalValue); // Set the target variable $targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration); if (!empty($targetVariableName)) { $processedData[$targetVariableName] = $flexformData; } else { $processedData['data'][$fieldName] = $flexformData; } return $processedData; }
/** * Overrides configuration settings from flexForms. * This merges the whole flexForm data, and overrides switchable controller actions. * * @param array $frameworkConfiguration the framework configuration * @return array the framework configuration with overridden data from flexForm */ protected function overrideConfigurationFromFlexForm(array $frameworkConfiguration) { $flexFormConfiguration = $this->contentObject->data['pi_flexform']; if (is_string($flexFormConfiguration)) { if ($flexFormConfiguration !== '') { $flexFormConfiguration = $this->flexFormService->convertFlexFormContentToArray($flexFormConfiguration); } else { $flexFormConfiguration = []; } } if (is_array($flexFormConfiguration) && !empty($flexFormConfiguration)) { $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $flexFormConfiguration, 'settings'); $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $flexFormConfiguration, 'persistence'); $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $flexFormConfiguration, 'view'); $frameworkConfiguration = $this->overrideSwitchableControllerActionsFromFlexForm($frameworkConfiguration, $flexFormConfiguration); } return $frameworkConfiguration; }
/** * Create a new flexform based on the old one * * @param string $flexform * @return string */ protected function createFlexForm($flexform) { $data = $this->flexFormService->convertFlexFormContentToArray($flexform); $new = $this->newsFlexConfig; foreach ($data as $key => $value) { switch ($key) { case 'what_to_display': $this->addFieldToArray($new, $this->getValueMap($key, $value), 'switchableControllerActions'); if ($value === 'VERSION_PREVIEW') { $this->addFieldToArray($new, '1', 'settings.previewHiddenRecords'); } break; case 'listOrderBy': $this->addFieldToArray($new, $this->getValueMap($key, $value), 'settings.orderBy'); break; case 'ascDesc': $this->addFieldToArray($new, $value, 'settings.orderDirection'); break; case 'categoryMode': $this->addFieldToArray($new, $this->getValueMap($key, $value), 'settings.categoryConjunction'); break; case 'categorySelection': $this->addFieldToArray($new, $this->getSysCategoryIdList($value), 'settings.categories'); break; case 'useSubCategories': $this->addFieldToArray($new, (int) $value, 'settings.includeSubCategories'); break; case 'archive': $this->addFieldToArray($new, $this->getValueMap($key, $value), 'settings.archiveRestriction'); break; case 'imageMaxWidth': $this->addFieldToArray($new, $value, 'settings.media.maxWidth', 'template'); break; case 'imageMaxHeight': $this->addFieldToArray($new, $value, 'settings.media.maxHeight', 'template'); break; case 'listLimit': $this->addFieldToArray($new, $value, 'settings.limit', 'additional'); break; case 'noPageBrowser': $this->addFieldToArray($new, $value, 'settings.hidePagination', 'additional'); break; case 'croppingLenght': $this->addFieldToArray($new, $value, 'settings.cropMaxCharacters', 'template'); break; case 'PIDitemDisplay': $this->addFieldToArray($new, $value, 'settings.detailPid', 'additional'); break; case 'backPid': $this->addFieldToArray($new, $value, 'settings.backPid'); break; case 'pages': $this->addFieldToArray($new, $value, 'settings.startingpoint'); break; case 'recursive': $this->addFieldToArray($new, (int) $value, 'settings.recursive'); break; } } return $this->array2xml($new, TRUE); }