-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.php
152 lines (131 loc) · 3.5 KB
/
module.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
use LithiumHosting\WebApps\DokuWiki\Handler;
use Module\Support\Webapps;
use Module\Support\Webapps\PhpWrapper;
use Module\Support\Webapps\DatabaseGenerator;
use Module\Support\Webapps\VersionFetcher\Github;
use Opcenter\Auth\Password;
use Opcenter\Map;
use Opcenter\Provisioning\ConfigurationWriter;
use Opcenter\SiteConfiguration;
use Opcenter\Versioning;
/**
* DokuWiki management
*
* @package core
*/
class DokuWiki_Module extends Webapps
{
const REGISTERED_HANDLER_KEY = 'webapps.dokuwiki';
const APP_NAME = Handler::NAME;
const DEFAULT_VERSION_LOCK = 'minor';
protected $aclList = [
'min' => [
'data',
'lib/plugins',
'lib/tpl',
'conf/local.php', //for the installer and for subsequent web configuration to work.
'conf/local.php.bak',
'conf/users.auth.php', //for the ACL web configuration and usermanager to work.
'conf/acl.auth.php', //for the ACL web configuration and usermanager to work.
'conf/plugins.local.php', //for the Extension Manager
'conf/plugins.local.php.bak',
],
'max' => [
'data',
'lib/plugins',
'lib/tpl',
],
];
protected const CLEANUP_FILES = [
'COPYING',
'README',
'SECURITY.md'
];
/**
* Install DokuWiki into a pre-existing location
*
* @param string $hostname domain or subdomain to install DokuWiki
* @param string $path optional path under hostname
* @param array $opts additional install options
* @return bool
*/
public function install(string $hostname, string $path = '', array $opts = []): bool
{
if (!version_compare($this->php_version(), '7', '>=')) {
return error('DokuWiki requires PHP7.2 or higher, PHP8+ is recommended');
}
if (!($docroot = $this->getDocumentRoot($hostname, $path))) {
return error("failed to normalize path for `%s'", $hostname);
}
if (!$this->parseInstallOptions($opts, $hostname, $path)) {
return false;
}
$args['version'] = $opts['version'];
/**
* Download - https://github.com/splitbrain/dokuwiki/tarball/stable
* Extract
* Cleanup
* Write conf/local.php
* Write conf/users.auth.php
* Write conf/acl.auth.php
*/
$oldex = Error_Reporter::exception_upgrade(Error_Reporter::E_ERROR);
$approot = $this->getAppRoot($hostname, $path);
// try {
// $this->downloadVersion($approot, $args['version']);
// }
}
/**
* Get all available DokuWiki versions
*
* @return array
*/
public function get_versions(): array
{
$versions = $this->_getVersions();
return array_column(array_filter($versions, static function ($meta) {
return false === strpos($meta['version'], 'A');
}), 'version');
}
/**
* Get all current major versions
*
* @return array
*/
private function _getVersions(): array
{
$key = 'dokuwiki.versions';
$cache = Cache_Super_Global::spawn();
// if (false !== ($ver = $cache->get($key))) {
// return (array)$ver;
// }
$versions = (new Github)->setMode('tags')->fetch('splitbrain/dokuwiki');
$cache->set($key, $versions, 43200);
return $versions;
}
public function get_version(string $hostname, string $path = ''): ?string
{
return '';
// TODO: Implement get_version() method.
}
/**
* Location is a valid DokuWiki install
*
* @param string $hostname or $docroot
* @param string $path
* @return bool
*/
public function valid(string $hostname, string $path = ''): bool
{
if ($hostname[0] === '/') {
$approot = $hostname;
} else {
$approot = $this->getAppRoot($hostname, $path);
if (!$approot) {
return false;
}
}
return $this->file_exists($approot . '/doku.php');
}
}