fixed bug #1469174 configuration changes not accepted in theme manager
This commit is contained in:
@@ -6,6 +6,8 @@ $Id$
|
|||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
2006-04-12 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2006-04-12 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
|
* libraries\common.lib.php, libraries\Theme_Manager.class.php:
|
||||||
|
fixed bug #1469174 configuration changes not accepted in theme manager
|
||||||
* libraries\Theme_Manager.class.php:
|
* libraries\Theme_Manager.class.php:
|
||||||
fixed bug #1469120 missing property in Theme_Manager class
|
fixed bug #1469120 missing property in Theme_Manager class
|
||||||
* libraries\common.lib.php:
|
* libraries\common.lib.php:
|
||||||
|
@@ -8,8 +8,9 @@ class PMA_Theme_Manager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string path to theme folder
|
* @var string path to theme folder
|
||||||
|
* @protected
|
||||||
*/
|
*/
|
||||||
var $themes_path;
|
var $_themes_path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array available themes
|
* @var array available themes
|
||||||
@@ -43,15 +44,60 @@ class PMA_Theme_Manager {
|
|||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->themes_path = trim($GLOBALS['cfg']['ThemePath']) ;
|
$this->init();
|
||||||
$this->per_server = (bool) $GLOBALS['cfg']['ThemePerServer'];
|
}
|
||||||
$this->theme = new PMA_Theme;
|
|
||||||
|
|
||||||
if ( ! $this->_checkThemeFolder($this->themes_path)) {
|
/**
|
||||||
return;
|
* sets path to folder containing the themes
|
||||||
|
*
|
||||||
|
* @param string $path path to themes folder
|
||||||
|
* @return boolean success
|
||||||
|
*/
|
||||||
|
function setThemesPath($path)
|
||||||
|
{
|
||||||
|
if (! $this->_checkThemeFolder($path)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->loadThemes($this->themes_path);
|
$this->_themes_path = trim($path);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getThemesPath()
|
||||||
|
{
|
||||||
|
return $this->_themes_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets if there are different themes per server
|
||||||
|
*
|
||||||
|
* @param boolean $per_server
|
||||||
|
*/
|
||||||
|
function setThemePerServer($per_server)
|
||||||
|
{
|
||||||
|
$this->per_server = (bool) $per_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
function init()
|
||||||
|
{
|
||||||
|
$this->themes = array();
|
||||||
|
$this->theme_default = 'original';
|
||||||
|
$this->active_theme = '';
|
||||||
|
|
||||||
|
if (! $this->setThemesPath($GLOBALS['cfg']['ThemePath'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setThemePerServer($GLOBALS['cfg']['ThemePerServer']);
|
||||||
|
|
||||||
|
$this->loadThemes();
|
||||||
|
|
||||||
|
$this->theme = new PMA_Theme;
|
||||||
|
|
||||||
|
|
||||||
if ( ! $this->checkTheme($GLOBALS['cfg']['ThemeDefault'])) {
|
if ( ! $this->checkTheme($GLOBALS['cfg']['ThemeDefault'])) {
|
||||||
$GLOBALS['PMA_errors'][] = sprintf( $GLOBALS['strThemeDefaultNotFound'],
|
$GLOBALS['PMA_errors'][] = sprintf( $GLOBALS['strThemeDefaultNotFound'],
|
||||||
@@ -67,18 +113,23 @@ class PMA_Theme_Manager {
|
|||||||
|
|
||||||
// check if user have a theme cookie
|
// check if user have a theme cookie
|
||||||
if (! $this->getThemeCookie()
|
if (! $this->getThemeCookie()
|
||||||
|| ! $this->setActiveTheme($this->getThemeCookie())) {
|
|| ! $this->setActiveTheme($this->getThemeCookie())) {
|
||||||
|
// otherwise use default theme
|
||||||
if ($GLOBALS['cfg']['ThemeDefault']) {
|
if ($GLOBALS['cfg']['ThemeDefault']) {
|
||||||
$this->setActiveTheme($GLOBALS['cfg']['ThemeDefault']);
|
$this->setActiveTheme($GLOBALS['cfg']['ThemeDefault']);
|
||||||
} else {
|
} else {
|
||||||
|
// or original theme
|
||||||
$this->setActiveTheme('original');
|
$this->setActiveTheme('original');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wakeup()
|
function checkConfig()
|
||||||
{
|
{
|
||||||
$this->loadThemes($this->themes_path);
|
if ($this->_themes_path != trim($GLOBALS['cfg']['ThemePath'])
|
||||||
|
|| $this->theme_default != $GLOBALS['cfg']['ThemeDefault']) {
|
||||||
|
$this->init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActiveTheme($theme = null)
|
function setActiveTheme($theme = null)
|
||||||
@@ -174,35 +225,34 @@ class PMA_Theme_Manager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* read all themes
|
* read all themes
|
||||||
*
|
|
||||||
* @param string $folder themes folders
|
|
||||||
*/
|
*/
|
||||||
function loadThemes($folder)
|
function loadThemes()
|
||||||
{
|
{
|
||||||
if ($handleThemes = opendir($folder)) {
|
$this->themes = array();
|
||||||
|
|
||||||
|
if ($handleThemes = opendir($this->getThemesPath())) {
|
||||||
// check for themes directory
|
// check for themes directory
|
||||||
while (FALSE !== ($PMA_Theme = readdir($handleThemes))) {
|
while (false !== ($PMA_Theme = readdir($handleThemes))) {
|
||||||
if (array_key_exists($PMA_Theme, $this->themes)) {
|
if (array_key_exists($PMA_Theme, $this->themes)) {
|
||||||
$new_themes[$PMA_Theme] = $this->themes[$PMA_Theme];
|
$this->themes[$PMA_Theme] = $this->themes[$PMA_Theme];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$new_theme = PMA_Theme::load($folder . '/' . $PMA_Theme);
|
$new_theme = PMA_Theme::load($this->getThemesPath() . '/' . $PMA_Theme);
|
||||||
if ($new_theme) {
|
if ($new_theme) {
|
||||||
$new_theme->setId($PMA_Theme);
|
$new_theme->setId($PMA_Theme);
|
||||||
$new_themes[$PMA_Theme] = $new_theme;
|
$this->themes[$PMA_Theme] = $new_theme;
|
||||||
}
|
}
|
||||||
} // end get themes
|
} // end get themes
|
||||||
closedir($handleThemes);
|
closedir($handleThemes);
|
||||||
} else {
|
} else {
|
||||||
trigger_error(
|
trigger_error(
|
||||||
'phpMyAdmin-ERROR: can not open themes folder: ' . $folder,
|
'phpMyAdmin-ERROR: can not open themes folder: ' . $this->getThemesPath(),
|
||||||
E_USER_WARNING);
|
E_USER_WARNING);
|
||||||
return false;
|
return false;
|
||||||
} // end check for themes directory
|
} // end check for themes directory
|
||||||
|
|
||||||
$this->themes = $new_themes;
|
|
||||||
|
|
||||||
ksort($this->themes);
|
ksort($this->themes);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user