diff options
Diffstat (limited to 'platform/www/lib/plugins/config/core/Setting/SettingDirchoice.php')
-rw-r--r-- | platform/www/lib/plugins/config/core/Setting/SettingDirchoice.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/platform/www/lib/plugins/config/core/Setting/SettingDirchoice.php b/platform/www/lib/plugins/config/core/Setting/SettingDirchoice.php new file mode 100644 index 0000000..dfb27f5 --- /dev/null +++ b/platform/www/lib/plugins/config/core/Setting/SettingDirchoice.php @@ -0,0 +1,33 @@ +<?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 = array(); + + 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); + } +} |