Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove font size feature #13925

Merged
merged 25 commits into from Apr 14, 2018
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions doc/config.rst
Expand Up @@ -3228,13 +3228,6 @@ 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be simply removed. See this example: 8cc6de4#diff-5a2f160c43a637ce34c72d79c769e4cf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, got it! I'll fix it.

Default queries
---------------

Expand Down
14 changes: 0 additions & 14 deletions index.php
Expand Up @@ -66,17 +66,6 @@
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();
Expand Down Expand Up @@ -294,9 +283,6 @@
, ThemeManager::getInstance()->getHtmlSelectBox();
echo '</li>';
}
echo '<li id="li_select_fontsize">';
echo Config::getFontsizeForm();
echo '</li>';

echo '</ul>';

Expand Down
114 changes: 1 addition & 113 deletions libraries/classes/Config.php
Expand Up @@ -1186,18 +1186,12 @@ public function getSource()
* returns a unique value to force a CSS reload if either the config
* or the theme changes
*
* @return int Summary of unix timestamps and fontsize,
* @return int Summary of unix timestamps,
* to be unique on theme parameters change
*/
public function getThemeUniqueValue()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should update the doc for this method to reflect the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find anything related to this in the doc, please help.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to the comment block just above the method.

{
if (null !== $this->get('FontSize')) {
$fontsize = intval($this->get('FontSize'));
} else {
$fontsize = 0;
}
return (
$fontsize +
$this->source_mtime +
$this->default_source_mtime +
$this->get('user_preferences_mtime') +
Expand Down Expand Up @@ -1370,112 +1364,6 @@ public function enableBc()
}
}

/**
* returns options for font size selection
*
* @param string $current_size current selected font size with unit
*
* @return array selectable font sizes
*/
protected static function getFontsizeOptions($current_size = '82%')
{
$unit = preg_replace('/[0-9.]*/', '', $current_size);
$value = preg_replace('/[^0-9.]*/', '', $current_size);

$factors = array();
$options = array();
$options["$value"] = $value . $unit;

if ($unit === '%') {
$factors[] = 1;
$factors[] = 5;
$factors[] = 10;
$options['100'] = '100%';
} elseif ($unit === 'em') {
$factors[] = 0.05;
$factors[] = 0.2;
$factors[] = 1;
} elseif ($unit === 'pt') {
$factors[] = 0.5;
$factors[] = 2;
} elseif ($unit === 'px') {
$factors[] = 1;
$factors[] = 5;
$factors[] = 10;
} else {
//unknown font size unit
$factors[] = 0.05;
$factors[] = 0.2;
$factors[] = 1;
$factors[] = 5;
$factors[] = 10;
}

foreach ($factors as $key => $factor) {
$option_inc = $value + $factor;
$option_dec = $value - $factor;
while (count($options) < 21) {
$options["$option_inc"] = $option_inc . $unit;
if ($option_dec > $factors[0]) {
$options["$option_dec"] = $option_dec . $unit;
}
$option_inc += $factor;
$option_dec -= $factor;
if (isset($factors[$key + 1])
&& $option_inc >= $value + $factors[$key + 1]
) {
break;
}
}
}
ksort($options);
return $options;
}

/**
* returns html selectbox for font sizes
*
* @return string html selectbox
*/
protected static function getFontsizeSelection()
{
$current_size = $GLOBALS['PMA_Config']->get('FontSize');
// for the case when there is no config file (this is supported)
if (empty($current_size)) {
$current_size = '82%';
}
$options = Config::getFontsizeOptions($current_size);

$return = '<label for="select_fontsize">' . __('Font size')
. ':</label>' . "\n"
. '<select name="set_fontsize" id="select_fontsize"'
. ' class="autosubmit">' . "\n";
foreach ($options as $option) {
$return .= '<option value="' . $option . '"';
if ($option == $current_size) {
$return .= ' selected="selected"';
}
$return .= '>' . $option . '</option>' . "\n";
}
$return .= '</select>';

return $return;
}

/**
* return complete font size selection form
*
* @return string html selectbox
*/
public static function getFontsizeForm()
{
return '<form name="form_fontsize_selection" id="form_fontsize_selection"'
. ' method="post" action="index.php" class="disableAjax">' . "\n"
. Url::getHiddenInputs() . "\n"
. Config::getFontsizeSelection() . "\n"
. '</form>';
}

/**
* removes cookie
*
Expand Down
1 change: 0 additions & 1 deletion libraries/classes/Config/ConfigFile.php
Expand Up @@ -86,7 +86,6 @@ public function __construct($base_config = null)
// load default config values
$cfg = &$this->_defaultCfg;
include './libraries/config.default.php';
$cfg['fontsize'] = '82%';

// load additional config information
$cfg_db = &$this->_cfgDb;
Expand Down
2 changes: 0 additions & 2 deletions libraries/classes/Config/Descriptions.php
Expand Up @@ -1482,8 +1482,6 @@ public static function getString($path, $type = 'name')
return __('Order');
case 'Console_OrderBy_name':
return __('Order by');
case 'FontSize_name':
return __('Font size');
case 'DefaultConnectionCollation_name':
return __('Server connection collation');
}
Expand Down
1 change: 0 additions & 1 deletion libraries/classes/Config/Forms/User/FeaturesForm.php
Expand Up @@ -24,7 +24,6 @@ public static function getForms()
'SendErrorReports',
'ConsoleEnterExecutes',
'DisableShortcutKeys',
'FontSize',
),
'Databases' => array(
'Servers/1/only_db', // saves to Server/only_db
Expand Down
14 changes: 0 additions & 14 deletions libraries/classes/Theme.php
Expand Up @@ -415,20 +415,6 @@ public function getPrintPreview()
]);
}

/**
* Gets currently configured font size.
*
* @return String with font size.
*/
function getFontSize()
{
$fs = $GLOBALS['PMA_Config']->get('FontSize');
if (!is_null($fs)) {
return $fs;
}
return '82%';
}

/**
* Generates code for CSS gradient using various browser extensions.
*
Expand Down
6 changes: 0 additions & 6 deletions libraries/config.default.php
Expand Up @@ -2866,12 +2866,6 @@
*/
$cfg['ThemePerServer'] = false;


/**
* Font size to use by default
*/
$cfg['FontSize'] = '82%';

/*******************************************************************************
*
*/
Expand Down
1 change: 0 additions & 1 deletion libraries/config.values.php
Expand Up @@ -265,7 +265,6 @@
'Servers/1/hide_db' => 'validateRegex',
'TextareaCols' => 'validatePositiveNumber',
'TextareaRows' => 'validatePositiveNumber',
'FontSize' => array(array('validateByRegex', '/^[0-9.]+(px|em|pt|\%)$/')),
'TrustedProxies' => 'validateTrustedProxies');

/**
Expand Down
5 changes: 0 additions & 5 deletions test/classes/Config/ConfigFileTest.php
Expand Up @@ -62,11 +62,6 @@ protected function tearDown()
public function testNewObjectState()
{
// Check default dynamic values
$this->assertEquals(
"82%",
$this->object->getDefault('fontsize')
);

$this->assertEquals(
array(),
$this->object->getConfig()
Expand Down
73 changes: 0 additions & 73 deletions test/classes/ConfigTest.php
Expand Up @@ -80,71 +80,6 @@ public function testCheckSystem()
$this->assertNotEmpty($this->object->get('PMA_MAJOR_VERSION'));
}

/**
* Test for GetFontsizeForm
*
* @return void
*/
public function testGetFontsizeForm()
{
$this->assertContains(
'<form name="form_fontsize_selection" id="form_fontsize_selection"',
Config::getFontsizeForm()
);

$this->assertContains(
'<label for="select_fontsize">',
Config::getFontsizeForm()
);

//test getFontsizeOptions for "em" unit
$fontsize = $GLOBALS['PMA_Config']->get('FontSize');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more places where the FontSize setting is used with the Config class.

$GLOBALS['PMA_Config']->set('FontSize', '10em');
$this->assertContains(
'<option value="7em"',
Config::getFontsizeForm()
);
$this->assertContains(
'<option value="8em"',
Config::getFontsizeForm()
);

//test getFontsizeOptions for "pt" unit
$GLOBALS['PMA_Config']->set('FontSize', '10pt');
$this->assertContains(
'<option value="2pt"',
Config::getFontsizeForm()
);
$this->assertContains(
'<option value="4pt"',
Config::getFontsizeForm()
);

//test getFontsizeOptions for "px" unit
$GLOBALS['PMA_Config']->set('FontSize', '10px');
$this->assertContains(
'<option value="5px"',
Config::getFontsizeForm()
);
$this->assertContains(
'<option value="6px"',
Config::getFontsizeForm()
);

//test getFontsizeOptions for unknown unit
$GLOBALS['PMA_Config']->set('FontSize', '10abc');
$this->assertContains(
'<option value="7abc"',
Config::getFontsizeForm()
);
$this->assertContains(
'<option value="8abc"',
Config::getFontsizeForm()
);
//rollback the fontsize setting
$GLOBALS['PMA_Config']->set('FontSize', $fontsize);
}

/**
* Test for checkOutputCompression
*
Expand Down Expand Up @@ -822,15 +757,7 @@ public function testGetThemeUniqueValue()
$GLOBALS['PMA_Theme']->filesize_info
);

$this->object->set('FontSize', 10);
$this->assertEquals(10 + $partial_sum, $this->object->getThemeUniqueValue());

$this->object->set('FontSize', 20);
$this->assertEquals(20 + $partial_sum, $this->object->getThemeUniqueValue());
$this->object->set('FontSize', null);

$this->assertEquals($partial_sum, $this->object->getThemeUniqueValue());
$this->object->set('FontSize', '82%');

}

Expand Down
20 changes: 0 additions & 20 deletions test/classes/ThemeTest.php
Expand Up @@ -303,26 +303,6 @@ public function testGetPrintPreview()
);
}

/**
* Test for getFontSize
*
* @return void
*/
public function testGetFontSize()
{
$this->assertEquals(
$this->object->getFontSize(),
'82%'
);

$GLOBALS['PMA_Config']->set('FontSize', '12px');
$this->assertEquals(
$this->object->getFontSize(),
'12px'
);

}

/**
* Test for getCssGradient
*
Expand Down
2 changes: 1 addition & 1 deletion themes/original/css/common.css.php
Expand Up @@ -16,7 +16,7 @@

/* general tags */
html {
font-size: <?php echo $theme->getFontSize(); ?>
font-size: 82%;
}

input,
Expand Down
2 changes: 1 addition & 1 deletion themes/pmahomme/css/common.css.php
Expand Up @@ -15,7 +15,7 @@
/******************************************************************************/
/* general tags */
html {
font-size: <?php echo $theme->getFontSize(); ?>
font-size: 82%;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to keep the font-size property here.


input,
Expand Down