-
Notifications
You must be signed in to change notification settings - Fork 3
/
upgrade-to-3.10.php
executable file
·128 lines (117 loc) · 4.11 KB
/
upgrade-to-3.10.php
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/php
<?php
require __DIR__.'/util/globrecursive.php';
if (is_file('vkwf_branch') || is_file('kwf_branch')) {
die("This script will update from 3.9, update to 3.9 first.\n");
}
if (!is_file('composer.json')) {
die("composer.json not found.\n");
}
$changed = false;
$c = json_decode(file_get_contents('composer.json'));
foreach ($c->require as $packageName=>$packageVersion) {
if (substr($packageVersion, 0, 4) == "3.9.") {
$c->require->$packageName = '3.10.x-dev';
$changed = true;
}
}
if (!$changed) {
die("This script will update from 3.9, update to 3.9 first.\n");
}
file_put_contents('composer.json', json_encode($c, (defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0) + (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) ));
$files = glob_recursive('Master.tpl');
foreach ($files as $file) {
$c = file_get_contents($file);
$origC = $c;
$c = str_replace("<html", '<html lang="<?=$this->pageLanguage?>"', $c);
if ($c != $origC) {
echo "Added lang attribute to <html: $file\n";
file_put_contents($file, $c);
}
$origC = $c;
$search = '<?=$this->doctype('."'".'XHTML1_STRICT'."'".');?>';
$c = str_replace($search, '<!DOCTYPE html>', $c);
if ($c != $origC) {
echo "Changed doctype to html5 in file: $file\n";
file_put_contents($file, $c);
}
$origC = $c;
$c = str_replace(' xmlns="http://www.w3.org/1999/xhtml"', '', $c);
if ($c != $origC) {
echo "Removed xmlns in file: $file\n";
file_put_contents($file, $c);
}
}
$files = glob_recursive('Master.twig');
foreach ($files as $file) {
$c = file_get_contents($file);
$origC = $c;
$c = str_replace("<html", '<html lang="{{ pageLanguage }}"', $c);
if ($c != $origC) {
echo "Added lang attribute to <html: $file\n";
file_put_contents($file, $c);
}
$origC = $c;
$c = str_replace('<?=$this->doctype(\'XHTML1_STRICT\');?>', '<!DOCTYPE html>', $c);
if ($c != $origC) {
echo "Changed doctype to html5 in file: $file\n";
file_put_contents($file, $c);
}
$origC = $c;
$c = str_replace(' xmlns="http://www.w3.org/1999/xhtml"', '', $c);
if ($c != $origC) {
echo "Removed xmlns in file: $file\n";
file_put_contents($file, $c);
}
}
$files = glob_recursive('Component.php');
foreach ($files as $file) {
$c = file_get_contents($file);
$origC = $c;
$c = str_replace("public function getTemplateVars()", 'public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer = null)', $c);
$c = str_replace("::getTemplateVars()", '::getTemplateVars($renderer)', $c);
if ($c != $origC) {
echo "Added \$renderer in getTemplateVars in file: $file\n";
file_put_contents($file, $c);
}
$origC = $c;
}
$c = file_get_contents('bootstrap.php');
$origC = $c;
$c = str_replace("Kwf_Util_Https::ensureHttps();\n", '', $c);
if ($c != $origC) {
echo "removed Kwf_Util_Https::ensureHttps: bootstrap.php\n";
file_put_contents('bootstrap.php', $c);
}
$c = file_get_contents('config.ini');
$origC = $c;
$c = preg_replace("# *processControl\..*\.cmd\s*=\s*newsletter start *\n#", '', $c);
if ($c != $origC) {
echo "removed processControl newsletter start: config.ini\n";
file_put_contents('config.ini', $c);
}
//try common location for component where boxes are created
$files = array(
'themes/Theme/Component.php',
'components/Root/Component.php',
'components/Root/Domain/Component.php',
'components/Root/Master/Component.php',
);
foreach ($files as $file) {
if (!file_exists($file)) continue;
$c = file_get_contents($file);
$origC = $c;
$c = preg_replace("#\\\$ret\['generators'\]\['openGraph'\].*?\);\s*#s", '', $c);
if ($c != $origC) {
echo "removed openGraph box: $file\n";
file_put_contents($file, $c);
}
}
if (!is_dir('cache/simple')) {
mkdir('cache/simple');
file_put_contents('cache/simple/.gitignore', "*\n!.gitignore\n");
system("git add cache/simple/.gitignore");
echo "folder \"cache/simple\" created\n";
}
echo "\n";
echo "run now 'composer update' to update dependencies\n";