Merge pull request #6893 from nupplaphil/issue/fixing_htconfig
Fixing .htconfig loading
This commit is contained in:
commit
5ed48ba425
|
@ -30,7 +30,7 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
$categories = array_keys($config);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if (isset($config[$category]) && is_array($config[$category])) {
|
||||
if (is_array($config[$category])) {
|
||||
$keys = array_keys($config[$category]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
|
|
|
@ -103,47 +103,64 @@ class ConfigCacheLoader
|
|||
{
|
||||
$filePath = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php';
|
||||
|
||||
$config = [];
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
$a = new \stdClass();
|
||||
$a->config = [];
|
||||
include $filePath;
|
||||
|
||||
$htConfigCategories = array_keys($a->config);
|
||||
|
||||
// map the legacy configuration structure to the current structure
|
||||
foreach ($htConfigCategories as $htConfigCategory) {
|
||||
if (is_array($a->config[$htConfigCategory])) {
|
||||
$keys = array_keys($a->config[$htConfigCategory]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$config[$htConfigCategory][$key] = $a->config[$htConfigCategory][$key];
|
||||
}
|
||||
} else {
|
||||
$config['config'][$htConfigCategory] = $a->config[$htConfigCategory];
|
||||
}
|
||||
}
|
||||
|
||||
unset($a);
|
||||
|
||||
if (isset($db_host)) {
|
||||
$a->config['database']['hostname'] = $db_host;
|
||||
$config['database']['hostname'] = $db_host;
|
||||
unset($db_host);
|
||||
}
|
||||
if (isset($db_user)) {
|
||||
$a->config['database']['username'] = $db_user;
|
||||
$config['database']['username'] = $db_user;
|
||||
unset($db_user);
|
||||
}
|
||||
if (isset($db_pass)) {
|
||||
$a->config['database']['password'] = $db_pass;
|
||||
$config['database']['password'] = $db_pass;
|
||||
unset($db_pass);
|
||||
}
|
||||
if (isset($db_data)) {
|
||||
$a->config['database']['database'] = $db_data;
|
||||
$config['database']['database'] = $db_data;
|
||||
unset($db_data);
|
||||
}
|
||||
if (isset($a->config['system']['db_charset'])) {
|
||||
$a->config['database']['charset'] = $a->config['system']['charset'];
|
||||
if (isset($config['system']['db_charset'])) {
|
||||
$config['database']['charset'] = $config['system']['db_charset'];
|
||||
}
|
||||
if (isset($pidfile)) {
|
||||
$a->config['system']['pidfile'] = $pidfile;
|
||||
$config['system']['pidfile'] = $pidfile;
|
||||
unset($pidfile);
|
||||
}
|
||||
if (isset($default_timezone)) {
|
||||
$a->config['system']['default_timezone'] = $default_timezone;
|
||||
$config['system']['default_timezone'] = $default_timezone;
|
||||
unset($default_timezone);
|
||||
}
|
||||
if (isset($lang)) {
|
||||
$a->config['system']['language'] = $lang;
|
||||
$config['system']['language'] = $lang;
|
||||
unset($lang);
|
||||
}
|
||||
|
||||
return $a->config;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,5 +9,55 @@ $db_pass = 'testpw';
|
|||
$db_data = 'testdb';
|
||||
|
||||
$pidfile = '/var/run/friendica.pid';
|
||||
|
||||
// Set the database connection charset to UTF8.
|
||||
// Changing this value will likely corrupt the special characters.
|
||||
// You have been warned.
|
||||
$a->config['system']['db_charset'] = "anotherCharset";
|
||||
|
||||
// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
|
||||
// It can be changed later and only applies to timestamps for anonymous viewers.
|
||||
$default_timezone = 'Europe/Berlin';
|
||||
$lang = 'fr';
|
||||
|
||||
// What is your site name?
|
||||
$a->config['sitename'] = "Friendica My Network";
|
||||
|
||||
// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED.
|
||||
// Be certain to create your own personal account before setting
|
||||
// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on
|
||||
// the registration page. REGISTER_APPROVE requires you set 'admin_email'
|
||||
// to the email address of an already registered person who can authorise
|
||||
// and/or approve/deny the request.
|
||||
// In order to perform system administration via the admin panel, admin_email
|
||||
// must precisely match the email address of the person logged in.
|
||||
$a->config['register_policy'] = REGISTER_OPEN;
|
||||
$a->config['register_text'] = 'A register text';
|
||||
$a->config['admin_email'] = 'admin@friendica.local';
|
||||
$a->config['admin_nickname'] = 'Friendly admin';
|
||||
|
||||
// Maximum size of an imported message, 0 is unlimited
|
||||
$a->config['max_import_size'] = 999;
|
||||
|
||||
// maximum size of uploaded photos
|
||||
$a->config['system']['maximagesize'] = 666;
|
||||
|
||||
// Location of PHP command line processor
|
||||
$a->config['php_path'] = '/another/php';
|
||||
|
||||
// PuSH - aka pubsubhubbub URL. This makes delivery of public posts as fast as private posts
|
||||
$a->config['system']['huburl'] = '[internal]';
|
||||
|
||||
// allowed themes (change this from admin panel after installation)
|
||||
$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero';
|
||||
|
||||
// default system theme
|
||||
$a->config['system']['theme'] = 'duepuntozero';
|
||||
|
||||
// By default allow pseudonyms
|
||||
$a->config['system']['no_regfullname'] = true;
|
||||
|
||||
//Deny public access to the local directory
|
||||
//$a->config['system']['block_local_dir'] = false;
|
||||
// Location of the global directory
|
||||
$a->config['system']['directory'] = 'http://another.url';
|
||||
|
|
|
@ -131,10 +131,21 @@ class ConfigCacheLoaderTest extends MockedTest
|
|||
$this->assertEquals('testuser', $configCache->get('database', 'username'));
|
||||
$this->assertEquals('testpw', $configCache->get('database', 'password'));
|
||||
$this->assertEquals('testdb', $configCache->get('database', 'database'));
|
||||
$this->assertEquals('anotherCharset', $configCache->get('database', 'charset'));
|
||||
|
||||
$this->assertEquals('/var/run/friendica.pid', $configCache->get('system', 'pidfile'));
|
||||
$this->assertEquals('Europe/Berlin', $configCache->get('system', 'default_timezone'));
|
||||
$this->assertEquals('fr', $configCache->get('system', 'language'));
|
||||
|
||||
$this->assertEquals('admin@friendica.local', $configCache->get('config', 'admin_email'));
|
||||
$this->assertEquals('Friendly admin', $configCache->get('config', 'admin_nickname'));
|
||||
|
||||
$this->assertEquals('/another/php', $configCache->get('config', 'php_path'));
|
||||
$this->assertEquals('999', $configCache->get('config', 'max_import_size'));
|
||||
$this->assertEquals('666', $configCache->get('system', 'maximagesize'));
|
||||
|
||||
$this->assertEquals('quattro,vier,duepuntozero', $configCache->get('system', 'allowed_themes'));
|
||||
$this->assertEquals('1', $configCache->get('system', 'no_regfullname'));
|
||||
}
|
||||
|
||||
public function testLoadAddonConfig()
|
||||
|
|
Loading…
Reference in New Issue
Block a user