blob: a571149f011741ef4f097dcb77550e1e02582169 (
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
|
<?php
namespace dokuwiki\plugin\config\core\Setting;
/**
* Class setting_dirchoice
*/
class SettingDirchoice extends SettingMultichoice
{
protected $dir = '';
/** @inheritdoc */
public function initialize($default = null, $local = null, $protected = null)
{
// populate $this->_choices with a list of directories
$list = [];
if ($dh = @opendir($this->dir)) {
while (false !== ($entry = readdir($dh))) {
if ($entry == '.' || $entry == '..') continue;
if ($this->pattern && !preg_match($this->pattern, $entry)) continue;
$file = (is_link($this->dir . $entry)) ? readlink($this->dir . $entry) : $this->dir . $entry;
if (is_dir($file)) $list[] = $entry;
}
closedir($dh);
}
sort($list);
$this->choices = $list;
parent::initialize($default, $local, $protected);
}
}
|