TYPO3 CMS  TYPO3_7-6
SleepTaskAdditionalFieldProvider.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
33  public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
34  {
35  // Initialize extra field value
36  if (empty($taskInfo['sleepTime'])) {
37  if ($parentObject->CMD === 'add') {
38  // In case of new task and if field is empty, set default sleep time
39  $taskInfo['sleepTime'] = 30;
40  } elseif ($parentObject->CMD === 'edit') {
41  // In case of edit, set to internal value if no data was submitted already
42  $taskInfo['sleepTime'] = $task->sleepTime;
43  } else {
44  // Otherwise set an empty value, as it will not be used anyway
45  $taskInfo['sleepTime'] = '';
46  }
47  }
48  // Write the code for the field
49  $fieldID = 'task_sleepTime';
50  $fieldCode = '<input type="text" class="form-control" name="tx_scheduler[sleepTime]" id="' . $fieldID . '" value="' . $taskInfo['sleepTime'] . '" size="10">';
51  $additionalFields = [];
52  $additionalFields[$fieldID] = [
53  'code' => $fieldCode,
54  'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime',
55  'cshKey' => '_MOD_system_txschedulerM1',
56  'cshLabel' => $fieldID
57  ];
58  return $additionalFields;
59  }
60 
69  public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
70  {
71  $submittedData['sleepTime'] = (int)$submittedData['sleepTime'];
72  if ($submittedData['sleepTime'] < 0) {
73  $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
74  $result = false;
75  } else {
76  $result = true;
77  }
78  return $result;
79  }
80 
89  public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
90  {
91  $task->sleepTime = $submittedData['sleepTime'];
92  }
93 }
getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']