Skip to content

Commit

Permalink
[FEATURE] Replace deprecated configuration translation
Browse files Browse the repository at this point in the history
Since TYPO3 7.6 the previous handling of translated
page configuration has been deprecated and moved
into the compatibility6 extension. To replace this
functionality this commit introduces the flexform fields
 for configuration to the  pages_language_overlay
table and takes care of the overlaying of the affected
configurations. This functionality is disable by default
and can be activated through a toggle in the extension
configuration.

related deprecation: #70138 - Flex form language handling
  • Loading branch information
Marc Neuhaus committed Dec 14, 2015
1 parent e5e0614 commit 271f09b
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 14 deletions.
50 changes: 50 additions & 0 deletions Classes/Provider/PageLanguageOverlayProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
namespace FluidTYPO3\Fluidpages\Provider;

/*
* This file is part of the FluidTYPO3/Fluidpages project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Flux\Form;
use FluidTYPO3\Flux\Provider\ProviderInterface;
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;

/**
* Page LanguageOverlayConfiguration Provider
*
* This Provider takes care of page Configuration
* for other languages inside the pages_language_overlay
* record.
*/
class PageLanguageOverlayProvider extends PageProvider implements ProviderInterface {

/**
* @var string
*/
protected $tableName = 'pages_language_overlay';

/**
* @param array $record
* @return array
*/
protected function loadRecordTreeFromDatabase($record) {
$parentFieldName = $this->getParentFieldName($record);
if (FALSE === isset($record[$parentFieldName])) {
$record[$parentFieldName] = $this->getParentFieldValue($record);
}
$pageRecord = $this->recordService->getSingle('pages', '*', $record['pid']);
$records = array();
while (0 < $pageRecord[$parentFieldName]) {
$record = $this->recordService->get($this->tableName, '*', 'pid = ' . $pageRecord['pid']);
$parentFieldName = $this->getParentFieldName($record);
array_push($records, $record);
$pageRecord = $this->recordService->getSingle('pages', '*', $pageRecord['pid']);
}
$records = array_reverse($records);
return $records;
}

}
45 changes: 43 additions & 2 deletions Classes/Provider/PageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,54 @@ public function getControllerActionReferenceFromRecord(array $row) {
*/
public function getFlexFormValues(array $row) {
$fieldName = $this->getFieldName($row);
$form = $this->getForm($row);
$immediateConfiguration = $this->configurationService->convertFlexFormContentToArray($row[$fieldName], $form, NULL, NULL);
$form = $this->getForm($row);

$immediateConfiguration = $this->getFlexFormValuesSingle($row);
$inheritedConfiguration = $this->getInheritedConfiguration($row);
$merged = RecursiveArrayUtility::merge($inheritedConfiguration, $immediateConfiguration);

return $merged;
}

/**
* @param array $row source record row
* @param array $configuration to be overlayed
*/
public function overlayFlexFormValues($row, $configuration, $form) {
if ($GLOBALS['TSFE']->sys_language_uid > 0) {
$overlays = $this->recordService->get('pages_language_overlay', '*', 'sys_language_uid = ' . $GLOBALS['TSFE']->sys_language_uid . ' AND pid = ' . $row['uid']);
$fieldName = $this->getFieldName($row);
if (count($overlays) > 0) {
foreach ($overlays as $overlay) {
$overlayConfiguration = $this->configurationService->convertFlexFormContentToArray($overlay[$fieldName], $form, NULL, NULL);
$configuration = RecursiveArrayUtility::merge($configuration, $overlayConfiguration);
}
}
}
return $configuration;
}

/**
* @param array $row
* @return array
*/
public function getFlexFormValuesSingle(array $row) {
$fieldName = $this->getFieldName($row);
$form = $this->getForm($row);

// legacy language handling, this was deprecated in TYPO3 7.6 (Deprecation: #70138 - Flex form language handling)
// this should stay here for a little while and be removed at some point in the future
$languageRef = NULL;
if ($GLOBALS['TSFE']->sys_language_uid > 0) {
$languageRef = 'l' . $GLOBALS['TSFE']->config['config']['language'];
}
$immediateConfiguration = $this->configurationService->convertFlexFormContentToArray($row[$fieldName], $form, $languageRef, NULL);

// replacement for the deprecated language handling (Deprecation: #70138 - Flex form language handling)
$immediateConfiguration = $this->overlayFlexFormValues($row, $immediateConfiguration, $form);
return $immediateConfiguration;
}

/**
* @param string $operation
* @param integer $id
Expand Down
55 changes: 55 additions & 0 deletions Classes/Provider/SubPageLanguageOverlayProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
namespace FluidTYPO3\Fluidpages\Provider;

/*
* This file is part of the FluidTYPO3/Fluidpages project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Flux\Form;
use FluidTYPO3\Flux\Provider\ProviderInterface;

/**
* PageLanguageOverlay SubConfiguration Provider
*
* This Provider has a slightly lower priority
* than the main PageProvider but will trigger
* on any selection in the targeted field,
* including when "parent decides" is selected.
*
* This lets the PageProvider act on records
* that define a specific action to use and the
* SubPageProvider act on all other page records.
*/
class SubPageLanguageOverlayProvider extends PageLanguageOverlayProvider implements ProviderInterface {

/**
* @var string
*/
protected $fieldName = self::FIELD_NAME_SUB;

/**
* @param array $row
* @return string
*/
public function getControllerActionReferenceFromRecord(array $row) {
if (TRUE === empty($row[self::FIELD_ACTION_SUB])) {
$row = $this->pageService->getPageTemplateConfiguration($row['uid']);
}
return $row[self::FIELD_ACTION_SUB];
}

/**
* @param array $row
* @return array
*/
public function getFlexFormValuesSingle(array $row) {
$fieldName = $this->getFieldName($row);
$form = $this->getForm($row);
$immediateConfiguration = $this->configurationService->convertFlexFormContentToArray($row[$fieldName], $form, NULL, NULL);
return $immediateConfiguration;
}

}
11 changes: 0 additions & 11 deletions Classes/Provider/SubPageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,4 @@ public function getControllerActionReferenceFromRecord(array $row) {
return $row[self::FIELD_ACTION_SUB];
}

/**
* @param array $row
* @return array
*/
public function getFlexFormValuesSingle(array $row) {
$fieldName = $this->getFieldName($row);
$form = $this->getForm($row);
$immediateConfiguration = $this->configurationService->convertFlexFormContentToArray($row[$fieldName], $form, NULL, NULL);
return $immediateConfiguration;
}

}
3 changes: 3 additions & 0 deletions ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ autoload = 1

# cat=basic/enable; type=input; label=Doktypes: CSV list of doktypes to add the page layout selectors to in addition to the default standard pages and shortcuts (0,1,4). Possible use cases are sysfolders (254) or custom page types.
doktypes =

# cat=basic/enable; type=boolean; label=Enable translation of Page Configuration through the Pages Language Overlays.
pagesLanguageConfigurationOverlay = 0
2 changes: 2 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

\FluidTYPO3\Flux\Core::registerConfigurationProvider('FluidTYPO3\Fluidpages\Provider\PageProvider');
\FluidTYPO3\Flux\Core::registerConfigurationProvider('FluidTYPO3\Fluidpages\Provider\SubPageProvider');
\FluidTYPO3\Flux\Core::registerConfigurationProvider('FluidTYPO3\Fluidpages\Provider\PageLanguageOverlayProvider');
\FluidTYPO3\Flux\Core::registerConfigurationProvider('FluidTYPO3\Fluidpages\Provider\SubPageLanguageOverlayProvider');

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'FluidTYPO3.Fluidpages',
Expand Down
27 changes: 27 additions & 0 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,30 @@
$GLOBALS['TCA']['pages']['ctrl']['requestUpdate'] .= ',tx_fluidpages_templatefile';

unset($doktypes, $additionalDoktypes, $doktypeIcon);

if (TRUE === isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fluidpages']['setup']['pagesLanguageConfigurationOverlay'])
&& TRUE === (boolean) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fluidpages']['setup']['pagesLanguageConfigurationOverlay']) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages_language_overlay', array(
'tx_fed_page_flexform' => Array (
'exclude' => 1,
'label' => 'LLL:EXT:fluidpages/Resources/Private/Language/locallang.xlf:pages.tx_fed_page_flexform',
'config' => array (
'type' => 'flex',
)
),
'tx_fed_page_flexform_sub' => Array (
'exclude' => 1,
'label' => 'LLL:EXT:fluidpages/Resources/Private/Language/locallang.xlf:pages.tx_fed_page_flexform_sub',
'config' => array (
'type' => 'flex',
)
),
));

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'pages_language_overlay',
'--div--;LLL:EXT:fluidpages/Resources/Private/Language/locallang.xlf:pages.tx_fed_page_configuration,tx_fed_page_flexform,tx_fed_page_flexform_sub'
);

$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] .= ',tx_fed_page_flexform,tx_fed_page_flexform_sub';
}
10 changes: 9 additions & 1 deletion ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ CREATE TABLE pages (
tx_fed_page_flexform_sub text,
tx_fed_page_controller_action varchar(255) DEFAULT '' NOT NULL,
tx_fed_page_controller_action_sub varchar(255) DEFAULT '' NOT NULL,
);
);

#
# Table structure for table 'pages_language_overlay'
#
CREATE TABLE pages_language_overlay (
tx_fed_page_flexform text,
tx_fed_page_flexform_sub text
);

0 comments on commit 271f09b

Please sign in to comment.