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

View File

@@ -63,8 +63,9 @@ class ConfigFile
// load default config values // load default config values
$cfg = &$this->cfg; $cfg = &$this->cfg;
require './libraries/config.default.php'; require './libraries/config.default.php';
$cfg['fontsize'] = '82%';
// load additionsl config information // load additional config information
$cfg_db = &$this->cfgDb; $cfg_db = &$this->cfgDb;
require './libraries/config.values.php'; 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); $forms_all_keys = PMA_read_userprefs_fieldnames($forms);
$cf = ConfigFile::getInstance(); $cf = ConfigFile::getInstance();
$cf->resetConfigData(); // start with a clean instance
$cf->setAllowedKeys($forms_all_keys); $cf->setAllowedKeys($forms_all_keys);
$cf->updateWithGlobalConfig($GLOBALS['PMA_Config']); $cf->updateWithGlobalConfig($GLOBALS['PMA_Config']);

View File

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