| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * (c) Kitodo. Key to digital objects e.V. <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This file is part of the Kitodo and TYPO3 projects. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @license GNU General Public License version 3 or later. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * For the full copyright and license information, please read the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * LICENSE.txt file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace Kitodo\Dlf\Task; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use TYPO3\CMS\Core\Database\Connection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use TYPO3\CMS\Core\Database\ConnectionPool; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use TYPO3\CMS\Scheduler\Task\Enumeration\Action; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Additional fields for reindex documents task. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @package TYPO3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @subpackage dlf | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | class OptimizeAdditionalFieldProvider extends BaseAdditionalFieldProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * Gets additional fields to render in the form to add/edit a task | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @param array $taskInfo Values of the fields from the add/edit task form | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @param BaseTask $task The task object being edited. Null when adding a task! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => '')) | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 37 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule) | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |         $currentSchedulerModuleAction = $schedulerModule->getCurrentAction(); | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |         /** @var BaseTask $task */ | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         if ($currentSchedulerModuleAction->equals(Action::EDIT)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |             $taskInfo['solr'] = $task->getSolr(); | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |             $taskInfo['commit'] = $task->isCommit(); | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |             $taskInfo['optimize'] = $task->isOptimize(); | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |             $taskInfo['solr'] = - 1; | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |             $taskInfo['commit'] = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |             $taskInfo['optimize'] = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         $additionalFields = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |         // DropDown for Solr core | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         $additionalFields['solr'] = $this->getSolrField($taskInfo['solr']); | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         // Checkbox for commit | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |         $fieldName = 'commit'; | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         $fieldId = 'task_' . $fieldName; | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         $fieldHtml = '<input type="checkbox" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="1"' . ($taskInfo['commit'] ? ' checked="checked"' : '') . '>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |         $additionalFields[$fieldId] = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |             'code' => $fieldHtml, | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |             'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.commit', | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |             'cshKey' => '_MOD_system_txschedulerM1', | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |             'cshLabel' => $fieldId | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |         // Checkbox for optimize | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |         $fieldName = 'optimize'; | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |         $fieldId = 'task_' . $fieldName; | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |         $fieldHtml = '<input type="checkbox" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="1"' . ($taskInfo['optimize'] ? ' checked="checked"' : '') . '>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |         $additionalFields[$fieldId] = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |             'code' => $fieldHtml, | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |             'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.optimize', | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |             'cshKey' => '_MOD_system_txschedulerM1', | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |             'cshLabel' => $fieldId | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |         return $additionalFields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 82 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 83 |  |  |  |