3 final class PhabricatorCalendarICSFileImportEngine
4 extends PhabricatorCalendarICSImportEngine
{
6 const ENGINETYPE
= 'icsfile';
8 public function getImportEngineName() {
9 return pht('Import .ics File');
12 public function getImportEngineTypeName() {
13 return pht('.ics File');
16 public function getImportEngineHint() {
17 return pht('Import an event in ".ics" (iCalendar) format.');
20 public function supportsTriggers(PhabricatorCalendarImport
$import) {
24 public function appendImportProperties(
25 PhabricatorUser
$viewer,
26 PhabricatorCalendarImport
$import,
27 PHUIPropertyListView
$properties) {
29 $phid_key = PhabricatorCalendarImportICSFileTransaction
::PARAMKEY_FILE
;
30 $file_phid = $import->getParameter($phid_key);
32 $properties->addProperty(
34 $viewer->renderHandle($file_phid));
37 public function newEditEngineFields(
38 PhabricatorEditEngine
$engine,
39 PhabricatorCalendarImport
$import) {
42 if ($engine->getIsCreate()) {
43 $fields[] = id(new PhabricatorFileEditField())
44 ->setKey('icsFilePHID')
45 ->setLabel(pht('ICS File'))
46 ->setDescription(pht('ICS file to import.'))
48 PhabricatorCalendarImportICSFileTransaction
::TRANSACTIONTYPE
)
49 ->setConduitDescription(pht('File PHID to import.'))
50 ->setConduitTypeDescription(pht('File PHID.'));
56 public function getDisplayName(PhabricatorCalendarImport
$import) {
57 $filename_key = PhabricatorCalendarImportICSFileTransaction
::PARAMKEY_NAME
;
58 $filename = $import->getParameter($filename_key);
59 if (strlen($filename)) {
60 return pht('ICS File "%s"', $filename);
62 return pht('ICS File');
66 public function importEventsFromSource(
67 PhabricatorUser
$viewer,
68 PhabricatorCalendarImport
$import,
71 $phid_key = PhabricatorCalendarImportICSFileTransaction
::PARAMKEY_FILE
;
72 $file_phid = $import->getParameter($phid_key);
74 $file = id(new PhabricatorFileQuery())
76 ->withPHIDs(array($file_phid))
81 'Unable to load file ("%s") for import.',
85 $data = $file->loadFileData();
87 if ($should_queue && $this->shouldQueueDataImport($data)) {
88 return $this->queueDataImport($import, $data);
91 return $this->importICSData($viewer, $import, $data);
94 public function canDisable(
95 PhabricatorUser
$viewer,
96 PhabricatorCalendarImport
$import) {
100 public function explainCanDisable(
101 PhabricatorUser
$viewer,
102 PhabricatorCalendarImport
$import) {
104 'You can not disable import of an ICS file because the entire import '.
105 'occurs immediately when you upload the file. There is no further '.
106 'activity to disable.');