From ae85313a36a37775332e09fdeeb03ea2d1656530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 12 Aug 2004 17:38:43 +0000 Subject: [PATCH] Impleneted versioning and naming for themes (RFEs #991642 and #991645). --- ChangeLog | 6 ++++- libraries/common.lib.php | 34 ++++++++++++++++++----------- libraries/defines.lib.php | 5 +++++ libraries/select_theme.lib.php | 12 ++++++++++ main.php | 4 ++-- themes.php | 23 ++++++++++++++----- themes/darkblue_orange/info.inc.php | 6 +++++ themes/original/info.inc.php | 6 +++++ 8 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 themes/darkblue_orange/info.inc.php create mode 100644 themes/original/info.inc.php diff --git a/ChangeLog b/ChangeLog index d9b32595a..c37ec221c 100755 --- a/ChangeLog +++ b/ChangeLog @@ -16,7 +16,11 @@ $Source$ * left.php, queryframe.php: Replace htmlentities with htmlspecialchars (bug #1008002). * libraries/config_import.lib.php: Remove compatibility code for colors. - * lang/czech: Improved message. + * lang/czech: Improved message.\ + * main.php, themes.php, libraries/common.lib.php, + libraries/defines.lib.php, libraries/select_theme.lib.php, + themes/darkblue_orange/info.inc.php, themes/original/info.inc.php: + Impleneted versioning and naming for themes (RFEs #991642 and #991645). 2004-08-11 Michal Čihař * tbl_replace.php: Do not empty protected values (bug #1006812). diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 129426792..b745f00b0 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -312,28 +312,36 @@ if (!isset($_COOKIE['pma_theme']) || empty($_COOKIE['pma_theme'])){ } } if ($ThemeDefaultOk == TRUE){ - $pmaThemeImage = './' . $cfg['ThemePath'] . '/' . $cfg['ThemeDefault'] . '/img/'; - $tmp_layout_file = './' . $cfg['ThemePath'] . '/' . $cfg['ThemeDefault'] . '/layout.inc.php'; - if (@file_exists($tmp_layout_file)) { - include($tmp_layout_file); - } + $GLOBALS['theme'] = $cfg['ThemeDefault']; } else { - $pmaThemeImage = './' . $cfg['ThemePath'] . '/original/img/'; + $GLOBALS['theme'] = 'original'; } } else { // if we just changed theme, we must take the new one so that // index.php takes the correct one for height computing if (isset($_POST['set_theme'])) { - $GLOBALS['theme'] = $_POST['set_theme']; + $GLOBALS['theme'] = PMA_securePath($_POST['set_theme']); } else { - $GLOBALS['theme'] = $_COOKIE['pma_theme']; - } - $pmaThemeImage = './' . $cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/img/'; - $tmp_layout_file = './' . $cfg['ThemePath'] . '/' . PMA_securePath($GLOBALS['theme']) . '/layout.inc.php'; - if (@file_exists($tmp_layout_file)) { - include($tmp_layout_file); + $GLOBALS['theme'] = PMA_securePath($_COOKIE['pma_theme']); } } + +// check for theme requires/name +unset($theme_name, $theme_version); +@include($cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/info.inc.php'); + +// did it set correctly? +if (!isset($theme_name, $theme_version)) + $GLOBALS['theme'] = 'original'; // invalid theme + +if ($theme_version < PMA_THEME_VERSION) + $GLOBALS['theme'] = 'original'; // too old version + +$pmaThemeImage = './' . $cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/img/'; +$tmp_layout_file = './' . $cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/layout.inc.php'; +if (@file_exists($tmp_layout_file)) { + include($tmp_layout_file); +} if (!is_dir($pmaThemeImage)) { $pmaThemeImage = './' . $cfg['ThemePath'] . '/original/img/'; } diff --git a/libraries/defines.lib.php b/libraries/defines.lib.php index 97c2e4abb..d932126e7 100644 --- a/libraries/defines.lib.php +++ b/libraries/defines.lib.php @@ -6,6 +6,7 @@ * DEFINES VARIABLES & CONSTANTS * Overview: * PMA_VERSION (string) - phpMyAdmin version string + * PMA_THEME_VERSION (int) - phpMyAdmin theme version integer * PMA_PHP_INT_VERSION (int) - eg: 30017 instead of 3.0.17 or * 40006 instead of 4.0.6RC3 * PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows @@ -21,6 +22,10 @@ if (!defined('PMA_VERSION')) { define('PMA_VERSION', '2.6.0-rc2'); } +if (!defined('PMA_THEME_VERSION')) { + define('PMA_THEME_VERSION', 1); +} + // php version if (!defined('PMA_PHP_INT_VERSION')) { if (!preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match)) { diff --git a/libraries/select_theme.lib.php b/libraries/select_theme.lib.php index 12ab60774..25a809ee5 100644 --- a/libraries/select_theme.lib.php +++ b/libraries/select_theme.lib.php @@ -54,7 +54,19 @@ if ($PMA_ThemeAvailable == TRUE) { // themeManager is available while (FALSE !== ($PMA_Theme = readdir($handleThemes))) { // get themes if ($PMA_Theme != "." && $PMA_Theme != ".." && $PMA_Theme != 'CVS') { // file check if (@is_dir($cfg['ThemePath'].'/'.$PMA_Theme)) { // check the theme + // check for theme requires/name + unset($theme_name, $theme_version); + @include($cfg['ThemePath'] . '/' . $PMA_Theme . '/info.inc.php'); + + // did it set correctly? + if (!isset($theme_name, $theme_version)) + continue; // invalid theme + + if ($theme_version < PMA_THEME_VERSION) + continue; // too old version + $available_themes_choices[]=$PMA_Theme; + $available_themes_choices_names[$PMA_Theme] = $theme_name; } // end check the theme } // end file check } // end get themes diff --git a/main.php b/main.php index 589287e64..8b642998f 100644 --- a/main.php +++ b/main.php @@ -626,12 +626,12 @@ if (isset($available_themes_choices) && $available_themes_choices > 1) { ?> diff --git a/themes.php b/themes.php index c848a6595..be2b32915 100644 --- a/themes.php +++ b/themes.php @@ -86,14 +86,27 @@ echo ""; ' . strtoupper(preg_replace("/_/"," ",$PMA_Theme)) . ''; + echo '' . $theme_name . ''; ?> @@ -106,8 +119,8 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes if (document.getElementById) { document.write('style="border: 1px solid #000000;" '); } - document.write('alt=" - Theme" '); - document.write('title=" - Theme" />'); + document.write('alt=" - Theme" '); + document.write('title=" - Theme" />'); document.write('
'); document.write('[ '); document.write(''); @@ -116,7 +129,7 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes diff --git a/themes/darkblue_orange/info.inc.php b/themes/darkblue_orange/info.inc.php new file mode 100644 index 000000000..cccc81c75 --- /dev/null +++ b/themes/darkblue_orange/info.inc.php @@ -0,0 +1,6 @@ + diff --git a/themes/original/info.inc.php b/themes/original/info.inc.php new file mode 100644 index 000000000..666b44854 --- /dev/null +++ b/themes/original/info.inc.php @@ -0,0 +1,6 @@ +