getLanguageService(); $resultArray = $this->initializeResultArray(); $parameterArray = $this->data['parameterArray']; $itemValue = $parameterArray['itemFormElValue']; $itemName = $parameterArray['itemFormElName']; if (is_array($itemValue) && $itemValue !== []) { $executionDetails = Execution::createFromDetails($itemValue); } else { $executionDetails = new Execution(); // Set the default value to "in 5 minutes" $executionDetails->setStart($this->context->getPropertyFromAspect('date', 'accessTime') + (5 * 60)); } $fieldsHtml = ''; $runningType = GeneralUtility::makeInstance(RadioElement::class); $runningType->data = $this->data; $runningType->data['containerFieldName'] = 'runningType'; $runningType->data['parameterArray']['fieldConf']['label'] = htmlspecialchars($languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:runningType')); $runningType->data['parameterArray']['itemFormElName'] .= '[runningType]'; $runningType->data['parameterArray']['fieldConf']['config']['items'] = [ ['label' => $languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.type.single'), 'value' => 1], ['label' => $languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.type.recurring'), 'value' => 2], ]; $runningType->data['parameterArray']['itemFormElValue'] = $executionDetails->isSingleRun() ? 1 : 2; $runningType->data['parameterArray']['fieldChangeFunc'] = []; $runningType->data['parameterArray']['fieldConf'] = array_replace_recursive($runningType->data['parameterArray']['fieldConf'], $parameterArray['fieldConf']['config']['overrideFieldTca']['runningType'] ?? []); $subFieldResult = $runningType->render(); $resultArray['javaScriptModules'] = array_merge($resultArray['javaScriptModules'], $subFieldResult['javaScriptModules']); $fieldsHtml .= '
' . str_replace('"form-check"', '"form-check form-inline me-2"', $subFieldResult['html']) . '
'; $multiple = GeneralUtility::makeInstance(CheckboxElement::class); $multiple->data = $this->data; $multiple->data['containerFieldName'] = 'multiple'; $multiple->data['parameterArray']['fieldConf']['label'] = htmlspecialchars($languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.parallel.long')); $multiple->data['parameterArray']['itemFormElName'] .= '[multiple]'; $multiple->data['parameterArray']['fieldConf']['config']['items'] = []; $multiple->data['parameterArray']['fieldChangeFunc'] = []; $multiple->data['parameterArray']['itemFormElValue'] = $executionDetails->isParallelExecutionAllowed(); $multiple->data['parameterArray']['fieldConf'] = array_replace_recursive($multiple->data['parameterArray']['fieldConf'], $parameterArray['fieldConf']['config']['overrideFieldTca']['multiple'] ?? []); $subFieldResult = $multiple->render(); $resultArray['javaScriptModules'] = array_merge($resultArray['javaScriptModules'], $subFieldResult['javaScriptModules']); $fieldsHtml .= '
' . $subFieldResult['html'] . '
'; $start = GeneralUtility::makeInstance(DatetimeElement::class); $start->data = $this->data; $start->data['containerFieldName'] = 'start'; $start->data['parameterArray']['fieldConf']['label'] = htmlspecialchars($languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:scheduledFrom')); $start->data['parameterArray']['itemFormElName'] .= '[start]'; $start->data['parameterArray']['itemFormElValue'] = DateTimeFactory::createFromTimestamp($executionDetails->getStart() ?: $this->context->getPropertyFromAspect('date', 'timestamp')); $start->data['parameterArray']['fieldConf'] = array_replace_recursive($start->data['parameterArray']['fieldConf'], $parameterArray['fieldConf']['config']['overrideFieldTca']['start'] ?? []); $subFieldResult = $start->render(); $resultArray['javaScriptModules'] = array_merge($resultArray['javaScriptModules'], $subFieldResult['javaScriptModules']); $fieldsHtml .= '
' . $subFieldResult['html'] . '
'; $end = GeneralUtility::makeInstance(DatetimeElement::class); $end->data = $this->data; $end->data['containerFieldName'] = 'end'; $end->data['parameterArray']['fieldConf']['label'] = htmlspecialchars($languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:scheduledUntil')); $end->data['parameterArray']['itemFormElName'] .= '[end]'; $end->data['parameterArray']['itemFormElValue'] = $executionDetails->getEnd() ? DateTimeFactory::createFromTimestamp($executionDetails->getEnd()) : null; $end->data['parameterArray']['fieldConf'] = array_replace_recursive($end->data['parameterArray']['fieldConf'], $parameterArray['fieldConf']['config']['overrideFieldTca']['end'] ?? []); $subFieldResult = $end->render(); $resultArray['javaScriptModules'] = array_merge($resultArray['javaScriptModules'], $subFieldResult['javaScriptModules']); $fieldsHtml .= '
' . $subFieldResult['html'] . '
'; $frequency = GeneralUtility::makeInstance(InputTextElement::class); $frequency->data = $this->data; $frequency->data['containerFieldName'] = 'frequency'; $frequency->data['parameterArray']['fieldConf']['label'] = htmlspecialchars($languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.frequency.long')); $frequency->data['parameterArray']['itemFormElName'] .= '[frequency]'; $frequency->data['parameterArray']['itemFormElValue'] = $executionDetails->getCronCmd() ?: $executionDetails->getInterval(); $frequency->data['parameterArray']['fieldChangeFunc'] = []; $frequency->data['parameterArray']['fieldConf']['config']['size'] = 40; $frequency->data['parameterArray']['fieldConf'] = array_replace_recursive($frequency->data['parameterArray']['fieldConf'], $parameterArray['fieldConf']['config']['overrideFieldTca']['frequency'] ?? []); $subFieldResult = $frequency->render(); $resultArray['javaScriptModules'] = array_merge($resultArray['javaScriptModules'], $subFieldResult['javaScriptModules']); $fieldsHtml .= '
' . $subFieldResult['html'] . '
'; $fieldInformationResult = $this->renderFieldInformation(); $fieldInformationHtml = $fieldInformationResult['html']; $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false); $html = []; $html[] = ''; $html[] = $fieldInformationHtml; $html[] = '
'; $html[] = '
'; $html[] = '
'; $html[] = '
' . $fieldsHtml . $this->renderServerTime() . '
'; $html[] = '
'; $html[] = '
'; $html[] = '
'; $html[] = '
'; $resultArray['html'] = $this->wrapWithFieldsetAndLegend(implode(LF, $html)); $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/scheduler/form-engine/element/timing-options-element.js'); return $resultArray; } protected function renderServerTime(): string { $view = $this->viewFactory->create( new ViewFactoryData( templateRootPaths: ['EXT:scheduler/Resources/Private/Templates'], partialRootPaths: ['EXT:scheduler/Resources/Private/Partials'], layoutRootPaths: ['EXT:scheduler/Resources/Private/Layouts'], request: $this->data['request'], format: 'html', ) ); $view->assignMultiple([ 'dateFormat' => [ 'day' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?? 'd-m-y', 'time' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] ?? 'H:i', ], ]); return $view->render('ServerTime'); } }