public function buildCollectionsFromConfiguration() { $responsiveImageConfiguration = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_customresponsiveimages.']; $responsiveImageConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($responsiveImageConfiguration); $this->galleryAspectRatio = $responsiveImageConfiguration['galleryAspectRatio']; foreach ($responsiveImageConfiguration['colPosWidths'] as $collectionName => $colPosWidths) { $this->collections[$collectionName]['colPosWidths'] = $colPosWidths; foreach ($responsiveImageConfiguration['widthFactorByImageorient'] as $imageorient => $widthFactorByImageorient) { if (is_array($widthFactorByImageorient)) { // The factor changes from collection to collection, e.g. because a picture that is 1/16 size on desktop becomes 1/4 on mobile if (array_key_exists($collectionName, $widthFactorByImageorient)) { $this->collections[$collectionName]['widthFactorByImageorient'][$imageorient] = $widthFactorByImageorient[$collectionName]; } elseif (array_key_exists('default', $widthFactorByImageorient)) { // If configuration for current collection is missing, switch to default if available $this->collections[$collectionName]['widthFactorByImageorient'][$imageorient] = $widthFactorByImageorient['default']; } else { // fall back to fallbackWidth $this->collections[$collectionName]['widthFactorByImageorient'][$imageorient] = $responsiveImageConfiguration['fallbackWidth']; } } else { // The factor is identical for all collections $this->collections[$collectionName]['widthFactorByImageorient'][$imageorient] = $widthFactorByImageorient; } } foreach ($responsiveImageConfiguration['cropConfiguration'] as $imageorient => $cropConfiguration) { $this->collections['cropConfiguration'][$imageorient] = $cropConfiguration; } } }
/** * Process flexform field data to an array * * @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) { if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) { return $processedData; } // set targetvariable, default "flexform" $targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration, 'flexform'); // set fieldname, default "pi_flexform" $fieldName = $cObj->stdWrapValue('fieldName', $processorConfiguration, 'pi_flexform'); // parse flexform $flexformService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\FlexFormService'); $processedData[$targetVariableName] = $flexformService->convertFlexFormContentToArray($cObj->data[$fieldName]); // if targetvariable is settings, try to merge it with contentObjectConfiguration['settings.'] if ($targetVariableName == 'settings') { if (is_array($contentObjectConfiguration['settings.'])) { $convertedConf = GeneralUtility::removeDotsFromTS($contentObjectConfiguration['settings.']); foreach ($convertedConf as $key => $value) { if (!isset($processedData[$targetVariableName][$key]) || $processedData[$targetVariableName][$key] == false) { $processedData[$targetVariableName][$key] = $value; } } } } return $processedData; }
/** * @param $imageorientConfig * @return array */ public function setImageorientItems(&$imageorientConfig) { $pageTsConfig = BackendUtility::getPagesTSconfig(GeneralUtility::_GET('id')); $pageTsConfig = GeneralUtility::removeDotsFromTS($pageTsConfig); if (array_key_exists('tx_customresponsiveimages', $pageTsConfig)) { $responsiveImageConfiguration = $pageTsConfig['tx_customresponsiveimages']; } else { $responsiveImageConfiguration = array(); } $groupedItems = array(); $i = 0; foreach ($responsiveImageConfiguration['items'] as $imageorient => $item) { $groupedItems[$item['group']][$i][] = $GLOBALS['LANG']->sL($item['label']); $groupedItems[$item['group']][$i][] = $imageorient; $groupedItems[$item['group']][$i][] = array_key_exists('icon', $item) && !empty($item['icon']) ? $responsiveImageConfiguration['seliconsPath'] . $item['icon'] : NULL; $i++; } $imageOrientItems = array(); foreach ($responsiveImageConfiguration['groups'] as $groupName => $group) { if (array_key_exists('label', $group) && !empty($group['label'])) { $imageOrientItems[] = array($GLOBALS['LANG']->sL($group['label']), '--div--'); } if (array_key_exists($groupName, $groupedItems)) { foreach ($groupedItems[$groupName] as $item) { array_push($imageOrientItems, $item); } } } $imageorientConfig['items'] = $imageOrientItems; }
/** * Generate variable Get string from classMappings array with the same key as the "layout" in the 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) { if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) { return $processedData; } // set targetvariable, default "layoutClass" $targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration, 'layoutClass'); $processedData[$targetVariableName] = ''; // set fieldname, default "layout" $fieldName = $cObj->stdWrapValue('fieldName', $processorConfiguration, 'layout'); if (isset($cObj->data[$fieldName]) && is_array($processorConfiguration['classMappings.'])) { $layoutClassMappings = GeneralUtility::removeDotsFromTS($processorConfiguration['classMappings.']); $processedData[$targetVariableName] = $layoutClassMappings[$cObj->data[$fieldName]]; } // if targetvariable is settings, try to merge it with contentObjectConfiguration['settings.'] if ($targetVariableName == 'settings') { if (is_array($contentObjectConfiguration['settings.'])) { $convertedConf = GeneralUtility::removeDotsFromTS($contentObjectConfiguration['settings.']); foreach ($convertedConf as $key => $value) { if (!isset($processedData[$targetVariableName][$key]) || $processedData[$targetVariableName][$key] == false) { $processedData[$targetVariableName][$key] = $value; } } } } return $processedData; }
/** * @param string $fileref */ public function download($fileref) { $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sharepoint_connector']); $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($extensionConfiguration); $filePath = explode(';#', $fileref); $urlInfo = parse_url($extensionConfiguration['sharepointServer']['url']); $downloadLink = $urlInfo['scheme'] . '://' . $urlInfo['host'] . '/' . $filePath[1]; $destinationFile = \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('spdownload_'); $fp = fopen($destinationFile, 'w+'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $downloadLink); curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); curl_setopt($ch, CURLOPT_USERPWD, $extensionConfiguration['sharepointServer']['username'] . ':' . $extensionConfiguration['sharepointServer']['password']); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); # increase timeout to download big file curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec($ch); curl_close($ch); fclose($fp); if (file_exists($destinationFile)) { header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=" . basename($downloadLink)); header("Content-Transfer-Encoding: binary"); header('Content-Length: ' . filesize($destinationFile)); ob_clean(); flush(); readfile($destinationFile); } \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($destinationFile); }
/** * Injects the Configuration Manager * * @param ConfigurationManagerInterface $configurationManager * @return void */ public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager) { $this->configurationManager = $configurationManager; $typoScriptSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); if (!empty($typoScriptSetup['plugin.']['tx_powermail.']['settings.']['setup.'])) { $this->settings = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($typoScriptSetup['plugin.']['tx_powermail.']['settings.']['setup.']); } }
/** * Set Configuration * * @return void * @static */ protected static function initializeConfiguration() { $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sharepoint_connector']); $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($extensionConfiguration); $logFilePath = $extensionConfiguration['path']['logs']; if ('/' != substr($logFilePath, -1)) { $logFilePath .= '/'; } $GLOBALS['TYPO3_CONF_VARS']['LOG']['Aijko']['SharepointConnector']['Utility']['Logger'] = array('writerConfiguration' => array(\TYPO3\CMS\Core\Log\LogLevel::ERROR => array('\\TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => array('logFile' => $logFilePath . 'error.log')), \TYPO3\CMS\Core\Log\LogLevel::INFO => array('\\TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => array('logFile' => $logFilePath . 'info.log')))); }
/** * Constructor */ public function __construct(array $configuration = array()) { $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); if (!count($configuration)) { // Get configuration $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); $typoscriptConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $configuration = $typoscriptConfiguration['plugin.']['tx_aijkogeoip.']['settings.']; $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($configuration); } $this->configuration = $configuration; }
/** * Constructor */ public function __construct() { $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); $typoscriptConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $configuration = $typoscriptConfiguration['module.']['tx_sharepointconnector.']; $this->configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($configuration); // get extension configuration $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sharepoint_connector']); $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($extensionConfiguration); // merge typoscript configuration and extension configuration $this->configuration['settings']['sharepointServer'] = array_merge($this->configuration['settings']['sharepointServer'], $extensionConfiguration['sharepointServer']); }
/** * Render a selector element that allows to select the encryption method for SMTP * * @param array $params Field information to be rendered * * @return string The HTML selector */ public function buildSmtpEncryptSelector(array $params) { $extConf = GeneralUtility::removeDotsFromTS(unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mailcopy'])); $transports = stream_get_transports(); if (empty($transports)) { return ''; } $markup = '<select class="valid" name="' . $params['fieldName'] . '" id=em-' . $params['propertyName'] . '">'; $active = (string) self::extract($extConf, explode('.', $params['propertyName'])); foreach ($transports as $transport) { $markup .= '<option value="' . $transport . '"' . ($transport === $active ? ' selected="selected"' : '') . '>' . $transport . '</option>'; } $markup .= '</select>'; return $markup; }
/** * Returns the TypoScript configuration for this extension. * * @return array */ public function getSettings() { // Use cache or initialize settings property. if (empty($this->settings)) { if ($this->isFrontendMode()) { $this->settings = GeneralUtility::removeDotsFromTS($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_formule.']['settings.']); } else { $setup = $this->getConfigurationManager()->getTypoScriptSetup(); if (is_array($setup['plugin.']['tx_formule.'])) { /** @var \TYPO3\CMS\Extbase\Service\TypoScriptService $typoScriptService */ $typoScriptService = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Service\TypoScriptService::class); $this->settings = $typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_formule.']['settings.']); } } } return $this->settings; }
/** * Render * * @param string $path * @return mixed */ public function render($path = NULL) { if (NULL === $path) { $path = $this->renderChildren(); } if (TRUE === empty($path)) { return NULL; } $all = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $segments = explode('.', $path); $value = $all; foreach ($segments as $path) { $value = TRUE === isset($value[$path . '.']) ? $value[$path . '.'] : $value[$path]; } if (TRUE === is_array($value)) { $value = GeneralUtility::removeDotsFromTS($value); } return $value; }
/** * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return mixed */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { $extensionKey = $arguments['extensionKey']; $path = $arguments['path']; if (null === $extensionKey) { $extensionName = $renderingContext->getControllerContext()->getRequest()->getControllerExtensionName(); $extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName); } if (!array_key_exists($extensionKey, $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'])) { return null; } elseif (!array_key_exists($extensionKey, static::$configurations)) { $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]); static::$configurations[$extensionKey] = GeneralUtility::removeDotsFromTS($extConf); } if (!$path) { return static::$configurations[$extensionKey]; } return ObjectAccess::getPropertyPath(static::$configurations[$extensionKey], $path); }
/** * @throws \InvalidArgumentException|\UnexpectedValueException */ public function __construct() { $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $extensionConfiguration = \Aijko\AijkoGeoip\Utility\EmConfiguration::getConfiguration('aijko_geoip', '\\Aijko\\AijkoGeoip\\Domain\\Model\\Dto\\EmConfiguration'); if (!$extensionConfiguration->getDatabaseFilePath()) { throw new \UnexpectedValueException('You must set a path to the database file in the extension managaer', 1409315403); } try { $this->reader = new Reader($extensionConfiguration->getDatabaseFilePath()); } catch (\InvalidArgumentException $exception) { throw new \InvalidArgumentException($exception->getMessage(), 1409315902); } catch (\UnexpectedValueException $exception) { throw new \UnexpectedValueException($exception->getMessage(), 1409315903); } // Get configuration $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); $typoscriptConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $configuration = $typoscriptConfiguration['plugin.']['tx_aijkogeoip.']['settings.']; $this->configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($configuration); }
/** * Overrides the TCA field configuration by TSconfig settings. * * Example TSconfig: TCEform.<table>.<field>.config.appearance.useSortable = 1 * This overrides the setting in $GLOBALS['TCA'][<table>]['columns'][<field>]['config']['appearance']['useSortable']. * * @param array $fieldConfig $GLOBALS['TCA'] field configuration * @param array $TSconfig TSconfig * @return array Changed TCA field configuration * @internal */ public static function overrideFieldConf($fieldConfig, $TSconfig) { if (is_array($TSconfig)) { $TSconfig = GeneralUtility::removeDotsFromTS($TSconfig); $type = $fieldConfig['type']; if (is_array($TSconfig['config']) && is_array(static::$allowOverrideMatrix[$type])) { // Check if the keys in TSconfig['config'] are allowed to override TCA field config: foreach ($TSconfig['config'] as $key => $_) { if (!in_array($key, static::$allowOverrideMatrix[$type], true)) { unset($TSconfig['config'][$key]); } } // Override $GLOBALS['TCA'] field config by remaining TSconfig['config']: if (!empty($TSconfig['config'])) { ArrayUtility::mergeRecursiveWithOverrule($fieldConfig, $TSconfig['config']); } } } return $fieldConfig; }
/** * Render a Flexible Content Element type selection field * * @param array $parameters * @param mixed $parentObject * @return string */ public function renderField(array &$parameters, &$parentObject) { /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */ $cacheManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')->get('TYPO3\\CMS\\Core\\Cache\\CacheManager'); /** @var StringFrontend $cache */ $cache = $cacheManager->getCache('fluidcontent'); $pageTypoScript = TRUE === $cache->has('pageTsConfig') ? $cache->get('pageTsConfig') : array(); $tsParser = new TypoScriptParser(); $conditions = new ConditionMatcher(); $pageUid = GeneralUtility::_GET('id'); $pageUid = intval($pageUid); if (0 === $pageUid) { $pageUid = intval($parameters['row']['pid']); } $conditions->setPageId($pageUid); $tsParser->parse($pageTypoScript, $conditions); $setup = $tsParser->setup['mod.']['wizards.']['newContentElement.']['wizardItems.']; if (FALSE === is_array($setup)) { return LocalizationUtility::translate('pages.no_content_types', 'Fluidcontent'); } $setup = GeneralUtility::removeDotsFromTS($setup); $name = $parameters['itemFormElName']; $value = $parameters['itemFormElValue']; $select = '<div><select name="' . htmlspecialchars($name) . '" class="formField select" onchange="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };">' . LF; $select .= '<option value="">' . $GLOBALS['LANG']->sL('LLL:EXT:fluidcontent/Resources/Private/Language/locallang.xml:tt_content.tx_fed_fcefile', TRUE) . '</option>' . LF; foreach ($setup as $groupLabel => $configuration) { $select .= '<optgroup label="' . htmlspecialchars($groupLabel) . '">' . LF; foreach ($configuration['elements'] as $elementConfiguration) { $optionValue = $elementConfiguration['tt_content_defValues']['tx_fed_fcefile']; $selected = $optionValue === $value ? ' selected="selected"' : ''; $label = $elementConfiguration['title']; $label = $GLOBALS['LANG']->sL($label); $select .= '<option value="' . htmlspecialchars($optionValue) . '"' . $selected . '>' . htmlspecialchars($label) . '</option>' . LF; } $select .= '</optgroup>' . LF; } $select .= '</select></div>' . LF; unset($parentObject); return $select; }
/** * @param string $extensionKey * @return array */ protected function getContextSpecificViewConfiguration($extensionKey) { if (empty($extensionKey)) { return array(); } if (empty($this->typoScript)) { $this->typoScript = GeneralUtility::removeDotsFromTS($this->getConfigurationManager()->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)); } $signature = str_replace('_', '', $extensionKey); $resources = $this->getExtensionPrivateResourcesPath($extensionKey); $configuration = array(); $paths = array(self::CONFIG_TEMPLATEROOTPATHS => array($resources . 'Templates/'), self::CONFIG_PARTIALROOTPATHS => array($resources . 'Partials/'), self::CONFIG_LAYOUTROOTPATHS => array($resources . 'Layouts/')); if (TYPO3_MODE === 'BE' && isset($this->typoScript['module']['tx_' . $signature]['view'])) { $configuration = (array) $this->typoScript['module']['tx_' . $signature]['view']; } elseif (TYPO3_MODE === 'FE' && isset($this->typoScript['plugin']['tx_' . $signature]['view'])) { $configuration = (array) $this->typoScript['plugin']['tx_' . $signature]['view']; } foreach ($paths as $name => $values) { $paths[$name] = $values + (array) $configuration[$name]; } return $paths; }
/** * When constructing, also initializes the \Swift_Transport like configured * * @param null|\Swift_Transport $transport optionally pass a transport to the constructor. * @throws \TYPO3\CMS\Core\Exception */ public function __construct(\Swift_Transport $transport = null) { parent::__construct($this->transport); $backupSettings = $this->mailSettings; $backupTransport = $this->transport; // initialize addtional transports as configured in extension configuration re-using core initialization method $extConf = GeneralUtility::removeDotsFromTS(unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mailcopy'])); foreach ($extConf['transports'] as $config) { if (false === (bool) $config['enabled']) { continue; } $type = $config['type']; $transportConfig = $config[$type]; $this->mailSettings = array('transport' => $type); foreach ($transportConfig as $key => $value) { $this->mailSettings['transport_' . $type . '_' . $key] = $value; } $this->initializeTransport(); $this->extraTransports[] = $this->transport; } $this->transport = $backupTransport; $this->mailSettings = $backupSettings; }
/** * @param array $parameters * @return string */ protected function renderInheritanceField(array $parameters) { $selector = ''; $onChange = 'onclick="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };"'; $pageIsSiteRoot = (bool) $parameters['row']['is_siteroot']; $name = $parameters['itemFormElName']; $value = $parameters['itemFormElValue']; $fieldTSConfig = $parameters['fieldTSConfig']; $default = isset($fieldTSConfig['default']) ? $fieldTSConfig['default'] : NULL; $typoScript = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $settings = GeneralUtility::removeDotsFromTS((array) $typoScript['plugin.']['tx_fluidpages.']); $hideInheritFieldSiteRoot = (bool) (TRUE === isset($settings['siteRootInheritance']) ? 1 > $settings['siteRootInheritance'] : FALSE); $tsHideInheritanceField = isset($fieldTSConfig['hideInheritanceField']) ? (bool) $fieldTSConfig['hideInheritanceField'] : FALSE; $forceDisplayInheritSiteRoot = (bool) ('tx_fed_page_controller_action_sub' === $parameters['field'] && (FALSE === $hideInheritFieldSiteRoot || FALSE === $tsHideInheritanceField)); $forceHideInherit = (bool) (0 === intval($parameters['row']['pid'])); if (FALSE === $forceHideInherit) { if (FALSE === $pageIsSiteRoot || TRUE === $forceDisplayInheritSiteRoot || FALSE === $hideInheritFieldSiteRoot) { $emptyLabel = LocalizationUtility::translate('pages.tx_fed_page_controller_action.default', 'Fluidpages'); $selected = TRUE === empty($value) && TRUE === empty($default) ? ' checked="checked" ' : NULL; $selector = sprintf($this->templates['inheritanceField'], $name, $onChange, $selected, $emptyLabel); } } return $selector; }
/** * Translate Page TS Config array in JS nested array definition * Replace 0 values with false * Unquote regular expression values * Replace empty arrays with empty objects * * @param array $conf: Page TSConfig configuration array * @return string nested JS array definition */ protected function buildNestedJSArray($conf) { $convertedConf = GeneralUtility::removeDotsFromTS($conf); return str_replace(array(':"0"', ':"\\/^(', ')$\\/i"', ':"\\/^(', ')$\\/"', '[]'), array(':false', ':/^(', ')$/i', ':/^(', ')$/', '{}'), json_encode($convertedConf)); }
/** * @param array $row * @return Form|NULL */ public function getForm(array $row) { if (NULL !== $this->form) { return $this->form; } $formClassName = $this->resolveFormClassName($row); if (NULL !== $formClassName) { $form = call_user_func_array(array($formClassName, 'create'), array($row)); } else { $templateSource = $this->getTemplateSource($row); if (NULL === $templateSource) { // Early return: no template file, no source - NULL expected. return NULL; } $section = $this->getConfigurationSectionName($row); $controllerName = 'Flux'; $formName = 'form'; $paths = $this->getTemplatePaths($row); $extensionKey = $this->getExtensionKey($row); $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey); $fieldName = $this->getFieldName($row); $typoScript = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $signature = str_replace('_', '', $extensionKey); $variables = array('record' => $row); if (TRUE === isset($typoScript['plugin.']['tx_' . $signature . '.']['settings.'])) { $variables['settings'] = GeneralUtility::removeDotsFromTS($typoScript['plugin.']['tx_' . $signature . '.']['settings.']); } // Special case: when saving a new record variable $row[$fieldName] is already an array // and must not be processed by the configuration service. if (FALSE === is_array($row[$fieldName])) { $recordVariables = $this->configurationService->convertFlexFormContentToArray($row[$fieldName]); $variables = GeneralUtility::array_merge_recursive_overrule($variables, $recordVariables); } $variables = GeneralUtility::array_merge_recursive_overrule($this->templateVariables, $variables); $view = $this->configurationService->getPreparedExposedTemplateView($extensionName, $controllerName, $paths, $variables); $view->setTemplateSource($templateSource); $form = $view->getForm($section, $formName); } $form = $this->setDefaultValuesInFieldsWithInheritedValues($form, $row); return $form; }
/** * @return ProviderInterface[] */ public function loadTypoScriptConfigurationProviderInstances() { $typoScriptSettings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); if (FALSE === isset($typoScriptSettings['plugin.']['tx_flux.']['providers.'])) { return array(); } $providerConfigurations = GeneralUtility::removeDotsFromTS($typoScriptSettings['plugin.']['tx_flux.']['providers.']); $providers = array(); foreach ($providerConfigurations as $name => $providerSettings) { $className = 'FluidTYPO3\\Flux\\Provider\\Provider'; if (TRUE === isset($providerSettings['className']) && TRUE === class_exists($providerSettings['className'])) { $className = $providerSettings['className']; } /** @var ProviderInterface $provider */ $provider = $this->objectManager->get($className); $provider->setName($name); $provider->loadSettings($providerSettings); $providers[$name] = $provider; } return $providers; }
/** * Returns the settings used by this particular Asset * during inclusion. Public access allows later inspection * of the TypoScript values which were applied to the Asset. * * @return array */ public function getSettings() { if (NULL === self::$settingsCache) { $allTypoScript = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $settingsExist = isset($allTypoScript['plugin.']['tx_vhs.']['settings.']); if (FALSE === $settingsExist) { // no settings exist, but don't allow a NULL value. This prevents cache clobbering. self::$settingsCache = array(); } else { self::$settingsCache = GeneralUtility::removeDotsFromTS($allTypoScript['plugin.']['tx_vhs.']['settings.']); } } $settings = self::$settingsCache; if (TRUE === is_array($this->localSettings)) { if (TRUE === method_exists('TYPO3\\CMS\\Core\\Utility\\ArrayUtility', 'mergeRecursiveWithOverrule')) { ArrayUtility::mergeRecursiveWithOverrule($settings, $this->localSettings); } else { $settings = GeneralUtility::array_merge_recursive_overrule($settings, $this->localSettings); } } return $settings; }
/** * Returns the complete, global TypoScript array * defined in TYPO3. * * @return array */ public function getAllTypoScript() { if (!$this->configurationManager instanceof BackendConfigurationManager) { $typoScript = (array) $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $typoScript = GeneralUtility::removeDotsFromTS($typoScript); return $typoScript; } else { $pageId = $this->configurationManager->getCurrentPageId(); if (FALSE === isset(self::$typoScript[$pageId])) { self::$typoScript[$pageId] = (array) $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); self::$typoScript[$pageId] = GeneralUtility::removeDotsFromTS(self::$typoScript[$pageId]); } return (array) self::$typoScript[$pageId]; } }
/** * Checks if config-array exists already but if not, gets it * * @return void * @todo Define visibility */ public function getConfigArray() { $setStatPageName = FALSE; // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) { $GLOBALS['TT']->push('Parse template', ''); // Force parsing, if set?: $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing; // Start parsing the TS template. Might return cached version. $this->tmpl->start($this->rootLine); $GLOBALS['TT']->pull(); if ($this->tmpl->loaded) { $GLOBALS['TT']->push('Setting the config-array', ''); // toplevel - objArrayName $this->sPre = $this->tmpl->setup['types.'][$this->type]; $this->pSetup = $this->tmpl->setup[$this->sPre . '.']; if (!is_array($this->pSetup)) { $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].'; if ($this->checkPageUnavailableHandler()) { $this->pageUnavailableAndExit($message); } else { $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.'; \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR); throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message . ' ' . $explanation, 1294587217); } } else { $this->config['config'] = array(); // Filling the config-array, first with the main "config." part if (is_array($this->tmpl->setup['config.'])) { $this->config['config'] = $this->tmpl->setup['config.']; } // override it with the page/type-specific "config." if (is_array($this->pSetup['config.'])) { $this->config['config'] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->config['config'], $this->pSetup['config.']); } if ($this->config['config']['typolinkEnableLinksAcrossDomains']) { $this->config['config']['typolinkCheckRootline'] = TRUE; } // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0 if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('4.0')) { if (!isset($this->config['config']['removeDefaultJS'])) { $this->config['config']['removeDefaultJS'] = 'external'; } if (!isset($this->config['config']['inlineStyle2TempFile'])) { $this->config['config']['inlineStyle2TempFile'] = 1; } } if (!isset($this->config['config']['compressJs'])) { $this->config['config']['compressJs'] = 0; } // Processing for the config_array: $this->config['rootLine'] = $this->tmpl->rootLine; $this->config['mainScript'] = trim($this->config['config']['mainScript']) ? trim($this->config['config']['mainScript']) : 'index.php'; // Class for render Header and Footer parts $template = ''; if ($this->pSetup['pageHeaderFooterTemplateFile']) { $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']); if ($file) { $this->setTemplateFile($file); } } } $GLOBALS['TT']->pull(); } else { if ($this->checkPageUnavailableHandler()) { $this->pageUnavailableAndExit('No TypoScript template found!'); } else { $message = 'No TypoScript template found!'; \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR); throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1294587218); } } } // Initialize charset settings etc. $this->initLLvars(); // No cache // Set $this->no_cache TRUE if the config.no_cache value is set! if ($this->config['config']['no_cache']) { $this->set_no_cache(); } // Merge GET with defaultGetVars if (!empty($this->config['config']['defaultGetVars.'])) { $modifiedGetVars = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(\TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']), \TYPO3\CMS\Core\Utility\GeneralUtility::_GET()); \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset($modifiedGetVars); } // Hook for postProcessing the configuration array if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) { $params = array('config' => &$this->config['config']); foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } }
/** * Boots up: * - objectManager to get class instances * - configuration manager for ts settings * - contentObjectRenderer for generating links etc. * - termRepository to get the Terms * * @return WrapperService */ public function __construct() { // Make instance of Object Manager /** @var ObjectManager $objectManager */ $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); // Get Configuration Manager /** @var ConfigurationManager $configurationManager */ $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); // Inject Content Object Renderer $this->cObj = $objectManager->get('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); // Get Query Settings /** @var QuerySettingsInterface $querySettings */ $querySettings = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface'); // Get termRepository $this->termRepository = $objectManager->get('Dpn\\DpnGlossary\\Domain\\Repository\\TermRepository'); // Get Typoscript Configuration $this->tsConfig = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); // Reduce TS config to plugin $this->tsConfig = $this->tsConfig['plugin.']['tx_dpnglossary.']; if (FALSE === empty($this->tsConfig)) { // Save extension settings without ts dots $this->settings = GeneralUtility::removeDotsFromTS($this->tsConfig['settings.']); // Set StoragePid in the query settings object $querySettings->setStoragePageIds(GeneralUtility::trimExplode(',', $this->tsConfig['persistence.']['storagePid'])); // Set current language uid $querySettings->setLanguageUid($GLOBALS['TSFE']->sys_language_uid); // Assign query settings object to repository $this->termRepository->setDefaultQuerySettings($querySettings); } }
/** * @param mixed $asset * @return string */ private function renderAssetAsFluidTemplate($asset) { $settings = $this->extractAssetSettings($asset); $templateReference = $settings['path']; $variables = TRUE === (isset($settings['variables']) && is_array($settings['variables'])) ? $settings['variables'] : array(); $isExternal = TRUE === (isset($settings['external']) && $settings['external'] > 0); if (TRUE === $isExternal) { $fileContents = file_get_contents($templateReference); } else { $templatePathAndFilename = GeneralUtility::getFileAbsFileName($templateReference); $fileContents = file_get_contents($templatePathAndFilename); } $variables = GeneralUtility::removeDotsFromTS($variables); /** @var \TYPO3\CMS\Fluid\View\StandaloneView $view */ $view = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); $view->setTemplateSource($fileContents); $view->assignMultiple($variables); $content = $view->render(); return $content; }
/** * @param array $parameter * @param \TYPO3\CMS\Recordlist\Browser\ElementBrowser $elementBrowser * * @return string */ public function getAttributefields(array $parameter, \TYPO3\CMS\Recordlist\Browser\ElementBrowser $elementBrowser) { if ($elementBrowser->act == 'page' && $elementBrowser->buttonConfig && is_array($elementBrowser->buttonConfig['sharepointProductMapping.']) && $elementBrowser->buttonConfig['sharepointProductMapping.']['enabled']) { try { $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sharepoint_shop']); $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($extensionConfiguration); $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $sharepointListsRepository = $this->objectManager->get('Aijko\\SharepointConnector\\Domain\\Repository\\Sharepoint\\ListsRepository'); $records = $sharepointListsRepository->findRecords($extensionConfiguration['sharepointServer']['list']['article']['identifier']); $options = array(); if (is_array($records) && count($records) > 0) { foreach ($records as $record) { $options[] = '<option ' . ($elementBrowser->additionalAttributes['data-sharepoint-product'] == $record['id'] ? 'selected="selected"' : '') . ' value="' . $record['id'] . '">' . $record['bezeichnung'] . ' (' . $record['title'] . ')</option>'; } } if (count($options) > 0) { return ' <tr> <td>Sharepoint Product:</td> <td colspan="3"> <select name="lsharepoint_product"> <option></option> ' . implode('', $options) . ' </select> </td> </tr> '; } } catch (\Exception $e) { } } }
/** * @test */ public function removeDotsFromTypoScriptOverridesWithScalar() { $typoScript = array('propertyA.' => array('keyA.' => array('valueA' => 1), 'keyA' => 'willOverride', 'keyB' => 2), 'propertyB' => 3); $expectedResult = array('propertyA' => array('keyA' => 'willOverride', 'keyB' => 2), 'propertyB' => 3); $this->assertEquals($expectedResult, Utility\GeneralUtility::removeDotsFromTS($typoScript)); }
/** * Modify the Data Structure of a FlexForm field via TSconfig and group access lists * * @param array $dataStructure The data structure of the FlexForm field * @param string $table The table name of the record * @param string $tableField The field name * @param array $tableRow The record data * @param array $tableConf Additional configuration options * @return array Modified FlexForm DS * @see \TYPO3\CMS\Backend\Form\FormEngine::getSingleField_typeFlex() */ public function modifyFlexFormDS(array $dataStructure, $table, $tableField, array $tableRow, array $tableConf) { $singleSheet = !isset($dataStructure['sheets']) || !is_array($dataStructure['sheets']); $metaConf = !empty($dataStructure['meta']) ? $dataStructure['meta'] : array(); $sheetConf = array(); // Get extension identifier (uses second pointer field if it's value is not empty, // "list" or "*", else it must be a plugin and first one will be used) $pointerFields = !empty($tableConf['config']['ds_pointerField']) ? $tableConf['config']['ds_pointerField'] : 'list_type,CType'; $pointerFields = GeneralUtility::trimExplode(',', $pointerFields); $flexformIdentifier = !empty($tableRow[$pointerFields[0]]) ? $tableRow[$pointerFields[0]] : ''; if (!empty($tableRow[$pointerFields[1]]) && $tableRow[$pointerFields[1]] != 'list' && $tableRow[$pointerFields[1]] != '*') { $flexformIdentifier = $tableRow[$pointerFields[1]]; } if (empty($flexformIdentifier)) { return $dataStructure; } // Get field configuration from page TSConfig $TSconfig = $this->setTSconfig($table, $tableRow); if (!empty($TSconfig[$tableField][$flexformIdentifier . '.'])) { $sheetConf = GeneralUtility::removeDotsFromTS($TSconfig[$tableField][$flexformIdentifier . '.']); } // Get non-exclude-fields from group access lists $nonExcludeFields = $this->getFlexFormNonExcludeFields($table, $tableField, $flexformIdentifier); // Load complete DS, including external file references $dataStructure = GeneralUtility::resolveAllSheetsInDS($dataStructure); // Modify language handling in meta configuration if (isset($sheetConf['langDisable'])) { $metaConf['langDisable'] = $sheetConf['langDisable']; } if (isset($sheetConf['langChildren'])) { $metaConf['langChildren'] = $sheetConf['langChildren']; } // Modify flexform sheets foreach ($dataStructure['sheets'] as $sheetName => $sheet) { if (empty($sheet['ROOT']['el']) || !is_array($sheet['ROOT']['el'])) { continue; } // Remove whole sheet (tab) if disabled if (!empty($sheetConf[$sheetName]['disabled'])) { unset($dataStructure['sheets'][$sheetName]); continue; } // Rename sheet (tab) if (!empty($sheetConf[$sheetName]['sheetTitle'])) { $dataStructure['sheets'][$sheetName]['ROOT']['TCEforms']['sheetTitle'] = $sheetConf[$sheetName]['sheetTitle']; } // Set sheet description (tab) if (!empty($sheetConf[$sheetName]['sheetDescription'])) { $dataStructure['sheets'][$sheetName]['ROOT']['TCEforms']['sheetDescription'] = $sheetConf[$sheetName]['sheetDescription']; } // Set sheet short description (tab) if (!empty($sheetConf[$sheetName]['sheetShortDescr'])) { $dataStructure['sheets'][$sheetName]['ROOT']['TCEforms']['sheetShortDescr'] = $sheetConf[$sheetName]['sheetShortDescr']; } // Modify all configured fields in sheet (tab) $dataStructure['sheets'][$sheetName]['ROOT']['el'] = $this->modifySingleFlexFormSheet($sheet['ROOT']['el'], $table, $tableField, $tableRow, !empty($sheetConf[$sheetName]) ? $sheetConf[$sheetName] : array(), !empty($nonExcludeFields[$sheetName]) ? $nonExcludeFields[$sheetName] : array()); // Remove empty sheet (tab) if (empty($dataStructure['sheets'][$sheetName]['ROOT']['el'])) { unset($dataStructure['sheets'][$sheetName]); } } // Recover single flexform structure if ($singleSheet && isset($dataStructure['sheets']['sDEF'])) { $dataStructure = $dataStructure['sheets']['sDEF']; } // Recover meta configuration if (!empty($metaConf)) { $dataStructure['meta'] = $metaConf; } return $dataStructure; }