/** * Main function of the module. Write the content to $this->content * * @return void */ public function main() { $languageService = $this->getLanguageService(); $this->thisScript = BackendUtility::getModuleUrl($this->MCONF['name']); // Clean up settings: $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name']); // Draw the header // DBAL page title: $this->content .= '<h1>' . $languageService->getLL('title') . '</h1>'; $this->generateMenu(); // Debug log: switch ($this->MOD_SETTINGS['function']) { case 'info': $this->content .= $this->moduleTemplate->section($languageService->getLL('Cached_info'), $this->printCachedInfo()); break; case 'sqlcheck': $this->content .= $this->moduleTemplate->section($languageService->getLL('SQL_check'), $this->printSqlCheck()); break; case 0: $this->content .= $this->moduleTemplate->section($languageService->getLL('Debug_log'), $this->printLogMgm()); break; } // ShortCut $shortcutButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeShortcutButton()->setModuleName($this->MCONF['name'])->setGetVariables(['id']); $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($shortcutButton); }
/** * Initialize module header etc and call extObjContent function * * @return void */ public function main() { // We leave this here because of dependencies to submodules $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); // The page will show only if there is a valid page and if this page // may be viewed by the user $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); if ($this->pageinfo) { $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo); } $access = is_array($this->pageinfo); if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) { if ($this->backendUser->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } // JavaScript $this->moduleTemplate->addJavaScriptCode('WebFuncInLineJS', 'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . '; function jumpToUrl(URL) { window.location.href = URL; return false; } '); // Setting up the context sensitive menu: $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); $this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl($this->moduleName)) . '" method="post" id="InfoModuleController" name="webinfoForm" class="form-inline form-inline-spaced">'; $vContent = $this->moduleTemplate->getVersionSelector($this->id, 1); if ($vContent) { $this->content .= $this->moduleTemplate->section('', $vContent); } $this->extObjContent(); // Setting up the buttons and markers for docheader $this->getButtons(); $this->generateMenu(); $this->content .= '</form>'; } else { // If no access or if ID == zero $this->content = $this->doc->header($this->languageService->getLL('title')); } }
/** * Initialize module header etc and call extObjContent function * * @return void */ public function main() { // Access check... // The page will show only if there is a valid page and if this page may be viewed by the user $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo); $access = is_array($this->pageinfo); // We keep this here, in case somebody relies on the old doc being here $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); // Main if ($this->id && $access) { // JavaScript $this->moduleTemplate->addJavaScriptCode('WebFuncInLineJS', 'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . ';'); // Setting up the context sensitive menu: $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); $this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('web_func')) . '" id="PageFunctionsController" method="post"><input type="hidden" name="id" value="' . htmlspecialchars($this->id) . '" />'; $vContent = $this->moduleTemplate->getVersionSelector($this->id, true); if ($vContent) { $this->content .= $this->moduleTemplate->section('', $vContent); } $this->extObjContent(); // Setting up the buttons and markers for docheader $this->getButtons(); $this->generateMenu(); $this->content .= '</form>'; } else { // If no access or if ID == zero $title = $this->getLanguageService()->getLL('title'); $message = $this->getLanguageService()->getLL('clickAPage_content'); $view = GeneralUtility::makeInstance(StandaloneView::class); $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:func/Resources/Private/Templates/InfoBox.html')); $view->assignMultiple(array('title' => $title, 'message' => $message, 'state' => InfoboxViewHelper::STATE_INFO)); $this->content = $view->render(); // Setting up the buttons and markers for docheader $this->getButtons(); } }
/** * Generate the module's content * * @return string HTML of the module's main content */ protected function getModuleContent() { $content = ''; $sectionTitle = ''; // Get submitted data $this->submittedData = GeneralUtility::_GPmerged('tx_scheduler'); $this->submittedData['uid'] = (int) $this->submittedData['uid']; // If a save command was submitted, handle saving now if ($this->CMD === 'save' || $this->CMD === 'saveclose' || $this->CMD === 'savenew') { $previousCMD = GeneralUtility::_GP('previousCMD'); // First check the submitted data $result = $this->preprocessData(); // If result is ok, proceed with saving if ($result) { $this->saveTask(); if ($this->CMD === 'saveclose') { // Unset command, so that default screen gets displayed unset($this->CMD); } elseif ($this->CMD === 'save') { // After saving a "add form", return to edit $this->CMD = 'edit'; } elseif ($this->CMD === 'savenew') { // Unset submitted data, so that empty form gets displayed unset($this->submittedData); // After saving a "add/edit form", return to add $this->CMD = 'add'; } else { // Return to edit form $this->CMD = $previousCMD; } } else { $this->CMD = $previousCMD; } } // Handle chosen action switch ((string) $this->MOD_SETTINGS['function']) { case 'scheduler': $this->executeTasks(); switch ($this->CMD) { case 'add': case 'edit': try { // Try adding or editing $content .= $this->editTaskAction(); $sectionTitle = $this->getLanguageService()->getLL('action.' . $this->CMD); } catch (\Exception $e) { if ($e->getCode() === 1305100019) { // Invalid controller class name exception $this->addMessage($e->getMessage(), FlashMessage::ERROR); } // An exception may also happen when the task to // edit could not be found. In this case revert // to displaying the list of tasks // It can also happen when attempting to edit a running task $content .= $this->listTasksAction(); } break; case 'delete': $this->deleteTask(); $content .= $this->listTasksAction(); break; case 'stop': $this->stopTask(); $content .= $this->listTasksAction(); break; case 'toggleHidden': $this->toggleDisableAction(); $content .= $this->listTasksAction(); break; case 'list': default: $content .= $this->listTasksAction(); } break; // Setup check screen // Setup check screen case 'check': // @todo move check to the report module $content .= $this->checkScreenAction(); break; // Information screen // Information screen case 'info': $content .= $this->infoScreenAction(); break; } // Wrap the content in a section return $this->moduleTemplate->section($sectionTitle, '<div class="tx_scheduler_mod1">' . $content . '</div>', false, true); }
/** * Import part of module * * @param array $inData Content of POST VAR tx_impexp[].. * @throws \BadFunctionCallException * @throws \InvalidArgumentException * @throws \RuntimeException * @return void Setting content in $this->content */ public function importData($inData) { $access = is_array($this->pageinfo) ? 1 : 0; $beUser = $this->getBackendUser(); if ($this->id && $access || $beUser->user['admin'] && !$this->id) { if ($beUser->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } if ($inData['new_import']) { unset($inData['import_mode']); } /** @var $import \TYPO3\CMS\Impexp\ImportExport */ $import = GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\ImportExport::class); $import->init(0, 'import'); $import->update = $inData['do_update']; $import->import_mode = $inData['import_mode']; $import->enableLogging = $inData['enableLogging']; $import->global_ignore_pid = $inData['global_ignore_pid']; $import->force_all_UIDS = $inData['force_all_UIDS']; $import->showDiff = !$inData['notShowDiff']; $import->allowPHPScripts = $inData['allowPHPScripts']; $import->softrefInputValues = $inData['softrefInputValues']; // OUTPUT creation: $menuItems = array(); // Make input selector: // must have trailing slash. $path = $this->getDefaultImportExportFolder(); $exportFiles = $this->getExportFiles(); $this->shortcutName .= ' (' . $this->pageinfo['title'] . ')'; // Configuration $row = array(); $selectOptions = array(''); foreach ($exportFiles as $file) { $selectOptions[$file->getCombinedIdentifier()] = $file->getPublicUrl(); } $row[] = ' <tr> <th colspan="2">' . $this->lang->getLL('importdata_selectFileToImport', true) . '</th> </tr>'; $noCompressorAvailable = !$import->compress ? '<br /><span class="text-danger">' . $this->lang->getLL('importdata_noteNoDecompressorAvailable', true) . '</span>' : ''; $row[] = ' <tr> <td valign="top"> ' . $this->lang->getLL('importdata_file', true) . '' . BackendUtility::cshItem('xMOD_tx_impexp', 'importFile') . ' </td> <td> ' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $selectOptions) . '<br />' . sprintf($this->lang->getLL('importdata_fromPathS', true), $path ? $path->getCombinedIdentifier() : $this->lang->getLL('importdata_no_accessible_file_mount', true)) . $noCompressorAvailable . ' </td> </tr>'; $row[] = ' <tr> <th colspan="2"> ' . $this->lang->getLL('importdata_importOptions', true) . ' </th> </tr>'; $row[] = ' <tr> <td valign="top"> ' . $this->lang->getLL('importdata_update', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'update') . ' </td> <td> <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ? ' checked="checked"' : '') . ' /> <label for="checkDo_update">' . $this->lang->getLL('importdata_updateRecords', true) . '</label> <br/> <em>(' . $this->lang->getLL('importdata_thisOptionRequiresThat', true) . ')</em>' . ($inData['do_update'] ? ' <hr/> <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ? ' checked="checked"' : '') . ' /> <label for="checkGlobal_ignore_pid">' . $this->lang->getLL('importdata_ignorePidDifferencesGlobally', true) . '</label><br/> <em>(' . $this->lang->getLL('importdata_ifYouSetThis', true) . ')</em> ' : '') . ' </td> </tr>'; $allowPhpScripts = $beUser->isAdmin() ? ' <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ? ' checked="checked"' : '') . ' /> <label for="checkAllowPHPScripts">' . $this->lang->getLL('importdata_allowToWriteBanned', true) . '</label><br/>' : ''; $doUpdate = !$inData['do_update'] && $beUser->isAdmin() ? ' <br/> <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ? ' checked="checked"' : '') . ' /> <label for="checkForce_all_UIDS"><span class="text-danger">' . $this->lang->getLL('importdata_force_all_UIDS', true) . '</span></label><br/> <em>(' . $this->lang->getLL('importdata_force_all_UIDS_descr', true) . ')</em>' : ''; $row[] = '<tr> <td valign="top"> ' . $this->lang->getLL('importdata_options', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'options') . ' </td> <td> <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ? ' checked="checked"' : '') . ' /> <label for="checkNotShowDiff">' . $this->lang->getLL('importdata_doNotShowDifferences', true) . '</label><br/> <em>(' . $this->lang->getLL('importdata_greenValuesAreFrom', true) . ')</em> <br/><br/> ' . $allowPhpScripts . $doUpdate . ' </td> </tr>'; $newImport = !$inData['import_file'] ? '<input class="btn btn-default" type="submit" value="' . $this->lang->getLL('importdata_preview', true) . '" />' . ($inData['file'] ? ' - <input type="hidden" name="not-set" value="1" id="t3js-submit-field" /><input class="btn btn-default t3js-confirm-trigger" type="button" value="' . ($inData['do_update'] ? $this->lang->getLL('importdata_update_299e', true) : $this->lang->getLL('importdata_import', true)) . '" name="tx_impexp[import_file]" data-title="' . $this->lang->getLL('pleaseConfirm', true) . '" data-message="' . $this->lang->getLL('importdata_areYouSure', true) . '" />' : '') : '<input class="btn btn-default" type="submit" name="tx_impexp[new_import]" value="' . $this->lang->getLL('importdata_newImport', true) . '" />'; $row[] = '<tr> <td valign="top"> ' . $this->lang->getLL('importdata_action', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'action') . ' </td> <td> ' . $newImport . ' <input type="hidden" name="tx_impexp[action]" value="import" /> </td> </tr>'; $row[] = '<tr> <td valign="top"> ' . $this->lang->getLL('importdata_enableLogging', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'enableLogging') . ' </td> <td> <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ? ' checked="checked"' : '') . ' /> <label for="checkEnableLogging">' . $this->lang->getLL('importdata_writeIndividualDbActions', true) . '</label><br/> <em>(' . $this->lang->getLL('importdata_thisIsDisabledBy', true) . ')</em> </td> </tr>'; $menuItems[] = array('label' => $this->lang->getLL('importdata_import', true), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // Upload file: $tempFolder = $this->getDefaultImportExportFolder(); if ($tempFolder) { $row = array(); $row[] = ' <tr> <th colspan="2">' . $this->lang->getLL('importdata_uploadFileFromLocal', true) . '</th> </tr>'; $row[] = ' <tr> <td valign="top"> ' . $this->lang->getLL('importdata_browse', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'upload') . ' </td> <td> <input type="file" name="upload_1" size="40" /> <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder->getCombinedIdentifier()) . '" /> <input type="hidden" name="file[upload][1][data]" value="1" /> <br /> <input class="btn btn-default" type="submit" name="_upload" value="' . $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', true) . '" /> <input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $this->lang->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', true) . '</label> </td> </tr>'; if (GeneralUtility::_POST('_upload')) { $noFileUploaded = $this->fileProcessor->internalUploadMap[1] ? $this->lang->getLL('importdata_success', true) . ' ' . $this->uploadedFiles[0]->getName() : '<span class="text-danger">' . $this->lang->getLL('importdata_failureNoFileUploaded', true) . '</span>'; $row[] = '<tr class="bgColor4"> <td>' . $this->lang->getLL('importdata_uploadStatus', true) . '</td> <td>' . $noFileUploaded . '</td> </tr>'; } $menuItems[] = array('label' => $this->lang->getLL('importdata_upload'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); } // Perform import or preview depending: $overviewContent = ''; $extensionInstallationMessage = ''; $inFile = $this->getFile($inData['file']); if ($inFile !== null && $inFile->exists()) { $trow = array(); if ($import->loadFile($inFile->getForLocalProcessing(false), 1)) { // Check extension dependencies: $extKeysToInstall = array(); if (is_array($import->dat['header']['extensionDependencies'])) { foreach ($import->dat['header']['extensionDependencies'] as $extKey) { if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) { $extKeysToInstall[] = $extKey; } } } if (!empty($extKeysToInstall)) { $extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '".'; } if ($inData['import_file']) { if (empty($extKeysToInstall)) { $import->importData($this->id); BackendUtility::setUpdateSignal('updatePageTree'); } } $import->display_import_pid_record = $this->pageinfo; $overviewContent = $import->displayContentOverview(); } // Meta data output: $trow[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $this->lang->getLL('importdata_metaData', true) . '</strong></td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_title', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['title'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_description', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['description'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_notes', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_packager', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'] . ' (' . $import->dat['header']['meta']['packager_username'] . ')')) . '<br/> ' . $this->lang->getLL('importdata_email', true) . ' ' . $import->dat['header']['meta']['packager_email'] . '</td> </tr>'; // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (GeneralUtility::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb.' . $pI['extension']; GeneralUtility::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="../' . PathUtility::stripPathSitePrefix($fileName) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_icon', true) . '</strong></td> <td>' . $iconTag . '</td> </tr>'; } else { GeneralUtility::unlink_tempfile($fileName); } } } $menuItems[] = array('label' => $this->lang->getLL('importdata_metaData_1387'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $trow) . ' </table> '); } // Print errors that might be: $errors = $import->printErrorLog(); $menuItems[] = array('label' => $this->lang->getLL('importdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0); // Output tabs: $content = $this->moduleTemplate->getDynamicTabMenu($menuItems, 'tx_impexp_import', 1, false, true, false); if ($extensionInstallationMessage) { $content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->moduleTemplate->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content; } $this->content .= $this->moduleTemplate->section('', $content, 0, 1); // Print overview: if ($overviewContent) { $this->content .= $this->moduleTemplate->section($inData['import_file'] ? $this->lang->getLL('importdata_structureHasBeenImported', true) : $this->lang->getLL('filterpage_structureToBeImported', true), $overviewContent, 0, 1); } } }
/** * Rendering the quick-edit view. * * @return string */ public function renderQuickEdit() { $databaseConnection = $this->getDatabaseConnection(); $beUser = $this->getBackendUser(); $lang = $this->getLanguageService(); // Alternative form tag; Quick Edit submits its content to tce_db.php. $this->moduleTemplate->setForm('<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db', ['prErr' => 1, 'uPT' => 1])) . '" method="post" enctype="multipart/form-data" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">'); // Set the edit_record value for internal use in this function: $edit_record = $this->edit_record; // If a command to edit all records in a column is issue, then select all those elements, and redirect to FormEngine if (substr($edit_record, 0, 9) == '_EDIT_COL') { $res = $databaseConnection->exec_SELECTquery('*', 'tt_content', 'pid=' . (int) $this->id . ' AND colPos=' . (int) substr($edit_record, 10) . ' AND sys_language_uid=' . (int) $this->current_sys_language . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting'); $idListA = array(); while ($cRow = $databaseConnection->sql_fetch_assoc($res)) { $idListA[] = $cRow['uid']; } $url = BackendUtility::getModuleUrl('record_edit', array('edit[tt_content][' . implode(',', $idListA) . ']' => 'edit', 'returnUrl' => $this->local_linkThisScript(array('edit_record' => '')))); HttpUtility::redirect($url); } // If the former record edited was the creation of a NEW record, this will look up the created records uid: if ($this->new_unique_uid) { $res = $databaseConnection->exec_SELECTquery('*', 'sys_log', 'userid=' . (int) $beUser->user['uid'] . ' AND NEWid=' . $databaseConnection->fullQuoteStr($this->new_unique_uid, 'sys_log')); $sys_log_row = $databaseConnection->sql_fetch_assoc($res); if (is_array($sys_log_row)) { $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid']; } } $edit_record = $this->makeQuickEditMenu($edit_record); // Splitting the edit-record cmd value into table/uid: $this->eRParts = explode(':', $edit_record); $tableName = $this->eRParts[0]; // Delete-button flag? $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($tableName !== 'pages' && $this->EDIT_CONTENT || $tableName === 'pages' && $this->CALC_PERMS & Permission::PAGE_DELETE); // If undo-button should be rendered (depends on available items in sys_history) $this->undoButton = false; $undoRes = $databaseConnection->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $databaseConnection->fullQuoteStr($tableName, 'sys_history') . ' AND recuid=' . (int) $this->eRParts[1], '', 'tstamp DESC', '1'); if ($this->undoButtonR = $databaseConnection->sql_fetch_assoc($undoRes)) { $this->undoButton = true; } // Setting up the Return URL for coming back to THIS script (if links take the user to another script) $R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI')); $R_URL_getvars = GeneralUtility::_GET(); unset($R_URL_getvars['popView']); unset($R_URL_getvars['new_unique_uid']); $R_URL_getvars['edit_record'] = $edit_record; $this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars); // Creating editing form: $content = ''; if ($edit_record) { // Splitting uid parts for special features, if new: list($uidVal, $neighborRecordUid, $ex_colPos) = explode('/', $this->eRParts[1]); if ($uidVal === 'new') { $command = 'new'; // Page id of this new record $theUid = $this->id; if ($neighborRecordUid) { $theUid = $neighborRecordUid; } } else { $command = 'edit'; $theUid = $uidVal; // Convert $uidVal to workspace version if any: $draftRecord = BackendUtility::getWorkspaceVersionOfRecord($beUser->workspace, $tableName, $theUid, 'uid'); if ($draftRecord) { $theUid = $draftRecord['uid']; } } // @todo: Hack because DatabaseInitializeNewRow reads from _GP directly $GLOBALS['_GET']['defVals'][$tableName] = array('colPos' => (int) $ex_colPos, 'sys_language_uid' => (int) $this->current_sys_language); /** @var TcaDatabaseRecord $formDataGroup */ $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class); /** @var FormDataCompiler $formDataCompiler */ $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup); /** @var NodeFactory $nodeFactory */ $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class); try { $formDataCompilerInput = ['tableName' => $tableName, 'vanillaUid' => (int) $theUid, 'command' => $command]; $formData = $formDataCompiler->compile($formDataCompilerInput); if ($command !== 'new') { BackendUtility::lockRecords($tableName, $formData['databaseRow']['uid'], $tableName === 'tt_content' ? $formData['databaseRow']['pid'] : 0); } $formData['renderType'] = 'outerWrapContainer'; $formResult = $nodeFactory->create($formData)->render(); $panel = $formResult['html']; $formResult['html'] = ''; /** @var FormResultCompiler $formResultCompiler */ $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class); $formResultCompiler->mergeResult($formResult); $row = $formData['databaseRow']; $new_unique_uid = ''; if ($command === 'new') { $new_unique_uid = $row['uid']; } // Add hidden fields: if ($uidVal == 'new') { $panel .= '<input type="hidden" name="data[' . $tableName . '][' . $row['uid'] . '][pid]" value="' . $row['pid'] . '" />'; } $redirect = $uidVal == 'new' ? BackendUtility::getModuleUrl($this->moduleName, ['id' => $this->id, 'new_unique_uid' => $new_unique_uid, 'returnUrl' => $this->returnUrl]) : $this->R_URI; $panel .= ' <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" /> <input type="hidden" name="edit_record" value="' . $edit_record . '" /> <input type="hidden" name="redirect" value="' . htmlspecialchars($redirect) . '" /> '; // Add JavaScript as needed around the form: $content = $formResultCompiler->JStop() . $panel . $formResultCompiler->printNeededJSFunctions(); // Display "is-locked" message: if ($command === 'edit') { $lockInfo = BackendUtility::isRecordLocked($tableName, $formData['databaseRow']['uid']); if ($lockInfo) { /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } } } catch (AccessDeniedException $e) { // If no edit access, print error message: $content = $this->moduleTemplate->section($lang->getLL('noAccess'), $lang->getLL('noAccess_msg') . '<br /><br />' . ($beUser->errorMsg ? 'Reason: ' . $beUser->errorMsg . '<br /><br />' : ''), 0, 1); } } else { // If no edit access, print error message: $content = $this->moduleTemplate->section($lang->getLL('noAccess'), $lang->getLL('noAccess_msg'), 0, 1); } // Element selection matrix: if ($tableName === 'tt_content' && MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) { $content .= '<h2>' . $lang->getLL('CEonThisPage') . '</h2>'; // PositionMap $posMap = GeneralUtility::makeInstance(ContentLayoutPagePositionMap::class); $posMap->cur_sys_language = $this->current_sys_language; $content .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI); // Toggle hidden ContentElements $numberOfHiddenElements = $this->getNumberOfHiddenElements(); if ($numberOfHiddenElements) { $content .= '<div class="checkbox">'; $content .= '<label for="checkTt_content_showHidden">'; $content .= BackendUtility::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], '', '', 'id="checkTt_content_showHidden"'); $content .= !$numberOfHiddenElements ? '<span class="text-muted">' . $lang->getLL('hiddenCE', true) . '</span>' : $lang->getLL('hiddenCE', true) . ' (' . $numberOfHiddenElements . ')'; $content .= '</label>'; $content .= '</div>'; } // CSH $content .= BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement'); } return $content; }
/** * No template * * @param int $newStandardTemplate * @return string */ public function noTemplate($newStandardTemplate = 0) { // Defined global here! /** @var ExtendedTemplateService $tmpl */ $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class); $GLOBALS['tmpl'] = $tmpl; // Do not log time-performance information $tmpl->tt_track = false; $tmpl->init(); $lang = $this->getLanguageService(); $title = $lang->getLL('noTemplate'); $message = '<p>' . $lang->getLL('noTemplateDescription') . '<br />' . $lang->getLL('createTemplateToEditConfiguration') . '</p>'; $view = GeneralUtility::makeInstance(StandaloneView::class); $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html')); $view->assignMultiple(array('title' => $title, 'message' => $message, 'state' => InfoboxViewHelper::STATE_INFO)); $theOutput = $view->render(); // New standard? if ($newStandardTemplate) { // Hook to change output, implemented for statictemplates if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateView'])) { $selector = ''; $staticsText = ''; $reference = array('selectorHtml' => &$selector, 'staticsText' => &$staticsText); GeneralUtility::callUserFunction($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateView'], $reference, $this); $selector = $reference['selectorHtml']; $staticsText = $reference['staticsText']; } else { $selector = '<input type="hidden" name="createStandard" value="" />'; $staticsText = ''; } // Extension? $theOutput .= $this->moduleTemplate->section($lang->getLL('newWebsite') . $staticsText, '<p>' . $lang->getLL('newWebsiteDescription') . '</p>' . $selector . '<input class="btn btn-primary" type="submit" name="newWebsite" value="' . $lang->getLL('newWebsiteAction') . '" />', 0, 1); } // Extension? $theOutput .= $this->moduleTemplate->section($lang->getLL('extTemplate'), '<p>' . $lang->getLL('extTemplateDescription') . '</p>' . '<input class="btn btn-default" type="submit" name="createExtension" value="' . $lang->getLL('extTemplateAction') . '" />', 0, 1); // Go to first appearing... $first = $tmpl->ext_prevPageWithTemplate($this->id, $this->perms_clause); if ($first) { $urlParameters = array('id' => $first['uid']); $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters); $theOutput .= $this->moduleTemplate->section($lang->getLL('goToClosest'), sprintf('<p>' . $lang->getLL('goToClosestDescription') . '</p>%s' . $lang->getLL('goToClosestAction') . '%s', htmlspecialchars($first['title']), $first['uid'], '<a class="btn btn-default" href="' . htmlspecialchars($aHref) . '">', '</a>'), 0, 1); } return $theOutput; }