ILIAS  release_8 Revision v8.24
class.ilCOPageDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\COPage\Setup;
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 $field = array(
36 'type' => 'integer',
37 'length' => 2,
38 'notnull' => true,
39 'default' => 0
40 );
41
42 $this->db->modifyTableColumn("copg_pc_def", "order_nr", $field);
43 }
44
45 public function step_2(): void
46 {
47 $field = array(
48 'type' => 'integer',
49 'length' => 4,
50 'notnull' => true,
51 'default' => 0
52 );
53
54 $this->db->modifyTableColumn("copg_pc_def", "order_nr", $field);
55 }
56
57 public function step_3(): void
58 {
59 $this->db->update(
60 "page_layout",
61 [
62 "title" => ["text", "Text page with accompanying media"]
63 ],
64 [ // where
65 "title" => ["text", "1A Simple text page with accompanying media"]
66 ]
67 );
68 $this->db->update(
69 "page_layout",
70 [
71 "title" => ["text", "Text page with accompanying media and test"]
72 ],
73 [ // where
74 "title" => ["text", "1C Text page with accompanying media and test"]
75 ]
76 );
77 $this->db->update(
78 "page_layout",
79 [
80 "title" => ["text", "Text page with accompanying media followed by test and text"]
81 ],
82 [ // where
83 "title" => ["text", "1E Text page with accompanying media followed by test and text"]
84 ]
85 );
86 $this->db->update(
87 "page_layout",
88 [
89 "title" => ["text", "Media page with accompanying text and test"]
90 ],
91 [ // where
92 "title" => ["text", "2C Simple media page with accompanying text and test"]
93 ]
94 );
95 $this->db->update(
96 "page_layout",
97 [
98 "title" => ["text", "Vertical component navigation page with media and text "]
99 ],
100 [ // where
101 "title" => ["text", "7C Vertical component navigation page with media and text"]
102 ]
103 );
104 }
105
106 public function step_4(): void
107 {
108 if (!$this->db->tableColumnExists('page_object', 'est_reading_time')) {
109 $this->db->addTableColumn('page_object', 'est_reading_time', array(
110 'type' => 'integer',
111 'notnull' => true,
112 'length' => 4,
113 'default' => 0
114 ));
115 }
116 }
117
118 public function step_5(): void
119 {
120 $set = $this->db->queryF(
121 "SELECT content FROM page_object " .
122 " WHERE page_id = %s AND parent_type = %s AND lang = %s",
123 ["integer", "text", "text"],
124 [5, "stys", "-"]
125 );
126 while ($rec = $this->db->fetchAssoc($set)) {
127 $content = $rec["content"];
128
129 $replacements = [
130 ["a4e417c08feebeafb1487e60a2e245a4", "a4e417c08feebeafb1487e60a2e245a5"],
131 ["a4e417c08feebeafb1487e60a2e245a4", "a4e417c08feebeafb1487e60a2e245a6"],
132 ["a4e417c08feebeafb1487e60a2e245a5", "a4e417c08feebeafb1487e60a2e245a7"],
133 ["a4e417c08feebeafb1487e60a2e245a5", "a4e417c08feebeafb1487e60a2e245a8"]
134 ];
135
136 foreach ($replacements as $r) {
137 $content = preg_replace('/' . $r[0] . '/', $r[1], $content, 1);
138 }
139
140 $this->db->update(
141 "page_object",
142 [
143 "content" => ["clob", $content]
144 ],
145 [ // where
146 "page_id" => ["integer", 5],
147 "parent_type" => ["text", "stys"],
148 "lang" => ["text", '-'],
149 ]
150 );
151 }
152 }
153}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
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...
Definition: class.Agent.php:19