ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilQuestionPoolExportTableGUI.php
Go to the documentation of this file.
1 <?php
2 
21 
28 {
31 
32  public function __construct($parent_obj, $parent_cmd, $exp_obj)
33  {
34  global $DIC;
35  $this->ui_factory = $DIC->ui()->factory();
36  $this->ui_renderer = $DIC->ui()->renderer();
37 
39  }
40 
45  protected function formatActionsList($type, $filename): string
46  {
47  $this->ctrl->setParameter($this->getParentObject(), 'file', $type . ':' . $filename);
48  $action = $this->ui_factory->link()->standard(
49  $this->lng->txt('download'),
50  $this->ctrl->getLinkTarget($this->getParentObject(), 'download')
51  );
52  $this->ctrl->setParameter($this->getParentObject(), 'file', '');
53  $dropdown = $this->ui_factory->dropdown()->standard($action)->withLabel($this->lng->txt('actions'));
54  return $this->ui_renderer->render($dropdown);
55 
56  }
57 
61  public function numericOrdering(string $a_field): bool
62  {
63  if (in_array($a_field, array('size', 'date'))) {
64  return true;
65  }
66 
67  return false;
68  }
69 
70  protected function initMultiCommands(): void
71  {
72  $this->addMultiCommand('confirmDeletion', $this->lng->txt('delete'));
73  }
74 
75  public function getExportFiles(): array
76  {
77  $obj_type = $this->obj->getType();
78  $types = [];
79  foreach ($this->parent_obj->getFormats() as $f) {
80  $types[] = $f['key'];
81  $this->formats[$f['key']] = $f['txt'];
82  }
83  $file = [];
84 
85  foreach ($types as $type) {
87  $this->obj->getId(),
88  $type,
89  $obj_type
90  );
91 
92  // quit if import dir not available
93  if (!is_dir($dir) || !is_writable($dir)) {
94  continue;
95  }
96 
97  // open directory
98  $h_dir = dir($dir);
99 
100  // get files and save the in the array
101  while ($entry = $h_dir->read()) {
102  if ($entry !== "."
103  && $entry !== ".."
104  && (substr($entry, -4) === ".zip" || substr($entry, -5) === ".xlsx")
105  && (preg_match("/^[0-9]{10}_{2}[0-9]+_{2}(" . $obj_type . "_)*[0-9]+\.zip\$/", $entry)
106  || preg_match("/^[0-9]{10}_{2}[0-9]+_{2}(" . $obj_type . "_)*[0-9]+\.xlsx\$/", $entry))) {
107  $ts = substr($entry, 0, strpos($entry, "__"));
108  $file[$entry . $type] = [
109  "type" => (string) $type,
110  "file" => (string) $entry,
111  "size" => (int) filesize($dir . "/" . $entry),
112  "timestamp" => (int) $ts
113  ];
114  }
115  }
116 
117  // close import directory
118  $h_dir->close();
119  }
120 
121  // sort files
122  ksort($file);
123  reset($file);
124  return $file;
125  }
126 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
__construct($parent_obj, $parent_cmd, $exp_obj)
$filename
Definition: buildRTE.php:78
addMultiCommand(string $a_cmd, string $a_text)