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\Scheduler\Controller\SchedulerModuleController; |
15
|
|
|
use TYPO3\CMS\Scheduler\Task\AbstractTask; |
16
|
|
|
use TYPO3\CMS\Scheduler\Task\Enumeration\Action; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Additional fields for index document task. |
20
|
|
|
* |
21
|
|
|
* @package TYPO3 |
22
|
|
|
* @subpackage dlf |
23
|
|
|
* |
24
|
|
|
* @access public |
25
|
|
|
*/ |
26
|
|
|
class IndexAdditionalFieldProvider extends BaseAdditionalFieldProvider |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Gets additional fields to render in the form to add/edit a task |
30
|
|
|
* |
31
|
|
|
* @param array $taskInfo Values of the fields from the add/edit task form |
32
|
|
|
* @param BaseTask $task The task object being edited. Null when adding a task! |
33
|
|
|
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module |
34
|
|
|
* @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => '')) |
35
|
|
|
*/ |
36
|
|
|
public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule) |
37
|
|
|
{ |
38
|
|
|
$currentSchedulerModuleAction = $schedulerModule->getCurrentAction(); |
39
|
|
|
|
40
|
|
|
/** @var BaseTask $task */ |
41
|
|
|
if ($currentSchedulerModuleAction->equals(Action::EDIT)) { |
42
|
|
|
$taskInfo['dryRun'] = $task->isDryRun(); |
43
|
|
|
$taskInfo['doc'] = $task->getDoc(); |
44
|
|
|
$taskInfo['pid'] = $task->getPid(); |
45
|
|
|
$taskInfo['solr'] = $task->getSolr(); |
46
|
|
|
$taskInfo['owner'] = $task->getOwner(); |
47
|
|
|
$taskInfo['softCommit'] = $task->isSoftCommit(); |
48
|
|
|
} else { |
49
|
|
|
$taskInfo['dryRun'] = false; |
50
|
|
|
$taskInfo['doc'] = 'https://'; |
51
|
|
|
$taskInfo['pid'] = - 1; |
52
|
|
|
$taskInfo['solr'] = - 1; |
53
|
|
|
$taskInfo['owner'] = ''; |
54
|
|
|
$taskInfo['softCommit'] = false; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$additionalFields = []; |
58
|
|
|
|
59
|
|
|
// Checkbox for dry-run |
60
|
|
|
$additionalFields['dryRun'] = $this->getDryRunField($taskInfo['dryRun']); |
61
|
|
|
|
62
|
|
|
// Text field for document URL |
63
|
|
|
$fieldName = 'doc'; |
64
|
|
|
$fieldId = 'task_' . $fieldName; |
65
|
|
|
$fieldHtml = '<input type="text" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="' . $taskInfo[$fieldName] . '" >'; |
66
|
|
|
$additionalFields[$fieldId] = [ |
67
|
|
|
'code' => $fieldHtml, |
68
|
|
|
'label' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_tasks.xlf:additionalFields.doc', |
69
|
|
|
'cshKey' => '_MOD_system_txschedulerM1', |
70
|
|
|
'cshLabel' => $fieldId |
71
|
|
|
]; |
72
|
|
|
|
73
|
|
|
// DropDown for storage page |
74
|
|
|
$additionalFields['pid'] = $this->getPidField($taskInfo['pid']); |
75
|
|
|
|
76
|
|
|
// DropDown for Solr core |
77
|
|
|
$additionalFields['solr'] = $this->getSolrField($taskInfo['solr'], $taskInfo['pid']); |
78
|
|
|
|
79
|
|
|
// Text field for owner |
80
|
|
|
$additionalFields['owner'] = $this->getOwnerField($taskInfo['owner']); |
81
|
|
|
|
82
|
|
|
// Checkbox for soft commit |
83
|
|
|
$additionalFields['softCommit'] = $this->getSoftCommitField($taskInfo['softCommit']); |
84
|
|
|
|
85
|
|
|
return $additionalFields; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|