diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-05-18 21:48:24 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-06-11 09:30:56 +0200 |
commit | 684e662a58b02bde225e44d3677987b6fc3adf0b (patch) | |
tree | db0d4ca1d9b53341cc108b0e7671ffde0e9caee9 /application/Updater.php | |
parent | 59404d7909b21682ec0782778452a8a70e38b25e (diff) | |
download | Shaarli-684e662a58b02bde225e44d3677987b6fc3adf0b.tar.gz Shaarli-684e662a58b02bde225e44d3677987b6fc3adf0b.tar.zst Shaarli-684e662a58b02bde225e44d3677987b6fc3adf0b.zip |
Replace $GLOBALS configuration with the configuration manager in the whole code base
Diffstat (limited to 'application/Updater.php')
-rw-r--r-- | application/Updater.php | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/application/Updater.php b/application/Updater.php index 58c13c07..6b92af3d 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -13,11 +13,6 @@ class Updater | |||
13 | protected $doneUpdates; | 13 | protected $doneUpdates; |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * @var array Shaarli's configuration array. | ||
17 | */ | ||
18 | protected $config; | ||
19 | |||
20 | /** | ||
21 | * @var LinkDB instance. | 16 | * @var LinkDB instance. |
22 | */ | 17 | */ |
23 | protected $linkDB; | 18 | protected $linkDB; |
@@ -36,14 +31,12 @@ class Updater | |||
36 | * Object constructor. | 31 | * Object constructor. |
37 | * | 32 | * |
38 | * @param array $doneUpdates Updates which are already done. | 33 | * @param array $doneUpdates Updates which are already done. |
39 | * @param array $config Shaarli's configuration array. | ||
40 | * @param LinkDB $linkDB LinkDB instance. | 34 | * @param LinkDB $linkDB LinkDB instance. |
41 | * @param boolean $isLoggedIn True if the user is logged in. | 35 | * @param boolean $isLoggedIn True if the user is logged in. |
42 | */ | 36 | */ |
43 | public function __construct($doneUpdates, $config, $linkDB, $isLoggedIn) | 37 | public function __construct($doneUpdates, $linkDB, $isLoggedIn) |
44 | { | 38 | { |
45 | $this->doneUpdates = $doneUpdates; | 39 | $this->doneUpdates = $doneUpdates; |
46 | $this->config = $config; | ||
47 | $this->linkDB = $linkDB; | 40 | $this->linkDB = $linkDB; |
48 | $this->isLoggedIn = $isLoggedIn; | 41 | $this->isLoggedIn = $isLoggedIn; |
49 | 42 | ||
@@ -114,19 +107,21 @@ class Updater | |||
114 | */ | 107 | */ |
115 | public function updateMethodMergeDeprecatedConfigFile() | 108 | public function updateMethodMergeDeprecatedConfigFile() |
116 | { | 109 | { |
117 | $config_file = $this->config['config']['CONFIG_FILE']; | 110 | $conf = ConfigManager::getInstance(); |
118 | 111 | ||
119 | if (is_file($this->config['config']['DATADIR'].'/options.php')) { | 112 | if (is_file($conf->get('config.DATADIR') . '/options.php')) { |
120 | include $this->config['config']['DATADIR'].'/options.php'; | 113 | include $conf->get('config.DATADIR') . '/options.php'; |
121 | 114 | ||
122 | // Load GLOBALS into config | 115 | // Load GLOBALS into config |
116 | $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS); | ||
117 | $allowedKeys[] = 'config'; | ||
123 | foreach ($GLOBALS as $key => $value) { | 118 | foreach ($GLOBALS as $key => $value) { |
124 | $this->config[$key] = $value; | 119 | if (in_array($key, $allowedKeys)) { |
120 | $conf->set($key, $value); | ||
121 | } | ||
125 | } | 122 | } |
126 | $this->config['config']['CONFIG_FILE'] = $config_file; | 123 | $conf->write($this->isLoggedIn); |
127 | writeConfig($this->config, $this->isLoggedIn); | 124 | unlink($conf->get('config.DATADIR').'/options.php'); |
128 | |||
129 | unlink($this->config['config']['DATADIR'].'/options.php'); | ||
130 | } | 125 | } |
131 | 126 | ||
132 | return true; | 127 | return true; |
@@ -137,13 +132,14 @@ class Updater | |||
137 | */ | 132 | */ |
138 | public function updateMethodRenameDashTags() | 133 | public function updateMethodRenameDashTags() |
139 | { | 134 | { |
135 | $conf = ConfigManager::getInstance(); | ||
140 | $linklist = $this->linkDB->filterSearch(); | 136 | $linklist = $this->linkDB->filterSearch(); |
141 | foreach ($linklist as $link) { | 137 | foreach ($linklist as $link) { |
142 | $link['tags'] = preg_replace('/(^| )\-/', '$1', $link['tags']); | 138 | $link['tags'] = preg_replace('/(^| )\-/', '$1', $link['tags']); |
143 | $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); | 139 | $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); |
144 | $this->linkDB[$link['linkdate']] = $link; | 140 | $this->linkDB[$link['linkdate']] = $link; |
145 | } | 141 | } |
146 | $this->linkDB->savedb($this->config['config']['PAGECACHE']); | 142 | $this->linkDB->savedb($conf->get('config.PAGECACHE')); |
147 | return true; | 143 | return true; |
148 | } | 144 | } |
149 | } | 145 | } |