Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: select_theme.lib.php,v 2.13 2005/07/24 12:07:21 nijel Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 00004 00034 require_once('./libraries/grab_globals.lib.php'); 00035 global $PHP_SELF; 00039 $PMA_ThemeDefault = FALSE; 00040 $PMA_ThemeAvailable = FALSE; 00041 if ($cfg['ThemeManager']){ 00042 $PMA_ThemeAvailable = TRUE; 00043 } 00044 00045 if ($PMA_ThemeAvailable == TRUE){ // check after default theme 00046 $tmp_path_default = $cfg['ThemePath'] . '/' .$cfg['ThemeDefault']; 00047 if (isset($cfg['ThemeDefault']) && is_dir($tmp_path_default)){ 00048 $PMA_ThemeDefault = TRUE; 00049 } 00050 } // end check default theme 00051 00052 if ($PMA_ThemeAvailable == TRUE) { // themeManager is available 00053 if ($handleThemes = opendir($cfg['ThemePath'])) { // check for themes directory 00054 while (FALSE !== ($PMA_Theme = readdir($handleThemes))) { // get themes 00055 if ($PMA_Theme != "." && $PMA_Theme != ".." && $PMA_Theme != 'CVS') { // file check 00056 if (@is_dir($cfg['ThemePath'].'/'.$PMA_Theme)) { // check the theme 00057 // check for theme requires/name 00058 unset($theme_name, $theme_generation, $theme_version); 00059 @include($cfg['ThemePath'] . '/' . $PMA_Theme . '/info.inc.php'); 00060 00061 // did it set correctly? 00062 if (!isset($theme_name, $theme_version, $theme_generation)) 00063 continue; // invalid theme 00064 00065 if ($theme_generation != PMA_THEME_GENERATION) 00066 continue; // different generation 00067 00068 if ($theme_version < PMA_THEME_VERSION) 00069 continue; // too old version 00070 00071 $available_themes_choices[]=$PMA_Theme; 00072 $available_themes_choices_names[$PMA_Theme] = $theme_name; 00073 } // end check the theme 00074 } // end file check 00075 } // end get themes 00076 } // end check for themes directory 00077 closedir($handleThemes); 00078 asort($available_themes_choices); 00079 } // end themeManger 00080 00081 // Allow different theme per server 00082 $theme_cookie_name = 'pma_theme'; 00083 if ($GLOBALS['cfg']['ThemePerServer']) { 00084 $theme_cookie_name .= '-' . $server; 00085 } 00086 00087 if (isset($set_theme)) { // if user submit a theme 00088 setcookie($theme_cookie_name, $set_theme, time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); 00089 } else { // else check if user have a theme cookie 00090 if (!isset($_COOKIE[$theme_cookie_name]) || empty($_COOKIE[$theme_cookie_name])) { 00091 if ($PMA_ThemeDefault == TRUE) { 00092 if (basename($PHP_SELF) == 'index.php') { 00093 setcookie($theme_cookie_name, $cfg['ThemeDefault'], time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); 00094 } 00095 $pmaTheme=$cfg['ThemeDefault']; 00096 }else{ 00097 if (basename($PHP_SELF) == 'index.php') { 00098 setcookie($theme_cookie_name, 'original', time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); 00099 } 00100 $pmaTheme='original'; 00101 } 00102 } else { 00103 $pmaTheme=$_COOKIE[$theme_cookie_name]; 00104 if (basename($PHP_SELF) == 'index.php') { 00105 setcookie($theme_cookie_name, $pmaTheme, time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); 00106 } 00107 } 00108 } // end if 00109 ?>