diff --git a/doc/config.rst b/doc/config.rst index e62b52da4a..e6be9dd8ba 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -2094,6 +2094,13 @@ Navigation panel setup Whether to show events under database in the navigation panel. +.. config:option:: $cfg['NavigationWdith'] + + :type: integer + :default: 240 + + Navigation panel width. + Main panel ---------- @@ -3219,6 +3226,13 @@ Theme manager settings Whether to allow different theme for each server. +.. config:option:: $cfg['FontSize'] + + :type: string + :default: '82%' + + Font size to use, is applied in CSS. + Default queries --------------- diff --git a/index.php b/index.php index 98039f1b0f..93a3785322 100644 --- a/index.php +++ b/index.php @@ -66,6 +66,27 @@ if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) { exit; } +// user selected font size +if (isset($_POST['set_fontsize']) && preg_match('/^[0-9.]+(px|em|pt|\%)$/', $_POST['set_fontsize'])) { + $GLOBALS['PMA_Config']->setUserValue( + null, + 'FontSize', + $_POST['set_fontsize'], + '82%' + ); + header('Location: index.php' . Url::getCommonRaw()); + exit(); +} +// if user selected a theme +if (isset($_POST['set_theme'])) { + $tmanager = ThemeManager::getInstance(); + $tmanager->setActiveTheme($_POST['set_theme']); + $tmanager->setThemeCookie(); + header('Location: index.php' . Url::getCommonRaw()); + exit(); +} + + // See FAQ 1.34 if (! empty($_REQUEST['db'])) { $page = null; diff --git a/js/navigation.js b/js/navigation.js index cf4340ee53..d1aabde459 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -1117,9 +1117,6 @@ var ResizeHandler = function () { var resizer_width = $resizer.width(); var $collapser = $('#pma_navigation_collapser'); var windowWidth = $(window).width(); - if (pos > 240 && windowWidth > 768) { - pos = 241; - } $('#pma_navigation').width(pos); $('body').css('margin-' + this.left, pos + 'px'); $('#floating_menubar, #pma_console') @@ -1221,7 +1218,7 @@ var ResizeHandler = function () { */ this.mouseup = function (event) { $('body').css('cursor', ''); - Cookies.set('pma_navi_width', event.data.resize_handler.getPos(event)); + configSet('NavigationWidth', event.data.resize_handler.getPos(event)); $('#topmenu').menuResizer('resize'); $(document) .off('mousemove') @@ -1284,10 +1281,8 @@ var ResizeHandler = function () { // Hide the pma_navigation initially when loaded on mobile if ($(window).width() < 768) { this.setWidth(0); - } else if (Cookies.get('pma_navi_width')) { - // If we have a cookie, set the width of the panel to its value - var pos = Math.abs(parseInt(Cookies.get('pma_navi_width'), 10) || 0); - this.setWidth(pos); + } else { + this.setWidth(configGet('NavigationWidth', false)); $('#topmenu').menuResizer('resize'); } // Register the events for the resizer and the collapser diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index 4053a4c2a5..9387b89454 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -756,12 +756,6 @@ class Config $this->setSource($source); } - /** - * We check and set the font size at this point, to make the font size - * selector work also for users without a config.inc.php - */ - $this->checkFontsize(); - if (! $this->checkConfigSource()) { // even if no config file, set collation_connection $this->checkCollationConnection(); @@ -934,11 +928,6 @@ class Config $_SESSION['cache'][$cache_key]['userprefs_mtime'] ); - // backup some settings - $org_fontsize = ''; - if (isset($this->settings['fontsize'])) { - $org_fontsize = $this->settings['fontsize']; - } // load config array $this->settings = array_replace_recursive($this->settings, $config_data); $GLOBALS['cfg'] = array_replace_recursive($GLOBALS['cfg'], $config_data); @@ -977,15 +966,6 @@ class Config } } - // save font size - if ((! isset($config_data['fontsize']) - && $org_fontsize != '82%') - || isset($config_data['fontsize']) - && $org_fontsize != $config_data['fontsize'] - ) { - $this->setUserValue(null, 'fontsize', $org_fontsize, '82%'); - } - // save language if (isset($_COOKIE['pma_lang']) || isset($_POST['lang'])) { if ((! isset($config_data['lang']) @@ -1234,18 +1214,14 @@ class Config /** * returns a unique value to force a CSS reload if either the config * or the theme changes - * must also check the pma_fontsize cookie in case there is no - * config file * * @return int Summary of unix timestamps and fontsize, * to be unique on theme parameters change */ public function getThemeUniqueValue() { - if (null !== $this->get('fontsize')) { - $fontsize = intval($this->get('fontsize')); - } elseif (isset($_COOKIE['pma_fontsize'])) { - $fontsize = intval($_COOKIE['pma_fontsize']); + if (null !== $this->get('FontSize')) { + $fontsize = intval($this->get('FontSize')); } else { $fontsize = 0; } @@ -1285,34 +1261,6 @@ class Config $this->set('collation_connection', $collation); } - /** - * checks for font size configuration, and sets font size as requested by user - * - * @return void - */ - public function checkFontsize() - { - $new_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']; - } - - if (preg_match('/^[0-9.]+(px|em|pt|\%)$/', $new_fontsize)) { - $this->set('fontsize', $new_fontsize); - } elseif (! $this->get('fontsize')) { - // 80% would correspond to the default browser font size - // of 16, but use 82% to help read the monoface font - $this->set('fontsize', '82%'); - } - - $this->setCookie('pma_fontsize', $this->get('fontsize'), '82%'); - } - /** * checks if upload is enabled * @@ -1548,14 +1496,10 @@ class Config */ protected static function getFontsizeSelection() { - $current_size = $GLOBALS['PMA_Config']->get('fontsize'); + $current_size = $GLOBALS['PMA_Config']->get('FontSize'); // for the case when there is no config file (this is supported) if (empty($current_size)) { - if (isset($_COOKIE['pma_fontsize'])) { - $current_size = htmlspecialchars($_COOKIE['pma_fontsize']); - } else { - $current_size = '82%'; - } + $current_size = '82%'; } $options = Config::getFontsizeOptions($current_size); @@ -1583,7 +1527,7 @@ class Config public static function getFontsizeForm() { return '
' . "\n" + . ' method="post" action="index.php" class="disableAjax">' . "\n" . Url::getHiddenInputs() . "\n" . Config::getFontsizeSelection() . "\n" . '
'; diff --git a/libraries/classes/Config/Descriptions.php b/libraries/classes/Config/Descriptions.php index b46b8c4b87..88c638aba1 100644 --- a/libraries/classes/Config/Descriptions.php +++ b/libraries/classes/Config/Descriptions.php @@ -768,6 +768,8 @@ class Descriptions return __('In the navigation panel, replaces the database tree with a selector'); case 'ShowDatabasesNavigationAsTree_name': return __('Show databases navigation as tree'); + case 'NavigationWidth_name': + return __('Navigation panel width'); case 'NavigationLinkWithMainPanel_desc': return __('Link with main panel by highlighting the current database or table.'); case 'NavigationLinkWithMainPanel_name': @@ -1478,6 +1480,8 @@ class Descriptions return __('Order'); case 'Console_OrderBy_name': return __('Order by'); + case 'FontSize_name': + return __('Font size'); } return null; } diff --git a/libraries/classes/Config/Forms/User/FeaturesForm.php b/libraries/classes/Config/Forms/User/FeaturesForm.php index b3e027e510..6e8e30d1d1 100644 --- a/libraries/classes/Config/Forms/User/FeaturesForm.php +++ b/libraries/classes/Config/Forms/User/FeaturesForm.php @@ -24,6 +24,7 @@ class FeaturesForm extends BaseForm 'SendErrorReports', 'ConsoleEnterExecutes', 'DisableShortcutKeys', + 'FontSize', ), 'Databases' => array( 'Servers/1/only_db', // saves to Server/only_db diff --git a/libraries/classes/Config/Forms/User/NaviForm.php b/libraries/classes/Config/Forms/User/NaviForm.php index 7084353b6e..1d9ff1ff76 100644 --- a/libraries/classes/Config/Forms/User/NaviForm.php +++ b/libraries/classes/Config/Forms/User/NaviForm.php @@ -24,7 +24,8 @@ class NaviForm extends BaseForm 'FirstLevelNavigationItems', 'NavigationTreeDisplayItemFilterMinimum', 'NumRecentTables', - 'NumFavoriteTables' + 'NumFavoriteTables', + 'NavigationWidth', ), 'Navi_tree' => array( 'MaxNavigationItems', diff --git a/libraries/classes/Theme.php b/libraries/classes/Theme.php index acb1cd6d9a..52e1fe4667 100644 --- a/libraries/classes/Theme.php +++ b/libraries/classes/Theme.php @@ -433,7 +433,7 @@ class Theme */ function getFontSize() { - $fs = $GLOBALS['PMA_Config']->get('fontsize'); + $fs = $GLOBALS['PMA_Config']->get('FontSize'); if (!is_null($fs)) { return $fs; } diff --git a/libraries/classes/ThemeManager.php b/libraries/classes/ThemeManager.php index 0dff5e2722..68c8b8cad2 100644 --- a/libraries/classes/ThemeManager.php +++ b/libraries/classes/ThemeManager.php @@ -428,11 +428,6 @@ class ThemeManager { $tmanager = self::getInstance(); - if (isset($_REQUEST['set_theme'])) { - // if user selected a theme - $tmanager->setActiveTheme($_REQUEST['set_theme']); - } - /** * the theme object * diff --git a/libraries/classes/UserPreferences.php b/libraries/classes/UserPreferences.php index 05e90ab4a9..69fd8905dc 100644 --- a/libraries/classes/UserPreferences.php +++ b/libraries/classes/UserPreferences.php @@ -168,7 +168,6 @@ class UserPreferences $whitelist = array_flip(UserFormList::getFields()); // whitelist some additional fields which are custom handled $whitelist['ThemeDefault'] = true; - $whitelist['fontsize'] = true; $whitelist['lang'] = true; $whitelist['collation_connection'] = true; $whitelist['Server/hide_db'] = true; diff --git a/libraries/config.default.php b/libraries/config.default.php index fc42feba92..bd30705f6a 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -1045,6 +1045,13 @@ $cfg['NavigationTreeShowProcedures'] = true; */ $cfg['NavigationTreeShowEvents'] = true; +/** + * Width of navigation panel + * + * @global boolean $cfg['NavigationWidth'] + */ +$cfg['NavigationWidth'] = 240; + /******************************************************************************* * In the main panel, at startup... */ @@ -2860,6 +2867,11 @@ $cfg['ThemeDefault'] = 'pmahomme'; $cfg['ThemePerServer'] = false; +/** + * Font size to use by default + */ +$cfg['FontSize'] = '82%'; + /******************************************************************************* * */ diff --git a/libraries/config.values.php b/libraries/config.values.php index 1e7409e679..74c021daa4 100644 --- a/libraries/config.values.php +++ b/libraries/config.values.php @@ -51,6 +51,7 @@ $cfg_db['NavigationTreeDefaultTabTable2'] = array( ); $cfg_db['NavigationTreeDbSeparator'] = 'short_string'; $cfg_db['NavigationTreeTableSeparator'] = 'short_string'; +$cfg_db['NavigationWidth'] = 'integer'; $cfg_db['TableNavigationLinksMode'] = array( 'icons' => __('Icons'), 'text' => __('Text'), @@ -255,6 +256,7 @@ $cfg_db['_validators'] = array( 'MaxTableList' => 'validatePositiveNumber', 'MemoryLimit' => array(array('validateByRegex', '/^(-1|(\d+(?:[kmg])?))$/i')), 'NavigationTreeTableLevel' => 'validatePositiveNumber', + 'NavigationWidth' => 'validatePositiveNumber', 'QueryHistoryMax' => 'validatePositiveNumber', 'RepeatCells' => 'validateNonNegativeNumber', 'Server' => 'validateServer', @@ -263,6 +265,7 @@ $cfg_db['_validators'] = array( 'Servers/1/hide_db' => 'validateRegex', 'TextareaCols' => 'validatePositiveNumber', 'TextareaRows' => 'validatePositiveNumber', + 'FontSize' => array(array('validateByRegex', '/^[0-9.]+(px|em|pt|\%)$/')), 'TrustedProxies' => 'validateTrustedProxies'); /** diff --git a/prefs_manage.php b/prefs_manage.php index 74a97fff96..a87ec2c63c 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -145,7 +145,7 @@ if (isset($_POST['submit_export']) exit; } - // check for ThemeDefault and fontsize + // check for ThemeDefault $params = array(); $tmanager = ThemeManager::getInstance(); if (isset($config['ThemeDefault']) @@ -155,11 +155,6 @@ if (isset($_POST['submit_export']) $tmanager->setActiveTheme($config['ThemeDefault']); $tmanager->setThemeCookie(); } - if (isset($config['fontsize']) - && $config['fontsize'] != $GLOBALS['PMA_Config']->get('fontsize') - ) { - $params['set_fontsize'] = $config['fontsize']; - } if (isset($config['lang']) && $config['lang'] != $GLOBALS['lang'] ) { @@ -201,9 +196,6 @@ if (isset($_POST['submit_export']) $result = UserPreferences::save(array()); if ($result === true) { $params = array(); - if ($GLOBALS['PMA_Config']->get('fontsize') != '82%') { - $GLOBALS['PMA_Config']->removeCookie('pma_fontsize'); - } $GLOBALS['PMA_Config']->removeCookie('pma_collaction_connection'); $GLOBALS['PMA_Config']->removeCookie('pma_lang'); UserPreferences::redirect('prefs_manage.php', $params); diff --git a/test/classes/ConfigTest.php b/test/classes/ConfigTest.php index 39cd267b7b..20e067ff58 100644 --- a/test/classes/ConfigTest.php +++ b/test/classes/ConfigTest.php @@ -98,9 +98,8 @@ class ConfigTest extends PmaTestCase ); //test getFontsizeOptions for "em" unit - $fontsize = $GLOBALS['PMA_Config']->get('fontsize'); - $GLOBALS['PMA_Config']->set('fontsize', ''); - $_COOKIE['pma_fontsize'] = "10em"; + $fontsize = $GLOBALS['PMA_Config']->get('FontSize'); + $GLOBALS['PMA_Config']->set('FontSize', '10em'); $this->assertContains( '