|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 François Suter <francois@typo3.org> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * Aditional fields provider class for usage with the Scheduler's test task 00027 * 00028 * @author François Suter <francois@typo3.org> 00029 * @package TYPO3 00030 * @subpackage tx_scheduler 00031 * 00032 * $Id: class.tx_scheduler_testtask_additionalfieldprovider.php 10120 2011-01-18 20:03:36Z ohader $ 00033 */ 00034 class tx_scheduler_TestTask_AdditionalFieldProvider implements tx_scheduler_AdditionalFieldProvider { 00035 00036 /** 00037 * This method is used to define new fields for adding or editing a task 00038 * In this case, it adds an email field 00039 * 00040 * @param array $taskInfo: reference to the array containing the info used in the add/edit form 00041 * @param object $task: when editing, reference to the current task object. Null when adding. 00042 * @param tx_scheduler_Module $parentObject: reference to the calling object (Scheduler's BE module) 00043 * @return array Array containg all the information pertaining to the additional fields 00044 * The array is multidimensional, keyed to the task class name and each field's id 00045 * For each field it provides an associative sub-array with the following: 00046 * ['code'] => The HTML code for the field 00047 * ['label'] => The label of the field (possibly localized) 00048 * ['cshKey'] => The CSH key for the field 00049 * ['cshLabel'] => The code of the CSH label 00050 */ 00051 public function getAdditionalFields(array &$taskInfo, $task, tx_scheduler_Module $parentObject) { 00052 00053 // Initialize extra field value 00054 if (empty($taskInfo['email'])) { 00055 if ($parentObject->CMD == 'add') { 00056 // In case of new task and if field is empty, set default email address 00057 $taskInfo['email'] = $GLOBALS['BE_USER']->user['email']; 00058 00059 } elseif ($parentObject->CMD == 'edit') { 00060 // In case of edit, and editing a test task, set to internal value if not data was submitted already 00061 $taskInfo['email'] = $task->email; 00062 } else { 00063 // Otherwise set an empty value, as it will not be used anyway 00064 $taskInfo['email'] = ''; 00065 } 00066 } 00067 00068 // Write the code for the field 00069 $fieldID = 'task_email'; 00070 $fieldCode = '<input type="text" name="tx_scheduler[email]" id="' . $fieldID . '" value="' . $taskInfo['email'] . '" size="30" />'; 00071 $additionalFields = array(); 00072 $additionalFields[$fieldID] = array( 00073 'code' => $fieldCode, 00074 'label' => 'LLL:EXT:scheduler/mod1/locallang.xml:label.email', 00075 'cshKey' => '_MOD_tools_txschedulerM1', 00076 'cshLabel' => $fieldID 00077 ); 00078 00079 return $additionalFields; 00080 } 00081 00082 /** 00083 * This method checks any additional data that is relevant to the specific task 00084 * If the task class is not relevant, the method is expected to return true 00085 * 00086 * @param array $submittedData: reference to the array containing the data submitted by the user 00087 * @param tx_scheduler_Module $parentObject: reference to the calling object (Scheduler's BE module) 00088 * @return boolean True if validation was ok (or selected class is not relevant), false otherwise 00089 */ 00090 public function validateAdditionalFields(array &$submittedData, tx_scheduler_Module $parentObject) { 00091 $submittedData['email'] = trim($submittedData['email']); 00092 00093 if (empty($submittedData['email'])) { 00094 $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:msg.noEmail'), t3lib_FlashMessage::ERROR); 00095 $result = false; 00096 } else { 00097 $result = true; 00098 } 00099 00100 return $result; 00101 } 00102 00103 /** 00104 * This method is used to save any additional input into the current task object 00105 * if the task class matches 00106 * 00107 * @param array $submittedData: array containing the data submitted by the user 00108 * @param tx_scheduler_Task $task: reference to the current task object 00109 * @return void 00110 */ 00111 public function saveAdditionalFields(array $submittedData, tx_scheduler_Task $task) { 00112 $task->email = $submittedData['email']; 00113 } 00114 } 00115 00116 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/examples/class.tx_scheduler_testtask_additionalfieldprovider.php'])) { 00117 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/examples/class.tx_scheduler_testtask_additionalfieldprovider.php']); 00118 } 00119 00120 ?>
1.8.0