ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStyleDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
20
25{
26 protected \ilDBInterface $db;
27
28 public function prepare(\ilDBInterface $db): void
29 {
30 $this->db = $db;
31 }
32
33 public function step_1(): void
34 {
35 if (!$this->db->tableExists('style_char_title')) {
36 $fields = [
37 'type' => [
38 'type' => 'text',
39 'length' => 30,
40 'notnull' => true
41 ],
42 'characteristic' => [
43 'type' => 'text',
44 'length' => 30,
45 'notnull' => true
46 ],
47 'lang' => [
48 'type' => 'text',
49 'length' => 2,
50 'notnull' => true
51 ],
52 'title' => [
53 'type' => 'text',
54 'length' => 200,
55 'notnull' => false
56 ]
57 ];
58
59 $this->db->createTable('style_char_title', $fields);
60 $this->db->addPrimaryKey('style_char_title', ['type', 'characteristic', 'lang']);
61 }
62 }
63
64 public function step_2()
65 {
66 $this->db->dropPrimaryKey('style_char_title');
67 if (!$this->db->tableColumnExists('style_char_title', 'style_id')) {
68 $this->db->addTableColumn('style_char_title', 'style_id', array(
69 "type" => "integer",
70 "notnull" => true,
71 "length" => 4
72 ));
73 }
74 $this->db->addPrimaryKey('style_char_title', ['style_id', 'type', 'characteristic', 'lang']);
75 }
76
77 public function step_3()
78 {
79 if (!$this->db->tableColumnExists('style_char', 'order_nr')) {
80 $this->db->addTableColumn('style_char', 'order_nr', array(
81 "type" => "integer",
82 "notnull" => true,
83 "length" => 4,
84 "default" => 0
85 ));
86 }
87 }
88
89 public function step_4()
90 {
91 if (!$this->db->tableColumnExists('style_char', 'deprecated')) {
92 $this->db->addTableColumn('style_char', 'deprecated', array(
93 "type" => "integer",
94 "notnull" => true,
95 "length" => 1,
96 "default" => 0
97 ));
98 }
99 }
100
101 public function step_5()
102 {
103 $this->db->renameTableColumn('style_char', "deprecated", 'outdated');
104 }
105
106 public function step_6()
107 {
108 if (!$this->db->tableExists('sty_rep_container')) {
109 $fields = [
110 'ref_id' => [
111 'type' => 'integer',
112 'length' => 4,
113 'notnull' => true,
114 'default' => 0
115 ],
116 'reuse' => [
117 'type' => 'integer',
118 'length' => 1,
119 'notnull' => true,
120 'default' => 0
121 ]
122 ];
123
124 $this->db->createTable('sty_rep_container', $fields);
125 $this->db->addPrimaryKey('sty_rep_container', ['ref_id']);
126 }
127 }
128
129 public function step_7()
130 {
131 $set = $this->db->queryF(
132 "SELECT * FROM content_object ",
133 [],
134 []
135 );
136 while ($rec = $this->db->fetchAssoc($set)) {
137 $this->db->replace(
138 "style_usage",
139 array(
140 "obj_id" => array("integer", (int) $rec["id"])
141 ),
142 array(
143 "style_id" => array("integer", (int) $rec["stylesheet"])
144 )
145 );
146 }
147 }
148
149 public function step_8()
150 {
151 $set = $this->db->queryF(
152 "SELECT * FROM content_page_data ",
153 [],
154 []
155 );
156 while ($rec = $this->db->fetchAssoc($set)) {
157 $this->db->replace(
158 "style_usage",
159 array(
160 "obj_id" => array("integer", (int) $rec["content_page_id"])),
161 array(
162 "style_id" => array("integer", (int) $rec["stylesheet"]))
163 );
164 }
165 }
166
167 public function step_9()
168 {
169 if (!$this->db->tableColumnExists('style_data', 'owner_obj')) {
170 $this->db->addTableColumn('style_data', 'owner_obj', array(
171 'type' => 'integer',
172 'notnull' => false,
173 'length' => 4,
174 'default' => 0
175 ));
176 }
177 }
178
179 public function step_10()
180 {
181 $set = $this->db->queryF(
182 "SELECT * FROM style_data WHERE standard = %s",
183 ["integer"],
184 [0]
185 );
186 while ($rec = $this->db->fetchAssoc($set)) {
187 $set2 = $this->db->queryF(
188 "SELECT * FROM style_usage " .
189 " WHERE style_id = %s ",
190 ["integer"],
191 [$rec["id"]]
192 );
193 while ($rec2 = $this->db->fetchAssoc($set2)) {
194 $this->db->update(
195 "style_data",
196 [
197 "owner_obj" => ["integer", $rec2["obj_id"]]
198 ],
199 [ // where
200 "id" => ["integer", $rec["id"]]
201 ]
202 );
203 }
204 }
205 }
206
207 public function step_11()
208 {
209 // Add new index
210 if (!$this->db->indexExistsByFields('style_template', ['style_id'])) {
211 $this->db->addIndex('style_template', ['style_id'], 'i1');
212 }
213 }
214
215 public function step_12()
216 {
217 // Add new index
218 if (!$this->db->indexExistsByFields('style_usage', array('style_id'))) {
219 $this->db->addIndex('style_usage', array('style_id'), 'i1');
220 }
221 }
222
223 public function step_13()
224 {
225 $this->db->update(
226 "style_parameter",
227 [
228 "tag" => ["text", "p"]
229 ],
230 [ // where
231 "type" => ["text", "text_block"],
232 "tag" => ["text", "div"]
233 ]
234 );
235 }
236
237 public function step_14()
238 {
239 $this->db->update(
240 "style_data",
241 [
242 "uptodate" => ["integer", 0]
243 ],
244 [ // where
245 "uptodate" => ["integer", 1]
246 ]
247 );
248 }
249
250 public function step_15()
251 {
252 $this->db->update(
253 "style_char",
254 [
255 "type" => ["text", "strong"]
256 ],
257 [ // where
258 "type" => ["text", "text_inline"],
259 "characteristic" => ["text", "Strong"]
260 ]
261 );
262 }
263
264 public function step_16()
265 {
266 $this->db->update(
267 "style_parameter",
268 [
269 "tag" => ["text", "strong"],
270 "type" => ["text", "strong"]
271 ],
272 [ // where
273 "type" => ["text", "text_inline"],
274 "tag" => ["text", "span"],
275 "class" => ["text", "Strong"]
276 ]
277 );
278 }
279
280 public function step_17()
281 {
282 $this->db->update(
283 "style_char",
284 [
285 "type" => ["text", "em"]
286 ],
287 [ // where
288 "type" => ["text", "text_inline"],
289 "characteristic" => ["text", "Emph"]
290 ]
291 );
292 }
293
294 public function step_18()
295 {
296 $this->db->update(
297 "style_parameter",
298 [
299 "tag" => ["text", "em"],
300 "type" => ["text", "em"]
301 ],
302 [ // where
303 "type" => ["text", "text_inline"],
304 "tag" => ["text", "span"],
305 "class" => ["text", "Emph"]
306 ]
307 );
308 }
309
310 public function step_19()
311 {
312 $this->db->update(
313 "style_data",
314 [
315 "uptodate" => ["integer", 0]
316 ],
317 [ // where
318 "uptodate" => ["integer", 1]
319 ]
320 );
321 }
322
323 public function step_20()
324 {
325 $this->db->update(
326 "style_data",
327 [
328 "uptodate" => ["integer", 0]
329 ],
330 [ // where
331 "uptodate" => ["integer", 1]
332 ]
333 );
334 }
335
336 public function step_21()
337 {
338 if (!$this->db->tableColumnExists('style_data', 'rid')) {
339 $this->db->addTableColumn('style_data', 'rid', [
340 'type' => 'text',
341 'notnull' => false,
342 'length' => 64,
343 'default' => ''
344 ]);
345 }
346 }
347
348
349}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
return true
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...