[TASK] Remove superfluous parenthesis in sysexts
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / Classes / Example / TestTaskAdditionalFieldProvider.php
1 <?php
2 namespace TYPO3\CMS\Scheduler\Example;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009-2011 Fran├žois Suter <francois@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Aditional fields provider class for usage with the Scheduler's test task
28 *
29 * @author Fran├žois Suter <francois@typo3.org>
30 * @package TYPO3
31 * @subpackage tx_scheduler
32 */
33 class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface {
34
35 /**
36 * This method is used to define new fields for adding or editing a task
37 * In this case, it adds an email field
38 *
39 * @param array $taskInfo Reference to the array containing the info used in the add/edit form
40 * @param object $task When editing, reference to the current task object. Null when adding.
41 * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
42 * @return array Array containing all the information pertaining to the additional fields
43 */
44 public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
45 // Initialize extra field value
46 if (empty($taskInfo['email'])) {
47 if ($parentObject->CMD == 'add') {
48 // In case of new task and if field is empty, set default email address
49 $taskInfo['email'] = $GLOBALS['BE_USER']->user['email'];
50 } elseif ($parentObject->CMD == 'edit') {
51 // In case of edit, and editing a test task, set to internal value if not data was submitted already
52 $taskInfo['email'] = $task->email;
53 } else {
54 // Otherwise set an empty value, as it will not be used anyway
55 $taskInfo['email'] = '';
56 }
57 }
58 // Write the code for the field
59 $fieldID = 'task_email';
60 $fieldCode = '<input type="text" name="TYPO3\\CMS\\Scheduler\\Scheduler[email]" id="' . $fieldID . '" value="' . htmlspecialchars($taskInfo['email']) . '" size="30" />';
61 $additionalFields = array();
62 $additionalFields[$fieldID] = array(
63 'code' => $fieldCode,
64 'label' => 'LLL:EXT:scheduler/mod1/locallang.xml:label.email',
65 'cshKey' => '_MOD_tools_txschedulerM1',
66 'cshLabel' => $fieldID
67 );
68 return $additionalFields;
69 }
70
71 /**
72 * This method checks any additional data that is relevant to the specific task
73 * If the task class is not relevant, the method is expected to return TRUE
74 *
75 * @param array $submittedData Reference to the array containing the data submitted by the user
76 * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
77 * @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
78 */
79 public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
80 $submittedData['email'] = trim($submittedData['email']);
81 if (empty($submittedData['email'])) {
82 $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:msg.noEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
83 $result = FALSE;
84 } else {
85 $result = TRUE;
86 }
87 return $result;
88 }
89
90 /**
91 * This method is used to save any additional input into the current task object
92 * if the task class matches
93 *
94 * @param array $submittedData Array containing the data submitted by the user
95 * @param \TYPO3\CMS\Scheduler\Task $task Reference to the current task object
96 * @return void
97 */
98 public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task $task) {
99 $task->email = $submittedData['email'];
100 }
101
102 }
103
104
105 ?>