1 | <?php |
||
8 | class Setting { |
||
9 | |||
10 | protected $_key = ''; |
||
11 | protected $_default = null; |
||
12 | protected $_local = null; |
||
13 | protected $_protected = null; |
||
14 | |||
15 | protected $_pattern = ''; |
||
16 | protected $_error = false; // only used by those classes which error check |
||
17 | protected $_input = null; // only used by those classes which error check |
||
18 | protected $_caution = null; // used by any setting to provide an alert along with the setting |
||
19 | // valid alerts, 'warning', 'danger', 'security' |
||
20 | // images matching the alerts are in the plugin's images directory |
||
21 | |||
22 | static protected $_validCautions = array('warning', 'danger', 'security'); |
||
23 | |||
24 | /** |
||
25 | * @param string $key |
||
26 | * @param array|null $params array with metadata of setting |
||
27 | */ |
||
28 | public function __construct($key, $params = null) { |
||
37 | |||
38 | /** |
||
39 | * Receives current values for the setting $key |
||
40 | * |
||
41 | * @param mixed $default default setting value |
||
42 | * @param mixed $local local setting value |
||
43 | * @param mixed $protected protected setting value |
||
44 | */ |
||
45 | public function initialize($default, $local, $protected) { |
||
50 | |||
51 | /** |
||
52 | * update changed setting with user provided value $input |
||
53 | * - if changed value fails error check, save it to $this->_input (to allow echoing later) |
||
54 | * - if changed value passes error check, set $this->_local to the new value |
||
55 | * |
||
56 | * @param mixed $input the new value |
||
57 | * @return boolean true if changed, false otherwise (also on error) |
||
58 | */ |
||
59 | public function update($input) { |
||
75 | |||
76 | /** |
||
77 | * Build html for label and input of setting |
||
78 | * |
||
79 | * @param \admin_plugin_config $plugin object of config plugin |
||
80 | * @param bool $echo true: show inputted value, when error occurred, otherwise the stored setting |
||
81 | * @return string[] with content array(string $label_html, string $input_html) |
||
82 | */ |
||
83 | public function html(\admin_plugin_config $plugin, $echo = false) { |
||
105 | |||
106 | /** |
||
107 | * Generate string to save setting value to file according to $fmt |
||
108 | * |
||
109 | * @param string $var name of variable |
||
110 | * @param string $fmt save format |
||
111 | * @return string |
||
112 | */ |
||
113 | public function out($var, $fmt = 'php') { |
||
128 | |||
129 | /** |
||
130 | * Returns the localized prompt |
||
131 | * |
||
132 | * @param \admin_plugin_config $plugin object of config plugin |
||
133 | * @return string text |
||
134 | */ |
||
135 | public function prompt(\admin_plugin_config $plugin) { |
||
140 | |||
141 | /** |
||
142 | * Is setting protected |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function is_protected() { |
||
149 | |||
150 | /** |
||
151 | * Is setting the default? |
||
152 | * |
||
153 | * @return bool |
||
154 | */ |
||
155 | public function is_default() { |
||
158 | |||
159 | /** |
||
160 | * Has an error? |
||
161 | * |
||
162 | * @return bool |
||
163 | */ |
||
164 | public function error() { |
||
167 | |||
168 | /** |
||
169 | * Returns caution |
||
170 | * |
||
171 | * @return false|string caution string, otherwise false for invalid caution |
||
172 | */ |
||
173 | public function caution() { |
||
194 | |||
195 | /** |
||
196 | * Returns setting key, eventually with referer to config: namespace at dokuwiki.org |
||
197 | * |
||
198 | * @param bool $pretty create nice key |
||
199 | * @param bool $url provide url to config: namespace |
||
200 | * @return string key |
||
201 | */ |
||
202 | public function _out_key($pretty = false, $url = false) { |
||
216 | } |
||
217 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.