[TASK] Add save only button to Scheduler task 81/17681/2
authorLorenz Ulrich <lorenz.ulrich@visol.ch>
Fri, 18 Jan 2013 14:17:06 +0000 (15:17 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 23 Jan 2013 22:47:18 +0000 (23:47 +0100)
Scheduler tasks currently miss a save only button. Since Firefox and
Opera don't send the value of an <input type="submit">, the save and
save & close buttons are wrapped in a <button type="submit"> to ensure
saving and saving & closing is cross-browser compatible.

Change-Id: Ia5e32efc2e5e2af2943374c9a570a3a94b0511b4
Fixes: #44152
Releases: 6.1, 6.0, 4.7
Reviewed-on: https://review.typo3.org/17681
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/mod1/mod_template.html

index e9199ba..3de68dc 100644 (file)
@@ -158,15 +158,23 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                $this->submittedData = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged('tx_scheduler');
                $this->submittedData['uid'] = intval($this->submittedData['uid']);
                // If a save command was submitted, handle saving now
-               if ($this->CMD == 'save') {
+               if ($this->CMD == 'save' || $this->CMD == 'saveclose') {
                        $previousCMD = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('previousCMD');
                        // First check the submitted data
                        $result = $this->preprocessData();
                        // If result is ok, proceed with saving
                        if ($result) {
                                $this->saveTask();
-                               // Unset command, so that default screen gets displayed
-                               unset($this->CMD);
+                               if ($this->CMD == 'saveclose') {
+                                       // Unset command, so that default screen gets displayed
+                                       unset($this->CMD);
+                               } elseif ($this->CMD == 'save') {
+                                       // After saving a "add form", return to edit
+                                       $this->CMD = 'edit';
+                               } else {
+                                       // Return to edit form
+                                       $this->CMD = $previousCMD;
+                               }
                        } else {
                                $this->CMD = $previousCMD;
                        }
@@ -651,14 +659,13 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                // Start rendering the add/edit form
                $content .= '<input type="hidden" name="tx_scheduler[uid]" value="' . $this->submittedData['uid'] . '" />';
                $content .= '<input type="hidden" name="previousCMD" value="' . $this->CMD . '" />';
-               $content .= '<input type="hidden" name="CMD" value="save" />';
                $table = array();
                $tr = 0;
                $defaultCell = array('<td class="td-input">', '</td>');
                // Disable checkbox
                $label = '<label for="task_disable">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disable') . '</label>';
                $table[$tr][] = \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp($this->cshKey, 'task_disable', $label);
-               $table[$tr][] = '<input type="hidden"   name="tx_scheduler[disable]" value="0" />
+               $table[$tr][] = '<input type="hidden" name="tx_scheduler[disable]" value="0" />
                         <input type="checkbox" name="tx_scheduler[disable]" value="1" id="task_disable"' . ($taskInfo['disable'] == 1 ? ' checked="checked"' : '') . ' />';
                $tableLayout[$tr] = array(
                        'tr' => array('<tr id="task_disable_row">', '</tr>'),
@@ -1160,6 +1167,10 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                        if ($result) {
                                $GLOBALS['BE_USER']->writeLog(4, 0, 0, 0, 'Scheduler task "%s" (UID: %s, Class: "%s") was added', array($task->getTaskTitle(), $task->getTaskUid(), $task->getTaskClassName()));
                                $this->addMessage($GLOBALS['LANG']->getLL('msg.addSuccess'));
+
+                               // set the uid of the just created task so that we
+                               // can continue editing after initial saving
+                               $this->submittedData['uid'] = $task->getTaskUid();
                        } else {
                                $this->addMessage($GLOBALS['LANG']->getLL('msg.addError'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                        }
@@ -1381,6 +1392,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                        'addtask' => '',
                        'close' => '',
                        'save' => '',
+                       'saveclose' => '',
                        'reload' => '',
                        'shortcut' => $this->getShortcutButton()
                );
@@ -1394,7 +1406,8 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                }
                if ($this->CMD === 'add' || $this->CMD === 'edit') {
                        $buttons['close'] = '<a href="#" onclick="document.location=\'' . $GLOBALS['MCONF']['_'] . '\'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:cancel', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-close') . '</a>';
-                       $buttons['save'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save-close', array('html' => '<input type="image" name="data[save]" class="c-inputButton" src="clear.gif" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:saveAndClose', TRUE) . '" />'));
+                       $buttons['save'] = '<button style="padding: 0; margin: 0; cursor: pointer;" type="submit" name="CMD" value="save" class="c-inputButton" src="clear.gif" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:save', TRUE) . '" />' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save') . '</button>';
+                       $buttons['saveclose'] = '<button style="padding: 0; margin: 0; cursor: pointer;" type="submit" name="CMD" value="saveclose" class="c-inputButton" src="clear.gif" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:saveAndClose', TRUE) . '" />' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save-close') . '</button>';
                }
                return $buttons;
        }
index d18e5df..923e13f 100644 (file)
@@ -26,7 +26,7 @@
 <!-- ###BUTTON_GROUP_WRAP### -->
 
 <!-- ###BUTTON_GROUPS_LEFT### -->
-<!-- ###BUTTON_GROUP1### -->###ADDTASK######CLOSE######SAVE###<!-- ###BUTTON_GROUP1### -->
+<!-- ###BUTTON_GROUP1### -->###ADDTASK######CLOSE######SAVE######SAVECLOSE###<!-- ###BUTTON_GROUP1### -->
 <!-- ###BUTTON_GROUPS_LEFT### -->
 
 <!-- ###BUTTON_GROUPS_RIGHT### -->