aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/config/ConfigManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/config/ConfigManager.php')
-rw-r--r--application/config/ConfigManager.php83
1 files changed, 54 insertions, 29 deletions
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php
index 70456737..a663a071 100644
--- a/application/config/ConfigManager.php
+++ b/application/config/ConfigManager.php
@@ -116,6 +116,11 @@ class ConfigManager
116 */ 116 */
117 public function get($setting, $default = '') 117 public function get($setting, $default = '')
118 { 118 {
119 // During the ConfigIO transition, map legacy settings to the new ones.
120 if ($this->configIO instanceof ConfigPhp && isset(ConfigPhp::$LEGACY_KEYS_MAPPING[$setting])) {
121 $setting = ConfigPhp::$LEGACY_KEYS_MAPPING[$setting];
122 }
123
119 $settings = explode('.', $setting); 124 $settings = explode('.', $setting);
120 $value = self::getConfig($settings, $this->loadedConfig); 125 $value = self::getConfig($settings, $this->loadedConfig);
121 if ($value === self::$NOT_FOUND) { 126 if ($value === self::$NOT_FOUND) {
@@ -142,6 +147,11 @@ class ConfigManager
142 throw new Exception('Invalid setting key parameter. String expected, got: '. gettype($setting)); 147 throw new Exception('Invalid setting key parameter. String expected, got: '. gettype($setting));
143 } 148 }
144 149
150 // During the ConfigIO transition, map legacy settings to the new ones.
151 if ($this->configIO instanceof ConfigPhp && isset(ConfigPhp::$LEGACY_KEYS_MAPPING[$setting])) {
152 $setting = ConfigPhp::$LEGACY_KEYS_MAPPING[$setting];
153 }
154
145 $settings = explode('.', $setting); 155 $settings = explode('.', $setting);
146 self::setConfig($settings, $value, $this->loadedConfig); 156 self::setConfig($settings, $value, $this->loadedConfig);
147 if ($write) { 157 if ($write) {
@@ -160,6 +170,11 @@ class ConfigManager
160 */ 170 */
161 public function exists($setting) 171 public function exists($setting)
162 { 172 {
173 // During the ConfigIO transition, map legacy settings to the new ones.
174 if ($this->configIO instanceof ConfigPhp && isset(ConfigPhp::$LEGACY_KEYS_MAPPING[$setting])) {
175 $setting = ConfigPhp::$LEGACY_KEYS_MAPPING[$setting];
176 }
177
163 $settings = explode('.', $setting); 178 $settings = explode('.', $setting);
164 $value = self::getConfig($settings, $this->loadedConfig); 179 $value = self::getConfig($settings, $this->loadedConfig);
165 if ($value === self::$NOT_FOUND) { 180 if ($value === self::$NOT_FOUND) {
@@ -183,8 +198,15 @@ class ConfigManager
183 { 198 {
184 // These fields are required in configuration. 199 // These fields are required in configuration.
185 $mandatoryFields = array( 200 $mandatoryFields = array(
186 'login', 'hash', 'salt', 'timezone', 'title', 'titleLink', 201 'credentials.login',
187 'redirector', 'disablesessionprotection', 'privateLinkByDefault' 202 'credentials.hash',
203 'credentials.salt',
204 'security.session_protection_disabled',
205 'general.timezone',
206 'general.title',
207 'general.header_link',
208 'general.default_private_links',
209 'extras.redirector',
188 ); 210 );
189 211
190 // Only logged in user can alter config. 212 // Only logged in user can alter config.
@@ -265,75 +287,78 @@ class ConfigManager
265 protected function setDefaultValues() 287 protected function setDefaultValues()
266 { 288 {
267 // Data subdirectory 289 // Data subdirectory
268 $this->setEmpty('config.DATADIR', 'data'); 290 $this->setEmpty('path.data_dir', 'data');
269 291
270 // Main configuration file 292 // Main configuration file
271 $this->setEmpty('config.CONFIG_FILE', 'data/config.php'); 293 $this->setEmpty('path.config', 'data/config.php');
272 294
273 // Link datastore 295 // Link datastore
274 $this->setEmpty('config.DATASTORE', 'data/datastore.php'); 296 $this->setEmpty('path.datastore', 'data/datastore.php');
275 297
276 // Banned IPs 298 // Banned IPs
277 $this->setEmpty('config.IPBANS_FILENAME', 'data/ipbans.php'); 299 $this->setEmpty('path.ban_file', 'data/ipbans.php');
278 300
279 // Processed updates file. 301 // Processed updates file.
280 $this->setEmpty('config.UPDATES_FILE', 'data/updates.txt'); 302 $this->setEmpty('path.updates', 'data/updates.txt');
281 303
282 // Access log 304 // Access log
283 $this->setEmpty('config.LOG_FILE', 'data/log.txt'); 305 $this->setEmpty('path.log', 'data/log.txt');
284 306
285 // For updates check of Shaarli 307 // For updates check of Shaarli
286 $this->setEmpty('config.UPDATECHECK_FILENAME', 'data/lastupdatecheck.txt'); 308 $this->setEmpty('path.update_check', 'data/lastupdatecheck.txt');
287 309
288 // Set ENABLE_UPDATECHECK to disabled by default. 310 // Set ENABLE_UPDATECHECK to disabled by default.
289 $this->setEmpty('config.ENABLE_UPDATECHECK', false); 311 $this->setEmpty('general.check_updates', false);
290 312
291 // RainTPL cache directory (keep the trailing slash!) 313 // RainTPL cache directory (keep the trailing slash!)
292 $this->setEmpty('config.RAINTPL_TMP', 'tmp/'); 314 $this->setEmpty('path.raintpl_tmp', 'tmp/');
293 // Raintpl template directory (keep the trailing slash!) 315 // Raintpl template directory (keep the trailing slash!)
294 $this->setEmpty('config.RAINTPL_TPL', 'tpl/'); 316 $this->setEmpty('path.raintpl_tpl', 'tpl/');
295 317
296 // Thumbnail cache directory 318 // Thumbnail cache directory
297 $this->setEmpty('config.CACHEDIR', 'cache'); 319 $this->setEmpty('path.thumbnails_cache', 'cache');
298 320
299 // Atom & RSS feed cache directory 321 // Atom & RSS feed cache directory
300 $this->setEmpty('config.PAGECACHE', 'pagecache'); 322 $this->setEmpty('path.page_cache', 'pagecache');
301 323
302 // Ban IP after this many failures 324 // Ban IP after this many failures
303 $this->setEmpty('config.BAN_AFTER', 4); 325 $this->setEmpty('security.ban_after', 4);
304 // Ban duration for IP address after login failures (in seconds) 326 // Ban duration for IP address after login failures (in seconds)
305 $this->setEmpty('config.BAN_DURATION', 1800); 327 $this->setEmpty('security.ban_after', 1800);
306 328
307 // Feed options 329 // Feed options
308 // Enable RSS permalinks by default. 330 // Enable RSS permalinks by default.
309 // This corresponds to the default behavior of shaarli before this was added as an option. 331 // This corresponds to the default behavior of shaarli before this was added as an option.
310 $this->setEmpty('config.ENABLE_RSS_PERMALINKS', true); 332 $this->setEmpty('general.rss_permalinks', true);
311 // If true, an extra "ATOM feed" button will be displayed in the toolbar 333 // If true, an extra "ATOM feed" button will be displayed in the toolbar
312 $this->setEmpty('config.SHOW_ATOM', false); 334 $this->setEmpty('extras.show_atom', false);
313 335
314 // Link display options 336 // Link display options
315 $this->setEmpty('config.HIDE_PUBLIC_LINKS', false); 337 $this->setEmpty('extras.hide_public_links', false);
316 $this->setEmpty('config.HIDE_TIMESTAMPS', false); 338 $this->setEmpty('extras.hide_timestamps', false);
317 $this->setEmpty('config.LINKS_PER_PAGE', 20); 339 $this->setEmpty('general.links_per_page', 20);
340
341 // Private checkbox is checked by default
342 $this->setEmpty('general.default_private_links', false);
318 343
319 // Open Shaarli (true): anyone can add/edit/delete links without having to login 344 // Open Shaarli (true): anyone can add/edit/delete links without having to login
320 $this->setEmpty('config.OPEN_SHAARLI', false); 345 $this->setEmpty('extras.open_shaarli', false);
321 346
322 // Thumbnails 347 // Thumbnails
323 // Display thumbnails in links 348 // Display thumbnails in links
324 $this->setEmpty('config.ENABLE_THUMBNAILS', true); 349 $this->setEmpty('general.enable_thumbnails', true);
325 // Store thumbnails in a local cache 350 // Store thumbnails in a local cache
326 $this->setEmpty('config.ENABLE_LOCALCACHE', true); 351 $this->setEmpty('general.enable_localcache', true);
327 352
328 // Update check frequency for Shaarli. 86400 seconds=24 hours 353 // Update check frequency for Shaarli. 86400 seconds=24 hours
329 $this->setEmpty('config.UPDATECHECK_BRANCH', 'stable'); 354 $this->setEmpty('general.check_updates_branch', 'stable');
330 $this->setEmpty('config.UPDATECHECK_INTERVAL', 86400); 355 $this->setEmpty('general.check_updates_interval', 86400);
331 356
332 $this->setEmpty('redirector', ''); 357 $this->setEmpty('extras.redirector', '');
333 $this->setEmpty('config.REDIRECTOR_URLENCODE', true); 358 $this->setEmpty('extras.redirector_encode_url', true);
334 359
335 // Enabled plugins. 360 // Enabled plugins.
336 $this->setEmpty('config.ENABLED_PLUGINS', array('qrcode')); 361 $this->setEmpty('general.enabled_plugins', array('qrcode'));
337 362
338 // Initialize plugin parameters array. 363 // Initialize plugin parameters array.
339 $this->setEmpty('plugins', array()); 364 $this->setEmpty('plugins', array());