[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/config/core/Setting/ -> SettingDirchoice.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\plugin\config\core\Setting;
   4  
   5  /**
   6   * Class setting_dirchoice
   7   */
   8  class SettingDirchoice extends SettingMultichoice
   9  {
  10      protected $dir = '';
  11  
  12      /** @inheritdoc */
  13      public function initialize($default = null, $local = null, $protected = null)
  14      {
  15  
  16          // populate $this->_choices with a list of directories
  17          $list = [];
  18  
  19          if ($dh = @opendir($this->dir)) {
  20              while (false !== ($entry = readdir($dh))) {
  21                  if ($entry == '.' || $entry == '..') continue;
  22                  if ($this->pattern && !preg_match($this->pattern, $entry)) continue;
  23  
  24                  $file = (is_link($this->dir . $entry)) ? readlink($this->dir . $entry) : $this->dir . $entry;
  25                  if (is_dir($file)) $list[] = $entry;
  26              }
  27              closedir($dh);
  28          }
  29          sort($list);
  30          $this->choices = $list;
  31  
  32          parent::initialize($default, $local, $protected);
  33      }
  34  }