|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright (c) 2018 Justin Kuenzel (jukusoft.com) |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Project: JuKuCMS |
|
22
|
|
|
* License: Apache 2.0 license |
|
23
|
|
|
* User: Justin |
|
24
|
|
|
* Date: 08.04.2018 |
|
25
|
|
|
* Time: 14:45 |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
class PluginInstaller { |
|
29
|
|
|
|
|
30
|
|
|
//plugin to install / deinstall |
|
31
|
|
|
protected $plugin = null; |
|
32
|
|
|
|
|
33
|
|
|
public function __construct(Plugin $plugin) { |
|
34
|
|
|
$this->plugin = $plugin; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* check php version, php extensions and so on |
|
39
|
|
|
* |
|
40
|
|
|
* @return mixed true, if all required plugins are available, or an array with missing |
|
41
|
|
|
*/ |
|
42
|
|
|
public function checkRequirements () { |
|
43
|
|
|
//get require |
|
44
|
|
|
$require_array = $this->plugin->getRequiredPlugins(); |
|
45
|
|
|
|
|
46
|
|
|
//get package list |
|
47
|
|
|
require(STORE_PATH . "package_list.php"); |
|
48
|
|
|
|
|
49
|
|
|
$missing_plugins = array(); |
|
50
|
|
|
|
|
51
|
|
|
//iterate through all requirements |
|
52
|
|
|
foreach ($require_array as $requirement=>$version) { |
|
53
|
|
|
if ($requirement === "php") { |
|
54
|
|
|
//TODO: check php version |
|
55
|
|
|
} else if (PHPUtils::startsWith($requirement, "ext-")) { |
|
56
|
|
|
//check php extension |
|
57
|
|
|
} else if (PHPUtils::startsWith($requirement, "package-")) { |
|
58
|
|
|
//TODO: check if package is installed |
|
59
|
|
|
$package = str_replace("package-", "", $requirement); |
|
60
|
|
|
|
|
61
|
|
|
//packages doesnt supports version |
|
62
|
|
|
|
|
63
|
|
|
if (!isset($package_list[$package])) { |
|
|
|
|
|
|
64
|
|
|
$missing_plugins[] = $requirement; |
|
65
|
|
|
} |
|
66
|
|
|
} else if ($requirement === "core") { |
|
67
|
|
|
//TODO: check core version |
|
68
|
|
|
} else { |
|
69
|
|
|
//TODO: check installed plugins |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if (empty($missing_plugins)) { |
|
74
|
|
|
return true; |
|
75
|
|
|
} else { |
|
76
|
|
|
return $missing_plugins; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
?> |
|
|
|
|
|
|
83
|
|
|
|