/** * Helper function for editPanel() which wraps icons in the panel in a link with the action of the panel. * The links are for some of them not simple hyperlinks but onclick-actions which submits a little form which the panel is wrapped in. * * @param string $string The string to wrap in a link, typ. and image used as button in the edit panel. * @param string $formName The name of the form wrapping the edit panel. * @param string $cmd The command of the link. There is a predefined list available: edit, new, up, down etc. * @param string $currentRecord The "table:uid" of the record being processed by the panel. * @param string $confirm Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed) * @param int|string $nPid "New pid" - for new records * @return string A <a> tag wrapped string. */ protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord = '', $confirm = '', $nPid = '') { $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0; if ($cmd == 'edit') { $rParts = explode(':', $currentRecord); $out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('record_edit', array('edit[' . $rParts[0] . '][' . $rParts[1] . ']' => 'edit', 'noView=' . $nV)), $currentRecord); } elseif ($cmd == 'new') { $rParts = explode(':', $currentRecord); if ($rParts[0] == 'pages') { $out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('db_new', ['id' => $rParts[1], 'pagesOnly' => 1]), $currentRecord); } else { if (!(int) $nPid) { $nPid = MathUtility::canBeInterpretedAsInteger($rParts[1]) ? -$rParts[1] : $this->frontendController->id; } $out = $this->editPanelLinkWrap_doWrap($string, BackendUtility::getModuleUrl('record_edit', array('edit[' . $rParts[0] . '][' . $nPid . ']' => 'new', 'noView' => $nV)), $currentRecord); } } else { if ($confirm && $this->backendUser->jsConfirmation(JsConfirmation::FE_EDIT)) { // Gets htmlspecialchared later $cf1 = 'if (confirm(' . GeneralUtility::quoteJSvalue($confirm, TRUE) . ')) {'; $cf2 = '}'; } else { $cf1 = $cf2 = ''; } $out = '<a href="#" onclick="' . htmlspecialchars($cf1 . 'document.' . $formName . '[\'TSFE_EDIT[cmd]\'].value=\'' . $cmd . '\'; document.' . $formName . '.submit();' . $cf2 . ' return false;') . '">' . $string . '</a>'; } return $out; }