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