[FEATURE] Add interval presets for cron command field of scheduler task 93/57293/5
authorGeorg Ringer <georg.ringer@gmail.com>
Fri, 22 Jun 2018 12:44:10 +0000 (14:44 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 22 Jun 2018 23:26:25 +0000 (01:26 +0200)
Improve the usability by having presets for the cron command field
of a scheduler task.

Resolves: #44297
Releases: master
Change-Id: Iedf4da6c36bc3a77ac2886401efedbfd491c5005
Reviewed-on: https://review.typo3.org/57293
Reviewed-by: Sebastian Hofer <sebastian.hofer@marit.ag>
Tested-by: Sebastian Hofer <sebastian.hofer@marit.ag>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jonas Götze <jonnsn@gmail.com>
Tested-by: Jonas Götze <jonnsn@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-44297-IntervalPresetsForCronCommandOfSchedulerTask.rst [new file with mode: 0644]
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Resources/Private/Language/locallang.xlf
typo3/sysext/scheduler/Resources/Private/Templates/Backend/SchedulerModule/EditTask.html
typo3/sysext/scheduler/ext_localconf.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-44297-IntervalPresetsForCronCommandOfSchedulerTask.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-44297-IntervalPresetsForCronCommandOfSchedulerTask.rst
new file mode 100644 (file)
index 0000000..97f6bc9
--- /dev/null
@@ -0,0 +1,25 @@
+.. include:: ../../Includes.txt
+
+=====================================================================
+Feature: #44297 - Interval presets for cron command of scheduler task
+=====================================================================
+
+See :issue:`44297`
+
+Description
+===========
+
+To support administrators creating scheduler tasks, presets have been added to the frequency field.
+
+The default presets are:
+
+.. code-block:: php
+
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['frequencyOptions'] = [
+               '0 9,15 * * 1-5' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example1',
+               '0 */2 * * *' =>  'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example2',
+               '*/20 * * * *' =>  'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example3',
+               '0 7 * * 2' =>  'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example4',
+];
+
+.. index:: Backend, ext:scheduler
index f1b2d22..6b6e60c 100644 (file)
@@ -701,6 +701,7 @@ class SchedulerModuleController
         $this->view->assign('returnUrl', (string)GeneralUtility::getIndpEnv('REQUEST_URI'));
         $this->view->assign('table', implode(LF, $table));
         $this->view->assign('now', $this->getServerTime());
+        $this->view->assign('frequencyOptions', (array)$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['frequencyOptions']);
 
         return $this->view->render();
     }
index f0397e9..4d711af 100644 (file)
                        <trans-unit id="label.ipAnonymization.mask.2">
                                <source>Last 2 bytes for IPv4 / Interface &amp; SLA ID for IPv6</source>
                        </trans-unit>
+                       <trans-unit id="command.example1">
+                               <source>Every day-of-week from Monday through Friday. at 09:00 and 15:00</source>
+                       </trans-unit>
+                       <trans-unit id="command.example2">
+                               <source>Every 2 hours</source>
+                       </trans-unit>
+                       <trans-unit id="command.example3">
+                               <source>Every 20 minutes</source>
+                       </trans-unit>
+                       <trans-unit id="command.example4">
+                               <source>Every Tuesday at 07:00</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>
index dce8501..4bb8cea 100644 (file)
     <div class="form-group">
         <f:be.labels.csh table="{csh}" field="task_frequency" label="{lang}label.frequency.long"/>
         <div class="form-control-wrap">
-            <input type="text" name="tx_scheduler[frequency]" class="form-control" id="task_frequency" value="{frequency}">
+          <div class="form-wizards-wrap">
+            <div class="form-wizards-element">
+              <input type="text" name="tx_scheduler[frequency]" class="form-control" id="task_frequency" value="{frequency}">
+            </div>
+            <f:if condition="{frequencyOptions}">
+              <div class="form-wizards-items-aside">
+                <div class="btn-group">
+                  <select
+                    class="form-control tceforms-select tceforms-wizardselect"
+                    onchange="document.getElementById('task_frequency').value=this.options[this.selectedIndex].value;this.blur();this.selectedIndex=0;">
+                    <option></option>
+                    <f:for each="{frequencyOptions}" as="label" key="command">
+                      <option value="{command}">{f:translate(key:label,default:label)} ({command})</option>
+                    </f:for>
+                  </select>
+                </div>
+              </div>
+            </f:if>
+          </div>
         </div>
     </div>
 </div>
index c3c67bc..9d18be8 100644 (file)
@@ -124,3 +124,11 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Sched
     'additionalFields' => \TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableAdditionalFieldProvider::class
 
 ];
+
+// Available frequency options
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['frequencyOptions'] = [
+    '0 9,15 * * 1-5' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example1',
+    '0 */2 * * *' =>  'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example2',
+    '*/20 * * * *' =>  'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example3',
+    '0 7 * * 2' =>  'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example4',
+];