ILIAS  release_8 Revision v8.24
class.ilObjectDefinitionProcessor.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22{
23 protected ilDBInterface $db;
24 protected ?string $component;
25 protected ?string $current_object;
26
27 public function __construct(ilDBInterface $db)
28 {
29 $this->db = $db;
30 }
31
32 public function purge(): void
33 {
34 $this->db->manipulate("DELETE FROM il_object_def");
35 $this->db->manipulate("DELETE FROM il_object_subobj");
36 $this->db->manipulate("DELETE FROM il_object_group");
37 $this->db->manipulate("DELETE FROM il_object_sub_type");
38 }
39
40 public function beginComponent(string $component, string $type): void
41 {
42 $this->component = $type . "/" . $component;
43 $this->current_object = null;
44 }
45
46 public function endComponent(string $component, string $type): void
47 {
48 $this->component = null;
49 $this->current_object = null;
50 }
51
52 public function beginTag(string $name, array $attributes): void
53 {
54 switch ($name) {
55 case 'object':
56
57 // if attributes are not given, set default (repository only)
58 if (($attributes["repository"] ?? null) === null) {
59 $attributes["repository"] = true;
60 }
61 if (($attributes["workspace"] ?? null) === null) {
62 $attributes["workspace"] = false;
63 }
64
65 $this->current_object = $attributes["id"];
66 $this->db->manipulateF(
67 "INSERT INTO il_object_def (id, class_name, component,location," .
68 "checkbox,inherit,translate,devmode,allow_link,allow_copy,rbac,default_pos," .
69 "default_pres_pos,sideblock,grp," . $this->db->quoteIdentifier("system") . ",export,repository,workspace,administration," .
70 "amet,orgunit_permissions,lti_provider,offline_handling) VALUES " .
71 "(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
72 array("text", "text", "text", "text", "integer", "integer", "text", "integer","integer","integer",
73 "integer","integer","integer","integer", "text", "integer", "integer", "integer", "integer",
74 'integer','integer','integer','integer','integer'),
75 array(
76 $attributes["id"],
77 $attributes["class_name"],
78 $this->component,
79 $this->component . "/" . $attributes["dir"],
80 (int) ($attributes["checkbox"] ?? null),
81 (int) ($attributes["inherit"] ?? null),
82 $attributes["translate"] ?? null,
83 (int) ($attributes["devmode"] ?? null),
84 (int) ($attributes["allow_link"] ?? null),
85 (int) ($attributes["allow_copy"] ?? null),
86 (int) ($attributes["rbac"] ?? null),
87 (int) ($attributes["default_pos"] ?? null),
88 (int) ($attributes["default_pres_pos"] ?? null),
89 (int) ($attributes["sideblock"] ?? null),
90 $attributes["group"] ?? null,
91 (int) ($attributes["system"] ?? null),
92 (int) ($attributes["export"] ?? null),
93 (int) ($attributes["repository"] ?? null),
94 (int) ($attributes["workspace"] ?? null),
95 (int) ($attributes['administration'] ?? null),
96 (int) ($attributes['amet'] ?? null),
97 (int) ($attributes['orgunit_permissions'] ?? null),
98 (int) ($attributes['lti_provider'] ?? null),
99 (int) ($attributes['offline_handling'] ?? null)
100 )
101 );
102 break;
103
104 case "subobj":
105 $this->db->manipulateF(
106 "INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
107 array("text", "text", "integer"),
108 array($this->current_object, $attributes["id"], (int) ($attributes["max"] ?? null))
109 );
110 break;
111
112 case "parent":
113 $this->db->manipulateF(
114 "INSERT INTO il_object_subobj (parent, subobj, mmax) VALUES (%s,%s,%s)",
115 array("text", "text", "integer"),
116 array($attributes["id"], $this->current_object, (int) ($attributes["max"] ?? null))
117 );
118 break;
119
120 case "objectgroup":
121 $this->db->manipulateF(
122 "INSERT INTO il_object_group (id, name, default_pres_pos) VALUES (%s,%s,%s)",
123 array("text", "text", "integer"),
124 array($attributes["id"], $attributes["name"], $attributes["default_pres_pos"])
125 );
126 break;
127 case "sub_type":
128 $this->db->manipulate("INSERT INTO il_object_sub_type " .
129 "(obj_type, sub_type, amet) VALUES (" .
130 $this->db->quote($this->current_object, "text") . "," .
131 $this->db->quote($attributes["id"], "text") . "," .
132 $this->db->quote($attributes["amet"], "integer") .
133 ")");
134 break;
135 }
136 }
137
138 public function endTag(string $name): void
139 {
140 }
141}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
beginTag(string $name, array $attributes)
This is called when a tag starts in the context of the given component.
endComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component ends.
beginComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component starts.
endTag(string $name)
This is called when a tag ends in the context of the given component.
purge()
This methods is supposed to purge existing data in the provider of the component, so new components c...
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i....
Interface ilDBInterface.
if($format !==null) $name
Definition: metadata.php:247
$attributes
Definition: metadata.php:248
$type