ILIAS  release_8 Revision v8.24
class.ilMediaCastDataSet.php
Go to the documentation of this file.
1<?php
2
25{
27 protected array $order = array();
28
29 public function getSupportedVersions(): array
30 {
31 return array("8.0", "5.0.0", "4.1.0");
32 }
33
34 public function getXmlNamespace(string $a_entity, string $a_schema_version): string
35 {
36 return "https://www.ilias.de/xml/Modules/MediaCast/" . $a_entity;
37 }
38
39 protected function getTypes(string $a_entity, string $a_version): array
40 {
41 if ($a_entity == "mcst") {
42 switch ($a_version) {
43 case "4.1.0":
44 return array(
45 "Id" => "integer",
46 "Title" => "text",
47 "Description" => "text",
48 "PublicFiles" => "integer",
49 "Downloadable" => "integer",
50 "DefaultAccess" => "integer");
51
52 case "5.0.0":
53 return array(
54 "Id" => "integer",
55 "Title" => "text",
56 "Description" => "text",
57 "PublicFiles" => "integer",
58 "Downloadable" => "integer",
59 "DefaultAccess" => "integer",
60 "Sortmode" => "integer",
61 "Viewmode" => "text",
62 "PublicFeed" => "integer",
63 "KeepRssMin" => "integer",
64 "Order" => "text"
65 );
66
67 case "8.0":
68 return array(
69 "Id" => "integer",
70 "Title" => "text",
71 "Description" => "text",
72 "PublicFiles" => "integer",
73 "Downloadable" => "integer",
74 "DefaultAccess" => "integer",
75 "Sortmode" => "integer",
76 "Viewmode" => "text",
77 "PublicFeed" => "integer",
78 "KeepRssMin" => "integer",
79 "Order" => "text",
80 "Autoplaymode" => "integer",
81 "NrInitialVideos" => "integer",
82 "NewItemsInLp" => "integer"
83 );
84 }
85 }
86 return [];
87 }
88
89 public function readData(
90 string $a_entity,
91 string $a_version,
92 array $a_ids
93 ): void {
94 $ilDB = $this->db;
95
96
97 if ($a_entity == "mcst") {
98 switch ($a_version) {
99 case "4.1.0":
100 $this->getDirectDataFromQuery("SELECT id, title, description, " .
101 " public_files, downloadable, def_access default_access" .
102 " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
103 "WHERE " .
104 $ilDB->in("id", $a_ids, false, "integer"));
105 break;
106
107 case "5.0.0":
108 $this->getDirectDataFromQuery("SELECT id, title, description, " .
109 " public_files, downloadable, def_access default_access, sortmode, viewmode" .
110 " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
111 "WHERE " .
112 $ilDB->in("id", $a_ids, false, "integer"));
113
114 // #17174 - manual order?
115 $order = array();
116 $set = $ilDB->query("SELECT * FROM il_media_cast_data_ord" .
117 " WHERE " . $ilDB->in("obj_id", $a_ids, false, "integer") .
118 " ORDER BY pos");
119 while ($row = $ilDB->fetchAssoc($set)) {
120 $order[$row["obj_id"]][] = $row["item_id"];
121 }
122
123 foreach ($this->data as $k => $v) {
124 $this->data[$k]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $v["Id"]);
125 $this->data[$k]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $v["Id"]);
126
127 // manual order?
128 if ($this->data[$k]["Sortmode"] == 4 &&
129 array_key_exists($v["Id"], $order)) {
130 $this->data[$k]["Order"] = implode(";", $order[$v["Id"]]);
131 }
132 }
133 break;
134
135 case "8.0":
136 $this->getDirectDataFromQuery("SELECT id, title, description, " .
137 " public_files, downloadable, def_access default_access, sortmode, viewmode," .
138 " autoplaymode,nr_initial_videos,new_items_in_lp" .
139 " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
140 "WHERE " .
141 $ilDB->in("id", $a_ids, false, "integer"));
142
143 // #17174 - manual order?
144 $order = array();
145 $set = $ilDB->query("SELECT * FROM il_media_cast_data_ord" .
146 " WHERE " . $ilDB->in("obj_id", $a_ids, false, "integer") .
147 " ORDER BY pos");
148 while ($row = $ilDB->fetchAssoc($set)) {
149 $order[$row["obj_id"]][] = $row["item_id"];
150 }
151
152 foreach ($this->data as $k => $v) {
153 $this->data[$k]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $v["Id"]);
154 $this->data[$k]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $v["Id"]);
155
156 // manual order?
157 if ($this->data[$k]["Sortmode"] == 4 &&
158 array_key_exists($v["Id"], $order)) {
159 $this->data[$k]["Order"] = implode(";", $order[$v["Id"]]);
160 }
161 }
162 break;
163 }
164 }
165 }
166
167 protected function getDependencies(
168 string $a_entity,
169 string $a_version,
170 ?array $a_rec = null,
171 ?array $a_ids = null
172 ): array {
173 return [];
174 }
175
176 public function importRecord(
177 string $a_entity,
178 array $a_types,
179 array $a_rec,
180 ilImportMapping $a_mapping,
181 string $a_schema_version
182 ): void {
183 $a_rec = $this->stripTags($a_rec);
184 switch ($a_entity) {
185 case "mcst":
186
187 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
188 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
189 } else {
190 $newObj = new ilObjMediaCast();
191 $newObj->setType("mcst");
192 $newObj->create();
193 }
194
195 $newObj->setTitle($a_rec["Title"] ?? "");
196 $newObj->setDescription($a_rec["Description"] ?? "");
197 $newObj->setDefaultAccess((int) ($a_rec["DefaultAccess"] ?? 0));
198 $newObj->setDownloadable((bool) (int) ($a_rec["Downloadable"] ?? false));
199 $newObj->setPublicFiles((bool) (int) ($a_rec["PublicFiles"] ?? false));
200
201 if (in_array($a_schema_version, ["5.0.0", "8.0"])) {
202 $newObj->setOrder((int) ($a_rec["Sortmode"] ?? 0));
203 $newObj->setViewMode((string) ($a_rec["Viewmode"] ?? ""));
204
205 if ($a_rec["Order"] ?? false) {
206 $this->order[$newObj->getId()] = explode(";", $a_rec["Order"]);
207 }
208
210 "news",
211 "public_feed",
212 $a_rec["PublicFeed"],
213 0,
214 $newObj->getId()
215 );
216
218 "news",
219 "keep_rss_min",
220 $a_rec["KeepRssMin"],
221 0,
222 $newObj->getId()
223 );
224 }
225 if (in_array($a_schema_version, ["8.0"])) {
226 $newObj->setAutoplayMode((int) ($a_rec["Autoplaymode"] ?? 0));
227 $newObj->setNumberInitialVideos((int) ($a_rec["NrInitialVideos"] ?? 0));
228 $newObj->setNewItemsInLearningProgress((bool) (int) ($a_rec["NewItemsInLp"] ?? false));
229 }
230
231 $newObj->update();
232 $this->current_obj = $newObj;
233 $a_mapping->addMapping("Modules/MediaCast", "mcst", $a_rec["Id"], $newObj->getId());
234 $a_mapping->addMapping(
235 "Services/News",
236 "news_context",
237 $a_rec["Id"] . ":mcst:0:",
238 $newObj->getId() . ":mcst:0:"
239 );
240 break;
241 }
242 }
243
244 public function getOrder(): array
245 {
246 return $this->order;
247 }
248}
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
getXmlNamespace(string $a_entity, string $a_schema_version)
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Needs to be overwritten for import use case.
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
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', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']