Customizable window title (RFE #1408241).

This commit is contained in:
Michal Čihař
2006-02-22 11:20:57 +00:00
parent b105c6c0eb
commit 8b7b4ed53e
4 changed files with 46 additions and 27 deletions

View File

@@ -18,6 +18,8 @@ $Source$
Possibility to select SQL compatibility on import (RFE #1386132).
* main.php, lang/*: Better message for reloading privileges (RFE
#1420556).
* Documentation.html, libraries/config.default.php,
libraries/header.inc.php: Customizable window title (RFE #1408241).
2006-02-22 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* libraries/footer.inc.php:

View File

@@ -1623,14 +1623,24 @@ ALTER TABLE `pma_column_comments`
t1, t2, t10). Currently implemented in the left panel (Light mode)
and in Database view, for the table list.</dd>
<dt id="cfg_ShowHttpHostTitle">$cfg[ShowHttpHostTitle] boolean</dt>
<dd>Shows the <abbr title="HyperText Transfer Protocol">HTTP</abbr> host name
in window's title bar.</dd>
<dt id="cfg_SetHttpHostTitle">$cfg[SetHttpHostTitle] string</dt>
<dd>If <tt>$cfg['ShowHttpHostTitle']</tt> is <tt>TRUE</tt>, it shows the real
<abbr title="HyperText Transfer Protocol">HTTP</abbr> host name, unless
an alternate name is set here.</dd>
<dt id="cfg_TitleTable">$cfg[TitleTable] string</dt>
<dt id="cfg_TitleDatabase">$cfg[TitleDatabase] string</dt>
<dt id="cfg_TitleServer">$cfg[TitleServer] string</dt>
<dt id="cfg_TitleDefault">$cfg[TitleDefault] string</dt>
<dd>Allows you to specify window's title bar. Following magic string can
be used to get special values:
<dl>
<dt><code>@HTTP_HOST@</code></dt>
<dd>HTTP host that runs phpMyAdmin</dd>
<dt><code>@SERVER@</code></dt>
<dd>MySQL server name</dd>
<dt><code>@DATABASE@</code></dt>
<dd>Currently opened database</dd>
<dt><code>@TABLE@</code></dt>
<dd>Currently opened table</dd>
<dt><code>@PHPMYADMIN@</code></dt>
<dd>phpMyAdmin with version</dd>
</dl>
<dt id="cfg_ErrorIconic">$cfg[ErrorIconic] boolean</dt>
<dd>Uses icons for warnings, errors and informations.</dd>

View File

@@ -514,10 +514,11 @@ $cfg['NaturalOrder'] = TRUE; // Sort table and database in natura
// FIXME:
// 2004-05-08 rabus: We need to rearrange these variables.
$cfg['ShowHttpHostTitle'] = TRUE; // show HttpHost in browsers window title (true|false)?
$cfg['SetHttpHostTitle'] = ''; // if ShowHttpHostTitle=true, please set your host (server)
// or an other string, wich should be shown in browsers window title.
// If not set (or empty), the PMA will get your real Host-Adress.
// Window title settings
$cfg['TitleTable'] = '@HTTP_HOST@ / @SERVER@ / @DATABASE@ / @TABLE@ | @PHPMYADMIN@';
$cfg['TitleDatabase'] = '@HTTP_HOST@ / @SERVER@ / @DATABASE@ | @PHPMYADMIN@';
$cfg['TitleServer'] = '@HTTP_HOST@ / @SERVER@ | @PHPMYADMIN@';
$cfg['TitleDefault'] = '@HTTP_HOST@ | @PHPMYADMIN@';
$cfg['ErrorIconic'] = TRUE; // show some icons for warning, error and information messages (true|false)?
$cfg['MainPageIconic'] = TRUE; // show icons in list on main page and on menu tabs (true|false)?

View File

@@ -26,27 +26,33 @@ if (empty($GLOBALS['is_header_sent'])) {
require_once('./libraries/header_meta_style.inc.php');
// generate title
$title = '';
if ($cfg['ShowHttpHostTitle']) {
$title .= (empty($GLOBALS['cfg']['SetHttpHostTitle']) && isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $GLOBALS['cfg']['SetHttpHostTitle']) . ' / ';
}
if (!empty($GLOBALS['cfg']['Server']) && isset($GLOBALS['cfg']['Server']['host'])) {
$title.=str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['host']);
}
if (isset($GLOBALS['db'])) {
$title .= ' / ' . str_replace('\'', '\\\'', $GLOBALS['db']);
}
if (isset($GLOBALS['table'])) {
$title .= (empty($title) ? '' : ' ') . ' / ' . str_replace('\'', '\\\'', $GLOBALS['table']);
}
$title .= ' | phpMyAdmin ' . PMA_VERSION;
$title = str_replace(
array(
'@HTTP_HOST@',
'@SERVER@',
'@DATABASE@',
'@TABLE@',
'@PHPMYADMIN@',
),
array(
isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '',
isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '',
isset($GLOBALS['db']) ? $GLOBALS['db'] : '',
isset($GLOBALS['table']) ? $GLOBALS['table'] : '',
'phpMyAdmin ' . PMA_VERSION,
),
!empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] :
(!empty($GLOBALS['db']) ? $GLOBALS['cfg']['TitleDatabase'] :
(!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] :
$GLOBALS['cfg']['TitleDefault']))
);
?>
<script type="text/javascript" language="javascript">
<!--
// Updates the title of the frameset if possible (ns4 does not allow this)
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
&& typeof(parent.document.title) == 'string') {
parent.document.title = '<?php echo PMA_sanitize($title); ?>';
parent.document.title = '<?php echo PMA_sanitize(str_replace('\'', '\\\'', $title)); ?>';
}
<?php
// Add some javascript instructions if required