diff --git a/css/phpmyadmin.css.php b/css/phpmyadmin.css.php index 550ba4b8c..232ffcd38 100644 --- a/css/phpmyadmin.css.php +++ b/css/phpmyadmin.css.php @@ -29,8 +29,7 @@ div.nowrap { } checkVersion( '2.7.0' ) ) { ?> form { @@ -478,8 +477,7 @@ img.lightbulb { checkVersion( '2.7.1' ) ) { ?> /********************/ @@ -657,24 +655,6 @@ li#li_flush_privileges { loadCss( $_REQUEST['js_frame'] ); ?> diff --git a/index.php b/index.php index c3a3b6a8b..62abe96b1 100644 --- a/index.php +++ b/index.php @@ -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 456e44dde..a7bc8c3cf 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 298200a3e..bed780734 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 90b45a8f1..f87f3d18c 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); +$_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' ); } -unset( $tmp_layout_file ); -if (!is_dir($pmaThemeImage)) { - $pmaThemeImage = $cfg['ThemePath'] . '/original/img/'; -} -// 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'] ) { diff --git a/main.php b/main.php index fa1be507a..4ef413200 100644 --- a/main.php +++ b/main.php @@ -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 // ThemeManager if available -if (isset($available_themes_choices) && $available_themes_choices > 1) { - $theme_selected = FALSE; - $theme_preview_path= './themes.php'; - $theme_preview_href = ''; +if ( $GLOBALS['cfg']['ThemeManager'] ) { echo '
  • '; - ?> -
    - :' . "\n"; - ?> - - -
    -
  • - getHtmlSelectBox(); + echo ''; } PMA_printListItem( $strPmaDocumentation, 'li_pma_docs', 'Documentation.html' ); diff --git a/test/theme.php b/test/theme.php index 9456801b5..0f3b045b2 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,
    getHtmlSelectBox( false ); ?> -
    diff --git a/themes.php b/themes.php index fcda420fb..a396bd87d 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');