Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarImportEditEngine
4
extends PhabricatorEditEngine {
5
6
const ENGINECONST = 'calendar.import';
7
8
private $importEngine;
9
10
public function setImportEngine(PhabricatorCalendarImportEngine $engine) {
11
$this->importEngine = $engine;
12
return $this;
13
}
14
15
public function getImportEngine() {
16
return $this->importEngine;
17
}
18
19
public function getEngineName() {
20
return pht('Calendar Imports');
21
}
22
23
public function isEngineConfigurable() {
24
return false;
25
}
26
27
public function getSummaryHeader() {
28
return pht('Configure Calendar Import Forms');
29
}
30
31
public function getSummaryText() {
32
return pht('Configure how users create and edit imports.');
33
}
34
35
public function getEngineApplicationClass() {
36
return 'PhabricatorCalendarApplication';
37
}
38
39
protected function newEditableObject() {
40
$viewer = $this->getViewer();
41
$engine = $this->getImportEngine();
42
43
return PhabricatorCalendarImport::initializeNewCalendarImport(
44
$viewer,
45
$engine);
46
}
47
48
protected function newObjectQuery() {
49
return new PhabricatorCalendarImportQuery();
50
}
51
52
protected function getObjectCreateTitleText($object) {
53
return pht('Create New Import');
54
}
55
56
protected function getObjectEditTitleText($object) {
57
return pht('Edit Import: %s', $object->getDisplayName());
58
}
59
60
protected function getObjectEditShortText($object) {
61
return pht('Import %d', $object->getID());
62
}
63
64
protected function getObjectCreateShortText() {
65
return pht('Create Import');
66
}
67
68
protected function getObjectName() {
69
return pht('Import');
70
}
71
72
protected function getObjectViewURI($object) {
73
return $object->getURI();
74
}
75
76
protected function getEditorURI() {
77
return $this->getApplication()->getApplicationURI('import/edit/');
78
}
79
80
protected function buildCustomEditFields($object) {
81
$viewer = $this->getViewer();
82
83
$engine = $object->getEngine();
84
$can_trigger = $engine->supportsTriggers($object);
85
86
$fields = array(
87
id(new PhabricatorTextEditField())
88
->setKey('name')
89
->setLabel(pht('Name'))
90
->setDescription(pht('Name of the import.'))
91
->setTransactionType(
92
PhabricatorCalendarImportNameTransaction::TRANSACTIONTYPE)
93
->setConduitDescription(pht('Rename the import.'))
94
->setConduitTypeDescription(pht('New import name.'))
95
->setPlaceholder($object->getDisplayName())
96
->setValue($object->getName()),
97
id(new PhabricatorBoolEditField())
98
->setKey('disabled')
99
->setOptions(pht('Active'), pht('Disabled'))
100
->setLabel(pht('Disabled'))
101
->setDescription(pht('Disable the import.'))
102
->setTransactionType(
103
PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
104
->setIsFormField(false)
105
->setConduitDescription(pht('Disable or restore the import.'))
106
->setConduitTypeDescription(pht('True to cancel the import.'))
107
->setValue($object->getIsDisabled()),
108
id(new PhabricatorBoolEditField())
109
->setKey('delete')
110
->setLabel(pht('Delete Imported Events'))
111
->setDescription(pht('Delete all events from this source.'))
112
->setTransactionType(
113
PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
114
->setIsFormField(false)
115
->setConduitDescription(pht('Disable or restore the import.'))
116
->setConduitTypeDescription(pht('True to delete imported events.'))
117
->setValue(false),
118
id(new PhabricatorBoolEditField())
119
->setKey('reload')
120
->setLabel(pht('Reload Import'))
121
->setDescription(pht('Reload events imported from this source.'))
122
->setTransactionType(
123
PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
124
->setIsFormField(false)
125
->setConduitDescription(pht('Disable or restore the import.'))
126
->setConduitTypeDescription(pht('True to reload the import.'))
127
->setValue(false),
128
);
129
130
if ($can_trigger) {
131
$frequency_map = PhabricatorCalendarImport::getTriggerFrequencyMap();
132
$frequency_options = ipull($frequency_map, 'name');
133
134
$fields[] = id(new PhabricatorSelectEditField())
135
->setKey('frequency')
136
->setLabel(pht('Update Automatically'))
137
->setDescription(pht('Configure an automatic update frequency.'))
138
->setTransactionType(
139
PhabricatorCalendarImportFrequencyTransaction::TRANSACTIONTYPE)
140
->setConduitDescription(pht('Set the automatic update frequency.'))
141
->setConduitTypeDescription(pht('Update frequency constant.'))
142
->setValue($object->getTriggerFrequency())
143
->setOptions($frequency_options);
144
}
145
146
$import_engine = $object->getEngine();
147
foreach ($import_engine->newEditEngineFields($this, $object) as $field) {
148
$fields[] = $field;
149
}
150
151
return $fields;
152
}
153
154
155
}
156
157