/** * display unordered list of tables * calls itself recursively if table in given list * is a list itself * * @uses is_array() * @uses count() * @uses urlencode() * @uses strpos() * @uses printf() * @uses htmlspecialchars() * @uses strlen() * @uses is_array() * @uses PMA_displayTableList() * @uses $_REQUEST['tbl_group'] * @uses $GLOBALS['common_url_query'] * @uses $GLOBALS['table'] * @uses $GLOBALS['pmaThemeImage'] * @uses $GLOBALS['cfg']['LeftFrameTableSeparator'] * @uses $GLOBALS['cfg']['DefaultTabDatabase'] * @uses $GLOBALS['cfg']['DefaultTabTable'] * @uses $GLOBALS['strRows'] * @uses $GLOBALS['strBrowse'] * @global integer the element counter * @global string html code for '-' image * @global string html code for '+' image * @global string html code for self link * @param array $tables array of tables/tablegroups * @param boolean $visible wether the list is visible or not * @param string $tab_group_full full tab group name * @param string $table_db db of this table */ function PMA_displayTableList($tables, $visible = false, $tab_group_full = '', $table_db = '') { if (!is_array($tables) || count($tables) === 0) { return; } global $element_counter, $img_minus, $img_plus, $href_left; $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; if ($visible) { echo '<ul id="subel' . $element_counter . '">'; } else { echo '<ul id="subel' . $element_counter . '" style="display: none">'; } foreach ($tables as $group => $table) { if (isset($table['is' . $sep . 'group'])) { $common_url_query = $GLOBALS['common_url_query'] . '&tbl_group=' . urlencode($tab_group_full . $group); $element_counter++; echo '<li>' . "\n"; if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || isset($GLOBALS['table']) && strpos($GLOBALS['table'], $group) === 0)) { printf($href_left, $element_counter, $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full); printf($img_minus, $element_counter); } else { printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } echo '</a>'; ?> <a href="index.php?<?php echo $common_url_query; ?> " target="_parent" 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">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep))); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } ?> </a> <?php unset($table['is' . $sep . 'group']); unset($table['tab' . $sep . 'group']); unset($table['tab' . $sep . 'count']); if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || isset($GLOBALS['table']) && strpos($GLOBALS['table'], $group) === 0)) { PMA_displayTableList($table, true, $tab_group_full . $group, $table_db); } else { PMA_displayTableList($table, false, '', $table_db); } echo '</li>' . "\n"; } elseif (is_array($table)) { $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&table=' . urlencode($table['Name']); echo '<li>' . "\n"; echo '<a title="' . $GLOBALS['strBrowse'] . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"' . ' id="browse_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="sql.php?' . $GLOBALS['common_url_query'] . '&table=' . urlencode($table['Name']) . '&goto=' . $GLOBALS['cfg']['DefaultTabTable'] . '" >' . '<img class="icon"'; if ('VIEW' === strtoupper($table['Comment'])) { echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"'; } else { echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"'; } echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' width="10" height="10" alt="' . $GLOBALS['strBrowse'] . '" /></a>' . "\n" . '<a href="' . $href . '" title="' . htmlspecialchars($table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"' . ' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . htmlspecialchars($table['disp_name']) . '</a>'; echo '</li>' . "\n"; } } echo '</ul>'; }
/** * display unordered list of tables * calls itself recursively if table in given list * is a list itself * * @param array $tables array of tables/tablegroups * @param boolean $visible whether the list is visible or not * @param string $tab_group_full full tab group name * @param string $table_db db of this table * * @return void * * @global integer the element counter * @global string html code for '-' image * @global string html code for '+' image * @global string html code for self link */ function PMA_displayTableList( $tables, $visible = false, $tab_group_full = '', $table_db = '' ) { if (! is_array($tables) || count($tables) === 0) { return; } global $element_counter, $img_minus, $img_plus, $href_left; $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; if ($visible) { echo '<ul id="subel' . $element_counter . '">'; } else { echo '<ul id="subel' . $element_counter . '" style="display: none">'; } foreach ($tables as $group => $table) { // only allow grouping if the group has more than 1 table if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1 ) { $common_url_query = $GLOBALS['common_url_query'] . '&tbl_group=' . urlencode($tab_group_full . $group); $element_counter++; echo '<li>' . "\n"; if ($visible && ((isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) || strpos($GLOBALS['table'], $group) === 0) ) { printf( $href_left, $element_counter, $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full ); printf($img_minus, $element_counter); } else { printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } echo '</a>'; ?> <a href="index.php?<?php echo $common_url_query; ?>" target="_parent" 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">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep))); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } ?> </a> <?php unset($table['is' . $sep . 'group']); unset($table['tab' . $sep . 'group']); unset($table['tab' . $sep . 'count']); if ($visible && ((isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) || strpos($GLOBALS['table'], $group) === 0) ) { PMA_displayTableList( $table, true, $tab_group_full . $group, $table_db ); } else { PMA_displayTableList($table, false, '', $table_db); } echo '</li>' . "\n"; } elseif (is_array($table)) { // the table was not grouped because it is the only one with its prefix while (isset($table['is' . $sep . 'group'])) { // get the array with the actual table information foreach ($table as $value) { if (is_array($value)) { $table = $value; } } } $link_title = PMA_Util::getTitleForTarget( $GLOBALS['cfg']['LeftDefaultTabTable'] ); // quick access icon next to each table name echo '<li>' . "\n"; echo '<a target="frame_content" class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) .' (' . PMA_Util::formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $GLOBALS['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'])) { echo PMA_Util::getImage( 's_views.png', htmlspecialchars($link_title), $attr ); } else { echo PMA_Util::getImage( 'b_browse.png', htmlspecialchars($link_title), $attr ); } echo '</a>'; // link for the table name itself $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' .$GLOBALS['common_url_query'] . '&table=' .urlencode($table['Name']) . '&pos=0'; echo '<a target="frame_content" href="' . $href . '" title="' . htmlspecialchars( PMA_Util::getTitleForTarget( $GLOBALS['cfg']['DefaultTabTable'] ) . ': ' . $table['Comment'] .' (' . PMA_Util::formatNumber( $table['Rows'], 0 ) . ' ' . __('Rows') . ')' ) .'" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' // preserve spaces in table name . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>'; echo '</li>' . "\n"; } } echo '</ul>'; }