‪TYPO3CMS  9.5
RecyclerGarbageCollectionAdditionalFieldProvider.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 
21 
30 {
36  protected ‪$defaultNumberOfDays = 30;
37 
47  public function ‪getAdditionalFields(array &$taskInfo, $task, ‪SchedulerModuleController $schedulerModule)
48  {
49  $currentSchedulerModuleAction = $schedulerModule->‪getCurrentAction();
50 
51  // Initialize selected fields
52  if (!isset($taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'])) {
53  $taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'] = ‪$this->defaultNumberOfDays;
54  if ($currentSchedulerModuleAction->equals(‪Action::EDIT)) {
55  $taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'] = $task->numberOfDays;
56  }
57  }
58  $fieldName = 'tx_scheduler[scheduler_recyclerGarbageCollection_numberOfDays]';
59  $fieldId = 'task_recyclerGarbageCollection_numberOfDays';
60  $fieldValue = (int)$taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'];
61  $fieldHtml = '<input class="form-control" type="text" name="' . $fieldName . '" id="' . $fieldId . '" value="' . htmlspecialchars($fieldValue) . '">';
62  $additionalFields[$fieldId] = [
63  'code' => $fieldHtml,
64  'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.recyclerGarbageCollection.numberOfDays',
65  'cshKey' => '_MOD_system_txschedulerM1',
66  'cshLabel' => $fieldId
67  ];
68  return $additionalFields;
69  }
70 
78  public function ‪validateAdditionalFields(array &$submittedData, ‪SchedulerModuleController $schedulerModule)
79  {
80  $result = true;
81  // Check if number of days is indeed a number and greater or equals to 0
82  // If not, fail validation and issue error message
83  if (!is_numeric($submittedData['scheduler_recyclerGarbageCollection_numberOfDays']) || (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'] < 0) {
84  $result = false;
85  $this->‪addMessage(‪$GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), ‪FlashMessage::ERROR);
86  }
87  return $result;
88  }
89 
96  public function ‪saveAdditionalFields(array $submittedData, ‪AbstractTask $task)
97  {
98  $task->numberOfDays = (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'];
99  }
100 }
‪TYPO3\CMS\Scheduler\Task\RecyclerGarbageCollectionAdditionalFieldProvider
Definition: RecyclerGarbageCollectionAdditionalFieldProvider.php:30
‪TYPO3\CMS\Scheduler\Task
Definition: AbstractTask.php:2
‪TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider
Definition: AbstractAdditionalFieldProvider.php:26
‪TYPO3\CMS\Scheduler\Task\RecyclerGarbageCollectionAdditionalFieldProvider\getAdditionalFields
‪array getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
Definition: RecyclerGarbageCollectionAdditionalFieldProvider.php:46
‪TYPO3\CMS\Scheduler\Task\RecyclerGarbageCollectionAdditionalFieldProvider\validateAdditionalFields
‪bool validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
Definition: RecyclerGarbageCollectionAdditionalFieldProvider.php:77
‪TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider\addMessage
‪addMessage(string $message, int $severity=FlashMessage::OK)
Definition: AbstractAdditionalFieldProvider.php:33
‪TYPO3\CMS\Scheduler\Task\RecyclerGarbageCollectionAdditionalFieldProvider\$defaultNumberOfDays
‪int $defaultNumberOfDays
Definition: RecyclerGarbageCollectionAdditionalFieldProvider.php:35
‪TYPO3\CMS\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:32
‪TYPO3\CMS\Scheduler\Controller\SchedulerModuleController
Definition: SchedulerModuleController.php:53
‪TYPO3\CMS\Scheduler\Task\Enumeration\Action\EDIT
‪const EDIT
Definition: Action.php:28
‪TYPO3\CMS\Scheduler\Controller\SchedulerModuleController\getCurrentAction
‪Action getCurrentAction()
Definition: SchedulerModuleController.php:198
‪TYPO3\CMS\Scheduler\Task\RecyclerGarbageCollectionAdditionalFieldProvider\saveAdditionalFields
‪saveAdditionalFields(array $submittedData, AbstractTask $task)
Definition: RecyclerGarbageCollectionAdditionalFieldProvider.php:95
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:22
‪TYPO3\CMS\Scheduler\Task\Enumeration\Action
Definition: Action.php:24
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29