/** * displays collapsable db list * * @uses $_REQUEST['dbgroup'] * @uses $GLOBALS['cfg']['DefaultTabDatabase'] * @uses $GLOBALS['strSelectADb'] * @uses strpos() * @uses urlencode() * @uses printf() * @uses htmlspecialchars() * @uses PMA_generate_common_url() * @uses PMA_getTableList() * @uses PMA_displayTableList() * @global $element_counter * @global $img_minus * @global $img_plus * @global $href_left * @global $db_start * @global $common_url_query * @param array $ext_dblist extended db list */ function PMA_displayDbList($ext_dblist) { global $element_counter, $img_minus, $img_plus, $href_left, $db_start, $common_url_query; // get table list, for all databases // doing this in one step takes advantage of a single query with information_schema! $tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->items); $url_dbgroup = ''; echo '<ul id="leftdatabaselist">'; $close_db_group = false; foreach ($ext_dblist as $group => $db_group) { if ($GLOBALS['PMA_List_Database']->count() > 1) { if ($close_db_group) { $url_dbgroup = ''; echo '</ul>'; echo '</li>'; $close_db_group = false; } if (count($db_group) > 1) { $close_db_group = true; $url_dbgroup = '&dbgroup=' . urlencode($group); $common_url_query = PMA_generate_common_url() . $url_dbgroup; $element_counter++; echo '<li class="dbgroup">'; if (!empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group || $db_start == $group || strpos($db_start, $group) === 0) { // display + only if this db(group) is not preselected printf($href_left, $element_counter, PMA_generate_common_url()); printf($img_minus, $element_counter); } else { printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } echo '</a> ' . $group . "\n"; if (!empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group || $db_start == $group || strpos($db_start, $group) === 0) { echo '<ul id="subel' . $element_counter . '">' . "\n"; } else { echo '<ul id="subel' . $element_counter . '"' . ' style="display: none">' . "\n"; } } } foreach ($db_group as $db) { $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup; $element_counter++; // Displays the database name echo '<li>' . "\n"; if ($GLOBALS['PMA_List_Database']->count() > 1) { // only with more than one db we need collapse ... if ($db_start != $db['name'] || $db['num_tables'] < 1) { // display + only if this db is not preselected // or table count is 0 printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } else { printf($href_left, $element_counter, PMA_generate_common_url() . $url_dbgroup); printf($img_minus, $element_counter); } echo '</a>'; // ... and we need to refresh both frames on db selection ?> <a class="item" id="<?php echo htmlspecialchars($db['name']); ?> " href="index.php?<?php echo $common_url_query; ?> " target="_parent" title="<?php echo htmlspecialchars($db['comment']); ?> " onclick=" if (! toggle('<?php echo $element_counter; ?> ', true)) window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?> '); window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?> ', 'main'); return false;"> <?php if ($GLOBALS['text_dir'] === 'rtl') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } echo htmlspecialchars($db['disp_name']); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } ?> </a> <?php } else { // with only 1 db available we dont need to refresh left frame // on db selection, only phpmain ?> <a href="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?> " id="<?php echo htmlspecialchars($db['name']); ?> " title="<?php echo htmlspecialchars($db['comment']); ?> "> <?php if ($GLOBALS['text_dir'] === 'rtl') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } echo htmlspecialchars($db['disp_name']); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } ?> </a> <?php } if ($db['num_tables']) { if (isset($tables_full[$db['name']])) { $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]); } elseif (isset($tables_full[strtolower($db['name'])])) { // on windows with lower_case_table_names = 1 // MySQL returns // with SHOW DATABASES or information_schema.SCHEMATA: `Test` // but information_schema.TABLES gives `test` // bug #1436171 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]); } else { $tables = PMA_getTableList($db['name']); } $child_visible = (bool) ($GLOBALS['PMA_List_Database']->count() === 1 || $db_start == $db['name']); PMA_displayTableList($tables, $child_visible, '', $db['name']); } elseif ($GLOBALS['cfg']['LeftFrameLight']) { // no tables and LeftFrameLight: // display message no tables in selected db echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n"; } echo '</li>' . "\n"; } // end foreach db } // end foreach group if ($close_db_group) { $url_dbgroup = ''; echo '</ul>'; echo '</li>'; $close_db_group = false; } echo '</ul>' . "\n"; }
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * DB search optimisation * * @package PhpMyAdmin */ require_once 'libraries/common.inc.php'; require_once 'libraries/common.lib.php'; $db = $_GET['db']; $table_term = $_GET['table']; $common_url_query = PMA_generate_common_url($GLOBALS['db']); $tables_full = PMA_getTableList($db); $tables_response = array(); foreach ($tables_full as $key => $table) { if (strpos($key, $table_term) !== false) { $link = '<li class="ajax_table"><a class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >'; $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name'])); if (PMA_Table::isView($table_db, $table['Name'])) { $link .= PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr); } else { $link .= PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr); } $link .= '</a>'; // link for the table name itself $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&pos=0'; $link .= '<a href="' . $href . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')') . '" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>'; $link .= '</li>' . "\n"; $table['line'] = $link; $tables_response[] = $table;
<?php if ($style == 'even') { $style = 'odd'; } else { $style = 'even'; } } unset($tmp_link); ?> </tbody> </table> <?php } $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; // Get list of tables $table_list = PMA_getTableList($GLOBALS['db']); // For each table try to get the tracking version foreach ($table_list as $key => $value) { // If $value is a table group. if (array_key_exists('is' . $sep . 'group', $value) && $value['is' . $sep . 'group']) { foreach ($value as $temp_table) { // If $temp_table is a table with the value for 'Name' is set, // rather than a propery of the table group. if (is_array($temp_table) && array_key_exists('Name', $temp_table)) { if (PMA_Tracker::getVersion($GLOBALS['db'], $temp_table['Name']) == -1) { $my_tables[] = $temp_table['Name']; } } } // If $value is a table. } else {
/** * displays collapsable db list * * @uses $_REQUEST['dbgroup'] * @uses $GLOBALS['cfg']['DefaultTabDatabase'] * @uses $GLOBALS['strSelectADb'] * @uses strpos() * @uses urlencode() * @uses printf() * @uses htmlspecialchars() * @uses PMA_generate_common_url() * @uses PMA_getTableList() * @uses PMA_displayTableList() * @global $element_counter * @global $img_minus * @global $img_plus * @global $href_left * @global $num_dbs * @global $db_start * @global $common_url_query * @param array $ext_dblist extended db list */ function PMA_displayDbList($ext_dblist) { global $element_counter, $img_minus, $img_plus, $href_left, $num_dbs, $db_start, $common_url_query; $url_dbgroup = ''; echo '<ul id="leftdatabaselist">'; $close_db_group = false; foreach ($ext_dblist as $group => $db_group) { if ($num_dbs > 1) { if ($close_db_group) { $url_dbgroup = ''; echo '</ul>'; echo '</li>'; $close_db_group = false; } if (count($db_group) > 1) { $close_db_group = true; $url_dbgroup = '&dbgroup=' . urlencode($group); $common_url_query = PMA_generate_common_url() . $url_dbgroup; $element_counter++; echo '<li class="dbgroup">'; if (!empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group || $db_start == $group || strpos($db_start, $group) === 0) { // display + only if this db(group) is not preselected printf($href_left, $element_counter, PMA_generate_common_url()); printf($img_minus, $element_counter); } else { printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } echo '</a> ' . $group . "\n"; if (!empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group || $db_start == $group || strpos($db_start, $group) === 0) { echo '<ul id="subel' . $element_counter . '">' . "\n"; } else { echo '<ul id="subel' . $element_counter . '"' . ' style="display: none">' . "\n"; } } } foreach ($db_group as $db) { $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup; $element_counter++; // Displays the database name echo '<li>' . "\n"; if ($num_dbs > 1) { // only with more than one db we need collapse ... if ($db_start != $db['name'] || $db['num_tables'] < 1) { // display + only if this db is not preselected // or table count is 0 printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } else { printf($href_left, $element_counter, PMA_generate_common_url() . $url_dbgroup); printf($img_minus, $element_counter); } echo '</a>'; // ... and we need to refresh both frames on db selection ?> <a class="item" id="<?php echo htmlspecialchars($db['name']); ?> " href="index.php?<?php echo $common_url_query; ?> " target="_parent" title="<?php echo htmlspecialchars($db['comment']); ?> " onclick=" if ( ! toggle('<?php echo $element_counter; ?> ', true) ) window.parent.goTo( './left.php?<?php echo $common_url_query; ?> ' ); window.parent.goTo( './<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?> ', 'main' ); return false;"> <?php if ($GLOBALS['text_dir'] === 'rtl') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } echo htmlspecialchars($db['disp_name']); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } ?> </a> <?php } else { // with only 1 db available we dont need to refresh left frame // on db selection, only phpmain ?> <a href="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?> " id="<?php echo htmlspecialchars($db['name']); ?> " title="<?php echo htmlspecialchars($db['comment']); ?> "> <?php if ($GLOBALS['text_dir'] === 'rtl') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } echo htmlspecialchars($db['disp_name']); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> '; } ?> </a> <?php } if ($db['num_tables']) { $tables = PMA_getTableList($db['name']); $child_visible = (bool) ($num_dbs === 1 || $db_start == $db['name']); PMA_displayTableList($tables, $child_visible, '', $db['name']); } elseif ($GLOBALS['cfg']['LeftFrameLight']) { // no tables and LeftFrameLight: // display message no tables in selected db echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n"; } echo '</li>' . "\n"; } // end foreach db } // end foreach group if ($close_db_group) { $url_dbgroup = ''; echo '</ul>'; echo '</li>'; $close_db_group = false; } echo '</ul>' . "\n"; }