]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Rename configuration key for better sections
authorArthurHoaro <arthur@hoa.ro>
Sat, 11 Jun 2016 07:08:02 +0000 (09:08 +0200)
committerArthurHoaro <arthur@hoa.ro>
Sat, 11 Jun 2016 07:30:56 +0000 (09:30 +0200)
application/ApplicationUtils.php
application/PageBuilder.php
application/Updater.php
application/config/ConfigManager.php
application/config/ConfigPhp.php
index.php
tests/ApplicationUtilsTest.php
tests/Updater/UpdaterTest.php
tests/config/ConfigJsonTest.php
tests/utils/config/configJson.json.php

index c5a157b91f74d0a99b20b9a820a433d868c72f24..e67b29021504ccada967da6dea47d191aa5f6b67 100644 (file)
@@ -145,7 +145,7 @@ class ApplicationUtils
             'application',
             'inc',
             'plugins',
-            $conf->get('path.raintpl_tpl'),
+            $conf->get('resource.raintpl_tpl'),
         ) as $path) {
             if (! is_readable(realpath($path))) {
                 $errors[] = '"'.$path.'" directory is not readable';
@@ -154,10 +154,10 @@ class ApplicationUtils
 
         // Check cache and data directories are readable and writeable
         foreach (array(
-            $conf->get('path.thumbnails_cache'),
-            $conf->get('path.data_dir'),
-            $conf->get('path.page_cache'),
-            $conf->get('path.raintpl_tmp'),
+            $conf->get('resource.thumbnails_cache'),
+            $conf->get('resource.data_dir'),
+            $conf->get('resource.page_cache'),
+            $conf->get('resource.raintpl_tmp'),
         ) as $path) {
             if (! is_readable(realpath($path))) {
                 $errors[] = '"'.$path.'" directory is not readable';
@@ -170,10 +170,10 @@ class ApplicationUtils
         // Check configuration files are readable and writeable
         foreach (array(
             $conf->getConfigFileExt(),
-            $conf->get('path.datastore'),
-            $conf->get('path.ban_file'),
-            $conf->get('path.log'),
-            $conf->get('path.update_check'),
+            $conf->get('resource.datastore'),
+            $conf->get('resource.ban_file'),
+            $conf->get('resource.log'),
+            $conf->get('resource.update_check'),
         ) as $path) {
             if (! is_file(realpath($path))) {
                 # the file may not exist yet
index 843cc0dc136bccad7758dd5adc7343236e67ff75..88dbfa8a4db669e02b507b0dc76bee3634107840 100644 (file)
@@ -41,17 +41,17 @@ class PageBuilder
         try {
             $version = ApplicationUtils::checkUpdate(
                 shaarli_version,
-                $this->conf->get('path.update_check'),
-                $this->conf->get('general.check_updates_interval'),
-                $this->conf->get('general.check_updates'),
+                $this->conf->get('resource.update_check'),
+                $this->conf->get('updates.check_updates_interval'),
+                $this->conf->get('updates.check_updates'),
                 isLoggedIn(),
-                $this->conf->get('general.check_updates_branch')
+                $this->conf->get('updates.check_updates_branch')
             );
             $this->tpl->assign('newVersion', escape($version));
             $this->tpl->assign('versionError', '');
 
         } catch (Exception $exc) {
-            logm($this->conf->get('path.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage());
+            logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage());
             $this->tpl->assign('newVersion', '');
             $this->tpl->assign('versionError', escape($exc->getMessage()));
         }
@@ -80,9 +80,9 @@ class PageBuilder
             $this->tpl->assign('pagetitle', $this->conf->get('pagetitle'));
         }
         $this->tpl->assign('shaarlititle', $this->conf->get('title', 'Shaarli'));
-        $this->tpl->assign('openshaarli', $this->conf->get('extras.open_shaarli', false));
-        $this->tpl->assign('showatom', $this->conf->get('extras.show_atom', false));
-        $this->tpl->assign('hide_timestamps', $this->conf->get('extras.hide_timestamps', false));
+        $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false));
+        $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false));
+        $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
         if (!empty($GLOBALS['plugin_errors'])) {
             $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']);
         }
index b8940e4126261c04fa323241874d89e5f6fd4110..fd45d17fd4dcbb4b411518cf5c98ebdbce6b8119 100644 (file)
@@ -114,8 +114,8 @@ class Updater
      */
     public function updateMethodMergeDeprecatedConfigFile()
     {
-        if (is_file($this->conf->get('path.data_dir') . '/options.php')) {
-            include $this->conf->get('path.data_dir') . '/options.php';
+        if (is_file($this->conf->get('resource.data_dir') . '/options.php')) {
+            include $this->conf->get('resource.data_dir') . '/options.php';
 
             // Load GLOBALS into config
             $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS);
@@ -126,7 +126,7 @@ class Updater
                 }
             }
             $this->conf->write($this->isLoggedIn);
-            unlink($this->conf->get('path.data_dir').'/options.php');
+            unlink($this->conf->get('resource.data_dir').'/options.php');
         }
 
         return true;
@@ -143,7 +143,7 @@ class Updater
             $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
             $this->linkDB[$link['linkdate']] = $link;
         }
-        $this->linkDB->savedb($this->conf->get('path.page_cache'));
+        $this->linkDB->savedb($this->conf->get('resource.page_cache'));
         return true;
     }
 
@@ -207,7 +207,7 @@ class Updater
         try {
             $this->conf->set('general.title', escape($this->conf->get('general.title')));
             $this->conf->set('general.header_link', escape($this->conf->get('general.header_link')));
-            $this->conf->set('extras.redirector', escape($this->conf->get('extras.redirector')));
+            $this->conf->set('redirector.url', escape($this->conf->get('redirector.url')));
             $this->conf->write($this->isLoggedIn);
         } catch (Exception $e) {
             error_log($e->getMessage());
index 5aafc89d30d4e662511e46a6917d1943624f6b30..ff41772a73153d7c3bb1d477e58d2586c5a5cf93 100644 (file)
@@ -186,8 +186,8 @@ class ConfigManager
             'general.timezone',
             'general.title',
             'general.header_link',
-            'general.default_private_links',
-            'extras.redirector',
+            'privacy.default_private_links',
+            'redirector.url',
         );
 
         // Only logged in user can alter config.
@@ -287,39 +287,43 @@ class ConfigManager
      */
     protected function setDefaultValues()
     {
-        $this->setEmpty('path.data_dir', 'data');
-        $this->setEmpty('path.config', 'data/config.php');
-        $this->setEmpty('path.datastore', 'data/datastore.php');
-        $this->setEmpty('path.ban_file', 'data/ipbans.php');
-        $this->setEmpty('path.updates', 'data/updates.txt');
-        $this->setEmpty('path.log', 'data/log.txt');
-        $this->setEmpty('path.update_check', 'data/lastupdatecheck.txt');
-        $this->setEmpty('path.raintpl_tpl', 'tpl/');
-        $this->setEmpty('path.raintpl_tmp', 'tmp/');
-        $this->setEmpty('path.thumbnails_cache', 'cache');
-        $this->setEmpty('path.page_cache', 'pagecache');
+        $this->setEmpty('resource.data_dir', 'data');
+        $this->setEmpty('resource.config', 'data/config.php');
+        $this->setEmpty('resource.datastore', 'data/datastore.php');
+        $this->setEmpty('resource.ban_file', 'data/ipbans.php');
+        $this->setEmpty('resource.updates', 'data/updates.txt');
+        $this->setEmpty('resource.log', 'data/log.txt');
+        $this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt');
+        $this->setEmpty('resource.raintpl_tpl', 'tpl/');
+        $this->setEmpty('resource.raintpl_tmp', 'tmp/');
+        $this->setEmpty('resource.thumbnails_cache', 'cache');
+        $this->setEmpty('resource.page_cache', 'pagecache');
 
         $this->setEmpty('security.ban_after', 4);
         $this->setEmpty('security.ban_duration', 1800);
         $this->setEmpty('security.session_protection_disabled', false);
+        $this->setEmpty('security.open_shaarli', false);
 
-        $this->setEmpty('general.check_updates', false);
-        $this->setEmpty('general.rss_permalinks', true);
-        $this->setEmpty('general.links_per_page', 20);
-        $this->setEmpty('general.default_private_links', false);
-        $this->setEmpty('general.enable_thumbnails', true);
-        $this->setEmpty('general.enable_localcache', true);
-        $this->setEmpty('general.check_updates_branch', 'stable');
-        $this->setEmpty('general.check_updates_interval', 86400);
         $this->setEmpty('general.header_link', '?');
+        $this->setEmpty('general.links_per_page', 20);
         $this->setEmpty('general.enabled_plugins', array('qrcode'));
 
-        $this->setEmpty('extras.show_atom', false);
-        $this->setEmpty('extras.hide_public_links', false);
-        $this->setEmpty('extras.hide_timestamps', false);
-        $this->setEmpty('extras.open_shaarli', false);
-        $this->setEmpty('extras.redirector', '');
-        $this->setEmpty('extras.redirector_encode_url', true);
+        $this->setEmpty('updates.check_updates', false);
+        $this->setEmpty('updates.check_updates_branch', 'stable');
+        $this->setEmpty('updates.check_updates_interval', 86400);
+
+        $this->setEmpty('feed.rss_permalinks', true);
+        $this->setEmpty('feed.show_atom', false);
+
+        $this->setEmpty('privacy.default_private_links', false);
+        $this->setEmpty('privacy.hide_public_links', false);
+        $this->setEmpty('privacy.hide_timestamps', false);
+
+        $this->setEmpty('thumbnail.enable_thumbnails', true);
+        $this->setEmpty('thumbnail.enable_localcache', true);
+
+        $this->setEmpty('redirector.url', '');
+        $this->setEmpty('redirector.encode_url', true);
 
         $this->setEmpty('plugins', array());
     }
index b122f4f1bca0a1a3d726a7481dd375c822504eec..27187b662f34c3e984d1097776017050e88c4d6a 100644 (file)
@@ -34,38 +34,38 @@ class ConfigPhp implements ConfigIO
         'credentials.login' => 'login',
         'credentials.hash' => 'hash',
         'credentials.salt' => 'salt',
-        'path.data_dir' => 'config.DATADIR',
-        'path.config' => 'config.CONFIG_FILE',
-        'path.datastore' => 'config.DATASTORE',
-        'path.updates' => 'config.UPDATES_FILE',
-        'path.log' => 'config.LOG_FILE',
-        'path.update_check' => 'config.UPDATECHECK_FILENAME',
-        'path.raintpl_tpl' => 'config.RAINTPL_TPL',
-        'path.raintpl_tmp' => 'config.RAINTPL_TMP',
-        'path.thumbnails_cache' => 'config.CACHEDIR',
-        'path.page_cache' => 'config.PAGECACHE',
-        'path.ban_file' => 'config.IPBANS_FILENAME',
+        'resource.data_dir' => 'config.DATADIR',
+        'resource.config' => 'config.CONFIG_FILE',
+        'resource.datastore' => 'config.DATASTORE',
+        'resource.updates' => 'config.UPDATES_FILE',
+        'resource.log' => 'config.LOG_FILE',
+        'resource.update_check' => 'config.UPDATECHECK_FILENAME',
+        'resource.raintpl_tpl' => 'config.RAINTPL_TPL',
+        'resource.raintpl_tmp' => 'config.RAINTPL_TMP',
+        'resource.thumbnails_cache' => 'config.CACHEDIR',
+        'resource.page_cache' => 'config.PAGECACHE',
+        'resource.ban_file' => 'config.IPBANS_FILENAME',
         'security.session_protection_disabled' => 'disablesessionprotection',
         'security.ban_after' => 'config.BAN_AFTER',
         'security.ban_duration' => 'config.BAN_DURATION',
         'general.title' => 'title',
         'general.timezone' => 'timezone',
         'general.header_link' => 'titleLink',
-        'general.check_updates' => 'config.ENABLE_UPDATECHECK',
-        'general.check_updates_branch' => 'config.UPDATECHECK_BRANCH',
-        'general.check_updates_interval' => 'config.UPDATECHECK_INTERVAL',
-        'general.default_private_links' => 'privateLinkByDefault',
-        'general.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS',
+        'updates.check_updates' => 'config.ENABLE_UPDATECHECK',
+        'updates.check_updates_branch' => 'config.UPDATECHECK_BRANCH',
+        'updates.check_updates_interval' => 'config.UPDATECHECK_INTERVAL',
+        'privacy.default_private_links' => 'privateLinkByDefault',
+        'feed.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS',
         'general.links_per_page' => 'config.LINKS_PER_PAGE',
-        'general.enable_thumbnails' => 'config.ENABLE_THUMBNAILS',
-        'general.enable_localcache' => 'config.ENABLE_LOCALCACHE',
+        'thumbnail.enable_thumbnails' => 'config.ENABLE_THUMBNAILS',
+        'thumbnail.enable_localcache' => 'config.ENABLE_LOCALCACHE',
         'general.enabled_plugins' => 'config.ENABLED_PLUGINS',
-        'extras.redirector' => 'redirector',
-        'extras.redirector_encode_url' => 'config.REDIRECTOR_URLENCODE',
-        'extras.show_atom' => 'config.SHOW_ATOM',
-        'extras.hide_public_links' => 'config.HIDE_PUBLIC_LINKS',
-        'extras.hide_timestamps' => 'config.HIDE_TIMESTAMPS',
-        'extras.open_shaarli' => 'config.OPEN_SHAARLI',
+        'redirector.url' => 'redirector',
+        'redirector.encode_url' => 'config.REDIRECTOR_URLENCODE',
+        'feed.show_atom' => 'config.SHOW_ATOM',
+        'privacy.hide_public_links' => 'config.HIDE_PUBLIC_LINKS',
+        'privacy.hide_timestamps' => 'config.HIDE_TIMESTAMPS',
+        'security.open_shaarli' => 'config.OPEN_SHAARLI',
     );
 
     /**
index d061f9124687864dd8c36d172184aecef42df77e..b9576de8f989764ff7e9b57a5b1d0a32e972c77f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -108,8 +108,8 @@ if (isset($_COOKIE['shaarli']) && !is_session_id_valid($_COOKIE['shaarli'])) {
 $conf = new ConfigManager();
 $conf->setEmpty('general.timezone', date_default_timezone_get());
 $conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER)));
-RainTPL::$tpl_dir = $conf->get('path.raintpl_tpl'); // template directory
-RainTPL::$cache_dir = $conf->get('path.raintpl_tmp'); // cache directory
+RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl'); // template directory
+RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory
 
 $pluginManager = new PluginManager($conf);
 $pluginManager->load($conf->get('general.enabled_plugins'));
@@ -172,7 +172,7 @@ header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper int
  */
 function setup_login_state($conf)
 {
-       if ($conf->get('extras.open_shaarli')) {
+       if ($conf->get('security.open_shaarli')) {
            return true;
        }
        $userIsLoggedIn = false; // By default, we do not consider the user as logged in;
@@ -273,10 +273,10 @@ function check_auth($login, $password, $conf)
     if ($login == $conf->get('credentials.login') && $hash == $conf->get('credentials.hash'))
     {   // Login/password is correct.
                fillSessionInfo($conf);
-        logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login successful');
+        logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Login successful');
         return true;
     }
-    logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login);
+    logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login);
     return false;
 }
 
@@ -302,14 +302,14 @@ function logout() {
 // ------------------------------------------------------------------------------------------
 // Brute force protection system
 // Several consecutive failed logins will ban the IP address for 30 minutes.
-if (!is_file($conf->get('path.ban_file', 'data/ipbans.php'))) {
+if (!is_file($conf->get('resource.ban_file', 'data/ipbans.php'))) {
     // FIXME! globals
     file_put_contents(
-        $conf->get('path.ban_file', 'data/ipbans.php'),
+        $conf->get('resource.ban_file', 'data/ipbans.php'),
         "<?php\n\$GLOBALS['IPBANS']=".var_export(array('FAILURES'=>array(),'BANS'=>array()),true).";\n?>"
     );
 }
-include $conf->get('path.ban_file', 'data/ipbans.php');
+include $conf->get('resource.ban_file', 'data/ipbans.php');
 /**
  * Signal a failed login. Will ban the IP if too many failures:
  *
@@ -324,11 +324,11 @@ function ban_loginFailed($conf)
     if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1))
     {
         $gb['BANS'][$ip] = time() + $conf->get('security.ban_after', 1800);
-        logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login');
+        logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login');
     }
     $GLOBALS['IPBANS'] = $gb;
     file_put_contents(
-        $conf->get('path.ban_file', 'data/ipbans.php'),
+        $conf->get('resource.ban_file', 'data/ipbans.php'),
         "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
     );
 }
@@ -345,7 +345,7 @@ function ban_loginOk($conf)
     unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
     $GLOBALS['IPBANS'] = $gb;
     file_put_contents(
-        $conf->get('path.ban_file', 'data/ipbans.php'),
+        $conf->get('resource.ban_file', 'data/ipbans.php'),
         "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
     );
 }
@@ -365,10 +365,10 @@ function ban_canLogin($conf)
         // User is banned. Check if the ban has expired:
         if ($gb['BANS'][$ip]<=time())
         {   // Ban expired, user can try to login again.
-            logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.');
+            logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.');
             unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
             file_put_contents(
-                $conf->get('path.ban_file', 'data/ipbans.php'),
+                $conf->get('resource.ban_file', 'data/ipbans.php'),
                 "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
             );
             return true; // Ban has expired, user can login.
@@ -533,11 +533,11 @@ function showDailyRSS($conf) {
     // If cached was not found (or not usable), then read the database and build the response:
     // Read links from database (and filter private links if used it not logged in).
     $LINKSDB = new LinkDB(
-        $conf->get('path.datastore'),
+        $conf->get('resource.datastore'),
         isLoggedIn(),
-        $conf->get('extras.hide_public_links'),
-        $conf->get('extras.redirector'),
-        $conf->get('extras.redirector_encode_url')
+        $conf->get('privacy.hide_public_links'),
+        $conf->get('redirector.url'),
+        $conf->get('redirector.encode_url')
     );
 
     /* Some Shaarlies may have very few links, so we need to look
@@ -590,7 +590,7 @@ function showDailyRSS($conf) {
         // We pre-format some fields for proper output.
         foreach ($linkdates as $linkdate) {
             $l = $LINKSDB[$linkdate];
-            $l['formatedDescription'] = format_description($l['description'], $conf->get('extras.redirector'));
+            $l['formatedDescription'] = format_description($l['description'], $conf->get('redirector.url'));
             $l['thumbnail'] = thumbnail($conf, $l['url']);
             $l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']);
             $l['timestamp'] = $l_date->getTimestamp();
@@ -607,7 +607,7 @@ function showDailyRSS($conf) {
         $tpl->assign('absurl', $absurl);
         $tpl->assign('links', $links);
         $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS)));
-        $tpl->assign('hide_timestamps', $conf->get('extras.hide_timestamps', false));
+        $tpl->assign('hide_timestamps', $conf->get('privacy.hide_timestamps', false));
         $html = $tpl->draw('dailyrss', $return_string=true);
 
         echo $html . PHP_EOL;
@@ -657,7 +657,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager)
         $taglist = explode(' ',$link['tags']);
         uasort($taglist, 'strcasecmp');
         $linksToDisplay[$key]['taglist']=$taglist;
-        $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('extras.redirector'));
+        $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('redirector.url'));
         $linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']);
         $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
         $linksToDisplay[$key]['timestamp'] = $date->getTimestamp();
@@ -726,15 +726,15 @@ function showLinkList($PAGE, $LINKSDB, $conf, $pluginManager) {
 function renderPage($conf, $pluginManager)
 {
     $LINKSDB = new LinkDB(
-        $conf->get('path.datastore'),
+        $conf->get('resource.datastore'),
         isLoggedIn(),
-        $conf->get('extras.hide_public_links'),
-        $conf->get('extras.redirector'),
-        $conf->get('extras.redirector_encode_url')
+        $conf->get('privacy.hide_public_links'),
+        $conf->get('redirector.url'),
+        $conf->get('redirector.encode_url')
     );
 
     $updater = new Updater(
-        read_updates_file($conf->get('path.updates')),
+        read_updates_file($conf->get('resource.updates')),
         $LINKSDB,
         $conf,
         isLoggedIn()
@@ -743,7 +743,7 @@ function renderPage($conf, $pluginManager)
         $newUpdates = $updater->update();
         if (! empty($newUpdates)) {
             write_updates_file(
-                $conf->get('path.updates'),
+                $conf->get('resource.updates'),
                 $updater->getDoneUpdates()
             );
         }
@@ -782,7 +782,7 @@ function renderPage($conf, $pluginManager)
     // -------- Display login form.
     if ($targetPage == Router::$PAGE_LOGIN)
     {
-        if ($conf->get('extras.open_shaarli')) { header('Location: ?'); exit; }  // No need to login for open Shaarli
+        if ($conf->get('security.open_shaarli')) { header('Location: ?'); exit; }  // No need to login for open Shaarli
         $token=''; if (ban_canLogin($conf)) $token=getToken($conf); // Do not waste token generation if not useful.
         $PAGE->assign('token',$token);
         if (isset($_GET['username'])) {
@@ -795,7 +795,7 @@ function renderPage($conf, $pluginManager)
     // -------- User wants to logout.
     if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout'))
     {
-        invalidateCaches($conf->get('path.page_cache'));
+        invalidateCaches($conf->get('resource.page_cache'));
         logout();
         header('Location: ?');
         exit;
@@ -895,7 +895,7 @@ function renderPage($conf, $pluginManager)
         // Cache system
         $query = $_SERVER['QUERY_STRING'];
         $cache = new CachedPage(
-            $conf->get('path.page_cache'),
+            $conf->get('resource.page_cache'),
             page_url($_SERVER),
             startsWith($query,'do='. $targetPage) && !isLoggedIn()
         );
@@ -908,8 +908,8 @@ function renderPage($conf, $pluginManager)
         // Generate data.
         $feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn());
         $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0)));
-        $feedGenerator->setHideDates($conf->get('extras.hide_timestamps') && !isLoggedIn());
-        $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('general.rss_permalinks'));
+        $feedGenerator->setHideDates($conf->get('privacy.hide_timestamps') && !isLoggedIn());
+        $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('feed.rss_permalinks'));
         $pshUrl = $conf->get('config.PUBSUBHUB_URL');
         if (!empty($pshUrl)) {
             $feedGenerator->setPubsubhubUrl($pshUrl);
@@ -1072,7 +1072,7 @@ function renderPage($conf, $pluginManager)
     // -------- User wants to change his/her password.
     if ($targetPage == Router::$PAGE_CHANGEPASSWORD)
     {
-        if ($conf->get('extras.open_shaarli')) {
+        if ($conf->get('security.open_shaarli')) {
             die('You are not supposed to change a password on an Open Shaarli.');
         }
 
@@ -1128,12 +1128,12 @@ function renderPage($conf, $pluginManager)
             $conf->set('general.timezone', $tz);
             $conf->set('general.title', escape($_POST['title']));
             $conf->set('general.header_link', escape($_POST['titleLink']));
-            $conf->set('extras.redirector', escape($_POST['redirector']));
+            $conf->set('redirector.url', escape($_POST['redirector']));
             $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection']));
-            $conf->set('general.default_private_links', !empty($_POST['privateLinkByDefault']));
-            $conf->set('general.rss_permalinks', !empty($_POST['enableRssPermalinks']));
-            $conf->set('general.check_updates', !empty($_POST['updateCheck']));
-            $conf->set('extras.hide_public_links', !empty($_POST['hidePublicLinks']));
+            $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault']));
+            $conf->set('feed.rss_permalinks', !empty($_POST['enableRssPermalinks']));
+            $conf->set('updates.check_updates', !empty($_POST['updateCheck']));
+            $conf->set('privacy.hide_public_links', !empty($_POST['hidePublicLinks']));
             try {
                 $conf->write(isLoggedIn());
             }
@@ -1154,14 +1154,14 @@ function renderPage($conf, $pluginManager)
         {
             $PAGE->assign('token',getToken($conf));
             $PAGE->assign('title', $conf->get('general.title'));
-            $PAGE->assign('redirector', $conf->get('extras.redirector'));
+            $PAGE->assign('redirector', $conf->get('redirector.url'));
             list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone'));
             $PAGE->assign('timezone_form', $timezone_form);
             $PAGE->assign('timezone_js',$timezone_js);
-            $PAGE->assign('private_links_default', $conf->get('general.default_private_links', false));
-            $PAGE->assign('enable_rss_permalinks', $conf->get('general.rss_permalinks', false));
-            $PAGE->assign('enable_update_check', $conf->get('general.check_updates', true));
-            $PAGE->assign('hide_public_links', $conf->get('extras.hide_public_links', false));
+            $PAGE->assign('private_links_default', $conf->get('privacy.default_private_links', false));
+            $PAGE->assign('enable_rss_permalinks', $conf->get('feed.rss_permalinks', false));
+            $PAGE->assign('enable_update_check', $conf->get('updates.check_updates', true));
+            $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false));
             $PAGE->renderPage('configure');
             exit;
         }
@@ -1193,7 +1193,7 @@ function renderPage($conf, $pluginManager)
                 $value['tags']=trim(implode(' ',$tags));
                 $LINKSDB[$key]=$value;
             }
-            $LINKSDB->savedb($conf->get('path.page_cache'));
+            $LINKSDB->savedb($conf->get('resource.page_cache'));
             echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>';
             exit;
         }
@@ -1210,7 +1210,7 @@ function renderPage($conf, $pluginManager)
                 $value['tags']=trim(implode(' ',$tags));
                 $LINKSDB[$key]=$value;
             }
-            $LINKSDB->savedb($conf->get('path.page_cache')); // Save to disk.
+            $LINKSDB->savedb($conf->get('resource.page_cache')); // Save to disk.
             echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>';
             exit;
         }
@@ -1261,7 +1261,7 @@ function renderPage($conf, $pluginManager)
         $pluginManager->executeHooks('save_link', $link);
 
         $LINKSDB[$linkdate] = $link;
-        $LINKSDB->savedb($conf->get('path.page_cache'));
+        $LINKSDB->savedb($conf->get('resource.page_cache'));
         pubsubhub($conf);
 
         // If we are called from the bookmarklet, we must close the popup:
@@ -1303,7 +1303,7 @@ function renderPage($conf, $pluginManager)
         $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
 
         unset($LINKSDB[$linkdate]);
-        $LINKSDB->savedb('path.page_cache'); // save to disk
+        $LINKSDB->savedb('resource.page_cache'); // save to disk
 
         // If we are called from the bookmarklet, we must close the popup:
         if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
@@ -1629,7 +1629,7 @@ function importFile($LINKSDB, $conf)
                 }
             }
         }
-        $LINKSDB->savedb($conf->get('path.page_cache'));
+        $LINKSDB->savedb($conf->get('resource.page_cache'));
 
         echo '<script>alert("File '.json_encode($filename).' ('.$filesize.' bytes) was successfully processed: '.$import_count.' links imported.");document.location=\'?\';</script>';
     }
@@ -1693,7 +1693,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
     while ($i<$end && $i<count($keys))
     {
         $link = $linksToDisplay[$keys[$i]];
-        $link['description'] = format_description($link['description'], $conf->get('extras.redirector'));
+        $link['description'] = format_description($link['description'], $conf->get('redirector.url'));
         $classLi =  ($i % 2) != 0 ? '' : 'publicLinkHightLight';
         $link['class'] = $link['private'] == 0 ? $classLi : 'private';
         $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
@@ -1735,7 +1735,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
         'result_count' => count($linksToDisplay),
         'search_term' => $searchterm,
         'search_tags' => $searchtags,
-        'redirector' => $conf->get('extras.redirector'),  // Optional redirector URL.
+        'redirector' => $conf->get('redirector.url'),  // Optional redirector URL.
         'token' => $token,
         'links' => $linkDisp,
         'tags' => $LINKSDB->allTags(),
@@ -1773,7 +1773,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
  */
 function computeThumbnail($conf, $url, $href = false)
 {
-    if (!$conf->get('general.enable_thumbnails')) return array();
+    if (!$conf->get('thumbnail.enable_thumbnails')) return array();
     if ($href==false) $href=$url;
 
     // For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link.
@@ -1841,7 +1841,7 @@ function computeThumbnail($conf, $url, $href = false)
     // So we deport the thumbnail generation in order not to slow down page generation
     // (and we also cache the thumbnail)
 
-    if (! $conf->get('general.enable_localcache')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache.
+    if (! $conf->get('thumbnail.enable_localcache')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache.
 
     if ($domain=='flickr.com' || endsWith($domain,'.flickr.com')
         || $domain=='vimeo.com'
@@ -1996,7 +1996,7 @@ function install($conf)
         } else {
             $conf->set('general.title', 'Shared links on '.escape(index_url($_SERVER)));
         }
-        $conf->set('general.check_updates', !empty($_POST['updateCheck']));
+        $conf->set('updates.check_updates', !empty($_POST['updateCheck']));
         try {
             // Everything is ok, let's create config file.
             $conf->write(isLoggedIn());
@@ -2047,7 +2047,7 @@ function genThumbnail($conf)
     $sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt'));
     if ($sign!=$_GET['hmac']) die('Naughty boy!');
 
-    $cacheDir = $conf->get('path.thumbnails_cache', 'cache');
+    $cacheDir = $conf->get('resource.thumbnails_cache', 'cache');
     // Let's see if we don't already have the image for this URL in the cache.
     $thumbname=hash('sha1',$_GET['url']).'.jpg';
     if (is_file($cacheDir .'/'. $thumbname))
index 3da726399add89f352e8c52cf31550acb6009c06..c37a94f0944f08f9da242cdadf6211d8a6619835 100644 (file)
@@ -277,16 +277,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
     public function testCheckCurrentResourcePermissions()
     {
         $conf = new ConfigManager('');
-        $conf->set('path.thumbnails_cache', 'cache');
-        $conf->set('path.config', 'data/config.php');
-        $conf->set('path.data_dir', 'data');
-        $conf->set('path.datastore', 'data/datastore.php');
-        $conf->set('path.ban_file', 'data/ipbans.php');
-        $conf->set('path.log', 'data/log.txt');
-        $conf->set('path.page_cache', 'pagecache');
-        $conf->set('path.raintpl_tmp', 'tmp');
-        $conf->set('path.raintpl_tpl', 'tpl');
-        $conf->set('path.update_check', 'data/lastupdatecheck.txt');
+        $conf->set('resource.thumbnails_cache', 'cache');
+        $conf->set('resource.config', 'data/config.php');
+        $conf->set('resource.data_dir', 'data');
+        $conf->set('resource.datastore', 'data/datastore.php');
+        $conf->set('resource.ban_file', 'data/ipbans.php');
+        $conf->set('resource.log', 'data/log.txt');
+        $conf->set('resource.page_cache', 'pagecache');
+        $conf->set('resource.raintpl_tmp', 'tmp');
+        $conf->set('resource.raintpl_tpl', 'tpl');
+        $conf->set('resource.update_check', 'data/lastupdatecheck.txt');
 
         $this->assertEquals(
             array(),
@@ -300,16 +300,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
     public function testCheckCurrentResourcePermissionsErrors()
     {
         $conf = new ConfigManager('');
-        $conf->set('path.thumbnails_cache', 'null/cache');
-        $conf->set('path.config', 'null/data/config.php');
-        $conf->set('path.data_dir', 'null/data');
-        $conf->set('path.datastore', 'null/data/store.php');
-        $conf->set('path.ban_file', 'null/data/ipbans.php');
-        $conf->set('path.log', 'null/data/log.txt');
-        $conf->set('path.page_cache', 'null/pagecache');
-        $conf->set('path.raintpl_tmp', 'null/tmp');
-        $conf->set('path.raintpl_tpl', 'null/tpl');
-        $conf->set('path.update_check', 'null/data/lastupdatecheck.txt');
+        $conf->set('resource.thumbnails_cache', 'null/cache');
+        $conf->set('resource.config', 'null/data/config.php');
+        $conf->set('resource.data_dir', 'null/data');
+        $conf->set('resource.datastore', 'null/data/store.php');
+        $conf->set('resource.ban_file', 'null/data/ipbans.php');
+        $conf->set('resource.log', 'null/data/log.txt');
+        $conf->set('resource.page_cache', 'null/pagecache');
+        $conf->set('resource.raintpl_tmp', 'null/tmp');
+        $conf->set('resource.raintpl_tpl', 'null/tpl');
+        $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
         $this->assertEquals(
             array(
                 '"null/tpl" directory is not readable',
index 5ed2df6caff8527877a594b0213eb49ec050b597..6bdce08b2c77c385f2f5c385c1eb3869c43ae86d 100644 (file)
@@ -38,7 +38,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
     public function testReadEmptyUpdatesFile()
     {
         $this->assertEquals(array(), read_updates_file(''));
-        $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt';
+        $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
         touch($updatesFile);
         $this->assertEquals(array(), read_updates_file($updatesFile));
         unlink($updatesFile);
@@ -49,7 +49,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
      */
     public function testReadWriteUpdatesFile()
     {
-        $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt';
+        $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
         $updatesMethods = array('m1', 'm2', 'm3');
 
         write_updates_file($updatesFile, $updatesMethods);
@@ -83,7 +83,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
      */
     public function testWriteUpdatesFileNotWritable()
     {
-        $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt';
+        $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
         touch($updatesFile);
         chmod($updatesFile, 0444);
         try {
@@ -189,7 +189,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
 
         // make sure updated field is changed
         $this->conf->reload();
-        $this->assertTrue($this->conf->get('general.default_private_links'));
+        $this->assertTrue($this->conf->get('privacy.default_private_links'));
         $this->assertFalse(is_file($optionsFile));
         // Delete the generated file.
         unlink($this->conf->getConfigFileExt());
@@ -243,8 +243,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
         // Check JSON config data.
         $this->conf->reload();
         $this->assertEquals('root', $this->conf->get('credentials.login'));
-        $this->assertEquals('lala', $this->conf->get('extras.redirector'));
-        $this->assertEquals('data/datastore.php', $this->conf->get('path.datastore'));
+        $this->assertEquals('lala', $this->conf->get('redirector.url'));
+        $this->assertEquals('data/datastore.php', $this->conf->get('resource.datastore'));
         $this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION'));
 
         rename($configFile . '.save.php', $configFile . '.php');
index 0960c729a3a7ebf0de6846e3f24ee915ba0e6cba..359e9112593b8351980c537850bab92a9aff3562 100644 (file)
@@ -24,8 +24,8 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
     {
         $conf = $this->configIO->read('tests/utils/config/configJson.json.php');
         $this->assertEquals('root', $conf['credentials']['login']);
-        $this->assertEquals('lala', $conf['extras']['redirector']);
-        $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']);
+        $this->assertEquals('lala', $conf['redirector']['url']);
+        $this->assertEquals('tests/utils/config/datastore.php', $conf['resource']['datastore']);
         $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']);
     }
 
@@ -58,11 +58,11 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
             'credentials' => array(
                 'login' => 'root',
             ),
-            'path' => array(
+            'resource' => array(
                 'datastore' => 'data/datastore.php',
             ),
-            'extras' => array(
-                'redirector' => 'lala',
+            'redirector' => array(
+                'url' => 'lala',
             ),
             'plugins' => array(
                 'WALLABAG_VERSION' => '1',
@@ -75,18 +75,18 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
     "credentials": {
         "login": "root"
     },
-    "path": {
+    "resource": {
         "datastore": "data\/datastore.php"
     },
-    "extras": {
-        "redirector": "lala"
+    "redirector": {
+        "url": "lala"
     },
     "plugins": {
         "WALLABAG_VERSION": "1"
     }
 }';
         } else {
-            $expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}';
+            $expected = '{"credentials":{"login":"root"},"resource":{"datastore":"data\/datastore.php"},"redirector":{"url":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}';
         }
         $expected = ConfigJson::getPhpHeaders() . $expected;
         $this->assertEquals($expected, file_get_contents($dataFile));
@@ -102,10 +102,10 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
         $dest = 'tests/utils/config/configOverwrite.json.php';
         copy($source, $dest);
         $conf = $this->configIO->read($dest);
-        $conf['extras']['redirector'] = 'blabla';
+        $conf['redirector']['url'] = 'blabla';
         $this->configIO->write($dest, $conf);
         $conf = $this->configIO->read($dest);
-        $this->assertEquals('blabla', $conf['extras']['redirector']);
+        $this->assertEquals('blabla', $conf['redirector']['url']);
         unlink($dest);
     }
 
index 6a841f8a3cb33ffb7a147022d234a7ec40985b78..c54882c3dad8bbb7fb09e300b09fd48a98150492 100644 (file)
     },
     "general": {
         "timezone":"Europe\/Paris",
-        "default_private_linksheader_link":true,
         "title": "Shaarli",
         "header_link": "?"
     },
-    "extras": {
-        "redirector":"lala"
+    "privacy": {
+        "default_private_links":true
+    },
+    "redirector": {
+        "url":"lala"
     },
     "config": {
         "foo": "bar"
     },
-    "path": {
+    "resource": {
         "datastore": "tests\/utils\/config\/datastore.php",
         "data_dir": "tests\/utils\/config"
     },