65 $this->db = $DIC->database();
68 $this->log->debug(
"constructed");
69 $this->rbacsystem = $DIC->rbac()->system();
70 $this->
user = $DIC->user();
71 $this->repo = $DIC->contentStyle()->internal()->repo();
81 return array(
"5.1.0",
"8.0");
89 public function getXmlNamespace(
string $a_entity,
string $a_schema_version): string
91 return "http://www.ilias.de/xml/Services/Style/" . $a_entity;
100 protected function getTypes(
string $a_entity,
string $a_version): array
102 if ($a_entity ==
"sty") {
103 switch ($a_version) {
109 "Description" =>
"text",
110 "ImagesDir" =>
"directory" 115 if ($a_entity ==
"object_style") {
116 switch ($a_version) {
120 "ObjectId" =>
"integer" 125 if ($a_entity ==
"sty_setting") {
126 switch ($a_version) {
130 "StyleId" =>
"integer",
137 if ($a_entity ==
"sty_char") {
138 switch ($a_version) {
141 "StyleId" =>
"integer",
143 "Characteristic" =>
"text",
148 "StyleId" =>
"integer",
150 "Characteristic" =>
"text",
152 "OrderNr" =>
"integer",
153 "Outdate" =>
"integer" 158 if ($a_entity ==
"sty_char_title") {
159 switch ($a_version) {
162 "StyleId" =>
"integer",
164 "Characteristic" =>
"text",
171 if ($a_entity ==
"sty_parameter") {
172 switch ($a_version) {
176 "StyleId" =>
"integer",
179 "Parameter" =>
"text",
183 "Custom" =>
"integer" 188 if ($a_entity ==
"sty_color") {
189 switch ($a_version) {
193 "StyleId" =>
"integer",
194 "ColorName" =>
"text",
195 "ColorCode" =>
"text" 200 if ($a_entity ==
"sty_media_query") {
201 switch ($a_version) {
206 "StyleId" =>
"integer",
207 "OrderNr" =>
"integer",
213 if ($a_entity ==
"sty_template") {
214 switch ($a_version) {
219 "StyleId" =>
"integer",
227 if ($a_entity ==
"sty_template_class") {
228 switch ($a_version) {
232 "TemplateId" =>
"integer",
233 "ClassType" =>
"text",
239 if ($a_entity ==
"sty_usage") {
240 switch ($a_version) {
244 "ObjId" =>
"integer",
245 "StyleId" =>
"integer" 256 public function getXmlRecord(
string $a_entity,
string $a_version, array $a_set): array
258 if ($a_entity ==
"sty") {
260 $a_set[
"ImagesDir"] = $dir;
271 public function readData(
string $a_entity,
string $a_version, array $a_ids): void
275 if (!is_array($a_ids)) {
276 $a_ids = array($a_ids);
279 if ($a_entity ==
"object_style") {
280 switch ($a_version) {
283 foreach ($a_ids as
$id) {
284 $this->data[] = array(
"ObjectId" => $id);
290 if ($a_entity ==
"sty") {
291 switch ($a_version) {
295 " FROM object_data o " .
296 " WHERE " .
$ilDB->in(
"o.obj_id", $a_ids,
false,
"integer"));
301 if ($a_entity ==
"sty_setting") {
302 switch ($a_version) {
306 " FROM style_setting " .
307 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
312 if ($a_entity ==
"sty_char") {
313 switch ($a_version) {
317 " FROM style_char " .
318 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
323 if ($a_entity ==
"sty_char_title") {
324 switch ($a_version) {
327 " FROM style_char_title " .
328 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
333 if ($a_entity ==
"sty_parameter") {
334 switch ($a_version) {
338 " FROM style_parameter " .
339 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
344 if ($a_entity ==
"sty_color") {
345 switch ($a_version) {
349 " FROM style_color " .
350 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
355 if ($a_entity ==
"sty_media_query") {
356 switch ($a_version) {
360 " FROM sty_media_query " .
361 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
366 if ($a_entity ==
"sty_template") {
367 switch ($a_version) {
371 " FROM style_template " .
372 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
377 if ($a_entity ==
"sty_template_class") {
378 switch ($a_version) {
382 " FROM style_template_class " .
383 " WHERE " .
$ilDB->in(
"template_id", $a_ids,
false,
"integer"));
388 if ($a_entity ==
"sty_usage") {
389 switch ($a_version) {
393 " FROM style_usage " .
394 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
406 ?array $a_rec = null,
409 $this->ds_log->debug(
"entity: " . $a_entity .
", rec: " . print_r($a_rec,
true));
412 $this->ds_log->debug(
"object id: " . ($a_rec[
"ObjectId"] ?? null));
414 $this->ds_log->debug(
"style id: " . $style_id);
418 "sty" => array(
"ids" => $style_id));
425 "sty_setting" => array(
"ids" => $a_rec[
"Id"] ?? null),
426 "sty_media_query" => array(
"ids" => $a_rec[
"Id"] ?? null),
427 "sty_char" => array(
"ids" => $a_rec[
"Id"] ?? null),
428 "sty_char_title" => array(
"ids" => $a_rec[
"Id"] ?? null),
429 "sty_color" => array(
"ids" => $a_rec[
"Id"] ?? null),
430 "sty_parameter" => array(
"ids" => $a_rec[
"Id"] ?? null),
431 "sty_template" => array(
"ids" => $a_rec[
"Id"] ?? null),
432 "sty_usage" => array(
"ids" => $a_rec[
"Id"] ?? null)
437 "sty_template_class" => array(
"ids" => $a_rec[
"Id"] ?? null)
453 $service = $DIC->contentStyle()->internal();
454 $access_manager =
$service->domain()->access(
458 $access_manager->enableWrite(
true);
460 $style_id = (isset($this->current_obj))
461 ? $this->current_obj->getId()
463 $characteristic_manager =
$service->domain()->characteristic(
468 $color_manager =
$service->domain()->color(
476 $this->log->debug(
"Entity: " . $a_entity);
477 if ($new_id = $a_mapping->
getMapping(
'Services/Container',
'objs', $a_rec[
'Id'])) {
481 $newObj->create(0,
true);
484 $newObj->setTitle($a_rec[
"Title"]);
485 $newObj->setDescription($a_rec[
"Description"]);
486 $newObj->update(
true);
488 $this->current_obj = $newObj;
489 $a_mapping->
addMapping(
"Services/Style",
"sty", $a_rec[
"Id"], $newObj->getId());
490 $a_mapping->
addMapping(
"Services/Object",
"obj", $a_rec[
"Id"], $newObj->getId());
491 $this->log->debug(
"Added mapping Services/Style sty " . $a_rec[
"Id"] .
" > " . $newObj->getId());
493 $dir = str_replace(
"..",
"", $a_rec[
"ImagesDir"]);
502 $this->current_obj->writeStyleSetting($a_rec[
"Name"], $a_rec[
"Value"]);
506 $this->current_obj->addCharacteristic($a_rec[
"Type"], $a_rec[
"Characteristic"], $a_rec[
"Hide"], (
int) ($a_rec[
"OrderNr"] ?? 0), (
bool) ($a_rec[
"Outdated"] ??
false));
509 case "sty_char_title":
510 $char_repo = $this->repo->characteristic();
511 $char_repo->addTitle(
512 $this->current_obj->getId(),
514 $a_rec[
"Characteristic"],
520 case "sty_parameter":
521 $mq_id = (
int) $a_mapping->
getMapping(
"Services/Style",
"media_query", $a_rec[
"MqId"]);
522 $characteristic_manager->replaceParameter($a_rec[
"Tag"], $a_rec[
"Class"], $a_rec[
"Parameter"], $a_rec[
"Value"], $a_rec[
"Type"], $mq_id, $a_rec[
"Custom"]);
526 $color_manager->addColor($a_rec[
"ColorName"], $a_rec[
"ColorCode"]);
529 case "sty_media_query":
530 $mq_id = $this->current_obj->addMediaQuery($a_rec[
"MQuery"], $a_rec[
"OrderNr"]);
531 $a_mapping->
addMapping(
"Services/Style",
"media_query", $a_rec[
"Id"], $mq_id);
535 $tid = $this->current_obj->addTemplate($a_rec[
"TempType"], $a_rec[
"Name"], array());
536 $a_mapping->
addMapping(
"Services/Style",
"template", $a_rec[
"Id"], $tid);
539 case "sty_template_class":
540 $tid = (
int) $a_mapping->
getMapping(
"Services/Style",
"template", $a_rec[
"TemplateId"]);
541 $this->current_obj->addTemplateClass($tid, $a_rec[
"ClassType"], $a_rec[
"Class"]);
545 $obj_id = (
int) $a_mapping->
getMapping(
"Services/Object",
"obj", $a_rec[
"ObjId"]);
546 $style_id = (
int) $a_mapping->
getMapping(
"Services/Style",
"sty", $a_rec[
"StyleId"]);
547 if ($obj_id > 0 && $style_id > 0) {
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Content InternalRepoService $repo
static _getImagesDirectory(int $a_style_id)
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
ilObjStyleSheet $current_obj
getXmlRecord(string $a_entity, string $a_version, array $a_set)
Get xml record.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static writeOwner($obj_id, $style_id)
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
Determine the dependent sets of data.
getMapping(string $a_comp, string $a_entity, string $a_old_id)
Content style internal repo service.
getSupportedVersions()
Get supported versions.
readData(string $a_entity, string $a_version, array $a_ids)
Read data.
getTypes(string $a_entity, string $a_version)
Get field types for entity.
getXmlNamespace(string $a_entity, string $a_schema_version)
Get xml namespace.
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 ...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static writeStyleUsage(int $a_obj_id, int $a_style_id)
Write style usage.
static lookupObjectStyle(int $a_obj_id)
Lookup object style.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
stripTags(array $rec, array $omit_keys=[])
static _lookupType(int $id, bool $reference=false)
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Import record.