Commit 1fa6effd authored by Wouter Wolters's avatar Wouter Wolters Committed by Markus Klein
Browse files

[TASK] Upgrade ext:scheduler to a modern file structure

* Move images to Resources/Public/Images/
* Move language files to Resources/Private/Language/
* Migrate ExtJs to jQuery
* Move module template to Resources/Private/Template/
* Add strict comparison were possible

Resolves: #60630
Releases: 6.3
Change-Id: I7bae64263268562b158dccf9b9c8fa6d6726fe52
Reviewed-on: http://review.typo3.org/31875


Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Tested-by: default avatarMarkus Klein <klein.t3@reelworx.at>
parent dc373eeb
=============================================================
Breaking: #60630 - Scheduler Javascript File Moved
=============================================================
Description
===========
Javascript files of the scheduler module moved from EXT:scheduler/res/tx_scheduler_be.js to
EXT:scheduler/Resources/Public/JavaScript/Scheduler.js
Impact
======
Javascript or file not found errors.
Affected installations
======================
An installation is affected if a 3rd party extension includes EXT:scheduler/res/tx_scheduler_be.js
Migration
=========
Include EXT:scheduler/Resources/Public/JavaScript/Scheduler.js instead or refactor the affected extension to free it
from the dependency to this scheduler internal file.
\ No newline at end of file
===========================================================
Breaking: #60630 - Scheduler Language Files Moved
===========================================================
Description
===========
The language files of the scheduler extension are moved to EXT:scheduler/Resources/Private/Language/
Impact
======
Labels are not translated when being fetched from old file location.
Affected installations
======================
A TYPO3 instance is affected if a 3rd party extension uses a language file from EXT:scheduler
or if localization overrides of these files are registered. Those overridden labels may not
work anymore.
Migration
=========
Use new path to language file instead or create/copy the labels to an own language file and
adapt existing overrides to the new file locations.
===========================================================
Breaking: #60630 - Scheduler Module Template File Moved
===========================================================
Description
===========
The HTML template file for the scheduler module was moved from EXT:scheduler/mod1/mod_template.html
to EXT:scheduler/Resources/Private/Templates/Module.html.
Impact
======
Broken module screen.
Affected installations
======================
A TYPO3 instance is affected if a 3rd party extension uses file EXT:scheduler/mod1/mod_template.html
Migration
=========
Use file EXT:scheduler/Resources/Private/Templates/Module.html instead or refactor the affected extension to free it
from the dependency to this scheduler internal file.
......@@ -13,13 +13,14 @@ namespace TYPO3\CMS\Scheduler;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Interface for classes who want to provide additional fields when adding a task
*
* @author Ingo Renner <ingo@typo3.org>
* @author Ingo Renner <ingo@typo3.org>
*/
interface AdditionalFieldProviderInterface
{
interface AdditionalFieldProviderInterface {
/**
* Gets additional fields to render in the form to add/edit a task
*
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Scheduler\CronCommand;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This class provides calculations for the cron command format.
*
......@@ -54,7 +55,7 @@ class CronCommand {
* @return \TYPO3\CMS\Scheduler\CronCommand\CronCommand
*/
public function __construct($cronCommand, $timestamp = FALSE) {
$cronCommand = \TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand::normalize($cronCommand);
$cronCommand = NormalizeCommand::normalize($cronCommand);
// Explode cron command to sections
$this->cronCommandSections = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $cronCommand);
// Initialize the values with the starting time
......@@ -72,6 +73,7 @@ class CronCommand {
*
* @api
* @return void
* @throws \RuntimeException
*/
public function calculateNextValue() {
$newTimestamp = $this->getTimestamp();
......@@ -106,7 +108,7 @@ class CronCommand {
$this->timestamp = $newTimestamp;
}
/*
/**
* Get next timestamp
*
* @api
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Scheduler\CronCommand;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\MathUtility;
/**
......@@ -55,7 +56,6 @@ class NormalizeCommand {
static protected function convertKeywordsToCronCommand($cronCommand) {
switch ($cronCommand) {
case '@yearly':
case '@annually':
$cronCommand = '0 0 1 1 *';
break;
......
......@@ -25,7 +25,7 @@ class SleepTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
/**
* Number of seconds the task should be sleeping for
*
* @var integer $sleepTime
* @var integer
*/
public $sleepTime = 10;
......@@ -50,7 +50,7 @@ class SleepTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
* @return string Information to display
*/
public function getAdditionalInformation() {
return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:label.sleepTime') . ': ' . $this->sleepTime;
return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime') . ': ' . $this->sleepTime;
}
}
......@@ -13,10 +13,11 @@ namespace TYPO3\CMS\Scheduler\Example;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Additional fields provider class for usage with the Scheduler's sleep task
*
* @author François Suter <francois@typo3.org>
* @author François Suter <francois@typo3.org>
*/
class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface {
......@@ -27,15 +28,15 @@ class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additiona
* @param array $taskInfo Reference to the array containing the info used in the add/edit form
* @param object $task When editing, reference to the current task object. Null when adding.
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
* @return array Array containing all the information pertaining to the additional fields
* @return array Array containing all the information pertaining to the additional fields
*/
public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
// Initialize extra field value
if (empty($taskInfo['sleepTime'])) {
if ($parentObject->CMD == 'add') {
if ($parentObject->CMD === 'add') {
// In case of new task and if field is empty, set default sleep time
$taskInfo['sleepTime'] = 30;
} elseif ($parentObject->CMD == 'edit') {
} elseif ($parentObject->CMD === 'edit') {
// In case of edit, set to internal value if no data was submitted already
$taskInfo['sleepTime'] = $task->sleepTime;
} else {
......@@ -49,7 +50,7 @@ class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additiona
$additionalFields = array();
$additionalFields[$fieldID] = array(
'code' => $fieldCode,
'label' => 'LLL:EXT:scheduler/mod1/locallang.xlf:label.sleepTime',
'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime',
'cshKey' => '_MOD_system_txschedulerM1',
'cshLabel' => $fieldID
);
......@@ -67,7 +68,7 @@ class SleepTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additiona
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
$submittedData['sleepTime'] = (int)$submittedData['sleepTime'];
if ($submittedData['sleepTime'] < 0) {
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:msg.invalidSleepTime'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$result = FALSE;
} else {
$result = TRUE;
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Scheduler\Example;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Provides testing procedures
*
......@@ -84,7 +85,7 @@ class TestTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
* @return string Information to display
*/
public function getAdditionalInformation() {
return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:label.email') . ': ' . $this->email;
return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.email') . ': ' . $this->email;
}
}
......@@ -13,10 +13,11 @@ namespace TYPO3\CMS\Scheduler\Example;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Additional fields provider class for usage with the Scheduler's test task
*
* @author François Suter <francois@typo3.org>
* @author François Suter <francois@typo3.org>
*/
class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface {
......@@ -27,15 +28,15 @@ class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additional
* @param array $taskInfo Reference to the array containing the info used in the add/edit form
* @param object $task When editing, reference to the current task object. Null when adding.
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
* @return array Array containing all the information pertaining to the additional fields
* @return array Array containing all the information pertaining to the additional fields
*/
public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
// Initialize extra field value
if (empty($taskInfo['email'])) {
if ($parentObject->CMD == 'add') {
if ($parentObject->CMD === 'add') {
// 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') {
} 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 {
......@@ -49,7 +50,7 @@ class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additional
$additionalFields = array();
$additionalFields[$fieldID] = array(
'code' => $fieldCode,
'label' => 'LLL:EXT:scheduler/mod1/locallang.xlf:label.email',
'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.email',
'cshKey' => '_MOD_system_txschedulerM1',
'cshLabel' => $fieldID
);
......@@ -67,7 +68,7 @@ class TestTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Additional
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
$submittedData['email'] = trim($submittedData['email']);
if (empty($submittedData['email'])) {
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:msg.noEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$result = FALSE;
} else {
$result = TRUE;
......
......@@ -13,47 +13,48 @@ namespace TYPO3\CMS\Scheduler;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This class manages the logic of a particular execution of a task
*
* @author François Suter <francois@typo3.org>
* @author Christian Jul Jensen <julle@typo3.org>
* @author Markus Friedrich <markus.friedrich@dkd.de>
* @author François Suter <francois@typo3.org>
* @author Christian Jul Jensen <julle@typo3.org>
* @author Markus Friedrich <markus.friedrich@dkd.de>
*/
class Execution {
/**
* Start date of a task (timestamp)
*
* @var integer $start
* @var integer
*/
protected $start;
/**
* End date of a task (timestamp)
*
* @var integer $end
* @var integer
*/
protected $end;
/**
* Interval between executions (in seconds)
*
* @var integer $interval
* @var integer
*/
protected $interval;
/**
* Flag for concurrent executions: TRUE if allowed, FALSE otherwise (default)
*
* @var boolean $multiple
* @var boolean
*/
protected $multiple = FALSE;
/**
* The cron command string of this task,
*
* @var string $cronCmd
* @var string
*/
protected $cronCmd;
......@@ -61,7 +62,7 @@ class Execution {
* This flag is used to mark a new single execution
* See explanations in method setIsNewSingleExecution()
*
* @var boolean $isNewSingleExecution
* @var boolean
* @see \TYPO3\CMS\Scheduler\Execution::setIsNewSingleExecution()
*/
protected $isNewSingleExecution = FALSE;
......
......@@ -13,12 +13,12 @@ namespace TYPO3\CMS\Scheduler;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Failed execution exception
*
* @author Ingo Renner <ingo@typo3.org>
* @author Ingo Renner <ingo@typo3.org>
*/
class FailedExecutionException extends \RuntimeException {
}
......@@ -13,12 +13,14 @@ namespace TYPO3\CMS\Scheduler;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Interface for tasks who can provide their progress
*
* @author Ingo Renner <ingo@typo3.org>
*/
interface ProgressProviderInterface {
/**
* Gets the progress of a task.
*
......
......@@ -13,17 +13,18 @@ namespace TYPO3\CMS\Scheduler;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* TYPO3 Scheduler. This class handles scheduling and execution of tasks.
* Formerly known as "Gabriel TYPO3 arch angel"
*
* @author François Suter <francois@typo3.org>
* @author Christian Jul Jensen <julle@typo3.org>
* @author François Suter <francois@typo3.org>
* @author Christian Jul Jensen <julle@typo3.org>
*/
class Scheduler implements \TYPO3\CMS\Core\SingletonInterface {
/**
* @var array $extConf: settings from the extension manager
* @var array $extConf Settings from the extension manager
* @todo Define visibility
*/
public $extConf = array();
......@@ -245,6 +246,8 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface {
*
* @param integer $uid Primary key of a task
* @return \TYPO3\CMS\Scheduler\Task\AbstractTask The fetched task object
* @throws \OutOfBoundsException
* @throws \UnexpectedValueException
*/
public function fetchTask($uid = 0) {
// Define where clause
......@@ -294,7 +297,8 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface {
*
* @param integer $uid Primary key of the task to get
* @return array Database record for the task
* @see tx_scheduler::fetchTask()
* @see \TYPO3\CMS\Scheduler\Scheduler::fetchTask()
* @throws \OutOfBoundsException
*/
public function fetchTaskRecord($uid) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_scheduler_task', 'uid = ' . (int)$uid);
......
......@@ -13,13 +13,14 @@ namespace TYPO3\CMS\Scheduler\Task;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This is the base class for all Scheduler tasks
* It's an abstract class, not designed to be instantiated directly
* All Scheduler tasks should inherit from this class
*
* @author François Suter <francois@typo3.org>
* @author Christian Jul Jensen <julle@typo3.org>
* @author François Suter <francois@typo3.org>
* @author Christian Jul Jensen <julle@typo3.org>
*/
abstract class AbstractTask {
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Scheduler\Task;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Additional BE fields for caching framework garbage collection task.
* Creates a multi selectbox with all available cache backends to select from.
......@@ -33,12 +34,12 @@ class CachingFrameworkGarbageCollectionAdditionalFieldProvider implements \TYPO3
// Initialize selected fields
if (empty($taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'])) {
$taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'] = array();
if ($parentObject->CMD == 'add') {
if ($parentObject->CMD === 'add') {
// In case of new task, set to dbBackend if it's available
if (in_array('TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend', $this->getRegisteredBackends())) {
$taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'][] = 'TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend';
}
} elseif ($parentObject->CMD == 'edit') {
} elseif ($parentObject->CMD === 'edit') {
// In case of editing the task, set to currently selected value
$taskInfo['scheduler_cachingFrameworkGarbageCollection_selectedBackends'] = $task->selectedBackends;
}
......@@ -49,7 +50,7 @@ class CachingFrameworkGarbageCollectionAdditionalFieldProvider implements \TYPO3
$fieldHtml = '<select name="' . $fieldName . '" id="' . $fieldId . '" class="wide" size="10" multiple="multiple">' . $fieldOptions . '</select>';
$additionalFields[$fieldId] = array(
'code' => $fieldHtml,
'label' => 'LLL:EXT:scheduler/mod1/locallang.xlf:label.cachingFrameworkGarbageCollection.selectBackends',
'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.cachingFrameworkGarbageCollection.selectBackends',
'cshKey' => '_MOD_system_txschedulerM1',
'cshLabel' => $fieldId
);
......@@ -69,11 +70,11 @@ class CachingFrameworkGarbageCollectionAdditionalFieldProvider implements \TYPO3
if (is_array($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'])) {
$invalidBackends = array_diff($submittedData['scheduler_cachingFrameworkGarbageCollection_selectedBackends'], $availableBackends);
if (!empty($invalidBackends)) {
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:msg.selectionOfNonExistingCacheBackends'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.selectionOfNonExistingCacheBackends'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$validData = FALSE;
}
} else {
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:msg.noCacheBackendSelected'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noCacheBackendSelected'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
$validData = FALSE;
}
return $validData;
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Scheduler\Task;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Garbage collection of caching framework cache backends.
*
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Scheduler\Task;
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This class provides Scheduler plugin implementation
*
......
......@@ -64,7 +64,7 @@ class FileStorageExtractionAdditionalFieldProvider implements \TYPO3\CMS\Schedul
$fieldConfiguration = array(
'code' => $fieldHtml,
'label' => 'LLL:EXT:scheduler/mod1/locallang.xlf:label.fileStorageIndexing.storage',
'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.fileStorageIndexing.storage',
'cshKey' => '_MOD_system_txschedulerM1',
'cshLabel' => $fieldId
);
......@@ -85,7 +85,7 @@ class FileStorageExtractionAdditionalFieldProvider implements \TYPO3\CMS\Schedul
$fieldConfiguration = array(
'code' => $fieldHtml,
'label' => 'LLL:EXT:scheduler/mod1/locallang.xlf:label.fileStorageExtraction.fileCount',
'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.fileStorageExtraction.fileCount',
'cshKey' => '_MOD_system_txschedulerM1',
'cshLabel' => $fieldId
);
......@@ -100,8 +100,10 @@ class FileStorageExtractionAdditionalFieldProvider implements \TYPO3\CMS\Schedul
* @return boolean True if validation was ok (or selected class is not relevant), false otherwise
*/
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
if (!MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_storage']) ||
!MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_fileCount'])) {
if (
!MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_storage'])
|| !MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_fileCount'])
) {
return FALSE;
} elseif(\TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getStorageObject($submittedData['scheduler_fileStorageIndexing_storage']) === NULL) {
return FALSE;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment