public function __construct() { $this->setDatabaseConnection($GLOBALS['TYPO3_DB']); $this->setLanguageService($GLOBALS['LANG']); $this->helper = Helper::getInstance(); $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); $this->cleanupCollapsedStatesInUC(); }
/** * Renders the grid layout table after the HTML content for the single elements has been rendered * * @param array $layoutSetup : The setup of the layout that is selected for the grid we are going to render * @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 * * @return string */ public function renderGridLayoutTable($layoutSetup, $row, $head, $gridContent) { $specificIds = Helper::getInstance()->getSpecificIds($row); $grid = '<div class="t3-gridContainer' . ($layoutSetup['frame'] ? ' t3-gridContainer-framed t3-gridContainer-' . $layoutSetup['frame'] : '') . ($layoutSetup['top_level_layout'] ? ' t3-gridTLContainer' : '') . '">'; if ($layoutSetup['frame']) { $grid .= '<h4 class="t3-gridContainer-title-' . $layoutSetup['frame'] . '">' . $this->lang->sL($layoutSetup['title'], TRUE) . '</h4>'; } if ($GLOBALS['BE_USER']->uc['showGridInformation'] === 1) { $grid .= '<span class="t3-help-link" href="#" data-title="' . htmlspecialchars($this->lang->sL($layoutSetup['title'])) . '" data-description="' . htmlspecialchars($this->lang->sL($layoutSetup['description'])) . '"><abbr class="t3-help-teaser">' . $this->lang->sL($layoutSetup['title'], TRUE) . '</abbr></span>'; } $grid .= '<table border="0" cellspacing="1" cellpadding="4" width="100%" height="100%" class="t3-page-columns t3-gridTable">'; // add colgroups $colCount = 0; $rowCount = 0; if (isset($layoutSetup['config'])) { if (isset($layoutSetup['config']['colCount'])) { $colCount = (int) $layoutSetup['config']['colCount']; } if (isset($layoutSetup['config']['rowCount'])) { $rowCount = (int) $layoutSetup['config']['rowCount']; } } $grid .= '<colgroup>'; for ($i = 0; $i < $colCount; $i++) { $grid .= '<col style="width:' . 100 / $colCount . '%"></col>'; } $grid .= '</colgroup>'; // cycle through rows for ($layoutRow = 1; $layoutRow <= $rowCount; $layoutRow++) { $rowConfig = $layoutSetup['config']['rows.'][$layoutRow . '.']; if (!isset($rowConfig)) { continue; } $grid .= '<tr>'; for ($col = 1; $col <= $colCount; $col++) { $columnConfig = $rowConfig['columns.'][$col . '.']; if (!isset($columnConfig)) { continue; } // which column should be displayed inside this cell $columnKey = $columnConfig['colPos'] !== '' ? (int) $columnConfig['colPos'] : 32768; // allowed CTypes if (!empty($columnConfig['allowed'])) { $allowedCTypes = array_flip(GeneralUtility::trimExplode(',', $columnConfig['allowed'])); if (!isset($allowedCTypes['*'])) { foreach ($allowedCTypes as $ctype => &$ctypeClass) { $ctypeClass = 't3-allow-' . $ctype; } } else { unset($allowedCTypes); } } if (!empty($columnConfig['allowedGridTypes'])) { $allowedGridTypes = array_flip(GeneralUtility::trimExplode(',', $columnConfig['allowedGridTypes'])); if (!isset($allowedGridTypes['*'])) { foreach ($allowedGridTypes as $gridType => &$gridTypeClass) { $gridTypeClass = 't3-allow-gridtype-' . $gridType; } $allowedCTypes['gridelements_pi1'] = 't3-allow-gridelements_pi1'; } else { if (isset($allowedCTypes)) { $allowedCTypes['gridelements_pi1'] = 't3-allow-gridelements_pi1'; } unset($allowedGridTypes); } } // render the grid cell $colSpan = (int) $columnConfig['colspan']; $rowSpan = (int) $columnConfig['rowspan']; $grid .= '<td valign="top"' . (isset($columnConfig['colspan']) ? ' colspan="' . $colSpan . '"' : '') . (isset($columnConfig['rowspan']) ? ' rowspan="' . $rowSpan . '"' : '') . 'id="column-' . $specificIds['uid'] . 'x' . $columnKey . '" class="t3-gridCell t3-page-column t3-page-column-' . $columnKey . (!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '' ? ' t3-gridCell-unassigned' : '') . (isset($columnConfig['colspan']) && $columnConfig['colPos'] !== '' ? ' t3-gridCell-width' . $colSpan : '') . (isset($columnConfig['rowspan']) && $columnConfig['colPos'] !== '' ? ' t3-gridCell-height' . $rowSpan : '') . ' ' . ($layoutSetup['horizontal'] ? ' t3-gridCell-horizontal' : '') . (count($allowedCTypes) ? ' ' . join(' ', $allowedCTypes) : ' t3-allow-all') . (count($allowedGridTypes) ? ' ' . join(' ', $allowedGridTypes) : '') . '">'; $grid .= ($GLOBALS['BE_USER']->uc['hideColumnHeaders'] ? '' : $head[$columnKey]) . $gridContent[$columnKey]; $grid .= '</td>'; } $grid .= '</tr>'; } $grid .= '</table></div>'; return $grid; }
/** * check if current row has child elements and add info to $theData array * * @param string $table * @param array $row * @param int $level * @param array $theData * @param object $parentObject * * @return void */ public function checkChildren($table, $row, $level, &$theData, &$parentObject) { if ($table === 'tt_content' && $row['CType'] === 'gridelements_pi1') { $elementChildren = Helper::getInstance()->getChildren($table, $row['uid']); if (count($elementChildren) > 0) { $theData['_EXPANDABLE_'] = TRUE; $theData['_EXPAND_ID_'] = $table . ':' . $row['uid']; $theData['_EXPAND_TABLE_'] = $table; $theData['_LEVEL_'] = $level; } } }
/** * get list rows * * @param AjaxRequestHandler $ajaxObj the parent ajax object * * @return void */ public function getListRows(AjaxRequestHandler &$ajaxObj) { $uid = (int) $this->getParamValue('uid'); if ($uid > 0) { $table = (string) $this->getParamValue('table'); $table = $table ? $table : 'tt_content'; $level = (int) $this->getParamValue('level'); $this->initializeTemplateContainer(); $elementChildren = Helper::getInstance()->getChildren($table, $uid, GeneralUtility::_GP('sortField'), (int) GeneralUtility::_GP('sortRev')); $row = BackendUtility::getRecord($table, $uid); $recordList = $this->getRecordList($table, $uid, $row); if ($recordList instanceof DatabaseRecordList) { $level++; foreach ($elementChildren as $elementChild) { $listRows[] = $recordList->renderListRow($elementChild->getTable(), BackendUtility::getRecord($elementChild->getTable(), $elementChild->getId()), 0, $GLOBALS['TCA'][$table]['ctrl']['label'], $GLOBALS['TCA'][$table]['ctrl']['thumbnail'], 1, $level); } } $ajaxObj->addContent('list', $listRows); } }
/** * check if current row has child elements and add info to $theData array * * @param string $table * @param array $row * @param int $level * @param array $theData * @param \GridElementsTeam\Gridelements\Xclass\DatabaseRecordList $parentObj */ public function checkChildren($table, $row, $level, &$theData, $parentObj) { if ($table === 'tt_content' && $row['CType'] === 'gridelements_pi1') { $elementChildren = Helper::getInstance()->getChildren($table, $row['uid'], '', 0, $parentObj->selFieldList); if (!empty($elementChildren)) { $theData['_EXPANDABLE_'] = true; $theData['_EXPAND_ID_'] = $table . ':' . $row['uid']; $theData['_EXPAND_TABLE_'] = $table; $theData['_LEVEL_'] = $level; $theData['_CHILDREN_'] = $elementChildren; } } }
/** * Creates the control panel for a single record in the listing. * * @param string $table The table * @param array $row The record for which to make the control panel. * @param string $level * @return string HTML table with the control panel (unless disabled) */ public function makeControl($table, $row, $level) { if ($this->dontShowClipControlPanels) { return ''; } $rowUid = \GridElementsTeam\Gridelements\Helper\Helper::getInstance()->getSpecificUid($row); $rowUid = $row['uid']; if (ExtensionManagementUtility::isLoaded('version') && isset($row['_ORIG_uid'])) { $rowUid = $row['_ORIG_uid']; } $cells = array(); // If the listed table is 'pages' we have to request the permission settings for each page: if ($table == 'pages') { $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $row['uid'])); } // This expresses the edit permissions for this particular element: $permsEdit = $table == 'pages' && $localCalcPerms & 2 || $table != 'pages' && $this->calcPerms & 16; // "Show" link (only pages and tt_content elements) if ($table == 'pages' || $table == 'tt_content') { $cells['view'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($table === 'tt_content' ? $this->id : $row['uid'], $this->backPath, '', $table === 'tt_content' ? '#' . $row['uid'] : '')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>'; } elseif (!$this->table) { $cells['view'] = $this->spaceIcon; } // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id) if ($permsEdit) { $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; $cells['edit'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . ($GLOBALS['TCA'][$table]['ctrl']['readOnly'] ? IconUtility::getSpriteIcon('actions-document-open-read-only') : IconUtility::getSpriteIcon('actions-document-open')) . '</a>'; } elseif (!$this->table) { $cells['edit'] = $this->spaceIcon; } // "Move" wizard link for pages/tt_content elements: if (($table == 'tt_content' && $permsEdit || $table == 'pages') && $level == 0) { $cells['move'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'move_el.php?table=' . $table . '&uid=' . $row['uid'] . '\');') . '" title="' . $GLOBALS['LANG']->getLL('move_' . ($table == 'tt_content' ? 'record' : 'page'), TRUE) . '">' . ($table == 'tt_content' ? IconUtility::getSpriteIcon('actions-document-move') : IconUtility::getSpriteIcon('actions-page-move')) . '</a>'; } elseif (!$this->table || $level > 0) { $cells['move'] = $this->spaceIcon; } // If the extended control panel is enabled OR if we are seeing a single table: if ($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel'] || $this->table) { // "Info": (All records) $cells['viewBig'] = '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;') . '" title="' . $GLOBALS['LANG']->getLL('showInfo', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-info') . '</a>'; // If the table is NOT a read-only table, then show these links: if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly']) { // "Revert" link (history/undo) $cells['history'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue($this->backPath . BackendUtility::getModuleUrl('record_history', array('element' => $table . ':' . $row['uid']))) . ',\'#latest\');') . '" title="' . $GLOBALS['LANG']->getLL('history', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>'; // Versioning: if (ExtensionManagementUtility::isLoaded('version') && !ExtensionManagementUtility::isLoaded('workspaces')) { $vers = BackendUtility::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace, FALSE, $row); // If table can be versionized. if (is_array($vers)) { $versionIcon = 'no-version'; if (count($vers) > 1) { $versionIcon = count($vers) - 1; } $cells['version'] = '<a href="' . htmlspecialchars($this->backPath . BackendUtility::getModuleUrl('web_txversionM1', array('table' => $table, 'uid' => $row['uid']))) . '" title="' . $GLOBALS['LANG']->getLL('displayVersions', TRUE) . '">' . IconUtility::getSpriteIcon('status-version-' . $versionIcon) . '</a>'; } elseif (!$this->table) { $cells['version'] = $this->spaceIcon; } } // "Edit Perms" link: if ($table == 'pages' && $GLOBALS['BE_USER']->check('modules', 'web_perm') && ExtensionManagementUtility::isLoaded('perm')) { $cells['perms'] = '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_perm') . '&id=' . $row['uid'] . '&return_id=' . $row['uid'] . '&edit=1') . '" title="' . $GLOBALS['LANG']->getLL('permissions', TRUE) . '">' . IconUtility::getSpriteIcon('status-status-locked') . '</a>'; } elseif ((!$this->table || $level > 0) && $GLOBALS['BE_USER']->check('modules', 'web_perm')) { $cells['perms'] = $this->spaceIcon; } // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record): if ($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) { if ($table != 'pages' && $this->calcPerms & 16 || $table == 'pages' && $this->calcPerms & 8) { if ($this->showNewRecLink($table)) { $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new'; $cells['new'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1)) . '" title="' . $GLOBALS['LANG']->getLL('new' . ($table == 'pages ' ? 'Page' : 'Record'), TRUE) . '">' . ($table == 'pages' ? IconUtility::getSpriteIcon('actions-page-new') : IconUtility::getSpriteIcon('actions-document-new')) . '</a>'; } } } elseif (!$this->table) { $cells['new'] = $this->spaceIcon; } // "Up/Down" links if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) { if (isset($this->currentTable['prev'][$row['uid']]) && $this->showMoveUp === TRUE) { // Up if ($this->lastMoveDownParams) { $params = $this->lastMoveDownParams; } else { $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']]; } $cells['moveUp'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('moveUp', TRUE) . '">' . IconUtility::getSpriteIcon('actions-move-up') . '</a>'; } else { $cells['moveUp'] = $this->spaceIcon; } if ($this->currentTable['next'][$row['uid']] && $this->showMoveDown === TRUE) { // Down $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']]; $this->lastMoveDownParams = $params; $cells['moveDown'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('moveDown', TRUE) . '">' . IconUtility::getSpriteIcon('actions-move-down') . '</a>'; } else { $cells['moveDown'] = $this->spaceIcon; } } elseif (!$this->table) { $cells['moveUp'] = $this->spaceIcon; $cells['moveDown'] = $this->spaceIcon; } // "Hide/Unhide" links: $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']; if ($permsEdit && $hiddenField && $GLOBALS['TCA'][$table]['columns'][$hiddenField] && (!$GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $hiddenField))) { if ($row[$hiddenField]) { $params = '&data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0'; $cells['hide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('unHide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-unhide') . '</a>'; } else { $params = '&data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1'; $cells['hide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('hide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-hide') . '</a>'; } } elseif (!$this->table) { $cells['hide'] = $this->spaceIcon; } // "Delete" link: if ($table == 'pages' && $localCalcPerms & 4 || $table != 'pages' && $this->calcPerms & 16) { // Check if the record version is in "deleted" state, because that will switch the action to "restore" if ($GLOBALS['BE_USER']->workspace > 0 && isset($row['t3ver_state']) && (int) $row['t3ver_state'] === 2) { $actionName = 'restore'; $refCountMsg = ''; } else { $actionName = 'delete'; $refCountMsg = BackendUtility::referenceCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToRecord'), $this->getReferenceCount($table, $row['uid'])) . BackendUtility::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')); } $titleOrig = BackendUtility::getRecordTitle($table, $row, FALSE, TRUE); $title = GeneralUtility::slashJS(GeneralUtility::fixed_lgd_cs($titleOrig, $this->fixedL), 1); $warningText = GeneralUtility::quoteJSvalue($GLOBALS['LANG']->getLL($actionName . 'Warning') . ' "' . $title . '" ' . $refCountMsg); $params = '&cmd[' . $table . '][' . $row['uid'] . '][delete]=1'; $onClick = htmlspecialchars('if (confirm(' . $warningText . ')) {jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');} return false;'); $icon = IconUtility::getSpriteIcon('actions-edit-' . $actionName); $linkTitle = $GLOBALS['LANG']->getLL($actionName, TRUE); $cells['delete'] = '<a href="#" onclick="' . $onClick . '" title="' . $linkTitle . '">' . $icon . '</a>'; } elseif (!$this->table) { $cells['delete'] = $this->spaceIcon; } // "Levels" links: Moving pages into new levels... if ($permsEdit && $table == 'pages' && !$this->searchLevels) { // Up (Paste as the page right after the current parent page) if ($this->calcPerms & 8) { $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id; $cells['moveLeft'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('prevLevel', TRUE) . '">' . IconUtility::getSpriteIcon('actions-move-left') . '</a>'; } // Down (Paste as subpage to the page right above) if ($this->currentTable['prevUid'][$row['uid']]) { $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']])); if ($localCalcPerms & 8) { $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']]; $cells['moveRight'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('nextLevel', TRUE) . '">' . IconUtility::getSpriteIcon('actions-move-right') . '</a>'; } else { $cells['moveRight'] = $this->spaceIcon; } } else { $cells['moveRight'] = $this->spaceIcon; } } elseif (!$this->table) { $cells['moveLeft'] = $this->spaceIcon; $cells['moveRight'] = $this->spaceIcon; } } } /** * @hook recStatInfoHooks: Allows to insert HTML before record icons on various places * @date 2007-09-22 * @request Kasper Skårhøj <*****@*****.**> */ if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) { $stat = ''; $_params = array($table, $row['uid']); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) { $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $this); } $cells['stat'] = $stat; } /** * @hook makeControl: Allows to change control icons of records in list-module * @date 2007-11-20 * @request Bernhard Kraft <*****@*****.**> * @usage This hook method gets passed the current $cells array as third parameter. This array contains values for the icons/actions generated for each record in Web>List. Each array entry is accessible by an index-key. The order of the icons is dependend on the order of those array entries. */ if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface) { throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Recordlist\\RecordList\\RecordListHookInterface', 1195567840); } $cells = $hookObject->makeControl($table, $row, $cells, $this); } } // Compile items into a DIV-element: return ' <!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' --> <div class="typo3-DBctrl">' . implode('', $cells) . '</div>'; }