improved font size definition

This commit is contained in:
Loïc Chapeaux
2001-09-04 12:53:36 +00:00
parent 16f51e3b24
commit dd51fca8b4
5 changed files with 132 additions and 28 deletions

View File

@@ -11,6 +11,9 @@
* PMA_WINDOWS (bool) - mark if phpMyAdmin running on windows
* server
* MYSQL_INT_VERSION (int) - eg: 32339 instead of 3.23.39
* USR_OS (string) - the plateform (os) of the user
* USR_BROWSER_AGENT (string) - the browser of the user
* USR_BROWSER_VER (double) - the version of this browser
*/
// phpMyAdmin release
if (!defined('PHPMYADMIN_VERSION')) {
@@ -74,4 +77,40 @@ if (!defined('MYSQL_MAJOR_VERSION') && isset($link)) {
define('MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
unset($match);
}
// Determines platform (OS), browser and version of the user
// Based on a phpBuilder article:
// see http://www.phpbuilder.net/columns/tim20000821.php3
if (!defined('USR_OS')) {
if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
}
// 1. Platform
if (strstr($HTTP_USER_AGENT, 'Win')) {
define('USR_OS', 'Win');
} else if (strstr($HTTP_USER_AGENT, 'Mac')) {
define('USR_OS', 'Mac');
} else if (strstr($HTTP_USER_AGENT, 'Linux')) {
define('USR_OS', 'Linux');
} else if (strstr($HTTP_USER_AGENT, 'Unix')) {
define('USR_OS', 'Unix');
} else {
define('USR_OS', 'Other');
}
// 2. browser and version
if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
define('USR_BROWSER_VER', $log_version[1]);
define('USR_BROWSER_AGENT', 'IE');
} else if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
define('USR_BROWSER_VER', $log_version[2]);
define('USR_BROWSER_AGENT', 'OPERA');
} else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
define('USR_BROWSER_VER', $log_version[1]);
define('USR_BROWSER_AGENT', 'MOZILLA');
} else {
define('USR_BROWSER_VER', 0);
define('USR_BROWSER_AGENT', 'OTHER');
}
}
?>

View File

@@ -32,6 +32,8 @@ header('Content-Type: text/html; charset=' . $charset);
/**
* Sends the beginning of the html page then returns to the calling script
*/
// Gets the font sizes to use
set_font_sizes();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
@@ -40,14 +42,14 @@ header('Content-Type: text/html; charset=' . $charset);
<title>phpMyAdmin</title>
<style type="text/css">
<!--
body {font-family: <?php echo $right_font_family; ?>; font-size: 10pt}
th {font-family: <?php echo $right_font_family; ?>; font-size: 10pt; font-weight: bold; background-color: <?php echo $cfgThBgcolor;?>}
td {font-family: <?php echo $right_font_family; ?>; font-size: 10pt}
form {font-family: <?php echo $right_font_family; ?>; font-size: 10pt}
h1 {font-family: <?php echo $right_font_family; ?>; font-size: 16pt; font-weight: bold}
A:link {font-family: <?php echo $right_font_family; ?>; font-size: 10pt; text-decoration: none; color: #0000ff}
A:visited {font-family: <?php echo $right_font_family; ?>; font-size: 10pt; text-decoration: none; color: #0000ff}
A:hover {font-family: <?php echo $right_font_family; ?>; font-size: 10pt; text-decoration: underline; color: #FF0000}
body {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>}
th {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; font-weight: bold; background-color: <?php echo $cfgThBgcolor;?>}
td {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>}
form {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>}
h1 {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_bigger; ?>; font-weight: bold}
A:link {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; text-decoration: none; color: #0000ff}
A:visited {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; text-decoration: none; color: #0000ff}
A:hover {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo $font_size; ?>; text-decoration: underline; color: #FF0000}
A:link.nav {font-family: <?php echo $right_font_family; ?>; color: #000000}
A:visited.nav {font-family: <?php echo $right_font_family; ?>; color: #000000}
A:hover.nav {font-family: <?php echo $right_font_family; ?>; color: #FF0000}

24
left.js
View File

@@ -220,11 +220,11 @@ if (capable) {
var lstyle = '<style type="text\/css">'
+ '<!--'
+ 'div {color: #000000;}'
+ '.heada {font-family: ' + fontFamily + '; font-size: 10pt}'
+ '.heada_cnt {font-family: ' + fontFamily + '; font-size: 8pt}'
+ '.heada {font-family: ' + fontFamily + '; font-size: ' + fontSize + '}'
+ '.heada_cnt {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '}'
+ '.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration:none; display: block}'
+ '.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; text-decoration:none; display: none}'
+ '.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt;}'
+ '.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; text-decoration:none; display: none}'
+ '.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: ' + fontSmall + '}'
+ '.tblItem:hover {color: #FF0000; text-decoration: underline}'
+ '\/\/-->'
+ '<\/style>';
@@ -234,17 +234,17 @@ if (capable) {
writeln('<style type="text\/css">');
writeln('<!--');
writeln('div {color: #000000; }');
writeln('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
writeln('.heada_cnt {font-family: ' + fontFamily + '; font-size: 8pt}');
writeln('.heada {font-family: ' + fontFamily + '; font-size: ' + fontSize + '}');
writeln('.heada_cnt {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '}');
if (isIE4) {
writeln('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; display: block}');
writeln('.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; text-decoration: none; display: none}');
writeln('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt}');
writeln('.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; text-decoration: none; display: none}');
writeln('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: ' + fontSmall + '}');
writeln('.tblItem:hover {color: #FF0000; text-decoration: underline}');
}
else {
writeln('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; position: absolute; visibility: hidden}');
writeln('.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; position: absolute; visibility: hidden}');
writeln('.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; position: absolute; visibility: hidden}');
writeln('.item, .tblItem {color: #333399; text-decoration: none}');
}
writeln('\/\/-->');
@@ -257,10 +257,10 @@ else {
writeln('<style type="text\/css">');
writeln('<!--');
writeln('div {color: #000000; }');
writeln('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
writeln('.heada_cnt {font-family: ' + fontFamily + '; font-size: 8pt}');
writeln('.heada {font-family: ' + fontFamily + '; font-size: ' + fontSize + '}');
writeln('.heada_cnt {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '}');
writeln('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none}');
writeln('.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; text-decoration: none}');
writeln('.child {font-family: ' + fontFamily + '; font-size: ' + fontSmall + '; color: #333399; text-decoration: none}');
writeln('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}');
writeln('.tblItem:hover {color: #FF0000; text-decoration: underline}');
writeln('\/\/-->');

View File

@@ -71,6 +71,8 @@ header('Content-Type: text/html; charset=' . $charset);
/**
* Displays the frame
*/
// Gets the font sizes to use
set_font_sizes();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
@@ -99,6 +101,9 @@ if ($num_dbs > 1) {
}
}
var fontFamily = '<?php echo $left_font_family; ?>';
var fontSize = '<?php echo $font_size; ?>';
var fontBig = '<?php echo $font_bigger; ?>';
var fontSmall = '<?php echo $font_smaller; ?>';
var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
//-->
</script>
@@ -107,9 +112,9 @@ if ($num_dbs > 1) {
<style type="text/css">
<!--
div {color: #000000}
.heada {font-family: <?php echo $left_font_family; ?>; font-size: 10pt}
.heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
.parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
.child {font-family: <?php echo $left_font_family; ?>; font-size: 8pt; color: #333399; text-decoration: none}
.child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}
.tblItem:hover {color: #FF0000; text-decoration: underline}
//-->
@@ -131,10 +136,10 @@ else if ($num_dbs == 1) {
<!--
body {font-family: <?php echo $left_font_family; ?>; font-size: 10pt}
div {color: #000000}
.heada {font-family: <?php echo $left_font_family; ?>; font-size: 10pt}
.heada_cnt {font-family: <?php echo $left_font_family; ?>; font-size: 8pt}
.heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
.heada_cnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>}
.parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
.child {font-family: <?php echo $left_font_family; ?>; font-size: 8pt; color: #333399; text-decoration: none}
.child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}
.tblItem:hover {color: #FF0000; text-decoration: underline}
//-->
@@ -147,10 +152,10 @@ else {
?>
<style type="text/css">
<!--
body {font-family: <?php echo $left_font_family; ?>; font-size: 10pt}
body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
div {color: #000000}
.heada {font-family: <?php echo $left_font_family; ?>; font-size: 10pt}
.heada_cnt {font-family: <?php echo $left_font_family; ?>; font-size: 8pt}
.heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
.heada_cnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>}
//-->
</style>
<?php

View File

@@ -483,6 +483,64 @@ if (!defined('__LIB_INC__')){
/* ----------------------- Set of misc functions ----------------------- */
/**
* Determines the font sizes to use depending on the os and browser of the
* user.
*
* This function is based on an article from phpBuilder (see
* http://www.phpbuilder.net/columns/tim20000821.php3).
*
* @return boolean always true
*
* @global string the standard font size
* @global string the font size for titles
* @global string the small font size
* @global string the smallest font size
*
* @version 1.0
*
* @access public
*/
function set_font_sizes()
{
global $font_size, $font_bigger, $font_smaller, $font_smallest;
// IE for win case: needs smaller fonts than anyone else
if (USR_OS == 'Win'
&& (USR_BROWSER_AGENT == 'IE' || USR_BROWSER_AGENT == 'OPERA')) {
$font_size = 'x-small';
$font_bigger = 'large ';
// Unreadable
// $font_smaller = 'xx-small';
$font_smaller = '90%';
$font_smallest = '7pt';
}
// Other browsers for win case
else if (USR_OS == 'Win') {
$font_size = 'small';
$font_bigger = 'large ';
$font_smaller = 'x-small';
$font_smallest = 'x-small';
}
// Mac browsers: need bigger fonts
else if (USR_OS == 'Mac') {
$font_size = 'medium';
$font_bigger = 'x-large ';
$font_smaller = 'small';
$font_smallest = 'x-small';
}
// Other cases
else {
$font_size = 'small';
$font_bigger = 'large ';
$font_smaller = 'x-small';
$font_smallest = 'x-small';
}
return true;
} // end of the 'set_font_sizes()' function
/**
* Adds backquotes on both sides of a database, table or field name.
* Since MySQL 3.23.6 this allows to use non-alphanumeric characters in