/** * Return TSconfig for a page id * * @param int $tscPID Page id (PID) from which to get configuration. * @return array TSconfig array, if any */ public function getTCEMAIN_TSconfig($tscPID) { if (!isset($this->cachedTSconfig[$tscPID])) { $this->cachedTSconfig[$tscPID] = $this->BE_USER->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($tscPID)); } return $this->cachedTSconfig[$tscPID]['properties']; }
/** * Make 1st level clickmenu: * * @param string $table Table name * @param int $uid UID for the current record. * @return array the array to be returned as JSON */ public function printDBClickMenu($table, $uid) { $uid = (int) $uid; // Get record: $this->rec = BackendUtility::getRecordWSOL($table, $uid); $menuItems = []; $root = 0; $DBmount = false; // Rootlevel if ($table === 'pages' && $uid === 0) { $root = 1; } // DB mount if ($table === 'pages' && in_array($uid, $this->backendUser->returnWebmounts())) { $DBmount = true; } // Used to hide cut,copy icons for l10n-records $l10nOverlay = false; // Should only be performed for overlay-records within the same table if (BackendUtility::isTableLocalizable($table) && $table !== 'pages_language_overlay') { $l10nOverlay = (int) $this->rec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0; } // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render. if (is_array($this->rec) || $root) { // Get permissions $lCP = $this->backendUser->calcPerms(BackendUtility::getRecord('pages', $table === 'pages' ? (int) $this->rec['uid'] : (int) $this->rec['pid'])); // View if (!in_array('view', $this->disabledItems, true)) { if ($table === 'pages') { $menuItems['view'] = $this->DB_view($uid); } if ($table === 'tt_content') { $ws_rec = BackendUtility::getRecordWSOL($table, (int) $this->rec['uid']); $menuItems['view'] = $this->DB_view((int) $ws_rec['pid']); } } // Edit: if (!$root && ($this->backendUser->isPSet($lCP, $table, 'edit') || $this->backendUser->isPSet($lCP, $table, 'editcontent'))) { if (!in_array('edit', $this->disabledItems, true)) { $menuItems['edit'] = $this->DB_edit($table, $uid); } $this->editOK = true; } // New: if (!in_array('new', $this->disabledItems, true) && $this->backendUser->isPSet($lCP, $table, 'new')) { $menuItems['new'] = $this->DB_new($table, $uid); } // Info: if (!in_array('info', $this->disabledItems, true) && !$root) { $menuItems['info'] = $this->DB_info($table, $uid); } $menuItems['spacer1'] = 'spacer'; // Copy: if (!in_array('copy', $this->disabledItems, true) && !$root && !$DBmount && !$l10nOverlay) { $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy'); } // Cut: if (!in_array('cut', $this->disabledItems, true) && !$root && !$DBmount && !$l10nOverlay && $this->editOK) { $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut'); } // Paste: $elFromAllTables = count($this->clipObj->elFromTable('')); if (!in_array('paste', $this->disabledItems, true) && $elFromAllTables) { $selItem = $this->clipObj->getSelectedRecord(); $elInfo = [GeneralUtility::fixed_lgd_cs($selItem['_RECORD_TITLE'], $this->backendUser->uc['titleLen']), $root ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $this->backendUser->uc['titleLen']), $this->clipObj->currentMode()]; if ($table === 'pages' && $lCP & Permission::PAGE_NEW) { if ($elFromAllTables) { $menuItems['pasteinto'] = $this->DB_paste('', $uid, 'into', $elInfo); } } $elFromTable = count($this->clipObj->elFromTable($table)); if (!$root && !$DBmount && $elFromTable && $GLOBALS['TCA'][$table]['ctrl']['sortby']) { $menuItems['pasteafter'] = $this->DB_paste($table, -$uid, 'after', $elInfo); } } // Delete: $elInfo = [GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $this->backendUser->uc['titleLen'])]; $disableDeleteTS = $this->backendUser->getTSConfig('options.disableDelete'); $disableDelete = (bool) trim(isset($disableDeleteTS['properties'][$table]) ? $disableDeleteTS['properties'][$table] : $disableDeleteTS['value']); if (!in_array('delete', $this->disabledItems, true) && !$root && !$DBmount && $this->backendUser->isPSet($lCP, $table, 'delete') && !$disableDelete) { $menuItems['spacer2'] = 'spacer'; $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo); } if (!in_array('history', $this->disabledItems, true)) { $menuItems['history'] = $this->DB_history($table, $uid); } $localItems = []; if (!$this->cmLevel && !in_array('moreoptions', $this->disabledItems, true)) { // Creating menu items here: if ($this->editOK) { $localItems['spacer3'] = 'spacer'; $localItems['moreoptions'] = $this->linkItem($this->label('more') . ' <span class="fa fa-caret-right"></span>', '<span class="fa fa-fw"></span>', 'TYPO3.ClickMenu.fetch(' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript() . '&cmLevel=1&subname=moreoptions') . ');return false;', false, true); $menuItemHideUnhideAllowed = false; $hiddenField = ''; // Check if column for disabled is defined if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'])) { $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']; if ($hiddenField !== '' && !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude']) && $this->backendUser->check('non_exclude_fields', $table . ':' . $hiddenField)) { $menuItemHideUnhideAllowed = true; } } if ($menuItemHideUnhideAllowed && !in_array('hide', $this->disabledItems, true)) { $localItems['hide'] = $this->DB_hideUnhide($table, $this->rec, $hiddenField); } $anyEnableColumnsFieldAllowed = false; // Check if columns are defined if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) { $columnsToCheck = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']; if ($table === 'pages' && !empty($columnsToCheck)) { $columnsToCheck[] = 'extendToSubpages'; } foreach ($columnsToCheck as $currentColumn) { if (!empty($GLOBALS['TCA'][$table]['columns'][$currentColumn]['exclude']) && $this->backendUser->check('non_exclude_fields', $table . ':' . $currentColumn)) { $anyEnableColumnsFieldAllowed = true; } } } if ($anyEnableColumnsFieldAllowed && !in_array('edit_access', $this->disabledItems, true)) { $localItems['edit_access'] = $this->DB_editAccess($table, $uid); } } // Find delete element among the input menu items and insert the local items just before that: $c = 0; $deleteFound = false; foreach ($menuItems as $key => $value) { $c++; if ($key === 'delete') { $deleteFound = true; break; } } if ($deleteFound) { // .. subtract two... (delete item + its spacer element...) $c -= 2; // and insert the items just before the delete element. array_splice($menuItems, $c, 0, $localItems); } else { $menuItems = array_merge($menuItems, $localItems); } } } // Adding external elements to the menuItems array $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid); // Processing by external functions? $menuItems = $this->externalProcessingOfDBMenuItems($menuItems); if (!is_array($this->rec)) { $this->rec = []; } // Return the printed elements: return $this->printItems($menuItems); }