ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestExportOptionARC Class Reference
+ Inheritance diagram for ilTestExportOptionARC:
+ Collaboration diagram for ilTestExportOptionARC:

Public Member Functions

 init (Container $DIC)
 
 getExportType ()
 
 getExportOptionId ()
 
 getSupportedRepositoryObjectTypes ()
 
 getLabel ()
 
 onDeleteFiles (ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
 
 onDownloadFiles (ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
 
 onDownloadWithLink (ReferenceId $reference_id, ilExportHandlerConsumerFileIdentifierInterface $file_identifier)
 
 getFiles (ilExportHandlerConsumerContextInterface $context)
 
 onExportOptionSelected (ilExportHandlerConsumerContextInterface $context)
 
- Public Member Functions inherited from ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler
 init (Container $DIC)
 
 onDeleteFiles (ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
 
 onDownloadFiles (ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
 
 onDownloadWithLink (ReferenceId $reference_id, ilExportHandlerConsumerFileIdentifierInterface $file_identifier)
 
 getFileSelection (ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
 
 getFiles (ilExportHandlerConsumerContextInterface $context)
 
- Public Member Functions inherited from ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicHandler
 __construct ()
 
 isObjectSupported (ObjectId $object_id)
 
 isPublicAccessPossible ()
 

Protected Member Functions

 getExportFiles (string $directory)
 
 getDirectory (ObjectId $object_id, string $export_object_type)
 

Protected Attributes

ilLanguage $lng
 
string $data_dir
 
- Protected Attributes inherited from ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler
ilCtrl $ctrl
 
ilDataFactory $data_factory
 

Detailed Description

Definition at line 30 of file class.ilTestExportOptionARC.php.

Member Function Documentation

◆ getDirectory()

ilTestExportOptionARC::getDirectory ( ObjectId  $object_id,
string  $export_object_type 
)
protected

Definition at line 161 of file class.ilTestExportOptionARC.php.

References CLIENT_ID, ilTestArchiver\EXPORT_DIRECTORY, and ILIAS\Data\ObjectId\toInt().

Referenced by getFiles(), onDeleteFiles(), onDownloadFiles(), and onDownloadWithLink().

164  : string {
165  return $this->data_dir
166  . DIRECTORY_SEPARATOR . CLIENT_ID . DIRECTORY_SEPARATOR . 'tst_data' . DIRECTORY_SEPARATOR
167  . ilTestArchiver::EXPORT_DIRECTORY . DIRECTORY_SEPARATOR . $export_object_type . "_" . $object_id->toInt();
168  }
const CLIENT_ID
Definition: constants.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportFiles()

ilTestExportOptionARC::getExportFiles ( string  $directory)
protected

Definition at line 141 of file class.ilTestExportOptionARC.php.

References Vendor\Package\$e.

Referenced by getFiles().

143  : array {
144  $files = [];
145  try {
146  foreach (scandir($directory) as $file) {
147  if (
148  in_array($file, ['.', '..']) ||
149  !str_ends_with($file, ".zip")
150  ) {
151  continue;
152  }
153  $files[$file] = ["file" => $file];
154  }
155  } catch (Exception $e) {
156 
157  }
158  return $files;
159  }
+ Here is the caller graph for this function:

◆ getExportOptionId()

ilTestExportOptionARC::getExportOptionId ( )

Definition at line 48 of file class.ilTestExportOptionARC.php.

48  : string
49  {
50  return 'test_exp_option_arc';
51  }

◆ getExportType()

ilTestExportOptionARC::getExportType ( )

Definition at line 43 of file class.ilTestExportOptionARC.php.

43  : string
44  {
45  return 'Archive';
46  }

◆ getFiles()

ilTestExportOptionARC::getFiles ( ilExportHandlerConsumerContextInterface  $context)

Definition at line 118 of file class.ilTestExportOptionARC.php.

References getDirectory(), and getExportFiles().

120  : ilExportHandlerFileInfoCollectionInterface {
121  $collection_builder = $context->fileCollectionBuilder();
122  $object_id = new ObjectId($context->exportObject()->getId());
123  $dir = $this->getDirectory($object_id, $context->exportObject()->getType());
124  $file_infos = $this->getExportFiles($dir);
125  foreach ($file_infos as $file_name => $file_info) {
126  $collection_builder = $collection_builder->withSPLFileInfo(
127  new SplFileInfo($dir . DIRECTORY_SEPARATOR . $file_info["file"]),
128  $object_id,
129  $this
130  );
131  }
132  return $collection_builder->collection();
133  }
getDirectory(ObjectId $object_id, string $export_object_type)
$context
Definition: webdav.php:31
+ Here is the call graph for this function:

◆ getLabel()

ilTestExportOptionARC::getLabel ( )

Definition at line 58 of file class.ilTestExportOptionARC.php.

References ILIAS\Repository\lng().

58  : string
59  {
60  $this->lng->loadLanguageModule('assessment');
61  return $this->lng->txt('ass_create_export_test_archive');
62  }
+ Here is the call graph for this function:

◆ getSupportedRepositoryObjectTypes()

ilTestExportOptionARC::getSupportedRepositoryObjectTypes ( )

Definition at line 53 of file class.ilTestExportOptionARC.php.

53  : array
54  {
55  return ['tst'];
56  }

◆ init()

ilTestExportOptionARC::init ( Container  $DIC)

Definition at line 35 of file class.ilTestExportOptionARC.php.

References ILIAS\DI\Container\iliasIni(), init(), ILIAS\DI\Container\language(), and ILIAS\Repository\lng().

37  : void {
38  $this->lng = $DIC->language();
39  $this->data_dir = $DIC->iliasIni()->readVariable('clients', 'datadir');
40  parent::init($DIC);
41  }
language()
Get interface to the i18n service.
Definition: Container.php:95
+ Here is the call graph for this function:

◆ onDeleteFiles()

ilTestExportOptionARC::onDeleteFiles ( ilExportHandlerConsumerContextInterface  $context,
ilExportHandlerConsumerFileIdentifierCollectionInterface  $file_identifiers 
)

Definition at line 64 of file class.ilTestExportOptionARC.php.

References ilFileUtils\delDir(), and getDirectory().

67  : void {
68  $object_id = new ObjectId($context->exportObject()->getId());
69  foreach ($file_identifiers as $file_identifier) {
70  $file = explode(":", $file_identifier->getIdentifier());
71  $file[1] = basename($file[1]);
72  $export_dir = $this->getDirectory($object_id, $context->exportObject()->getType());
73  $exp_file = $export_dir . "/" . str_replace("..", "", $file[1]);
74  $exp_dir = $export_dir . "/" . substr($file[1], 0, strlen($file[1]) - 4);
75  if (is_file($exp_file)) {
76  unlink($exp_file);
77  }
78  if (
79  is_dir($exp_dir) and
80  count(scandir($exp_dir)) === 2
81  ) {
82  ilFileUtils::delDir($exp_dir);
83  }
84  }
85  }
getDirectory(ObjectId $object_id, string $export_object_type)
$context
Definition: webdav.php:31
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ onDownloadFiles()

ilTestExportOptionARC::onDownloadFiles ( ilExportHandlerConsumerContextInterface  $context,
ilExportHandlerConsumerFileIdentifierCollectionInterface  $file_identifiers 
)

Definition at line 87 of file class.ilTestExportOptionARC.php.

References ilFileDelivery\deliverFileLegacy(), and getDirectory().

90  : void {
91  $object_id = new ObjectId($context->exportObject()->getId());
92  foreach ($file_identifiers as $file_identifier) {
93  $file = explode(":", trim($file_identifier->getIdentifier()));
94  $export_dir = $this->getDirectory($object_id, $context->exportObject()->getType());
95  $file[1] = basename($file[1]);
97  $export_dir . "/" . $file[1],
98  $file[1]
99  );
100  }
101  }
getDirectory(ObjectId $object_id, string $export_object_type)
$context
Definition: webdav.php:31
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
+ Here is the call graph for this function:

◆ onDownloadWithLink()

ilTestExportOptionARC::onDownloadWithLink ( ReferenceId  $reference_id,
ilExportHandlerConsumerFileIdentifierInterface  $file_identifier 
)

Definition at line 103 of file class.ilTestExportOptionARC.php.

References ilObject\_lookupType(), ilFileDelivery\deliverFileLegacy(), getDirectory(), and ILIAS\Data\ReferenceId\toObjectId().

106  : void {
107  $object_id = $reference_id->toObjectId();
108  $type = ilObject::_lookupType($object_id->toInt());
109  $file = explode(":", trim($file_identifier->getIdentifier()));
110  $export_dir = $this->getDirectory($object_id, $type);
111  $file[1] = basename($file[1]);
113  $export_dir . "/" . $file[1],
114  $file[1]
115  );
116  }
getDirectory(ObjectId $object_id, string $export_object_type)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ onExportOptionSelected()

ilTestExportOptionARC::onExportOptionSelected ( ilExportHandlerConsumerContextInterface  $context)

Definition at line 135 of file class.ilTestExportOptionARC.php.

137  : void {
138  $context->exportGUIObject()->createTestArchiveExport();
139  }
$context
Definition: webdav.php:31

Field Documentation

◆ $data_dir

string ilTestExportOptionARC::$data_dir
protected

Definition at line 33 of file class.ilTestExportOptionARC.php.

◆ $lng

ilLanguage ilTestExportOptionARC::$lng
protected

Definition at line 32 of file class.ilTestExportOptionARC.php.


The documentation for this class was generated from the following file: