diff --git a/Classes/Backend/ItemsProcFuncs/AbstractItemsProcFunc.php b/Classes/Backend/ItemsProcFuncs/AbstractItemsProcFunc.php index d44f76e..c64ff7a 100644 --- a/Classes/Backend/ItemsProcFuncs/AbstractItemsProcFunc.php +++ b/Classes/Backend/ItemsProcFuncs/AbstractItemsProcFunc.php @@ -23,18 +23,14 @@ use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Backend\View\BackendLayoutView; use TYPO3\CMS\Core\Database\QueryGenerator; use TYPO3\CMS\Core\SingletonInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Lang\LanguageService; /** * Class/Function which offers TCE main hook functions. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ abstract class AbstractItemsProcFunc implements SingletonInterface { @@ -65,62 +61,7 @@ public function init() */ public function getSelectedBackendLayout($pageId) { - if (empty($GLOBALS['tx_gridelements']['pageBackendLayoutData'][$pageId])) { - $backendLayoutData = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getSelectedBackendLayout', - $pageId, $this); - // add allowed CTypes to the columns, since this is not done by the native core methods - if (!empty($backendLayoutData['__items'])) { - $backendLayoutData['columns']['CSV'] = '-2,-1'; - if (!empty($backendLayoutData['__config']['backend_layout.']['rows.'])) { - $allowed = []; - $disallowed = []; - $maxItems = []; - foreach ($backendLayoutData['__config']['backend_layout.']['rows.'] as $row) { - if (!empty($row['columns.'])) { - foreach ($row['columns.'] as $column) { - if (!isset($column['colPos'])) { - continue; - } - $colPos = (int)$column['colPos']; - if (isset($column['allowed.'])) { - $column['allowed'] = $column['allowed.']; - } - if (isset($column['disallowed.'])) { - $column['disallowed'] = $column['disallowed.']; - } - if (!is_array($column['allowed']) && !empty($column['allowed'])) { - $allowed[$colPos] = ['CType' => $column['allowed']]; - } else if (empty($column['allowed'])) { - $allowed[$colPos] = ['CType' => '*']; - } else { - $allowed[$colPos] = $column['allowed']; - } - if ($column['allowedGridTypes']) { - $allowed[$colPos]['tx_gridelements_backend_layout'] = $column['allowedGridTypes']; - } - if (!empty($column['disallowed'])) { - $disallowed[$colPos] = $column['disallowed']; - } - if (!empty($column['maxitems'])) { - $maxItems[$colPos] = $column['maxitems']; - } - $backendLayoutData['columns']['CSV'] .= ',' . $colPos; - } - } - } - $backendLayoutData['allowed'] = $allowed; - if (!empty($disallowed)) { - $backendLayoutData['disallowed'] = $disallowed; - } - if (!empty($maxItems)) { - $backendLayoutData['maxitems'] = $maxItems; - } - } - $backendLayoutData = Helper::getInstance()->mergeAllowedDisallowedSettings($backendLayoutData); - }; - $GLOBALS['tx_gridelements']['pageBackendLayoutData'][$pageId] = $backendLayoutData; - } - return $GLOBALS['tx_gridelements']['pageBackendLayoutData'][$pageId]; + return Helper::getInstance()->getSelectedBackendLayout($pageId); } /** @@ -166,5 +107,4 @@ public function getBackendUser() { return $GLOBALS['BE_USER']; } - } diff --git a/Classes/Backend/ItemsProcFuncs/CTypeList.php b/Classes/Backend/ItemsProcFuncs/CTypeList.php index ef1b61f..54047c2 100644 --- a/Classes/Backend/ItemsProcFuncs/CTypeList.php +++ b/Classes/Backend/ItemsProcFuncs/CTypeList.php @@ -21,7 +21,6 @@ ***************************************************************/ use GridElementsTeam\Gridelements\Backend\LayoutSetup; -use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -29,8 +28,6 @@ * Class/Function which manipulates the item-array for table/field tt_content CType. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class CTypeList extends AbstractItemsProcFunc { @@ -49,16 +46,26 @@ public function itemsProcFunc(array &$params) { if ((int)$params['row']['pid'] > 0) { $colPos = is_array($params['row']['colPos']) ? $params['row']['colPos'][0] : $params['row']['colPos']; - $this->checkForAllowedCTypes($params['items'], $params['row']['pid'], $colPos, - $params['row']['tx_gridelements_container'], $params['row']['tx_gridelements_columns']); + $this->checkForAllowedCTypes( + $params['items'], + $params['row']['pid'], + $colPos, + $params['row']['tx_gridelements_container'], + $params['row']['tx_gridelements_columns'] + ); } else { $this->init((int)$params['row']['pid']); // negative uid_pid values indicate that the element has been inserted after an existing element // so there is no pid to get the backendLayout for and we have to get that first $existingElement = BackendUtility::getRecordWSOL('tt_content', -((int)$params['row']['pid']), 'pid,CType,colPos,tx_gridelements_container,tx_gridelements_columns'); if ((int)$existingElement['pid'] > 0) { - $this->checkForAllowedCTypes($params['items'], $existingElement['pid'], $existingElement['colPos'], - $existingElement['tx_gridelements_container'], $existingElement['tx_gridelements_columns']); + $this->checkForAllowedCTypes( + $params['items'], + $existingElement['pid'], + $existingElement['colPos'], + $existingElement['tx_gridelements_container'], + $existingElement['tx_gridelements_columns'] + ); } } } @@ -89,7 +96,7 @@ public function checkForAllowedCTypes(array &$items, $pageId, $pageColumn, $grid if (is_array($layout['allowed']) && is_array($layout['allowed'][$column]) && !empty($layout['allowed'][$column]['CType'])) { $allowed = $layout['allowed'][$column]['CType']; } - if (is_array($layout['disallowed']) && is_array($layout['disallowed'][$column]) && !empty($layout['disallowed'][$column]['CType'])){ + if (is_array($layout['disallowed']) && is_array($layout['disallowed'][$column]) && !empty($layout['disallowed'][$column]['CType'])) { $disallowed = $layout['disallowed'][$column]['CType']; } } @@ -122,9 +129,6 @@ public function init($pageId = 0) { parent::init(); if (!$this->layoutSetup) { - if ($pageId < 0) { - $pageId = Helper::getInstance()->getPidFromNegativeUid($pageId); - } $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageId)); } } diff --git a/Classes/Backend/ItemsProcFuncs/ColPosList.php b/Classes/Backend/ItemsProcFuncs/ColPosList.php index 23b8caa..d1794aa 100644 --- a/Classes/Backend/ItemsProcFuncs/ColPosList.php +++ b/Classes/Backend/ItemsProcFuncs/ColPosList.php @@ -26,8 +26,6 @@ * Class/Function which manipulates the item-array for table/field tt_content colPos. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class ColPosList extends AbstractItemsProcFunc { @@ -43,17 +41,31 @@ public function itemsProcFunc(array &$params) $contentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType']; $listType = is_array($params['row']['list_type']) ? $params['row']['list_type'][0] : $params['row']['list_type']; $gridType = is_array($params['row']['tx_gridelements_backend_layout']) ? $params['row']['tx_gridelements_backend_layout'][0] : $params['row']['tx_gridelements_backend_layout']; - $params['items'] = $this->addColPosListLayoutItems($params['row']['pid'], $params['items'], $contentType, - $listType, $gridType, $params['row']['tx_gridelements_container']); + $params['items'] = $this->addColPosListLayoutItems( + $params['row']['pid'], + $params['items'], + $contentType, + $listType, + $gridType, + $params['row']['tx_gridelements_container'] + ); } else { // negative uid_pid values indicate that the element has been inserted after an existing element // so there is no pid to get the backendLayout for and we have to get that first - $existingElement = BackendUtility::getRecordWSOL('tt_content', -((int)$params['row']['pid']), - 'pid,CType,tx_gridelements_container'); + $existingElement = BackendUtility::getRecordWSOL( + 'tt_content', + -((int)$params['row']['pid']), + 'pid,CType,tx_gridelements_container' + ); if ($existingElement['pid'] > 0) { - $params['items'] = $this->addColPosListLayoutItems($existingElement['pid'], $params['items'], - $existingElement['CType'], $existingElement['list_type'], - $existingElement['tx_gridelements_backend_layout'], $existingElement['tx_gridelements_container']); + $params['items'] = $this->addColPosListLayoutItems( + $existingElement['pid'], + $params['items'], + $existingElement['CType'], + $existingElement['list_type'], + $existingElement['tx_gridelements_backend_layout'], + $existingElement['tx_gridelements_container'] + ); } } } diff --git a/Classes/Backend/ItemsProcFuncs/ListTypeList.php b/Classes/Backend/ItemsProcFuncs/ListTypeList.php index f15ee4f..4381cb8 100644 --- a/Classes/Backend/ItemsProcFuncs/ListTypeList.php +++ b/Classes/Backend/ItemsProcFuncs/ListTypeList.php @@ -21,7 +21,6 @@ ***************************************************************/ use GridElementsTeam\Gridelements\Backend\LayoutSetup; -use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -29,8 +28,6 @@ * Class/Function which manipulates the item-array for table/field tt_content CType. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class ListTypeList extends AbstractItemsProcFunc { @@ -49,16 +46,26 @@ public function itemsProcFunc(array &$params) { if ((int)$params['row']['pid'] > 0) { $colPos = is_array($params['row']['colPos']) ? $params['row']['colPos'][0] : $params['row']['colPos']; - $this->checkForAllowedListTypes($params['items'], $params['row']['pid'], $colPos, - $params['row']['tx_gridelements_container'], $params['row']['tx_gridelements_columns']); + $this->checkForAllowedListTypes( + $params['items'], + $params['row']['pid'], + $colPos, + $params['row']['tx_gridelements_container'], + $params['row']['tx_gridelements_columns'] + ); } else { $this->init((int)$params['row']['pid']); // negative uid_pid values indicate that the element has been inserted after an existing element // so there is no pid to get the backendLayout for and we have to get that first $existingElement = BackendUtility::getRecordWSOL('tt_content', -((int)$params['row']['pid']), 'pid,list_type,colPos,tx_gridelements_container,tx_gridelements_columns'); if ((int)$existingElement['pid'] > 0) { - $this->checkForAllowedListTypes($params['items'], $existingElement['pid'], $existingElement['colPos'], - $existingElement['tx_gridelements_container'], $existingElement['tx_gridelements_columns']); + $this->checkForAllowedListTypes( + $params['items'], + $existingElement['pid'], + $existingElement['colPos'], + $existingElement['tx_gridelements_container'], + $existingElement['tx_gridelements_columns'] + ); } } } @@ -89,7 +96,7 @@ public function checkForAllowedListTypes(array &$items, $pageId, $pageColumn, $g if (is_array($layout['allowed']) && is_array($layout['allowed'][$column]) && !empty($layout['allowed'][$column]['list_type'])) { $allowed = $layout['allowed'][$column]['list_type']; } - if (is_array($layout['disallowed']) && is_array($layout['disallowed'][$column]) && !empty($layout['disallowed'][$column]['list_type'])){ + if (is_array($layout['disallowed']) && is_array($layout['disallowed'][$column]) && !empty($layout['disallowed'][$column]['list_type'])) { $disallowed = $layout['disallowed'][$column]['list_type']; } } @@ -122,9 +129,6 @@ public function init($pageId = 0) { parent::init(); if (!$this->layoutSetup) { - if ($pageId < 0) { - $pageId = Helper::getInstance()->getPidFromNegativeUid($pageId); - } $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageId)); } } diff --git a/Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php b/Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php index a283f89..9413322 100644 --- a/Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php +++ b/Classes/Backend/ItemsProcFuncs/SysLanguageUidList.php @@ -26,8 +26,6 @@ * Class/Function which manipulates the item-array for table/field tt_content CType. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class SysLanguageUidList extends AbstractItemsProcFunc { @@ -61,6 +59,6 @@ public function checkForAllowedLanguages(array &$items, $gridContainerId) unset($items[$item]); } } - }; + } } } diff --git a/Classes/Backend/LayoutSetup.php b/Classes/Backend/LayoutSetup.php index 4d19621..def2448 100644 --- a/Classes/Backend/LayoutSetup.php +++ b/Classes/Backend/LayoutSetup.php @@ -37,8 +37,6 @@ * Utilities for gridelements. * * @author Arno Dudek - * @package TYPO3 - * @subpackage tx_gridelements */ class LayoutSetup { @@ -68,6 +66,11 @@ class LayoutSetup */ protected $flexformConfigurationPathAndFileName = 'EXT:gridelements/Configuration/FlexForms/default_flexform_configuration.xml'; + /** + * @var int + */ + protected $realPid; + /** * Load page TSconfig * @@ -80,6 +83,10 @@ public function init($pageId, array $typoScriptSetup = []) { $this->setLanguageService($GLOBALS['LANG']); $pageId = (strpos($pageId, 'NEW') === 0) ? 0 : (int)$pageId; + if ((int)$pageId < 0) { + $pageId = Helper::getInstance()->getPidFromUid($pageId); + } + $this->realPid = $pageId; $this->loadLayoutSetup($pageId); foreach ($this->layoutSetup as $key => $setup) { $columns = $this->getLayoutColumns($key); @@ -161,8 +168,10 @@ protected function loadLayoutSetup($pageId) ? (int)$pageTSconfig['TCEFORM.']['pages.']['_STORAGE_PID'] : 0; $pageTSconfigId = isset($pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID']) - ? implode(',', GeneralUtility::intExplode(',', - $pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID'])) + ? implode(',', GeneralUtility::intExplode( + ',', + $pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID'] + )) : 0; // Load records. @@ -177,15 +186,21 @@ protected function loadLayoutSetup($pageId) $queryBuilder->expr()->comparison($storagePid, '=', 0) ), $queryBuilder->expr()->orX( - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$pageTSconfigId, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$storagePid, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$pageTSconfigId, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$storagePid, \PDO::PARAM_INT) + ) ), $queryBuilder->expr()->andX( $queryBuilder->expr()->comparison($pageTSconfigId, '=', 0), - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$pageId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$pageId, \PDO::PARAM_INT) + ) ) ) ) @@ -225,7 +240,6 @@ protected function loadLayoutSetup($pageId) } $gridLayoutRecords[$layoutId] = $item; - } if ($overruleRecords === true) { @@ -244,6 +258,7 @@ protected function loadLayoutSetup($pageId) */ public function getQueryBuilder() { + /** @var $queryBuilder QueryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tx_gridelements_backend_layout'); $queryBuilder->getRestrictions() @@ -280,7 +295,8 @@ public function getLayoutColumns($layoutId) * @param bool $csvValues * @return array */ - public function checkAvailableColumns($setup, $csvValues = false) { + public function checkAvailableColumns($setup, $csvValues = false) + { $availableColumns = ['CSV' => '-2,-1']; $allowed = []; $disallowed = []; @@ -300,10 +316,12 @@ public function checkAvailableColumns($setup, $csvValues = false) { } if (!is_array($column['allowed']) && !empty($column['allowed'])) { $allowed[$colPos] = ['CType' => $column['allowed']]; - } else if (empty($column['allowed'])) { - $allowed[$colPos] = ['CType' => '*']; } else { - $allowed[$colPos] = $column['allowed']; + if (empty($column['allowed'])) { + $allowed[$colPos] = ['CType' => '*']; + } else { + $allowed[$colPos] = $column['allowed']; + } } if ($column['allowedGridTypes']) { $allowed[$colPos]['tx_gridelements_backend_layout'] = $column['allowedGridTypes']; @@ -390,38 +408,16 @@ public function setFlexformConfigurationPathAndFileName($flexformConfigurationPa $this->flexformConfigurationPathAndFileName = $flexformConfigurationPathAndFileName; } - /** - * Caches Container-Records and their setup to avoid multiple selects of the same record during a single request - * - * @param int $gridContainerId The ID of the current grid container - * @param bool $doReturn - * - * @return null|array - */ - public function cacheCurrentParent($gridContainerId = 0, $doReturn = false) - { - if ($gridContainerId > 0) { - if (empty($GLOBALS['tx_gridelements']['parentElement'][$gridContainerId])) { - $GLOBALS['tx_gridelements']['parentElement'][$gridContainerId] = BackendUtility::getRecordWSOL('tt_content', - $gridContainerId); - } - } - if ($doReturn) { - return $GLOBALS['tx_gridelements']['parentElement'][$gridContainerId]; - }; - - return null; - } - /** * Returns the item array for form field selection. * - * @param int $colPos The selected content column position. * + * @param int $colPos The selected content column position. * @param int $gridColPos * @param int $containerId + * @param int $pageId * @return array */ - public function getLayoutSelectItems($colPos, $gridColPos = 0, $containerId = 0) + public function getLayoutSelectItems($colPos, $gridColPos = 0, $containerId = 0, $pageId = 0) { $allowed = ['*' => '*']; $disallowed = []; @@ -433,6 +429,12 @@ public function getLayoutSelectItems($colPos, $gridColPos = 0, $containerId = 0) $allowed = $containerLayout['allowed'][$gridColPos]['tx_gridelements_backend_layout']; $disallowed = $containerLayout['disallowed'][$gridColPos]['tx_gridelements_backend_layout']; } + } elseif ($pageId > 0) { + $pageLayout = Helper::getInstance()->getSelectedBackendLayout($pageId); + if (!empty($pageLayout)) { + $allowed = $pageLayout['allowed'][$colPos]['tx_gridelements_backend_layout']; + $disallowed = $pageLayout['disallowed'][$colPos]['tx_gridelements_backend_layout']; + } } foreach ($this->layoutSetup as $layoutId => $item) { if (( @@ -472,6 +474,31 @@ public function getLayoutSelectItems($colPos, $gridColPos = 0, $containerId = 0) return $selectItems; } + /** + * Caches Container-Records and their setup to avoid multiple selects of the same record during a single request + * + * @param int $gridContainerId The ID of the current grid container + * @param bool $doReturn + * + * @return array|null + */ + public function cacheCurrentParent($gridContainerId = 0, $doReturn = false) + { + if ($gridContainerId > 0) { + if (empty($GLOBALS['tx_gridelements']['parentElement'][$gridContainerId])) { + $GLOBALS['tx_gridelements']['parentElement'][$gridContainerId] = BackendUtility::getRecordWSOL( + 'tt_content', + $gridContainerId + ); + } + } + if ($doReturn) { + return $GLOBALS['tx_gridelements']['parentElement'][$gridContainerId]; + } + + return null; + } + /** * Returns the item array for form field selection * @@ -552,8 +579,12 @@ public function setSingleLayoutSetup($key, array $layoutSetup) * * @return array */ - public function getLayoutWizardItems($colPos, $excludeLayouts = '', array $allowedGridTypes = [], array $disallowedGridTypes = []) - { + public function getLayoutWizardItems( + $colPos, + $excludeLayouts = '', + array $allowedGridTypes = [], + array $disallowedGridTypes = [] + ) { $wizardItems = []; $excludeLayouts = array_flip(explode(',', $excludeLayouts)); foreach ($this->layoutSetup as $layoutId => $item) { @@ -562,8 +593,7 @@ public function getLayoutWizardItems($colPos, $excludeLayouts = '', array $allow !isset($allowedGridTypes[$layoutId]) ) || isset($disallowedGridTypes[$layoutId]) - ) - { + ) { continue; } if (isset($excludeLayouts[$item['uid']]) || (int)$colPos === -1 && $item['top_level_layout']) { @@ -578,7 +608,6 @@ public function getLayoutWizardItems($colPos, $excludeLayouts = '', array $allow 'iconIdentifier' => $item['iconIdentifier'], 'tll' => $item['top_level_layout'], ]; - } return $wizardItems; @@ -598,8 +627,10 @@ public function getFlexformConfiguration($layoutId) if ($layoutSetup['pi_flexform_ds_file']) { $flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($layoutSetup['pi_flexform_ds_file'])); } elseif (strpos($layoutSetup['pi_flexform_ds'], 'FILE:') === 0) { - $flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName(substr($layoutSetup['pi_flexform_ds'], - 5))); + $flexformConfiguration = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName(substr( + $layoutSetup['pi_flexform_ds'], + 5 + ))); } elseif ($layoutSetup['pi_flexform_ds']) { $flexformConfiguration = $layoutSetup['pi_flexform_ds']; } else { @@ -652,4 +683,13 @@ public function getBackendUser() return $GLOBALS['BE_USER']; } + /** + * Gets the current real pid. + * + * @return int + */ + public function getRealPid() + { + return $this->realPid; + } } diff --git a/Classes/Backend/TtContent.php b/Classes/Backend/TtContent.php index 1f69d34..00cfc43 100644 --- a/Classes/Backend/TtContent.php +++ b/Classes/Backend/TtContent.php @@ -20,7 +20,6 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; @@ -32,8 +31,6 @@ * Class/Function which manipulates the item-array for table/field tt_content_tx_gridelements_columns. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class TtContent { @@ -80,9 +77,6 @@ public function columnsItemsProcFunc(array &$params) public function init($pageId) { if (!$this->layoutSetup instanceof LayoutSetup) { - if ($pageId < 0) { - $pageId = Helper::getInstance()->getPidFromNegativeUid($pageId); - } $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageId)); } } @@ -170,8 +164,10 @@ public function lookForChildContainersRecursively($containerIds, array &$possibl ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('gridelements_pi1')), - $queryBuilder->expr()->in('tx_gridelements_container', - $queryBuilder->createNamedParameter($containerIds, Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'tx_gridelements_container', + $queryBuilder->createNamedParameter($containerIds, Connection::PARAM_INT_ARRAY) + ) ) ) ->execute() @@ -201,6 +197,7 @@ public function lookForChildContainersRecursively($containerIds, array &$possibl */ public function getQueryBuilder() { + /** @var $queryBuilder QueryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tt_content'); $queryBuilder->getRestrictions() @@ -230,8 +227,10 @@ public function deleteDisallowedContainers(array &$params, $itemUidList = '') ->select('uid', 'tx_gridelements_backend_layout') ->from('tt_content') ->where( - $queryBuilder->expr()->in('uid', - $queryBuilder->createNamedParameter($itemUidList, Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter($itemUidList, Connection::PARAM_INT_ARRAY) + ) ) ->execute(); $containers = []; @@ -293,9 +292,12 @@ public function deleteDisallowedContainers(array &$params, $itemUidList = '') public function layoutItemsProcFunc(array &$params) { $this->init($params['row']['pid']); - $layoutSelectItems = $this->layoutSetup->getLayoutSelectItems($params['row']['colPos'][0] ?: $params['row']['colPos'], $params['row']['tx_gridelements_columns'], $params['row']['tx_gridelements_container']); + $layoutSelectItems = $this->layoutSetup->getLayoutSelectItems( + isset($params['row']['colPos'][0]) ? $params['row']['colPos'][0] : $params['row']['colPos'], + $params['row']['tx_gridelements_columns'], + $params['row']['tx_gridelements_container'], + $this->layoutSetup->getRealPid() + ); $params['items'] = ArrayUtility::keepItemsInArray($layoutSelectItems, $params['items'], true); } - - } diff --git a/Classes/ContextMenu/ItemProvider.php b/Classes/ContextMenu/ItemProvider.php index 56779dd..f0d1eab 100644 --- a/Classes/ContextMenu/ItemProvider.php +++ b/Classes/ContextMenu/ItemProvider.php @@ -94,8 +94,12 @@ protected function canRender(string $itemName, string $type): bool { $canRender = false; if ($itemName === 'pastereference') { - $canRender = $this->canBePastedAfter() && $this->clipboard->currentMode() === 'copy' && $this->backendUser->checkAuthMode('tt_content', - 'CType', 'shortcut', $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode']); + $canRender = $this->canBePastedAfter() && $this->clipboard->currentMode() === 'copy' && $this->backendUser->checkAuthMode( + 'tt_content', + 'CType', + 'shortcut', + $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] + ); } return $canRender; } diff --git a/Classes/DataHandler/AbstractDataHandler.php b/Classes/DataHandler/AbstractDataHandler.php index 3c3586b..13adb47 100644 --- a/Classes/DataHandler/AbstractDataHandler.php +++ b/Classes/DataHandler/AbstractDataHandler.php @@ -25,7 +25,9 @@ use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; -use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; +use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction; +use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; +use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -33,8 +35,6 @@ * Class/Function which offers TCE main hook functions. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ abstract class AbstractDataHandler { @@ -53,6 +53,11 @@ abstract class AbstractDataHandler */ protected $pageUid; + /** + * @var int + */ + protected $contentUid = 0; + /** * @var DataHandler */ @@ -67,22 +72,45 @@ abstract class AbstractDataHandler * initializes this class * * @param string $table : The name of the table the data should be saved to - * @param integer $uidPid : The uid of the record or page we are currently working on + * @param int $uidPid : The uid of the record or page we are currently working on * @param DataHandler $dataHandler */ public function init($table, $uidPid, DataHandler $dataHandler) { $this->setTable($table); - $this->setPageUid($uidPid); + if ($table === 'tt_content' && (int)$uidPid < 0) { + $this->setContentUid(abs($uidPid)); + $pageUid = Helper::getInstance()->getPidFromUid($this->getContentUid()); + $this->setPageUid($pageUid); + } else { + $this->setPageUid((int)$uidPid); + } $this->setTceMain($dataHandler); if (!$this->layoutSetup instanceof LayoutSetup) { - if ($uidPid < 0) { - $uidPid = Helper::getInstance()->getPidFromNegativeUid($uidPid); - } - $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($uidPid)); + $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($this->getPageUid())); } } + /** + * getter for contentUid + * + * @return int contentUid + */ + public function getContentUid() + { + return $this->contentUid; + } + + /** + * setter for contentUid + * + * @param int $contentUid + */ + public function setContentUid($contentUid) + { + $this->contentUid = $contentUid; + } + /** * setter for dataHandler object * @@ -103,6 +131,75 @@ public function injectLayoutSetup(LayoutSetup $layoutSetup) $this->layoutSetup = $layoutSetup; } + /** + * getter for pageUid + * + * @return int pageUid + */ + public function getPageUid() + { + return $this->pageUid; + } + + /** + * setter for pageUid + * + * @param int $pageUid + */ + public function setPageUid($pageUid) + { + $this->pageUid = $pageUid; + } + + /** + * Function to remove any remains of versioned records after finalizing a workspace action + * via 'Discard' or 'Publish' commands + */ + public function cleanupWorkspacesAfterFinalizing() + { + $queryBuilder = $this->getQueryBuilder(); + + $constraints = [ + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->eq( + 't3ver_wsid', + $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->gt( + 't3ver_id', + $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) + ) + ), + ]; + + $queryBuilder->delete('tt_content') + ->where(...$constraints) + ->execute(); + } + + /** + * getter for queryBuilder + * + * @param string $table + * @return QueryBuilder $queryBuilder + */ + public function getQueryBuilder($table = 'tt_content') + { + /**@var $queryBuilder QueryBuilder */ + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) + ->getQueryBuilderForTable($table); + $queryBuilder->getRestrictions() + ->removeByType(HiddenRestriction::class) + ->removeByType(StartTimeRestriction::class) + ->removeByType(EndTimeRestriction::class); + + return $queryBuilder; + } + /** * Function to handle record actions for current or former children of translated grid containers * as well as translated references @@ -116,8 +213,14 @@ public function checkAndUpdateTranslatedElements($uid) } $queryBuilder = $this->getQueryBuilder(); $currentValues = $queryBuilder - ->select('uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', - 'l18n_parent') + ->select( + 'uid', + 'tx_gridelements_container', + 'tx_gridelements_columns', + 'sys_language_uid', + 'colPos', + 'l18n_parent' + ) ->from('tt_content') ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT)) @@ -126,30 +229,57 @@ public function checkAndUpdateTranslatedElements($uid) ->execute() ->fetch(); if (!empty($currentValues['l18n_parent'])) { + $originalUid = (int)$currentValues['uid']; $queryBuilder = $this->getQueryBuilder(); $currentValues = $queryBuilder - ->select('uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', - 'l18n_parent') + ->select( + 'uid', + 'tx_gridelements_container', + 'tx_gridelements_columns', + 'sys_language_uid', + 'colPos', + 'l18n_parent' + ) ->from('tt_content') ->where( - $queryBuilder->expr()->eq('uid', - $queryBuilder->createNamedParameter((int)$currentValues['l18n_parent'], \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 'uid', + $queryBuilder->createNamedParameter((int)$currentValues['l18n_parent'], \PDO::PARAM_INT) + ) ) ->setMaxResults(1) ->execute() ->fetch(); + + $updateArray = $currentValues; + unset($updateArray['uid']); + unset($updateArray['sys_language_uid']); + unset($updateArray['l18n_parent']); + $this->getConnection()->update( + 'tt_content', + $updateArray, + ['uid' => (int)$originalUid] + ); } if (empty($currentValues['uid'])) { return; } $queryBuilder = $this->getQueryBuilder(); $translatedElementQuery = $queryBuilder - ->select('uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', - 'l18n_parent') + ->select( + 'uid', + 'tx_gridelements_container', + 'tx_gridelements_columns', + 'sys_language_uid', + 'colPos', + 'l18n_parent' + ) ->from('tt_content') ->where( - $queryBuilder->expr()->eq('l18n_parent', - $queryBuilder->createNamedParameter((int)$currentValues['uid'], \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 'l18n_parent', + $queryBuilder->createNamedParameter((int)$currentValues['uid'], \PDO::PARAM_INT) + ) ) ->execute(); $translatedElements = []; @@ -166,9 +296,13 @@ public function checkAndUpdateTranslatedElements($uid) ->select('uid', 'sys_language_uid') ->from('tt_content') ->where( - $queryBuilder->expr()->eq('l18n_parent', - $queryBuilder->createNamedParameter((int)$currentValues['tx_gridelements_container'], - \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 'l18n_parent', + $queryBuilder->createNamedParameter( + (int)$currentValues['tx_gridelements_container'], + \PDO::PARAM_INT + ) + ) ) ->execute(); while ($translatedContainer = $translatedContainerQuery->fetch()) { @@ -181,9 +315,14 @@ public function checkAndUpdateTranslatedElements($uid) if (isset($translatedContainers[$translatedElement['sys_language_uid']])) { $updateArray['tx_gridelements_container'] = (int)$translatedContainers[$translatedElement['sys_language_uid']]['uid']; $updateArray['tx_gridelements_columns'] = (int)$currentValues['tx_gridelements_columns']; - } else if ($translatedElement['tx_gridelements_container'] == $currentValues['tx_gridelements_container']) { - $updateArray['tx_gridelements_container'] = (int)$currentValues['tx_gridelements_container']; - $updateArray['tx_gridelements_columns'] = (int)$currentValues['tx_gridelements_columns']; + } else { + if ($translatedElement['tx_gridelements_container'] == $currentValues['tx_gridelements_container']) { + $updateArray['tx_gridelements_container'] = (int)$currentValues['tx_gridelements_container']; + $updateArray['tx_gridelements_columns'] = (int)$currentValues['tx_gridelements_columns']; + } else { + $updateArray['tx_gridelements_container'] = 0; + $updateArray['tx_gridelements_columns'] = 0; + } } $updateArray['colPos'] = (int)$currentValues['colPos']; @@ -206,22 +345,6 @@ public function checkAndUpdateTranslatedElements($uid) } } - /** - * getter for queryBuilder - * - * @return QueryBuilder queryBuilder - */ - public function getQueryBuilder() - { - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) - ->getQueryBuilderForTable('tt_content'); - $queryBuilder->getRestrictions() - ->removeAll() - ->add(GeneralUtility::makeInstance(DeletedRestriction::class)); - return $queryBuilder; - } - - /** * setter for Connection object * @@ -230,7 +353,7 @@ public function getQueryBuilder() public function getConnection() { return GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('tt_content');; + ->getConnectionForTable('tt_content'); } /** @@ -293,25 +416,4 @@ public function setTable($table) { $this->table = $table; } - - /** - * getter for pageUid - * - * @return integer pageUid - */ - public function getPageUid() - { - return $this->pageUid; - } - - /** - * setter for pageUid - * - * @param integer $pageUid - */ - public function setPageUid($pageUid) - { - $this->pageUid = $pageUid; - } - } diff --git a/Classes/DataHandler/AfterDatabaseOperations.php b/Classes/DataHandler/AfterDatabaseOperations.php index 582a7d0..b3b73f0 100644 --- a/Classes/DataHandler/AfterDatabaseOperations.php +++ b/Classes/DataHandler/AfterDatabaseOperations.php @@ -23,7 +23,6 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\BackendLayoutView; use TYPO3\CMS\Core\Database\Connection; -use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -31,11 +30,49 @@ * Class/Function which offers TCE main hook functions. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class AfterDatabaseOperations extends AbstractDataHandler { + /** + * Function to adjust colPos, container and grid column of an element + * after it has been moved out of or into a container during a workspace operation + * + * @param array $fieldArray The array of fields and values that have been saved to the datamap + * @param int $uid the ID of the record + * @param DataHandler $parentObj The parent object that triggered this hook + */ + public function adjustValuesAfterWorkspaceOperations(array $fieldArray, $uid, DataHandler $parentObj) + { + $workspace = $this->getBackendUser()->workspace; + if ($workspace && (isset($fieldArray['colPos']) || isset($fieldArray['tx_gridelements_container']) || isset($fieldArray['tx_gridelements_columns']))) { + $originalRecord = $parentObj->recordInfo('tt_content', (int)$uid, '*'); + if ($originalRecord['t3ver_state'] === 4) { + $updateArray = []; + $movePlaceholder = BackendUtility::getMovePlaceholder('tt_content', (int)$uid, 'uid', $workspace); + if (isset($fieldArray['colPos'])) { + $updateArray['colPos'] = (int)$fieldArray['colPos']; + } + if (isset($fieldArray['tx_gridelements_container'])) { + $updateArray['tx_gridelements_container'] = (int)$fieldArray['tx_gridelements_container']; + } + if (isset($fieldArray['tx_gridelements_columns'])) { + $updateArray['tx_gridelements_columns'] = (int)$fieldArray['tx_gridelements_columns']; + } + $parentObj->updateDB('tt_content', (int)$movePlaceholder['uid'], $updateArray); + } + } + } + + /** + * Gets the current backend user. + * + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication + */ + public function getBackendUser() + { + return $GLOBALS['BE_USER']; + } + /** * Function to set the colPos of an element depending on * whether it is a child of a parent container or not @@ -52,11 +89,11 @@ class AfterDatabaseOperations extends AbstractDataHandler */ public function execute_afterDatabaseOperations(array &$fieldArray, $table, $uid, DataHandler $parentObj) { - if ($table === 'tt_content') { + if ($table === 'tt_content' || $table === 'pages') { $this->init($table, $uid, $parentObj); if (!$this->getTceMain()->isImporting) { $this->saveCleanedUpFieldArray($fieldArray); - if ((int)$uid > 0) { + if ($table === 'tt_content' && (int)$uid > 0) { $this->checkAndUpdateTranslatedElements($uid); } } @@ -91,11 +128,10 @@ public function setUnusedElements(array &$fieldArray) $changedSubPageElements = []; if ($this->getTable() === 'tt_content') { - $changedGridElements[$this->getPageUid()] = true; + $changedGridElements[$this->getContentUid()] = true; $childElementsInUnavailableColumns = []; $childElementsInAvailableColumns = []; - $availableColumns = $this->getAvailableColumns($fieldArray['tx_gridelements_backend_layout'], 'tt_content', - $this->getPageUid()); + $availableColumns = $this->getAvailableColumns($fieldArray['tx_gridelements_backend_layout'], 'tt_content'); if (!empty($availableColumns) || $availableColumns === '0') { $availableColumns = GeneralUtility::intExplode(',', $availableColumns); $queryBuilder = $this->getQueryBuilder(); @@ -104,10 +140,15 @@ public function setUnusedElements(array &$fieldArray) ->from('tt_content') ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('tx_gridelements_container', - $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT)), - $queryBuilder->expr()->notIn('tx_gridelements_columns', - $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->gt('tx_gridelements_container', 0), + $queryBuilder->expr()->eq( + 'tx_gridelements_container', + $queryBuilder->createNamedParameter((int)$this->getContentUid(), \PDO::PARAM_INT) + ), + $queryBuilder->expr()->notIn( + 'tx_gridelements_columns', + $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) + ) ) ) ->execute(); @@ -119,9 +160,13 @@ public function setUnusedElements(array &$fieldArray) $queryBuilder ->update('tt_content') ->where( - $queryBuilder->expr()->in('uid', - $queryBuilder->createNamedParameter($childElementsInUnavailableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter( + $childElementsInUnavailableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) ->set('colPos', -2) ->set('backupColPos', -1) @@ -135,10 +180,15 @@ public function setUnusedElements(array &$fieldArray) ->from('tt_content') ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('tx_gridelements_container', - $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT)), - $queryBuilder->expr()->in('tx_gridelements_columns', - $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->gt('tx_gridelements_container', 0), + $queryBuilder->expr()->eq( + 'tx_gridelements_container', + $queryBuilder->createNamedParameter((int)$this->getContentUid(), \PDO::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'tx_gridelements_columns', + $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) + ) ) ) ->execute(); @@ -150,9 +200,13 @@ public function setUnusedElements(array &$fieldArray) $queryBuilder ->update('tt_content') ->where( - $queryBuilder->expr()->in('uid', - $queryBuilder->createNamedParameter($childElementsInAvailableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter( + $childElementsInAvailableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) ->set('colPos', -1) ->set('backupColPos', -2) @@ -168,8 +222,11 @@ public function setUnusedElements(array &$fieldArray) $backendLayoutNextLevelUid = 0; $rootline = BackendUtility::BEgetRootLine($this->getPageUid()); for ($i = count($rootline); $i > 0; $i--) { - $page = BackendUtility::getRecord('pages', (int)$rootline[$i]['uid'], - 'uid,backend_layout,backend_layout_next_level'); + $page = BackendUtility::getRecord( + 'pages', + (int)$rootline[$i]['uid'], + 'uid,backend_layout,backend_layout_next_level' + ); $selectedBackendLayoutNextLevel = (int)$page['backend_layout_next_level']; if ($page['uid'] === $this->getPageUid()) { if ($fieldArray['backend_layout_next_level'] !== 0) { @@ -185,12 +242,11 @@ public function setUnusedElements(array &$fieldArray) if ($selectedBackendLayoutNextLevel === -1 && $page['uid'] !== $this->getPageUid()) { // Some previous page in our rootline sets layout_next to "None" break; - } else { - if ($selectedBackendLayoutNextLevel > 0 && $page['uid'] !== $this->getPageUid()) { - // Some previous page in our rootline sets some backend_layout, use it - $backendLayoutUid = $selectedBackendLayoutNextLevel; - break; - } + } + if ($selectedBackendLayoutNextLevel > 0 && $page['uid'] !== $this->getPageUid()) { + // Some previous page in our rootline sets some backend_layout, use it + $backendLayoutUid = $selectedBackendLayoutNextLevel; + break; } } } @@ -204,10 +260,14 @@ public function setUnusedElements(array &$fieldArray) ->from('tt_content') ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT)), - $queryBuilder->expr()->notIn('colPos', - $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT) + ), + $queryBuilder->expr()->notIn( + 'colPos', + $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) + ) ) ) ->execute(); @@ -219,11 +279,15 @@ public function setUnusedElements(array &$fieldArray) $queryBuilder ->update('tt_content') ->where( - $queryBuilder->expr()->in('uid', - $queryBuilder->createNamedParameter($elementsInUnavailableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter( + $elementsInUnavailableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) - ->set('backupColPos', $queryBuilder->quoteIdentifier('colPos')) + ->set('backupColPos', $queryBuilder->quoteIdentifier('colPos'), false) ->set('colPos', -2) ->execute(); array_flip($elementsInUnavailableColumns); @@ -235,12 +299,18 @@ public function setUnusedElements(array &$fieldArray) ->from('tt_content') ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT)), - $queryBuilder->expr()->neq('backupColPos', - $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), - $queryBuilder->expr()->in('backupColPos', - $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT) + ), + $queryBuilder->expr()->neq( + 'backupColPos', + $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'backupColPos', + $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) + ) ) ) ->execute(); @@ -252,11 +322,15 @@ public function setUnusedElements(array &$fieldArray) $queryBuilder ->update('tt_content') ->where( - $queryBuilder->expr()->in('uid', - $queryBuilder->createNamedParameter($elementsInAvailableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter( + $elementsInAvailableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) - ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos')) + ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos'), false) ->set('backupColPos', -2) ->execute(); array_flip($elementsInAvailableColumns); @@ -279,11 +353,17 @@ public function setUnusedElements(array &$fieldArray) ->from('tt_content') ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT)), - $queryBuilder->expr()->notIn('colPos', - $queryBuilder->createNamedParameter($availableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT) + ), + $queryBuilder->expr()->notIn( + 'colPos', + $queryBuilder->createNamedParameter( + $availableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) ) ->execute(); @@ -295,9 +375,13 @@ public function setUnusedElements(array &$fieldArray) $queryBuilder ->update('tt_content') ->where( - $queryBuilder->expr()->in('uid', - $queryBuilder->createNamedParameter($subPageElementsInUnavailableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter( + $subPageElementsInUnavailableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) ->set('backupColPos', $queryBuilder->quoteIdentifier('colPos'), false) ->set('colPos', -2) @@ -311,13 +395,21 @@ public function setUnusedElements(array &$fieldArray) ->from('tt_content') ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT)), - $queryBuilder->expr()->neq('backupColPos', - $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), - $queryBuilder->expr()->in('backupColPos', - $queryBuilder->createNamedParameter($availableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT) + ), + $queryBuilder->expr()->neq( + 'backupColPos', + $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'backupColPos', + $queryBuilder->createNamedParameter( + $availableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) ) ->execute(); @@ -329,11 +421,15 @@ public function setUnusedElements(array &$fieldArray) $queryBuilder ->update('tt_content') ->where( - $queryBuilder->expr()->in('uid', - $queryBuilder->createNamedParameter($subPageElementsInAvailableColumns, - Connection::PARAM_INT_ARRAY)) + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter( + $subPageElementsInAvailableColumns, + Connection::PARAM_INT_ARRAY + ) + ) ) - ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos')) + ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos'), false) ->set('backupColPos', -2) ->execute(); array_flip($subPageElementsInAvailableColumns); @@ -365,22 +461,25 @@ public function setUnusedElements(array &$fieldArray) */ public function getAvailableColumns($layout = '', $table = '', $id = 0) { - $tcaColumns = []; + $tcaColumns = ''; if ($layout && $table === 'tt_content') { $tcaColumns = $this->layoutSetup->getLayoutColumns($layout); - $tcaColumns = $tcaColumns['CSV']; + $tcaColumns = '-2,-1,' . $tcaColumns['CSV']; } elseif ($table === 'pages') { - $tcaColumns = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getColPosListItemsParsed', - $id, $this); + $tcaColumns = GeneralUtility::callUserFunction( + BackendLayoutView::class . '->getColPosListItemsParsed', + $id, + $this + ); $temp = []; - foreach ($tcaColumns AS $item) { + foreach ($tcaColumns as $item) { if (trim($item[1]) !== '') { $temp[] = (int)$item[1]; } } // Implode into a CSV string as BackendLayoutView->getColPosListItemsParsed returns an array - $tcaColumns = '-2,-1,' . implode(',', $temp); + $tcaColumns = rtrim('-2,-1,' . implode(',', $temp), ','); } return $tcaColumns; } @@ -393,13 +492,18 @@ public function getAvailableColumns($layout = '', $table = '', $id = 0) */ public function getSubPagesRecursively($pageUid, array &$subPages) { - $childPages = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('pages') - ->select( - ['uid', 'backend_layout', 'backend_layout_next_level'], - 'pages', - ['pid' => (int)$pageUid] - )->fetchAll(); + $queryBuilder = $this->getQueryBuilder('pages'); + $childPages = $queryBuilder + ->select('uid', 'backend_layout', 'backend_layout_next_level') + ->from('pages') + ->where( + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$pageUid, \PDO::PARAM_INT) + ) + ) + ->execute() + ->fetchAll(); if (!empty($childPages)) { foreach ($childPages as $page) { diff --git a/Classes/DataHandler/PreProcessFieldArray.php b/Classes/DataHandler/PreProcessFieldArray.php index b40dd4a..0fb0885 100644 --- a/Classes/DataHandler/PreProcessFieldArray.php +++ b/Classes/DataHandler/PreProcessFieldArray.php @@ -31,8 +31,6 @@ * Class/Function which offers TCE main hook functions. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class PreProcessFieldArray extends AbstractDataHandler { @@ -220,7 +218,7 @@ public function extractDefaultDataFromDataStructure($dataStructure) } $sheetArray['data'][$sheetName]['lDEF'] = $elArray; } - }; + } } if (!empty($sheetArray)) { $flexformTools = GeneralUtility::makeInstance(FlexFormTools::class); @@ -246,8 +244,11 @@ public function setFieldEntries(array &$fieldArray, $contentId = 0, $new = false $containerUpdateArray[(int)$fieldArray['tx_gridelements_container']] = 1; } if ((int)$fieldArray['tx_gridelements_container'] === 0) { - $originalContainer = BackendUtility::getRecord('tt_content', (int)$contentId, - 'tx_gridelements_container,sys_language_uid'); + $originalContainer = BackendUtility::getRecord( + 'tt_content', + (int)$contentId, + 'tx_gridelements_container,sys_language_uid' + ); if (!empty($originalContainer)) { $containerUpdateArray[(int)$originalContainer['tx_gridelements_container']] = -1; } @@ -269,20 +270,26 @@ public function setFieldEntriesForGridContainers(array &$fieldArray) if ((int)$fieldArray['tx_gridelements_container'] > 0 && isset($fieldArray['colPos']) && (int)$fieldArray['colPos'] !== -1) { $fieldArray['colPos'] = -1; $fieldArray['tx_gridelements_columns'] = 0; - $targetContainer = BackendUtility::getRecord('tt_content', (int)$fieldArray['tx_gridelements_container'], - 'sys_language_uid'); + $targetContainer = BackendUtility::getRecord( + 'tt_content', + (int)$fieldArray['tx_gridelements_container'], + 'sys_language_uid' + ); if ((int)$targetContainer['sys_language_uid'] > -1) { $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid']; } } else { if (isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] === 0 && (int)$fieldArray['colPos'] === -1) { - $fieldArray['colPos'] = $this->checkForRootColumn((int)$this->getPageUid()); + $fieldArray['colPos'] = $this->checkForRootColumn((int)$this->getContentUid()); $fieldArray['tx_gridelements_columns'] = 0; $fieldArray['tx_gridelements_container'] = 0; } else { if (!isset($fieldArray['sys_language_uid']) && isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] > 0 && (int)$fieldArray['colPos'] === -1) { - $targetContainer = BackendUtility::getRecord('tt_content', - (int)$fieldArray['tx_gridelements_container'], 'sys_language_uid'); + $targetContainer = BackendUtility::getRecord( + 'tt_content', + (int)$fieldArray['tx_gridelements_container'], + 'sys_language_uid' + ); if ((int)$targetContainer['sys_language_uid'] > -1) { $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid']; } @@ -290,8 +297,11 @@ public function setFieldEntriesForGridContainers(array &$fieldArray) } } if (isset($targetContainer) && (int)$targetContainer['sys_language_uid'] === -1) { - $list = array_flip(GeneralUtility::trimExplode(',', - $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'], true)); + $list = array_flip(GeneralUtility::trimExplode( + ',', + $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'], + true + )); unset($list['sys_language_uid']); $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'] = implode(',', array_flip($list)); } @@ -313,7 +323,7 @@ public function checkForRootColumn($contentId) ->getRestrictions() ->removeAll(); $parent = $queryBuilder - ->select('t1.colPos, t1.tx_gridelements_container') + ->select('t1.colPos', 't1.tx_gridelements_container') ->from('tt_content', 't1') ->join( 't1', @@ -322,10 +332,13 @@ public function checkForRootColumn($contentId) $queryBuilder->expr()->eq('t1.uid', $queryBuilder->quoteIdentifier('t2.tx_gridelements_container')) ) ->where( - $queryBuilder->expr()->eq('t2.uid', - $queryBuilder->createNamedParameter((int)$contentId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 't2.uid', + $queryBuilder->createNamedParameter((int)$contentId, \PDO::PARAM_INT) + ) ) - ->execute(); + ->execute() + ->fetch(); if (!empty($parent) && $parent['tx_gridelements_container'] > 0) { $colPos = $this->checkForRootColumn($parent['tx_gridelements_container']); } else { diff --git a/Classes/DataHandler/ProcessCmdmap.php b/Classes/DataHandler/ProcessCmdmap.php index 1282f6e..66e9494 100644 --- a/Classes/DataHandler/ProcessCmdmap.php +++ b/Classes/DataHandler/ProcessCmdmap.php @@ -28,8 +28,6 @@ * Class/Function which offers TCE main hook functions. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class ProcessCmdmap extends AbstractDataHandler { @@ -57,7 +55,6 @@ public function execute_processCmdmap( $reference = (int)GeneralUtility::_GET('reference'); if ($command === 'copy' && $reference === 1 && !$commandIsProcessed && $table === 'tt_content' && !$this->getTceMain()->isImporting) { - $dataArray = [ 'pid' => $value, 'CType' => 'shortcut', @@ -87,20 +84,30 @@ public function execute_processCmdmap( $parentObj->registerDBList = null; $parentObj->remapStack = null; $commandIsProcessed = true; - } if ($command === 'delete' && $table === 'tt_content') { $containerUpdateArray = []; - $originalContainer = $this->getConnection()->select( - ['tx_gridelements_container', 'sys_language_uid'], - 'tt_content', - ['uid' => (int)$id] - )->fetch(); + $queryBuilder = $this->getQueryBuilder(); + $originalContainer = $queryBuilder + ->select('tx_gridelements_container', 'sys_language_uid') + ->from('tt_content') + ->where( + $queryBuilder->expr()->eq( + 'uid', + $queryBuilder->createNamedParameter((int)$id, \PDO::PARAM_INT) + ) + ) + ->execute() + ->fetch(); + if (!empty($originalContainer)) { $containerUpdateArray[$originalContainer['tx_gridelements_container']] = -1; $this->doGridContainerUpdate($containerUpdateArray); } } + if ($table === 'tt_content') { + $this->cleanupWorkspacesAfterFinalizing(); + } } -} \ No newline at end of file +} diff --git a/Classes/Helper/Helper.php b/Classes/Helper/Helper.php index a547ef7..b9588c8 100644 --- a/Classes/Helper/Helper.php +++ b/Classes/Helper/Helper.php @@ -20,8 +20,12 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use TYPO3\CMS\Core\Database\Connection; +use TYPO3\CMS\Backend\View\BackendLayoutView; use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Database\Query\QueryBuilder; +use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction; +use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; +use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -29,8 +33,6 @@ * Gridelements helper class * * @author Dirk Hoffmann - * @package TYPO3 - * @subpackage tx_gridelements */ class Helper implements SingletonInterface { @@ -41,11 +43,6 @@ class Helper implements SingletonInterface */ protected static $instance = null; - /** - * @var Connection - */ - protected static $connection; - /** * Get instance from the class. * @@ -76,14 +73,24 @@ public function getChildren($table = '', $uid = 0, $pid = 0, $sortingField = '', if (trim($table) === 'tt_content' && $uid > 0) { $selectFieldList .= ',sorting,tx_gridelements_columns'; $selectFieldArray = GeneralUtility::trimExplode(',', $selectFieldList); - $children = self::getConnection()->select( - $selectFieldArray, - 'tt_content', - [ - 'tx_gridelements_container' => (int)$uid, - 'pid' => (int)$pid, - ] - )->fetchAll(); + $queryBuilder = self::getQueryBuilder(); + $children = $queryBuilder + ->select(...$selectFieldArray) + ->from('tt_content') + ->where( + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq( + 'tx_gridelements_container', + $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) + ) + ) + ) + ->execute() + ->fetchAll(); foreach ($children as $child) { if (trim($sortingField) && isset($child[$sortingField]) && $sortingField !== 'sorting') { @@ -91,8 +98,10 @@ public function getChildren($table = '', $uid = 0, $pid = 0, $sortingField = '', } else { $sortField = sprintf('%1$011d', $child['sorting']); } - $sortKey = sprintf('%1$011d', - $child['tx_gridelements_columns']) . '.' . $sortField . ':' . sprintf('%1$011d', $child['uid']); + $sortKey = sprintf( + '%1$011d', + $child['tx_gridelements_columns'] + ) . '.' . $sortField . ':' . sprintf('%1$011d', $child['uid']); $retVal[$sortKey] = $child; } @@ -111,80 +120,88 @@ public function getChildren($table = '', $uid = 0, $pid = 0, $sortingField = '', * @param bool $csvValues * @return mixed */ - public function mergeAllowedDisallowedSettings($backendLayout, $csvValues = false) { + public function mergeAllowedDisallowedSettings($backendLayout, $csvValues = false) + { if (!empty($backendLayout['allowed'])) { - foreach ($backendLayout['allowed'] as $column => &$fields) { - if (isset($fields['CType']) && $fields['CType'] !== '*') { - if (!empty($fields['list_type']) && strpos($fields['CType'], 'list') === false) { - $fields['CType'] .= ',list'; + foreach ($backendLayout['allowed'] as $column => &$allowedFields) { + if (isset($fields['CType']) && $allowedFields['CType'] !== '*') { + if (!empty($allowedFields['list_type']) && strpos($allowedFields['CType'], 'list') === false) { + $allowedFields['CType'] .= ',list'; } - if (!empty($fields['tx_gridelements_backend_layout']) && strpos($fields['CType'], 'gridelements_pi1') === false) { - $fields['CType'] .= ',gridelements_pi1'; + if (!empty($allowedFields['tx_gridelements_backend_layout']) && strpos($allowedFields['CType'], 'gridelements_pi1') === false) { + $allowedFields['CType'] .= ',gridelements_pi1'; } } - if (!isset($fields['CType'])) { - $fields['CType'] = '*'; + if (!isset($allowedFields['CType'])) { + $allowedFields['CType'] = '*'; } - if (!empty($fields['CType']) && !$csvValues) { - $fields['CType'] = array_flip(GeneralUtility::trimExplode(',', $fields['CType'])); + if (!empty($allowedFields['CType']) && !$csvValues) { + $allowedFields['CType'] = array_flip(GeneralUtility::trimExplode(',', $allowedFields['CType'])); } - if (!empty($fields['list_type']) && !$csvValues) { - $fields['list_type'] = array_flip(GeneralUtility::trimExplode(',', $fields['list_type'])); + if (!empty($allowedFields['list_type']) && !$csvValues) { + $allowedFields['list_type'] = array_flip(GeneralUtility::trimExplode(',', $allowedFields['list_type'])); } - if (!empty($fields['tx_gridelements_backend_layout']) && !$csvValues) { - $fields['tx_gridelements_backend_layout'] = array_flip(GeneralUtility::trimExplode(',', $fields['tx_gridelements_backend_layout'])); + if (!empty($allowedFields['tx_gridelements_backend_layout']) && !$csvValues) { + $allowedFields['tx_gridelements_backend_layout'] = array_flip(GeneralUtility::trimExplode(',', $allowedFields['tx_gridelements_backend_layout'])); } } - }; + } if (!empty($backendLayout['disallowed']) && !$csvValues) { - foreach ($backendLayout['disallowed'] as $column => &$fields) { - if (!empty($fields['CType'])) { - $fields['CType'] = array_flip(GeneralUtility::trimExplode(',', $fields['CType'])); + foreach ($backendLayout['disallowed'] as $column => &$disallowedFields) { + if (!empty($disallowedFields['CType'])) { + $disallowedFields['CType'] = array_flip(GeneralUtility::trimExplode(',', $disallowedFields['CType'])); } - if (!empty($fields['list_type'])) { - $fields['list_type'] = array_flip(GeneralUtility::trimExplode(',', $fields['list_type'])); + if (!empty($disallowedFields['list_type'])) { + $disallowedFields['list_type'] = array_flip(GeneralUtility::trimExplode(',', $disallowedFields['list_type'])); } - if (!empty($fields['tx_gridelements_backend_layout'])) { - $fields['tx_gridelements_backend_layout'] = array_flip(GeneralUtility::trimExplode(',', $fields['tx_gridelements_backend_layout'])); + if (!empty($disallowedFields['tx_gridelements_backend_layout'])) { + $disallowedFields['tx_gridelements_backend_layout'] = array_flip(GeneralUtility::trimExplode(',', $disallowedFields['tx_gridelements_backend_layout'])); } } - }; + } return $backendLayout; } /** - * setter for Connection object + * converts tt_content uid into a pid * - * @return Connection + * @param int $uid the uid value of a tt_content record + * + * @return int */ - public function getConnection() + public function getPidFromUid($uid = 0) { - if (!$this->connection instanceof Connection) { - $this->connection = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('tt_content'); - } - return $this->connection; + $queryBuilder = self::getQueryBuilder(); + $triggerElement = $queryBuilder + ->select('pid') + ->from('tt_content') + ->where( + $queryBuilder->expr()->eq( + 'uid', + $queryBuilder->createNamedParameter(abs($uid), \PDO::PARAM_INT) + ) + ) + ->execute() + ->fetch(); + $pid = (int)$triggerElement['pid']; + return is_array($triggerElement) && $pid ? $pid : 0; } /** - * converts a negative tt_content uid into a positive pid - * - * @param int $negativeUid the negative uid value of a tt_content record + * getter for queryBuilder * - * @return int + * @return QueryBuilder queryBuilder */ - public function getPidFromNegativeUid($negativeUid = 0) + public function getQueryBuilder() { - if ($negativeUid >= 0) { - return $negativeUid; - } - $triggerElement = self::getConnection()->select( - ['pid'], - 'tt_content', - ['uid' => abs($negativeUid)] - )->fetch(); - $pid = (int)$triggerElement['pid']; - return is_array($triggerElement) && $pid ? $pid : 0; + /** @var $queryBuilder QueryBuilder */ + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) + ->getQueryBuilderForTable('tt_content'); + $queryBuilder->getRestrictions() + ->removeByType(HiddenRestriction::class) + ->removeByType(StartTimeRestriction::class) + ->removeByType(EndTimeRestriction::class); + return $queryBuilder; } /** @@ -210,6 +227,73 @@ public function getSpecificIds(array $record) return $specificIds; } + /** + * @param $pageId + * @return mixed + */ + public function getSelectedBackendLayout($pageId) + { + if (empty($GLOBALS['tx_gridelements']['pageBackendLayoutData'][$pageId])) { + $backendLayoutData = GeneralUtility::callUserFunction( + BackendLayoutView::class . '->getSelectedBackendLayout', + $pageId, + $this + ); + // add allowed CTypes to the columns, since this is not done by the native core methods + if (!empty($backendLayoutData['__items'])) { + $backendLayoutData['columns']['CSV'] = '-2,-1'; + if (!empty($backendLayoutData['__config']['backend_layout.']['rows.'])) { + $allowed = []; + $disallowed = []; + $maxItems = []; + foreach ($backendLayoutData['__config']['backend_layout.']['rows.'] as $row) { + if (!empty($row['columns.'])) { + foreach ($row['columns.'] as $column) { + if (!isset($column['colPos'])) { + continue; + } + $colPos = (int)$column['colPos']; + if (isset($column['allowed.'])) { + $column['allowed'] = $column['allowed.']; + } + if (isset($column['disallowed.'])) { + $column['disallowed'] = $column['disallowed.']; + } + if (!is_array($column['allowed']) && !empty($column['allowed'])) { + $allowed[$colPos] = ['CType' => $column['allowed']]; + } elseif (empty($column['allowed'])) { + $allowed[$colPos] = ['CType' => '*']; + } else { + $allowed[$colPos] = $column['allowed']; + } + if ($column['allowedGridTypes']) { + $allowed[$colPos]['tx_gridelements_backend_layout'] = $column['allowedGridTypes']; + } + if (!empty($column['disallowed'])) { + $disallowed[$colPos] = $column['disallowed']; + } + if (!empty($column['maxitems'])) { + $maxItems[$colPos] = $column['maxitems']; + } + $backendLayoutData['columns']['CSV'] .= ',' . $colPos; + } + } + } + $backendLayoutData['allowed'] = $allowed; + if (!empty($disallowed)) { + $backendLayoutData['disallowed'] = $disallowed; + } + if (!empty($maxItems)) { + $backendLayoutData['maxitems'] = $maxItems; + } + } + $backendLayoutData = $this->mergeAllowedDisallowedSettings($backendLayoutData); + } + $GLOBALS['tx_gridelements']['pageBackendLayoutData'][$pageId] = $backendLayoutData; + } + return $GLOBALS['tx_gridelements']['pageBackendLayoutData'][$pageId]; + } + /** * Gets the current backend user. * @@ -219,5 +303,4 @@ public function getBackendUser() { return $GLOBALS['BE_USER']; } - } diff --git a/Classes/Hooks/BackendUtilityGridelements.php b/Classes/Hooks/BackendUtilityGridelements.php index f071e97..fd247ce 100644 --- a/Classes/Hooks/BackendUtilityGridelements.php +++ b/Classes/Hooks/BackendUtilityGridelements.php @@ -21,7 +21,6 @@ ***************************************************************/ use GridElementsTeam\Gridelements\Backend\LayoutSetup; -use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -30,8 +29,6 @@ * @author Jo Hasenau * @author Dirk Hoffmann * @author Stephan Schuler - * @package TYPO3 - * @subpackage tx_gridelements */ class BackendUtilityGridelements { @@ -67,9 +64,6 @@ public function getFlexFormDS_postProcessDS(&$dataStructureArray, array $conf, a public function init($pageUid) { if (!$this->layoutSetup instanceof LayoutSetup) { - if ($pageUid < 0) { - $pageUid = Helper::getInstance()->getPidFromNegativeUid($pageUid); - } $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid)); } } @@ -83,5 +77,4 @@ public function injectLayoutSetup(LayoutSetup $layoutSetup) { $this->layoutSetup = $layoutSetup; } - } diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index fc895aa..95cd6b2 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -30,12 +30,9 @@ * Class/Function which offers TCE main hook functions. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class DataHandler implements SingletonInterface { - public function __construct() { } @@ -90,7 +87,11 @@ public function processDatamap_afterDatabaseOperations( $hook = GeneralUtility::makeInstance(AfterDatabaseOperations::class); if (strpos($id, 'NEW') !== false) { $id = $parentObj->substNEWwithIDs[$id]; - }; + } else { + if ($table === 'tt_content' && $status === 'update') { + $hook->adjustValuesAfterWorkspaceOperations($fieldArray, $id, $parentObj); + } + } $hook->execute_afterDatabaseOperations($fieldArray, $table, $id, $parentObj); } } @@ -102,7 +103,7 @@ public function processDatamap_afterDatabaseOperations( * @param string $table The name of the table we are working on * @param int $id The id of the record that is going to be copied * @param string $value The value that has been sent with the copy command - * @param boolean $commandIsProcessed A switch to tell the parent object, if the record has been copied + * @param bool $commandIsProcessed A switch to tell the parent object, if the record has been copied * @param \TYPO3\CMS\Core\DataHandling\DataHandler $parentObj The parent object that triggered this hook * @param array|bool $pasteUpdate Values to be updated after the record is pasted */ @@ -121,5 +122,4 @@ public function processCmdmap( $hook->execute_processCmdmap($command, $table, $id, $value, $commandIsProcessed, $parentObj, $pasteUpdate); } } - -} \ No newline at end of file +} diff --git a/Classes/Hooks/DatabaseRecordList.php b/Classes/Hooks/DatabaseRecordList.php index 8bf55ec..3aaae95 100644 --- a/Classes/Hooks/DatabaseRecordList.php +++ b/Classes/Hooks/DatabaseRecordList.php @@ -34,8 +34,6 @@ * * @author Jo Hasenau * @author Dirk Hoffmann - * @package TYPO3 - * @subpackage tx_gridelements */ class DatabaseRecordList implements RecordListHookInterface, SingletonInterface { @@ -133,8 +131,14 @@ public function renderListHeaderActions($table, $currentIdList, $cells, &$parent public function checkChildren($table, array $row, $level, array &$theData, DatabaseRecordListXclass $parentObj) { if ($table === 'tt_content' && $row['CType'] === 'gridelements_pi1') { - $elementChildren = Helper::getInstance()->getChildren($table, $row['uid'], $row['pid'], '', 0, - $parentObj->selFieldList); + $elementChildren = Helper::getInstance()->getChildren( + $table, + $row['uid'], + $row['pid'], + '', + 0, + $parentObj->selFieldList + ); if (!empty($elementChildren)) { $theData['_EXPANDABLE_'] = true; $theData['_EXPAND_ID_'] = $table . ':' . $row['uid']; @@ -210,7 +214,6 @@ public function getLanguageService() * * @param LanguageService $languageService */ - public function setLanguageService(LanguageService $languageService) { $this->languageService = $languageService; diff --git a/Classes/Hooks/DrawItem.php b/Classes/Hooks/DrawItem.php index ef52f5d..b160597 100644 --- a/Classes/Hooks/DrawItem.php +++ b/Classes/Hooks/DrawItem.php @@ -30,6 +30,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; @@ -39,10 +40,10 @@ use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Messaging\FlashMessageQueue; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Type\Bitmask\Permission; -use TYPO3\CMS\Core\Utility\DebugUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Core\Versioning\VersionState; @@ -52,12 +53,15 @@ * Class/Function which manipulates the rendering of item example content and replaces it with a grid of child elements. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class DrawItem implements PageLayoutViewDrawItemHookInterface, SingletonInterface { + /** + * @var array + */ + protected $extentensionConfiguration; + /** * @var Helper */ @@ -97,6 +101,7 @@ class DrawItem implements PageLayoutViewDrawItemHookInterface, SingletonInterfac public function __construct() { + $this->extentensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['gridelements']); $this->setLanguageService($GLOBALS['LANG']); $this->helper = Helper::getInstance(); $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); @@ -134,7 +139,7 @@ public function getBackendUser() * Deactivates the original example content output * * @param PageLayoutView $parentObject : The parent object that triggered this hook - * @param boolean $drawItem : A switch to tell the parent object, if the item still must be drawn + * @param bool $drawItem : A switch to tell the parent object, if the item still must be drawn * @param string $headerContent : The content of the item header * @param string $itemContent : The content of the item itself * @param array $row : The current data row for this item @@ -213,17 +218,24 @@ protected function renderCTypeGridelements(PageLayoutView $parentObject, &$row) // if there are any columns, lets build the content for them $outerTtContentDataArray = $parentObject->tt_contentData['nextThree']; if (!empty($colPosValues)) { - $this->renderGridColumns($parentObject, $colPosValues, $gridContent, $gridElement, $editUidList, - $singleColumn, $head); + $this->renderGridColumns( + $parentObject, + $colPosValues, + $gridContent, + $gridElement, + $editUidList, + $singleColumn, + $head + ); } $parentObject->tt_contentData['nextThree'] = $outerTtContentDataArray; // if we got a selected backend layout, we have to create the layout table now if ($layoutUid && isset($layout['config'])) { - $itemContent = $this->renderGridLayoutTable($layout, $gridElement, $head, $gridContent); + $itemContent = $this->renderGridLayoutTable($layout, $gridElement, $head, $gridContent, $parentObject); } else { $itemContent = '
'; - $itemContent .= ''; + $itemContent .= '
'; $itemContent .= ''; $itemContent .= '
' . $gridContent[0] . '
'; } @@ -280,14 +292,15 @@ protected function setMultipleColPosValues($parserRows, &$colPosValues, $layout) protected function setSingleColPosItems(PageLayoutView $parentObject, &$colPosValues, &$row) { $specificIds = $this->helper->getSpecificIds($row); - $parentObject->setOverridePageIdList([$specificIds['pid']]); + /** @var $expressionBuilder ExpressionBuilder */ $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tt_content') ->expr(); $queryBuilder = $parentObject->getQueryBuilder( 'tt_content', - $specificIds['pid'], [ + $specificIds['pid'], + [ $expressionBuilder->eq('colPos', -1), $expressionBuilder->in('tx_gridelements_container', [(int)$row['uid'], $specificIds['uid']]), ] @@ -300,8 +313,6 @@ protected function setSingleColPosItems(PageLayoutView $parentObject, &$colPosVa $restrictions->removeByType(EndTimeRestriction::class); $queryBuilder->setRestrictions($restrictions); - $parentObject->setOverridePageIdList([]); - $colPosValues[] = [0, '']; return $parentObject->getResult($queryBuilder->execute()); @@ -315,7 +326,7 @@ protected function setSingleColPosItems(PageLayoutView $parentObject, &$colPosVa * @param array $gridContent : The rendered content data of the grid columns * @param array $row : The current data row for the container item * @param array $editUidList : determines if we will get edit icons or not - * @param boolean $singleColumn : Determines if we are in single column mode or not + * @param bool $singleColumn : Determines if we are in single column mode or not * @param array $head : An array of headers for each of the columns * * @return void @@ -330,6 +341,59 @@ protected function renderGridColumns( &$head ) { $collectedItems = $this->collectItemsForColumns($parentObject, $colPosValues, $row); + $workspace = $this->helper->getBackendUser()->workspace; + if ($workspace > 0) { + $workspacePreparedItems = []; + $moveUids = []; + foreach ($collectedItems as $item) { + if ($item['t3ver_state'] === 3) { + $moveUids[] = (int)$item['t3ver_move_id']; + $item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']); + $movePlaceholder = BackendUtility::getMovePlaceholder( + 'tt_content', + (int)$item['uid'], + '*', + $workspace + ); + if (!empty($movePlaceholder)) { + $item['sorting'] = $movePlaceholder['sorting']; + $item['tx_gridelements_columns'] = $movePlaceholder['tx_gridelements_columns']; + $item['tx_gridelements_container'] = $movePlaceholder['tx_gridelements_container']; + } + } else { + $item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']); + if ($item['t3ver_state'] === 4) { + $movePlaceholder = BackendUtility::getMovePlaceholder( + 'tt_content', + (int)$item['uid'], + '*', + $workspace + ); + if (!empty($movePlaceholder)) { + $item['sorting'] = $movePlaceholder['sorting']; + $item['tx_gridelements_columns'] = $movePlaceholder['tx_gridelements_columns']; + $item['tx_gridelements_container'] = $movePlaceholder['tx_gridelements_container']; + } + } + } + $workspacePreparedItems[] = $item; + } + $moveUids = array_flip($moveUids); + $collectedItems = $workspacePreparedItems; + foreach ($collectedItems as $key => $item) { + if (isset($moveUids[$item['uid']]) && !$item['_MOVE_PLH']) { + unset($collectedItems[$key]); + } + } + } else { + foreach ($collectedItems as $key => $item) { + $item = BackendUtility::getRecordWSOL('tt_content', (int)$item['uid']); + if ($item['t3ver_state'] > 0) { + unset($collectedItems[$key]); + } + } + } + foreach ($colPosValues as $colPos => $values) { // first we have to create the column content separately for each column // so we can check for the first and the last element to provide proper sorting @@ -337,7 +401,7 @@ protected function renderGridColumns( if ($singleColumn === false) { $items = []; foreach ($collectedItems as $item) { - if ((int)$item['tx_gridelements_columns'] === $colPos) { + if ((int)$item['tx_gridelements_columns'] === $colPos && (int)$item['tx_gridelements_container'] === (int)$row['uid']) { if ( $row['sys_language_uid'] === $item['sys_language_uid'] || ($row['sys_language_uid'] === -1 && $item['sys_language_uid'] === 0) @@ -350,6 +414,12 @@ protected function renderGridColumns( } else { $items = []; } + usort($items, function ($a, $b) { + if ($a['sorting'] === $b['sorting']) { + return 0; + } + return $a['sorting'] > $b['sorting'] ? 1 : -1; + }); // if there are any items, we can create the HTML for them just like in the original TCEform $gridContent['numberOfItems'][$colPos] = $counter; $this->renderSingleGridColumn($parentObject, $items, $colPos, $values, $gridContent, $row, $editUidList); @@ -372,32 +442,67 @@ protected function collectItemsForColumns(PageLayoutView $parentObject, &$colPos { $colPosList = array_keys($colPosValues); $specificIds = $this->helper->getSpecificIds($row); - $parentObject->setOverridePageIdList([$specificIds['pid']]); $queryBuilder = $this->getQueryBuilder(); $constraints = [ - $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($row['pid'], \PDO::PARAM_INT)), + $queryBuilder->expr()->in( + 'pid', + $queryBuilder->createNamedParameter( + [(int)$row['pid'], $specificIds['pid']], + Connection::PARAM_INT_ARRAY + ) + ), $queryBuilder->expr()->eq('colPos', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)), - $queryBuilder->expr()->in('tx_gridelements_container', - $queryBuilder->createNamedParameter([(int)$row['uid'], $specificIds['uid']], - Connection::PARAM_INT_ARRAY)), - $queryBuilder->expr()->in('tx_gridelements_columns', - $queryBuilder->createNamedParameter($colPosList, Connection::PARAM_INT_ARRAY)), + $queryBuilder->expr()->in( + 'tx_gridelements_container', + $queryBuilder->createNamedParameter( + [(int)$row['uid'], $specificIds['uid']], + Connection::PARAM_INT_ARRAY + ) + ), + $queryBuilder->expr()->in( + 'tx_gridelements_columns', + $queryBuilder->createNamedParameter($colPosList, Connection::PARAM_INT_ARRAY) + ), ]; if (!$parentObject->tt_contentConfig['languageMode']) { $constraints[] = $queryBuilder->expr()->orX( $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('sys_language_uid', - $queryBuilder->createNamedParameter((int)$parentObject->tt_contentConfig['sys_language_uid'], - \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 'sys_language_uid', + $queryBuilder->createNamedParameter( + (int)$parentObject->tt_contentConfig['sys_language_uid'], + \PDO::PARAM_INT + ) + ) ); } elseif ($row['sys_language_uid'] > 0) { - $constraints[] = $queryBuilder->expr()->eq('sys_language_uid', - $queryBuilder->createNamedParameter((int)$row['sys_language_uid'], \PDO::PARAM_INT)); + $constraints[] = $queryBuilder->expr()->eq( + 'sys_language_uid', + $queryBuilder->createNamedParameter((int)$row['sys_language_uid'], \PDO::PARAM_INT) + ); } - if ($this->helper->getBackendUser()->workspace > 0 && $row['t3ver_wsid'] > 0) { - $constraints[] = $queryBuilder->expr()->eq('t3ver_wsid', - $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)); + if ($this->helper->getBackendUser()->workspace > 0) { + if ($row['t3ver_wsid'] > 0) { + $constraints[] = $queryBuilder->expr()->eq( + 't3ver_wsid', + $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT) + ); + } else { + $constraints[] = $queryBuilder->expr()->orX( + $queryBuilder->expr()->eq( + 't3ver_wsid', + $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->eq( + 't3ver_wsid', + $queryBuilder->createNamedParameter( + $this->helper->getBackendUser()->workspace, + \PDO::PARAM_INT + ) + ) + ); + } } $queryBuilder @@ -454,14 +559,13 @@ protected function renderSingleGridColumn( $row, &$editUidList ) { - $specificIds = $this->helper->getSpecificIds($row); $allowed = base64_encode(json_encode($values['allowed'])); $disallowed = base64_encode(json_encode($values['disallowed'])); $maxItems = (int)$values['maxitems']; $url = ''; $pageinfo = BackendUtility::readPageAccess($parentObject->id, ''); - if (get_class($this->getPageLayoutController()) === PageLayoutController::class) { + if (!empty($this->getPageLayoutController()) && get_class($this->getPageLayoutController()) === PageLayoutController::class) { $contentIsNotLockedForEditors = $this->getPageLayoutController()->contentIsNotLockedForEditors(); } else { $contentIsNotLockedForEditors = true; @@ -512,9 +616,13 @@ protected function renderSingleGridColumn( if ($colPos !== '' && $colPos !== null && $colPos < 32768 && $url) { $iconsArray = [ - 'new' => '' . $this->iconFactory->getIcon('actions-document-new', - 'small') . ' ' . $this->languageService->getLL('content', true) . '', + 'new' => '' . $this->iconFactory->getIcon( + 'actions-document-new', + 'small' + ) . ' ' . $this->languageService->getLL('content', true) . '', ]; } @@ -664,8 +772,10 @@ protected function checkIfTranslationsExistInLanguage( // Also, you may override this strict behavior via user TS Config // If you do so, you're on your own and cannot rely on any support by the TYPO3 core // We jump out here since we don't need to do the expensive loop operations - $allowInconsistentLanguageHandling = BackendUtility::getModTSconfig($parentObject->id, - 'mod.web_layout.allowInconsistentLanguageHandling'); + $allowInconsistentLanguageHandling = BackendUtility::getModTSconfig( + $parentObject->id, + 'mod.web_layout.allowInconsistentLanguageHandling' + ); if ($language === 0 || $language === -1 || $allowInconsistentLanguageHandling['value'] === '1') { return false; } @@ -687,13 +797,18 @@ protected function checkIfTranslationsExistInLanguage( ) { $message = GeneralUtility::makeInstance( FlashMessage::class, - sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), - $parentObject->languageIconTitles[$language]['title']), - sprintf($this->getLanguageService()->getLL('staleTranslationWarningTitle'), - $parentObject->languageIconTitles[$language]['title']), + sprintf( + $this->getLanguageService()->getLL('staleTranslationWarning'), + $parentObject->languageIconTitles[$language]['title'] + ), + sprintf( + $this->getLanguageService()->getLL('staleTranslationWarningTitle'), + $parentObject->languageIconTitles[$language]['title'] + ), FlashMessage::WARNING ); $service = GeneralUtility::makeInstance(FlashMessageService::class); + /** @var $queue FlashMessageQueue */ $queue = $service->getMessageQueueByIdentifier(); $queue->addMessage($message); } @@ -737,12 +852,21 @@ public function setLanguageService(LanguageService $languageService) protected function renderSingleElementHTML(PageLayoutView $parentObject, $item) { $singleElementHTML = ''; - $parentObject->tt_contentData['nextThree'][$item['uid']] = $item['uid']; + $unset = false; + if (!isset($parentObject->tt_contentData['nextThree'][$item['uid']])) { + $unset = true; + $parentObject->tt_contentData['nextThree'][$item['uid']] = $item['uid']; + } if (!$parentObject->tt_contentConfig['languageMode']) { $singleElementHTML .= '
'; } - $singleElementHTML .= $parentObject->tt_content_drawHeader($item, - $parentObject->tt_contentConfig['showInfo'] ? 15 : 5, $parentObject->defLangBinding, true, true); + $singleElementHTML .= $parentObject->tt_content_drawHeader( + $item, + $parentObject->tt_contentConfig['showInfo'] ? 15 : 5, + $parentObject->defLangBinding, + true, + true + ); $singleElementHTML .= (!empty($item['_ORIG_uid']) ? '
' : '') . '
' . $parentObject->tt_content_drawItem($item) @@ -752,7 +876,9 @@ protected function renderSingleElementHTML(PageLayoutView $parentObject, $item) if (!$parentObject->tt_contentConfig['languageMode']) { $singleElementHTML .= '
'; } - unset($parentObject->tt_contentData['nextThree'][$item['uid']]); + if ($unset) { + unset($parentObject->tt_contentData['nextThree'][$item['uid']]); + } return $singleElementHTML; } @@ -770,8 +896,12 @@ protected function tt_content_drawFooter(PageLayoutView $parentObject, array $ro $content = ''; // Get processed values: $info = []; - $parentObject->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, - $info); + $parentObject->getProcessedValue( + 'tt_content', + 'starttime,endtime,fe_group,spaceBefore,spaceAfter', + $row, + $info + ); // Content element annotation if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn'])) { @@ -784,8 +914,10 @@ protected function tt_content_drawFooter(PageLayoutView $parentObject, array $ro foreach ($drawFooterHooks as $hookClass) { $hookObject = GeneralUtility::getUserObj($hookClass); if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) { - throw new \UnexpectedValueException($hookClass . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, - 1404378171); + throw new \UnexpectedValueException( + $hookClass . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, + 1404378171 + ); } $hookObject->preProcess($parentObject, $info, $row); } @@ -824,9 +956,12 @@ protected function setColumnHeader( &$editUidList, $expanded = true ) { - $head[$colPos] = $this->tt_content_drawColHeader($name, + $head[$colPos] = $this->tt_content_drawColHeader( + $name, ($parentObject->doEdit && $editUidList[$colPos]) ? '&edit[tt_content][' . $editUidList[$colPos] . ']=edit' : '', - $parentObject, $expanded); + $parentObject, + $expanded + ); } /** @@ -835,7 +970,7 @@ protected function setColumnHeader( * @param string $colName Column name * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine) * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject - * @param boolean $expanded + * @param bool $expanded * * @return string HTML table */ @@ -846,9 +981,13 @@ protected function tt_content_drawColHeader($colName, $editParams, PageLayoutVie if ($parentObject->tt_contentConfig['showCommands']) { // Edit whole of column: if ($editParams) { - $iconsArr['edit'] = '' . $this->iconFactory->getIcon('actions-document-open', - Icon::SIZE_SMALL)->render() . ''; + $iconsArr['edit'] = '' . $this->iconFactory->getIcon( + 'actions-document-open', + Icon::SIZE_SMALL + )->render() . ''; } } @@ -862,11 +1001,17 @@ protected function tt_content_drawColHeader($colName, $editParams, PageLayoutVie $toggleTitle = $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_collapsecontent'); } - $iconsArr['toggleContent'] = '' . $this->iconFactory->getIcon('actions-view-list-collapse', - 'small') . $this->iconFactory->getIcon('actions-view-list-expand', - 'small') . ''; - $icons = '
' . implode('', - $iconsArr) . '
'; + $iconsArr['toggleContent'] = '' . $this->iconFactory->getIcon( + 'actions-view-list-collapse', + 'small' + ) . $this->iconFactory->getIcon( + 'actions-view-list-expand', + 'small' + ) . ''; + $icons = '
' . implode( + '', + $iconsArr + ) . '
'; // Create header row: $out = '
' . $icons . ' @@ -883,25 +1028,27 @@ protected function tt_content_drawColHeader($colName, $editParams, PageLayoutVie * @param array $row : The current data row for the container item * @param array $head : The data for the column headers of the grid we are going to render * @param array $gridContent : The content data of the grid we are going to render + * @param PageLayoutView $parentObject * * @return string */ - protected function renderGridLayoutTable($layout, $row, $head, $gridContent) + protected function renderGridLayoutTable($layout, $row, $head, $gridContent, PageLayoutView $parentObject) { $specificIds = $this->helper->getSpecificIds($row); - $grid = '
'; - if ($layout['frame'] || $this->helper->getBackendUser()->uc['showGridInformation'] === 1) { - $grid .= '

' . + $grid = '
'; + if ($layout['frame'] || (int)$this->helper->getBackendUser()->uc['showGridInformation'] === 1) { + $grid .= '

' . BackendUtility::wrapInHelp( 'tx_gridelements_backend_layouts', 'title', - $this->languageService->sL($layout['title']), [ + $this->languageService->sL($layout['title']), + [ 'title' => $this->languageService->sL($layout['title']), 'description' => $this->languageService->sL($layout['description']), ] ) . '

'; } - $grid .= ''; + $grid .= '
'; // add colgroups $colCount = 0; $rowCount = 0; @@ -915,7 +1062,7 @@ protected function renderGridLayoutTable($layout, $row, $head, $gridContent) } $grid .= ''; for ($i = 0; $i < $colCount; $i++) { - $grid .= ''; + $grid .= ''; } $grid .= ''; // cycle through rows @@ -937,10 +1084,12 @@ protected function renderGridLayoutTable($layout, $row, $head, $gridContent) foreach ($disallowedContentTypes as $key => &$ctype) { $ctype = $key; } - } else if(isset($disallowedContentTypes['*'])) { - $disallowedGridTypes['*'] = '*'; } else { - $disallowedContentTypes = []; + if (isset($disallowedContentTypes['*'])) { + $disallowedGridTypes['*'] = '*'; + } else { + $disallowedContentTypes = []; + } } // when everything is disallowed, no further checks are necessary if (!isset($disallowedContentTypes['*'])) { @@ -964,12 +1113,14 @@ protected function renderGridLayoutTable($layout, $row, $head, $gridContent) foreach ($disallowedListTypes as $key => &$ctype) { $ctype = $key; } - } else if(isset($disallowedListTypes['*'])) { - // when each list type is disallowed, no CType list is necessary anymore - $disallowedListTypes['*'] = '*'; - unset($allowedContentTypes['list']); } else { - $disallowedListTypes = []; + if (isset($disallowedListTypes['*'])) { + // when each list type is disallowed, no CType list is necessary anymore + $disallowedListTypes['*'] = '*'; + unset($allowedContentTypes['list']); + } else { + $disallowedListTypes = []; + } } // when each list type is disallowed, no further list type checks are necessary if (!isset($disallowedListTypes['*'])) { @@ -999,12 +1150,14 @@ protected function renderGridLayoutTable($layout, $row, $head, $gridContent) foreach ($disallowedGridTypes as $key => &$ctype) { $ctype = $key; } - } else if(isset($disallowedGridTypes['*'])) { - // when each list type is disallowed, no CType gridelements_pi1 is necessary anymore - $disallowedGridTypes['*'] = '*'; - unset($allowedContentTypes['gridelements_pi1']); } else { - $disallowedGridTypes = []; + if (isset($disallowedGridTypes['*'])) { + // when each list type is disallowed, no CType gridelements_pi1 is necessary anymore + $disallowedGridTypes['*'] = '*'; + unset($allowedContentTypes['gridelements_pi1']); + } else { + $disallowedGridTypes = []; + } } // when each list type is disallowed, no further grid types checks are necessary if (!isset($disallowedGridTypes['*'])) { @@ -1038,6 +1191,15 @@ protected function renderGridLayoutTable($layout, $row, $head, $gridContent) $disableNewContent = $gridContent['numberOfItems'][$columnKey] >= $maxItems && $maxItems > 0; $tooManyItems = $gridContent['numberOfItems'][$columnKey] > $maxItems && $maxItems > 0; $expanded = $this->helper->getBackendUser()->uc['moduleData']['page']['gridelementsCollapsedColumns'][$row['uid'] . '_' . $columnKey] ? 'collapsed' : 'expanded'; + if (!empty($columnConfig['name']) && $columnKey === 32768) { + $columnHead = $this->tt_content_drawColHeader( + htmlspecialchars($columnConfig['name']) . ' (' . $this->languageService->getLL('notAssigned') . ')', + '', + $parentObject + ); + } else { + $columnHead = $head[$columnKey]; + } $grid .= ' @@ -1463,8 +1517,10 @@ public function makeControl($table, $row) // If the listed table is 'pages' we have to request the permission settings for each page: $localCalcPerms = 0; if ($table === 'pages') { - $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', - $row['uid'])); + $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord( + 'pages', + $row['uid'] + )); } $permsEdit = $table === 'pages' && $this->getBackendUserAuthentication()->checkLanguageAccess(0) @@ -1497,10 +1553,16 @@ public function makeControl($table, $row) $iconIdentifier = 'actions-page-open'; } $overlayIdentifier = !$this->isEditable($table) ? 'overlay-readonly' : null; - $editAction = '' . $this->iconFactory->getIcon($iconIdentifier, - Icon::SIZE_SMALL, $overlayIdentifier)->render() . ''; + $editAction = '' . $this->iconFactory->getIcon( + $iconIdentifier, + Icon::SIZE_SMALL, + $overlayIdentifier + )->render() . ''; } else { $editAction = $this->spaceIcon; } @@ -1514,8 +1576,10 @@ public function makeControl($table, $row) if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) { $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');'; $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page'))); - $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-move', - Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)); + $icon = ($table === 'pages' ? $this->iconFactory->getIcon( + 'actions-page-move', + Icon::SIZE_SMALL + ) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)); $moveAction = '' . $icon->render() . ''; $this->addActionToCellGroup($cells, $moveAction, 'move'); } @@ -1530,8 +1594,14 @@ public function makeControl($table, $row) $this->addActionToCellGroup($cells, $historyAction, 'history'); // Versioning: if (ExtensionManagementUtility::isLoaded('version') && !ExtensionManagementUtility::isLoaded('workspaces')) { - $vers = BackendUtility::selectVersionsOfRecord($table, $row['uid'], 'uid', - $this->getBackendUserAuthentication()->workspace, false, $row); + $vers = BackendUtility::selectVersionsOfRecord( + $table, + $row['uid'], + 'uid', + $this->getBackendUserAuthentication()->workspace, + false, + $row + ); // If table can be versionized. if (is_array($vers)) { $href = BackendUtility::getModuleUrl('web_txversionM1', [ @@ -1545,8 +1615,10 @@ public function makeControl($table, $row) } } // "Edit Perms" link: - if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', - 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) { + if ($table === 'pages' && $this->getBackendUserAuthentication()->check( + 'modules', + 'system_BeuserTxPermission' + ) && ExtensionManagementUtility::isLoaded('beuser')) { $href = BackendUtility::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&returnId=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit'; $permsAction = '' @@ -1559,14 +1631,19 @@ public function makeControl($table, $row) if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) { if ($this->showNewRecLink($table)) { $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new'; - $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-new', - Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)); + $icon = ($table === 'pages' ? $this->iconFactory->getIcon( + 'actions-page-new', + Icon::SIZE_SMALL + ) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)); $titleLabel = 'new'; if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) { $titleLabel .= ($table === 'pages' ? 'Page' : 'Record'); } - $newAction = '' . $icon->render() . ''; $this->addActionToCellGroup($cells, $newAction, 'new'); @@ -1579,8 +1656,10 @@ public function makeControl($table, $row) // Up $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']]; $moveUpAction = '' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . ''; } else { @@ -1592,8 +1671,10 @@ public function makeControl($table, $row) // Down $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']]; $moveDownAction = '' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . ''; } else { @@ -1646,7 +1727,9 @@ public function makeControl($table, $row) $table, $row['uid'], ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'), - $this->getReferenceCount($table, $row['uid'])) . BackendUtility::translationCount($table, + $this->getReferenceCount($table, $row['uid']) + ) . BackendUtility::translationCount( + $table, $row['uid'], ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord') ); @@ -1677,21 +1760,27 @@ public function makeControl($table, $row) if ($this->calcPerms & Permission::PAGE_NEW) { $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id; $moveLeftAction = '' . $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . ''; $this->addActionToCellGroup($cells, $moveLeftAction, 'moveLeft'); } // Down (Paste as subpage to the page right above) if ($this->currentTable['prevUid'][$row['uid']]) { - $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', - $this->currentTable['prevUid'][$row['uid']])); + $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord( + 'pages', + $this->currentTable['prevUid'][$row['uid']] + )); if ($localCalcPerms & Permission::PAGE_NEW) { $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']]; $moveRightAction = '' . $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . ''; } else { @@ -1732,8 +1821,10 @@ public function makeControl($table, $row) foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof RecordListHookInterface) { - throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, - 1195567840); + throw new \UnexpectedValueException( + $classData . ' must implement interface ' . RecordListHookInterface::class, + 1195567840 + ); } $cells = $hookObject->makeControl($table, $row, $cells, $this); } @@ -1937,15 +2028,22 @@ public function makeClip($table, $row) } $cells['copy'] = '' . $copyIcon->render() . ''; // Check permission to cut page or content if ($table === 'pages') { - $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', - $row['uid'])); + $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord( + 'pages', + $row['uid'] + )); $permsEdit = $localCalcPerms & Permission::PAGE_EDIT; } else { $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT; @@ -1956,8 +2054,13 @@ public function makeClip($table, $row) if ($table === 'pages') { if ($permsEdit) { $cells['cut'] = '' . $cutIcon->render() . ''; } else { @@ -1966,8 +2069,13 @@ public function makeClip($table, $row) } else { if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT) { $cells['cut'] = '' . $cutIcon->render() . ''; } else { @@ -2006,8 +2114,12 @@ public function makeClip($table, $row) . ' href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"' . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"' - . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'after', - $elFromTable)) . '"' + . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText( + $table, + $row, + 'after', + $elFromTable + )) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)->render() . ''; } @@ -2018,8 +2130,12 @@ public function makeClip($table, $row) . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' - . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'into', - $elFromTable)) . '"' + . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText( + $table, + $row, + 'into', + $elFromTable + )) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . ''; } @@ -2034,8 +2150,10 @@ public function makeClip($table, $row) foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof RecordListHookInterface) { - throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, - 1195567845); + throw new \UnexpectedValueException( + $classData . ' must implement interface ' . RecordListHookInterface::class, + 1195567845 + ); } $cells = $hookObject->makeClip($table, $row, $cells, $this); } @@ -2069,7 +2187,6 @@ public function makeLocalizationPanel($table, $row) if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) { return $out; } - $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList); if (is_array($translations)) { $this->translations = $translations['translations']; @@ -2084,8 +2201,10 @@ public function makeLocalizationPanel($table, $row) ); $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title'); if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) { - $lC = $this->iconFactory->getIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon'], - Icon::SIZE_SMALL)->render(); + $lC = $this->iconFactory->getIcon( + $this->languageIconTitles[$lUid_OnPage]['flagIcon'], + Icon::SIZE_SMALL + )->render(); } else { $lC = $this->languageIconTitles[$lUid_OnPage]['title']; } @@ -2125,6 +2244,7 @@ public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', $pagination = true; } else { $colType = ($colType === 'th') ? 'th' : 'td'; + $pagination = false; } $noWrap = $this->no_noWrap ? '' : ' nowrap="nowrap"'; // Start up: @@ -2161,7 +2281,6 @@ public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', $out .= '<' . $colType . '>'; } } - } // Show icon and lines if ($this->showIcon) { @@ -2198,8 +2317,10 @@ public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', if ($lastKey) { $cssClass = $this->addElement_tdCssClass[$lastKey]; if ($this->oddColumnsCssClass && $ccount % 2 == 0) { - $cssClass = implode(' ', - [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass]); + $cssClass = implode( + ' ', + [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass] + ); } $out .= ' <' . $colType . $noWrap . ' class="' . $cssClass . '"' . $colsp @@ -2219,9 +2340,9 @@ public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', } if ($pagination) { $colsp = ' colspan="' . ($this->totalColumnCount - 1) . '"'; - } else if ($c > 1) { + } elseif ($c > 1) { $colsp = ' colspan="2"'; - } else if ($ccount === 1 && $colType === 'td') { + } elseif ($ccount === 1 && $colType === 'td') { $colsp = ' colspan="' . ($this->maxDepth - $level - 1) . '"'; } else { $colsp = ''; @@ -2243,7 +2364,6 @@ public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', return $out; } - /** * Creates a page browser for tables with many records * @@ -2271,10 +2391,14 @@ protected function renderListNavigation($renderPart = 'top') $previous = '
  • ' . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '
  • '; } else { - $first = '
  • ' . $this->iconFactory->getIcon('actions-view-paging-first', - Icon::SIZE_SMALL)->render() . '
  • '; - $previous = '
  • ' . $this->iconFactory->getIcon('actions-view-paging-previous', - Icon::SIZE_SMALL)->render() . '
  • '; + $first = '
  • ' . $this->iconFactory->getIcon( + 'actions-view-paging-first', + Icon::SIZE_SMALL + )->render() . '
  • '; + $previous = '
  • ' . $this->iconFactory->getIcon( + 'actions-view-paging-previous', + Icon::SIZE_SMALL + )->render() . '
  • '; } if ($currentPage < $totalPages) { $labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:next')); @@ -2284,10 +2408,14 @@ protected function renderListNavigation($renderPart = 'top') $last = '
  • ' . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '
  • '; } else { - $next = '
  • ' . $this->iconFactory->getIcon('actions-view-paging-next', - Icon::SIZE_SMALL)->render() . '
  • '; - $last = '
  • ' . $this->iconFactory->getIcon('actions-view-paging-last', - Icon::SIZE_SMALL)->render() . '
  • '; + $next = '
  • ' . $this->iconFactory->getIcon( + 'actions-view-paging-next', + Icon::SIZE_SMALL + )->render() . '
  • '; + $last = '
  • ' . $this->iconFactory->getIcon( + 'actions-view-paging-last', + Icon::SIZE_SMALL + )->render() . '
  • '; } $reload = '
  • iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render(); - $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB', '', - $lang->getLL('clip_selectMarked')); + $cells['copyMarked'] = $this->linkClipboardHeaderIcon( + $spriteIcon, + $table, + 'setCB', + '', + $lang->getLL('clip_selectMarked') + ); // The "edit marked" link: $editIdList = implode(',', $currentIdList); $editIdList = '\'+editList(' . GeneralUtility::quoteJSvalue($table) . ',' . GeneralUtility::quoteJSvalue($editIdList) . ')+\''; @@ -2442,17 +2577,23 @@ public function renderListHeader($table, $currentIdList) $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(), $table, 'delete', - sprintf($lang->getLL('clip_deleteMarkedWarning'), - $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])), + sprintf( + $lang->getLL('clip_deleteMarkedWarning'), + $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']) + ), $lang->getLL('clip_deleteMarked') ); // The "Select all" link: - $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility::quoteJSvalue(implode(',', - $this->CBnames)) . ', this); return false;')); + $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility::quoteJSvalue(implode( + ',', + $this->CBnames + )) . ', this); return false;')); $cells['markAll'] = '' - . $this->iconFactory->getIcon('actions-document-select', - Icon::SIZE_SMALL)->render() . ''; + . $this->iconFactory->getIcon( + 'actions-document-select', + Icon::SIZE_SMALL + )->render() . ''; } else { $cells['empty'] = ''; } @@ -2467,8 +2608,10 @@ public function renderListHeader($table, $currentIdList) foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof RecordListHookInterface) { - throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, - 1195567850); + throw new \UnexpectedValueException( + $classData . ' must implement interface ' . RecordListHookInterface::class, + 1195567850 + ); } $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this); } @@ -2491,12 +2634,15 @@ public function renderListHeader($table, $currentIdList) $containerIds = implode(',', array_flip(array_flip($this->currentContainerIdList))); $icon = '' . $this->iconFactory->getIcon('actions-view-list-collapse', - 'small')->render() . '' . $this->iconFactory->getIcon( + 'actions-view-list-collapse', + 'small' + )->render() . '' . $this->iconFactory->getIcon('actions-view-list-expand', - 'small')->render() . ''; - + title="' . $expandTitle . '" data-container-ids="' . $containerIds . '">' . $this->iconFactory->getIcon( + 'actions-view-list-expand', + 'small' + )->render() . ''; } if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) { $spriteIcon = $table === 'pages' @@ -2508,8 +2654,10 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa $newContentElementWizard = isset($tmpTSc['properties']['newContentElementWizard.']['override']) ? $tmpTSc['properties']['newContentElementWizard.']['override'] : 'new_content_element'; - $newContentWizScriptPath = BackendUtility::getModuleUrl($newContentElementWizard, - ['id' => $this->id]); + $newContentWizScriptPath = BackendUtility::getModuleUrl( + $newContentElementWizard, + ['id' => $this->id] + ); $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($newContentWizScriptPath) . ');'; $icon = '' . $spriteIcon->render() . ''; } } @@ -2539,8 +2690,10 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa if ($this->clipNumPane()) { $editIdList = '\'+editList(' . GeneralUtility::quoteJSvalue($table) . ',' . GeneralUtility::quoteJSvalue($editIdList) . ')+\''; } - $params = 'edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . implode(',', - $this->fieldArray); + $params = 'edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . implode( + ',', + $this->fieldArray + ); // we need to build this uri differently, otherwise GeneralUtility::quoteJSvalue messes up the edit list function $onClick = BackendUtility::editOnClick('', '', -1); $onClickArray = explode('?', $onClick, 2); @@ -2549,8 +2702,10 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa $onClick = implode('?', $onClickArray); $icon .= '' - . $this->iconFactory->getIcon('actions-document-open', - Icon::SIZE_SMALL)->render() . ''; + . $this->iconFactory->getIcon( + 'actions-document-open', + Icon::SIZE_SMALL + )->render() . ''; $icon = '
    ' . $icon . '
    '; } // Add an empty entry, so column count fits again after moving this into $icon @@ -2576,11 +2731,15 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa if ($this->table && is_array($currentIdList)) { // If the numeric clipboard pads are selected, show duplicate sorting link: if ($this->clipNumPane()) { - $theData[$fCol] .= '' - . $this->iconFactory->getIcon('actions-document-duplicates-select', - Icon::SIZE_SMALL)->render() . ''; + . $this->iconFactory->getIcon( + 'actions-document-duplicates-select', + Icon::SIZE_SMALL + )->render() . ''; } // If the table can be edited, add link for editing THIS field for all // listed records: @@ -2599,8 +2758,10 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel); $theData[$fCol] .= '' - . $this->iconFactory->getIcon('actions-document-open', - Icon::SIZE_SMALL)->render() . ''; + . $this->iconFactory->getIcon( + 'actions-document-open', + Icon::SIZE_SMALL + )->render() . ''; } if (strlen($theData[$fCol]) > 0) { $theData[$fCol] = '
    ' . $theData[$fCol] . '
    '; @@ -2629,8 +2790,10 @@ class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expa foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof RecordListHookInterface) { - throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, - 1195567855); + throw new \UnexpectedValueException( + $classData . ' must implement interface ' . RecordListHookInterface::class, + 1195567855 + ); } $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this); } @@ -2715,8 +2878,10 @@ public function addSortLink($code, $field, $table) $sortUrl = $this->listURL('', '-1', 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || $this->sortField != $field ? 0 : 1); $sortArrow = $this->sortField === $field - ? $this->iconFactory->getIcon('status-status-sorting-' . ($this->sortRev ? 'desc' : 'asc'), - Icon::SIZE_SMALL)->render() + ? $this->iconFactory->getIcon( + 'status-status-sorting-' . ($this->sortRev ? 'desc' : 'asc'), + Icon::SIZE_SMALL + )->render() : ''; // Return linked field: return '' . $code . $sortArrow . ''; @@ -2752,15 +2917,17 @@ public function outputCSV($prefix) * @param string $table Tablename (_FILE for files) * @param mixed $uid "destination": can be positive or negative indicating how the paste is done (paste into / paste after) * @param bool $setRedirect If set, then the redirect URL will point back to the current script, but with CB reset. - * @param array|NULL $update Additional key/value pairs which should get set in the moved/copied record (via DataHandler) + * @param array|null $update Additional key/value pairs which should get set in the moved/copied record (via DataHandler) * * @return string */ public function pasteUrl($table, $uid, $setRedirect = true, array $update = null) { $formProtection = FormProtectionFactory::get(); - return ($table === '_FILE' ? BackendUtility::getModuleUrl('tce_file', - []) : BackendUtility::getModuleUrl('tce_db', [])) + return ($table === '_FILE' ? BackendUtility::getModuleUrl( + 'tce_file', + [] + ) : BackendUtility::getModuleUrl('tce_db', [])) . ($setRedirect ? '&redirect=' . rawurlencode(GeneralUtility::linkThisScript(['CB' => ''])) : '') . '&vC=' . $this->getBackendUserAuthentication()->veriCode() . '&prErr=1&uPT=1' . '&CB[paste]=' . rawurlencode($table . '|' . $uid) . '&CB[pad]=' . $this->clipObj->current diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 6596e0c..dcf8e2b 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -1,6 +1,5 @@ 'select', 'renderType' => 'selectSingle', 'itemsProcFunc' => 'GridElementsTeam\Gridelements\Backend\TtContent->layoutItemsProcFunc', + 'fieldWizard' => [ + 'selectIcons' => [ + 'disabled' => '' + ] + ], 'size' => 1, 'maxitems' => 1, 'default' => 0 @@ -136,4 +140,4 @@ --div--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category, categories, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,rowDescription - '; \ No newline at end of file + '; diff --git a/Configuration/TCA/tx_gridelements_backend_layout.php b/Configuration/TCA/tx_gridelements_backend_layout.php index 3975561..9f8c903 100644 --- a/Configuration/TCA/tx_gridelements_backend_layout.php +++ b/Configuration/TCA/tx_gridelements_backend_layout.php @@ -204,5 +204,4 @@ ], ], - ]; diff --git a/Configuration/TypoScript/setup.ts b/Configuration/TypoScript/setup.ts index 8a43333..7ed51c9 100644 --- a/Configuration/TypoScript/setup.ts +++ b/Configuration/TypoScript/setup.ts @@ -25,52 +25,59 @@ lib.gridelements.defaultGridSetup { # or tx_gridelements_view_child_123 (123 is the UID of the child) } +tt_content.gridelements_pi1 = COA +tt_content.gridelements_pi1 { + #10 =< lib.stdheader + 20 = COA + 20 { + 10 = USER + 10 { + userFunc = GridElementsTeam\Gridelements\Plugin\Gridelements->main + setup { + default < lib.gridelements.defaultGridSetup + } + } + } +} + +tt_content.gridelements_view < tt_content.gridelements_pi1 + lib.tt_content.shortcut.pages = COA lib.tt_content.shortcut.pages { + 5 = LOAD_REGISTER + 5 { + tt_content_shortcut_recursive.field = recursive + } 10 = USER 10 { userFunc = GridElementsTeam\Gridelements\Plugin\Gridelements->user_getTreeList - } + } 20 = CONTENT 20 { table = tt_content select { pidInList.data = register:pidInList + selectFields.dataWrap = *,FIND_IN_SET(pid,{register:pidInList}) AS gridelements_shortcut_page_order_by where = colPos >= 0 languageField = sys_language_uid - orderBy = colPos,sorting - orderBy.dataWrap = FIND_IN_SET(pid,'{register:pidInList}'),| + orderBy = gridelements_shortcut_page_order_by,colPos,sorting } } + 30 = RESTORE_REGISTER } -tt_content.shortcut { - 5 = LOAD_REGISTER - 5 { - tt_content_shortcut_recursive.field = recursive - } - 20 { +[userFunc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('fluid_styled_content')] + tt_content.shortcut.variables.shortcuts { tables := addToList(pages) conf.pages < lib.tt_content.shortcut.pages } - 30 = RESTORE_REGISTER -} +[global] -plugin.tx_gridelements_pi1 > -tt_content.gridelements_pi1 > -tt_content.gridelements_pi1 = COA -tt_content.gridelements_pi1 { - #10 =< lib.stdheader - 20 = COA - 20 { - 10 = USER - 10 { - userFunc = GridElementsTeam\Gridelements\Plugin\Gridelements->main - setup { - default < lib.gridelements.defaultGridSetup - } +[userFunc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('css_styled_content')] + tt_content.shortcut { + 20 { + tables := addToList(pages) + conf.pages < lib.tt_content.shortcut.pages } } -} - -tt_content.gridelements_view < tt_content.gridelements_pi1 +[global] diff --git a/Documentation/Chapters/Faq/Index.rst b/Documentation/Chapters/Faq/Index.rst index cae37a4..30a4a41 100644 --- a/Documentation/Chapters/Faq/Index.rst +++ b/Documentation/Chapters/Faq/Index.rst @@ -1,5 +1,4 @@ - .. ================================================== .. FOR YOUR INFORMATION .. -------------------------------------------------- @@ -18,6 +17,16 @@ FAQ --- +**Question: What is the recommended way to create grid element configurations?** + +**Answer:** Even though you can easily create record based grid elements +configurations using the grid wizard, the recommended way is to go for file +based configurations with unique configuration names instead of autoincremented IDs. +This will make sure each of your configurations will work on several systems +even though someone might already have created record based configurations there. +The most important advantage is that you can put these files into your favourite +versioning system and deploy it just like any other code for your project. + **Question: Are Grid Elements a full replacement for TemplaVoila?** **Answer:** Grid Elements are a replacement for the backend related @@ -57,7 +66,7 @@ individual input fields then?** **Answer:** It's very easy to provide a new CType for the tt\_content table with the TYPO3 API since this table already offers you lots of different fields to make use of. Just create the TCA structure and add -a new content type via an extension or maybe via extTables.php, +a new content type via an extension, provide some TypoScript for the frontend output and – voila – here you go with a new content element. diff --git a/Documentation/Chapters/GridTsSyntax/Index.rst b/Documentation/Chapters/GridTsSyntax/Index.rst index 738f186..64d21ad 100644 --- a/Documentation/Chapters/GridTsSyntax/Index.rst +++ b/Documentation/Chapters/GridTsSyntax/Index.rst @@ -40,18 +40,42 @@ Step by step: Start with the number of columns and rows """"""""""""""""""""""""""""""""""""""""" -Go to the **Configuration** tab of the layout record and edit the -**Grid Configuration** there. The wrapper for the whole block is the -same as for pages: **backend\_layout** – Use the keys **colCount** -and **rowCount** to create the basic grid structure. Both values -should be at least the lowest common multiple of the column sizes you -want to create. They represent the actual grid behind the cell -structure. The calculation should take into account that you might be -using colspan and rowspan as well. +Go to the **Configuration** tab of the layout record and use the +wizard to create the **Grid Configuration** there. It is not possible +to directly edit the configuration there anymore, but you will get an +overview about the TypoScript structure of the configuration, when you +click on the button below the wizard. + +Historically the wrapper for the whole block was the same as for pages: +**backend\_layout** – when you are providing the configuration via files, +**this has to be removed though!** + + +:: + + config { + backend_layout { + ... + } + } + +becomes + +:: + + config { + ... + } + +Use the keys **colCount** and **rowCount** to create the basic grid +structure. Both values should be at least the lowest common multiple of +the column sizes you want to create. They represent the actual grid behind +the cell structure. The calculation should take into account that you +might be using colspan and rowspan as well. :: - backend_layout { + config { colCount = 4 rowCount = 3 } @@ -67,7 +91,7 @@ even though it might stay empty later on. :: - backend_layout { + config { colCount = 4 rowCount = 3 rows { @@ -87,31 +111,39 @@ even though it might stay empty later on. Create the cells """""""""""""""" -Each of the cells comes with up to 6 different keys: **name**, -**colPos**, **colspan**, **rowspan**, **allowed** and -**allowedGridTypes**. There must be at least the **name** and if +Each of the cells comes with up to 7 different keys: **name**, +**colPos**, **colspan**, **rowspan**, **allowed**, **disallowed** +and **maxitems**. There must be at least the **name** and if you want to use the column as something else than a placeholder, there must be a value for **colPos** as well. Otherwise the cell will be marked as *inactive* in the page module. -The values for **colspan** , **rowspan**, **allowed** and -**allowedGridTypes** are optional. +The values for **colspan** , **rowspan**, **allowed**, **disallowed** +and **maxitems** are optional. The **allowed** feature is used to determine those content element types the user will be allowed to use within this column. You -can use a comma separated list of Ctype values here and as soon as -this contains at least one value, any other element type will be -forbidden. - -Same goes for the **allowedGridTypes** feature which is used to determine -those grid types the user will be allowed to use within this column. You -can use a comma separated list of Grid Identifiers here and as soon as -this contains at least one value, any other Grid type will be forbidden -and the value gridelements_pi1 will be silently added to **allowed**. - -n this context a "Grid Identifier" can be a GridElement's UID or alias -(if you use records to define your grid elements) -- or a GridElement's ID -(if you use TSconfig to define your grid elements). +can use an array with **CType**, **list_type** and **tx_gridelements_backend_layout** +as keys here and as soon as one of those contains at least one value, +any other type or layout will be forbidden. + +**CType** determines the content element types, **list_type** the plugin types +**tx_gridelements_backend_layout** the grid element types that are allowed +in that particular column. The syntax matches that of the content defender +extension so people using that will not have to change their configuration anymore. + +Same goes for the **disallowed** feature which is the black list variant of the +**allowed** feature. While **alowed** explicitely lists those elements, the +user may put into that column, **disallowed** will exclude specific element list +or grid types keeping all others available. **disallowed** will override **allowed** +in case they contain the same values. + +The **maxitems** feature will limit the maximum number of content elements to be put +in that column. Columns having that limit will get a small counter box at the upper right. +Limiting the number of elements will NOT completely restrict elements there, since users might +switch a layout and won't be able to touch the then superfluous elements anymore. +Still it will remove buttons and give visual feedback when the maximum number of elements +has been reached (orange counter) or exceeded (red counter and items). The **colPos** value will be used while fetching the content elements from the database, since grid view and grid elements @@ -125,7 +157,7 @@ only *text* and *text with image* allowed as a content type: :: - backend_layout { + config { colCount = 4 rowCount = 3 rows { @@ -135,7 +167,9 @@ only *text* and *text with image* allowed as a content type: name = Top colspan = 4 colPos = 0 - allowed = text,textpic + allowed { + CType = text,textpic + } } } } @@ -145,17 +179,24 @@ only *text* and *text with image* allowed as a content type: name = Outer Left rowspan = 2 colPos = 1 - allowed = text,textpic - allowedGridTypes = 2ColumnContainer,3ColumnContainer + allowed { + CType = text,textpic + tx_gridelements_backend_layout = 2ColumnContainer,3ColumnContainer + } } 2 { name = Left colPos = 2 allowed = * + disallowed { + CType = text,textpic + tx_gridelements_backend_layout = 2ColumnContainer,3ColumnContainer + } } 3 { name = Right colPos = 3 + maxitems = 4 } 4 { name = Outer Right diff --git a/Documentation/Chapters/GridWizard/Index.rst b/Documentation/Chapters/GridWizard/Index.rst index b5ed4ff..d30af1b 100644 --- a/Documentation/Chapters/GridWizard/Index.rst +++ b/Documentation/Chapters/GridWizard/Index.rst @@ -27,10 +27,9 @@ Creating the basic grid structure """"""""""""""""""""""""""""""""" When you want to use this wizard just go to the **Configuration** tab -of the layout record, click on the **icon with the pencil** to the -right of the of the **Grid Configuration** area and wait for the -popup window to open. When this is a newly created record, the wizard -will look like this: +of the layout record and you will find it within the editing form. +Since TYPO3 version 8 there is no popup window for that wizard anymore. +When this is a newly created record, the wizard will look like this: .. figure:: ../../Images/GridWizard/CreateBasicGridStructureStep1.png :alt: Create basic grid structure step 1 @@ -40,11 +39,11 @@ will look like this: Otherwise it will show a visible representation of the structure -provided in the textarea. +provided in the PageTS-Config area below. -Now you can click on the **small triangles** at the right and at the -bottom to create the basic grid structure. + will increase the number -of columns and/or rows, - will decrease it. To get the example we have +Now you can click on the **small arrows** at the right and at the +bottom to create the basic grid structure. down and right will increase the number +of columns and/or rows, up and left will decrease it. To get the example we have been using for the :ref:`Grid TS Syntax `, the basic grid would be looking like this: @@ -81,6 +80,15 @@ should be looking like this: .. :align: center .. :name: Create basic grid structure step 3 +Finally you should give the cells a **name** and a number to +be used as the value for the internal colPos within a grid element +using this layout. And you should decide about the available content, list +and grid element types and maybe the maximum number of items for each cell. +If you don't set the **column number**, the cell will be a placeholder that can +not contain any element later on. +To edit the values for each cell, just click on the **pencil within +the square** in the middle of each cell, fill in the values and save +them by clicking on the **disk symbol** . .. figure:: ../../Images/GridWizard/CreateBasicGridStructureStep4.png :alt: Create basic grid structure step 4 @@ -89,16 +97,6 @@ should be looking like this: .. :name: Create basic grid structure step 4 -Finally you should give the cells a **name** and a number to -be used as the value for the internal colPos within a grid element -using this layout. And you should decide about the available content -and grid element types for each cell. If you don't set the **column number**, -the cell will be a placeholder that can not contain any element later on. -To edit the values for each cell, just click on the **pencil within -the square** in the middle of each cell, fill in the values and save -them by clicking on the **disk symbol** . - - Saving the layout to the CE backend layout record """"""""""""""""""""""""""""""""""""""""""""""""" @@ -112,8 +110,10 @@ looking like this: .. :name: Create basic grid structure step 5 -You can save it by clicking on the **disk symbol at the upper left -corner** of the popup window. Depending on the names and column values -you have been using, the result should be close to the example we have +It will be saved and transformed into the PageTS-Config syntax below when you save the record. +Depending on the names and column values you have been using, the result should be close to the example we have used in the :ref:`Grid TS Syntax ` section. When you open the wizard the next time, it will come up in the same state. + +Of course you don't have to save the configuration as a record in the database, but you can copy it and paste it into a file to +include that just as any other usual PageTS-Config file. diff --git a/Documentation/Chapters/Installation/Index.rst b/Documentation/Chapters/Installation/Index.rst index 38c58b8..c2c6289 100644 --- a/Documentation/Chapters/Installation/Index.rst +++ b/Documentation/Chapters/Installation/Index.rst @@ -122,6 +122,8 @@ page, that you want to use as the container for your backend layouts ` chapter to find out how to do that. Now save the record and create some more layouts if you like. +If you want to use file based configuration for your CE backend layouts instead +you can still use the wizard to generate the necessary configuration. Create new Grid Elements @@ -139,18 +141,23 @@ column. After a few seconds the spinner symbol will disappear and show your newly created grid element. Drag in as many elements as necessary for the desired page layout. -.. figure:: ../../Images/Installation/CreateGridElements.png - :alt: Create grid elements +.. figure:: ../../Images/Installation/DragInWizard.png + :alt: Drag in wizard :width: 800 .. :align: center -.. :name: Create grid elements - +.. :name: Drag in wizard **Note:** Of course you can drag elements into the columns of a Grid Element as well, as soon as you got at least one of them on your page. So nesting can be done with the drag in wizard within just a few seconds as well. +.. figure:: ../../Images/Installation/CreateGridElements.png + :alt: Create grid elements + :width: 800 +.. :align: center +.. :name: Create grid elements + Change existing elements into Grid Elements """"""""""""""""""""""""""""""""""""""""""" diff --git a/Documentation/Chapters/Introduction/Index.rst b/Documentation/Chapters/Introduction/Index.rst index 1593644..02a511e 100644 --- a/Documentation/Chapters/Introduction/Index.rst +++ b/Documentation/Chapters/Introduction/Index.rst @@ -1,5 +1,4 @@ - .. ================================================== .. FOR YOUR INFORMATION .. -------------------------------------------------- @@ -25,11 +24,10 @@ Since version 4.5 the TYPO3 core offers the so called **grid view**, a feature developed during the user experience week, that gives backend users some nice options to get a more **user friendly backend layout**. You can create your own table based backend layout records, -fill in as many columns as you like with either a wizard or a -*TSconfig* like code and arrange these columns to match your desired +fill in as many columns as you like with either a wizard or a *TSconfig* like code and arrange these columns to match your desired layout, so backend users will easily recognize where to put their content. Each record can get an icon that will be used as with the -layout selector box. +layout selector box. Code can be stored and versioned in files as well. Grid Elements are pushing these features to the next level, namely content elements. @@ -48,7 +46,7 @@ lots of different features, like form based select boxes and switches to control the frontend output of a grid elements based on this layout later on. -Another usability improvement of Grid Elements is the new **drag and +Another usability improvement of Grid Elements is the **drag and drop behavior** added to the page module. You can drag elements between different columns within the page or element grid. Drop an element to move it or make a copy by pressing the CTRL-key while @@ -67,6 +65,9 @@ A short roundup of the features and advantages - Completely TypoScript based backend layout +- Allowed and (brandnew) disallowed content types, list types and grid types as well + as maximum items per column configurable via wizard or TypoScript + - Comfortable point and click wizard to create backend layout structures and assign columns and allowed content types @@ -98,7 +99,7 @@ A short roundup of the features and advantages - Referenced content visible in the preview section of the reference element -- Completely TypoScript based frontend output +- Completely TypoScript or Fluid based frontend output - Flexform field values automatically added to the data set @@ -111,7 +112,7 @@ A short roundup of the features and advantages - Completely based on hooks without XCLASSing (only exception is the list module due to missing hooks) -Some of you might be used to similar features of TemplaVoilaand ask +Some of you might be used to similar features of TemplaVoila and ask themselves why they should be using grid elements instead. If you want to know more details, check out the **FAQ** section to find some answers diff --git a/Documentation/Chapters/Sponsoring/Index.rst b/Documentation/Chapters/Sponsoring/Index.rst new file mode 100644 index 0000000..d2965f5 --- /dev/null +++ b/Documentation/Chapters/Sponsoring/Index.rst @@ -0,0 +1,85 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. ================================================== +.. DEFINE SOME TEXTROLES +.. -------------------------------------------------- +.. role:: underline +.. role:: typoscript(code) +.. role:: ts(typoscript) + :class: typoscript +.. role:: php(code) +Sponsoring +^^^^^^^^^^ +Inspiring people to share +------------------------- +We strongly believe in the principles of Open-source software, which is why we share this TYPO3 extension with you completely free of charge. + +Still even contributors to Open-source projects have to make a living somehow, so even though you are not obliged to do so, you should consider sharing a small part of the money you might be earning with this extension in return. This way we can make sure to still provide the TYPO3 community with better extensions and services in the future. + +Thanks in advance for your support. + +How to support our efforts? +--------------------------- + +.. |logo0| image:: ../../Images/Sponsoring/CodersCareLogo.png + :target: https://coders.care + :width: 300px + :align: middle +.. |logo1| image:: ../../Images/Sponsoring/PatreonLogo.png + :target: https://www.patreon.com/cybercraft + :width: 200px + :align: middle +.. |logo2| image:: ../../Images/Sponsoring/FlattrLogo.png + :target: https://www.flattr.com/@Cybercraft + :width: 200px + :align: middle +.. |logo3| image:: ../../Images/Sponsoring/PaypalLogo.png + :target: https://www.paypal.me/cybercraftsponsoring/50 + :width: 200px + :align: middle +.. |logo4| image:: ../../Images/Sponsoring/AmazonLogo.png + :target: https://www.amazon.de/gp/registry/wishlist/2I80GX9ZSMYXX + :width: 200px + :align: middle +.. |text0| replace:: Get yourself one of the Service Level Agreements we offer together with our fellow coders. This way you make sure Gridelements and other extensions live long and prosper and you will get a hotline with a defined response time in case of emergency. +.. |text1| replace:: A Service which allows you to become one of our Patrons on a monthly basis. You might even get a shoutout on twitter, get mentioned personally in the next release or even make a feature request depending on the amount you pick. +.. |text2| replace:: Pay any amount monthly on this service and it gets spread even around the people you want to support! We would be Flattr'ed to have you. +.. |text3| replace:: You don't want to sponsor monthly? Dont worry you can also support us via Paypal with any desired amount you find reasonable. +.. |text4| replace:: Sometimes you want to give it a personal touch. When you want to thank Joey and Petra with a nice Single Malt you should take a look here. Slàinte mhath! ++-------+-------------------+ ++-------+-------------------+ +||logo0|||text0| | ++-------+-------------------+ ++-------+-------------------+ +||logo1|||text1| | ++-------+-------------------+ ++-------+-------------------+ +||logo2|||text2| | ++-------+-------------------+ ++-------+-------------------+ +||logo3|||text3| | ++-------+-------------------+ ++-------+-------------------+ +||logo4|||text4| | ++-------+-------------------+ ++-------+-------------------+ +The Agreement +------------- +Excerpt from the coders.care blog post `Service Level Agreements for TYPO3 Extensions `_ + +.. image:: ../../Images/Sponsoring/Why.jpg + :width: 480px +Enabling companies, developers and the community to join forces and thrive +========================================================================== +There is one particular thing, that should be different to most of the variants of service level agreements provided by other open-source projects though. Having to buy a so called "enterprise" or "professional" edition of the extensions or TYPO3 itself just to become entitled for an SLA is a No-Go, since it will create two classes in the community and contradict the principles of free software implied by the GPL. + +The benefit for the people agreeing to a certain service level should be defined by reliability and responsiveness, not by getting access to something, that is unavailable for the rest of the community. So there must be an agreement to still share the improved public extensions with everybody in the community while getting a personal early or immediate access depending on the level and the priority you paid for. + +For developers there is the need for another agreement: They have to accept and publish fixes and changes to their extensions up to a certain degree, so the whole pool of developers can take care of the extensions covered by the SLAs. This will avoid forks. + +There are several nice side effects of these agreements. For example it would reduce the number of extensions which are maintained by a single person and therefor the risk of loss when using these extensions. Due to the four-eyes principle this would increase the quality of each extension in the approved pool and at the same time reduce the amount of "me too" extensions in the TER. + +There would be a powerful team of developers backing the service levels, so it would be easy to keep the approved extensions on a level with upcoming versions of the TYPO3 core. And since this would be done in close collaboration with the TYPO3 core team and the security team, core bugs and security holes affecting extension behaviour could be fixed and published much more easily as well. \ No newline at end of file diff --git a/Documentation/Chapters/Tsconfig/Index.rst b/Documentation/Chapters/Tsconfig/Index.rst index e02d6aa..60ed4c2 100644 --- a/Documentation/Chapters/Tsconfig/Index.rst +++ b/Documentation/Chapters/Tsconfig/Index.rst @@ -33,10 +33,21 @@ Grid Elements completely without grid records: .. ### BEGIN~OF~TABLE ### +.. _tsconfig: + +tx\_gridelements +^^^^^^^^ + + +.. _tsconfig-tx-gridelements-setup: + +tx\_gridelements.setup +"""""""""""""""" + .. container:: table-row Property - tx\_gridelements.setup + setup Data type Grid TS structure @@ -47,6 +58,10 @@ Grid Elements completely without grid records: Default N/A +.. _tsconfig-tx-gridelements-setup-123: + +tx\_gridelements.setup.123 +"""""""""""""""" .. container:: table-row @@ -64,6 +79,10 @@ Grid Elements completely without grid records: Default N/A +.. _tsconfig-tx-gridelements-overrulerecords: + +tx\_gridelements.overruleRecords +"""""""""""""""" .. container:: table-row @@ -80,6 +99,10 @@ Grid Elements completely without grid records: Default 0 +.. _tsconfig-tx-gridelements-excludelayoutids: + +tx\_gridelements.excludeLayoutIds +"""""""""""""""" .. container:: table-row @@ -96,12 +119,15 @@ Grid Elements completely without grid records: Default N/A +.. _tsconfig-TCEFORM-tt-content-tx-gridelements-backend-layout-PAGE-TSCONFIG-ID: + +TCEFORM.tt\_content.tx\_gridelements\_backend\_layout.PAGE\_TSCONFIG\_ID +"""""""""""""""" .. container:: table-row Property - TCEFORM.tt\_content.tx\_gridelements\_backend\_layout.PAGE\_TSCONFIG\_ - ID + TCEFORM.tt\_content.tx\_gridelements\_backend\_layout.PAGE\_TSCONFIG\_ID Data type Integer diff --git a/Documentation/Chapters/Typoscript/Index.rst b/Documentation/Chapters/Typoscript/Index.rst index cf40c65..69c3844 100644 --- a/Documentation/Chapters/Typoscript/Index.rst +++ b/Documentation/Chapters/Typoscript/Index.rst @@ -1,5 +1,3 @@ - - .. ================================================== .. FOR YOUR INFORMATION .. -------------------------------------------------- @@ -114,6 +112,9 @@ As described in the commented part, you will find some additional virtual fields in your data, that will contain stuff that has been used during the rendering process. These come in handy, when you want to use a TEMPLATE or FLUIDTEMPLATE element to produce your output. +Just use the the debug viewhelper in your template to get an overview of the available fields. +:: + {_all} Any of the internal keys and the default settings will of course be passed to the stdWrap method, so you can assign almost anything to any diff --git a/Documentation/Chapters/Typoscript/Reference/Index.rst b/Documentation/Chapters/Typoscript/Reference/Index.rst index 143ee6f..de1f672 100644 --- a/Documentation/Chapters/Typoscript/Reference/Index.rst +++ b/Documentation/Chapters/Typoscript/Reference/Index.rst @@ -1,5 +1,3 @@ - - .. ================================================== .. FOR YOUR INFORMATION .. -------------------------------------------------- @@ -20,20 +18,17 @@ Reference .. ### BEGIN~OF~TABLE ### -.. container:: table-row - Property - Property: +.. _typoscript: - Data type - Data type: +TypoScript +^^^^^^^^ - Description - Description: - Default - Default: +.. _typoscript-setup: +setup +"""""""""""""""" .. container:: table-row @@ -51,6 +46,11 @@ Reference N/A +.. _typoscript-setup-default: + +setup.default +"""""""""""""""" + .. container:: table-row Property @@ -72,6 +72,11 @@ Reference N/A +.. _typoscript-setup-123: + +setup.123 +"""""""""""""""" + .. container:: table-row Property @@ -88,6 +93,11 @@ Reference N/A +.. _typoscript-columns: + +columns +"""""""""""""""" + .. container:: table-row Property @@ -105,6 +115,11 @@ Reference N/A +.. _typoscript-columns-default: + +columns.default +"""""""""""""""" + .. container:: table-row Property @@ -121,6 +136,11 @@ Reference N/A +.. _typoscript-columns-123: + +columns.123 +"""""""""""""""" + .. container:: table-row Property @@ -136,6 +156,11 @@ Reference N/A +.. _typoscript-renderObj: + +renderObj +"""""""""""""""" + .. container:: table-row Property @@ -151,6 +176,11 @@ Reference COA +.. _typoscript-flexform-fieldname: + +flexform\_fieldname +"""""""""""""""" + .. container:: table-row Property @@ -167,6 +197,11 @@ Reference N/A +.. _typoscript-parentgrid-fieldname: + +parentgrid\_fieldname +"""""""""""""""" + .. container:: table-row Property @@ -182,6 +217,11 @@ Reference N/A +.. _typoscript-tx-gridelements-view-children: + +tx\_gridelements\_view\_children +"""""""""""""""" + .. container:: table-row Property @@ -196,6 +236,10 @@ Reference Default N/A +.. _typoscript-tx-gridelements-view-columns: + +tx\_gridelements\_view\_columns +"""""""""""""""" .. container:: table-row @@ -212,6 +256,11 @@ Reference N/A +.. _typoscript-tx-gridelements-view-column-123: + +tx\_gridelements\_view\_column\_123 +"""""""""""""""" + .. container:: table-row Property @@ -227,6 +276,11 @@ Reference N/A +.. _typoscript-tx-gridelements-view-child-123: + +tx\_gridelements\_view\_child\_123 +"""""""""""""""" + .. container:: table-row Property diff --git a/Documentation/Images/GridTsSyntax/ResultOfTheExampleCode.png b/Documentation/Images/GridTsSyntax/ResultOfTheExampleCode.png index 7346bf0..278f280 100644 Binary files a/Documentation/Images/GridTsSyntax/ResultOfTheExampleCode.png and b/Documentation/Images/GridTsSyntax/ResultOfTheExampleCode.png differ diff --git a/Documentation/Images/GridWizard/CreateBasicGridStructureStep1.png b/Documentation/Images/GridWizard/CreateBasicGridStructureStep1.png index 62ee1e2..51aefd7 100644 Binary files a/Documentation/Images/GridWizard/CreateBasicGridStructureStep1.png and b/Documentation/Images/GridWizard/CreateBasicGridStructureStep1.png differ diff --git a/Documentation/Images/GridWizard/CreateBasicGridStructureStep2.png b/Documentation/Images/GridWizard/CreateBasicGridStructureStep2.png index ad1e12c..e54db62 100644 Binary files a/Documentation/Images/GridWizard/CreateBasicGridStructureStep2.png and b/Documentation/Images/GridWizard/CreateBasicGridStructureStep2.png differ diff --git a/Documentation/Images/GridWizard/CreateBasicGridStructureStep3.png b/Documentation/Images/GridWizard/CreateBasicGridStructureStep3.png index 6ee432e..381c7b6 100644 Binary files a/Documentation/Images/GridWizard/CreateBasicGridStructureStep3.png and b/Documentation/Images/GridWizard/CreateBasicGridStructureStep3.png differ diff --git a/Documentation/Images/GridWizard/CreateBasicGridStructureStep4.png b/Documentation/Images/GridWizard/CreateBasicGridStructureStep4.png index 9d75bd7..cf3f2c2 100644 Binary files a/Documentation/Images/GridWizard/CreateBasicGridStructureStep4.png and b/Documentation/Images/GridWizard/CreateBasicGridStructureStep4.png differ diff --git a/Documentation/Images/GridWizard/CreateBasicGridStructureStep5.png b/Documentation/Images/GridWizard/CreateBasicGridStructureStep5.png index fdbac00..57f223e 100644 Binary files a/Documentation/Images/GridWizard/CreateBasicGridStructureStep5.png and b/Documentation/Images/GridWizard/CreateBasicGridStructureStep5.png differ diff --git a/Documentation/Images/Installation/CreateBackendLayouts.png b/Documentation/Images/Installation/CreateBackendLayouts.png index afe8de1..4ddf4dc 100644 Binary files a/Documentation/Images/Installation/CreateBackendLayouts.png and b/Documentation/Images/Installation/CreateBackendLayouts.png differ diff --git a/Documentation/Images/Installation/DragInWizard.png b/Documentation/Images/Installation/DragInWizard.png new file mode 100644 index 0000000..c7efb06 Binary files /dev/null and b/Documentation/Images/Installation/DragInWizard.png differ diff --git a/Documentation/Images/Sponsoring/AmazonLogo.png b/Documentation/Images/Sponsoring/AmazonLogo.png new file mode 100644 index 0000000..a76c7da Binary files /dev/null and b/Documentation/Images/Sponsoring/AmazonLogo.png differ diff --git a/Documentation/Images/Sponsoring/CodersCareLogo.png b/Documentation/Images/Sponsoring/CodersCareLogo.png new file mode 100644 index 0000000..29dc775 Binary files /dev/null and b/Documentation/Images/Sponsoring/CodersCareLogo.png differ diff --git a/Documentation/Images/Sponsoring/FlattrLogo.png b/Documentation/Images/Sponsoring/FlattrLogo.png new file mode 100644 index 0000000..fd2b4a0 Binary files /dev/null and b/Documentation/Images/Sponsoring/FlattrLogo.png differ diff --git a/Documentation/Images/Sponsoring/PatreonLogo.png b/Documentation/Images/Sponsoring/PatreonLogo.png new file mode 100644 index 0000000..0c9b637 Binary files /dev/null and b/Documentation/Images/Sponsoring/PatreonLogo.png differ diff --git a/Documentation/Images/Sponsoring/PaypalLogo.png b/Documentation/Images/Sponsoring/PaypalLogo.png new file mode 100644 index 0000000..79ce33e Binary files /dev/null and b/Documentation/Images/Sponsoring/PaypalLogo.png differ diff --git a/Documentation/Images/Sponsoring/Why.jpg b/Documentation/Images/Sponsoring/Why.jpg new file mode 100644 index 0000000..bee5171 Binary files /dev/null and b/Documentation/Images/Sponsoring/Why.jpg differ diff --git a/Documentation/Index.rst b/Documentation/Index.rst index cb85579..0ffb16e 100644 --- a/Documentation/Index.rst +++ b/Documentation/Index.rst @@ -9,7 +9,7 @@ .. role:: underline .. role:: typoscript(code) .. role:: ts(typoscript) - :class: typoscript + :class: typoscript .. role:: php(code) @@ -18,59 +18,53 @@ Grid Elements ============= :Extension key: - gridelements + gridelements :Version: - 4.0.0 + 8.3.0 :Language: - en + en :Description: - This extension integrates the grid layout concept to regular content - elements. + This extension integrates the backend layout concept of pages to regular content + elements. :Keywords: - grid elements, backend, layout + grid elements, backend, layout :Copyright: - Jo Hasenau, Cybercraft Media Manufactory + Jo Hasenau, Cybercraft Media Manufactory :Author: - The Grid Elements Team + The Grid Elements Team :License: - GNU General Public License, either version 2 of the License or any - later version. + GNU General Public License, either version 2 of the License or any + later version. :Rendered: - |today| + |today| | -This project aims to integrate the grid layout concept also to regular -content elements - the grid elements. This approach is an alternative -to TemplaVoila storing relations normalized in the database without -using XML and offers a lot of comfortable features for an improved -experience of the backend user. It's development has been financed by -T-Systems, Cybercraft and via a crowd funding project @ -http://www.startnext.de/en/typo3-grid-elements-2-0 with sponsoring of -99 Supporters +This project aims to integrate the backend layout concept of pages also to regular content elements - the grid elements. This approach is an alternative to TemplaVoila storing relations normalized in the database without using XML and offers a lot of comfortable features for an improved experience of the backend user. It's development has been financed by T-Systems, Cybercraft and via a crowd funding project @ +http://www.startnext.de/en/typo3-grid-elements-2-0 with sponsoring of 99 supporters. Additionally this new version is now managed by Coders.Care and has been sponsored during a private access phase backed by sponsors. Table Of Content ^^^^^^^^^^^^^^^^ .. toctree:: - :maxdepth: 5 - :titlesonly: - :glob: - - Chapters/Introduction/Index - Chapters/Installation/Index - Chapters/GridTsSyntax/Index - Chapters/GridWizard/Index - Chapters/Flexform/Index - Chapters/Tsconfig/Index - Chapters/Typoscript/Index - Chapters/Faq/Index - Chapters/Notes/Index + :titlesonly: + :glob: + + Chapters/Introduction/Index + Chapters/Installation/Index + Chapters/GridTsSyntax/Index + Chapters/GridWizard/Index + Chapters/Flexform/Index + Chapters/Tsconfig/Index + Chapters/Typoscript/Index + Chapters/Faq/Index + Chapters/Sponsoring/Index + Chapters/Notes/Index diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4ed98d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + gridelements + Copyright (C) 2018 Jo Hasenau + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + gridelements Copyright (C) 2018 Jo Hasenau + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md index 7a0683a..e27b0de 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,56 @@ -Gridelements -============= + +[coders.care-url]: https://coders.care +[patreon-url]: https://www.patreon.com/cybercraft +[flattr-url]: https://www.flattr.com/@Cybercraft +[paypal-url]: https://www.paypal.me/cybercraftsponsoring/50 +[amazon-url]: https://www.amazon.de/gp/registry/wishlist/2I80GX9ZSMYXX +[documentation-url]: https://docs.typo3.org/typo3cms/extensions/gridelements +[blog-url]: https://coders.care/blog/article/service-level-agreements-for-typo3-extensions -Development Branch for 8.x.x versions of Gridelements. -Compatible to TYPO3 CMS 8 LTS only. \ No newline at end of file +# Gridelements + +This TYPO3 extension integrates the grid based backend layout concept known from the page module also to regular content elements - the grid elements. + +## What does it do? + +Besides providing structures based on multiple columns similar to table cells, grid containers can be used to group several elements into one block or to assign special behaviour like accordions or tabs and to render the child elements accordingly. And of course containers can be nested. + +It offers a lot of new features like advanced drag & drop, drag in of new elements, maximum number of items, allowed content, plugin or grid types per column or real references, that improve the usability of the page and list module to speed up the daily work with the backend of TYPO3 CMS. + +## Documentation + +Find installation and configuration instructions and some basic examples on [docs.typo3.org][documentation-url] + +## Inspiring people to share + +We strongly believe in the principles of Open-source software, which is why we share this TYPO3 extension with you completely free of charge. + +Still even contributors to Open-source projects have to make a living somehow, so even though you are not obliged to do so, you should consider sharing a small part of the money you might be earning with this extension in return. This way we can make sure to still provide the TYPO3 community with better extensions and services in the future. + +Thanks in advance for your support. + +## How to support our efforts? + +| | | +|:---------------------------|:--------------------------------| +| [![CodersCareLogo](Documentation/Images/Sponsoring/CodersCareLogo.png)][coders.care-url] | Get yourself one of the Service Level Agreements we offer together with our fellow coders. This way you make sure Gridelements and other extensions live long and prosper and you will get a hotline with a defined response time in case of emergency. | +| [![PatreonLogo](Documentation/Images/Sponsoring/PatreonLogo.png)][patreon-url] | A Service which allows you to become one of our Patrons on a monthly basis. You might even get a shoutout on twitter, get mentioned personally in the next release or even make a feature request depending on the amount you pick. | +| [![FlattrLogo](Documentation/Images/Sponsoring/FlattrLogo.png)][flattr-url] | Pay any amount monthly on this service and it gets spread even around the people you want to support! We would be Flattr'ed to have you. | +| [![PaypalLogo](Documentation/Images/Sponsoring/PaypalLogo.png)][paypal-url] | You don't want to sponsor monthly? Don't worry you can also support us via Paypal with any desired amount you find reasonable. | +| [![AmazonWishlistLogo](Documentation/Images/Sponsoring/AmazonLogo.png)][amazon-url] | Sometimes you want to give it a personal touch. When you want to thank Joey and Petra with a nice Single Malt, you should take a look here. Slàinte mhath! | + +## The Agreement + +Excerpt from the coders.care blog post [Service Level Agreements for TYPO3 Extensions][blog-url] + +![Big Orange rope pulling several colorful small ropes](Documentation/Images/Sponsoring/Why.jpg) +### Enabling companies, developers and the community to join forces and thrive +There is one particular thing, that should be different to most of the variants of service level agreements provided by other open-source projects though. Having to buy a so called "enterprise" or "professional" edition of the extensions or TYPO3 itself just to become entitled for an SLA is a No-Go, since it will create two classes in the community and contradict the principles of free software implied by the GPL. + +The benefit for the people agreeing to a certain service level should be defined by reliability and responsiveness, not by getting access to something, that is unavailable for the rest of the community. So there must be an agreement to still share the improved public extensions with everybody in the community while getting a personal early or immediate access depending on the level and the priority you paid for. + +For developers there is the need for another agreement: They have to accept and publish fixes and changes to their extensions up to a certain degree, so the whole pool of developers can take care of the extensions covered by the SLAs. This will avoid forks. + +There are several nice side effects of these agreements. For example it would reduce the number of extensions which are maintained by a single person and therefor the risk of loss when using these extensions. Due to the four-eyes principle this would increase the quality of each extension in the approved pool and at the same time reduce the amount of "me too" extensions in the TER. + +There would be a powerful team of developers backing the service levels, so it would be easy to keep the approved extensions on a level with upcoming versions of the TYPO3 core. And since this would be done in close collaboration with the TYPO3 core team and the security team, core bugs and security holes affecting extension behaviour could be fixed and published much more easily as well. \ No newline at end of file diff --git a/Resources/Private/Language/de.locallang_wizard.xlf b/Resources/Private/Language/de.locallang_wizard.xlf index 0527d0e..38be552 100644 --- a/Resources/Private/Language/de.locallang_wizard.xlf +++ b/Resources/Private/Language/de.locallang_wizard.xlf @@ -41,7 +41,7 @@ Restricted CE - Zulässige CE + Unzulässige CE Select the content element types that may NOT be created or moved here. @@ -49,7 +49,7 @@ Restricted Grids - Zulässige Raster-Elemente + Unzulässige Raster-Elemente Select the Gridelements types that may NOT be created or moved here. @@ -57,7 +57,7 @@ Restricted Plugins - Zulässige Plugins + Unzulässige Plugins Select the plugin types that may NOT be created or moved here. diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index f930e78..8deccd6 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -9,6 +9,9 @@ Enable nesting in list module + + Use language overlay for content and page records referenced in shortcut elements. + \ No newline at end of file diff --git a/Resources/Public/Backend/Css/Skin/t3skin_override.css b/Resources/Public/Backend/Css/Skin/t3skin_override.css index a85074f..9daf17b 100644 --- a/Resources/Public/Backend/Css/Skin/t3skin_override.css +++ b/Resources/Public/Backend/Css/Skin/t3skin_override.css @@ -92,6 +92,18 @@ filter: alpha(opacity=65); } +.t3-grid-cell-horizontal > .t3js-sortable > .ui-draggable > .t3-page-ce-dropzone-possible { + margin: -28px 0 -27px 0!important; +} + +.t3-grid-cell-horizontal > .t3js-sortable > .t3js-page-ce-sortable > .t3-page-ce-dropzone-available { + margin: 10px 0!important; +} + +.t3-grid-cell-horizontal > .t3js-sortable > .t3js-page-ce-sortable > .t3-page-ce-dropzone-possible { + margin: -38px 0 -37px 0!important; +} + .t3-page-ce-dragitem.dragitem-shadow { opacity: 0.65; filter: alpha(opacity=65); @@ -102,7 +114,8 @@ margin: 0 -10px; } -.t3js-module-body .t3-grid-container-title-0 { +.t3js-module-body .t3-grid-container-title-0, +.t3js-module-body .t3-grid-container-title--1 { font-size: 12px; font-weight: normal; color: #999999; @@ -403,12 +416,28 @@ display: block; } -.t3-grid-cell-horizontal { - white-space: nowrap; +.t3-grid-cell-horizontal > .t3js-sortable { + display: table; + vertical-align: top; + width: 100%; +} + +.t3-grid-cell-horizontal > .t3js-sortable > .ui-draggable { + display: table-row; +} + +.t3-grid-cell-horizontal > .t3js-sortable > .ui-draggable > .ui-droppable { + margin: 10px; +} + +.t3-grid-cell-horizontal > .t3js-sortable > .ui-draggable > .t3js-page-new-ce { + display: table-cell; + padding: 10px; } .t3-grid-cell-horizontal > .t3js-sortable > .t3js-page-ce-sortable { - display: inline-block; + display: table-cell; + padding: 0px 10px 0px; vertical-align: top; } @@ -444,12 +473,12 @@ display: block; float: right; margin-top: 11px; - margin-right: 11px; + right: 11px; height: 25px; border: 1px solid #ccc; border-radius: 2px; padding: 2px 5px; - position: relative; + position: absolute; z-index: 100; } diff --git a/Resources/Public/JavaScript/ContextMenuActions.js b/Resources/Public/JavaScript/ContextMenuActions.js index 80bca7f..94cfd47 100644 --- a/Resources/Public/JavaScript/ContextMenuActions.js +++ b/Resources/Public/JavaScript/ContextMenuActions.js @@ -39,7 +39,6 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], func */ ContextMenuActions.pasteReference = function (table, uid) { var $anchorElement = $(this); - var title = $anchorElement.data('title'); var actionUrl = $anchorElement.data('action-url'); var performPaste = function () { var url = actionUrl + '&redirect=' + top.rawurlencode(top.list_frame.document.location.pathname + top.list_frame.document.location.search); diff --git a/Resources/Public/JavaScript/GridEditor.js b/Resources/Public/JavaScript/GridEditor.js index 9bbcfb9..6a24869 100644 --- a/Resources/Public/JavaScript/GridEditor.js +++ b/Resources/Public/JavaScript/GridEditor.js @@ -427,10 +427,14 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity', 'TYPO */ GridEditor.setName = function (newName, col, row) { var cell = GridEditor.getCell(col, row); - if (!cell || newName.trim() === '') { + if (!cell) { return false; } - cell.name = GridEditor.stripMarkup(newName); + if (newName.trim() === '') { + cell.name = undefined; + } else { + cell.name = GridEditor.stripMarkup(newName); + } return true; }; @@ -446,10 +450,14 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity', 'TYPO */ GridEditor.setColumn = function (newColumn, col, row) { var cell = GridEditor.getCell(col, row); - if (!cell || newColumn.trim() === '') { + if (!cell) { return false; } - cell.column = parseInt(newColumn, 10); + if (newColumn.trim() === '') { + cell.column = undefined; + } else { + cell.column = parseInt(newColumn, 10); + } return true; }; @@ -465,7 +473,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity', 'TYPO */ GridEditor.setMaxItems = function (newMaxItems, col, row) { var cell = GridEditor.getCell(col, row); - if (!cell || newMaxItems.trim() === '') { + if (!cell) { return false; } cell.maxitems = parseInt(newMaxItems, 10); @@ -836,7 +844,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity', 'TYPO typeIcon = type.icon, typeLabel = type.label, typeSelected = $.inArray(typeKey, selectedTypes) !== -1, - typeStyle = 'background: #fff url(' + typeIcon + ') 0% 50% no-repeat; height: 16px; padding: 2px 10px 0 22px;' + typeStyle = 'background: #fff url(' + typeIcon + ') 0% 50% no-repeat; height: 16px; padding: 2px 10px 0 22px;'; allowedTypeOptions.push(''); } @@ -874,7 +882,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity', 'TYPO * @returns {Boolean} */ GridEditor.cellCanSpanRight = function (col, row) { - if (col == GridEditor.colCount - 1) { + if (col === GridEditor.colCount - 1) { return false; } @@ -905,7 +913,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity', 'TYPO * @returns {Boolean} */ GridEditor.cellCanSpanDown = function (col, row) { - if (row == GridEditor.rowCount - 1) { + if (row === GridEditor.rowCount - 1) { return false; } diff --git a/Resources/Public/JavaScript/GridElementsDragDrop.js b/Resources/Public/JavaScript/GridElementsDragDrop.js index c095fc2..4c8b1f7 100644 --- a/Resources/Public/JavaScript/GridElementsDragDrop.js +++ b/Resources/Public/JavaScript/GridElementsDragDrop.js @@ -45,10 +45,10 @@ define(['jquery', 'jquery-ui/droppable', 'TYPO3/CMS/Backend/LayoutModule/DragDro distance: 20, addClasses: 'active-drag', revert: 'invalid', - start: function (evt, ui) { + start: function () { DragDrop.onDragStart($(this)); }, - stop: function (evt, ui) { + stop: function () { DragDrop.onDragStop($(this)); } }); @@ -79,7 +79,7 @@ define(['jquery', 'jquery-ui/droppable', 'TYPO3/CMS/Backend/LayoutModule/DragDro DragDrop.drag = $element.children(DragDrop.drag); DragDrop.drag.addClass('dragitem-shadow'); DragDrop.types = $element.find(DragDrop.cTypeIdentifier); - if ($element.closest(DragDrop.newContentElementWizardIdentifier).length == 0) { + if ($element.closest(DragDrop.newContentElementWizardIdentifier).length === 0) { $element.append('
    ' + TYPO3.lang['dragdrop.copy.message'] + '
    '); } else { // all information about CType, list_type and other default values has to be fetched from onclick diff --git a/Resources/Public/JavaScript/GridElementsDragInWizard.js b/Resources/Public/JavaScript/GridElementsDragInWizard.js index 43e4fd0..b9a3f4e 100644 --- a/Resources/Public/JavaScript/GridElementsDragInWizard.js +++ b/Resources/Public/JavaScript/GridElementsDragInWizard.js @@ -47,7 +47,7 @@ define(['jquery', 'TYPO3/CMS/Gridelements/GridElementsDragDrop', 'jquery-ui/drag originalWizardUrl = $newCeLink.attr('href').split('\&', 4); } if (typeof originalWizardUrl !== 'undefined') { - DragInWizard.wizardUrl = '\/typo3\/index.php?route=%2Frecord%2Fcontent%2Fnew&' + originalWizardUrl[1] + '&' + originalWizardUrl[2]; + DragInWizard.wizardUrl = originalWizardUrl[0] + '&' + originalWizardUrl[1] + '&' + originalWizardUrl[2]; } }; @@ -59,7 +59,7 @@ define(['jquery', 'TYPO3/CMS/Gridelements/GridElementsDragDrop', 'jquery-ui/drag var addNewIcon = $('.t3-page-ce-wrapper-new-ce a').first(); var newIcon = addNewIcon.clone().attr('class', 'btn btn-default btn-sm').insertAfter(lastIcon); newIcon.contents().filter(function () { - return (this.nodeType == 3); + return (this.nodeType === 3); }).remove(); newIcon.removeAttr('onclick').attr('title', 'Toggle Drag In Wizard'); newIcon.click(function () { @@ -104,8 +104,6 @@ define(['jquery', 'TYPO3/CMS/Gridelements/GridElementsDragDrop', 'jquery-ui/drag */ DragInWizard.rearrangeItems = function () { var panel = $('#' + DragInWizard.wizardIdentifier + ' .t3js-tabs'); - var CType; - var listType; $('#' + DragInWizard.wizardIdentifier + ' .media').each(function () { $(this).find('.media-left').addClass('t3-ctype-identifier'); var description = $(this).find('.media-body'); diff --git a/Resources/Public/JavaScript/GridElementsOnReady.js b/Resources/Public/JavaScript/GridElementsOnReady.js index ab7f359..52a2fe1 100644 --- a/Resources/Public/JavaScript/GridElementsOnReady.js +++ b/Resources/Public/JavaScript/GridElementsOnReady.js @@ -18,368 +18,456 @@ define(['jquery', 'TYPO3/CMS/Backend/AjaxDataHandler', 'TYPO3/CMS/Backend/Storage', 'TYPO3/CMS/Gridelements/GridElementsDragDrop', 'TYPO3/CMS/Backend/LayoutModule/Paste', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], function ($, AjaxDataHandler, Storage, DragDrop, Paste, Modal, Severity) { - var OnReady = { - openedPopupWindow: [] - }; - - - AjaxDataHandler.identifier.allGridelementsToggle = '.t3js-toggle-gridelements-all'; - AjaxDataHandler.identifier.gridelementToggle = '.t3js-toggle-gridelements-list'; - AjaxDataHandler.identifier.allGridelementsColumnsToggle = '.t3js-toggle-gridelements-columns-all'; - AjaxDataHandler.identifier.gridelementColumnToggle = '.t3js-toggle-gridelements-column'; - - /** - * initializes Drag+Drop for all content elements on the page - */ - OnReady.initialize = function () { - if ($('#recordlist-tt_content').length) { - OnReady.activateAllGridExpander(); - } - if ($('.t3js-page-columns').length) { - OnReady.setAllowedData(); - OnReady.activateAllCollapseIcons(); - } - }; - - /** - * activates the paste into / paste after and fetch copy from another page icons outside of the context menus - */ - Paste.activatePasteIcons = function () { - $('.icon-actions-document-paste-into').parent().remove(); - $('.t3-page-ce-wrapper-new-ce').each(function () { - if(!$(this).find('.icon-actions-document-new').length) { - return true; - } - $(this).addClass('btn-group btn-group-sm'); - $('.t3js-page-lang-column .t3-page-ce > .t3-page-ce').removeClass('t3js-page-ce'); - if (top.pasteAfterLinkTemplate && top.pasteIntoLinkTemplate) { - var parent = $(this).parent(); - if (parent.data('page') || (parent.data('container') && !parent.data('uid'))) { - $(this).append(top.pasteIntoLinkTemplate); - } else { - $(this).append(top.pasteAfterLinkTemplate); - } - $(this).find('.t3js-paste').on('click', function (evt) { - evt.preventDefault(); - Paste.activatePasteModal($(this)); - }); - } - $(this).append(top.copyFromAnotherPageLinkTemplate); - $(this).find('.t3js-paste-new').on('click', function (evt) { - evt.preventDefault(); - OnReady.copyFromAnotherPage($(this)); - }); - }); - } - - /** - * generates the paste into / paste after modal - */ - Paste.activatePasteModal = function (element) { - var $element = $(element); - var url = $element.data('url') || null; - var title = (TYPO3.lang['paste.modal.title.paste'] || 'Paste record') + ': "' + $element.data('title') + '"'; - var severity = (typeof top.TYPO3.Severity[$element.data('severity')] !== 'undefined') ? top.TYPO3.Severity[$element.data('severity')] : top.TYPO3.Severity.info; - if ($element.hasClass('t3js-paste-copy')) { - var content = TYPO3.lang['tx_gridelements_js.modal.pastecopy'] || '1 How do you want to paste that clipboard content here?'; - var buttons = [ - { - text: TYPO3.lang['paste.modal.button.cancel'] || 'Cancel', - active: true, - btnClass: 'btn-default', - trigger: function () { - Modal.currentModal.trigger('modal-dismiss'); - } - }, - { - text: TYPO3.lang['tx_gridelements_js.modal.button.pastecopy'] || 'Paste as copy', - btnClass: 'btn-' + top.TYPO3.Severity.getCssClass(severity), - trigger: function (ev) { - Modal.currentModal.trigger('modal-dismiss'); - DragDrop.onDrop($element.data('content'), $element, ev); - } - }, - { - text: TYPO3.lang['tx_gridelements_js.modal.button.pastereference'] || 'Paste as reference', - btnClass: 'btn-' + top.TYPO3.Severity.getCssClass(severity), - trigger: function (ev) { - Modal.currentModal.trigger('modal-dismiss'); - DragDrop.onDrop($element.data('content'), $element, ev, 'reference'); - } - } - ]; - if(top.pasteReferenceAllowed !== true) { - buttons.pop(); - } - } else { - var content = TYPO3.lang['paste.modal.paste'] || 'Do you want to move the record to this position?'; - var buttons = [ - { - text: TYPO3.lang['paste.modal.button.cancel'] || 'Cancel', - active: true, - btnClass: 'btn-default', - trigger: function () { - Modal.currentModal.trigger('modal-dismiss'); - } - }, - { - text: TYPO3.lang['paste.modal.button.paste'] || 'Move', - btnClass: 'btn-' + Severity.getCssClass(severity), - trigger: function () { - Modal.currentModal.trigger('modal-dismiss'); - DragDrop.onDrop($element.data('content'), $element, null); - } - } - ]; - } - if (url !== null) { - var separator = (url.indexOf('?') > -1) ? '&' : '?'; - var params = $.param({data: $element.data()}); - Modal.loadUrl(title, severity, buttons, url + separator + params); - } else { - Modal.show(title, content, severity, buttons); - } - } - - /** - * sets the classes for allowed element types to the cells of the original page module - */ - OnReady.setAllowedData = function () { - $('table.t3js-page-columns > tbody > tr > td').each(function () { - var colPos = $(this).data('colpos') ? $(this).data('colpos') : $(this).find('> .t3-page-ce-wrapper').data('colpos'); - if (typeof colPos !== 'undefined') { - if (typeof top.pageColumnsAllowed[colPos] !== 'undefined') { + var OnReady = { + openedPopupWindow: [] + }; + + + AjaxDataHandler.identifier.allGridelementsToggle = '.t3js-toggle-gridelements-all'; + AjaxDataHandler.identifier.gridelementToggle = '.t3js-toggle-gridelements-list'; + AjaxDataHandler.identifier.allGridelementsColumnsToggle = '.t3js-toggle-gridelements-columns-all'; + AjaxDataHandler.identifier.gridelementColumnToggle = '.t3js-toggle-gridelements-column'; + + /** + * initializes Drag+Drop for all content elements on the page + */ + OnReady.initialize = function () { + if ($('#recordlist-tt_content').length) { + OnReady.activateAllGridExpander(); + } + if ($('.t3js-page-columns').length) { + if (top.pasteIntoLinkTemplate === '' && top.pasteAfterLinkTemplate === '') { + OnReady.setAllowedData(); + } + OnReady.activateAllCollapseIcons(); + } + }; + + /** + * activates the paste into / paste after and fetch copy from another page icons outside of the context menus + */ + Paste.activatePasteIcons = function () { + OnReady.setAllowedData(); + $('.icon-actions-document-paste-into').parent().remove(); + $('.t3-page-ce-wrapper-new-ce').each(function () { + if (!$(this).find('.icon-actions-document-new').length) { + return true; + } + $(this).addClass('btn-group btn-group-sm'); + $('.t3js-page-lang-column .t3-page-ce > .t3-page-ce').removeClass('t3js-page-ce'); + var gridCell = $(this).closest('.t3-grid-cell'); + if (typeof(gridCell.data('allowed')) === 'undefined') { + gridCell.data('allowedCType', false); + gridCell.data('allowedTxGridelementsBackendLayout', false); + gridCell.data('allowedListType', false); + if (top.clipBoardElementCType) { + if (typeof(gridCell.data('allowed-ctype')) !== 'undefined') { + var allowedCTypes = gridCell.data('allowed-ctype').toString().split(','); + if ( + allowedCTypes.indexOf(top.clipBoardElementCType) > -1 + || allowedCTypes.indexOf('*') > -1 + || gridCell.data('allowed-ctype') === '*' + ) { + gridCell.data('allowedCType', true); + } + } else { + gridCell.data('allowedCType', true); + } + if (typeof(gridCell.data('disallowed-ctype')) !== 'undefined') { + var disallowedCTypes = gridCell.data('disallowed-ctype').toString().split(','); + if ( + disallowedCTypes.indexOf(top.clipBoardElementCType) > -1 + || disallowedCTypes.indexOf('*') > -1 + || gridCell.data('disallowed-ctype') === '*' + ) { + gridCell.data('allowedCType', false); + } + } + } else { + gridCell.data('allowedCType', true); + } + if (top.clipBoardElementTxGridelementsBackendLayout) { + if (typeof(gridCell.data('allowed-tx_gridelements_backend_layout')) !== 'undefined') { + var allowedTxGridelementsBackendLayouts = gridCell.data('allowed-tx_gridelements_backend_layout').toString().split(','); + if ( + allowedTxGridelementsBackendLayouts.indexOf(top.clipBoardElementTxGridelementsBackendLayout) > -1 + || allowedTxGridelementsBackendLayouts.indexOf('*') > -1 + || gridCell.data('allowed-tx_gridelements_backend_layout') === '*' + ) { + gridCell.data('allowedTxGridelementsBackendLayout', true); + } + } else { + gridCell.data('allowedTxGridelementsBackendLayout', true); + } + if (typeof(gridCell.data('disallowed-tx_gridelements_backend_layout')) !== 'undefined') { + var disallowedTxGridelementsBackendLayouts = gridCell.data('disallowed-tx_gridelements_backend_layout').toString().split(','); + if ( + disallowedTxGridelementsBackendLayouts.indexOf(top.clipBoardElementTxGridelementsBackendLayout) > -1 + || disallowedTxGridelementsBackendLayouts.indexOf('*') > -1 + || gridCell.data('disallowed-tx_gridelements_backend_layout') === '*' + ) { + gridCell.data('allowedTxGridelementsBackendLayout', false); + } + } + } else { + gridCell.data('allowedTxGridelementsBackendLayout', true); + } + if (top.clipBoardElementListType) { + if (typeof(gridCell.data('allowed-list_type')) !== 'undefined') { + var allowedListTypes = gridCell.data('allowed-list_type').toString().split(','); + if ( + allowedListTypes.indexOf(top.clipBoardElementListType) > -1 + || allowedListTypes.indexOf('*') > -1 + || gridCell.data('allowed-list_type') === '*' + ) { + gridCell.data('allowedListType', true); + } + } else { + gridCell.data('allowedListType', true); + } + if (typeof(gridCell.data('disallowed-list_type')) !== 'undefined') { + var disallowedListTypes = gridCell.data('disallowed-list_type').toString().split(','); + if ( + disallowedListTypes.indexOf(top.clipBoardElementListType) > -1 + || disallowedListTypes.indexOf('*') > -1 + || gridCell.data('disallowed-list_type') === '*' + ) { + gridCell.data('allowedListType', false); + } + } + } else { + gridCell.data('allowedListType', true); + } + gridCell.data('allowed', (gridCell.data('allowedCType') && gridCell.data('allowedTxGridelementsBackendLayout') && gridCell.data('allowedListType'))); + } + if (top.pasteAfterLinkTemplate && top.pasteIntoLinkTemplate && gridCell.data('allowed')) { + var parent = $(this).parent(); + if (parent.data('page') || (parent.data('container') && !parent.data('uid'))) { + $(this).append(top.pasteIntoLinkTemplate); + } else { + $(this).append(top.pasteAfterLinkTemplate); + } + $(this).find('.t3js-paste').on('click', function (evt) { + evt.preventDefault(); + Paste.activatePasteModal($(this)); + }); + } + $(this).append(top.copyFromAnotherPageLinkTemplate); + $(this).find('.t3js-paste-new').on('click', function (evt) { + evt.preventDefault(); + OnReady.copyFromAnotherPage($(this)); + }); + }); + }; + + /** + * generates the paste into / paste after modal + */ + Paste.activatePasteModal = function (element) { + var $element = $(element); + var url = $element.data('url') || null; + var title = (TYPO3.lang['paste.modal.title.paste'] || 'Paste record') + ': "' + $element.data('title') + '"'; + var severity = (typeof top.TYPO3.Severity[$element.data('severity')] !== 'undefined') ? top.TYPO3.Severity[$element.data('severity')] : top.TYPO3.Severity.info; + if ($element.hasClass('t3js-paste-copy')) { + var content = TYPO3.lang['tx_gridelements_js.modal.pastecopy'] || '1 How do you want to paste that clipboard content here?'; + var buttons = [ + { + text: TYPO3.lang['paste.modal.button.cancel'] || 'Cancel', + active: true, + btnClass: 'btn-default', + trigger: function () { + Modal.currentModal.trigger('modal-dismiss'); + } + }, + { + text: TYPO3.lang['tx_gridelements_js.modal.button.pastecopy'] || 'Paste as copy', + btnClass: 'btn-' + top.TYPO3.Severity.getCssClass(severity), + trigger: function (ev) { + Modal.currentModal.trigger('modal-dismiss'); + DragDrop.onDrop($element.data('content'), $element, ev); + } + }, + { + text: TYPO3.lang['tx_gridelements_js.modal.button.pastereference'] || 'Paste as reference', + btnClass: 'btn-' + top.TYPO3.Severity.getCssClass(severity), + trigger: function (ev) { + Modal.currentModal.trigger('modal-dismiss'); + DragDrop.onDrop($element.data('content'), $element, ev, 'reference'); + } + } + ]; + if (top.pasteReferenceAllowed !== true) { + buttons.pop(); + } + } else { + var content = TYPO3.lang['paste.modal.paste'] || 'Do you want to move the record to this position?'; + var buttons = [ + { + text: TYPO3.lang['paste.modal.button.cancel'] || 'Cancel', + active: true, + btnClass: 'btn-default', + trigger: function () { + Modal.currentModal.trigger('modal-dismiss'); + } + }, + { + text: TYPO3.lang['paste.modal.button.paste'] || 'Move', + btnClass: 'btn-' + Severity.getCssClass(severity), + trigger: function () { + Modal.currentModal.trigger('modal-dismiss'); + DragDrop.onDrop($element.data('content'), $element, null); + } + } + ]; + } + if (url !== null) { + var separator = (url.indexOf('?') > -1) ? '&' : '?'; + var params = $.param({data: $element.data()}); + Modal.loadUrl(title, severity, buttons, url + separator + params); + } else { + Modal.show(title, content, severity, buttons); + } + }; + + /** + * sets the classes for allowed element types to the cells of the original page module + */ + OnReady.setAllowedData = function () { + $('table.t3js-page-columns > tbody > tr > td').each(function () { + var colPos = $(this).data('colpos') ? $(this).data('colpos') : $(this).find('> .t3-page-ce-wrapper').data('colpos'); + if (typeof colPos !== 'undefined') { + if (typeof top.pageColumnsAllowed[colPos] !== 'undefined') { $(this).attr('data-allowed-ctype', top.pageColumnsAllowed[colPos]['CType']); $(this).attr('data-allowed-list_type', top.pageColumnsAllowed[colPos]['list_type']); $(this).attr('data-allowed-tx_gridelements_backend_layout', top.pageColumnsAllowed[colPos]['tx_gridelements_backend_layout']); - } - if (typeof top.pageColumnsDisallowed[colPos] !== 'undefined') { + } + if (typeof top.pageColumnsDisallowed[colPos] !== 'undefined') { $(this).attr('data-disallowed-ctype', top.pageColumnsDisallowed[colPos]['CType']); $(this).attr('data-disallowed-list_type', top.pageColumnsDisallowed[colPos]['list_type']); $(this).attr('data-disallowed-tx_gridelements_backend_layout', top.pageColumnsDisallowed[colPos]['tx_gridelements_backend_layout']); - } - if (typeof top.pageColumnsMaxitems[colPos] !== 'undefined') { - var $children = $(this).find('> .t3js-sortable > .t3js-page-ce-sortable'); - var itemsOfMax = $children.length + '/' + top.pageColumnsMaxitems[colPos]; + } + if (typeof top.pageColumnsMaxitems[colPos] !== 'undefined') { + var $children = $(this).find('> .t3js-sortable > .t3js-page-ce-sortable'); + var itemsOfMax = $children.length + '/' + top.pageColumnsMaxitems[colPos]; $(this).attr('data-maxitems', top.pageColumnsMaxitems[colPos]); $(this).find('> .t3-page-column-header').after('' + itemsOfMax + ''); if ($children.length > top.pageColumnsMaxitems[colPos]) { $(this).find('> .t3-grid-cell-number-of-items').text(itemsOfMax + '!').addClass('danger'); $(this).addClass('t3-page-ce-disable-new-ce'); - $children.each(function() { - if ($(this).index() > top.pageColumnsMaxitems[colPos]) { - $(this).addClass('t3-page-ce-danger'); - } - }); - } else if ($children.length == top.pageColumnsMaxitems[colPos]) { + $children.each(function () { + if ($(this).index() > top.pageColumnsMaxitems[colPos]) { + $(this).addClass('t3-page-ce-danger'); + } + }); + } else if ($children.length === Number(top.pageColumnsMaxitems[colPos])) { + $(this).addClass('t3-page-ce-disable-new-ce'); $(this).find('> .t3-grid-cell-number-of-items').addClass('warning'); - } else { + } else { $(this).find('> .t3-grid-cell-number-of-items').addClass('success'); - } - } - OnReady.setAllowedParameters($(this), colPos); - } - }); - }; - - /** - * sets the parameters for allowed element types to the add new content links of the original page module - */ - OnReady.setAllowedParameters = function (pageColumn, colPos) { - pageColumn.find('.t3js-page-new-ce:not(".t3js-page-new-ce-allowed") a').each(function () { - if(typeof $(this).attr('href') !== 'undefined') { - $(this).attr('href', $(this).attr('href').replace( - '&uid_pid', - (top.pageColumnsAllowed[colPos] ? ('&tx_gridelements_allowed=' + window.btoa(JSON.stringify(top.pageColumnsAllowed[colPos]))) : '') + - (top.pageColumnsDisallowed[colPos] ? ('&tx_gridelements_disallowed=' + window.btoa(JSON.stringify(top.pageColumnsDisallowed[colPos]))) : '') + - '&uid_pid' - )); - } - }); - }; - - /** - * activates the arrow icons to show/hide content previews within a certain grid column - */ - OnReady.activateAllCollapseIcons = function () { - OnReady.activateCollapseIcons(); - var lastIcon = $('.module-docheader-bar-column-left .btn-group .icon').last().parent(); - var addNewIcon = $('.t3js-toggle-gridelements-column').first(); - var newIcon = addNewIcon.clone().attr('class', 'btn btn-default btn-sm t3js-gridcolumn-toggle t3js-gridcolumn-expand').insertAfter(lastIcon); - newIcon.contents().filter(function () { - return (this.nodeType == 3); - }).remove(); - newIcon.find('.icon-actions-view-list-collapse').remove(); - newIcon.removeAttr('onclick').attr('title', 'Expand all grid columns'); - var newIcon = addNewIcon.clone().attr('class', 'btn btn-default btn-sm t3js-gridcolumn-toggle').insertAfter(lastIcon); - newIcon.contents().filter(function () { - return (this.nodeType == 3); - }).remove(); - newIcon.find('.icon-actions-view-list-expand').remove(); - newIcon.removeAttr('onclick').attr('title', 'Collapse all grid columns'); - $(document).on('click', '.t3js-gridcolumn-toggle', function (evt) { - evt.preventDefault(); - - var $me = $(this), - collapsed = $me.hasClass('t3js-gridcolumn-expand') ? 0 : 1; - - // Store collapse state in UC - var storedModuleDataPage = {}; - - if (Storage.Persistent.isset('moduleData.page.gridelementsCollapsedColumns')) { - storedModuleDataPage = Storage.Persistent.get('moduleData.list.gridelementsExpanded'); - } - - var collapseConfig = {}; - $('[data-columnkey]').each(function () { - collapseConfig[$(this).data('columnkey')] = collapsed; - $(this).removeClass('collapsed','expanded'); - $(this).addClass(collapsed ? 'collapsed' : 'expanded'); - }); - - storedModuleDataPage = $.extend(true, storedModuleDataPage, collapseConfig); - Storage.Persistent.set('moduleData.page.gridelementsCollapsedColumns', storedModuleDataPage); - - }); - } - - /** - * activates the arrow icons to show/hide content previews within a certain grid column - */ - OnReady.activateCollapseIcons = function () { - $(document).on('click', AjaxDataHandler.identifier.gridelementColumnToggle, function (evt) { - evt.preventDefault(); - - var $me = $(this), - column = $me.closest('.t3js-page-column').data('colpos'), - columnKey = $me.closest('.t3js-page-column').data('columnkey'), - isExpanded = $me.data('state') === 'expanded'; - - // Store collapse state in UC - var storedModuleDataPage = {}; - - if (Storage.Persistent.isset('moduleData.page.gridelementsCollapsedColumns')) { - storedModuleDataPage = Storage.Persistent.get('moduleData.page.gridelementsCollapsedColumns'); - } - - var expandConfig = {}; - expandConfig[columnKey] = isExpanded ? 1 : 0; - - storedModuleDataPage = $.extend(true, storedModuleDataPage, expandConfig); - Storage.Persistent.set('moduleData.page.gridelementsCollapsedColumns', storedModuleDataPage).done(function () { - $me.data('state', isExpanded ? 'collapsed' : 'expanded'); - }); - - $me.closest('.t3-grid-cell').toggleClass('collapsed','expanded'); - var originalTitle = $me.attr('title'); - $me.attr('title', $me.attr('data-toggle-title')); - $me.attr('data-toggle-title', originalTitle); - $me.blur(); - - }); - - $('.t3-page-column-header-icons').each(function () { - $(this).addClass('btn-group btn-group-sm'); - $(this).find('a').addClass('btn btn-default'); - }); - } - - /** - * generates the paste into / paste after modal - */ - OnReady.copyFromAnotherPage = function (element) { - var url = top.backPath + top.browserUrl + '&mode=db&bparams=' + element.parent().attr('id') + '|||tt_content|'; - OnReady.openedPopupWindow = window.open(url, 'Typo3WinBrowser', 'height=600,width=800,status=0,menubar=0,resizable=1,scrollbars=1'); - OnReady.openedPopupWindow.focus(); - } - - /** - * gives back the data from the popup window to the copy action - */ - if (!$('.typo3-TCEforms').length) { - OnReady.setSelectOptionFromExternalSource = setFormValueFromBrowseWin = function(elementId, tableUid){ - tableUid = tableUid.replace('tt_content_', '') * 1; - DragDrop.onDrop(tableUid, $('#' + elementId).find('.t3js-paste-new'), 'copyFromAnotherPage'); - } - } - - /** - * activates the toggle icons to open listings of nested grid container structure in the list module - */ - OnReady.activateAllGridExpander = function () { - OnReady.activateGridExpander(); - $(document).on('click', AjaxDataHandler.identifier.allGridelementsToggle, function (evt) { - evt.preventDefault(); - - var $me = $(this), - container = '0,' + $me.data('container-ids'), - isExpanded = this.id === 't3-gridelements-expand-all' ? 1 : 0; - - // Store collapse state in UC - var storedModuleDataList = {}; - - if (Storage.Persistent.isset('moduleData.list.gridelementsExpanded')) { - storedModuleDataList = Storage.Persistent.get('moduleData.list.gridelementsExpanded'); - } - - var expandConfig = {}; - $(container.split(',')).each(function (el, id) { - if (id > 0) { - expandConfig[id] = isExpanded; - if (isExpanded === 1) { - $('[data-uid=' + id + ']').find('.t3js-toggle-gridelements-list').addClass('open-gridelements-container'); - $('[data-trigger-container=' + id + ']').addClass('expanded'); - } else { - $('[data-uid=' + id + ']').find('.t3js-toggle-gridelements-list').removeClass('open-gridelements-container'); - $('[data-trigger-container=' + id + ']').removeClass('expanded'); - } - } - }); - - storedModuleDataList = $.extend(true, storedModuleDataList, expandConfig); - Storage.Persistent.set('moduleData.list.gridelementsExpanded', storedModuleDataList); - - }); - - }; - - /** - * activates the toggle icons to open listings of nested grid container structure in the list module - */ - OnReady.activateGridExpander = function () { - $(document).on('click', AjaxDataHandler.identifier.gridelementToggle, function (evt) { - evt.preventDefault(); - - var $me = $(this), - container = $me.closest('tr').data('uid'), - isExpanded = $me.data('state') === 'expanded'; - - // Store collapse state in UC - var storedModuleDataList = {}; - - if (Storage.Persistent.isset('moduleData.list.gridelementsExpanded')) { - storedModuleDataList = Storage.Persistent.get('moduleData.list.gridelementsExpanded'); - } - - var expandConfig = {}; - expandConfig[container] = isExpanded ? 0 : 1; - - storedModuleDataList = $.extend(true, storedModuleDataList, expandConfig); - Storage.Persistent.set('moduleData.list.gridelementsExpanded', storedModuleDataList).done(function () { - $me.data('state', isExpanded ? 'collapsed' : 'expanded'); - }); - - $(this).toggleClass('open-gridelements-container'); - var originalTitle = $(this).attr('data-original-title'); - $(this).attr('data-original-title', $(this).attr('data-toggle-title')); - $(this).attr('data-toggle-title', originalTitle); - $(this).blur(); - - $('[data-trigger-container=' + $(this).closest('tr').data('uid') + ']').toggleClass('expanded').find('.open-gridelements-container').click(); - }); - - }; - - $(OnReady.initialize); - return OnReady; + } + } + OnReady.setAllowedParameters($(this), colPos); + } + }); + }; + + /** + * sets the parameters for allowed element types to the add new content links of the original page module + */ + OnReady.setAllowedParameters = function (pageColumn, colPos) { + pageColumn.find('.t3js-page-new-ce:not(".t3js-page-new-ce-allowed") a').each(function () { + if (typeof $(this).attr('href') !== 'undefined') { + $(this).attr('href', $(this).attr('href').replace( + '&uid_pid', + (top.pageColumnsAllowed[colPos] ? ('&tx_gridelements_allowed=' + window.btoa(JSON.stringify(top.pageColumnsAllowed[colPos]))) : '') + + (top.pageColumnsDisallowed[colPos] ? ('&tx_gridelements_disallowed=' + window.btoa(JSON.stringify(top.pageColumnsDisallowed[colPos]))) : '') + + '&uid_pid' + )); + } + }); + }; + + /** + * activates the arrow icons to show/hide content previews within a certain grid column + */ + OnReady.activateAllCollapseIcons = function () { + OnReady.activateCollapseIcons(); + var lastIcon = $('.module-docheader-bar-column-left .btn-group .icon').last().parent(); + var addNewIcon = $('.t3js-toggle-gridelements-column').first(); + var newIcon = addNewIcon.clone().attr('class', 'btn btn-default btn-sm t3js-gridcolumn-toggle t3js-gridcolumn-expand').insertAfter(lastIcon); + newIcon.contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + newIcon.find('.icon-actions-view-list-collapse').remove(); + newIcon.removeAttr('onclick').attr('title', 'Expand all grid columns'); + var newIcon = addNewIcon.clone().attr('class', 'btn btn-default btn-sm t3js-gridcolumn-toggle').insertAfter(lastIcon); + newIcon.contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + newIcon.find('.icon-actions-view-list-expand').remove(); + newIcon.removeAttr('onclick').attr('title', 'Collapse all grid columns'); + $(document).on('click', '.t3js-gridcolumn-toggle', function (evt) { + evt.preventDefault(); + + var $me = $(this), + collapsed = $me.hasClass('t3js-gridcolumn-expand') ? 0 : 1; + + // Store collapse state in UC + var storedModuleDataPage = {}; + + if (Storage.Persistent.isset('moduleData.page.gridelementsCollapsedColumns')) { + storedModuleDataPage = Storage.Persistent.get('moduleData.list.gridelementsExpanded'); + } + + var collapseConfig = {}; + $('[data-columnkey]').each(function () { + collapseConfig[$(this).data('columnkey')] = collapsed; + $(this).removeClass('collapsed', 'expanded'); + $(this).addClass(collapsed ? 'collapsed' : 'expanded'); + }); + + storedModuleDataPage = $.extend(true, storedModuleDataPage, collapseConfig); + Storage.Persistent.set('moduleData.page.gridelementsCollapsedColumns', storedModuleDataPage); + + }); + }; + + /** + * activates the arrow icons to show/hide content previews within a certain grid column + */ + OnReady.activateCollapseIcons = function () { + $(document).on('click', AjaxDataHandler.identifier.gridelementColumnToggle, function (evt) { + evt.preventDefault(); + + var $me = $(this), + columnKey = $me.closest('.t3js-page-column').data('columnkey'), + isExpanded = $me.data('state') === 'expanded'; + + // Store collapse state in UC + var storedModuleDataPage = {}; + + if (Storage.Persistent.isset('moduleData.page.gridelementsCollapsedColumns')) { + storedModuleDataPage = Storage.Persistent.get('moduleData.page.gridelementsCollapsedColumns'); + } + + var expandConfig = {}; + expandConfig[columnKey] = isExpanded ? 1 : 0; + + storedModuleDataPage = $.extend(true, storedModuleDataPage, expandConfig); + Storage.Persistent.set('moduleData.page.gridelementsCollapsedColumns', storedModuleDataPage).done(function () { + $me.data('state', isExpanded ? 'collapsed' : 'expanded'); + }); + + $me.closest('.t3-grid-cell').toggleClass('collapsed', 'expanded'); + var originalTitle = $me.attr('title'); + $me.attr('title', $me.attr('data-toggle-title')); + $me.attr('data-toggle-title', originalTitle); + $me.blur(); + + }); + + $('.t3-page-column-header-icons').each(function () { + $(this).addClass('btn-group btn-group-sm'); + $(this).find('a').addClass('btn btn-default'); + }); + }; + + /** + * generates the paste into / paste after modal + */ + OnReady.copyFromAnotherPage = function (element) { + var url = top.backPath + top.browserUrl + '&mode=db&bparams=' + element.parent().attr('id') + '|||tt_content|'; + OnReady.openedPopupWindow = window.open(url, 'Typo3WinBrowser', 'height=600,width=800,status=0,menubar=0,resizable=1,scrollbars=1'); + OnReady.openedPopupWindow.focus(); + }; + + /** + * gives back the data from the popup window to the copy action + */ + if (!$('.typo3-TCEforms').length) { + OnReady.setSelectOptionFromExternalSource = setFormValueFromBrowseWin = function (elementId, tableUid) { + tableUid = tableUid.replace('tt_content_', '') * 1; + DragDrop.onDrop(tableUid, $('#' + elementId).find('.t3js-paste-new'), 'copyFromAnotherPage'); + } + } + + /** + * activates the toggle icons to open listings of nested grid container structure in the list module + */ + OnReady.activateAllGridExpander = function () { + OnReady.activateGridExpander(); + $(document).on('click', AjaxDataHandler.identifier.allGridelementsToggle, function (evt) { + evt.preventDefault(); + + var $me = $(this), + container = '0,' + $me.data('container-ids'), + isExpanded = this.id === 't3-gridelements-expand-all' ? 1 : 0; + + // Store collapse state in UC + var storedModuleDataList = {}; + + if (Storage.Persistent.isset('moduleData.list.gridelementsExpanded')) { + storedModuleDataList = Storage.Persistent.get('moduleData.list.gridelementsExpanded'); + } + + var expandConfig = {}; + $(container.toString().split(',')).each(function (el, id) { + if (id > 0) { + expandConfig[id] = isExpanded; + if (isExpanded === 1) { + $('[data-uid=' + id + ']').find('.t3js-toggle-gridelements-list').addClass('open-gridelements-container'); + $('[data-trigger-container=' + id + ']').addClass('expanded'); + } else { + $('[data-uid=' + id + ']').find('.t3js-toggle-gridelements-list').removeClass('open-gridelements-container'); + $('[data-trigger-container=' + id + ']').removeClass('expanded'); + } + } + }); + + storedModuleDataList = $.extend(true, storedModuleDataList, expandConfig); + Storage.Persistent.set('moduleData.list.gridelementsExpanded', storedModuleDataList); + + }); + + }; + + /** + * activates the toggle icons to open listings of nested grid container structure in the list module + */ + OnReady.activateGridExpander = function () { + $(document).on('click', AjaxDataHandler.identifier.gridelementToggle, function (evt) { + evt.preventDefault(); + + var $me = $(this), + container = $me.closest('tr').data('uid'), + isExpanded = $me.data('state') === 'expanded'; + + // Store collapse state in UC + var storedModuleDataList = {}; + + if (Storage.Persistent.isset('moduleData.list.gridelementsExpanded')) { + storedModuleDataList = Storage.Persistent.get('moduleData.list.gridelementsExpanded'); + } + + var expandConfig = {}; + expandConfig[container] = isExpanded ? 0 : 1; + + storedModuleDataList = $.extend(true, storedModuleDataList, expandConfig); + Storage.Persistent.set('moduleData.list.gridelementsExpanded', storedModuleDataList).done(function () { + $me.data('state', isExpanded ? 'collapsed' : 'expanded'); + }); + + $(this).toggleClass('open-gridelements-container'); + var originalTitle = $(this).attr('data-original-title'); + $(this).attr('data-original-title', $(this).attr('data-toggle-title')); + $(this).attr('data-toggle-title', originalTitle); + $(this).blur(); + + $('[data-trigger-container=' + $(this).closest('tr').data('uid') + ']').toggleClass('expanded').find('.open-gridelements-container').click(); + }); + + }; + + $(OnReady.initialize); + return OnReady; }); diff --git a/Tests/Backend/ItemsProcFuncs/CTypeListTest.php b/Tests/Backend/ItemsProcFuncs/CTypeListTest.php index f22f08e..ce2691c 100644 --- a/Tests/Backend/ItemsProcFuncs/CTypeListTest.php +++ b/Tests/Backend/ItemsProcFuncs/CTypeListTest.php @@ -63,5 +63,4 @@ public function testItemsProcFunc() public function testCheckForAllowedCTypes() { } - } diff --git a/Tests/Backend/ItemsProcFuncs/ColPosListTest.php b/Tests/Backend/ItemsProcFuncs/ColPosListTest.php index a24117f..13ae364 100644 --- a/Tests/Backend/ItemsProcFuncs/ColPosListTest.php +++ b/Tests/Backend/ItemsProcFuncs/ColPosListTest.php @@ -63,5 +63,4 @@ public function testItemsProcFunc() public function testAddColPosListLayoutItems() { } - } diff --git a/Tests/Backend/ItemsProcFuncs/SysLanguageUidListTest.php b/Tests/Backend/ItemsProcFuncs/SysLanguageUidListTest.php index ca6ab6b..f9b54e3 100644 --- a/Tests/Backend/ItemsProcFuncs/SysLanguageUidListTest.php +++ b/Tests/Backend/ItemsProcFuncs/SysLanguageUidListTest.php @@ -63,5 +63,4 @@ public function testItemsProcFunc() public function testCheckForAllowedLanguages() { } - } diff --git a/Tests/Backend/LayoutSetupTest.php b/Tests/Backend/LayoutSetupTest.php index 8ed0890..3d9e64a 100644 --- a/Tests/Backend/LayoutSetupTest.php +++ b/Tests/Backend/LayoutSetupTest.php @@ -126,5 +126,4 @@ public function testGetFlexformConfiguration() public function testLoadLayoutSetup() { } - } diff --git a/Tests/Backend/TtContentTest.php b/Tests/Backend/TtContentTest.php index e63f01b..2e95e5e 100644 --- a/Tests/Backend/TtContentTest.php +++ b/Tests/Backend/TtContentTest.php @@ -58,5 +58,4 @@ public function testLayoutItemsProcFunc() public function testLookForChildContainersRecursively() { } - } diff --git a/Tests/DataHandler/AfterDatabaseOperationsTest.php b/Tests/DataHandler/AfterDatabaseOperationsTest.php index a00644f..52239a0 100644 --- a/Tests/DataHandler/AfterDatabaseOperationsTest.php +++ b/Tests/DataHandler/AfterDatabaseOperationsTest.php @@ -130,5 +130,4 @@ public function testGetSubpagesRecursively() public function testGetAvailableColumns() { } - } diff --git a/Tests/DataHandler/PreProcessFieldArrayTest.php b/Tests/DataHandler/PreProcessFieldArrayTest.php index afe1c9d..6e9e36e 100644 --- a/Tests/DataHandler/PreProcessFieldArrayTest.php +++ b/Tests/DataHandler/PreProcessFieldArrayTest.php @@ -145,5 +145,4 @@ public function testGetBackendUser() $result = $hook->getBackendUser(); $this->assertEquals($backendUserAuthentication, $result); } - } diff --git a/Tests/DataHandler/ProcessCmdmapTest.php b/Tests/DataHandler/ProcessCmdmapTest.php index 88f466a..79aa90c 100644 --- a/Tests/DataHandler/ProcessCmdmapTest.php +++ b/Tests/DataHandler/ProcessCmdmapTest.php @@ -76,5 +76,4 @@ public function testGetTceMain() public function testExecute_processCmdmap() { } - } diff --git a/Tests/Helper/HelperTest.php b/Tests/Helper/HelperTest.php index 4de9c01..d9b9ebe 100644 --- a/Tests/Helper/HelperTest.php +++ b/Tests/Helper/HelperTest.php @@ -112,5 +112,4 @@ public function testGetSpecificIdsWithWorkspaceButWithoutOriginalId() $result = $helper->getSpecificIds($record); $this->assertEquals($expected, $result); } - } diff --git a/Tests/Hooks/BackendUtilityGridelementsTest.php b/Tests/Hooks/BackendUtilityGridelementsTest.php index 6251370..d58d347 100644 --- a/Tests/Hooks/BackendUtilityGridelementsTest.php +++ b/Tests/Hooks/BackendUtilityGridelementsTest.php @@ -13,5 +13,4 @@ class BackendUtilityGridelementsTest extends UnitTestCase public function testGetFlexFormDS_postProcessDS() { } - -} \ No newline at end of file +} diff --git a/Tests/Hooks/DataHandlerTest.php b/Tests/Hooks/DataHandlerTest.php index fe1af79..924a7fc 100644 --- a/Tests/Hooks/DataHandlerTest.php +++ b/Tests/Hooks/DataHandlerTest.php @@ -31,5 +31,4 @@ public function testProcessDatamap_afterDatabaseOperations() public function testProcessCmdmap() { } - } diff --git a/Tests/Hooks/DatabaseRecordListTest.php b/Tests/Hooks/DatabaseRecordListTest.php index 1c76f76..6840d27 100644 --- a/Tests/Hooks/DatabaseRecordListTest.php +++ b/Tests/Hooks/DatabaseRecordListTest.php @@ -88,5 +88,4 @@ public function testCheckChildren() public function testContentCollapseIcon() { } - -} \ No newline at end of file +} diff --git a/Tests/Hooks/DrawItemTest.php b/Tests/Hooks/DrawItemTest.php index bd6f164..618f354 100644 --- a/Tests/Hooks/DrawItemTest.php +++ b/Tests/Hooks/DrawItemTest.php @@ -197,5 +197,4 @@ public function testRenderSingleElementHTML() public function tesCheckIfTranslationsExistInLanguage() { } - } diff --git a/Tests/Hooks/PageRendererTest.php b/Tests/Hooks/PageRendererTest.php index 759ce4a..0a69f42 100644 --- a/Tests/Hooks/PageRendererTest.php +++ b/Tests/Hooks/PageRendererTest.php @@ -43,5 +43,4 @@ public function testGetLanguageService() public function testAddJsCss() { } - } diff --git a/Tests/Hooks/PreHeaderRenderHookTest.php b/Tests/Hooks/PreHeaderRenderHookTest.php index 49855da..c6362bd 100644 --- a/Tests/Hooks/PreHeaderRenderHookTest.php +++ b/Tests/Hooks/PreHeaderRenderHookTest.php @@ -13,5 +13,4 @@ class PreHeaderRendererHookTest extends UnitTestCase public function testMain() { } - } diff --git a/Tests/Hooks/WizardItemsTest.php b/Tests/Hooks/WizardItemsTest.php index 179f9e8..cca7f93 100644 --- a/Tests/Hooks/WizardItemsTest.php +++ b/Tests/Hooks/WizardItemsTest.php @@ -83,5 +83,4 @@ public function testAddGridItemsToWizard() public function testAddGridValuesToWizardItems() { } - } diff --git a/Tests/Plugin/PluginTest.php b/Tests/Plugin/PluginTest.php index dab2e33..3dc4ba5 100644 --- a/Tests/Plugin/PluginTest.php +++ b/Tests/Plugin/PluginTest.php @@ -164,5 +164,4 @@ public function testGetFlexformValueFromSheetArray() public function testGetFlexformSectionsRecursively() { } - } diff --git a/Tests/Wizard/BackendLayoutWizardControllerTest.php b/Tests/Wizard/BackendLayoutWizardControllerTest.php index 89787d2..3b8f79c 100644 --- a/Tests/Wizard/BackendLayoutWizardControllerTest.php +++ b/Tests/Wizard/BackendLayoutWizardControllerTest.php @@ -1,6 +1,5 @@ 'This extension integrates the grid layout concept also to regular content elements - the grid elements. It offers a lot of new features like advanced drag & drop or real references, that improve the usability of the page and list module to speed up the daily work with the backend.', 'category' => 'be', - 'version' => '8.0.0-dev', + 'version' => '8.3.0', 'priority' => 'bottom', 'module' => '', - 'state' => 'beta', + 'state' => 'stable', 'uploadfolder' => true, 'createDirs' => '', 'modify_tables' => 'tt_content', @@ -26,11 +26,15 @@ 'author_company' => '', 'constraints' => [ 'depends' => [ - 'typo3' => '8.6.0-8.99.99', + 'typo3' => '8.7.0-8.7.99', + 'backend' => '8.7.0-8.7.99', + 'recordlist' => '8.7.0-8.7.99', + 'frontend' => '8.7.0-8.7.99', + 'lang' => '8.7.0-8.7.99', ], 'conflicts' => [ 'templavoila' => '', - 'jfmulticontent' => '', + 'jfmulticontent' => '' ], 'suggests' => [], ], diff --git a/ext_localconf.php b/ext_localconf.php index 072ce6b..df4778d 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,30 +1,25 @@ 'belayoutwizard', - 'priority' => 50, - 'class' => \GridElementsTeam\Gridelements\Wizard\GridelementsBackendLayoutWizardElement::class, - ]; +$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1488914437] = [ + 'nodeName' => 'belayoutwizard', + 'priority' => 50, + 'class' => \GridElementsTeam\Gridelements\Wizard\GridelementsBackendLayoutWizardElement::class, +]; - // XCLASS - if ($_EXTCONF['nestingInListModule']) { - $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class] = ['className' => \GridElementsTeam\Gridelements\Xclass\DatabaseRecordList::class]; - } +// XCLASS +if ($_EXTCONF['nestingInListModule']) { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class] = ['className' => \GridElementsTeam\Gridelements\Xclass\DatabaseRecordList::class]; } \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(' options.saveDocNew.tx_gridelements_backend_layout=1 '); -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugin/Gridelements.php', '_pi1', - 'CType', 1); - $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); $signalSlotDispatcher->connect(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::class, 'tcaIsBeingBuilt', \GridElementsTeam\Gridelements\Slots\ExtTablesInclusionPostProcessing::class, 'processData'); diff --git a/ext_tables.php b/ext_tables.php index 9f34a16..639ddba 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,55 +1,61 @@ addJSCSS'; - $GLOBALS['TYPO3_CONF_VARS']['BE']['ContextMenu']['ItemProviders'][1487270751] = \GridElementsTeam\Gridelements\ContextMenu\ItemProvider::class; - - // Hooks - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][] = \GridElementsTeam\Gridelements\Hooks\DrawItem::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook'][] = \GridElementsTeam\Gridelements\Hooks\WizardItems::class; + $GLOBALS['TBE_STYLES']['skins']['gridelements']['name'] = 'gridelements'; + $GLOBALS['TBE_STYLES']['skins']['gridelements']['stylesheetDirectories']['gridelements_structure'] = 'EXT:' . ($_EXTKEY) . '/Resources/Public/Backend/Css/Skin/'; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = \GridElementsTeam\Gridelements\Hooks\DataHandler::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \GridElementsTeam\Gridelements\Hooks\DataHandler::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'][] = \GridElementsTeam\Gridelements\Hooks\DataHandler::class; + if ($_EXTCONF['additionalStylesheet'] && \TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr($_EXTCONF['additionalStylesheet'])) { + $GLOBALS['TBE_STYLES']['skins']['gridelements']['stylesheetDirectories']['gridelements_additional'] = $_EXTCONF['additionalStylesheet']; + } +} - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'][] = \GridElementsTeam\Gridelements\Hooks\BackendUtilityGridelements::class; +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_gridelements_backend_layout'); - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'][] = \GridElementsTeam\Gridelements\Hooks\PreHeaderRenderHook::class . '->main'; +// Hooks +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = \GridElementsTeam\Gridelements\Hooks\DataHandler::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \GridElementsTeam\Gridelements\Hooks\DataHandler::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'][] = \GridElementsTeam\Gridelements\Hooks\DataHandler::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook'][] = \GridElementsTeam\Gridelements\Hooks\WizardItems::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][] = \GridElementsTeam\Gridelements\Hooks\DrawItem::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['getFlexFormDSClass'][] = \GridElementsTeam\Gridelements\Hooks\BackendUtilityGridelements::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_api']['apiIsRunningTCEmain'] = true; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class]['flexParsing']['gridelements'] = \GridElementsTeam\Gridelements\Hooks\TtContentFlexForm::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_api']['apiIsRunningTCEmain'] = true; +if ($_EXTCONF['nestingInListModule']) { + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'][] = \GridElementsTeam\Gridelements\Hooks\DatabaseRecordList::class; +} - $GLOBALS['TYPO3_USER_SETTINGS']['columns']['dragAndDropHideNewElementWizardInfoOverlay'] = [ - 'type' => 'check', - 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:dragAndDropHideNewElementWizardInfoOverlay', - ]; +$GLOBALS['TYPO3_USER_SETTINGS']['columns']['dragAndDropHideNewElementWizardInfoOverlay'] = [ + 'type' => 'check', + 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:dragAndDropHideNewElementWizardInfoOverlay', +]; - $GLOBALS['TYPO3_USER_SETTINGS']['columns']['hideColumnHeaders'] = [ - 'type' => 'check', - 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:hideColumnHeaders', - ]; +$GLOBALS['TYPO3_USER_SETTINGS']['columns']['hideColumnHeaders'] = [ + 'type' => 'check', + 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:hideColumnHeaders', +]; - $GLOBALS['TYPO3_USER_SETTINGS']['columns']['hideContentPreview'] = [ - 'type' => 'check', - 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:hideContentPreview', - ]; +$GLOBALS['TYPO3_USER_SETTINGS']['columns']['hideContentPreview'] = [ + 'type' => 'check', + 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:hideContentPreview', +]; - $GLOBALS['TYPO3_USER_SETTINGS']['columns']['showGridInformation'] = [ - 'type' => 'check', - 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:showGridInformation', - ]; +$GLOBALS['TYPO3_USER_SETTINGS']['columns']['showGridInformation'] = [ + 'type' => 'check', + 'label' => 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:showGridInformation', +]; - $GLOBALS['TYPO3_USER_SETTINGS']['showitem'] .= ', +$GLOBALS['TYPO3_USER_SETTINGS']['showitem'] .= ', --div--;LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:gridElements, dragAndDropHideNewElementWizardInfoOverlay, hideColumnHeaders, @@ -57,16 +63,7 @@ showGridInformation '; - $TBE_STYLES['skins']['gridelements']['name'] = 'gridelements'; - $TBE_STYLES['skins']['gridelements']['stylesheetDirectories']['structure'] = 'EXT:' . ($_EXTKEY) . '/Resources/Public/Backend/Css/Skin/'; -} - -// Hooks -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class]['flexParsing']['gridelements'] = \GridElementsTeam\Gridelements\Hooks\TtContentFlexForm::class; - -if ($_EXTCONF['nestingInListModule']) { - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'][] = \GridElementsTeam\Gridelements\Hooks\DatabaseRecordList::class; -} +$GLOBALS['TYPO3_CONF_VARS']['BE']['ContextMenu']['ItemProviders'][1487270751] = \GridElementsTeam\Gridelements\ContextMenu\ItemProvider::class; $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); $iconRegistry->registerIcon('gridelements-default', \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, [
  • '; - $grid .= ($this->helper->getBackendUser()->uc['hideColumnHeaders'] ? '' : $head[$columnKey]); + $grid .= ($this->helper->getBackendUser()->uc['hideColumnHeaders'] ? '' : $columnHead); if ($maxItems > 0) { $maxItemsClass = ($disableNewContent ? ' warning' : ' success'); $maxItemsClass = ($tooManyItems ? ' danger' : $maxItemsClass); @@ -1091,10 +1271,21 @@ protected function renderCTypeShortcut(PageLayoutView $parentObject, &$row) foreach ($shortcutItems as $shortcutItem) { $shortcutItem = trim($shortcutItem); if (strpos($shortcutItem, 'pages_') !== false) { - $this->collectContentDataFromPages($shortcutItem, $collectedItems, $row['recursive'], $row['uid']); + $this->collectContentDataFromPages( + $shortcutItem, + $collectedItems, + $row['recursive'], + $row['uid'], + $row['sys_language_uid'] + ); } else { if (strpos($shortcutItem, '_') === false || strpos($shortcutItem, 'tt_content_') !== false) { - $this->collectContentData($shortcutItem, $collectedItems, $row['uid']); + $this->collectContentData( + $shortcutItem, + $collectedItems, + $row['uid'], + $row['sys_language_uid'] + ); } } } @@ -1122,6 +1313,7 @@ protected function renderCTypeShortcut(PageLayoutView $parentObject, &$row) * @param array $collectedItems : The collected item data rows ordered by parent position, column position and sorting * @param int $recursive : The number of levels for the recursion * @param int $parentUid : uid of the referencing tt_content record + * @param int $language : sys_language_uid of the referencing tt_content record * * @return void */ @@ -1129,7 +1321,8 @@ protected function collectContentDataFromPages( $shortcutItem, &$collectedItems, $recursive = 0, - $parentUid + $parentUid, + $language = 0 ) { $itemList = str_replace('pages_', '', $shortcutItem); if ($recursive) { @@ -1141,17 +1334,28 @@ protected function collectContentDataFromPages( $itemList = GeneralUtility::intExplode(',', $itemList); $queryBuilder = $this->getQueryBuilder(); + $items = $queryBuilder ->select('*') - ->addSelectLiteral($queryBuilder->expr()->inSet('pid', - $queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY) . ' AS inSet')) + ->addSelectLiteral($queryBuilder->expr()->inSet( + 'pid', + $queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY) + ) . ' AS inSet') ->from('tt_content') ->where( - $queryBuilder->expr()->neq('uid', - $queryBuilder->createNamedParameter((int)$parentUid, \PDO::PARAM_INT)), - $queryBuilder->expr()->in('pid', - $queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY)), - $queryBuilder->expr()->gte('colPos', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)) + $queryBuilder->expr()->neq( + 'uid', + $queryBuilder->createNamedParameter((int)$parentUid, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'pid', + $queryBuilder->createNamedParameter($itemList, Connection::PARAM_INT_ARRAY) + ), + $queryBuilder->expr()->gte('colPos', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), + $queryBuilder->expr()->in( + 'sys_language_uid', + $queryBuilder->createNamedParameter([0, -1], Connection::PARAM_INT_ARRAY) + ) ) ->orderBy('inSet') ->addOrderBy('colPos') @@ -1160,6 +1364,12 @@ protected function collectContentDataFromPages( ->fetchAll(); foreach ($items as $item) { + if (!empty($this->extentensionConfiguration['overlayShortcutTranslation']) && $language > 0) { + $translatedItem = BackendUtility::getRecordLocalization('tt_content', $item['uid'], $language); + if (!empty($translatedItem)) { + $item = array_shift($translatedItem); + } + } if ($this->helper->getBackendUser()->workspace > 0) { BackendUtility::workspaceOL('tt_content', $item, $this->helper->getBackendUser()->workspace); } @@ -1174,10 +1384,11 @@ protected function collectContentDataFromPages( * @param string $shortcutItem : The tt_content element to fetch the data from * @param array $collectedItems : The collected item data row * @param int $parentUid : uid of the referencing tt_content record + * @param int $language : sys_language_uid of the referencing tt_content record * * @return void */ - protected function collectContentData($shortcutItem, &$collectedItems, $parentUid) + protected function collectContentData($shortcutItem, &$collectedItems, $parentUid, $language) { $shortcutItem = str_replace('tt_content_', '', $shortcutItem); if ((int)$shortcutItem !== (int)$parentUid) { @@ -1189,13 +1400,22 @@ protected function collectContentData($shortcutItem, &$collectedItems, $parentUi ->select('*') ->from('tt_content') ->where( - $queryBuilder->expr()->eq('uid', - $queryBuilder->createNamedParameter((int)$shortcutItem, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq( + 'uid', + $queryBuilder->createNamedParameter((int)$shortcutItem, \PDO::PARAM_INT) + ) ) ->setMaxResults(1) ->execute() ->fetch(); + if (!empty($this->extentensionConfiguration['overlayShortcutTranslation']) && $language > 0) { + $translatedItem = BackendUtility::getRecordLocalization('tt_content', $item['uid'], $language); + if (!empty($translatedItem)) { + $item = array_shift($translatedItem); + } + } + if ($this->helper->getBackendUser()->workspace > 0) { BackendUtility::workspaceOL( 'tt_content', @@ -1216,5 +1436,4 @@ public function getIconFactory() { return $this->iconFactory; } - } diff --git a/Classes/Hooks/PageRenderer.php b/Classes/Hooks/PageRenderer.php index 13dc5a1..a172811 100644 --- a/Classes/Hooks/PageRenderer.php +++ b/Classes/Hooks/PageRenderer.php @@ -28,7 +28,6 @@ use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\SingletonInterface; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Recordlist\RecordList; @@ -36,8 +35,6 @@ * Class/Function which adds the necessary ExtJS and pure JS stuff for the grid elements. * * @author Jo Hasenau , Tobias Ferger - * @package TYPO3 - * @subpackage tx_gridelements */ class PageRenderer implements SingletonInterface { @@ -49,13 +46,17 @@ class PageRenderer implements SingletonInterface */ public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer) { - $pageRenderer->addCssFile(ExtensionManagementUtility::siteRelPath('gridelements') . 'Resources/Public/Backend/Css/Skin/t3skin_override.css'); - if (get_class($GLOBALS['SOBE']) === RecordList::class || is_subclass_of($GLOBALS['SOBE'], RecordList::class)) { + if (!empty($GLOBALS['SOBE']) && (get_class($GLOBALS['SOBE']) === RecordList::class || is_subclass_of( + $GLOBALS['SOBE'], + RecordList::class + ))) { $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady'); return; } - if (get_class($GLOBALS['SOBE']) === PageLayoutController::class || is_subclass_of($GLOBALS['SOBE'], - PageLayoutController::class)) { + if (!empty($GLOBALS['SOBE']) && (get_class($GLOBALS['SOBE']) === PageLayoutController::class || is_subclass_of( + $GLOBALS['SOBE'], + PageLayoutController::class + ))) { $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsDragDrop'); @@ -65,14 +66,16 @@ public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $p $clipObj = GeneralUtility::makeInstance(Clipboard::class); // Start clipboard $clipObj->initializeClipboard(); $clipObj->lockToNormal(); - + $clipBoard = $clipObj->clipData['normal']; if (!$pageRenderer->getCharSet()) { $pageRenderer->setCharSet($GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : 'utf-8'); } // pull locallang_db.xml to JS side - only the tx_gridelements_js-prefixed keys - $pageRenderer->addInlineLanguageLabelFile('EXT:gridelements/Resources/Private/Language/locallang_db.xml', - 'tx_gridelements_js'); + $pageRenderer->addInlineLanguageLabelFile( + 'EXT:gridelements/Resources/Private/Language/locallang_db.xml', + 'tx_gridelements_js' + ); $pAddExtOnReadyCode = ' TYPO3.l10n = { @@ -83,8 +86,11 @@ public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $p '; $id = (int)GeneralUtility::_GP('id'); - $layout = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getSelectedBackendLayout', - $id, $this); + $layout = GeneralUtility::callUserFunction( + BackendLayoutView::class . '->getSelectedBackendLayout', + $id, + $this + ); if (is_array($layout) && !empty($layout['__config']['backend_layout.']['rows.'])) { /** @var LayoutSetup $layoutSetup */ $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init(0); @@ -100,19 +106,41 @@ public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $p } // add Ext.onReady() code from file - $pAddExtOnReadyCode .= " - top.pageColumnsAllowed = " . json_encode($layout['allowed']) . "; - top.pageColumnsDisallowed = " . json_encode($layout['disallowed']) . "; - top.pageColumnsMaxitems = " . json_encode($layout['maxitems']) . "; - top.pasteReferenceAllowed = " . ($this->getBackendUser()->checkAuthMode('tt_content', 'CType', 'shortcut', - $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode']) ? 'true' : 'false') . "; - top.skipDraggableDetails = " . ($this->getBackendUser()->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'true' : 'false') . "; + $pAddExtOnReadyCode .= ' + top.pageColumnsAllowed = ' . json_encode($layout['allowed']) . '; + top.pageColumnsDisallowed = ' . json_encode($layout['disallowed']) . '; + top.pageColumnsMaxitems = ' . json_encode($layout['maxitems']) . '; + top.pasteReferenceAllowed = ' . ($this->getBackendUser()->checkAuthMode( + 'tt_content', + 'CType', + 'shortcut', + $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] + ) ? 'true' : 'false') . '; + top.skipDraggableDetails = ' . ($this->getBackendUser()->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'true' : 'false') . "; top.backPath = '" . $GLOBALS['BACK_PATH'] . "'; - top.browserUrl = '" . BackendUtility::getModuleUrl('wizard_element_browser') . "'"; + top.browserUrl = '" . BackendUtility::getModuleUrl('wizard_element_browser') . "';"; + + if (!empty($clipBoard) && !empty($clipBoard['el'])) { + $clipBoardElement = GeneralUtility::trimExplode('|', key($clipBoard['el'])); + if ($clipBoardElement[0] === 'tt_content') { + $clipBoardElementData = BackendUtility::getRecord('tt_content', (int)$clipBoardElement[1]); + $pAddExtOnReadyCode .= " + top.clipBoardElementCType = '" . $clipBoardElementData['CType'] . "'; + top.clipBoardElementTxGridelementsBackendLayout = '" . (($clipBoardElementData['CType'] == 'gridelements_pi1') ? $clipBoardElementData['tx_gridelements_backend_layout'] : '') . "'; + top.clipBoardElementListType = '" . $clipBoardElementData['list_type'] . "';"; + } else { + $pAddExtOnReadyCode .= " + top.clipBoardElementCType = ''; + top.clipBoardElementTxGridelementsBackendLayout = ''; + top.clipBoardElementListType = '';"; + } + } - $pAddExtOnReadyCode .= " - top.copyFromAnotherPageLinkTemplate = " . json_encode('' . $iconFactory->getIcon('actions-insert-reference', - Icon::SIZE_SMALL)->render() . '') . ";"; + $pAddExtOnReadyCode .= ' + top.copyFromAnotherPageLinkTemplate = ' . json_encode('' . $iconFactory->getIcon( + 'actions-insert-reference', + Icon::SIZE_SMALL + )->render() . '') . ';'; $pageRenderer->addJsInlineCode('gridelementsExtOnReady', $pAddExtOnReadyCode); } diff --git a/Classes/Hooks/PreHeaderRenderHook.php b/Classes/Hooks/PreHeaderRenderHook.php deleted file mode 100644 index f05ff02..0000000 --- a/Classes/Hooks/PreHeaderRenderHook.php +++ /dev/null @@ -1,42 +0,0 @@ - - * All rights reserved - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use TYPO3\CMS\Core\SingletonInterface; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; - -/** - * Class PreHeaderRenderHook - * - * @package GridElementsTeam\Gridelements\Hooks - */ -class PreHeaderRenderHook implements SingletonInterface -{ - /** - * @param array $arg - */ - function main(array $arg) - { - /** @var \TYPO3\CMS\Core\Page\PageRenderer $pagerenderer */ - $pagerenderer = $arg['pageRenderer']; - $pagerenderer->addCssFile(ExtensionManagementUtility::siteRelPath('gridelements') . 'Resources/Public/Backend/Css/Skin/t3skin_override.css'); - } -} diff --git a/Classes/Hooks/TtContentFlexForm.php b/Classes/Hooks/TtContentFlexForm.php index a654611..b724e67 100644 --- a/Classes/Hooks/TtContentFlexForm.php +++ b/Classes/Hooks/TtContentFlexForm.php @@ -21,7 +21,6 @@ ***************************************************************/ use GridElementsTeam\Gridelements\Backend\LayoutSetup; -use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -30,8 +29,6 @@ * @author Jo Hasenau * @author Dirk Hoffmann * @author Stephan Schuler - * @package TYPO3 - * @subpackage tx_gridelements */ class TtContentFlexForm { @@ -50,10 +47,8 @@ public function getDataStructureIdentifierPreProcess(array $tca, $tableName, $fi if ($tableName === 'tt_content' && $fieldName === 'pi_flexform' && $row['CType'] === 'gridelements_pi1') { if (!empty($row['tx_gridelements_backend_layout'])) { $pageUid = $row['pid']; - if ($pageUid < 0) { - $pageUid = Helper::getInstance()->getPidFromNegativeUid($pageUid); - } $layoutId = $row['tx_gridelements_backend_layout']; + /** @var $layoutSetupInstance LayoutSetup */ $layoutSetupInstance = GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid); $layoutSetup = $layoutSetupInstance->getLayoutSetup($layoutId); if ($layoutSetup['pi_flexform_ds_file']) { @@ -102,10 +97,10 @@ public function parseDataStructureByIdentifierPreProcess(array $identifier) { if ($identifier['type'] === 'gridelements-dummy') { return 'FILE:EXT:gridelements/Configuration/FlexForms/default_flexform_configuration.xml'; - } elseif (!empty($identifier['flexformDS'])) { + } + if (!empty($identifier['flexformDS'])) { return $identifier['flexformDS']; - } else { - return ''; } + return ''; } } diff --git a/Classes/Hooks/WizardItems.php b/Classes/Hooks/WizardItems.php index f6c6b1b..9b8ac43 100644 --- a/Classes/Hooks/WizardItems.php +++ b/Classes/Hooks/WizardItems.php @@ -21,10 +21,10 @@ ***************************************************************/ use GridElementsTeam\Gridelements\Backend\LayoutSetup; -use GridElementsTeam\Gridelements\Helper\Helper; use TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Wizard\NewContentElementWizardHookInterface; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider; use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider; use TYPO3\CMS\Core\Imaging\IconRegistry; @@ -36,8 +36,6 @@ * Class/Function which manipulates the rendering of items within the new content element wizard * * @author Jo Hasenau , Tobias Ferger - * @package TYPO3 - * @subpackage tx_gridelements */ class WizardItems implements NewContentElementWizardHookInterface { @@ -65,8 +63,12 @@ public function injectLayoutSetup(LayoutSetup $layoutSetup) */ public function manipulateWizardItems(&$wizardItems, &$parentObject) { - if (GeneralUtility::inList($GLOBALS['BE_USER']->groupData['explicit_allowdeny'], - 'tt_content:CType:gridelements_pi1:DENY')) { + if (!$this->getBackendUser()->checkAuthMode( + 'tt_content', + 'CType', + 'gridelements_pi1', + $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] + )) { return; } $pageID = $parentObject->id; @@ -96,6 +98,7 @@ public function manipulateWizardItems(&$wizardItems, &$parentObject) $this->removeDisallowedWizardItems($allowed, $disallowed, $wizardItems); } else { $allowed = null; + $disallowed = null; } if (( empty($allowed['CType']) || @@ -130,9 +133,6 @@ public function manipulateWizardItems(&$wizardItems, &$parentObject) public function init($pageUid) { if (!$this->layoutSetup instanceof LayoutSetup) { - if ($pageUid < 0) { - $pageUid = Helper::getInstance()->getPidFromNegativeUid($pageUid); - } $this->layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid); } } @@ -254,8 +254,10 @@ public function addGridItemsToWizard(array &$gridItems, array &$wizardItems) if (StringUtility::beginsWith($largeIcon, '../uploads/tx_gridelements/')) { $largeIcon = str_replace('../', '', $largeIcon); } else { - if (!StringUtility::beginsWith($largeIcon, 'EXT:') && strpos($largeIcon, - '/') === false + if (!StringUtility::beginsWith($largeIcon, 'EXT:') && strpos( + $largeIcon, + '/' + ) === false ) { $largeIcon = GeneralUtility::resolveBackPath($item['icon'][1]); } @@ -266,10 +268,13 @@ public function addGridItemsToWizard(array &$gridItems, array &$wizardItems) 'source' => $largeIcon, ]); } else { - $iconRegistry->registerIcon($item['iconIdentifierLarge'], BitmapIconProvider::class, + $iconRegistry->registerIcon( + $item['iconIdentifierLarge'], + BitmapIconProvider::class, [ 'source' => $largeIcon, - ]); + ] + ); } } } else { @@ -384,4 +389,13 @@ public function removeEmptyHeadersFromWizard(array &$wizardItems) } } + /** + * Gets the current backend user. + * + * @return BackendUserAuthentication + */ + public function getBackendUser() + { + return $GLOBALS['BE_USER']; + } } diff --git a/Classes/Plugin/Gridelements.php b/Classes/Plugin/Gridelements.php index 3f61efb..51e60f7 100644 --- a/Classes/Plugin/Gridelements.php +++ b/Classes/Plugin/Gridelements.php @@ -35,8 +35,6 @@ * Plugin 'Grid Element' for the 'gridelements' extension. * * @author Jo Hasenau - * @package TYPO3 - * @subpackage tx_gridelements */ class Gridelements extends ContentObjectRenderer { @@ -100,7 +98,7 @@ public function main($content = '', $conf = []) $layoutSetup->init($this->cObj->data['pid'], $conf); $availableColumns = $layoutSetup->getLayoutColumns($layout); - $csvColumns = str_replace('-2,-1,', '', $availableColumns['CSV']); + $csvColumns = ltrim(str_replace('-2,-1', '', $availableColumns['CSV']), ','); $this->getChildren($element, $pid, $csvColumns); // and we have to determine the frontend setup related to the backend layout record which is assigned to this container @@ -124,8 +122,10 @@ public function main($content = '', $conf = []) unset($csvColumns); if (isset($typoScriptSetup['jsFooterInline']) || isset($typoScriptSetup['jsFooterInline.'])) { - $jsFooterInline = isset($typoScriptSetup['jsFooterInline.']) ? $this->cObj->stdWrap($typoScriptSetup['jsFooterInline'], - $typoScriptSetup['jsFooterInline.']) : $typoScriptSetup['jsFooterInline']; + $jsFooterInline = isset($typoScriptSetup['jsFooterInline.']) ? $this->cObj->stdWrap( + $typoScriptSetup['jsFooterInline'], + $typoScriptSetup['jsFooterInline.'] + ) : $typoScriptSetup['jsFooterInline']; $this->getPageRenderer()->addJsFooterInlineCode('gridelements' . $element, $jsFooterInline); unset($typoScriptSetup['jsFooterInline']); @@ -143,11 +143,19 @@ public function main($content = '', $conf = []) * Converts $this->cObj->data['pi_flexform'] from XML string to flexForm array. * * @param string $field Field name to convert + * @param array $child */ - public function initPluginFlexForm($field = 'pi_flexform') + public function initPluginFlexForm($field = 'pi_flexform', &$child = null) { // Converting flexform data into array: - if (!is_array($this->cObj->data[$field]) && $this->cObj->data[$field]) { + if (!empty($child)) { + if (!is_array($child[$field]) && $child[$field]) { + $child[$field] = GeneralUtility::xml2array($child[$field]); + if (!is_array($child[$field])) { + $child[$field] = []; + } + } + } elseif (!is_array($this->cObj->data[$field]) && $this->cObj->data[$field]) { $this->cObj->data[$field] = GeneralUtility::xml2array($this->cObj->data[$field]); if (!is_array($this->cObj->data[$field])) { $this->cObj->data[$field] = []; @@ -157,10 +165,17 @@ public function initPluginFlexForm($field = 'pi_flexform') /** * fetches values from the grid flexform and assigns them to virtual fields in the data array + * @param array $child */ - public function getPluginFlexFormData() + public function getPluginFlexFormData(&$child = []) { - $pluginFlexForm = $this->cObj->data['pi_flexform']; + if (!empty($child)) { + $cObjData = $child; + } else { + $cObjData = $this->cObj->data; + } + + $pluginFlexForm = $cObjData['pi_flexform']; if (is_array($pluginFlexForm) && is_array($pluginFlexForm['data'])) { foreach ($pluginFlexForm['data'] as $sheet => $data) { @@ -168,8 +183,11 @@ public function getPluginFlexFormData() foreach ((array)$data as $language => $value) { if (is_array($value)) { foreach ((array)$value as $key => $val) { - $this->cObj->data['flexform_' . $key] = $this->getFlexFormValue($pluginFlexForm, $key, - $sheet); + $cObjData['flexform_' . $key] = $this->getFlexFormValue( + $pluginFlexForm, + $key, + $sheet + ); } } } @@ -178,6 +196,14 @@ public function getPluginFlexFormData() } unset($pluginFlexForm); + + if (!empty($child)) { + $child = $cObjData; + } else { + $this->cObj->data = $cObjData; + } + + unset($cObjData); } /** @@ -213,7 +239,6 @@ public function getFlexFormValue( * @param string $value Value for outermost key, typ. "vDEF" depending on language. * * @return mixed The value, typ. string. - * @access private * @see pi_getFlexFormValue() */ public function getFlexFormValueFromSheetArray($sheetArray, $fieldNameArr, $value) @@ -293,44 +318,94 @@ public function getChildren($element = 0, $pid = 0, $csvColumns = '') } $csvColumns = GeneralUtility::intExplode(',', $csvColumns); $queryBuilder = $this->getQueryBuilder(); + $where = $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq( + 'tx_gridelements_container', + $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'tx_gridelements_columns', + $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) + ), + $queryBuilder->expr()->in( + 'sys_language_uid', + $queryBuilder->createNamedParameter([-1, 0], Connection::PARAM_INT_ARRAY) + ) + ); + $translationOverlay = []; + $translationNoOverlay = []; + + if ($this->getTSFE()->sys_language_content > 0) { + if ($this->getTSFE()->sys_language_contentOL) { + if (isset($this->cObj->data['_LOCALIZED_UID']) && $this->cObj->data['_LOCALIZED_UID'] !== 0) { + $element = (int)$this->cObj->data['_LOCALIZED_UID']; + } + if ($element) { + $translationOverlay = $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq('tx_gridelements_container', $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT)), + $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'tx_gridelements_columns', + $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) + ), + $queryBuilder->expr()->in( + 'sys_language_uid', + $queryBuilder->createNamedParameter( + [-1, $this->getTSFE()->sys_language_content], + Connection::PARAM_INT_ARRAY + ) + ), + $queryBuilder->expr()->eq( + 'l18n_parent', + $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) + ) + ); + } + } else { + if ($element) { + $translationNoOverlay = $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq( + 'tx_gridelements_container', + $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq( + 'pid', + $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) + ), + $queryBuilder->expr()->in( + 'tx_gridelements_columns', + $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) + ), + $queryBuilder->expr()->in( + 'sys_language_uid', + $queryBuilder->createNamedParameter( + [-1, $this->getTSFE()->sys_language_content], + Connection::PARAM_INT_ARRAY + ) + ) + ); + } + } + } + $children = $queryBuilder ->select('*') ->from('tt_content') ->where( $queryBuilder->expr()->orX( - $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('tx_gridelements_container', - $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT)), - $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('pid', - $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT)), - $queryBuilder->expr()->in('tx_gridelements_columns', - $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY)), - $queryBuilder->expr()->in('sys_language_uid', - $queryBuilder->createNamedParameter([-1, 0], Connection::PARAM_INT_ARRAY)) - ), - $this->getTSFE()->sys_language_content > 0 && - $this->getTSFE()->sys_language_contentOL && - isset($this->cObj->data['_LOCALIZED_UID']) && - (int)$this->cObj->data['_LOCALIZED_UID'] !== 0 ? - $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('tx_gridelements_container', - $queryBuilder->createNamedParameter((int)$this->cObj->data['_LOCALIZED_UID'], - \PDO::PARAM_INT)), - $queryBuilder->expr()->in('sys_language_uid', - $queryBuilder->createNamedParameter([-1, $this->getTSFE()->sys_language_content], - Connection::PARAM_INT_ARRAY)), - $queryBuilder->expr()->eq('l18n_parent', - $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)) - ) : [], - $this->getTSFE()->sys_language_content > 0 ? - $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('tx_gridelements_container', - $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT)), - $queryBuilder->expr()->in('sys_language_uid', - $queryBuilder->createNamedParameter([-1, $this->getTSFE()->sys_language_content], - Connection::PARAM_INT_ARRAY)) - ) : [] + $where, + $translationOverlay, + $translationNoOverlay ) ) ->orderBy('sorting', 'ASC') @@ -346,10 +421,18 @@ public function getChildren($element = 0, $pid = 0, $csvColumns = '') if (is_array($child)) { $child['sorting'] = $sorting; if ($this->getTSFE()->sys_language_contentOL) { - $child = $this->getTSFE()->sys_page->getRecordOverlay('tt_content', $child, - $this->getTSFE()->sys_language_content, $this->getTSFE()->sys_language_contentOL); + $child = $this->getTSFE()->sys_page->getRecordOverlay( + 'tt_content', + $child, + $this->getTSFE()->sys_language_content, + $this->getTSFE()->sys_language_contentOL + ); } if (!empty($child)) { + if ($child['CType'] === 'gridelements_pi1') { + $this->initPluginFlexForm('pi_flexform', $child); + $this->getPluginFlexFormData($child); + } $this->cObj->data['tx_gridelements_view_children'][] = $child; unset($child); } @@ -359,18 +442,16 @@ public function getChildren($element = 0, $pid = 0, $csvColumns = '') $compareFunction = function ($child_a, $child_b) { if ($child_a['sorting'] > $child_b['sorting']) { return 1; - } elseif ($child_a['sorting'] === $child_b['sorting']) { + } + if ($child_a['sorting'] === $child_b['sorting']) { return 0; - } else { - return -1; } + return -1; }; usort($this->cObj->data['tx_gridelements_view_children'], $compareFunction); - } - /** * getter for queryBuilder * @@ -378,6 +459,7 @@ public function getChildren($element = 0, $pid = 0, $csvColumns = '') */ public function getQueryBuilder() { + /** @var $queryBuilder QueryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tt_content'); $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); @@ -412,8 +494,13 @@ public function renderChildrenIntoParentColumns($typoScriptSetup = [], $sortColu foreach ($this->cObj->data['tx_gridelements_view_children'] as $child) { $rawColumns[$child['tx_gridelements_columns']][] = $child; $renderedChild = $child; - $this->renderChildIntoParentColumn($columns, $renderedChild, $parentGridData, $parentRecordNumbers, - $typoScriptSetup); + $this->renderChildIntoParentColumn( + $columns, + $renderedChild, + $parentGridData, + $parentRecordNumbers, + $typoScriptSetup + ); $currentParentGrid['data']['tx_gridelements_view_child_' . $child['uid']] = $renderedChild; unset($renderedChild); } @@ -569,7 +656,7 @@ public function renderChildIntoParentColumn( * * @param array $setup The adjusted setup of the grid container * - * @return array $content The raw HTML output of the grid container before stdWrap functions will be applied to it + * @return string $content The raw HTML output of the grid container before stdWrap functions will be applied to it */ public function renderColumnsIntoParentGrid($setup = []) { @@ -612,10 +699,11 @@ public function getPageRenderer() public function user_getTreeList() { $pidList = $this->getTSFE()->register['tt_content_shortcut_recursive'] - ? $this->cObj->getTreeList($this->cObj->data['uid'], - $this->getTSFE()->register['tt_content_shortcut_recursive']) + ? $this->cObj->getTreeList( + $this->cObj->data['uid'], + $this->getTSFE()->register['tt_content_shortcut_recursive'] + ) : ''; $this->getTSFE()->register['pidInList'] = trim($this->cObj->data['uid'] . ',' . $pidList, ','); } - } diff --git a/Classes/Slots/ExtTablesInclusionPostProcessing.php b/Classes/Slots/ExtTablesInclusionPostProcessing.php index 09e0af4..8619dfe 100644 --- a/Classes/Slots/ExtTablesInclusionPostProcessing.php +++ b/Classes/Slots/ExtTablesInclusionPostProcessing.php @@ -24,8 +24,6 @@ /** * Class ExtTablesInclusionPostProcessing - * - * @package GridElementsTeam\Gridelements\Hooks */ class ExtTablesInclusionPostProcessing { @@ -35,7 +33,7 @@ class ExtTablesInclusionPostProcessing * * @param array $tca * - * @return void + * @return array */ public function processData($tca) { @@ -43,8 +41,10 @@ public function processData($tca) $GLOBALS['TCA'] = $tca; ExtensionManagementUtility::addToAllTCAtypes('tt_content', 'recursive', 'shortcut', 'after:records'); - ExtensionManagementUtility::addToAllTCAtypes('tt_content', - '--div--;LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:gridElements,tx_gridelements_container,tx_gridelements_columns'); + ExtensionManagementUtility::addToAllTCAtypes( + 'tt_content', + '--div--;LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:gridElements,tx_gridelements_container,tx_gridelements_columns' + ); // return the modified global TCA definition return [$GLOBALS['TCA']]; diff --git a/Classes/Wizard/GridelementsBackendLayoutWizardElement.php b/Classes/Wizard/GridelementsBackendLayoutWizardElement.php index b2ae561..2266747 100644 --- a/Classes/Wizard/GridelementsBackendLayoutWizardElement.php +++ b/Classes/Wizard/GridelementsBackendLayoutWizardElement.php @@ -129,10 +129,10 @@ public function render() $html[] = ''; $html[] = ''; - $contentTypes = array(); + $contentTypes = []; if (is_array($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'])) { foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $item) { - $contentType = array(); + $contentType = []; if (!empty($item[1])) { $contentType['key'] = $item[1]; if (substr($contentType['key'], 0, 2) !== '--') { @@ -153,7 +153,7 @@ public function render() } } } - $listTypes = array(); + $listTypes = []; if (is_array($GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'])) { foreach ($GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] as $item) { $listType = []; @@ -169,8 +169,10 @@ public function render() $listType['icon'] = '../../../' . '../typo3/sysext/core/Resources/Public/Icons/T3Icons/content/' . $item[2]; } // Check if file ending exists, therefore compare pos of last slash to pos of last dot - if (!empty($listType['icon']) && strrpos($listType['icon'], '/') > strrpos($listType['icon'], - '.')) { + if (!empty($listType['icon']) && strrpos($listType['icon'], '/') > strrpos( + $listType['icon'], + '.' + )) { $listType['icon'] .= '.svg'; } $listTypes[] = $listType; @@ -178,7 +180,7 @@ public function render() } } } - $gridTypes = array(); + $gridTypes = []; $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init($this->data['parentPageRow']['pid'])->getLayoutSetup(); if (is_array($layoutSetup)) { foreach ($layoutSetup as $key => $item) { @@ -187,17 +189,21 @@ public function render() $gridType['key'] = $key; if (substr($gridType['key'], 0, 2) !== '--') { $gridType['label'] = $lang->sL($item['title'], true); - if (strpos($item['icon'], 'EXT:') === 0) { - $gridType['icon'] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($item['icon']); - } elseif (strpos($item['icon'], '/typo3') === 0) { - $gridType['icon'] = '../../../' . $item['icon']; - } else { - $gridType['icon'] = '../../../' . '../typo3/sysext/core/Resources/Public/Icons/T3Icons/content/' . $item['icon']; - } - // Check if file ending exists, therefore compare pos of last slash to pos of last dot - if (!empty($gridType['icon']) && strrpos($gridType['icon'], '/') > strrpos($gridType['icon'], - '.')) { - $gridType['icon'] .= '.svg'; + if (!empty($item['icon']) && is_array($item['icon']) && !empty($item['icon'][0])) { + if (strpos($item['icon'][0], 'EXT:') === 0) { + $gridType['icon'] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($item['icon']); + } elseif (strpos($item['icon'][0], '/typo3') === 0) { + $gridType['icon'] = '../../../' . $item['icon']; + } else { + $gridType['icon'] = '../../../' . '../typo3/sysext/core/Resources/Public/Icons/T3Icons/content/' . $item['icon'][0]; + } + // Check if file ending exists, therefore compare pos of last slash to pos of last dot + if (!empty($gridType['icon']) && strrpos($gridType['icon'], '/') > strrpos( + $gridType['icon'], + '.' + )) { + $gridType['icon'] .= '.svg'; + } } $gridTypes[] = $gridType; } diff --git a/Classes/Xclass/DatabaseRecordList.php b/Classes/Xclass/DatabaseRecordList.php index 5371c6f..5a75725 100644 --- a/Classes/Xclass/DatabaseRecordList.php +++ b/Classes/Xclass/DatabaseRecordList.php @@ -285,8 +285,11 @@ public function getButtons() // View Exclude doktypes 254,255 Configuration: // mod.web_list.noViewWithDokTypes = 254,255 if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) { - $noViewDokTypes = GeneralUtility::trimExplode(',', - $module->modTSconfig['properties']['noViewWithDokTypes'], true); + $noViewDokTypes = GeneralUtility::trimExplode( + ',', + $module->modTSconfig['properties']['noViewWithDokTypes'], + true + ); } else { //default exclusion: doktype 254 (folder), 255 (recycler) $noViewDokTypes = [ @@ -295,16 +298,21 @@ public function getButtons() ]; } if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) { - $onClick = htmlspecialchars(BackendUtility::viewOnClick($this->id, '', - BackendUtility::BEgetRootLine($this->id))); + $onClick = htmlspecialchars(BackendUtility::viewOnClick( + $this->id, + '', + BackendUtility::BEgetRootLine($this->id) + )); $buttons['view'] = '' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . ''; } // New record on pages that are not locked by editlock if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) { - $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', - ['id' => $this->id])) . ');'); + $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl( + 'db_new', + ['id' => $this->id] + )) . ');'); $buttons['new_record'] = '' . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . ''; @@ -354,8 +362,10 @@ public function getButtons() $buttons['export'] = '' - . $this->iconFactory->getIcon('actions-document-export-t3d', - Icon::SIZE_SMALL)->render() . ''; + . $this->iconFactory->getIcon( + 'actions-document-export-t3d', + Icon::SIZE_SMALL + )->render() . ''; } } // Reload @@ -438,8 +448,11 @@ public function getDocHeaderButtons(ModuleTemplate $moduleTemplate) // View Exclude doktypes 254,255 Configuration: // mod.web_list.noViewWithDokTypes = 254,255 if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) { - $noViewDokTypes = GeneralUtility::trimExplode(',', - $module->modTSconfig['properties']['noViewWithDokTypes'], true); + $noViewDokTypes = GeneralUtility::trimExplode( + ',', + $module->modTSconfig['properties']['noViewWithDokTypes'], + true + ); } else { //default exclusion: doktype 254 (folder), 255 (recycler) $noViewDokTypes = [ @@ -449,8 +462,10 @@ public function getDocHeaderButtons(ModuleTemplate $moduleTemplate) } // New record on pages that are not locked by editlock if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) { - $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', - ['id' => $this->id])) . ');'; + $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl( + 'db_new', + ['id' => $this->id] + )) . ');'; $newRecordButton = $buttonBar->makeLinkButton() ->setHref('#') ->setOnClick($onClick) @@ -595,8 +610,10 @@ public function getTable($table, $id, $rowList = '') && $table !== 'pages_language_overlay'; $tableCollapsed = (bool)$this->tablesCollapsed[$table]; // prepare space icon - $this->spaceIcon = '' . $this->iconFactory->getIcon('empty-empty', - Icon::SIZE_SMALL)->render() . ''; + $this->spaceIcon = '' . $this->iconFactory->getIcon( + 'empty-empty', + Icon::SIZE_SMALL + )->render() . ''; // Cleaning rowlist for duplicates and place the $titleCol as the first column always! $this->fieldArray = []; // title Column @@ -688,8 +705,11 @@ public function getTable($table, $id, $rowList = '') $selectFields = array_unique($selectFields); $fieldListFields = $this->makeFieldList($table, 1); if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) { - $message = sprintf($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'), - $table, $table); + $message = sprintf( + $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'), + $table, + $table + ); $messageTitle = $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle'); /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( @@ -714,8 +734,10 @@ public function getTable($table, $id, $rowList = '') foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof RecordListGetTableHookInterface) { - throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListGetTableHookInterface::class, - 1195114460); + throw new \UnexpectedValueException( + $classData . ' must implement interface ' . RecordListGetTableHookInterface::class, + 1195114460 + ); } $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this); } @@ -788,12 +810,18 @@ public function getTable($table, $id, $rowList = '') . ' (' . $this->totalItems . ')'; } else { $icon = $this->table - ? '' . $this->iconFactory->getIcon('actions-view-table-collapse', - Icon::SIZE_SMALL)->render() . '' - : '' . $this->iconFactory->getIcon('actions-view-table-expand', - Icon::SIZE_SMALL)->render() . ''; - $theData[$titleCol] = $this->linkWrapTable($table, - $tableTitle . ' (' . $this->totalItems . ') ' . $icon); + ? '' . $this->iconFactory->getIcon( + 'actions-view-table-collapse', + Icon::SIZE_SMALL + )->render() . '' + : '' . $this->iconFactory->getIcon( + 'actions-view-table-expand', + Icon::SIZE_SMALL + )->render() . ''; + $theData[$titleCol] = $this->linkWrapTable( + $table, + $tableTitle . ' (' . $this->totalItems . ') ' . $icon + ); } if ($listOnlyInSingleTableMode) { $tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]); @@ -805,8 +833,10 @@ public function getTable($table, $id, $rowList = '') $title = $tableCollapsed ? htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.expandTable')) : htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.collapseTable')); - $icon = '' . $this->iconFactory->getIcon(($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'), - Icon::SIZE_SMALL)->render() . ''; + $icon = '' . $this->iconFactory->getIcon( + ($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'), + Icon::SIZE_SMALL + )->render() . ''; $collapseIcon = '' . $icon . ''; } $tableHeader .= $theData[$titleCol] . $collapseIcon; @@ -933,13 +963,17 @@ public function getTable($table, $id, $rowList = '') ), $queryBuilder->expr()->eq( 'pid', - $queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], - \PDO::PARAM_INT) + $queryBuilder->createNamedParameter( + (int)$row['_MOVE_PLH_pid'], + \PDO::PARAM_INT + ) ), $queryBuilder->expr()->eq( 't3ver_wsid', - $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], - \PDO::PARAM_INT) + $queryBuilder->createNamedParameter( + (int)$row['t3ver_wsid'], + \PDO::PARAM_INT + ) ), ]; @@ -956,8 +990,14 @@ public function getTable($table, $id, $rowList = '') BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true); if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) { $this->currentIdList[] = $lRow['uid']; - $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, - 18); + $rowOutput .= $this->renderListRow( + $table, + $lRow, + $cc, + $titleCol, + $thumbsCol, + 18 + ); } } } @@ -1090,8 +1130,10 @@ protected function addToCSV(array $row = []) // Get an field array without control fields but in the expected order $fieldArray = array_intersect_key(array_flip($this->fieldArray), $rowReducedByControlFields); // Overwrite fieldArray to keep the order with an array of needed fields - $rowReducedToSelectedColumns = array_replace($fieldArray, - array_intersect_key($rowReducedByControlFields, $fieldArray)); + $rowReducedToSelectedColumns = array_replace( + $fieldArray, + array_intersect_key($rowReducedByControlFields, $fieldArray) + ); $this->setCsvRow($rowReducedToSelectedColumns); } @@ -1139,7 +1181,6 @@ public function setCsvRow($csvRow) * @param string $expanded * @return string Table row for the element * @internal param string $expanded - * @access private * @see getTable() */ public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0, $level = 0, $triggerContainer = 0, $expanded = '') @@ -1179,11 +1220,15 @@ public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent $iconImg = '' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . ''; - $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, - $row['uid']) : $iconImg; + $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon( + $iconImg, + $table, + $row['uid'] + ) : $iconImg; // Preparing and getting the data-array $theData = []; $localizationMarkerClass = ''; + $lC2 = ''; foreach ($this->fieldArray as $fCol) { if ($fCol == $titleCol) { $recTitle = BackendUtility::getRecordTitle($table, $row, false, true); @@ -1194,8 +1239,12 @@ public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent $warning = '' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . ''; } - $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, - $row); + $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems( + $table, + $row['uid'], + $recTitle, + $row + ); // Render thumbnails, if: // - a thumbnail column exists // - there is content in it @@ -1249,8 +1298,13 @@ public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent } elseif ($fCol === '_LOCALIZATION_b') { $theData[$fCol] = $lC2; } else { - $theData[$fCol] = htmlspecialchars(BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, - $row['uid'])); + $theData[$fCol] = htmlspecialchars(BackendUtility::getProcessedValueExtra( + $table, + $fCol, + $row[$fCol], + 0, + $row['uid'] + )); } } // Reset the ID if it was overwritten @@ -1307,7 +1361,7 @@ function ($attributeValue) { if ($triggerContainer) { $theData['_triggerContainer'] = $triggerContainer; - }; + } $rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true)); @@ -1337,7 +1391,7 @@ function ($attributeValue) { } if ($theData['_EXPANDABLE_'] && $level < 8 && ($row['l18n_parent'] == 0 || !$this->localizationView) && !empty($theData['_CHILDREN_'])) { - $expanded = $this->expandedGridelements[$row['uid']] ? ' expanded' : ''; + $expanded = $this->expandedGridelements[$row['uid']] && (($this->expandedGridelements[$row['tx_gridelements_container']] && $expanded) || $row['tx_gridelements_container'] === 0)? ' expanded' : ''; $previousGridColumn = ''; $originalMoveUp = $this->showMoveUp; $originalMoveDown = $this->showMoveDown; @@ -1361,7 +1415,7 @@ function ($attributeValue) { if (isset($child['tx_gridelements_columns']) && ($child['tx_gridelements_columns'] !== $previousGridColumn)) { $previousGridColumn = $child['tx_gridelements_columns']; $this->showMoveUp = false; - $rowOutput .= '