TYPO3 CMS  TYPO3_7-6
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 
24 {
30  protected $defaultNumberOfDays = 30;
31 
41  public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
42  {
43  // Initialize selected fields
44  if (!isset($taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'])) {
45  $taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'] = $this->defaultNumberOfDays;
46  if ($parentObject->CMD === 'edit') {
47  $taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'] = $task->numberOfDays;
48  }
49  }
50  $fieldName = 'tx_scheduler[scheduler_recyclerGarbageCollection_numberOfDays]';
51  $fieldId = 'task_recyclerGarbageCollection_numberOfDays';
52  $fieldValue = (int)$taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'];
53  $fieldHtml = '<input class="form-control" type="text" name="' . $fieldName . '" id="' . $fieldId . '" value="' . htmlspecialchars($fieldValue) . '">';
54  $additionalFields[$fieldId] = [
55  'code' => $fieldHtml,
56  'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.recyclerGarbageCollection.numberOfDays',
57  'cshKey' => '_MOD_system_txschedulerM1',
58  'cshLabel' => $fieldId
59  ];
60  return $additionalFields;
61  }
62 
70  public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
71  {
72  $result = true;
73  // Check if number of days is indeed a number and greater or equals to 0
74  // If not, fail validation and issue error message
75  if (!is_numeric($submittedData['scheduler_recyclerGarbageCollection_numberOfDays']) || (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'] < 0) {
76  $result = false;
77  $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidNumberOfDays'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
78  }
79  return $result;
80  }
81 
89  public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
90  {
91  $task->numberOfDays = (int)$submittedData['scheduler_recyclerGarbageCollection_numberOfDays'];
92  }
93 }
saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
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']