Factor out variable expanding.

This commit is contained in:
Michal Čihař
2010-07-21 09:30:31 +02:00
parent ce9e7a9462
commit 40aaa768dd
2 changed files with 26 additions and 19 deletions

View File

@@ -2827,4 +2827,29 @@ $mapping = array(
return $mapping[$target];
}
/**
* Formats user string, expading @VARIABLES@.
*/
function PMA_expandUserString($string) {
return str_replace(
array(
'@HTTP_HOST@',
'@SERVER@',
'@VERBOSE@',
'@VSERVER@',
'@DATABASE@',
'@TABLE@',
'@PHPMYADMIN@',
),
array(
PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '',
$GLOBALS['cfg']['Server']['host'],
$GLOBALS['cfg']['Server']['verbose'],
!empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host'],
$GLOBALS['db'],
$GLOBALS['table'],
'phpMyAdmin ' . PMA_VERSION,
),
$string);
}
?>

View File

@@ -21,25 +21,7 @@ if ( false === $GLOBALS['cfg']['AllowThirdPartyFraming']) {
<?php
}
// generate title
$title = str_replace(
array(
'@HTTP_HOST@',
'@SERVER@',
'@VERBOSE@',
'@VSERVER@',
'@DATABASE@',
'@TABLE@',
'@PHPMYADMIN@',
),
array(
PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '',
isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '',
isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '',
!empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''),
$GLOBALS['db'],
$GLOBALS['table'],
'phpMyAdmin ' . PMA_VERSION,
),
$title = PMA_expandUserString(
!empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] :
(!empty($GLOBALS['db']) ? $GLOBALS['cfg']['TitleDatabase'] :
(!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] :