- make use of new PMA_Theme and PMA_Theme_Manager classes

- remove libraries/select_theme.lib.php
This commit is contained in:
Sebastian Mendel
2005-11-29 12:25:31 +00:00
parent 061da44a92
commit a7b7f0bd11
8 changed files with 31 additions and 139 deletions

View File

@@ -29,8 +29,7 @@ div.nowrap {
} }
<?php <?php
if ( ! isset( $theme_full_version ) if ( $_SESSION['PMA_Theme']->checkVersion( '2.7.0' ) ) {
|| version_compare( $theme_full_version, '2.7.0', 'lt' ) ) {
?> ?>
form { form {
@@ -478,8 +477,7 @@ img.lightbulb {
<?php <?php
} // end styles 2.7.0 } // end styles 2.7.0
if ( ! isset( $theme_full_version ) if ( $_SESSION['PMA_Theme']->checkVersion( '2.7.1' ) ) {
|| version_compare( $theme_full_version, '2.7.1', 'lt' ) ) {
?> ?>
/********************/ /********************/
@@ -657,24 +655,6 @@ li#li_flush_privileges {
<?php <?php
} // end styles 2.7.1 } // 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' ) { $_SESSION['PMA_Theme']->loadCss( $_REQUEST['js_frame'] );
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 );
?> ?>

View File

@@ -5,7 +5,6 @@
* forms frameset * forms frameset
* *
* @uses libraries/common.lib.php global fnctions * @uses libraries/common.lib.php global fnctions
* @uses libraries/select_theme.lib.php theme manager
* @uses libraries/relation.lib.php table relations * @uses libraries/relation.lib.php table relations
* @uses $_SESSION['window_name_hash'] to set it * @uses $_SESSION['window_name_hash'] to set it
* @uses $GLOBALS['strNoFrames'] * @uses $GLOBALS['strNoFrames']
@@ -40,7 +39,6 @@ require_once('./libraries/common.lib.php');
/** /**
* Includes the ThemeManager if it hasn't been included yet * Includes the ThemeManager if it hasn't been included yet
*/ */
require_once('./libraries/select_theme.lib.php');
require_once('./libraries/relation.lib.php'); require_once('./libraries/relation.lib.php');
// hash for the window names, against window hijacking // hash for the window names, against window hijacking

View File

@@ -79,8 +79,6 @@ function PMA_auth_fails()
// Defines the charset to be used // Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']); header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
// Defines the theme to be used
require_once('./libraries/select_theme.lib.php');
/* HTML header */ /* HTML header */
$page_title = $GLOBALS['strAccessDenied']; $page_title = $GLOBALS['strAccessDenied'];
require('./libraries/header_meta_style.inc.php'); require('./libraries/header_meta_style.inc.php');

View File

@@ -101,8 +101,6 @@ function PMA_auth()
// Defines the charset to be used // Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']); header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
require_once('./libraries/select_theme.lib.php');
// Defines the "item" image depending on text direction // Defines the "item" image depending on text direction
$item_img = $GLOBALS['pmaThemeImage'] . 'item_ltr.png'; $item_img = $GLOBALS['pmaThemeImage'] . 'item_ltr.png';

View File

@@ -317,6 +317,8 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $rs, $userl
*/ */
/* Input sanitizing */ /* Input sanitizing */
require_once('./libraries/sanitizing.lib.php'); 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) * themes
* This little script checks if there're themes available */
* and if the directory $ThemePath/$theme/img/ exists if ( ! isset( $_SESSION['PMA_Theme_Manager'] ) ) {
* If not, it will use default images $_SESSION['PMA_Theme_Manager'] = new PMA_Theme_Manager;
*/
// 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]);
}
} }
// check for theme requires/name if ( isset( $_REQUEST['set_theme'] ) ) {
unset($theme_name, $theme_generation, $theme_version); // if user submit a theme
@include($cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/info.inc.php'); $_SESSION['PMA_Theme_Manager']->setActiveTheme( $_REQUEST['set_theme'] );
// 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
} }
$pmaThemePath = $cfg['ThemePath'] . '/' . $GLOBALS['theme'] . '/'; $_SESSION['PMA_Theme'] = $_SESSION['PMA_Theme_Manager']->theme;
$pmaThemeImage = $pmaThemePath . 'img/';
$tmp_layout_file = $pmaThemePath . 'layout.inc.php'; // BC
if (@file_exists($tmp_layout_file)) { $GLOBALS['theme'] = $_SESSION['PMA_Theme']->getName();
include($tmp_layout_file); $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 * collation_connection
@@ -3003,6 +2967,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
PMA_setCookie( 'pma_charset', $GLOBALS['convcharset'] ); PMA_setCookie( 'pma_charset', $GLOBALS['convcharset'] );
PMA_setCookie( 'pma_collation_connection', $GLOBALS['collation_connection'] ); PMA_setCookie( 'pma_collation_connection', $GLOBALS['collation_connection'] );
$_SESSION['PMA_Theme_Manager']->setThemeCookie();
// Allow different theme per server // Allow different theme per server
$theme_cookie_name = 'pma_theme'; $theme_cookie_name = 'pma_theme';
if ( isset( $server ) && $GLOBALS['cfg']['ThemePerServer'] ) { if ( isset( $server ) && $GLOBALS['cfg']['ThemePerServer'] ) {

View File

@@ -12,11 +12,6 @@ define('PMA_DISPLAY_HEADING', 0);
*/ */
require_once('./libraries/common.lib.php'); 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 // Handles some variables that may have been sent by the calling script
if (isset($db)) { if (isset($db)) {
unset($db); unset($db);
@@ -259,34 +254,10 @@ if ( isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding']
// added by Michael Keck <mail_at_michaelkeck_dot_de> // added by Michael Keck <mail_at_michaelkeck_dot_de>
// ThemeManager if available // ThemeManager if available
if (isset($available_themes_choices) && $available_themes_choices > 1) { if ( $GLOBALS['cfg']['ThemeManager'] ) {
$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');"
. '">';
echo '<li id="li_select_theme">'; echo '<li id="li_select_theme">';
?> echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
<form name="setTheme" method="post" action="index.php" target="_parent"> echo '</li>';
<?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
} }
PMA_printListItem( $strPmaDocumentation, 'li_pma_docs', 'Documentation.html' ); PMA_printListItem( $strPmaDocumentation, 'li_pma_docs', 'Documentation.html' );

View File

@@ -5,7 +5,6 @@
* theme test * theme test
* *
* @uses libraries/common.lib.php global fnctions * @uses libraries/common.lib.php global fnctions
* @uses libraries/select_theme.lib.php theme manager
*/ */
chdir( '..' ); chdir( '..' );
@@ -14,10 +13,6 @@ chdir( '..' );
* Gets core libraries and defines some variables * Gets core libraries and defines some variables
*/ */
require_once('./libraries/common.lib.php'); 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]; $lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][2];
@@ -165,20 +160,8 @@ echo sprintf( $strWelcome,
<fieldset> <fieldset>
<legend><?php echo $strTheme; ?></legend> <legend><?php echo $strTheme; ?></legend>
<?php <?php
echo PMA_generate_common_hidden_inputs( '', '' ); echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox( false );
?> ?>
<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";
}
?>
</select>
<noscript><input type="submit" value="Go" style="vertical-align: middle" /></noscript> <noscript><input type="submit" value="Go" style="vertical-align: middle" /></noscript>
</fieldset> </fieldset>
</form> </form>

View File

@@ -4,7 +4,6 @@ require_once('./libraries/common.lib.php');
/* Theme Select */ /* Theme Select */
$path_to_themes = $cfg['ThemePath'] . '/'; $path_to_themes = $cfg['ThemePath'] . '/';
require_once('./libraries/select_theme.lib.php');
/* set language and charset */ /* set language and charset */
require_once('./libraries/header_http.inc.php'); require_once('./libraries/header_http.inc.php');