typo3/ext/phpmyadmin/modsub/phpmyadmin-2.6.2/libraries/display_tbl.lib.php

Go to the documentation of this file.
00001 <?php
00002 /* $Id: display_tbl.lib.php,v 2.74 2005/03/13 13:23:08 lem9 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00048 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
00049 {
00050     global $db, $table;
00051     global $unlim_num_rows, $fields_meta;
00052     global $err_url;
00053 
00054     // 1. Initializes the $do_display array
00055     $do_display              = array();
00056     $do_display['edit_lnk']  = $the_disp_mode[0] . $the_disp_mode[1];
00057     $do_display['del_lnk']   = $the_disp_mode[2] . $the_disp_mode[3];
00058     $do_display['sort_lnk']  = (string) $the_disp_mode[4];
00059     $do_display['nav_bar']   = (string) $the_disp_mode[5];
00060     $do_display['ins_row']   = (string) $the_disp_mode[6];
00061     $do_display['bkm_form']  = (string) $the_disp_mode[7];
00062     $do_display['text_btn']  = (string) $the_disp_mode[8];
00063     $do_display['pview_lnk'] = (string) $the_disp_mode[9];
00064 
00065     // 2. Display mode is not "false for all elements" -> updates the
00066     // display mode
00067     if ($the_disp_mode != 'nnnn000000') {
00068         // 2.0 Print view -> set all elements to FALSE!
00069         if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
00070             $do_display['edit_lnk']  = 'nn'; // no edit link
00071             $do_display['del_lnk']   = 'nn'; // no delete link
00072             $do_display['sort_lnk']  = (string) '0';
00073             $do_display['nav_bar']   = (string) '0';
00074             $do_display['ins_row']   = (string) '0';
00075             $do_display['bkm_form']  = (string) '0';
00076             $do_display['text_btn']  = (string) '0';
00077             $do_display['pview_lnk'] = (string) '0';
00078         }
00079         // 2.1 Statement is a "SELECT COUNT", a
00080         //     "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
00081         //     contains a "PROC ANALYSE" part
00082         else if ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
00083             $do_display['edit_lnk']  = 'nn'; // no edit link
00084             $do_display['del_lnk']   = 'nn'; // no delete link
00085             $do_display['sort_lnk']  = (string) '0';
00086             $do_display['nav_bar']   = (string) '0';
00087             $do_display['ins_row']   = (string) '0';
00088             $do_display['bkm_form']  = (string) '1';
00089             if ($GLOBALS['is_analyse']) {
00090                 $do_display['text_btn']  = (string) '1';
00091             } else {
00092                 $do_display['text_btn']  = (string) '0';
00093             }
00094             $do_display['pview_lnk'] = (string) '1';
00095         }
00096         // 2.2 Statement is a "SHOW..."
00097         else if ($GLOBALS['is_show']) {
00098             // 2.2.1 TODO : defines edit/delete links depending on show statement
00099             $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which);
00100             if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
00101                 $do_display['edit_lnk'] = 'nn'; // no edit link
00102                 $do_display['del_lnk']  = 'kp'; // "kill process" type edit link
00103             }
00104             else {
00105                 // Default case -> no links
00106                 $do_display['edit_lnk'] = 'nn'; // no edit link
00107                 $do_display['del_lnk']  = 'nn'; // no delete link
00108             }
00109             // 2.2.2 Other settings
00110             $do_display['sort_lnk']  = (string) '0';
00111             $do_display['nav_bar']   = (string) '0';
00112             $do_display['ins_row']   = (string) '0';
00113             $do_display['bkm_form']  = (string) '1';
00114             $do_display['text_btn']  = (string) '1';
00115             $do_display['pview_lnk'] = (string) '1';
00116         }
00117         // 2.3 Other statements (ie "SELECT" ones) -> updates
00118         //     $do_display['edit_lnk'], $do_display['del_lnk'] and
00119         //     $do_display['text_btn'] (keeps other default values)
00120         else {
00121             $prev_table = $fields_meta[0]->table;
00122             $do_display['text_btn']  = (string) '1';
00123             for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) {
00124                 $is_link = ($do_display['edit_lnk'] != 'nn'
00125                             || $do_display['del_lnk'] != 'nn'
00126                             || $do_display['sort_lnk'] != '0'
00127                             || $do_display['ins_row'] != '0');
00128                 // 2.3.2 Displays edit/delete/sort/insert links?
00129                 if ($is_link
00130                     && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
00131                     $do_display['edit_lnk'] = 'nn'; // don't display links
00132                     $do_display['del_lnk']  = 'nn';
00133                     // TODO: May be problematic with same fields names in
00134                     //       two joined table.
00135                     // $do_display['sort_lnk'] = (string) '0';
00136                     $do_display['ins_row']  = (string) '0';
00137                     if ($do_display['text_btn'] == '1') {
00138                         break;
00139                     }
00140                 } // end if (2.3.2)
00141                 // 2.3.3 Always display print view link
00142                 $do_display['pview_lnk']    = (string) '1';
00143                 $prev_table = $fields_meta[$i]->table;
00144             } // end for
00145         } // end if..elseif...else (2.1 -> 2.3)
00146     } // end if (2)
00147 
00148     // 3. Gets the total number of rows if it is unknown
00149     if (isset($unlim_num_rows) && $unlim_num_rows != '') {
00150         $the_total = $unlim_num_rows;
00151     }
00152     else if (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
00153              && (!empty($db) && !empty($table))) {
00154         $the_total   = PMA_countRecords($db, $table, TRUE);
00155     }
00156 
00157     // 4. If navigation bar or sorting fields names urls should be
00158     //    displayed but there is only one row, change these settings to
00159     //    false
00160     if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') {
00161 
00162         if (isset($unlim_num_rows) && $unlim_num_rows < 2) {
00163             // garvin: force display of navbar for vertical/horizontal display-choice.
00164             // $do_display['nav_bar']  = (string) '0';
00165             $do_display['sort_lnk'] = (string) '0';
00166         }
00167 
00168     } // end if (3)
00169 
00170     // 5. Updates the synthetic var
00171     $the_disp_mode = join('', $do_display);
00172 
00173     return $do_display;
00174 } // end of the 'PMA_setDisplayMode()' function
00175 
00176 
00205 function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
00206 {
00207     global $lang, $convcharset, $server, $db, $table;
00208     global $goto;
00209     global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
00210     global $disp_direction, $repeat_cells;
00211     global $dontlimitchars;
00212     global $is_innodb;
00213     global $showtable;
00214 
00215     // FIXME: move this to a central place
00216     // FIXME: for other future table types
00217     $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
00218 
00219     ?>
00220 
00221 <!-- Navigation bar -->
00222 <table border="0" cellpadding="2" cellspacing="0">
00223 <tr>
00224     <?php
00225     // Move to the beginning or to the previous page
00226     if ($pos > 0 && $session_max_rows != 'all') {
00227         // loic1: patch #474210 from Gosha Sakovich - part 1
00228         if ($GLOBALS['cfg']['NavigationBarIconic']) {
00229             $caption1 = '&lt;&lt;';
00230             $caption2 = '&nbsp;&lt;&nbsp;';
00231             $title1   = ' title="' . $GLOBALS['strPos1'] . '"';
00232             $title2   = ' title="' . $GLOBALS['strPrevious'] . '"';
00233         } else {
00234             $caption1 = $GLOBALS['strPos1'] . ' &lt;&lt;';
00235             $caption2 = $GLOBALS['strPrevious'] . ' &lt;';
00236             $title1   = '';
00237             $title2   = '';
00238         } // end if... else...
00239         ?>
00240 <td>
00241     <form action="sql.php" method="post">
00242         <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
00243         <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
00244         <input type="hidden" name="pos" value="0" />
00245         <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
00246         <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
00247         <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
00248         <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00249         <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
00250         <input type="submit" name="navig" value="<?php echo $caption1; ?>"<?php echo $title1; ?> />
00251     </form>
00252 </td>
00253 <td>
00254     <form action="sql.php" method="post">
00255         <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
00256         <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
00257         <input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
00258         <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
00259         <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
00260         <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
00261         <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00262         <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
00263         <input type="submit" name="navig" value="<?php echo $caption2; ?>"<?php echo $title2; ?> />
00264     </form>
00265 </td>
00266         <?php
00267     } // end move back
00268     echo "\n";
00269     ?>
00270 <td>
00271     &nbsp;&nbsp;&nbsp;
00272 </td>
00273 <td align="center">
00274     <form action="sql.php" method="post"
00275         onsubmit="return (checkFormElementInRange(this, 'session_max_rows', 1) &amp;&amp; checkFormElementInRange(this, 'pos', 0, <?php echo $unlim_num_rows - 1; ?>))">
00276         <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
00277         <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
00278         <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00279         <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
00280         <input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
00281         <input type="text" name="session_max_rows" size="3" value="<?php echo (($session_max_rows != 'all') ? $session_max_rows : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
00282         <?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
00283         <input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
00284         <br />
00285     <?php
00286     // Display mode (horizontal/vertical and repeat headers)
00287     $param1 = '            <select name="disp_direction">' . "\n"
00288             . '                <option value="horizontal"' . (($disp_direction == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
00289             . '                <option value="horizontalflipped"' . (($disp_direction == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
00290             . '                <option value="vertical"' . (($disp_direction == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
00291             . '            </select>' . "\n"
00292             . '           ';
00293     $param2 = '            <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" class="textfield" />' . "\n"
00294             . '           ';
00295     echo '    ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
00296     ?>
00297     </form>
00298 </td>
00299 <td>
00300     &nbsp;&nbsp;&nbsp;
00301 </td>
00302     <?php
00303     // Move to the next page or to the last one
00304     if (($pos + $session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
00305         && $session_max_rows != 'all') {
00306         // loic1: patch #474210 from Gosha Sakovich - part 2
00307         if ($GLOBALS['cfg']['NavigationBarIconic']) {
00308             $caption3 = '&nbsp;&gt;&nbsp;';
00309             $caption4 = '&gt;&gt;';
00310             $title3   = ' title="' . $GLOBALS['strNext'] . '"';
00311             $title4   = ' title="' . $GLOBALS['strEnd'] . '"';
00312         } else {
00313             $caption3 = '&gt; ' . $GLOBALS['strNext'];
00314             $caption4 = '&gt;&gt; ' . $GLOBALS['strEnd'];
00315             $title3   = '';
00316             $title4   = '';
00317         } // end if... else...
00318         echo "\n";
00319         ?>
00320 <td>
00321     <form action="sql.php" method="post">
00322         <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
00323         <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
00324         <input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
00325         <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
00326         <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
00327         <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
00328         <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00329         <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
00330         <input type="submit" name="navig" value="<?php echo $caption3; ?>"<?php echo $title3; ?> />
00331     </form>
00332 </td>
00333 <td>
00334     <form action="sql.php" method="post"
00335         onsubmit="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
00336         <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
00337         <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
00338         <input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $session_max_rows)- 1) * $session_max_rows); ?>" />
00339         <?php
00340         if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
00341             echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
00342             // no backquote around this message
00343             $onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], FALSE) . '\')"';
00344         }
00345         ?>
00346         <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
00347         <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
00348         <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
00349         <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00350         <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
00351         <input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> <?php echo (empty($onclick) ? '' : $onclick); ?>/>
00352     </form>
00353 </td>
00354         <?php
00355     } // end move toward
00356 
00357 
00358     //page redirection
00359     $pageNow = @floor($pos / $session_max_rows) + 1;
00360     $nbTotalPage = @ceil($unlim_num_rows / $session_max_rows);
00361 
00362     if ($nbTotalPage > 1){ //if1
00363        ?>
00364    <td>
00365        &nbsp;&nbsp;&nbsp;
00366    </td>
00367    <td>
00368         <?php //<form> for keep the form alignment of button < and << ?>
00369         <form>
00370         <?php echo PMA_pageselector(
00371                      'sql.php?sql_query='        . $encoded_query .
00372                         '&amp;session_max_rows=' . $session_max_rows .
00373                         '&amp;disp_direction='   . $disp_direction .
00374                         '&amp;repeat_cells='     . $repeat_cells .
00375                         '&amp;goto='             . $goto .
00376                         '&amp;dontlimitchars='   . $dontlimitchars .
00377                         '&amp;'                  . PMA_generate_common_url($db, $table) .
00378                         '&amp;',
00379                      $session_max_rows,
00380                      $pageNow,
00381                      $nbTotalPage
00382               );
00383         ?>
00384         </form>
00385     </td>
00386         <?php
00387     } //_if1
00388 
00389 
00390     // Show all the records if allowed
00391     if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
00392         echo "\n";
00393         ?>
00394 <td>
00395     &nbsp;&nbsp;&nbsp;
00396 </td>
00397 <td>
00398     <form action="sql.php" method="post">
00399         <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
00400         <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
00401         <input type="hidden" name="pos" value="0" />
00402         <input type="hidden" name="session_max_rows" value="all" />
00403         <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
00404         <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
00405         <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00406         <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
00407         <input type="submit" name="navig" value="<?php echo $GLOBALS['strShowAll']; ?>" />
00408     </form>
00409 </td>
00410         <?php
00411     } // end show all
00412     echo "\n";
00413     ?>
00414 </tr>
00415 </table>
00416 
00417     <?php
00418 } // end of the 'PMA_displayTableNavigation()' function
00419 
00420 
00452 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
00453 {
00454     global $lang, $convcharset, $server, $db, $table;
00455     global $goto, $text_url;
00456     global $sql_query, $num_rows, $pos, $session_max_rows;
00457     global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
00458     global $dontlimitchars;
00459 
00460     if ($analyzed_sql == '') {
00461         $analyzed_sql = array();
00462     }
00463 
00464     // can the result be sorted?
00465     if ($is_display['sort_lnk'] == '1') {
00466 
00467         // Just as fallback
00468         $unsorted_sql_query     = $sql_query;
00469         if (isset($analyzed_sql[0]['unsorted_query'])) {
00470             $unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
00471         }
00472 
00473         // we need $sort_expression and $sort_expression_nodir
00474         // even if there are many table references
00475 
00476         $sort_expression = trim(str_replace('  ', ' ',$analyzed_sql[0]['order_by_clause']));
00477 
00478         // Get rid of ASC|DESC (TODO: analyzer)
00479         preg_match('@(.*)([[:space:]]*(ASC|DESC))@si',$sort_expression,$matches);
00480         $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
00481 
00482         // sorting by indexes, only if it makes sense (only one table ref)
00483         if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
00484             isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
00485             isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
00486 
00487             // grab indexes data:
00488             PMA_DBI_select_db($db);
00489             if (!defined('PMA_IDX_INCLUDED')) {
00490                 $ret_keys = PMA_get_indexes($table);
00491             }
00492 
00493             $prev_index = '';
00494             foreach ($ret_keys as $row) {
00495 
00496                 if ($row['Key_name'] != $prev_index ){
00497                     $indexes[]  = $row['Key_name'];
00498                     $prev_index = $row['Key_name'];
00499                 }
00500                 $indexes_info[$row['Key_name']]['Sequences'][]     = $row['Seq_in_index'];
00501                 $indexes_info[$row['Key_name']]['Non_unique']      = $row['Non_unique'];
00502                 if (isset($row['Cardinality'])) {
00503                     $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
00504                 }
00505             //    I don't know what does the following column mean....
00506             //    $indexes_info[$row['Key_name']]['Packed']          = $row['Packed'];
00507                 $indexes_info[$row['Key_name']]['Comment']         = (isset($row['Comment']))
00508                                                                    ? $row['Comment']
00509                                                                    : '';
00510                 $indexes_info[$row['Key_name']]['Index_type']      = (isset($row['Index_type']))
00511                                                                    ? $row['Index_type']
00512                                                                    : '';
00513 
00514                 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name']  = $row['Column_name'];
00515                 if (isset($row['Sub_part'])) {
00516                     $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
00517                 }
00518             } // end while
00519 
00520             // do we have any index?
00521             if (isset($indexes_data)) {
00522 
00523                 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00524                     $span = $fields_cnt;
00525                     if ($is_display['edit_lnk'] != 'nn') $span++;
00526                     if ($is_display['del_lnk'] != 'nn') $span++;
00527                     if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') $span++;
00528                 } else {
00529                     $span = $num_rows + floor($num_rows/$repeat_cells) + 1;
00530                 }
00531 
00532                 echo '<form action="sql.php" method="post">' . "\n";
00533                 echo PMA_generate_common_hidden_inputs($db, $table, 5);
00534                 echo '<input type="hidden" name="pos" value="' . $pos .  '" />' . "\n";
00535                 echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
00536                 echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
00537                 echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
00538                 echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
00539                 echo $GLOBALS['strSortByKey'] . ': <select name="sql_query">' . "\n";
00540                 $used_index = false;
00541                 $local_order = (isset($sort_expression) ? $sort_expression : '');
00542                 foreach ($indexes_data AS $key => $val) {
00543                     $asc_sort = '';
00544                     $desc_sort = '';
00545                     foreach ($val AS $key2 => $val2) {
00546                         $asc_sort .= PMA_backquote($val2['Column_name']) . ' ASC , ';
00547                         $desc_sort .= PMA_backquote($val2['Column_name']) . ' DESC , ';
00548                     }
00549                     $asc_sort = substr($asc_sort, 0, -3);
00550                     $desc_sort = substr($desc_sort, 0, -3);
00551                     $used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
00552                     echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strAscending'] . ')</option>';
00553                     echo "\n";
00554                     echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>';
00555                     echo "\n";
00556                 }
00557                 echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"' ) . '>' . $GLOBALS['strNone'] . '</option>';
00558                 echo "\n";
00559                 echo '</select>&nbsp;';
00560                 echo "\n";
00561                 echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
00562                 echo "\n";
00563                 echo '</form>';
00564                 echo "\n";
00565             }
00566         }
00567     }
00568 
00569 
00570     $vertical_display['emptypre']   = 0;
00571     $vertical_display['emptyafter'] = 0;
00572     $vertical_display['textbtn']    = '';
00573 
00574 
00575     // Start of form for multi-rows delete
00576 
00577     if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp' ) {
00578         echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm">' . "\n";
00579         echo PMA_generate_common_hidden_inputs($db, $table, 1);
00580         echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
00581         echo '<input type="hidden" name="repeat_cells"   value="' . $repeat_cells   . '" />' . "\n";
00582         echo '<input type="hidden" name="goto"           value="sql.php" />' . "\n";
00583         echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
00584     }
00585 
00586     echo '<!-- Results table -->' . "\n"
00587        . '<table id="table_results" ';
00588     if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
00589         echo 'border="1" cellpadding="2" cellspacing="0"';
00590     } else {
00591         echo 'border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="2" cellspacing="1"';
00592     }
00593     echo '>' . "\n";
00594     if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00595         ?>
00596 <!-- Results table headers -->
00597 <tr>
00598         <?php
00599         echo "\n";
00600     }
00601 
00602     // 1. Displays the full/partial text button (part 1)...
00603     if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00604         $colspan  = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
00605                   ? ' colspan="3"'
00606                   : '';
00607     } else {
00608         $rowspan  = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
00609                   ? ' rowspan="3"'
00610                   : '';
00611     }
00612     $text_url = 'sql.php?'
00613               . PMA_generate_common_url($db, $table)
00614               . '&amp;sql_query=' . urlencode($sql_query)
00615               . '&amp;pos=' . $pos
00616               . '&amp;session_max_rows=' . $session_max_rows
00617               . '&amp;pos=' . $pos
00618               . '&amp;disp_direction=' . $disp_direction
00619               . '&amp;repeat_cells=' . $repeat_cells
00620               . '&amp;goto=' . $goto
00621               . '&amp;dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
00622 
00623     //     ... before the result table
00624     if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
00625         && $is_display['text_btn'] == '1') {
00626         $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
00627         if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00628             ?>
00629 <th class="td" colspan="<?php echo $fields_cnt; ?>" align="center">
00630     <a href="<?php echo $text_url; ?>">
00631         <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_'.(($dontlimitchars) ? 'partialtext' : 'fulltext') . '.png'; ?>" border="0" width="50" height="20" alt="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" title="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" /></a>
00632 </th>
00633 </tr>
00634 
00635 <tr>
00636             <?php
00637         } // end horizontal/horizontalflipped mode
00638         else {
00639             echo "\n";
00640             ?>
00641 <tr>
00642 <th class="td" colspan="<?php echo $num_rows + floor($num_rows/$repeat_cells) + 1; ?>" align="center">
00643     <a href="<?php echo $text_url; ?>">
00644         <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . (($dontlimitchars) ? 'partialtext' : 'fulltext') . '.png'; ?>" border="0" width="50" height="20" alt="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" title="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" /></a>
00645 </th>
00646 </tr>
00647             <?php
00648         } // end vertical mode
00649     }
00650 
00651     //     ... at the left column of the result table header if possible
00652     //     and required
00653     else if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
00654         $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
00655         if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00656             echo "\n";
00657             ?>
00658 <th class="td" <?php echo $colspan; ?> align="center">
00659     <a href="<?php echo $text_url; ?>">
00660         <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . (($dontlimitchars) ? 'partialtext' : 'fulltext') . '.png'; ?>" border="0" width="50" height="20" alt="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" title="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" /></a>
00661 </th>
00662             <?php
00663         } // end horizontal/horizontalflipped mode
00664         else {
00665             $vertical_display['textbtn'] = '    <th class="td" ' . $rowspan . ' align="center" valign="middle">' . "\n"
00666                                          . '        <a href="' . $text_url . '">' . "\n"
00667                                          . '            <img src="' . $GLOBALS['pmaThemeImage'] . 's_' . (($dontlimitchars) ? 'partialtext' : 'fulltext') . '.png" border="0" width="50" height="20" alt="' . (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" /></a>' . "\n"
00668                                          . '    </th>' . "\n";
00669         } // end vertical mode
00670     }
00671 
00672     //     ... else if no button, displays empty(ies) col(s) if required
00673     else if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
00674              && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
00675         $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
00676         if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00677             echo "\n";
00678             ?>
00679 <td<?php echo $colspan; ?>></td>
00680             <?php
00681             echo "\n";
00682         } // end horizontal/horizontalfipped mode
00683         else {
00684             $vertical_display['textbtn'] = '    <td' . $rowspan . '></td>' . "\n";
00685         } // end vertical mode
00686     }
00687 
00688     // 2. Displays the fields' name
00689     // 2.0 If sorting links should be used, checks if the query is a "JOIN"
00690     //     statement (see 2.1.3)
00691 
00692     // 2.0.1 Prepare Display column comments if enabled ($cfg['ShowBrowseComments']).
00693     //       Do not show comments, if using horizontalflipped mode, because of space usage
00694     if ($GLOBALS['cfg']['ShowBrowseComments'] && $GLOBALS['cfgRelation']['commwork'] && $disp_direction != 'horizontalflipped') {
00695         $comments_map = array();
00696         foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
00697 
00698             $tb = $tbl['table_true_name'];
00699 
00700             $comments_map[$tb] = PMA_getComments($db, $tb);
00701         }
00702     }
00703 
00704     if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
00705         require_once('./libraries/transformations.lib.php');
00706         $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
00707     }
00708 
00709     if ($is_display['sort_lnk'] == '1') {
00710         //$is_join = preg_match('@(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN@im', $sql_query, $select_stt);
00711         $is_join = (isset($analyzed_sql[0]['queryflags']['join']) ?TRUE:FALSE);
00712         $select_expr = $analyzed_sql[0]['select_expr_clause'];
00713     } else {
00714         $is_join = FALSE;
00715     }
00716 
00717     // garvin: See if we have to highlight any header fields of a WHERE query.
00718     //  Uses SQL-Parser results.
00719     $highlight_columns = array();
00720     if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
00721         isset($analyzed_sql[0]['where_clause_identifiers'])) {
00722 
00723         $wi = 0;
00724         if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
00725             foreach ($analyzed_sql[0]['where_clause_identifiers'] AS $wci_nr => $wci) {
00726                 $highlight_columns[$wci] = 'true';
00727             }
00728         }
00729     }
00730 
00731     for ($i = 0; $i < $fields_cnt; $i++) {
00732         // garvin: See if this column should get highlight because it's used in the
00733         //  where-query.
00734         if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
00735             $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
00736         } else {
00737             $column_style = '';
00738         }
00739 
00740         // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
00741         if (isset($comments_map) &&
00742                 isset($comments_map[$fields_meta[$i]->table]) &&
00743                 isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
00744             /*$comments_table_wrap_pre = '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><th>';
00745             $comments_table_wrap_post = '</th></tr><tr><th style="font-size: 8pt; font-weight: normal">' . htmlspecialchars($comments_map[$fields_meta[$i]->name]) . '</td></tr></table>';*/
00746             $comments_table_wrap_pre = '';
00747             $comments_table_wrap_post = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) . '</span>';
00748         } else {
00749             $comments_table_wrap_pre = '';
00750             $comments_table_wrap_post = '';
00751         }
00752 
00753         // 2.1 Results can be sorted
00754         if ($is_display['sort_lnk'] == '1') {
00755 
00756             // 2.1.1 Checks if the table name is required; it's the case
00757             //       for a query with a "JOIN" statement and if the column
00758             //       isn't aliased, or in queries like
00759             //       SELECT `1`.`master_field` , `2`.`master_field`
00760             //       FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
00761 
00762             if (($is_join
00763                 //&& !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name . '~i', $select_stt[1], $parts))
00764                 && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name . '~i', $select_expr, $parts))
00765                || ( isset($analyzed_sql[0]['select_expr'][$i]['expr'])
00766                    && isset($analyzed_sql[0]['select_expr'][$i]['column'])
00767                    && $analyzed_sql[0]['select_expr'][$i]['expr'] !=
00768                    $analyzed_sql[0]['select_expr'][$i]['column']
00769                   && !empty($fields_meta[$i]->table)) ) {
00770                 //$sort_tbl = PMA_backquote($fields_meta[$i]->table) . '.';
00771                 $sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . ';
00772             } else {
00773                 $sort_tbl = '';
00774             }
00775             // 2.1.2 Checks if the current column is used to sort the
00776             //       results
00777             if (empty($sort_expression)) {
00778                 $is_in_sort = FALSE;
00779             } else {
00780                 // field name may be preceded by a space, or any number
00781                 // of characters followed by a dot (tablename.fieldname)
00782                 // so do a direct comparison
00783                 // for the sort expression (avoids problems with queries
00784                 // like "SELECT id, count(id)..." and clicking to sort
00785                 // on id or on count(id) )
00786                 $is_in_sort = ($sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? TRUE : FALSE);
00787             }
00788             // 2.1.3 Check the field name for backquotes.
00789             //       If it contains some, it's probably a function column
00790             //       like 'COUNT(`field`)'
00791             if (strpos(' ' . $fields_meta[$i]->name, '`') > 0) {
00792                 $sort_order = ' ORDER BY \'' . $fields_meta[$i]->name . '\' ';
00793             } else {
00794                 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name) . ' ';
00795             }
00796             // 2.1.4 Do define the sorting url
00797             if (!$is_in_sort) {
00798                 // loic1: patch #455484 ("Smart" order)
00799                 $cfg['Order']  = strtoupper($GLOBALS['cfg']['Order']);
00800                 if ($cfg['Order'] == 'SMART') {
00801                     $cfg['Order'] = (preg_match('@time|date@i', $fields_meta[$i]->type)) ? 'DESC' : 'ASC';
00802                 }
00803                 $sort_order .= $cfg['Order'];
00804                 $order_img   = '';
00805             }
00806             else if (preg_match('@[[:space:]]ASC$@i', $sort_expression)) {
00807                 $sort_order .= ' DESC';
00808                 $order_img   = '&nbsp;<img src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" border="0" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
00809             }
00810             else if (preg_match('@[[:space:]]DESC$@i', $sort_expression)) {
00811                 $sort_order .= ' ASC';
00812                 $order_img   = '&nbsp;<img src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" border="0" width="11" height="9" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" id="soimg' . $i . '" />';
00813             }
00814             if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
00815                 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
00816             } else {
00817                 $sorted_sql_query = $unsorted_sql_query . $sort_order;
00818             }
00819             $url_query = PMA_generate_common_url($db, $table)
00820                        . '&amp;pos=' . $pos
00821                        . '&amp;session_max_rows=' . $session_max_rows
00822                        . '&amp;disp_direction=' . $disp_direction
00823                        . '&amp;repeat_cells=' . $repeat_cells
00824                        . '&amp;dontlimitchars=' . $dontlimitchars
00825                        . '&amp;sql_query=' . urlencode($sorted_sql_query);
00826 
00827             // 2.1.5 Displays the sorting url
00828             // added 20004-06-09: Michael Keck <mail@michaelkeck.de>
00829             //                    enable sord order swapping for image
00830             $order_onmouse = '';
00831             if (isset($order_img) && $order_img!='') {
00832                 if (strstr($order_img,'asc')) {
00833                     $order_onmouse.= ' onmouseover="if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }"'
00834                                    .' onmouseout="if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }"';
00835                 } else if (strstr($order_img,'desc')) {
00836                     $order_onmouse.= ' onmouseover="if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }"'
00837                                    .' onmouseout="if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }"';
00838                 }
00839             }
00840             $order_link_pre  = '<a href="sql.php?' . $url_query . '" ' . (($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'css') ? 'style="direction: ltr; writing-mode: tb-rl;"' : '') . ' title="' . $GLOBALS['strSort'] . '"' . $order_onmouse . '>';
00841             $order_link_post = '</a>';
00842             $order_link_content = ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
00843             $order_link_words = explode(' ', $order_link_content);
00844             if (isset($order_link_words[1])) {
00845                 $order_last_word_index = count($order_link_words)-1;
00846                 $order_last_word = $order_link_words[$order_last_word_index];
00847                 unset($order_link_words[$order_last_word_index]);
00848                 $order_link = $order_link_pre . implode(' ', $order_link_words)
00849                             . ' <div class="nowrap">' . $order_last_word . $order_img . '</div>' . $order_link_post . "\n";
00850             } else {
00851                 $order_link = '<div class="nowrap">' . $order_link_pre . $order_link_content . $order_link_post . $order_img . '</div>' . "\n";
00852             }
00853 
00854             if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00855                 echo "\n";
00856                 ?>
00857 <th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') echo 'valign="bottom"'; ?>>
00858     <?php echo $comments_table_wrap_pre; ?>
00859     <?php echo $order_link; ?>
00860     <?php echo $comments_table_wrap_post; ?>
00861 </th>
00862                 <?php
00863             }
00864             $vertical_display['desc'][] = '    <th ' . $column_style . '>' . "\n"
00865                                         . $comments_table_wrap_pre
00866                                         . $order_link
00867                                         . $comments_table_wrap_post
00868                                         . '    </th>' . "\n";
00869         } // end if (2.1)
00870 
00871         // 2.2 Results can't be sorted
00872         else {
00873             if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00874                 echo "\n";
00875                 ?>
00876 <th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') echo 'valign="bottom"'; ?>  <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'css' ? 'style="direction: ltr; writing-mode: tb-rl;"' : ''); ?>>
00877     <?php echo $comments_table_wrap_pre; ?>
00878     <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake'? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name)) . "\n"; ?>
00879     <?php echo $comments_table_wrap_post; ?>
00880 </th>
00881                 <?php
00882             }
00883             $vertical_display['desc'][] = '    <th ' . $column_style . '>' . "\n"
00884                                         . $comments_table_wrap_pre
00885                                         . '        ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
00886                                         . $comments_table_wrap_post
00887                                         . '    </th>';
00888         } // end else (2.2)
00889     } // end for
00890 
00891     // 3. Displays the full/partial text button (part 2) at the right
00892     //    column of the result table header if possible and required...
00893     if ($GLOBALS['cfg']['ModifyDeleteAtRight']
00894         && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
00895         && $is_display['text_btn'] == '1') {
00896         $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
00897         if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00898             echo "\n";
00899             ?>
00900 <th class="td" <?php echo $colspan; ?> align="center">
00901     <a href="<?php echo $text_url; ?>">
00902         <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . (($dontlimitchars) ? 'partialtext' : 'fulltext') . '.png'; ?>" border="0" width="50" height="20" alt="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" title="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" /></a>
00903 </th>
00904             <?php
00905         } // end horizontal/horizontalflipped mode
00906         else {
00907             $vertical_display['textbtn'] = '    <th class="td" ' . $rowspan . ' align="center" valign="middle">' . "\n"
00908                                          . '        <a href="' . $text_url . '">' . "\n"
00909                                          . '            <img src="' . $GLOBALS['pmaThemeImage'] . 's_' . (($dontlimitchars) ? 'partialtext' : 'fulltext') . '.png" border="0" width="50" height="20" alt="' . (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" /></a>' . "\n"
00910                                          . '    </th>' . "\n";
00911         } // end vertical mode
00912     }
00913 
00914     //     ... else if no button, displays empty cols if required
00915     // (unless coming from Browse mode print view)
00916     else if ($GLOBALS['cfg']['ModifyDeleteAtRight']
00917              && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
00918              && (!$GLOBALS['is_header_sent'])) {
00919         $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
00920         if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00921             echo "\n";
00922             ?>
00923 <td<?php echo $colspan; ?>></td>
00924             <?php
00925         } // end horizontal/horizontalflipped mode
00926         else {
00927             $vertical_display['textbtn'] = '    <td' . $rowspan . '></td>' . "\n";
00928         } // end vertical mode
00929     }
00930 
00931     if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
00932         echo "\n";
00933         ?>
00934 </tr>
00935         <?php
00936     }
00937     echo "\n";
00938 
00939     return TRUE;
00940 } // end of the 'PMA_displayTableHeaders()' function
00941 
00942 
00943 
00977 function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
00978 {
00979     global $lang, $convcharset, $server, $db, $table;
00980     global $goto;
00981     global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
00982     global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
00983     global $dontlimitchars;
00984     global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
00985 
00986     $url_sql_query          = $sql_query;
00987 
00988     // query without conditions to shorten urls when needed, 200 is just
00989     // guess, it should depend on remaining url length
00990 
00991     if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
00992         isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
00993         strlen($sql_query) > 200) {
00994 
00995         $url_sql_query = 'SELECT ';
00996         if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
00997             $url_sql_query .= ' DISTINCT ';
00998         }
00999         $url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
01000         if (!empty($analyzed_sql[0]['from_clause'])) {
01001             $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
01002         }
01003     }
01004 
01005     if (!is_array($map)) {
01006         $map = array();
01007     }
01008     ?>
01009 <!-- Results table body -->
01010     <?php
01011     echo "\n";
01012 
01013     $row_no                         = 0;
01014     $vertical_display['edit']       = array();
01015     $vertical_display['delete']     = array();
01016     $vertical_display['data']       = array();
01017     $vertical_display['row_delete'] = array();
01018 
01019     // Correction uva 19991216 in the while below
01020     // Previous code assumed that all tables have keys, specifically that
01021     // the phpMyAdmin GUI should support row delete/edit only for such
01022     // tables.
01023     // Although always using keys is arguably the prescribed way of
01024     // defining a relational table, it is not required. This will in
01025     // particular be violated by the novice.
01026     // We want to encourage phpMyAdmin usage by such novices. So the code
01027     // below has been changed to conditionally work as before when the
01028     // table being displayed has one or more keys; but to display
01029     // delete/edit options correctly for tables without keys.
01030 
01031     // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
01032     //        to get the NULL values
01033 
01034     // rabus: This function needs a little rework.
01035     //        Using MYSQL_BOTH just pollutes the memory!
01036 
01037     // ne0x:  Use function PMA_DBI_fetch_array() due to mysqli
01038     //        compatibility. Now this function is wrapped.
01039 
01040     while ($row = PMA_DBI_fetch_row($dt_result)) {
01041         // lem9: "vertical display" mode stuff
01042         if (($row_no != 0) && ($repeat_cells != 0) && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
01043             echo '<tr>' . "\n";
01044 
01045             for ($foo_i = 0; $foo_i < $vertical_display['emptypre']; $foo_i++) {
01046                 echo '    <th class="td">&nbsp;</th>' . "\n";
01047             }
01048 
01049             foreach ($vertical_display['desc'] AS $key => $val) {
01050                 echo $val;
01051             }
01052 
01053             for ($foo_i = 0; $foo_i < $vertical_display['emptyafter']; $foo_i++) {
01054                 echo '    <th class="td">&nbsp;</th>' . "\n";
01055             }
01056 
01057             echo '</tr>' . "\n";
01058         } // end if
01059 
01060         if (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
01061             $bgcolor = '#ffffff';
01062         } else {
01063             $bgcolor = ($row_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
01064         }
01065 
01066         if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
01067             // loic1: pointer code part
01068             $on_mouse     = '';
01069             if (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) {
01070                 if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) {
01071                     $on_mouse = ' onmouseover="setPointer(this, ' . $row_no . ', \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
01072                               . ' onmouseout="setPointer(this, ' . $row_no . ', \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
01073                 } else {
01074                     $on_mouse = '';
01075                 }
01076                 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
01077                     $on_mouse .= ' onmousedown="setPointer(this, ' . $row_no . ', \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
01078                 }
01079             } // end if
01080             ?>
01081 <tr<?php echo $on_mouse; ?>>
01082             <?php
01083             echo "\n";
01084         }
01085 
01086         // 1. Prepares the row (gets primary keys to use)
01087         if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
01088             // 1.1 Results from a "SELECT" statement -> builds the
01089             //     "primary" key to use in links
01090             if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) {
01091                 $uva_condition     =