moved Import by LOAD DATA settings to CSV category

moved PMA_array_* functions to core.lib.php
moved PMA_read_userprefs_fieldnames() to user_preferences.lib.php
server/database/table filename templates are saved to pmadb when "remember template" is checked
This commit is contained in:
Crack
2010-07-04 21:56:46 +02:00
parent d63fa35c0f
commit 68d9c40113
12 changed files with 216 additions and 145 deletions

View File

@@ -58,14 +58,13 @@ function PMA_load_userprefs()
* @uses PMA_Message::rawError()
* @uses PMA_sqlAddslashes()
* @uses PMA_getRelationsParam()
* @param array $config_data
* @return true|PMA_Message
*/
function PMA_save_userprefs()
function PMA_save_userprefs(array $config_array)
{
$cfgRelation = PMA_getRelationsParam();
$cf = ConfigFile::getInstance();
$config_data = serialize($cf->getConfigArray());
$config_data = serialize($config_array);
$query_table = PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['userconfig']);
$query = '
@@ -119,4 +118,57 @@ function PMA_apply_userprefs(array $config_data)
}
return $cfg;
}
/**
* Reads user preferences field names
*
* @param array|null $forms
* @return array
*/
function PMA_read_userprefs_fieldnames(array $forms = null)
{
static $names;
// return cached results
if ($names !== null) {
return $names;
}
if (is_null($forms)) {
$forms = array();
include 'libraries/config/user_preferences.forms.php';
}
$names = array();
foreach ($forms as $formset) {
foreach ($formset as $form) {
foreach ($form as $k => $v) {
$names[] = is_int($k) ? $v : $k;
}
}
}
return $names;
}
/**
* Updates one user preferences option (loads and saves to database).
*
* No validation is done!
*
* @param string $cfg_name
* @param mixed $value
* @return void
*/
function PMA_persist_option($path, $value, $default_value)
{
$prefs = PMA_load_userprefs();
if ($value === $default_value) {
if (isset($prefs['config_data'][$path])) {
unset($prefs['config_data'][$path]);
} else {
return;
}
} else {
$prefs['config_data'][$path] = $value;
}
PMA_save_userprefs($prefs['config_data']);
}
?>