diff options
-rwxr-xr-x | ChangeLog | 6 | ||||
-rw-r--r-- | libraries/common.lib.php | 34 | ||||
-rw-r--r-- | libraries/defines.lib.php | 5 | ||||
-rw-r--r-- | libraries/select_theme.lib.php | 12 | ||||
-rw-r--r-- | main.php | 4 | ||||
-rw-r--r-- | themes.php | 23 | ||||
-rw-r--r-- | themes/darkblue_orange/info.inc.php | 6 | ||||
-rw-r--r-- | themes/original/info.inc.php | 6 |
8 files changed, 75 insertions, 21 deletions
@@ -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ř <michal@cihar.com> * tbl_replace.php: Do not empty protected values (bug #1006812). diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 1294267922..b745f00b0b 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 97c2e4abbc..d932126e79 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 12ab607741..25a809ee56 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 @@ -626,12 +626,12 @@ if (isset($available_themes_choices) && $available_themes_choices > 1) { ?> <select name="set_theme" dir="ltr" onchange="this.form.submit();" style="vertical-align: middle"> <?php - foreach ($available_themes_choices AS $i => $cur_theme) { + foreach ($available_themes_choices AS $cur_theme) { echo '<option value="' . $cur_theme . '"'; if ($cur_theme == $theme) { echo ' selected="selected"'; } - echo '>' . $cur_theme . '</option>'; + echo '>' . $available_themes_choices_names[$cur_theme] . '</option>'; } ?> </select> diff --git a/themes.php b/themes.php index c848a65951..be2b32915c 100644 --- a/themes.php +++ b/themes.php @@ -86,14 +86,27 @@ echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; <?php if ($handleThemes = opendir($path_to_themes)) { // open themes while (false !== ($PMA_Theme = readdir($handleThemes))) { // get screens - if ($PMA_Theme != "." && $PMA_Theme != "..") { // && !strstr($PMA_Theme,'original')) { // but not the original + if ($PMA_Theme != "." && $PMA_Theme != "..") { $screen_directory = $path_to_themes . $PMA_Theme; + + // check for theme requires/name + unset($theme_name, $theme_version); + @include($path_to_themes . $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 + + if (is_dir($screen_directory) && @file_exists($screen_directory.'/screen.png')) { // if screen exists then output ?> <tr> <th align="left"> <?php - echo '<b>' . strtoupper(preg_replace("/_/"," ",$PMA_Theme)) . '</b>'; + echo '<b>' . $theme_name . '</b>'; ?> </th> </tr> @@ -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="<?php echo strtoupper(preg_replace("/_/"," ",$PMA_Theme)); ?> - Theme" '); - document.write('title="<?php echo strtoupper(preg_replace("/_/"," ",$PMA_Theme)); ?> - Theme" />'); + document.write('alt="<?php echo $theme_name; ?> - Theme" '); + document.write('title="<?php echo $theme_name; ?> - Theme" />'); document.write('</a><br />'); document.write('[ <b><a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">'); document.write('<?php echo (isset($strTakeIt) ? addslashes($strTakeIt) : 'take it'); ?>'); @@ -116,7 +129,7 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes </script> <noscript> <?php - echo '<img src="' . $screen_directory . '/screen.png" border="1" alt="' . strtoupper(preg_replace("/_/"," ",$PMA_Theme)) . ' - Theme" />'; + echo '<img src="' . $screen_directory . '/screen.png" border="1" alt="' . $theme_name . ' - Theme" />'; ?> </noscript> </td> diff --git a/themes/darkblue_orange/info.inc.php b/themes/darkblue_orange/info.inc.php new file mode 100644 index 0000000000..cccc81c75b --- /dev/null +++ b/themes/darkblue_orange/info.inc.php @@ -0,0 +1,6 @@ +<?php +/* $Id$ */ +/* Theme information */ +$theme_name = 'Darkblue/orange'; +$theme_version = 1; +?> diff --git a/themes/original/info.inc.php b/themes/original/info.inc.php new file mode 100644 index 0000000000..666b44854a --- /dev/null +++ b/themes/original/info.inc.php @@ -0,0 +1,6 @@ +<?php +/* $Id$ */ +/* Theme information */ +$theme_name = 'Original'; +$theme_version = 1; +?> |