ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 public function step_6(): void
154 {
155 }
156 public function step_7(): void
157 {
158 $content = <<<EOT
159<PageObject><PageContent PCID="0568f23f59f828dd532cd77c66dcea97"><Grid><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="7" WIDTH_L="8" WIDTH_XL="8" PCID="2fe139a171c9276193832c2d64f5822b"><PageContent PCID="1f77eb1d8a478497d69b99d938fda8f"><PlaceHolder ContentClass="Text" Height="500px"/></PageContent></GridCell><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="5" WIDTH_L="4" WIDTH_XL="4" PCID="010960eb5296c409d0b5070e186f033e"><PageContent PCID="2e77eb1d8a478497d69b99d938fda8e"><PlaceHolder ContentClass="Media" Height="500px"/></PageContent></GridCell></Grid></PageContent></PageObject>
160EOT;
161 $this->db->update(
162 "page_object",
163 [
164 "content" => ["clob", $content]
165 ],
166 [ // where
167 "page_id" => ["integer", 1],
168 "parent_type" => ["text", "stys"],
169 "lang" => ["text", '-'],
170 ]
171 );
172 }
173
174 public function step_8(): void
175 {
176 $content = <<<EOT
177<PageObject><PageContent PCID="336db62153bc33b955c8eab6b4ba1331"><Grid><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="7" WIDTH_L="8" WIDTH_XL="8" PCID="18772b9425070318d27bb2fdaf6b6bdf"><PageContent PCID="1f77eb1d8a478497d69b99d938fda8f"><PlaceHolder ContentClass="Text" Height="300px"/></PageContent></GridCell><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="5" WIDTH_L="4" WIDTH_XL="4" PCID="4309720c697857f55946691119fd7f10"><PageContent PCID="2e77eb1d8a478497d69b99d938fda8e"><PlaceHolder ContentClass="Media" Height="300px"/></PageContent></GridCell></Grid></PageContent><PageContent PCID="3f77eb1d8a478493d69b99d438fda8f"><PlaceHolder ContentClass="Question" Height="200px"/></PageContent></PageObject>
178EOT;
179 $this->db->update(
180 "page_object",
181 [
182 "content" => ["clob", $content]
183 ],
184 [ // where
185 "page_id" => ["integer", 2],
186 "parent_type" => ["text", "stys"],
187 "lang" => ["text", '-'],
188 ]
189 );
190 }
191
192 public function step_9(): void
193 {
194 $content = <<<EOT
195<PageObject><PageContent PCID="6239da5ab9497f14774a2cceb5525c3d"><Grid><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="5" WIDTH_L="4" WIDTH_XL="4" PCID="2f9835a738e7c83dbef27915816b0f5a"><PageContent PCID="2e77eb1d8a478497d69b99d938fda8e"><PlaceHolder ContentClass="Media" Height="500px"/></PageContent></GridCell><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="7" WIDTH_L="8" WIDTH_XL="8" PCID="1d74da9bf94b63e8c85a451399b624d9"><PageContent PCID="1f77eb1d8a478497d69b99d938fda8f"><PlaceHolder ContentClass="Text" Height="500px"/></PageContent></GridCell></Grid></PageContent></PageObject>
196EOT;
197 $this->db->update(
198 "page_object",
199 [
200 "content" => ["clob", $content]
201 ],
202 [ // where
203 "page_id" => ["integer", 3],
204 "parent_type" => ["text", "stys"],
205 "lang" => ["text", '-'],
206 ]
207 );
208 }
209
210 public function step_10(): void
211 {
212 $content = <<<EOT
213<PageObject><PageContent PCID="906a03fd9999c5c83a7166e9f9744fec"><Grid><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="5" WIDTH_L="4" WIDTH_XL="4" PCID="a27f25a9b1d8746d1cf3820759f37096"><PageContent PCID="2e77eb1d8a478497d69b99d938fda8e"><PlaceHolder ContentClass="Media" Height="300px"/></PageContent></GridCell><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="7" WIDTH_L="8" WIDTH_XL="8" PCID="8e769877102068dca417222215defaa9"><PageContent PCID="1f77eb1d8a478497d69b99d938fda8f"><PlaceHolder ContentClass="Text" Height="300px"/></PageContent></GridCell></Grid></PageContent><PageContent PCID="3f77eb1d8a478493d69b99d438fda8f"><PlaceHolder ContentClass="Question" Height="200px"/></PageContent></PageObject>
214EOT;
215 $this->db->update(
216 "page_object",
217 [
218 "content" => ["clob", $content]
219 ],
220 [ // where
221 "page_id" => ["integer", 4],
222 "parent_type" => ["text", "stys"],
223 "lang" => ["text", '-'],
224 ]
225 );
226 }
227
228 public function step_11(): void
229 {
230 $content = <<<EOT
231<PageObject><PageContent PCID="0fb0511a01dcb9b83d9f21eb0d588a19"><Grid><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="4" WIDTH_L="4" WIDTH_XL="4" PCID="b241816c4270ec842782a664cbe72979"><PageContent PCID="428c956f8035dc8ac59a9412bc19f955"><PlaceHolder Height="250px" ContentClass="Media"/></PageContent><PageContent PCID="6d0291683f92aa84920755184b0da66c"><PlaceHolder Height="250px" ContentClass="Text"/></PageContent></GridCell><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="4" WIDTH_L="4" WIDTH_XL="4" PCID="375c6f40533390645bd1bb58259bec54"><PageContent PCID="41f4e5a703244309231c2d6be0c49231"><PlaceHolder Height="250px" ContentClass="Media"/></PageContent><PageContent PCID="325dac9e34424f129a4e4f9a0c4e37c4"><PlaceHolder Height="250px" ContentClass="Text"/></PageContent></GridCell><GridCell WIDTH_XS="" WIDTH_S="12" WIDTH_M="4" WIDTH_L="4" WIDTH_XL="4" PCID="d8379b454401c9b7071d32efb69cc028"><PageContent PCID="5e744ec7c8784471e4668bcbc5e4b405"><PlaceHolder Height="250px" ContentClass="Media"/></PageContent><PageContent PCID="0ba252ad3ab834e2c8fba58708dc1995"><PlaceHolder Height="250px" ContentClass="Text"/></PageContent></GridCell></Grid></PageContent></PageObject>
232EOT;
233 $this->db->update(
234 "page_object",
235 [
236 "content" => ["clob", $content]
237 ],
238 [ // where
239 "page_id" => ["integer", 5],
240 "parent_type" => ["text", "stys"],
241 "lang" => ["text", '-'],
242 ]
243 );
244 }
245
246 public function step_12(): void
247 {
248 $layout_id = $this->db->nextId("page_layout");
249 $this->db->insert("page_layout", array(
250 "layout_id" => array("integer", $layout_id),
251 "active" => array("integer", 1),
252 "title" => array("text", "Leading image with text"),
253 "content" => array("clob", ""),
254 "description" => array("text", "")
255 ));
256
257 $content = <<<EOT
258<PageObject><PageContent PCID="6b1a4e68d752380bf108afff7fa66595"><PlaceHolder Height="300px" ContentClass="Media"/></PageContent><PageContent PCID="8535f59bec330f1cc30286898a36356f"><PlaceHolder Height="200px" ContentClass="Text"/></PageContent></PageObject>
259EOT;
260 $this->db->insert("page_object", array(
261 "page_id" => array("integer", $layout_id),
262 "parent_type" => array("text", "stys"),
263 "content" => array("clob", $content),
264 "lang" => array("text", "-")
265 ));
266 }
267
268 public function step_13(): void
269 {
270 if ($this->db->tableExists("copg_pc_def")) {
271 $query = "UPDATE copg_pc_def SET " . PHP_EOL
272 . " component = REPLACE(component, 'Modules', 'components/ILIAS') " . PHP_EOL
273 . " WHERE component LIKE ('Modules/%')";
274
275 $this->db->manipulate($query);
276 }
277 }
278
279 public function step_14(): void
280 {
281 if ($this->db->tableExists("copg_pc_def")) {
282 $query = "UPDATE copg_pc_def SET " . PHP_EOL
283 . " component = REPLACE(component, 'Services', 'components/ILIAS') " . PHP_EOL
284 . " WHERE component LIKE ('Services/%')";
285
286 $this->db->manipulate($query);
287 }
288 }
289}
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