1 | <?php |
||
14 | class Configuration { |
||
15 | |||
16 | const KEYMARKER = '____'; |
||
17 | |||
18 | protected $_name = 'conf'; // name of the config variable found in the files (overridden by $config['varname']) |
||
19 | protected $_format = 'php'; // format of the config file, supported formats - php (overridden by $config['format']) |
||
20 | protected $_heading = ''; // heading string written at top of config file - don't include comment indicators |
||
21 | |||
22 | /** @var ConfigParser */ |
||
23 | protected $parser; |
||
24 | |||
25 | protected $_loaded = false; // set to true after configuration files are loaded |
||
26 | protected $_metadata = array();// holds metadata describing the settings |
||
27 | |||
28 | public $locked = false; // configuration is considered locked if it can't be updated |
||
29 | public $show_disabled_plugins = false; |
||
30 | |||
31 | // configuration filenames |
||
32 | protected $_default_files = array(); |
||
33 | protected $_local_files = array(); // updated configuration is written to the first file |
||
34 | protected $_protected_files = array(); |
||
35 | |||
36 | protected $_plugin_list = null; |
||
37 | |||
38 | /** @var ConfigSettings FIXME better name? */ |
||
39 | protected $confset; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * constructor |
||
44 | * |
||
45 | * @param string $datafile path to config metadata file |
||
46 | */ |
||
47 | public function __construct($datafile) { |
||
68 | |||
69 | /** |
||
70 | * Stores setting[] array to file |
||
71 | * |
||
72 | * @param string $id Name of plugin, which saves the settings |
||
73 | * @param string $header Text at the top of the rewritten settings file |
||
74 | * @param bool $backup backup current file? (remove any existing backup) |
||
75 | * @return bool succesful? |
||
76 | */ |
||
77 | public function save_settings($id, $header = '', $backup = true) { |
||
111 | |||
112 | /** |
||
113 | * Update last modified time stamp of the config file |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | public function touch_settings() { |
||
122 | |||
123 | /** |
||
124 | * Returns header of rewritten settings file |
||
125 | * |
||
126 | * @param string $id plugin name of which generated this output |
||
127 | * @param string $header additional text for at top of the file |
||
128 | * @return string text of header |
||
129 | */ |
||
130 | protected function _out_header($id, $header) { |
||
144 | |||
145 | /** |
||
146 | * Returns footer of rewritten settings file |
||
147 | * |
||
148 | * @return string text of footer |
||
149 | */ |
||
150 | protected function _out_footer() { |
||
158 | |||
159 | /** |
||
160 | * Configuration is considered locked if there is no local settings filename |
||
161 | * or the directory its in is not writable or the file exists and is not writable |
||
162 | * |
||
163 | * @return bool true: locked, false: writable |
||
164 | */ |
||
165 | protected function _is_locked() { |
||
175 | |||
176 | } |
||
177 | |||
178 |
If you suppress an error, we recommend checking for the error condition explicitly: