From 67c331f1acb2b2131be516480514fb0b3d78683a Mon Sep 17 00:00:00 2001 From: "Jehan-Guillaume (ioguix) de Rorthais" Date: Fri, 18 Oct 2013 17:38:45 +0200 Subject: [PATCH] Add dynamic theme based on current server, database or user used for the connection Based on Julien Rouhaud patch. --- browser.php | 6 +++++- classes/Misc.php | 6 +++++- conf/config.inc.php-dist | 12 ++++++++++++ libraries/lib.inc.php | 29 +++++++++++++++++++++++++++++ themes/cappuccino/global.css | 20 ++++++++++++++------ themes/default/global.css | 28 ++++++++++++++++++---------- themes/gotar/global.css | 7 ++++++- 7 files changed, 89 insertions(+), 19 deletions(-) diff --git a/browser.php b/browser.php index 09dd2d734..3b7a5480d 100644 --- a/browser.php +++ b/browser.php @@ -25,7 +25,11 @@ echo "
\n"; ?> - +
<?php echo $lang['strrefresh']; ?>
"; + echo "\n"; echo "", htmlspecialchars($appName); if ($title != '') echo htmlspecialchars(" - {$title}"); echo "\n"; diff --git a/conf/config.inc.php-dist b/conf/config.inc.php-dist index 4c6757450..ba927d406 100644 --- a/conf/config.inc.php-dist +++ b/conf/config.inc.php-dist @@ -71,6 +71,18 @@ /* Warning: Only groups with no parents appears at the root of the tree. */ + /* You can apply specific theme depending on servers, users and databases + * The priority order is : + * * the theme defined for a server + * * the theme defined for a database apply over the server one + * * the theme defined for a user apply over the database one + */ + /* Example for servers */ + //$conf['servers'][0]['theme']['default'] = 'default'; + /* Example for users */ + //$conf['servers'][0]['theme']['user']['specific_user'] = 'default'; + /* Example for databases */ + //$conf['servers'][0]['theme']['db']['specific_db'] = 'default'; // Default language. E.g.: 'english', 'polish', etc. See lang/ directory // for all possibilities. If you specify 'auto' (the default) it will use diff --git a/libraries/lib.inc.php b/libraries/lib.inc.php index f6964bcce..d0e327593 100644 --- a/libraries/lib.inc.php +++ b/libraries/lib.inc.php @@ -115,6 +115,35 @@ $conf['theme'] = $_COOKIE['ppaTheme']; } + // 4. Check for theme by server/db/user + $info = $misc->getServerInfo(); + + if (!is_null($info)) { + $_theme = ''; + + if ( (isset($info['theme']['default'])) + and is_file("./themes/{$info['theme']['default']}/global.css") + ) + $_theme = $info['theme']['default']; + + if ( isset($_REQUEST['database']) + and isset($info['theme']['db'][$_REQUEST['database']]) + and is_file("./themes/{$info['theme']['db'][$_REQUEST['database']]}/global.css") + ) + $_theme = $info['theme']['db'][$_REQUEST['database']]; + + if ( isset($info['username']) + and isset($info['theme']['user'][$info['username']]) + and is_file("./themes/{$info['theme']['user'][$info['username']]}/global.css") + ) + $_theme = $info['theme']['user'][$info['username']]; + + if ($_theme !== '') { + setcookie('ppaTheme', $_theme, time()+31536000); + $conf['theme'] = $_theme; + } + } + // Determine language file to import: unset($_language); diff --git a/themes/cappuccino/global.css b/themes/cappuccino/global.css index de6b77c1e..575a86001 100644 --- a/themes/cappuccino/global.css +++ b/themes/cappuccino/global.css @@ -19,12 +19,6 @@ body.browser { } body.browser > * { margin: 0 } body.browser div.webfx-tree-row:hover { background: #524a42} -div.logo { - margin: 0px; - padding: 0px; - border: none; - margin-bottom: 15px; -} h1 {font-size: 1.5em} h2 { color: #fff; @@ -187,3 +181,17 @@ div.fk { border-left: 1px dotted #000; padding: 5px; } +div.logo { + margin: 0px; + padding: 0px; + border: none; + margin-bottom: 15px; + background-image: url('../../images/themes/cappuccino/title.png'); + background-repeat: no-repeat; + height: 50px; +} +div.logo a { + display: block; + height: 100%; + color: transparent; +} diff --git a/themes/default/global.css b/themes/default/global.css index 8281ba780..3f1a79665 100644 --- a/themes/default/global.css +++ b/themes/default/global.css @@ -11,16 +11,6 @@ body { padding: 0px; font-size: smaller; /*0.8em;*/ } -div.logo { - background-color: #CECF9C; - margin: 0px; - padding: 0px; - font-family: arial, tahoma, verdana, helvetica, sans-serif, serif; - font-size: smaller; /* 1em; */ - border: none; - border-bottom: 2px solid #000000; - margin-bottom: 2px; -} body.browser { background-color: #efefef; font-family: arial, tahoma, verdana, helvetica, sans-serif, serif; @@ -256,3 +246,21 @@ div.fk { border-left: 1px solid #000; padding: 5px; } +div.logo { + background-color: #CECF9C; + margin: 0px; + padding: 0px; + font-family: arial, tahoma, verdana, helvetica, sans-serif, serif; + font-size: smaller; /* 1em; */ + border: none; + border-bottom: 2px solid #000000; + margin-bottom: 2px; + background-image: url('../../images/themes/default/title.png'); + background-repeat: none; + height: 50px; +} +div.logo a { + display: block; + height: 100%; + color: transparent; +} diff --git a/themes/gotar/global.css b/themes/gotar/global.css index f15c75a72..ec8532692 100644 --- a/themes/gotar/global.css +++ b/themes/gotar/global.css @@ -19,7 +19,6 @@ p { table { border:1px gray solid; } -div.logo { display:none } body.browser { background-color: #447; color:#4bf; @@ -251,3 +250,9 @@ div.fk { border-left: 1px solid #000; padding: 5px 0 5px 0; } +div.logo { display:none } +div.logo a { + display: block; + height: 100%; + color: transparent: +}