-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathupdate.php
More file actions
107 lines (91 loc) · 3.36 KB
/
update.php
File metadata and controls
107 lines (91 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* @author https://github.com/FriendsOfREDAXO
* @package redaxo5
* @license MIT
*/
// set default template - always reset to standard on update
$this->setConfig('mblock_theme', 'standard');
if (!$this->hasConfig('mblock_delete')) {
$this->setConfig('mblock_delete', 1);
}
if (!$this->hasConfig('mblock_scroll')) {
$this->setConfig('mblock_scroll', 1);
}
if (!$this->hasConfig('mblock_delete_confirm')) {
$this->setConfig('mblock_delete_confirm', 1);
}
// MBlock 4.0 - Copy/Paste Feature - Default aktiviert für neue und bestehende Installationen
if (!$this->hasConfig('mblock_copy_paste')) {
$this->setConfig('mblock_copy_paste', 1); // Default: aktiviert
}
// MBlock 4.0 - Template System Update
// Löscht alte Default-Templates aus dem data/ Ordner
$dataTemplatesPath = $this->getDataPath('templates/');
if (is_dir($dataTemplatesPath)) {
// Liste der Default-Templates die gelöscht werden sollen
$defaultTemplates = [
'copy_theme',
'default_theme',
];
$deletedCount = 0;
foreach ($defaultTemplates as $templateName) {
$templatePath = $dataTemplatesPath . $templateName;
if (is_dir($templatePath)) {
// Rekursiv löschen
rex_dir::delete($templatePath);
$deletedCount++;
}
}
if ($deletedCount > 0) {
// Prüfen ob templates Ordner leer ist
$remainingFiles = glob($dataTemplatesPath . '*');
if (empty($remainingFiles)) {
// Leeren templates Ordner auch löschen
rmdir($dataTemplatesPath);
}
}
}
// copy data directory (für neue Installationen) oder aktualisiere Templates (bei Updates)
if (!is_dir($this->getDataPath())) {
rex_dir::copy($this->getPath('data'), $this->getDataPath());
}
// Bei jedem Update: Mitgelieferte Templates immer aktualisieren
$addonDataTemplatesPath = $this->getPath('data/templates/');
$userDataTemplatesPath = $this->getDataPath('templates/');
if (is_dir($addonDataTemplatesPath)) {
// Erstelle templates Ordner im data-Verzeichnis falls nicht vorhanden
if (!is_dir($userDataTemplatesPath)) {
rex_dir::create($userDataTemplatesPath);
}
// Kopiere/aktualisiere mitgelieferte Templates - immer überschreiben bei Update
$addonTemplates = glob($addonDataTemplatesPath . '*', GLOB_ONLYDIR);
foreach ($addonTemplates as $templateDir) {
$templateName = basename($templateDir);
$targetDir = $userDataTemplatesPath . $templateName;
// Überschreibe mitgelieferte Templates immer (für Updates)
if (is_dir($templateDir)) {
if (is_dir($targetDir)) {
rex_dir::delete($targetDir);
}
rex_dir::copy($templateDir, $targetDir);
}
}
}
// delete all assets
rex_dir::deleteFiles($this->getAssetsPath(), true);
// copy assets
rex_dir::copy($this->getPath('assets'), $this->getAssetsPath());
// rex media and link updater
$values = array();
for ($i = 1; $i < 21; $i++) {
$values[] = " value{$i} = REPLACE(value{$i}, 'REX_INPUT_L', 'REX_L')";
$values[] = " value{$i} = REPLACE(value{$i}, 'REX_INPUT_M', 'REX_M')";
}
$values = implode(",\n\t", $values);
$prefix = rex::getTablePrefix();
$query= "UPDATE\n\t {$prefix}article_slice \nSET\n\t{$values};\n";
$sql = rex_sql::factory();
$sql->setDebug(false);
$sql->setQuery($query);
$rows = $sql->getRows();