home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / xampp-win32-1.6.5-installer.exe / phpMyAdmin / navigation.php < prev    next >
Encoding:
PHP Script  |  2007-12-20  |  24.1 KB  |  619 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * the navigation frame - displays server, db and table selection tree
  5.  *
  6.  * @version $Id: navigation.php 10533 2007-07-27 11:58:41Z lem9 $
  7.  * @uses $GLOBALS['PMA_List_Database']
  8.  * @uses $GLOBALS['server']
  9.  * @uses $GLOBALS['db']
  10.  * @uses $GLOBALS['table']
  11.  * @uses $GLOBALS['available_languages']
  12.  * @uses $GLOBALS['lang']
  13.  * @uses $GLOBALS['text_dir']
  14.  * @uses $GLOBALS['charset']
  15.  * @uses $GLOBALS['pmaThemeImage']
  16.  * @uses $GLOBALS['strNoDatabases']
  17.  * @uses $GLOBALS['strDatabase']
  18.  * @uses $GLOBALS['strGo']
  19.  * @uses $GLOBALS['strSelectADb']
  20.  * @uses $GLOBALS['strNoTablesFound']
  21.  * @uses $GLOBALS['cfg']['LeftFrameLight']
  22.  * @uses $GLOBALS['cfg']['ShowTooltip']
  23.  * @uses $GLOBALS['cfg']['ShowTooltipAliasDB']
  24.  * @uses $GLOBALS['cfg']['DefaultTabDatabase']
  25.  * @uses $GLOBALS['cfgRelation']['commwork']) {
  26.  * @uses PMA_List_Database::getSingleItem()
  27.  * @uses PMA_List_Database::count()
  28.  * @uses PMA_List_Database::getHtmlSelectGrouped()
  29.  * @uses PMA_List_Database::getGroupedDetails()
  30.  * @uses PMA_generate_common_url()
  31.  * @uses PMA_generate_common_hidden_inputs()
  32.  * @uses PMA_getComments();
  33.  * @uses PMA_getTableCount()
  34.  * @uses PMA_getTableList()
  35.  * @uses PMA_getRelationsParam()
  36.  * @uses PMA_outBufferPre()
  37.  * @uses session_write_close()
  38.  * @uses strlen()
  39.  * @uses session_write_close()
  40.  * @uses is_array()
  41.  * @uses implode()
  42.  * @uses htmlspecialchars()
  43.  */
  44.  
  45. /**
  46.  * Gets a core script and starts output buffering work
  47.  */
  48. require_once './libraries/common.inc.php';
  49.  
  50. /**
  51.  * finish and cleanup navigation.php script execution
  52.  *
  53.  * @uses $GLOBALS['controllink'] to close it
  54.  * @uses $GLOBALS['userlink'] to close it
  55.  * @uses PMA_DBI_close()
  56.  * @access private only to be used in navigation.php
  57.  */
  58. function PMA_exitNavigationFrame()
  59. {
  60.     echo '</body></html>';
  61.  
  62.     /**
  63.      * Close MySQL connections
  64.      */
  65.     if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) {
  66.         @PMA_DBI_close($GLOBALS['controllink']);
  67.     }
  68.     if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
  69.         @PMA_DBI_close($GLOBALS['userlink']);
  70.     }
  71.  
  72.     exit;
  73. }
  74.  
  75. // keep the offset of the db list in session before closing it
  76. if (! isset($_SESSION['navi_limit_offset'])) {
  77.     $_SESSION['navi_limit_offset'] = 0;
  78. }
  79. if (isset($_REQUEST['pos'])) {
  80.     $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos'];
  81. }
  82. $pos = $_SESSION['navi_limit_offset']; 
  83.  
  84. // free the session file, for the other frames to be loaded
  85. session_write_close();
  86.  
  87. /**
  88.  * the output compression library
  89.  */
  90. require_once './libraries/ob.lib.php';
  91.  
  92. PMA_outBufferPre();
  93.  
  94. /*
  95.  * selects the database if there is only one on current server
  96.  */
  97. if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
  98.     $GLOBALS['db'] = $GLOBALS['PMA_List_Database']->getSingleItem();
  99. }
  100.  
  101. $db_start = $GLOBALS['db'];
  102.  
  103. /**
  104.  * the relation library
  105.  */
  106. require_once './libraries/relation.lib.php';
  107. $cfgRelation = PMA_getRelationsParam();
  108.  
  109. /**
  110.  * garvin: For re-usability, moved http-headers to a seperate file.
  111.  * It can now be included by libraries/header.inc.php, querywindow.php.
  112.  */
  113. require_once './libraries/header_http.inc.php';
  114.  
  115. if (! isset($_SESSION['navi_limit_offset'])) {
  116.     $_SESSION['navi_limit_offset'] = 0;
  117. }
  118. if (isset($_REQUEST['pos'])) {
  119.     $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos'];
  120. }
  121. $pos = $_SESSION['navi_limit_offset']; 
  122.  
  123. /*
  124.  * Displays the frame
  125.  */
  126. // xml declaration moves IE into quirks mode, making much trouble with CSS
  127. /* echo '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?>'; */
  128. ?>
  129. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  130.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  131. <html xmlns="http://www.w3.org/1999/xhtml"
  132.     xml:lang="<?php echo $available_languages[$lang][2]; ?>"
  133.     lang="<?php echo $available_languages[$lang][2]; ?>"
  134.     dir="<?php echo $GLOBALS['text_dir']; ?>">
  135.  
  136. <head>
  137.     <link rel="icon" href="./favicon.ico" type="image/x-icon" />
  138.     <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
  139.     <title>phpMyAdmin</title>
  140.     <meta http-equiv="Content-Type"
  141.         content="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
  142.     <base target="frame_content" />
  143.     <link rel="stylesheet" type="text/css"
  144.         href="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $_SESSION['PMA_Config']->getMtime(); ?>" />
  145.     <script type="text/javascript" src="js/navigation.js"></script>
  146.     <script type="text/javascript" src="js/functions.js"></script>
  147.     <script type="text/javascript">
  148.     // <![CDATA[
  149.     var image_minus = '<?php echo $GLOBALS['pmaThemeImage']; ?>b_minus.png';
  150.     var image_plus = '<?php echo $GLOBALS['pmaThemeImage']; ?>b_plus.png';
  151.     // ]]>
  152.     </script>
  153.     <?php
  154.     /*
  155.      * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
  156.      */
  157.     ?>
  158.     <!--[if IE 6]>
  159.     <style type="text/css">
  160.     /* <![CDATA[ */
  161.     html {
  162.         overflow-y: scroll;
  163.     }
  164.     /* ]]> */
  165.     </style>
  166.     <![endif]-->
  167. </head>
  168.  
  169. <body id="body_leftFrame" onload="PMA_setFrameSize();" onresize="PMA_saveFrameSize();">
  170. <?php
  171. require './libraries/navigation_header.inc.php';
  172. if (! $GLOBALS['server']) {
  173.     // no server selected
  174.     PMA_exitNavigationFrame();
  175. } elseif (! $GLOBALS['PMA_List_Database']->count()) {
  176.     // no database available, so we break here
  177.     echo '<p>' . $GLOBALS['strNoDatabases'] . '</p>';
  178.     PMA_exitNavigationFrame();
  179. } elseif ($GLOBALS['cfg']['LeftFrameLight'] && $GLOBALS['PMA_List_Database']->count() > 1) {
  180.     $list = $cfg['DisplayDatabasesList'];
  181.     if ($list === 'auto') {
  182.         if (empty($GLOBALS['db'])) {
  183.             $list = true;
  184.         } else {
  185.             $list = false;
  186.         }
  187.     }
  188.     if (!$list) {
  189.         // more than one database available and LeftFrameLight is true
  190.         // display db selectbox
  191.         //
  192.         // Light mode -> beginning of the select combo for databases
  193.         // Note: When javascript is active, the frameset will be changed from
  194.         // within navigation.php. With no JS (<noscript>) the whole frameset will
  195.         // be rebuilt with the new target frame.
  196.     ?>
  197.  
  198.     <div id="databaseList">
  199.     <form method="post" action="index.php" target="_parent" id="left">
  200.     <label for="lightm_db"><?php echo $GLOBALS['strDatabase']; ?></label>
  201.     <?php
  202.         echo PMA_generate_common_hidden_inputs() . "\n";
  203.         echo $GLOBALS['PMA_List_Database']->getHtmlSelectGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
  204.         echo '<noscript>' . "\n"
  205.             .'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
  206.             .'</noscript>' . "\n"
  207.             .'</form>' . "\n";
  208.     } else {
  209.         if (! empty($db)) {
  210.             echo '<div id="databaseList">' . "\n";
  211.         }
  212.         echo $GLOBALS['PMA_List_Database']->getHtmlListGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
  213.     }
  214.     $_url_params = array('pos' => $pos);
  215.     PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
  216.     if (! empty($db)) {
  217.         echo '</div>' . "\n";
  218.     }
  219. }
  220. ?>
  221.  
  222. <div id="left_tableList">
  223. <?php
  224. // Don't display expansible/collapsible database info if:
  225. // 1. $GLOBALS['server'] == 0 (no server selected)
  226. //    This is the case when there are multiple servers and
  227. //    '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
  228. //    screen to appear with no database info displayed.
  229. // 2. there is only one database available (ie either only one database exists
  230. //    or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
  231. //    In this case, the database should not be collapsible/expandable
  232.  
  233. $img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"'
  234.     .' width="9" height="9" alt="+" />';
  235. $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
  236.     .' width="9" height="9" alt="-" />';
  237.  
  238. $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
  239.     .' href="navigation.php?%s" target="_self">';
  240.  
  241. $element_counter = 0;
  242.  
  243. if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
  244.     // show selected databasename as link to DefaultTabDatabase-page
  245.     // with table count in ()
  246.     $common_url_query = PMA_generate_common_url($GLOBALS['db']);
  247.  
  248.     $db_tooltip = '';
  249.  
  250.     if ($GLOBALS['cfg']['ShowTooltip']
  251.       && $GLOBALS['cfgRelation']['commwork']) {
  252.         $_db_tooltip = PMA_getComments($GLOBALS['db']);
  253.         if (is_array($_db_tooltip)) {
  254.             $db_tooltip = implode(' ', $_db_tooltip);
  255.         }
  256.     }
  257.  
  258.     $disp_name  = $GLOBALS['db'];
  259.     if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
  260.         $disp_name      = $db_tooltip;
  261.         $disp_name_cut  = $db_tooltip;
  262.         $db_tooltip     = $GLOBALS['db'];
  263.     }
  264.  
  265.     ?>
  266.     <p><a class="item"
  267.         href="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?>"
  268.         title="<?php echo htmlspecialchars($db_tooltip); ?>" >
  269.     <?php
  270.     if ($GLOBALS['text_dir'] === 'rtl') {
  271.         echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
  272.     }
  273.     echo '<span class="navi_dbName">' . htmlspecialchars($disp_name) . '</span>';
  274.     if ($GLOBALS['text_dir'] === 'ltr') {
  275.         echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
  276.     }
  277.     echo '</a></p>';
  278.  
  279.     /**
  280.      * This helps reducing the navi panel size; in the right panel,
  281.      * user can find a navigator to page thru all tables.
  282.      *
  283.      * @todo instead of the 0 parameter, keep track of the
  284.      *       offset in the list of tables ($_SESSION['navi_table_limit_offset'])
  285.      *       and use PMA_listNavigator(); do not just check pos in REQUEST
  286.      *       but add another hidden param to see if it's the pos of databases
  287.      *       or the pos of tables. 
  288.      */
  289.     $table_list = PMA_getTableList($GLOBALS['db'], null, 0, $cfg['MaxTableList']);
  290.     if (! empty($table_list)) {
  291.         PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
  292.         // hint user that the table list is larger, until the todo is done
  293.         if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && PMA_getTableCount($GLOBALS['db']) > $GLOBALS['cfg']['MaxTableList']) {
  294.             echo '  ( 1 .. ', $GLOBALS['cfg']['MaxTableList'], ' / ', PMA_getTableCount($GLOBALS['db']), ' )'; 
  295.         } 
  296.     } else {
  297.         echo $GLOBALS['strNoTablesFound'];
  298.     }
  299.     unset($table_list);
  300. } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
  301.     echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
  302. } else {
  303.     echo '<div id="databaseList">' . "\n";
  304.     $_url_params = array('pos' => $pos);
  305.     PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
  306.     echo '</div>' . "\n";
  307.  
  308.     $common_url_query = PMA_generate_common_url();
  309.     PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails($_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
  310. }
  311.  
  312. /**
  313.  * displays collapsable db list
  314.  *
  315.  * @uses    $_REQUEST['dbgroup']
  316.  * @uses    $GLOBALS['cfg']['DefaultTabDatabase']
  317.  * @uses    $GLOBALS['strSelectADb']
  318.  * @uses    strpos()
  319.  * @uses    urlencode()
  320.  * @uses    printf()
  321.  * @uses    htmlspecialchars()
  322.  * @uses    PMA_generate_common_url()
  323.  * @uses    PMA_getTableList()
  324.  * @uses    PMA_displayTableList()
  325.  * @global  $element_counter
  326.  * @global  $img_minus
  327.  * @global  $img_plus
  328.  * @global  $href_left
  329.  * @global  $db_start
  330.  * @global  $common_url_query
  331.  * @param   array   $ext_dblist extended db list
  332.  * @param   integer $offset
  333.  * @param   integer $count
  334.  */
  335. function PMA_displayDbList($ext_dblist, $offset, $count) {
  336.     global $element_counter, $img_minus, $img_plus, $href_left,
  337.         $db_start, $common_url_query;
  338.  
  339.     // get table list, for all databases
  340.     // doing this in one step takes advantage of a single query with information_schema!
  341.     $tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->getLimitedItems($offset, $count));
  342.  
  343.     $url_dbgroup = '';
  344.     echo '<ul id="leftdatabaselist">';
  345.     $close_db_group = false;
  346.     foreach ($ext_dblist as $group => $db_group) {
  347.         if ($GLOBALS['PMA_List_Database']->count() > 1) {
  348.             if ($close_db_group) {
  349.                 $url_dbgroup = '';
  350.                 echo '</ul>';
  351.                 echo '</li>';
  352.                 $close_db_group = false;
  353.             }
  354.             if (count($db_group) > 1) {
  355.                 $close_db_group = true;
  356.                 $url_dbgroup = '&dbgroup=' . urlencode($group);
  357.                 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
  358.                 $element_counter++;
  359.                 echo '<li class="dbgroup">';
  360.                 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
  361.                   || $db_start == $group || strpos($db_start, $group) === 0) {
  362.                     // display + only if this db(group) is not preselected
  363.                     printf($href_left, $element_counter, PMA_generate_common_url());
  364.                     printf($img_minus, $element_counter);
  365.                 } else {
  366.                     printf($href_left, $element_counter, $common_url_query);
  367.                     printf($img_plus, $element_counter);
  368.                 }
  369.                 echo '</a> ' . $group . "\n";
  370.                 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
  371.                   || $db_start == $group || strpos($db_start, $group) === 0) {
  372.                     echo '<ul id="subel' . $element_counter . '">' . "\n";
  373.                 } else {
  374.                     echo '<ul id="subel' . $element_counter . '"'
  375.                         .' style="display: none">' . "\n";
  376.                 }
  377.             }
  378.         }
  379.         foreach ($db_group as $db) {
  380.             $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
  381.  
  382.             $element_counter++;
  383.             // Displays the database name
  384.             echo '<li>' . "\n";
  385.  
  386.             if ($GLOBALS['PMA_List_Database']->count() > 1) {
  387.                 // only with more than one db we need collapse ...
  388.                 if ($db_start != $db['name'] || $db['num_tables'] < 1) {
  389.                     // display + only if this db is not preselected
  390.                     // or table count is 0
  391.                     printf($href_left, $element_counter, $common_url_query);
  392.                     printf($img_plus, $element_counter);
  393.                 } else {
  394.                     printf($href_left, $element_counter,
  395.                         PMA_generate_common_url() . $url_dbgroup);
  396.                     printf($img_minus, $element_counter);
  397.                 }
  398.                 echo '</a>';
  399.  
  400.                 // ... and we need to refresh both frames on db selection
  401.                 ?>
  402.                 <a class="item"
  403.                     id="<?php echo htmlspecialchars($db['name']); ?>"
  404.                     href="index.php?<?php echo $common_url_query; ?>"
  405.                     target="_parent"
  406.                     title="<?php echo htmlspecialchars($db['comment']); ?>"
  407.                     onclick="
  408.                         if (! toggle('<?php echo $element_counter; ?>', true))
  409.                             window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
  410.                         window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
  411.                             . '?' . $common_url_query; ?>', 'main');
  412.                         return false;">
  413.                     <?php
  414.                     if ($GLOBALS['text_dir'] === 'rtl') {
  415.                         echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
  416.                     }
  417.                     echo htmlspecialchars($db['disp_name']);
  418.                     if ($GLOBALS['text_dir'] === 'ltr') {
  419.                         echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
  420.                     }
  421.                     ?>
  422.                 </a>
  423.                 <?php
  424.             } else {
  425.                 // with only 1 db available we dont need to refresh left frame
  426.                 // on db selection, only phpmain
  427.                 ?>
  428.                 <a href="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
  429.                     . '?' . $common_url_query; ?>"
  430.                     id="<?php echo htmlspecialchars($db['name']); ?>"
  431.                     title="<?php echo htmlspecialchars($db['comment']); ?>">
  432.                     <?php
  433.                     if ($GLOBALS['text_dir'] === 'rtl') {
  434.                         echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
  435.                     }
  436.                     echo htmlspecialchars($db['disp_name']);
  437.                     if ($GLOBALS['text_dir'] === 'ltr') {
  438.                         echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
  439.                     }
  440.                     ?>
  441.                 </a>
  442.                 <?php
  443.             }
  444.             if ($db['num_tables']) {
  445.                 if (isset($tables_full[$db['name']])) {
  446.                     $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
  447.                 } elseif (isset($tables_full[strtolower($db['name'])])) {
  448.                     // on windows with lower_case_table_names = 1
  449.                     // MySQL returns
  450.                     // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
  451.                     // but information_schema.TABLES gives `test`
  452.                     // bug #1436171
  453.                     // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
  454.                     $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
  455.                 } else {
  456.                     $tables = PMA_getTableList($db['name']);
  457.                 }
  458.                 $child_visible =
  459.                     (bool) ($GLOBALS['PMA_List_Database']->count() === 1 || $db_start == $db['name']);
  460.                 PMA_displayTableList($tables, $child_visible, '', $db['name']);
  461.             } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
  462.                 // no tables and LeftFrameLight:
  463.                 // display message no tables in selected db
  464.                 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
  465.             }
  466.             echo '</li>' . "\n";
  467.         } // end foreach db
  468.     } // end foreach group
  469.  
  470.     if ($close_db_group) {
  471.         $url_dbgroup = '';
  472.         echo '</ul>';
  473.         echo '</li>';
  474.         $close_db_group = false;
  475.     }
  476.  
  477.     echo '</ul>' . "\n";
  478. }
  479.  
  480. /**
  481.  * display unordered list of tables
  482.  * calls itself recursively if table in given list
  483.  * is a list itself
  484.  *
  485.  * @uses    is_array()
  486.  * @uses    count()
  487.  * @uses    urlencode()
  488.  * @uses    strpos()
  489.  * @uses    printf()
  490.  * @uses    htmlspecialchars()
  491.  * @uses    strlen()
  492.  * @uses    is_array()
  493.  * @uses    PMA_displayTableList()
  494.  * @uses    $_REQUEST['tbl_group']
  495.  * @uses    $GLOBALS['common_url_query']
  496.  * @uses    $GLOBALS['table']
  497.  * @uses    $GLOBALS['pmaThemeImage']
  498.  * @uses    $GLOBALS['cfg']['LeftFrameTableSeparator']
  499.  * @uses    $GLOBALS['cfg']['DefaultTabDatabase']
  500.  * @uses    $GLOBALS['cfg']['DefaultTabTable']
  501.  * @uses    $GLOBALS['strRows']
  502.  * @uses    $GLOBALS['strBrowse']
  503.  * @global  integer the element counter
  504.  * @global  string  html code for '-' image
  505.  * @global  string  html code for '+' image
  506.  * @global  string  html code for self link
  507.  * @param   array   $tables         array of tables/tablegroups
  508.  * @param   boolean $visible        wether the list is visible or not
  509.  * @param   string  $tab_group_full full tab group name
  510.  * @param   string  $table_db       db of this table
  511.  */
  512. function PMA_displayTableList($tables, $visible = false,
  513.     $tab_group_full = '', $table_db = '')
  514. {
  515.     if (! is_array($tables) || count($tables) === 0) {
  516.         return;
  517.     }
  518.  
  519.     global $element_counter, $img_minus, $img_plus, $href_left;
  520.     $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
  521.  
  522.     if ($visible) {
  523.         echo '<ul id="subel' . $element_counter . '">';
  524.     } else {
  525.         echo '<ul id="subel' . $element_counter . '" style="display: none">';
  526.     }
  527.     foreach ($tables as $group => $table) {
  528.         if (isset($table['is' . $sep . 'group'])) {
  529.             $common_url_query = $GLOBALS['common_url_query']
  530.                 . '&tbl_group=' . urlencode($tab_group_full . $group);
  531.  
  532.             $element_counter++;
  533.             echo '<li>' . "\n";
  534.             if ($visible
  535.              && ((isset($_REQUEST['tbl_group'])
  536.                && (strpos($_REQUEST['tbl_group'], $group) === 0
  537.                 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
  538.               || strpos($GLOBALS['table'], $group) === 0)) {
  539.                 printf($href_left, $element_counter,
  540.                     $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
  541.                 printf($img_minus, $element_counter);
  542.             } else {
  543.                 printf($href_left, $element_counter, $common_url_query);
  544.                 printf($img_plus, $element_counter);
  545.             }
  546.             echo '</a>';
  547.             ?>
  548.             <a href="index.php?<?php echo $common_url_query; ?>"
  549.                 target="_parent"
  550.                 onclick="
  551.                     if (! toggle('<?php echo $element_counter; ?>', true))
  552.                         window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
  553.                     window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
  554.                         . '?' . $common_url_query; ?>', 'main');
  555.                     return false;">
  556.                 <?php
  557.                 if ($GLOBALS['text_dir'] === 'rtl') {
  558.                     echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
  559.                 }
  560.                 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
  561.                 if ($GLOBALS['text_dir'] === 'ltr') {
  562.                     echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
  563.                 }
  564.                 ?>
  565.             </a>
  566.             <?php
  567.  
  568.             unset($table['is' . $sep . 'group']);
  569.             unset($table['tab' . $sep . 'group']);
  570.             unset($table['tab' . $sep . 'count']);
  571.  
  572.             if ($visible &&
  573.               ((isset($_REQUEST['tbl_group'])
  574.                 && (strpos($_REQUEST['tbl_group'], $group) === 0
  575.                 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
  576.               || strpos($GLOBALS['table'], $group) === 0)) {
  577.                 PMA_displayTableList($table, true,
  578.                     $tab_group_full . $group, $table_db);
  579.             } else {
  580.                 PMA_displayTableList($table, false, '', $table_db);
  581.             }
  582.             echo '</li>' . "\n";
  583.         } elseif (is_array($table)) {
  584.             $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
  585.                 .$GLOBALS['common_url_query'] . '&table='
  586.                 .urlencode($table['Name']);
  587.             echo '<li>' . "\n";
  588.             echo '<a title="' . $GLOBALS['strBrowse'] . ': '
  589.                 . htmlspecialchars($table['Comment'])
  590.                 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"'
  591.                 .' id="browse_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
  592.                 .' href="sql.php?' . $GLOBALS['common_url_query']
  593.                 .'&table=' . urlencode($table['Name'])
  594.                 .'&goto=' . $GLOBALS['cfg']['DefaultTabTable']
  595.                 . '" >'
  596.                 .'<img class="icon"';
  597.             if ('VIEW' === strtoupper($table['Comment'])) {
  598.                 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
  599.             } else {
  600.                 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
  601.             }
  602.             echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
  603.                 .' width="10" height="10" alt="' . $GLOBALS['strBrowse'] . '" /></a>' . "\n"
  604.                 .'<a href="' . $href . '" title="' . htmlspecialchars($table['Comment']
  605.                 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"'
  606.                 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
  607.                 // preserve spaces in table name
  608.                 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
  609.             echo '</li>' . "\n";
  610.         }
  611.     }
  612.     echo '</ul>';
  613. }
  614.  
  615. echo '</div>' . "\n";
  616.  
  617. PMA_exitNavigationFrame();
  618. ?>
  619.