0) {
if (!isset($stack[$key])) {
$stack[$key] = '';
}
PMA_multimerge($stack[$key], $table);
} else {
$stack['pma_name'][] = $table_item;
$stack['pma_list_item'][] = $list_item;
}
}
function PMA_reduceNest($_table) {
if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
$max = $GLOBALS['cfg']['LeftFrameTableLevel'];
$temp_table = $_table;
$new_table = array();
$last_index = 0;
for ($ti = 0; $ti <= $max; $ti++) {
if (isset($temp_table[$ti])) {
$new_table[$ti] = $temp_table[$ti];
unset($temp_table[$ti]);
$last_index = $ti;
}
}
$_table = $new_table;
}
return $_table;
}
function PMA_indent($spaces) {
$string = '';
for ($i = 0; $i <= $spaces; $i++) {
$string .= ' ';
}
return $string;
}
function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
$name = $key;
//$id = preg_replace('@[^a-z0-9]*@i', '', $baseid . $keyhistory . $key) . $indent;
$id = base64_encode($baseid . $keyhistory . $key) . $indent;
$groupkey = $keyhistory . ($key != $keyhistory ? $GLOBALS['cfg']['LeftFrameTableSeparator'] . $key : '');
$on_mouse = (($GLOBALS['cfg']['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
$countarray = $val;
if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
$counter = count($countarray['pma_name']);
} else {
unset($countarray['pma_name']);
if (count($countarray) > 1) {
unset($countarray['pma_list_item']);
}
$counter = count($countarray);
}
echo "\n";
echo PMA_indent($indent * 5) . '
' . "\n";
echo PMA_indent($indent * 6) . '
' . "\n";
echo PMA_indent($indent * 5) . '
' . "\n";
echo "\n";
if ($childout) {
echo PMA_indent($indent * 5) . '' . "\n";
}
}
function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
if ($firstGroup) {
PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
$indent++;
}
foreach ($tablestack AS $key => $val) {
if ($key != 'pma_name' && $key != 'pma_list_item') {
if ($headerOut) {
PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
}
if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
PMA_nestedSet($baseid, $val, $key, $keyhistory . ($keyhistory != '' ? $GLOBALS['cfg']['LeftFrameTableSeparator'] : '') . $key, false, ($indent + 1));
} else {
PMA_nestedSet($baseid, $val, $key, $keyhistory . ($keyhistory != '' ? $GLOBALS['cfg']['LeftFrameTableSeparator'] : '') . $key, true, ($indent + 1));
}
if ($headerOut) {
echo PMA_indent($indent * 5) . '
' . "\n";
}
}
}
if ($firstGroup && $firstGroupClose) {
echo PMA_indent($indent * 4) . '' . "\n";
} elseif ($firstGroup) {
echo PMA_indent($indent * 4) . '' . "\n";
}
}
function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
if ($keyhistory == '' && $key != '__protected__') {
$keyhistory = $key;
}
$indent_level = 9;
if (isset($tablestack)
&& isset($tablestack['pma_name'])
&& isset($tablestack['pma_list_item'])) {
if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
$divClose = true;
$extra_indent = 1;
} else {
PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
$divClose = false;
$extra_indent = 0;
}
$on_mouse = (($GLOBALS['cfg']['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
$loops = 0;
foreach ($tablestack['pma_name'] AS $tkey => $tval) {
echo PMA_indent($indent * 5) . ' ';
$items = explode("\n", $tablestack['pma_list_item'][$tkey]);
foreach ($items AS $ikey => $ival) {
echo "\n";
echo PMA_indent(($indent * 5)) . $ival;
}
echo "\n";
$loops++;
}
if ($divClose) {
echo PMA_indent($indent * 5) . '';
}
} elseif (is_array($tablestack)) {
PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut, (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
}
return true;
}
/**
* Get the list and number of available databases.
* Skipped if no server selected: in this case no database should be displayed
* before the user choose among available ones at the welcome screen.
*/
if ($server > 0) {
PMA_availableDatabases(); // this function is defined in "common.lib.php"
} else {
$num_dbs = 0;
}
// garvin: For re-usability, moved http-headers
// to a seperate file. It can now be included by header.inc.php,
// queryframe.php, querywindow.php.
require_once('./libraries/header_http.inc.php');
/**
* Displays the frame
*/
// Gets the font sizes to use
PMA_setFontSizes();
echo ""; // remove vertical scroll bar bug in ie
?>
phpMyAdmin
target="phpmain" />
1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
echo "\n";
?>
1)
else if ($num_dbs == 1) {
echo "\n";
?>
';
echo ' ';
echo ' ' . "\n";
}
echo ' ';
} // end of display logo
echo "\n";
if (!$cfg['QueryFrame']) {
echo "\n";
?>
1) {
// Light mode -> beginning of the select combo for databases
// Note: When javascript is active, the frameset will be changed from
// within left.php. With no JS () the whole frameset will
// be rebuilt with the new target frame.
if ($cfg['LeftFrameLight']) {
if (!$cfg['QueryFrame']) {
?>
' . "\n";
echo ' ' . $strDatabase . ': ';
echo ' ' . "\n";
echo ' (' . $strDatabases . ') ... ' . "\n";
} // end !$cfg['QueryFrame']
$table_list = '';
$table_list_header = '';
$db_name = '';
} // end FrameLight
$selected_db = 0;
// natural order for db list
if ($cfg['NaturalOrder'] && $num_dbs > 0) {
$dblist_temp = $dblist;
natsort($dblist_temp);
$i = 0;
foreach ($dblist_temp as $each) {
$dblist[$i] = $each;
$i++;
}
}
// Gets the tables list per database
for ($i = 0; $i < $num_dbs; $i++) {
$db = $dblist[$i];
$j = $i + 2;
if (!empty($db_start) && $db == $db_start) {
$selected_db = $j;
}
$tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db);
if ($num_tables) {
$num_tables_disp = $num_tables;
} else {
$num_tables_disp = '-';
}
// Get additional information about tables for tooltip
if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
&& $num_tables
&& (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
$tooltip = array();
$tooltip_name = array();
$result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
$tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
. '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
} // end while
} // end if
// garvin: Get comments from PMA comments table
$db_tooltip = '';
if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
$tmp_db_tooltip = PMA_getComments($db);
if (is_array($tmp_db_tooltip)) {
$db_tooltip = implode(' ', $tmp_db_tooltip);
}
}
// No light mode -> displays the expandible/collapsible db list
if ($cfg['LeftFrameLight'] == FALSE) {
// Displays the database name
$on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
echo "\n";
echo '
>
$table_sortkey) {
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
? htmlspecialchars($tooltip_name[$table])
: '';
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
? htmlspecialchars($tooltip[$table])
: '';
$table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
? $alias
: htmlspecialchars($table));
$tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
? $alias
: htmlspecialchars($table));
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
$list_item = '
';
$list_item .= ' ';
$list_item .= '
' . "\n";
$list_item .= '
';
$list_item .= $table_item . ' ' . "\n";
// garvin: Check whether to display nested sets
if (!empty($cfg['LeftFrameTableSeparator'])) {
$_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'', $tablename));
if (is_array($_table)) {
foreach ($_table AS $key => $val) {
if ($val == '') {
$_table[$key] = '__protected__';
}
}
$_table = PMA_reduceNest($_table);
if (count($_table) == 1) {
array_unshift($_table, '');
}
PMA_multimerge($tablestack, $_table);
} else {
$tablestack['']['pma_name'][] = $table_item;
$tablestack['']['pma_list_item'][] = $list_item;
}
} else {
$tablestack['']['pma_name'][] = $table_item;
$tablestack['']['pma_list_item'][] = $list_item;
}
} // end while (tables list)
PMA_nestedSet($j, $tablestack);
?>
displays the select combo with databases names and the
// list of tables contained in the current database
else {
echo "\n";
// Builds the databases' names list
if (!empty($db_start) && $db == $db_start) {
$table_title = array();
$table_array = array();
// Gets the list of tables from the current database
while (list($table) = PMA_DBI_fetch_row($tables)) {
$table_array[$table] = '';
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
? htmlspecialchars($tooltip[$table])
: '';
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
? htmlspecialchars($tooltip_name[$table])
: '';
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
// natural order or not, use an array for the table list
$table_array[$table] .= ' ' . "\n";
} else {
$table_array[$table] .= ' ' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . ' ' . "\n";
}
$table_title[$table] = htmlspecialchars($table);
} // end while (tables list)
if (count($table_title) > 0) {
if ($cfg['NaturalOrder'] && $num_tables > 0) {
natsort($table_title);
}
foreach ($table_title as $each_key => $each_val) {
$table_list .= ' ' . $table_array[$each_key];
}
} else {
$table_list = ' ' . "\n"
. ' ' . $strNoTablesFound . '
' . "\n";
}
$selected = ' selected="selected"';
$table_list_header .= ' ' . "\n";
$table_list_header .= ' ' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' ' . "\n\n";
} else {
$selected = '';
} // end if... else...
if (!$cfg['QueryFrame']) {
if (!empty($num_tables)) {
echo ' '
. ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ') ' . "\n";
} else {
echo ' '
. ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-) ' . "\n";
}
} // end !$cfg['QueryFrame']
} // end if (light mode)
} // end for $i (db list)
// Light mode -> end of the select combo for databases and table list for
// the current database
if ($cfg['LeftFrameLight']) {
if (!$cfg['QueryFrame']) {
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
}
if (!$table_list) {
$table_list = ' ' . $strSelectADb . '
' . "\n";
}
// Displays the current database name and the list of tables it
// contains
if (!$cfg['QueryFrame']) {
echo ' ';
}
echo $table_list_header;
echo $table_list;
}
// No light mode -> initialize some js variables for the
// expandible/collapsible stuff
else {
?>
1)
// Case where only one database has to be displayed
else if ($num_dbs == 1) {
$db = $dblist[0];
$tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db);
if ($num_tables) {
$num_tables_disp = $num_tables;
} else {
$num_tables_disp = '-';
}
// Get additional infomation about tables for tooltip
if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
&& $num_tables) {
$tooltip = array();
$tooltip_name = array();
$result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE);
while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
$tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
. '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
} // end while
} // end if
// garvin: Get comments from PMA comments table
$db_tooltip = '';
if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
$tmp_db_tooltip = PMA_getComments($db);
if (is_array($tmp_db_tooltip)) {
$db_tooltip = implode(' ', $tmp_db_tooltip);
}
}
// Displays the database name
if (!$cfg['LeftFrameLight']) {
$on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
echo "\n";
echo ' ';
if (!empty($num_tables)) {
echo "\n";
?>
>
$table_sortkey) {
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
? htmlspecialchars($tooltip_name[$table])
: '';
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
? htmlspecialchars($tooltip[$table])
: '';
$table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
? $alias
: htmlspecialchars($table));
$tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
? $alias
: htmlspecialchars($table));
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
if ($cfg['LeftFrameLight']) {
echo "\n";
?>
';
$list_item .= '
';
$list_item .= '
' . "\n";
$list_item .= '
';
$list_item .= $table_item . ' ';
// garvin: Check whether to display nested sets
if (!empty($cfg['LeftFrameTableSeparator'])) {
$_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'', $tablename));
if (is_array($_table)) {
foreach ($_table AS $key => $val) {
if ($val == '') {
$_table[$key] = '__protected__';
}
}
$_table = PMA_reduceNest($_table);
if (count($_table) == 1) {
array_unshift($_table, '');
}
PMA_multimerge($tablestack, $_table);
} else {
$tablestack['']['pma_name'][] = $table_item;
$tablestack['']['pma_list_item'][] = $list_item;
}
} else {
$tablestack['']['pma_name'][] = $table_item;
$tablestack['']['pma_list_item'][] = $list_item;
}
}
} // end for $j (tables list)
if (!$cfg['LeftFrameLight']) {
PMA_nestedSet('1', $tablestack);
?>
';
}
echo "\n";
} // end if ($num_dbs == 1)
// Case where no database has to be displayed
else {
echo "\n";
echo '
' . $strNoDatabases . '
';
} // end if ($num_dbs == 0)
echo "\n";
// 2004-08-05 added by Michael Keck
// reload queryframe if it exists and we delete a database
// or select a database from the db_list.
$my_lightm_db = '';
if (isset($lightm_db) && $lightm_db!='') {
$my_lightm_db = $lightm_db;
}
if ($cfg['LeftFrameLight'] && $cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
if (!isset($table_array) || count($table_array)==0) {
$my_url_query = PMA_generate_common_url('', '', '&');
?>