70 $this->db = $DIC->database();
73 $this->log->debug(
"constructed");
74 $this->rbacsystem = $DIC->rbac()->system();
75 $this->
user = $DIC->user();
76 $this->repo = $DIC->contentStyle()->internal()->repo();
86 return array(
"5.1.0",
"8.0");
94 public function getXmlNamespace(
string $a_entity,
string $a_schema_version): string
96 return "http://www.ilias.de/xml/Services/Style/" . $a_entity;
105 protected function getTypes(
string $a_entity,
string $a_version): array
107 if ($a_entity ==
"sty") {
108 switch ($a_version) {
114 "Description" =>
"text",
115 "ImagesDir" =>
"directory" 120 if ($a_entity ==
"object_style") {
121 switch ($a_version) {
125 "ObjectId" =>
"integer" 130 if ($a_entity ==
"sty_setting") {
131 switch ($a_version) {
135 "StyleId" =>
"integer",
142 if ($a_entity ==
"sty_char") {
143 switch ($a_version) {
146 "StyleId" =>
"integer",
148 "Characteristic" =>
"text",
153 "StyleId" =>
"integer",
155 "Characteristic" =>
"text",
157 "OrderNr" =>
"integer",
158 "Outdate" =>
"integer" 163 if ($a_entity ==
"sty_char_title") {
164 switch ($a_version) {
167 "StyleId" =>
"integer",
169 "Characteristic" =>
"text",
176 if ($a_entity ==
"sty_parameter") {
177 switch ($a_version) {
181 "StyleId" =>
"integer",
184 "Parameter" =>
"text",
188 "Custom" =>
"integer" 193 if ($a_entity ==
"sty_color") {
194 switch ($a_version) {
198 "StyleId" =>
"integer",
199 "ColorName" =>
"text",
200 "ColorCode" =>
"text" 205 if ($a_entity ==
"sty_media_query") {
206 switch ($a_version) {
211 "StyleId" =>
"integer",
212 "OrderNr" =>
"integer",
218 if ($a_entity ==
"sty_template") {
219 switch ($a_version) {
224 "StyleId" =>
"integer",
232 if ($a_entity ==
"sty_template_class") {
233 switch ($a_version) {
237 "TemplateId" =>
"integer",
238 "ClassType" =>
"text",
244 if ($a_entity ==
"sty_usage") {
245 switch ($a_version) {
249 "ObjId" =>
"integer",
250 "StyleId" =>
"integer" 261 public function getXmlRecord(
string $a_entity,
string $a_version, array $a_set): array
263 if ($a_entity ==
"sty") {
265 $a_set[
"ImagesDir"] = $dir;
276 public function readData(
string $a_entity,
string $a_version, array $a_ids): void
280 if (!is_array($a_ids)) {
281 $a_ids = array($a_ids);
284 if ($a_entity ==
"object_style") {
285 switch ($a_version) {
288 foreach ($a_ids as
$id) {
289 $this->data[] = array(
"ObjectId" => $id);
295 if ($a_entity ==
"sty") {
296 switch ($a_version) {
300 " FROM object_data o " .
301 " WHERE " .
$ilDB->in(
"o.obj_id", $a_ids,
false,
"integer"));
306 if ($a_entity ==
"sty_setting") {
307 switch ($a_version) {
311 " FROM style_setting " .
312 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
317 if ($a_entity ==
"sty_char") {
318 switch ($a_version) {
322 " FROM style_char " .
323 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
328 if ($a_entity ==
"sty_char_title") {
329 switch ($a_version) {
332 " FROM style_char_title " .
333 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
338 if ($a_entity ==
"sty_parameter") {
339 switch ($a_version) {
343 " FROM style_parameter " .
344 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
349 if ($a_entity ==
"sty_color") {
350 switch ($a_version) {
354 " FROM style_color " .
355 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
360 if ($a_entity ==
"sty_media_query") {
361 switch ($a_version) {
365 " FROM sty_media_query " .
366 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
371 if ($a_entity ==
"sty_template") {
372 switch ($a_version) {
376 " FROM style_template " .
377 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
382 if ($a_entity ==
"sty_template_class") {
383 switch ($a_version) {
387 " FROM style_template_class " .
388 " WHERE " .
$ilDB->in(
"template_id", $a_ids,
false,
"integer"));
393 if ($a_entity ==
"sty_usage") {
394 switch ($a_version) {
398 " FROM style_usage " .
399 " WHERE " .
$ilDB->in(
"style_id", $a_ids,
false,
"integer"));
411 ?array $a_rec = null,
414 $this->ds_log->debug(
"entity: " . $a_entity .
", rec: " . print_r($a_rec,
true));
417 $this->ds_log->debug(
"object id: " . ($a_rec[
"ObjectId"] ?? null));
419 $this->ds_log->debug(
"style id: " . $style_id);
423 "sty" => array(
"ids" => $style_id));
430 "sty_setting" => array(
"ids" => $a_rec[
"Id"] ?? null),
431 "sty_media_query" => array(
"ids" => $a_rec[
"Id"] ?? null),
432 "sty_char" => array(
"ids" => $a_rec[
"Id"] ?? null),
433 "sty_char_title" => array(
"ids" => $a_rec[
"Id"] ?? null),
434 "sty_color" => array(
"ids" => $a_rec[
"Id"] ?? null),
435 "sty_parameter" => array(
"ids" => $a_rec[
"Id"] ?? null),
436 "sty_template" => array(
"ids" => $a_rec[
"Id"] ?? null),
437 "sty_usage" => array(
"ids" => $a_rec[
"Id"] ?? null)
442 "sty_template_class" => array(
"ids" => $a_rec[
"Id"] ?? null)
458 $service = $DIC->contentStyle()->internal();
459 $access_manager =
$service->domain()->access(
463 $access_manager->enableWrite(
true);
465 $style_id = (isset($this->current_obj))
466 ? $this->current_obj->getId()
468 $characteristic_manager =
$service->domain()->characteristic(
473 $color_manager =
$service->domain()->color(
481 $this->log->debug(
"Entity: " . $a_entity);
482 if ($new_id = $a_mapping->
getMapping(
'Services/Container',
'objs', $a_rec[
'Id'])) {
486 $newObj->create(0,
true);
489 $newObj->setTitle($a_rec[
"Title"]);
490 $newObj->setDescription($a_rec[
"Description"]);
491 $newObj->update(
true);
493 $this->current_obj = $newObj;
494 $a_mapping->
addMapping(
"Services/Style",
"sty", $a_rec[
"Id"], $newObj->getId());
495 $a_mapping->
addMapping(
"Services/Object",
"obj", $a_rec[
"Id"], $newObj->getId());
496 $this->log->debug(
"Added mapping Services/Style sty " . $a_rec[
"Id"] .
" > " . $newObj->getId());
498 $dir = str_replace(
"..",
"", $a_rec[
"ImagesDir"]);
507 $this->current_obj->writeStyleSetting($a_rec[
"Name"], $a_rec[
"Value"]);
511 $this->current_obj->addCharacteristic($a_rec[
"Type"], $a_rec[
"Characteristic"], $a_rec[
"Hide"], (
int) ($a_rec[
"OrderNr"] ?? 0), (
bool) ($a_rec[
"Outdated"] ??
false));
514 case "sty_char_title":
515 $char_repo = $this->repo->characteristic();
516 $char_repo->addTitle(
517 $this->current_obj->getId(),
519 $a_rec[
"Characteristic"],
525 case "sty_parameter":
526 $mq_id = (
int) $a_mapping->
getMapping(
"Services/Style",
"media_query", $a_rec[
"MqId"]);
527 $characteristic_manager->replaceParameter($a_rec[
"Tag"], $a_rec[
"Class"], $a_rec[
"Parameter"], $a_rec[
"Value"], $a_rec[
"Type"], $mq_id, $a_rec[
"Custom"]);
531 $color_manager->addColor($a_rec[
"ColorName"], $a_rec[
"ColorCode"]);
534 case "sty_media_query":
535 $mq_id = $this->current_obj->addMediaQuery($a_rec[
"MQuery"], $a_rec[
"OrderNr"]);
536 $a_mapping->
addMapping(
"Services/Style",
"media_query", $a_rec[
"Id"], $mq_id);
540 $tid = $this->current_obj->addTemplate($a_rec[
"TempType"], $a_rec[
"Name"], array());
541 $a_mapping->
addMapping(
"Services/Style",
"template", $a_rec[
"Id"], $tid);
544 case "sty_template_class":
545 $tid = (
int) $a_mapping->
getMapping(
"Services/Style",
"template", $a_rec[
"TemplateId"]);
546 $this->current_obj->addTemplateClass($tid, $a_rec[
"ClassType"], $a_rec[
"Class"]);
550 $obj_id = (
int) $a_mapping->
getMapping(
"Services/Object",
"obj", $a_rec[
"ObjId"]);
551 $style_id = (
int) $a_mapping->
getMapping(
"Services/Style",
"sty", $a_rec[
"StyleId"]);
552 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.
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.
__construct(Container $dic, ilPlugin $plugin)
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Import record.