From eb8d8c017aeb43b8904c18761f0f68dc662ca359 Mon Sep 17 00:00:00 2001 From: Stefan Neufeind <typo3.neufeind@speedpartner.de> Date: Sat, 12 Oct 2013 00:05:36 +0200 Subject: [PATCH] [FEATURE] Description-field for scheduler-jobs Adds a description-textfield for tasks. This will be displayed in the scheduler-list. The description can either be shown as hover (default) or below the job-name, configurable through the extension-settings for "scheduler". Change-Id: If0191da43677fc261cb73257e3ede848a5375d69 Resolves: #52696 Releases: 6.2 Reviewed-on: https://review.typo3.org/24610 Reviewed-by: Philipp Gampe Tested-by: Philipp Gampe Reviewed-by: Anja Leichsenring Tested-by: Anja Leichsenring --- .../Controller/SchedulerModuleController.php | 25 +++++++++++++++++- typo3/sysext/scheduler/Classes/Scheduler.php | 1 + .../scheduler/Classes/Task/AbstractTask.php | 26 +++++++++++++++++++ typo3/sysext/scheduler/ext_conf_template.txt | 3 +++ typo3/sysext/scheduler/ext_tables.sql | 1 + 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php index cf3df77a5c7d..89c4601455b3 100644 --- a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php +++ b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php @@ -565,6 +565,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas $task = unserialize($taskRecord['serialized_task_object']); // Set some task information $taskInfo['disable'] = $taskRecord['disable']; + $taskInfo['description'] = $taskRecord['description']; // Check that the task object is valid if ($this->scheduler->isValidTaskObject($task)) { // The task object is valid, process with fetching current data @@ -775,6 +776,16 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas '0' => array('<td class="td-label">', '</td>') ); $tr++; + // Description + $label = '<label for="task_description">' . $GLOBALS['LANG']->getLL('label.description') . '</label>'; + $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_description', $label); + $table[$tr][] = '<textarea name="tx_scheduler[description]">' . htmlspecialchars($taskInfo['description']) . '</textarea>'; + $tableLayout[$tr] = array( + 'tr' => array('<tr id="task_description_row">', '</tr>'), + 'defCol' => $defaultCell, + '0' => array('<td class="td-label">', '</td>') + ); + $tr++; // Display additional fields foreach ($allAdditionalFields as $class => $fields) { if ($class == $taskInfo['class']) { @@ -1056,7 +1067,15 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas $table[$tr][] = $actions; $table[$tr][] = $schedulerRecord['uid']; $table[$tr][] = $executionStatusOutput; - $table[$tr][] = $name; + if ($schedulerRecord['description'] !== '') { + if (!empty($this->scheduler->extConf['listShowTaskDescriptionAsHover'])) { + $table[$tr][] = '<span title="' . htmlspecialchars($schedulerRecord['description']) . '">' . $name . '</span>'; + } else { + $table[$tr][] = $name . '<br />' . nl2br(htmlspecialchars($schedulerRecord['description'])) . '<br />'; + } + } else { + $table[$tr][] = $name; + } $table[$tr][] = $execType; $table[$tr][] = $frequency; $table[$tr][] = $multiple; @@ -1139,6 +1158,8 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas } // Set disable flag $task->setDisabled($this->submittedData['disable']); + // Set description + $task->setDescription($this->submittedData['description']); // Save additional input values if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields'])) { /** @var $providerObject \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface */ @@ -1176,6 +1197,8 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas } // Set disable flag $task->setDisabled($this->submittedData['disable']); + // Set description + $task->setDescription($this->submittedData['description']); // Add to database $result = $this->scheduler->addTask($task); if ($result) { diff --git a/typo3/sysext/scheduler/Classes/Scheduler.php b/typo3/sysext/scheduler/Classes/Scheduler.php index 11ca473d27ed..222824880810 100644 --- a/typo3/sysext/scheduler/Classes/Scheduler.php +++ b/typo3/sysext/scheduler/Classes/Scheduler.php @@ -233,6 +233,7 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface { $fields = array( 'nextexecution' => $executionTime, 'disable' => $task->isDisabled(), + 'description' => $task->getDescription(), 'serialized_task_object' => serialize($task) ); $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_scheduler_task', 'uid = ' . $taskUid, $fields); diff --git a/typo3/sysext/scheduler/Classes/Task/AbstractTask.php b/typo3/sysext/scheduler/Classes/Task/AbstractTask.php index 694a866d1216..fbc3310e4c01 100644 --- a/typo3/sysext/scheduler/Classes/Task/AbstractTask.php +++ b/typo3/sysext/scheduler/Classes/Task/AbstractTask.php @@ -68,6 +68,13 @@ abstract class AbstractTask { */ protected $executionTime = 0; + /** + * Description for the task + * + * @var string + */ + protected $description = ''; + /** * Constructor */ @@ -187,6 +194,25 @@ abstract class AbstractTask { return $this->executionTime; } + /** + * This method is used to set the description of the task + * + * @param string $description Description + * @return void + */ + public function setDescription($description) { + $this->description = $description; + } + + /** + * This method returns the description of the task + * + * @return string Description + */ + public function getDescription() { + return $this->description; + } + /** * Sets the internal reference to the singleton instance of the Scheduler * diff --git a/typo3/sysext/scheduler/ext_conf_template.txt b/typo3/sysext/scheduler/ext_conf_template.txt index ef47da024410..78ef2dda001f 100644 --- a/typo3/sysext/scheduler/ext_conf_template.txt +++ b/typo3/sysext/scheduler/ext_conf_template.txt @@ -9,3 +9,6 @@ showSampleTasks = 1 # cat=basic//; type=boolean; label=Use "at"-daemon: This allows automatic scheduling of the next execution of the scheduler. Your system must have the at daemon installed and configured for the user PHP runs with. useAtdaemon = 0 + +# cat=basic//; type=boolean; label=Show description of tasks as hover: If disabled descriptions of tasks will be shown below the job-name in the scheduler-list +listShowTaskDescriptionAsHover = 1 diff --git a/typo3/sysext/scheduler/ext_tables.sql b/typo3/sysext/scheduler/ext_tables.sql index bbe3a6380f6c..4fe7e64617a4 100755 --- a/typo3/sysext/scheduler/ext_tables.sql +++ b/typo3/sysext/scheduler/ext_tables.sql @@ -5,6 +5,7 @@ CREATE TABLE tx_scheduler_task ( uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment, crdate int(11) unsigned DEFAULT '0' NOT NULL, disable tinyint(4) unsigned DEFAULT '0' NOT NULL, + description text NOT NULL, nextexecution int(11) unsigned DEFAULT '0' NOT NULL, lastexecution_time int(11) unsigned DEFAULT '0' NOT NULL, lastexecution_failure text NOT NULL, -- GitLab