Skip to content

Commit

Permalink
Rename configuration key for better sections
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHoaro committed Jun 11, 2016
1 parent 2713121 commit 39fb209
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 167 deletions.
18 changes: 9 additions & 9 deletions application/ApplicationUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static function checkResourcePermissions($conf)
'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';
Expand All @@ -154,10 +154,10 @@ public static function checkResourcePermissions($conf)

// 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';
Expand All @@ -170,10 +170,10 @@ public static function checkResourcePermissions($conf)
// 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
Expand Down
16 changes: 8 additions & 8 deletions application/PageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ private function initialize()
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()));
}
Expand Down Expand Up @@ -80,9 +80,9 @@ private function initialize()
$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']);
}
Expand Down
10 changes: 5 additions & 5 deletions application/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public function getDoneUpdates()
*/
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);
Expand All @@ -126,7 +126,7 @@ public function updateMethodMergeDeprecatedConfigFile()
}
}
$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;
Expand All @@ -143,7 +143,7 @@ public function updateMethodRenameDashTags()
$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;
}

Expand Down Expand Up @@ -207,7 +207,7 @@ public function escapeUnescapedConfig()
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());
Expand Down
58 changes: 31 additions & 27 deletions application/config/ConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ public function write($isLoggedIn)
'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.
Expand Down Expand Up @@ -287,39 +287,43 @@ protected static function setConfig($settings, $value, &$conf)
*/
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());
}
Expand Down
48 changes: 24 additions & 24 deletions application/config/ConfigPhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);

/**
Expand Down
Loading

0 comments on commit 39fb209

Please sign in to comment.