ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDBUpdate3136.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
35 public static function copyStyleClass(
36 string $orig_class,
37 string $class,
38 string $type,
39 string $tag,
40 int $hide = 0
41 ): void {
42 global $ilDB;
43 $db = $ilDB;
44
45 $sql =
46 "SELECT obj_id" . PHP_EOL
47 . "FROM object_data" . PHP_EOL
48 . "WHERE type = 'sty'" . PHP_EOL
49 ;
50 $set = $db->query($sql);
51
52 while ($row = $db->fetchAssoc($set)) {
53 $sql =
54 "SELECT style_id, type, characteristic, hide" . PHP_EOL
55 . "FROM style_char" . PHP_EOL
56 . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
57 . "AND characteristic = " . $db->quote($class, "text") . PHP_EOL
58 . "AND type = " . $db->quote($type, "text") . PHP_EOL
59 ;
60 $res = $db->query($sql);
61
62 if (!$db->fetchAssoc($res)) {
63 $values = [
64 "style_id" => ["integer", $row["obj_id"]],
65 "type" => ["text", $type],
66 "characteristic" => ["text", $class],
67 "hide" => ["integer", $hide]
68 ];
69 $db->insert("style_char", $values);
70
71 $sql =
72 "SELECT id, style_id, tag, class, parameter, value, type, mq_id, custom" . PHP_EOL
73 . "FROM style_parameter" . PHP_EOL
74 . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
75 . "AND type = " . $db->quote($type, "text") . PHP_EOL
76 . "AND class = " . $db->quote($orig_class, "text") . PHP_EOL
77 . "AND tag = " . $db->quote($tag, "text") . PHP_EOL
78 ;
79
80 $res = $db->query($sql);
81
82 while ($row_2 = $db->fetchAssoc($res)) {
83 $spid = $db->nextId("style_parameter");
84 $values = [
85 "id" => ["integer", $spid],
86 "style_id" => ["integer", $row["obj_id"]],
87 "tag" => ["text", $tag],
88 "class" => ["text", $class],
89 "parameter" => ["text", $row_2["parameter"]],
90 "value" => ["text", $row_2["value"]],
91 "type" => ["text", $row_2["type"]]
92 ];
93 $db->insert("style_parameter", $values);
94 }
95 }
96 }
97 }
98
104 public static function addStyleClass(
105 string $class,
106 string $type,
107 string $tag,
108 array $parameters = [],
109 int $hide = 0
110 ): void {
111 global $ilDB;
112 $db = $ilDB;
113
114 $sql =
115 "SELECT obj_id" . PHP_EOL
116 . "FROM object_data" . PHP_EOL
117 . "WHERE type = 'sty'" . PHP_EOL
118 ;
119 $result = $db->query($sql);
120
121 while ($row = $db->fetchAssoc($result)) {
122 $sql =
123 "SELECT style_id, type, characteristic, hide" . PHP_EOL
124 . "FROM style_char" . PHP_EOL
125 . "WHERE style_id = " . $db->quote($row["obj_id"], "integer") . PHP_EOL
126 . "AND characteristic = " . $db->quote($class, "text") . PHP_EOL
127 . "AND type = " . $db->quote($type, "text") . PHP_EOL;
128 $res = $db->query($sql);
129
130 if (!$db->fetchAssoc($res)) {
131 $values = [
132 "style_id" => ["integer", $row["obj_id"]],
133 "type" => ["text", $type],
134 "characteristic" => ["text", $class],
135 "hide" => ["integer", $hide]
136 ];
137 $db->insert("style_char", $values);
138
139 foreach ($parameters as $k => $v) {
140 $spid = $db->nextId("style_parameter");
141 $values = [
142 "id" => ["integer", $spid],
143 "style_id" => ["integer", $row["obj_id"]],
144 "tag" => ["text", $tag],
145 "class" => ["text", $class],
146 "parameter" => ["text", $k],
147 "value" => ["text", $v],
148 "type" => ["text", $type]
149 ];
150 $db->insert("style_parameter", $values);
151 }
152 }
153 }
154 }
155}
Update class for step 3136.
static addStyleClass(string $class, string $type, string $tag, array $parameters=[], int $hide=0)
Add style class.
static copyStyleClass(string $orig_class, string $class, string $type, string $tag, int $hide=0)
Create style class GlossaryLink, link, IntLink.
$res
Definition: ltiservices.php:69