00001 <?php
00002
00003
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
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
00066
00067 if ($the_disp_mode != 'nnnn000000') {
00068
00069 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
00070 $do_display['edit_lnk'] = 'nn';
00071 $do_display['del_lnk'] = 'nn';
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
00080
00081
00082 else if ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
00083 $do_display['edit_lnk'] = 'nn';
00084 $do_display['del_lnk'] = 'nn';
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
00097 else if ($GLOBALS['is_show']) {
00098
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';
00102 $do_display['del_lnk'] = 'kp';
00103 }
00104 else {
00105
00106 $do_display['edit_lnk'] = 'nn';
00107 $do_display['del_lnk'] = 'nn';
00108 }
00109
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
00118
00119
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
00129 if ($is_link
00130 && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
00131 $do_display['edit_lnk'] = 'nn';
00132 $do_display['del_lnk'] = 'nn';
00133
00134
00135
00136 $do_display['ins_row'] = (string) '0';
00137 if ($do_display['text_btn'] == '1') {
00138 break;
00139 }
00140 }
00141
00142 $do_display['pview_lnk'] = (string) '1';
00143 $prev_table = $fields_meta[$i]->table;
00144 }
00145 }
00146 }
00147
00148
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
00158
00159
00160 if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') {
00161
00162 if (isset($unlim_num_rows) && $unlim_num_rows < 2) {
00163
00164
00165 $do_display['sort_lnk'] = (string) '0';
00166 }
00167
00168 }
00169
00170
00171 $the_disp_mode = join('', $do_display);
00172
00173 return $do_display;
00174 }
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
00216
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
00226 if ($pos > 0 && $session_max_rows != 'all') {
00227
00228 if ($GLOBALS['cfg']['NavigationBarIconic']) {
00229 $caption1 = '<<';
00230 $caption2 = ' < ';
00231 $title1 = ' title="' . $GLOBALS['strPos1'] . '"';
00232 $title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
00233 } else {
00234 $caption1 = $GLOBALS['strPos1'] . ' <<';
00235 $caption2 = $GLOBALS['strPrevious'] . ' <';
00236 $title1 = '';
00237 $title2 = '';
00238 }
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 }
00268 echo "\n";
00269 ?>
00270 <td>
00271
00272 </td>
00273 <td align="center">
00274 <form action="sql.php" method="post"
00275 onsubmit="return (checkFormElementInRange(this, 'session_max_rows', 1) && 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
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
00301 </td>
00302 <?php
00303
00304 if (($pos + $session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
00305 && $session_max_rows != 'all') {
00306
00307 if ($GLOBALS['cfg']['NavigationBarIconic']) {
00308 $caption3 = ' > ';
00309 $caption4 = '>>';
00310 $title3 = ' title="' . $GLOBALS['strNext'] . '"';
00311 $title4 = ' title="' . $GLOBALS['strEnd'] . '"';
00312 } else {
00313 $caption3 = '> ' . $GLOBALS['strNext'];
00314 $caption4 = '>> ' . $GLOBALS['strEnd'];
00315 $title3 = '';
00316 $title4 = '';
00317 }
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
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 }
00356
00357
00358
00359 $pageNow = @floor($pos / $session_max_rows) + 1;
00360 $nbTotalPage = @ceil($unlim_num_rows / $session_max_rows);
00361
00362 if ($nbTotalPage > 1){
00363 ?>
00364 <td>
00365
00366 </td>
00367 <td>
00368 <?php
00369 <form>
00370 <?php echo PMA_pageselector(
00371 'sql.php?sql_query=' . $encoded_query .
00372 '&session_max_rows=' . $session_max_rows .
00373 '&disp_direction=' . $disp_direction .
00374 '&repeat_cells=' . $repeat_cells .
00375 '&goto=' . $goto .
00376 '&dontlimitchars=' . $dontlimitchars .
00377 '&' . PMA_generate_common_url($db, $table) .
00378 '&',
00379 $session_max_rows,
00380 $pageNow,
00381 $nbTotalPage
00382 );
00383 ?>
00384 </form>
00385 </td>
00386 <?php
00387 }
00388
00389
00390
00391 if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
00392 echo "\n";
00393 ?>
00394 <td>
00395
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 }
00412 echo "\n";
00413 ?>
00414 </tr>
00415 </table>
00416
00417 <?php
00418 }
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
00465 if ($is_display['sort_lnk'] == '1') {
00466
00467
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
00474
00475
00476 $sort_expression = trim(str_replace(' ', ' ',$analyzed_sql[0]['order_by_clause']));
00477
00478
00479 preg_match('@(.*)([[:space:]]*(ASC|DESC))@si',$sort_expression,$matches);
00480 $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
00481
00482
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
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
00506
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 }
00519
00520
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> ';
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
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
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 . '&sql_query=' . urlencode($sql_query)
00615 . '&pos=' . $pos
00616 . '&session_max_rows=' . $session_max_rows
00617 . '&pos=' . $pos
00618 . '&disp_direction=' . $disp_direction
00619 . '&repeat_cells=' . $repeat_cells
00620 . '&goto=' . $goto
00621 . '&dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
00622
00623
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 }
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 }
00649 }
00650
00651
00652
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 }
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 }
00670 }
00671
00672
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 }
00683 else {
00684 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
00685 }
00686 }
00687
00688
00689
00690
00691
00692
00693
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
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
00718
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
00733
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
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
00745
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
00754 if ($is_display['sort_lnk'] == '1') {
00755
00756
00757
00758
00759
00760
00761
00762 if (($is_join
00763
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
00771 $sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . ';
00772 } else {
00773 $sort_tbl = '';
00774 }
00775
00776
00777 if (empty($sort_expression)) {
00778 $is_in_sort = FALSE;
00779 } else {
00780
00781
00782
00783
00784
00785
00786 $is_in_sort = ($sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? TRUE : FALSE);
00787 }
00788
00789
00790
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
00797 if (!$is_in_sort) {
00798
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 = ' <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 = ' <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 . '&pos=' . $pos
00821 . '&session_max_rows=' . $session_max_rows
00822 . '&disp_direction=' . $disp_direction
00823 . '&repeat_cells=' . $repeat_cells
00824 . '&dontlimitchars=' . $dontlimitchars
00825 . '&sql_query=' . urlencode($sorted_sql_query);
00826
00827
00828
00829
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 }
00870
00871
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 }
00889 }
00890
00891
00892
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 }
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 }
00912 }
00913
00914
00915
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 }
00926 else {
00927 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
00928 }
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 }
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;
00985
00986 $url_sql_query = $sql_query;
00987
00988
00989
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
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040 while ($row = PMA_DBI_fetch_row($dt_result)) {
01041
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"> </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"> </th>' . "\n";
01055 }
01056
01057 echo '</tr>' . "\n";
01058 }
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
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 }
01080 ?>
01081 <tr<?php echo $on_mouse; ?>>
01082 <?php
01083 echo "\n";
01084 }
01085
01086
01087 if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
01088
01089
01090 if ($is_display['edit_lnk'] == 'ur' ) {
01091 $uva_condition =