Impleneted versioning and naming for themes (RFEs #991642 and #991645).

This commit is contained in:
Michal Čihař
2004-08-12 17:38:43 +00:00
parent 4af60bec2c
commit ae85313a36
8 changed files with 75 additions and 21 deletions

View File

@@ -16,7 +16,11 @@ $Source$
* left.php, queryframe.php: Replace htmlentities with htmlspecialchars * left.php, queryframe.php: Replace htmlentities with htmlspecialchars
(bug #1008002). (bug #1008002).
* libraries/config_import.lib.php: Remove compatibility code for colors. * 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> 2004-08-11 Michal Čihař <michal@cihar.com>
* tbl_replace.php: Do not empty protected values (bug #1006812). * tbl_replace.php: Do not empty protected values (bug #1006812).

View File

@@ -312,28 +312,36 @@ if (!isset($_COOKIE['pma_theme']) || empty($_COOKIE['pma_theme'])){
} }
} }
if ($ThemeDefaultOk == TRUE){ if ($ThemeDefaultOk == TRUE){
$pmaThemeImage = './' . $cfg['ThemePath'] . '/' . $cfg['ThemeDefault'] . '/img/'; $GLOBALS['theme'] = $cfg['ThemeDefault'];
$tmp_layout_file = './' . $cfg['ThemePath'] . '/' . $cfg['ThemeDefault'] . '/layout.inc.php';
if (@file_exists($tmp_layout_file)) {
include($tmp_layout_file);
}
} else { } else {
$pmaThemeImage = './' . $cfg['ThemePath'] . '/original/img/'; $GLOBALS['theme'] = 'original';
} }
} else { } else {
// if we just changed theme, we must take the new one so that // if we just changed theme, we must take the new one so that
// index.php takes the correct one for height computing // index.php takes the correct one for height computing
if (isset($_POST['set_theme'])) { if (isset($_POST['set_theme'])) {
$GLOBALS['theme'] = $_POST['set_theme']; $GLOBALS['theme'] = PMA_securePath($_POST['set_theme']);
} else { } else {
$GLOBALS['theme'] = $_COOKIE['pma_theme']; $GLOBALS['theme'] = PMA_securePath($_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);
} }
} }
// 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)) { if (!is_dir($pmaThemeImage)) {
$pmaThemeImage = './' . $cfg['ThemePath'] . '/original/img/'; $pmaThemeImage = './' . $cfg['ThemePath'] . '/original/img/';
} }

View File

@@ -6,6 +6,7 @@
* DEFINES VARIABLES & CONSTANTS * DEFINES VARIABLES & CONSTANTS
* Overview: * Overview:
* PMA_VERSION (string) - phpMyAdmin version string * 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 * PMA_PHP_INT_VERSION (int) - eg: 30017 instead of 3.0.17 or
* 40006 instead of 4.0.6RC3 * 40006 instead of 4.0.6RC3
* PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows * 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'); define('PMA_VERSION', '2.6.0-rc2');
} }
if (!defined('PMA_THEME_VERSION')) {
define('PMA_THEME_VERSION', 1);
}
// php version // php version
if (!defined('PMA_PHP_INT_VERSION')) { if (!defined('PMA_PHP_INT_VERSION')) {
if (!preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match)) { if (!preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match)) {

View File

@@ -54,7 +54,19 @@ if ($PMA_ThemeAvailable == TRUE) { // themeManager is available
while (FALSE !== ($PMA_Theme = readdir($handleThemes))) { // get themes while (FALSE !== ($PMA_Theme = readdir($handleThemes))) { // get themes
if ($PMA_Theme != "." && $PMA_Theme != ".." && $PMA_Theme != 'CVS') { // file check if ($PMA_Theme != "." && $PMA_Theme != ".." && $PMA_Theme != 'CVS') { // file check
if (@is_dir($cfg['ThemePath'].'/'.$PMA_Theme)) { // check the theme 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[]=$PMA_Theme;
$available_themes_choices_names[$PMA_Theme] = $theme_name;
} // end check the theme } // end check the theme
} // end file check } // end file check
} // end get themes } // end get themes

View File

@@ -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"> <select name="set_theme" dir="ltr" onchange="this.form.submit();" style="vertical-align: middle">
<?php <?php
foreach ($available_themes_choices AS $i => $cur_theme) { foreach ($available_themes_choices AS $cur_theme) {
echo '<option value="' . $cur_theme . '"'; echo '<option value="' . $cur_theme . '"';
if ($cur_theme == $theme) { if ($cur_theme == $theme) {
echo ' selected="selected"'; echo ' selected="selected"';
} }
echo '>' . $cur_theme . '</option>'; echo '>' . $available_themes_choices_names[$cur_theme] . '</option>';
} }
?> ?>
</select> </select>

View File

@@ -86,14 +86,27 @@ echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
<?php <?php
if ($handleThemes = opendir($path_to_themes)) { // open themes if ($handleThemes = opendir($path_to_themes)) { // open themes
while (false !== ($PMA_Theme = readdir($handleThemes))) { // get screens 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; $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 if (is_dir($screen_directory) && @file_exists($screen_directory.'/screen.png')) { // if screen exists then output
?> ?>
<tr> <tr>
<th align="left"> <th align="left">
<?php <?php
echo '<b>' . strtoupper(preg_replace("/_/"," ",$PMA_Theme)) . '</b>'; echo '<b>' . $theme_name . '</b>';
?> ?>
</th> </th>
</tr> </tr>
@@ -106,8 +119,8 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes
if (document.getElementById) { if (document.getElementById) {
document.write('style="border: 1px solid #000000;" '); document.write('style="border: 1px solid #000000;" ');
} }
document.write('alt="<?php echo strtoupper(preg_replace("/_/"," ",$PMA_Theme)); ?> - Theme" '); document.write('alt="<?php echo $theme_name; ?> - Theme" ');
document.write('title="<?php echo strtoupper(preg_replace("/_/"," ",$PMA_Theme)); ?> - Theme" />'); document.write('title="<?php echo $theme_name; ?> - Theme" />');
document.write('</a><br />'); document.write('</a><br />');
document.write('[ <b><a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">'); document.write('[ <b><a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">');
document.write('<?php echo (isset($strTakeIt) ? addslashes($strTakeIt) : 'take it'); ?>'); document.write('<?php echo (isset($strTakeIt) ? addslashes($strTakeIt) : 'take it'); ?>');
@@ -116,7 +129,7 @@ if ($handleThemes = opendir($path_to_themes)) { // open themes
</script> </script>
<noscript> <noscript>
<?php <?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> </noscript>
</td> </td>

View File

@@ -0,0 +1,6 @@
<?php
/* $Id$ */
/* Theme information */
$theme_name = 'Darkblue/orange';
$theme_version = 1;
?>

View File

@@ -0,0 +1,6 @@
<?php
/* $Id$ */
/* Theme information */
$theme_name = 'Original';
$theme_version = 1;
?>