function config_edit() { global $tpl; $allCfg = get_configs(); $cfg = $allCfg[$_GET['scope']]; $tpl->assign('cfg', $cfg); if (isset($_POST['valider'])) { foreach (array_keys($cfg['fields']) as $name) { $tpl->assign('hsuccess', _config_update($cfg['name'], $name, $_POST[$name])); } } $form = ''; foreach (array_keys($cfg['fields']) as $name) { $form .= _config_display_field($cfg, $name); } $tpl->assign('form', $form); display(); }
*/ include $root . 'libs' . DS . 'Smarty' . DS . 'Smarty.class.php'; $tpl = new Smarty(); $tpl->compile_dir = $tmpdir; $tpl->template_dir = $root . 'templates'; $tpl->registerPlugin('function', 'mkurl', 'mkurl_smarty'); $tpl->registerPlugin('function', 'mkmenu', 'mkmenu_smarty'); $tpl->registerPlugin('block', 'acl', 'acl_smarty'); if (!is_dir($tpl->compile_dir)) { @mkdir($tpl->compile_dir, 0777); } if (!is_writable($tpl->compile_dir)) { chmod($tpl->compile_dir, 0777); } // Etape 1, on charge la configuration sur l'environnement présent. $cfg = get_configs(); $config = array(); foreach ($cfg as $cfgPart) { $config[$cfgPart['name']] = array(); foreach ($cfgPart['fields'] as $field) { $config[$cfgPart['name']][$field['name']] = isset($field['default']) ? $field['default'] : null; } } $conf = $pdo->prepare("SELECT * FROM config WHERE env is NULL OR env = ?"); $conf->bindValue(1, $env); $conf->execute(); while ($dat = $conf->fetch()) { $parts = explode('!!', $dat['name']); $config[$parts[0]][$parts[1]] = $dat['value']; } //Etapes 2 à 4 seulement si HTTP