blob: a7046909b9a28a7fcf75bf146258512f9ba7ab96 (
plain) (
blame)
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
|
<?php
namespace dokuwiki\plugin\extension;
class Local
{
/**
* Glob the given directory and init each subdirectory as an Extension
*
* @param string $directory
* @return Extension[]
*/
protected function readExtensionsFromDirectory($directory)
{
$extensions = [];
$directory = rtrim($directory, '/');
$dirs = glob($directory . '/*', GLOB_ONLYDIR);
foreach ($dirs as $dir) {
$ext = Extension::createFromDirectory($dir);
$extensions[$ext->getId()] = $ext;
}
return $extensions;
}
/**
* Get all locally installed templates
*
* @return Extension[]
*/
public function getTemplates()
{
$templates = $this->readExtensionsFromDirectory(DOKU_INC . 'lib/tpl/');
ksort($templates);
return $templates;
}
/**
* Get all locally installed plugins
*
* Note this skips the PluginController and just iterates over the plugin dir,
* it's basically the same as what the PluginController does, but allows us to
* directly initialize Extension objects.
*
* @return Extension[]
*/
public function getPlugins()
{
$plugins = $this->readExtensionsFromDirectory(DOKU_PLUGIN);
ksort($plugins);
return $plugins;
}
/**
* Get all locally installed extensions
*
* @return Extension[]
*/
public function getExtensions()
{
return array_merge($this->getPlugins(), $this->getTemplates());
}
}
|