summaryrefslogtreecommitdiff
path: root/lib/plugins/config/settings/extra.class.php
blob: 0c5d9866e2dd694056e74ed859b7aa4c48a10f17 (plain)
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
<?php
/**
 * additional setting classes specific to these settings
 *
 * @author    Chris Smith <chris@jalakai.co.uk>
 */

if (!class_exists('setting_sepchar')) {
  class setting_sepchar extends setting_multichoice {
    
    function setting_sepchar($key,$param=NULL) {
        $str = '_-.0123456789abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        for ($i=0;$i<strlen($str);$i++) $this->_choices[] = $str{$i};        
        
        // call foundation class constructor
        $this->setting($key,$param);
    }
  }
}

if (!class_exists('setting_savedir')) {
  class setting_savedir extends setting {

    function update($input) {
        if ($this->is_protected()) return false;
        
        $value = is_null($this->_local) ? $this->_default : $this->_local;
        if ($value == $input) return false;

        if (!init_path($input)) {
          $this->_error = true;
          $this->_input = $input;
          return false;
        }
        
        $this->_local = $input;
        return true;
    }
  }
}

if (!class_exists('setting_authtype')) {
  class setting_authtype extends setting {
    var $_pattern = '#^[a-zA-Z0-9_]*$#';

    function update($input) {
        if ($this->is_protected()) return false;
        
        $input = trim($input);
        
        $value = is_null($this->_local) ? $this->_default : $this->_local;
        if ($value == $input) return false;

        if (preg_match($this->_pattern, $input)) {
          if (@file_exists(DOKU_INC.'inc/auth/'.$input.'.class.php') ||
              @file_exists(DOKU_INC.'inc/auth/'.$input.'.php')) {
            $this->_local = $input;
            return true;
          }
        }
        
        $this->_error = true;
        $this->_input = $input;
        return false;    
    }
  }
}

if (!class_exists('setting_im_convert')) {
  class setting_im_convert extends setting {

    function update($input) {
        if ($this->is_protected()) return false;
        
        $input = trim($input);
        
        $value = is_null($this->_local) ? $this->_default : $this->_local;
        if ($value == $input) return false;

        if ($input && !@file_exists($input)) {
          $this->_error = true;
          $this->_input = $input;
          return false;    
        }
        
        $this->_local = $input;
        return true;
    }
  }
}