ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ExportFileDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Export\HTML;
22
27
29{
30 public function __construct(
31 protected ilDBInterface $db,
32 protected IRSSWrapper $irss,
33 protected DataService $data,
34 protected \ilExportHTMLStakeholder $stakeholder
35 ) {
36 }
37
38 public function create(
39 int $object_id,
40 string $type,
41 string $title
42 ): string {
43 $rid = $this->irss->createContainer(
44 $this->stakeholder,
45 $title
46 );
47 $this->db->insert('export_files_html', [
48 'object_id' => ['integer', $object_id],
49 'rid' => ['text', $rid],
50 'timestamp' => ['timestamp', \ilUtil::now()],
51 'type' => ['text', $type]
52 ]);
53 return $rid;
54 }
55
56 public function addString(
57 string $rid,
58 string $content,
59 string $path,
60 ): void {
61 $this->irss->addStringToContainer(
62 $rid,
63 $content,
64 $path
65 );
66 }
67
68 public function addFile(
69 string $rid,
70 string $fullpath,
71 string $path,
72 ): void {
73 $this->irss->addLocalFileToContainer(
74 $rid,
75 $fullpath,
76 $path
77 );
78 }
79
80 public function addDirectory(
81 string $rid,
82 string $source_dir,
83 string $target_path = ""
84 ): void {
85 $this->irss->addDirectoryToContainer(
86 $rid,
87 $source_dir,
88 $target_path
89 );
90 }
91
93 string $source_container_id,
94 string $target_container_id,
95 string $source_dir_path = "",
96 string $target_dir_path = ""
97 ): void {
98 $this->irss->addContainerDirToTargetContainer(
99 $source_container_id,
100 $target_container_id,
101 $source_dir_path,
102 $target_dir_path
103 );
104 }
105
106 public function update(ExportFile $file): void
107 {
108 $this->db->update('export_files_html', [
109 'timestamp' => ['timestamp', $file->getTimestamp()],
110 'type' => ['text', $file->getType()]
111 ], [
112 'object_id' => ['integer', $file->getObjectId()],
113 'rid' => ['text', $file->getRid()]
114 ]);
115 }
116
117 public function delete(
118 int $object_id,
119 string $rid
120 ): void {
121 $this->irss->deleteResource(
122 $rid,
123 $this->stakeholder
124 );
125 $this->db->manipulateF(
126 'DELETE FROM export_files_html WHERE object_id = %s AND rid = %s',
127 ['integer', 'text'],
128 [$object_id, $rid]
129 );
130 }
131
132 public function getFilePath(
133 string $rid
134 ): string {
135 return $this->irss->getResourcePath($rid);
136 }
137
138 public function getById(int $object_id, string $rid): ?ExportFile
139 {
140 $set = $this->db->queryF(
141 'SELECT * FROM export_files_html WHERE object_id = %s AND rid = %s',
142 ['integer', 'text'],
143 [$object_id, $rid]
144 );
145
146 $record = $this->db->fetchAssoc($set);
147 return $record ? $this->getExportFileFromRecord($record) : null;
148 }
149
153 public function getAllOfObjectId(int $object_id): \Generator
154 {
155 $set = $this->db->queryF(
156 "SELECT * FROM export_files_html " .
157 " WHERE object_id = %s ORDER BY timestamp DESC",
158 ["integer"],
159 [$object_id]
160 );
161 while ($record = $this->db->fetchAssoc($set)) {
162 yield $this->getExportFileFromRecord($record);
163 }
164 }
165
166 public function getLatestOfObjectIdAndType(int $object_id, string $type = ""): ?ExportFile
167 {
168 $set = $this->db->queryF(
169 "SELECT * FROM export_files_html " .
170 " WHERE object_id = %s AND type = %s ORDER BY timestamp DESC",
171 ["integer", "text"],
172 [$object_id, $type]
173 );
174 if ($record = $this->db->fetchAssoc($set)) {
175 return $this->getExportFileFromRecord($record);
176 }
177 return null;
178 }
179
181 {
182 return $this->irss->getResourceIdForIdString($rid);
183 }
184
185 protected function getExportFileFromRecord(array $record): ExportFile
186 {
187 return $this->data->exportFile(
188 (int) $record['object_id'],
189 (string) $record['rid'],
190 (string) $record['timestamp'],
191 (string) $record['type']
192 );
193 }
194
195 public function deliverFile(string $rid): void
196 {
197 $this->irss->deliverFile($rid);
198 }
199
200 // currently broken, see https://mantis.ilias.de/view.php?id=44135
201 public function rename(
202 string $rid,
203 string $title
204 ): void {
205 $this->irss->renameContainer($rid, $title);
206 }
207
208
209}
addContainerDirToTargetContainer(string $source_container_id, string $target_container_id, string $source_dir_path="", string $target_dir_path="")
getLatestOfObjectIdAndType(int $object_id, string $type="")
addString(string $rid, string $content, string $path,)
__construct(protected ilDBInterface $db, protected IRSSWrapper $irss, protected DataService $data, protected \ilExportHTMLStakeholder $stakeholder)
addDirectory(string $rid, string $source_dir, string $target_path="")
create(int $object_id, string $type, string $title)
addFile(string $rid, string $fullpath, string $path,)
static now()
Return current timestamp in Y-m-d H:i:s format.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilDBInterface.
$data
Definition: storeScorm.php:45