diff options
-rw-r--r-- | css/phpmyadmin.css.php | 26 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | libraries/auth/config.auth.lib.php | 2 | ||||
-rw-r--r-- | libraries/auth/cookie.auth.lib.php | 2 | ||||
-rw-r--r-- | libraries/common.lib.php | 83 | ||||
-rw-r--r-- | main.php | 35 | ||||
-rw-r--r-- | test/theme.php | 19 | ||||
-rw-r--r-- | themes.php | 1 |
8 files changed, 31 insertions, 139 deletions
diff --git a/css/phpmyadmin.css.php b/css/phpmyadmin.css.php index 550ba4b8c8..232ffcd38b 100644 --- a/css/phpmyadmin.css.php +++ b/css/phpmyadmin.css.php @@ -29,8 +29,7 @@ div.nowrap { } <?php -if ( ! isset( $theme_full_version ) - || version_compare( $theme_full_version, '2.7.0', 'lt' ) ) { +if ( $_SESSION['PMA_Theme']->checkVersion( '2.7.0' ) ) { ?> form { @@ -478,8 +477,7 @@ img.lightbulb { <?php } // end styles 2.7.0 -if ( ! isset( $theme_full_version ) - || version_compare( $theme_full_version, '2.7.1', 'lt' ) ) { +if ( $_SESSION['PMA_Theme']->checkVersion( '2.7.1' ) ) { ?> /********************/ @@ -657,24 +655,6 @@ li#li_flush_privileges { <?php } // end styles 2.7.1 -$_valid_css = array( 'left', 'right', 'print' ); -if ( empty( $_REQUEST['js_frame'] ) || ! in_array( $_REQUEST['js_frame'], $_valid_css ) ) { - $js_frame = 'left'; -} else { - $js_frame = $_REQUEST['js_frame']; -} -unset( $_valid_css ); - -if ( $js_frame == 'right' ) { - echo PMA_SQP_buildCssData(); -} - -$_css_file = $GLOBALS['cfg']['ThemePath'] - . '/' . $GLOBALS['theme'] - . '/css/theme_' . $js_frame . '.css.php'; -if ( file_exists( $_css_file ) ) { - include( $_css_file ); -} -unset( $_css_file ); +$_SESSION['PMA_Theme']->loadCss( $_REQUEST['js_frame'] ); ?> @@ -5,7 +5,6 @@ * forms frameset * * @uses libraries/common.lib.php global fnctions - * @uses libraries/select_theme.lib.php theme manager * @uses libraries/relation.lib.php table relations * @uses $_SESSION['window_name_hash'] to set it * @uses $GLOBALS['strNoFrames'] @@ -40,7 +39,6 @@ require_once('./libraries/common.lib.php'); /** * Includes the ThemeManager if it hasn't been included yet */ -require_once('./libraries/select_theme.lib.php'); require_once('./libraries/relation.lib.php'); // hash for the window names, against window hijacking diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index 456e44dde9..a7bc8c3cf3 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -79,8 +79,6 @@ function PMA_auth_fails() // Defines the charset to be used header('Content-Type: text/html; charset=' . $GLOBALS['charset']); - // Defines the theme to be used - require_once('./libraries/select_theme.lib.php'); /* HTML header */ $page_title = $GLOBALS['strAccessDenied']; require('./libraries/header_meta_style.inc.php'); diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 298200a3ef..bed780734d 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -101,8 +101,6 @@ function PMA_auth() // Defines the charset to be used header('Content-Type: text/html; charset=' . $GLOBALS['charset']); - - require_once('./libraries/select_theme.lib.php'); // Defines the "item" image depending on text direction $item_img = $GLOBALS['pmaThemeImage'] . 'item_ltr.png'; diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 90b45a8f1c..f87f3d18c5 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -317,6 +317,8 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $rs, $userl */ /* Input sanitizing */ require_once('./libraries/sanitizing.lib.php'); +require_once('./libraries/Theme.class.php'); +require_once('./libraries/Theme_Manager.class.php'); @@ -2556,70 +2558,32 @@ if (strtolower($cfg['OBGzip']) == 'auto') { } -/* Theme Manager - * 2004-05-20 Michael Keck (mail_at_michaelkeck_dot_de) - * This little script checks if there're themes available - * and if the directory $ThemePath/$theme/img/ exists - * If not, it will use default images -*/ -// Allow different theme per server -$theme_cookie_name = 'pma_theme'; -if ($GLOBALS['cfg']['ThemePerServer'] && isset($server)) { - $theme_cookie_name .= '-' . $server; -} -//echo $theme_cookie_name; -// Theme Manager -if (!$cfg['ThemeManager'] || !isset($_COOKIE[$theme_cookie_name]) || empty($_COOKIE[$theme_cookie_name])){ - $GLOBALS['theme'] = $cfg['ThemeDefault']; - $ThemeDefaultOk = FALSE; - if ($cfg['ThemePath']!='' && $cfg['ThemePath'] != FALSE) { - $tmp_theme_mainpath = $cfg['ThemePath']; - $tmp_theme_fullpath = $cfg['ThemePath'] . '/' .$cfg['ThemeDefault']; - if (@is_dir($tmp_theme_mainpath)) { - if (isset($cfg['ThemeDefault']) && @is_dir($tmp_theme_fullpath)) { - $ThemeDefaultOk = TRUE; - } - } - } - if ($ThemeDefaultOk == TRUE){ - $GLOBALS['theme'] = $cfg['ThemeDefault']; - } else { - $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'] = PMA_securePath($_POST['set_theme']); - } else { - $GLOBALS['theme'] = PMA_securePath($_COOKIE[$theme_cookie_name]); - } +/** + * themes + */ +if ( ! isset( $_SESSION['PMA_Theme_Manager'] ) ) { + $_SESSION['PMA_Theme_Manager'] = new PMA_Theme_Manager; } -// check for theme requires/name -unset($theme_name, $theme_generation, $theme_version); -@include($cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/info.inc.php'); - -// did it set correctly? -if (!isset($theme_name, $theme_generation, $theme_version)) { - $GLOBALS['theme'] = 'original'; // invalid theme -} elseif ($theme_generation != PMA_THEME_GENERATION) { - $GLOBALS['theme'] = 'original'; // different generation -} elseif ($theme_version < PMA_THEME_VERSION) { - $GLOBALS['theme'] = 'original'; // too old version +if ( isset( $_REQUEST['set_theme'] ) ) { + // if user submit a theme + $_SESSION['PMA_Theme_Manager']->setActiveTheme( $_REQUEST['set_theme'] ); } -$pmaThemePath = $cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/'; -$pmaThemeImage = $pmaThemePath . 'img/'; -$tmp_layout_file = $pmaThemePath . 'layout.inc.php'; -if (@file_exists($tmp_layout_file)) { - include($tmp_layout_file); -} -unset( $tmp_layout_file ); -if (!is_dir($pmaThemeImage)) { - $pmaThemeImage = $cfg['ThemePath'] . '/original/img/'; +$_SESSION['PMA_Theme'] = $_SESSION['PMA_Theme_Manager']->theme; + +// BC +$GLOBALS['theme'] = $_SESSION['PMA_Theme']->getName(); +$GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath(); +$GLOBALS['pmaThemeImage'] = $_SESSION['PMA_Theme']->getImgPath(); + +/** + * load layout file if exists + */ +if ( @file_exists( $GLOBALS['pmaThemePath'] . '/layout.inc.php' ) ) { + include( $GLOBALS['pmaThemePath'] . '/layout.inc.php' ); } -// end theme manager + /** * collation_connection @@ -3003,6 +2967,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { PMA_setCookie( 'pma_charset', $GLOBALS['convcharset'] ); PMA_setCookie( 'pma_collation_connection', $GLOBALS['collation_connection'] ); + $_SESSION['PMA_Theme_Manager']->setThemeCookie(); // Allow different theme per server $theme_cookie_name = 'pma_theme'; if ( isset( $server ) && $GLOBALS['cfg']['ThemePerServer'] ) { @@ -12,11 +12,6 @@ define('PMA_DISPLAY_HEADING', 0); */ require_once('./libraries/common.lib.php'); -/** - * Includes the ThemeManager - */ -require_once('./libraries/select_theme.lib.php'); - // Handles some variables that may have been sent by the calling script if (isset($db)) { unset($db); @@ -259,34 +254,10 @@ if ( isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] // added by Michael Keck <mail_at_michaelkeck_dot_de> // ThemeManager if available -if (isset($available_themes_choices) && $available_themes_choices > 1) { - $theme_selected = FALSE; - $theme_preview_path= './themes.php'; - $theme_preview_href = '<a href="' . $theme_preview_path . '" target="themes" onclick="' - . "window.open('" . $theme_preview_path . "','themes','left=10,top=20,width=510,height=350,scrollbars=yes,status=yes,resizable=yes');" - . '">'; +if ( $GLOBALS['cfg']['ThemeManager'] ) { echo '<li id="li_select_theme">'; - ?> - <form name="setTheme" method="post" action="index.php" target="_parent"> - <?php - echo PMA_generate_common_hidden_inputs( '', '', 3 ); - echo $theme_preview_href . $strTheme . '</a>:' . "\n"; - ?> - <select name="set_theme" xml:lang="en" dir="ltr" onchange="this.form.submit();" > - <?php - foreach ($available_themes_choices AS $cur_theme) { - echo '<option value="' . $cur_theme . '"'; - if ($cur_theme == $theme) { - echo ' selected="selected"'; - } - echo '>' . htmlspecialchars($available_themes_choices_names[$cur_theme]) . '</option>'; - } - ?> - </select> - <noscript><input type="submit" value="<?php echo $strGo;?>" /></noscript> - </form> - </li> - <?php + echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox(); + echo '</li>'; } PMA_printListItem( $strPmaDocumentation, 'li_pma_docs', 'Documentation.html' ); diff --git a/test/theme.php b/test/theme.php index 9456801b53..0f3b045b2d 100644 --- a/test/theme.php +++ b/test/theme.php @@ -5,7 +5,6 @@ * theme test * * @uses libraries/common.lib.php global fnctions - * @uses libraries/select_theme.lib.php theme manager */ chdir( '..' ); @@ -14,10 +13,6 @@ chdir( '..' ); * Gets core libraries and defines some variables */ require_once('./libraries/common.lib.php'); -/** - * Includes the ThemeManager if it hasn't been included yet - */ -require_once('./libraries/select_theme.lib.php'); $lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][2]; @@ -165,20 +160,8 @@ echo sprintf( $strWelcome, <fieldset> <legend><?php echo $strTheme; ?></legend> <?php -echo PMA_generate_common_hidden_inputs( '', '' ); -?> -<select name="set_theme" onchange="this.form.submit();"> -<?php -foreach ($available_themes_choices AS $cur_theme) { - echo '<option value="' . $cur_theme . '"'; - if ( $cur_theme == $theme ) { - echo ' selected="selected"'; - } - echo '>' . htmlspecialchars( $available_themes_choices_names[$cur_theme] ) - . '</option>' . "\n"; -} + echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox( false ); ?> -</select> <noscript><input type="submit" value="Go" style="vertical-align: middle" /></noscript> </fieldset> </form> diff --git a/themes.php b/themes.php index fcda420fb1..a396bd87d3 100644 --- a/themes.php +++ b/themes.php @@ -4,7 +4,6 @@ require_once('./libraries/common.lib.php'); /* Theme Select */ $path_to_themes = $cfg['ThemePath'] . '/'; -require_once('./libraries/select_theme.lib.php'); /* set language and charset */ require_once('./libraries/header_http.inc.php'); |