Browse files

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

  • Loading branch information...
1 parent 4af60be commit ae85313a36a37775332e09fdeeb03ea2d1656530 @nijel nijel committed Aug 12, 2004
View
6 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ř <michal@cihar.com>
* tbl_replace.php: Do not empty protected values (bug #1006812).
View
34 libraries/common.lib.php
@@ -312,28 +312,36 @@ function PMA_securePath($path) {
}
}
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/';
}
View
5 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 @@
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)) {
View
12 libraries/select_theme.lib.php
@@ -54,7 +54,19 @@
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
View
4 main.php
@@ -626,12 +626,12 @@ function PMA_cmp(&$a, $b)
?>
<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>
View
23 themes.php
@@ -86,14 +86,27 @@ function takeThis(what){
<?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 @@ function takeThis(what){
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 @@ function takeThis(what){
</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>
View
6 themes/darkblue_orange/info.inc.php
@@ -0,0 +1,6 @@
+<?php
+/* $Id$ */
+/* Theme information */
+$theme_name = 'Darkblue/orange';
+$theme_version = 1;
+?>
View
6 themes/original/info.inc.php
@@ -0,0 +1,6 @@
+<?php
+/* $Id$ */
+/* Theme information */
+$theme_name = 'Original';
+$theme_version = 1;
+?>

0 comments on commit ae85313

Please sign in to comment.