Bug #4267 ยป 4267.diff
mod1/index.php (working copy) | ||
---|---|---|
// Get the extra fields to display for each task that needs some
|
||
$allAdditionalFields = array();
|
||
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['additionalFields'])) {
|
||
foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['additionalFields'] as $className) {
|
||
$hookObject = t3lib_div::getUserObj($className);
|
||
if ($hookObject instanceof tx_scheduler_AdditionalFieldProvider) {
|
||
$additionalFields = $hookObject->getAdditionalFields($taskInfo, isset($task) ? $task : null, $this);
|
||
$allAdditionalFields = array_merge($allAdditionalFields, $additionalFields);
|
||
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'] as $extensionKey => $tasks) {
|
||
foreach ($tasks as $taskClass => $taskRegistration) {
|
||
if (isset($taskRegistration['additionalFields'])
|
||
&& !empty($taskRegistration['additionalFields'])) {
|
||
$hookObject = t3lib_div::getUserObj($taskRegistration['additionalFields']);
|
||
if ($hookObject instanceof tx_scheduler_AdditionalFieldProvider) {
|
||
$additionalFields = $hookObject->getAdditionalFields($taskInfo, isset($task) ? $task : null, $this);
|
||
$allAdditionalFields = array_merge($allAdditionalFields, $additionalFields);
|
||
}
|
||
}
|
||
}
|
||
}
|
ext_autoload.php (working copy) | ||
---|---|---|
'tx_scheduler_execution' => t3lib_extMgm::extPath('scheduler', 'class.tx_scheduler_execution.php'),
|
||
'tx_scheduler_failedexecutionexception' => t3lib_extMgm::extPath('scheduler', 'class.tx_scheduler_failedexecutionexception.php'),
|
||
'tx_scheduler_testtask' => t3lib_extMgm::extPath('scheduler', 'examples/class.tx_scheduler_testtask.php'),
|
||
'tx_scheduler_testtaskhook' => t3lib_extMgm::extPath('scheduler', 'examples/class.tx_scheduler_testtaskhook.php'),
|
||
'tx_scheduler_testtask_hook' => t3lib_extMgm::extPath('scheduler', 'examples/class.tx_scheduler_testtask_hook.php'),
|
||
'tx_scheduler_sleeptask' => t3lib_extMgm::extPath('scheduler', 'examples/class.tx_scheduler_sleeptask.php'),
|
||
'tx_scheduler_sleeptaskhook' => t3lib_extMgm::extPath('scheduler', 'examples/class.tx_scheduler_sleeptaskhook.php')
|
||
'tx_scheduler_sleeptask_hook' => t3lib_extMgm::extPath('scheduler', 'examples/class.tx_scheduler_sleeptask_hook.php')
|
||
);
|
||
?>
|
ext_localconf.php (working copy) | ||
---|---|---|
// TODO: documentation: new registration syntax
|
||
// TODO: documentation: new syntax for value: filepath:classname
|
||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$_EXTKEY] = array(
|
||
'testtask' => array (
|
||
'class' => 'tx_scheduler_testtask',
|
||
'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:testTask.name',
|
||
'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:testTask.description',
|
||
'hasArguments' => false,
|
||
'tx_scheduler_testtask' => array (
|
||
'class' => 'tx_scheduler_testtask',
|
||
'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:testTask.name',
|
||
'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:testTask.description',
|
||
'hasArguments' => false,
|
||
'additionalFields' => 'tx_scheduler_testtask_hook',
|
||
),
|
||
'sleeptask' => array(
|
||
'class' => 'tx_scheduler_sleeptask',
|
||
'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:sleepTask.name',
|
||
'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:sleepTask.description',
|
||
'hasArguments' => false,
|
||
'tx_scheduler_sleeptask' => array(
|
||
'class' => 'tx_scheduler_sleeptask',
|
||
'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:sleepTask.name',
|
||
'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:sleepTask.description',
|
||
'hasArguments' => false,
|
||
'additionalFields' => 'tx_scheduler_sleeptask_hook',
|
||
)
|
||
);
|
||
// Register the hook for the test task
|
||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['additionalFields'][] = 'EXT:' . $_EXTKEY . '/examples/class.tx_scheduler_testtask_hook.php:&tx_scheduler_testtask_hook';
|
||
// Register the hook for the sleep task
|
||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['additionalFields'][] = 'EXT:' . $_EXTKEY . '/examples/class.tx_scheduler_sleeptask_hook.php:&tx_scheduler_sleeptask_hook';
|
||
?>
|
examples/class.tx_scheduler_testtask_hook.php (working copy) | ||
---|---|---|
// In case of new task and if field is empty, set default email address
|
||
$taskInfo['email'] = $GLOBALS['BE_USER']->user['email'];
|
||
} elseif ($parentObject->CMD == 'edit' && $task instanceof self::$class) {
|
||
} elseif ($parentObject->CMD == 'edit') {
|
||
// In case of edit, and editing a test task, set to internal value if not data was submitted already
|
||
$taskInfo['email'] = $task->email;
|
||
} else {
|
||
... | ... | |
* @return boolean True if validation was ok (or selected class is not relevant), false otherwise
|
||
*/
|
||
public function validateAdditionalFields(array &$submittedData, tx_scheduler_module1 $parentObject) {
|
||
if ($submittedData['class'] == self::$class) {
|
||
$submittedData['email'] = trim($submittedData['email']);
|
||
$submittedData['email'] = trim($submittedData['email']);
|
||
if (empty($submittedData['email'])) {
|
||
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:msg.noEmail'), 3);
|
||
$result = false;
|
||
} else {
|
||
$result = true;
|
||
}
|
||
if (empty($submittedData['email'])) {
|
||
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:msg.noEmail'), 3);
|
||
$result = false;
|
||
} else {
|
||
$result = true;
|
||
}
|
||
... | ... | |
* @param tx_scheduler_Task $task: reference to the current task object
|
||
*/
|
||
public function saveAdditionalFields(array $submittedData, tx_scheduler_Task $task) {
|
||
if ($submittedData['class'] == self::$class) {
|
||
$task->email = $submittedData['email'];
|
||
}
|
||
$task->email = $submittedData['email'];
|
||
}
|
||
}
|
||
examples/class.tx_scheduler_sleeptask_hook.php (working copy) | ||
---|---|---|
if ($parentObject->CMD == 'add') {
|
||
// In case of new task and if field is empty, set default sleep time
|
||
$taskInfo['sleepTime'] = 30;
|
||
} else if ($parentObject->CMD == 'edit' && $task instanceof self::$class) {
|
||
} else if ($parentObject->CMD == 'edit') {
|
||
// In case of edit, and editing a test task, set to internal value if not data was submitted already
|
||
$taskInfo['sleepTime'] = $task->sleepTime;
|
||
} else {
|
||
... | ... | |
* @return boolean True if validation was ok (or selected class is not relevant), false otherwise
|
||
*/
|
||
public function validateAdditionalFields(array &$submittedData, tx_scheduler_module1 $parentObject) {
|
||
if ($submittedData['class'] == self::$class) {
|
||
$submittedData['sleepTime'] = intval($submittedData['sleepTime']);
|
||
$submittedData['sleepTime'] = intval($submittedData['sleepTime']);
|
||
if ($submittedData['sleepTime'] < 0) {
|
||
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:msg.invalidSleepTime'), 3);
|
||
$result = false;
|
||
} else {
|
||
$result = true;
|
||
}
|
||
if ($submittedData['sleepTime'] < 0) {
|
||
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:msg.invalidSleepTime'), 3);
|
||
$result = false;
|
||
} else {
|
||
$result = true;
|
||
}
|
||
return $result;
|
||
}
|
||
... | ... | |
* @param tx_scheduler_Task $task: reference to the current task object
|
||
*/
|
||
public function saveAdditionalFields(array $submittedData, tx_scheduler_Task $task) {
|
||
if ($submittedData['class'] == self::$class) {
|
||
$task->sleepTime = $submittedData['sleepTime'];
|
||
}
|
||
$task->sleepTime = $submittedData['sleepTime'];
|
||
}
|
||
}
|
||