Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2017-11-28 17:15:34 +0300
committerMichal Čihař <michal@cihar.com>2017-11-28 17:16:01 +0300
commitf9c73c7b10e5c57bfb8deb965491f84c9d6623c7 (patch)
tree27dca967aa4bd4655babdbc785801591b7dae623
parentcbbf0d5ccf8a4d1b03851407b93453786cd1d952 (diff)
Remove special casing for font size
It is now stored in configuration in same way as any other setting. Issue #13466 Issue #11688 Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r--doc/config.rst7
-rw-r--r--index.php11
-rw-r--r--libraries/classes/Config.php66
-rw-r--r--libraries/classes/Config/Descriptions.php2
-rw-r--r--libraries/classes/Config/Forms/User/FeaturesForm.php1
-rw-r--r--libraries/classes/Theme.php2
-rw-r--r--libraries/classes/UserPreferences.php1
-rw-r--r--libraries/config.default.php5
-rw-r--r--libraries/config.values.php1
-rw-r--r--prefs_manage.php10
-rw-r--r--test/classes/ConfigTest.php22
-rw-r--r--test/classes/ThemeTest.php2
12 files changed, 45 insertions, 85 deletions
diff --git a/doc/config.rst b/doc/config.rst
index e62b52da4a..1c5780b1a9 100644
--- a/doc/config.rst
+++ b/doc/config.rst
@@ -3219,6 +3219,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..66627f3e75 100644
--- a/index.php
+++ b/index.php
@@ -66,6 +66,17 @@ if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
exit;
}
+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();
+}
+
// See FAQ 1.34
if (! empty($_REQUEST['db'])) {
$page = null;
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;
}
@@ -1286,34 +1262,6 @@ class Config
}
/**
- * 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
*
* @return void
@@ -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 '<form name="form_fontsize_selection" id="form_fontsize_selection"'
- . ' method="get" action="index.php" class="disableAjax">' . "\n"
+ . ' method="post" action="index.php" class="disableAjax">' . "\n"
. Url::getHiddenInputs() . "\n"
. Config::getFontsizeSelection() . "\n"
. '</form>';
diff --git a/libraries/classes/Config/Descriptions.php b/libraries/classes/Config/Descriptions.php
index b46b8c4b87..5173eab335 100644
--- a/libraries/classes/Config/Descriptions.php
+++ b/libraries/classes/Config/Descriptions.php
@@ -1478,6 +1478,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/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/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..e74e8828e0 100644
--- a/libraries/config.default.php
+++ b/libraries/config.default.php
@@ -2860,6 +2860,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..a32189e3b8 100644
--- a/libraries/config.values.php
+++ b/libraries/config.values.php
@@ -263,6 +263,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(
'<option value="7em"',
Config::getFontsizeForm()
@@ -111,7 +110,7 @@ class ConfigTest extends PmaTestCase
);
//test getFontsizeOptions for "pt" unit
- $_COOKIE['pma_fontsize'] = "10pt";
+ $GLOBALS['PMA_Config']->set('FontSize', '10pt');
$this->assertContains(
'<option value="2pt"',
Config::getFontsizeForm()
@@ -122,7 +121,7 @@ class ConfigTest extends PmaTestCase
);
//test getFontsizeOptions for "px" unit
- $_COOKIE['pma_fontsize'] = "10px";
+ $GLOBALS['PMA_Config']->set('FontSize', '10px');
$this->assertContains(
'<option value="5px"',
Config::getFontsizeForm()
@@ -133,7 +132,7 @@ class ConfigTest extends PmaTestCase
);
//test getFontsizeOptions for unknown unit
- $_COOKIE['pma_fontsize'] = "10abc";
+ $GLOBALS['PMA_Config']->set('FontSize', '10abc');
$this->assertContains(
'<option value="7abc"',
Config::getFontsizeForm()
@@ -142,9 +141,8 @@ class ConfigTest extends PmaTestCase
'<option value="8abc"',
Config::getFontsizeForm()
);
- unset($_COOKIE['pma_fontsize']);
//rollback the fontsize setting
- $GLOBALS['PMA_Config']->set('fontsize', $fontsize);
+ $GLOBALS['PMA_Config']->set('FontSize', $fontsize);
}
/**
@@ -840,15 +838,15 @@ class ConfigTest extends PmaTestCase
$GLOBALS['PMA_Theme']->filesize_info
);
- $this->object->set('fontsize', 10);
+ $this->object->set('FontSize', 10);
$this->assertEquals(10 + $partial_sum, $this->object->getThemeUniqueValue());
- $this->object->set('fontsize', null);
- $_COOKIE['pma_fontsize'] = 20;
+ $this->object->set('FontSize', 20);
$this->assertEquals(20 + $partial_sum, $this->object->getThemeUniqueValue());
- unset($_COOKIE['pma_fontsize']);
+ $this->object->set('FontSize', null);
$this->assertEquals($partial_sum, $this->object->getThemeUniqueValue());
+ $this->object->set('FontSize', '82%');
}
diff --git a/test/classes/ThemeTest.php b/test/classes/ThemeTest.php
index da3a275435..63a3291286 100644
--- a/test/classes/ThemeTest.php
+++ b/test/classes/ThemeTest.php
@@ -312,7 +312,7 @@ class ThemeTest extends PmaTestCase
'82%'
);
- $GLOBALS['PMA_Config']->set('fontsize', '12px');
+ $GLOBALS['PMA_Config']->set('FontSize', '12px');
$this->assertEquals(
$this->object->getFontSize(),
'12px'