fix ThemeDefault and fontsize export

This commit is contained in:
Crack
2010-07-13 22:17:19 +02:00
parent b3ae73f2aa
commit 57a8d902f4
4 changed files with 23 additions and 25 deletions

View File

@@ -455,11 +455,8 @@ class PMA_Config
return;
}
$config_data = $_SESSION['cache'][$cache_key]['userprefs'];
// type id 'db' or 'session'
// type is 'db' or 'session'
$this->set('user_preferences', $_SESSION['cache'][$cache_key]['userprefs_type']);
if (!$config_data) {
return false;
}
// backup some settings
$fontsize = $this->get('fontsize');
@@ -478,10 +475,13 @@ class PMA_Config
// load/save theme
// theme cookie exists only if we are using non-default theme
$tmanager = $_SESSION['PMA_Theme_Manager'];
if (isset($_REQUEST['set_theme'])) {
if ($tmanager->getThemeCookie()) {
if (!isset($config_data['ThemeDefault'])
|| $config_data['ThemeDefault'] != $tmanager->theme->getId()) {
// new theme was set in common.inc.php
$this->setUserValue(null, 'ThemeDefault', $tmanager->theme->id);
} else if (!$tmanager->getThemeCookie()) {
$this->setUserValue(null, 'ThemeDefault', $tmanager->theme->getId(), 'original');
}
} else {
// no cookie - read default from settings
if ($this->settings['ThemeDefault'] != $tmanager->theme
&& $tmanager->checkTheme($this->settings['ThemeDefault'])) {
@@ -489,10 +489,9 @@ class PMA_Config
$tmanager->setThemeCookie();
}
}
// save new font size
// fontsize cookie exists only if we are using a non-default size
if (isset($_POST['set_fontsize']) || isset($_COOKIE['pma_fontsize'])) {
// cookie with new fontsize exists, save setting to database and remove it
if (!isset($config_data['fontsize']) || $fontsize != $config_data['fontsize']) {
$this->setUserValue('pma_fontsize', 'fontsize', $fontsize, '82%');
}
}
@@ -876,10 +875,10 @@ class PMA_Config
{
$new_fontsize = '';
if (isset($_GET['fontsize'])) {
$new_fontsize = $_GET['fontsize'];
} elseif (isset($_POST['fontsize'])) {
$new_fontsize = $_POST['fontsize'];
if (isset($_GET['set_fontsize'])) {
$new_fontsize = $_GET['set_fontsize'];
} elseif (isset($_POST['set_fontsize'])) {
$new_fontsize = $_POST['set_fontsize'];
} elseif (isset($_COOKIE['pma_fontsize'])) {
$new_fontsize = $_COOKIE['pma_fontsize'];
}

View File

@@ -63,8 +63,9 @@ class ConfigFile
// load default config values
$cfg = &$this->cfg;
require './libraries/config.default.php';
$cfg['fontsize'] = '82%';
// load additionsl config information
// load additional config information
$cfg_db = &$this->cfgDb;
require './libraries/config.values.php';

View File

@@ -58,6 +58,7 @@ if (window.parent && window.parent.frame_navigation) {
$forms_all_keys = PMA_read_userprefs_fieldnames($forms);
$cf = ConfigFile::getInstance();
$cf->resetConfigData(); // start with a clean instance
$cf->setAllowedKeys($forms_all_keys);
$cf->updateWithGlobalConfig($GLOBALS['PMA_Config']);

View File

@@ -9,7 +9,7 @@
/**
* Loads user preferences
*
* Returns false or an array:
* Returns an array:
* * config_data - path => value pairs
* * mtime - last modification time
* * type - 'db' (config read from pmadb) or 'session' (read from user session)
@@ -21,7 +21,7 @@
* @uses PMA_getRelationsParam()
* @uses PMA_sqlAddslashes()
* @uses $GLOBALS['controllink']
* @return false|array
* @return array
*/
function PMA_load_userprefs()
{
@@ -45,13 +45,9 @@ function PMA_load_userprefs()
FROM ' . $query_table . '
WHERE `username` = \'' . PMA_sqlAddslashes($cfgRelation['user']) . '\'';
$row = PMA_DBI_fetch_single_row($query, 'ASSOC', $GLOBALS['controllink']);
if (!$row) {
return false;
}
$config_data = unserialize($row['config_data']);
return array(
'config_data' => $config_data,
'mtime' => $row['ts'],
'config_data' => $row ? unserialize($row['config_data']) : array(),
'mtime' => $row ? $row['ts'] : time(),
'type' => 'db');
}
@@ -225,7 +221,8 @@ function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $
$check_keys = array_merge($check_keys, $forms['Left_frame']['Left_frame'],
$forms['Left_frame']['Left_databases']);
$diff = array_intersect($check_keys, $diff_keys);
$refresh_left_frame = !empty($diff);
$refresh_left_frame = !empty($diff)
|| (isset($params['refresh_left_frame']) && $params['refresh_left_frame']);
// redirect
$url_params = array(