ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCalendarDownloadZipInteraction.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 
19 {
20  const OPTION_DOWNLOAD = 'download';
21  const OPTION_CANCEL = 'cancel';
25  private $logger = null;
26 
27 
28  public function __construct()
29  {
30  $this->logger = $GLOBALS['DIC']->logger()->cal();
31  }
32 
33 
37  public function getInputTypes()
38  {
39  return [
40  new SingleType(StringValue::class),
41  new SingleType(StringValue::class),
42  ];
43  }
44 
45 
49  public function getRemoveOption()
50  {
51  return new UserInteractionOption('remove', self::OPTION_CANCEL);
52  }
53 
54 
58  public function getOutputType()
59  {
60  return new SingleType(StringValue::class);
61  }
62 
63 
67  public function getOptions(array $input)
68  {
69  return [
70  new UserInteractionOption('download', self::OPTION_DOWNLOAD),
71  ];
72  }
73 
74 
78  public function interaction(array $input, Option $user_selected_option, Bucket $bucket)
79  {
80  global $DIC;
81  $zip_name = $input[1];
82  $download_name = $input[0];
83 
84  $this->logger->debug('User interaction download zip ' . $input[0]->getValue() . ' as '
85  . $input[1]->getValue());
86 
87  if ($user_selected_option->getValue() != self::OPTION_DOWNLOAD) {
88  $this->logger->info('Download canceled');
89  // delete zip file
90  $filesystem = $DIC->filesystem()->temp();
91 
92  try {
93  $path = LegacyPathHelper::createRelativePath($zip_name->getValue());
94  } catch (InvalidArgumentException $e) {
95  $path = null;
96  }
97  if (!is_null($path) && $filesystem->has($path)) {
98  $filesystem->deleteDir(dirname($path));
99  }
100 
101  return $input;
102  }
103 
104  $this->logger->info("Delivering File.");
105 
107  $download_name->getValue(),
108  $zip_name->getValue(),
110  );
111 
112  return $input;
113  }
114 }
$path
Definition: aliased.php:25
interaction(array $input, Option $user_selected_option, Bucket $bucket)
getInputTypes()
Type[] A list of types that are taken as input.
global $DIC
Definition: saml.php:7
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.