Skip to content

Commit

Permalink
Add dynamic theme based on current server, database or user used for …
Browse files Browse the repository at this point in the history
…the connection

Based on Julien Rouhaud patch.
  • Loading branch information
ioguix committed Nov 11, 2013
1 parent dfcf70e commit 67c331f
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 19 deletions.
6 changes: 5 additions & 1 deletion browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
echo "<div dir=\"ltr\">\n";
?>

<div class="logo"><a href="intro.php" target="detail"><img src="<?php echo $misc->icon('title') ?>" width="200" height="50" alt="<?php echo htmlspecialchars($appName) ?>" title="<?php echo htmlspecialchars($appName) ?>" /></a></div>
<div class="logo">
<a href="intro.php" target="detail">
<?php echo htmlspecialchars($appName) ?>
</a>
</div>
<div class="refreshTree"><a href="browser.php" target="browser" ><img src="<?php echo $misc->icon('Refresh'); ?>" alt="<?php echo $lang['strrefresh']; ?>" title="<?php echo $lang['strrefresh']; ?>" /></a></div>
<script type="text/javascript">

Expand Down
6 changes: 5 additions & 1 deletion classes/Misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,14 @@ function printHeader($title = '', $script = null, $frameset = false) {
echo "<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
// Theme
echo "<link rel=\"stylesheet\" href=\"themes/{$conf['theme']}/global.css\" type=\"text/css\" />\n";
echo "<link rel=\"stylesheet\" href=\"themes/{$conf['theme']}/global.css\" type=\"text/css\" id=\"csstheme\" />\n";
echo "<link rel=\"shortcut icon\" href=\"images/themes/{$conf['theme']}/Favicon.ico\" type=\"image/vnd.microsoft.icon\" />\n";
echo "<link rel=\"icon\" type=\"image/png\" href=\"images/themes/{$conf['theme']}/Introduction.png\" />\n";
echo "<script type=\"text/javascript\" src=\"libraries/js/jquery.js\"></script>";
echo "<script type=\"text/javascript\">// <!-- \n";
echo "$(document).ready(function() { \n";
echo " $('#csstheme', window.parent.frames[0].document).attr('href','themes/{$conf['theme']}/global.css');\n";
echo "}); // --></script>\n";
echo "<title>", htmlspecialchars($appName);
if ($title != '') echo htmlspecialchars(" - {$title}");
echo "</title>\n";
Expand Down
12 changes: 12 additions & 0 deletions conf/config.inc.php-dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions libraries/lib.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
20 changes: 14 additions & 6 deletions themes/cappuccino/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
28 changes: 18 additions & 10 deletions themes/default/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
7 changes: 6 additions & 1 deletion themes/gotar/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ p {
table {
border:1px gray solid;
}
div.logo { display:none }
body.browser {
background-color: #447;
color:#4bf;
Expand Down Expand Up @@ -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:
}

0 comments on commit 67c331f

Please sign in to comment.