remove basepath and hostname from admin panel and add update path

This commit is contained in:
Philipp Holzer 2019-03-23 15:40:09 +01:00
parent 383a6715c3
commit fa31bb6dde
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
10 changed files with 158 additions and 35 deletions

View file

@ -57,13 +57,13 @@ class ConfigCacheLoader extends ConfigCacheManager
/**
* Tries to load the specified core-configuration and returns the config array.
*
* @param string $name The name of the configuration
* @param string $name The name of the configuration (default is empty, which means 'local')
*
* @return array The config array (empty if no config found)
*
* @throws \Exception if the configuration file isn't readable
*/
public function loadCoreConfig($name)
public function loadCoreConfig($name = '')
{
if (!empty($this->getConfigFullName($name))) {
return $this->loadConfigFile($this->getConfigFullName($name));
@ -101,13 +101,13 @@ class ConfigCacheLoader extends ConfigCacheManager
/**
* Tries to load the legacy config files (.htconfig.php, .htpreconfig.php) and returns the config array.
*
* @param string $name The name of the config file
* @param string $name The name of the config file (default is empty, which means .htconfig.php)
*
* @return array The configuration array (empty if no config found)
*
* @deprecated since version 2018.09
*/
private function loadLegacyConfig($name)
private function loadLegacyConfig($name = '')
{
$config = [];
if (!empty($this->getHtConfigFullName($name))) {

View file

@ -10,29 +10,77 @@ abstract class ConfigCacheManager
*/
const SUBDIRECTORY = 'config';
/**
* The default name of the user defined config file
* @var string
*/
const CONFIG_LOCAL = 'local';
/**
* The default name of the user defined ini file
* @var string
*/
const CONFIG_INI = 'ini';
/**
* The default name of the user defined legacy config file
* @var string
*/
const CONFIG_HTCONFIG = 'htconfig';
protected $baseDir;
protected $configDir;
/**
* @param string $baseDir The base directory of Friendica
*/
public function __construct($baseDir)
{
$this->baseDir = $baseDir;
$this->configDir = $baseDir . DIRECTORY_SEPARATOR . self::SUBDIRECTORY;
}
protected function getConfigFullName($name)
/**
* Gets the full name (including the path) for a *.config.php (default is local.config.php)
*
* @param string $name The config name (default is empty, which means local.config.php)
*
* @return string The full name or empty if not found
*/
protected function getConfigFullName($name = '')
{
$name = !empty($name) ? $name : self::CONFIG_LOCAL;
$fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.config.php';
return file_exists($fullName) ? $fullName : '';
}
protected function getIniFullName($name)
/**
* Gets the full name (including the path) for a *.ini.php (default is local.ini.php)
*
* @param string $name The config name (default is empty, which means local.ini.php)
*
* @return string The full name or empty if not found
*/
protected function getIniFullName($name = '')
{
$name = !empty($name) ? $name : self::CONFIG_INI;
$fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.ini.php';
return file_exists($fullName) ? $fullName : '';
}
protected function getHtConfigFullName($name)
/**
* Gets the full name (including the path) for a .*.php (default is .htconfig.php)
*
* @param string $name The config name (default is empty, which means .htconfig.php)
*
* @return string The full name or empty if not found
*/
protected function getHtConfigFullName($name = '')
{
$name = !empty($name) ? $name : self::CONFIG_HTCONFIG;
$fullName = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php';
return file_exists($fullName) ? $fullName : '';
}

View file

@ -20,18 +20,49 @@ class ConfigCacheSaver extends ConfigCacheManager
const INDENT = "\t";
/**
* Saves a given value to the config file
* The settings array to save to
* @var array
*/
private $settings = [];
/**
* Adds a given value to the config file
* Either it replaces the current value or it will get added
*
* @param string $cat The configuration category
* @param string $key The configuration key
* @param string $value The new value
*/
public function saveToConfigFile($cat, $key, $value)
public function addConfigValue($cat, $key, $value)
{
$this->saveToLegacyConfig('htpreconfig', $cat, $key, $value);
$this->saveToLegacyConfig('htconfig', $cat, $key, $value);
$this->saveToCoreConfig('local', $cat, $key, $value);
$this->settings[$cat][$key] = $value;
}
public function reset()
{
$this->settings = [];
}
public function saveToConfigFile($name = '')
{
$saved = false;
if (!empty($this->getConfigFullName($name))) {
$this->saveConfigFile($this->getConfigFullName($name));
$saved = true;
}
if (!empty($this->getIniFullName($name))) {
$this->saveINIConfigFile($this->getIniFullName($name));
$saved = true;
}
if (!empty($this->getHtConfigFullName($name))) {
$this->saveToLegacyConfig($this->getHtConfigFullName($name));
$saved = true;
}
return $saved;
}
/**