/**
  * Checks if a CType is allowed in this particular page or grid column - only this one column defines the allowed CTypes regardless of any parent column
  *
  * @param    array   $items           : The items of the current CType list
  * @param    integer $pid             : The id of the page we are currhently working on
  * @param    integer $pageColumn      : The page column the element is a child of
  * @param    integer $gridContainerId : The ID of the current container
  * @param    integer $gridColumn      : The grid column the element is a child of
  *
  * @return    array|null    $backendLayout: An array containing the data of the selected backend layout as well as a parsed version of the layout configuration
  */
 public function checkForAllowedCTypes(&$items, $pid, $pageColumn, $gridContainerId, $gridColumn)
 {
     if ((int) $pageColumn >= 0 || (int) $pageColumn === -2) {
         $column = $pageColumn ? $pageColumn : 0;
         $backendLayout = $this->getSelectedBackendLayout($pid);
     } else {
         $this->init($pid);
         $column = $gridColumn ? $gridColumn : 0;
         $gridElement = $this->layoutSetup->cacheCurrentParent($gridContainerId, TRUE);
         $backendLayout = $this->layoutSetup->getLayoutSetup($gridElement['tx_gridelements_backend_layout']);
     }
     if (isset($backendLayout)) {
         foreach ($items as $key => $item) {
             if (!(GeneralUtility::inList($backendLayout['columns'][$column], $item[1]) || GeneralUtility::inList($backendLayout['columns'][$column], '*'))) {
                 unset($items[$key]);
             }
         }
     }
 }
Example #2
0
 /**
  * delete containers from params which are not allowed
  *
  * @param array $params
  * @param string $itemUidList comma seperated list of uids
  *
  * @return void
  */
 public function deleteUnallowedContainer(array &$params, $itemUidList = '')
 {
     $layoutSetups = $this->layoutSetup->getLayoutSetup();
     if ($itemUidList) {
         $containerRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,tx_gridelements_backend_layout', 'tt_content', 'uid IN (' . $itemUidList . ')', '', '', '', 'uid');
         foreach ($params['items'] as $key => $container) {
             $allowed = $layoutSetups[$containerRecords[$container[1]]['tx_gridelements_backend_layout']]['allowed'];
             if ($container[1] > 0 && $allowed) {
                 if (!GeneralUtility::inList($allowed, $params['row']['CType']) && !GeneralUtility::inList($allowed, '*')) {
                     unset($params['items'][$key]);
                 }
             }
         }
     }
 }