Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-11-28 15:37:28 +01:00
commit 92a0b8451c
15 changed files with 78 additions and 99 deletions

View File

@ -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
---------------

View File

@ -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;

View File

@ -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

View File

@ -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 '<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>';

View File

@ -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;
}

View File

@ -24,6 +24,7 @@ class FeaturesForm extends BaseForm
'SendErrorReports',
'ConsoleEnterExecutes',
'DisableShortcutKeys',
'FontSize',
),
'Databases' => array(
'Servers/1/only_db', // saves to Server/only_db

View File

@ -24,7 +24,8 @@ class NaviForm extends BaseForm
'FirstLevelNavigationItems',
'NavigationTreeDisplayItemFilterMinimum',
'NumRecentTables',
'NumFavoriteTables'
'NumFavoriteTables',
'NavigationWidth',
),
'Navi_tree' => array(
'MaxNavigationItems',

View File

@ -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;
}

View File

@ -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
*

View File

@ -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;

View File

@ -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%';
/*******************************************************************************
*
*/

View File

@ -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');
/**

View File

@ -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);

View File

@ -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%');
}

View File

@ -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'