| Line 9... |
Line 9... |
| 9 |
* @package Framework
|
9 |
* @package Framework
|
| 10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
| 11 |
* @copyright Copyright (c) 2009, Tela Botanica (accueil@tela-botanica.org)
|
11 |
* @copyright Copyright (c) 2009, Tela Botanica (accueil@tela-botanica.org)
|
| 12 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
|
12 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
|
| 13 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
|
13 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
|
| 14 |
* @version SVN : $Id: Config.php 186 2010-04-28 15:50:16Z jpm $
|
14 |
* @version SVN : $Id: Config.php 189 2010-04-29 12:22:04Z jpm $
|
| 15 |
* @link /doc/framework/
|
15 |
* @link /doc/framework/
|
| 16 |
*/
|
16 |
*/
|
| Line 17... |
Line 17... |
| 17 |
|
17 |
|
| Line 188... |
Line 188... |
| 188 |
private static function evaluerCle(&$config, $cle, $valeur) {
|
188 |
private static function evaluerCle(&$config, $cle, $valeur) {
|
| 189 |
if (strpos($cle, '.') !== false) {
|
189 |
if (strpos($cle, '.') !== false) {
|
| 190 |
unset($config[$cle]);
|
190 |
unset($config[$cle]);
|
| 191 |
$pieces = explode('.', $cle, 2);
|
191 |
$pieces = explode('.', $cle, 2);
|
| 192 |
if (strlen($pieces[0]) && strlen($pieces[1])) {
|
192 |
if (strlen($pieces[0]) && strlen($pieces[1])) {
|
| 193 |
if (!isset($config[$pieces[0]])) {
|
193 |
if (isset($config[$pieces[0]]) && !is_array($config[$pieces[0]])) {
|
| 194 |
if ($pieces[0] === '0' && !empty($config)) {
|
- |
|
| 195 |
// convert the current values in $config into an array
|
194 |
$m = "Ne peut pas créer de sous-clé pour '{$pieces[0]}' car la clé existe déjà";
|
| 196 |
$config = array($pieces[0] => $config);
|
195 |
trigger_error($m, E_USER_WARNING);
|
| 197 |
} else {
|
196 |
} else {
|
| 198 |
$config[$pieces[0]] = array();
|
197 |
$config[$pieces[0]][$pieces[1]] = $valeur;
|
| 199 |
}
|
- |
|
| 200 |
} elseif (!is_array($config[$pieces[0]])) {
|
- |
|
| 201 |
throw new ErrorException("Ne peut pas créer de sous-clé pour '{$pieces[0]}' car la clé existe déjà");
|
198 |
$config[$pieces[0]] = self::evaluerCle($config[$pieces[0]], $pieces[1], $valeur);
|
| 202 |
}
|
199 |
}
|
| 203 |
$config[$pieces[0]] = self::evaluerCle($config[$pieces[0]], $pieces[1], $valeur);
|
- |
|
| 204 |
} else {
|
200 |
} else {
|
| 205 |
throw new ErrorException("Clé invalide '$cle'");
|
201 |
$m = "Clé invalide '$cle'";
|
| - |
|
202 |
trigger_error($m, E_USER_WARNING);
|
| 206 |
}
|
203 |
}
|
| 207 |
} else {
|
204 |
} else {
|
| 208 |
$config[$cle] = $valeur;
|
205 |
$config[$cle] = $valeur;
|
| 209 |
}
|
206 |
}
|
| 210 |
return $config;
|
207 |
return $config;
|