Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: display_tbl.lib.php,v 2.96.2.7 2006/03/23 10:37:17 lem9 Exp $ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4  
5 /**
6 * Set of functions used to display the records returned by a sql query
7 */
8  
9 /**
10 * Avoids undefined variables
11 */
12 if (!isset($pos)) {
13 $pos = 0;
14 }
15  
16 /**
17 * Defines the display mode to use for the results of a sql query
18 *
19 * It uses a synthetic string that contains all the required informations.
20 * In this string:
21 * - the first two characters stand for the action to do while
22 * clicking on the "edit" link (eg 'ur' for update a row, 'nn' for no
23 * edit link...);
24 * - the next two characters stand for the action to do while
25 * clicking on the "delete" link (eg 'kp' for kill a process, 'nn' for
26 * no delete link...);
27 * - the next characters are boolean values (1/0) and respectively stand
28 * for sorting links, navigation bar, "insert a new row" link, the
29 * bookmark feature, the expand/collapse text/blob fields button and
30 * the "display printable view" option.
31 * Of course '0'/'1' means the feature won't/will be enabled.
32 *
33 * @param string the synthetic value for display_mode (see �1 a few
34 * lines above for explanations)
35 * @param integer the total number of rows returned by the sql query
36 * without any programmatically appended "LIMIT" clause
37 * (just a copy of $unlim_num_rows if it exists, else
38 * computed inside this function)
39 *
40 * @return array an array with explicit indexes for all the display
41 * elements
42 *
43 * @global string the database name
44 * @global string the table name
45 * @global integer the total number of rows returned by the sql query
46 * without any programmatically appended "LIMIT" clause
47 * @global array the properties of the fields returned by the query
48 * @global string the url to return to in case of error in a sql
49 * statement
50 *
51 * @access private
52 *
53 * @see PMA_displayTable()
54 */
55 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
56 {
57 global $db, $table;
58 global $unlim_num_rows, $fields_meta;
59 global $err_url;
60  
61 // 1. Initializes the $do_display array
62 $do_display = array();
63 $do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
64 $do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3];
65 $do_display['sort_lnk'] = (string) $the_disp_mode[4];
66 $do_display['nav_bar'] = (string) $the_disp_mode[5];
67 $do_display['ins_row'] = (string) $the_disp_mode[6];
68 $do_display['bkm_form'] = (string) $the_disp_mode[7];
69 $do_display['text_btn'] = (string) $the_disp_mode[8];
70 $do_display['pview_lnk'] = (string) $the_disp_mode[9];
71  
72 // 2. Display mode is not "false for all elements" -> updates the
73 // display mode
74 if ($the_disp_mode != 'nnnn000000') {
75 // 2.0 Print view -> set all elements to FALSE!
76 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
77 $do_display['edit_lnk'] = 'nn'; // no edit link
78 $do_display['del_lnk'] = 'nn'; // no delete link
79 $do_display['sort_lnk'] = (string) '0';
80 $do_display['nav_bar'] = (string) '0';
81 $do_display['ins_row'] = (string) '0';
82 $do_display['bkm_form'] = (string) '0';
83 $do_display['text_btn'] = (string) '0';
84 $do_display['pview_lnk'] = (string) '0';
85 }
86 // 2.1 Statement is a "SELECT COUNT", a
87 // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
88 // contains a "PROC ANALYSE" part
89 elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
90 $do_display['edit_lnk'] = 'nn'; // no edit link
91 $do_display['del_lnk'] = 'nn'; // no delete link
92 $do_display['sort_lnk'] = (string) '0';
93 $do_display['nav_bar'] = (string) '0';
94 $do_display['ins_row'] = (string) '0';
95 $do_display['bkm_form'] = (string) '1';
96 if ($GLOBALS['is_analyse']) {
97 $do_display['text_btn'] = (string) '1';
98 } else {
99 $do_display['text_btn'] = (string) '0';
100 }
101 $do_display['pview_lnk'] = (string) '1';
102 }
103 // 2.2 Statement is a "SHOW..."
104 elseif ($GLOBALS['is_show']) {
105 // 2.2.1 TODO : defines edit/delete links depending on show statement
106 $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which);
107 if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
108 $do_display['edit_lnk'] = 'nn'; // no edit link
109 $do_display['del_lnk'] = 'kp'; // "kill process" type edit link
110 } else {
111 // Default case -> no links
112 $do_display['edit_lnk'] = 'nn'; // no edit link
113 $do_display['del_lnk'] = 'nn'; // no delete link
114 }
115 // 2.2.2 Other settings
116 $do_display['sort_lnk'] = (string) '0';
117 $do_display['nav_bar'] = (string) '0';
118 $do_display['ins_row'] = (string) '0';
119 $do_display['bkm_form'] = (string) '1';
120 $do_display['text_btn'] = (string) '1';
121 $do_display['pview_lnk'] = (string) '1';
122 }
123 // 2.3 Other statements (ie "SELECT" ones) -> updates
124 // $do_display['edit_lnk'], $do_display['del_lnk'] and
125 // $do_display['text_btn'] (keeps other default values)
126 else {
127 $prev_table = $fields_meta[0]->table;
128 $do_display['text_btn'] = (string) '1';
129 for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) {
130 $is_link = ($do_display['edit_lnk'] != 'nn'
131 || $do_display['del_lnk'] != 'nn'
132 || $do_display['sort_lnk'] != '0'
133 || $do_display['ins_row'] != '0');
134 // 2.3.2 Displays edit/delete/sort/insert links?
135 if ($is_link
136 && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
137 $do_display['edit_lnk'] = 'nn'; // don't display links
138 $do_display['del_lnk'] = 'nn';
139 // TODO: May be problematic with same fields names in
140 // two joined table.
141 // $do_display['sort_lnk'] = (string) '0';
142 $do_display['ins_row'] = (string) '0';
143 if ($do_display['text_btn'] == '1') {
144 break;
145 }
146 } // end if (2.3.2)
147 // 2.3.3 Always display print view link
148 $do_display['pview_lnk'] = (string) '1';
149 $prev_table = $fields_meta[$i]->table;
150 } // end for
151 } // end if..elseif...else (2.1 -> 2.3)
152 } // end if (2)
153  
154 // 3. Gets the total number of rows if it is unknown
155 if (isset($unlim_num_rows) && $unlim_num_rows != '') {
156 $the_total = $unlim_num_rows;
157 } elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
158 && (isset($db) && strlen($db) && !empty($table))) {
159 $the_total = PMA_countRecords($db, $table, TRUE);
160 }
161  
162 // 4. If navigation bar or sorting fields names urls should be
163 // displayed but there is only one row, change these settings to
164 // false
165 if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') {
166  
167 if (isset($unlim_num_rows) && $unlim_num_rows < 2) {
168 // garvin: force display of navbar for vertical/horizontal display-choice.
169 // $do_display['nav_bar'] = (string) '0';
170 $do_display['sort_lnk'] = (string) '0';
171 }
172  
173 } // end if (3)
174  
175 // 5. Updates the synthetic var
176 $the_disp_mode = join('', $do_display);
177  
178 return $do_display;
179 } // end of the 'PMA_setDisplayMode()' function
180  
181  
182 /**
183 * Displays a navigation bar to browse among the results of a sql query
184 *
185 * @param integer the offset for the "next" page
186 * @param integer the offset for the "previous" page
187 * @param string the url-encoded query
188 *
189 * @global string $db the database name
190 * @global string $table the table name
191 * @global string $goto the url to go back in case of errors
192 * @global boolean $dontlimitchars whether to limit the number of displayed
193 * characters of text type fields or not
194 * @global integer $num_rows the total number of rows returned by the
195 * sql query
196 * @global integer $unlim_num_rows the total number of rows returned by the
197 * sql any programmatically appended "LIMIT" clause
198 * @global integer $pos the current position in results
199 * @global mixed $session_max_rows the maximum number of rows per page
200 * ('all' = no limit)
201 * @global string $disp_direction the display mode
202 * (horizontal / vertical / horizontalflipped)
203 * @global integer $repeat_cells the number of row to display between two
204 * table headers
205 * @global boolean $is_innodb whether its InnoDB or not
206 * @global array $showtable table definitions
207 *
208 * @access private
209 *
210 * @see PMA_displayTable()
211 */
212 function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
213 {
214 global $db, $table, $goto, $dontlimitchars;
215 global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
216 global $disp_direction, $repeat_cells;
217 global $is_innodb;
218 global $showtable;
219  
220 // FIXME: move this to a central place
221 // FIXME: for other future table types
222 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
223  
224 ?>
225  
226 <!-- Navigation bar -->
227 <table border="0" cellpadding="2" cellspacing="0">
228 <tr>
229 <?php
230 // Move to the beginning or to the previous page
231 if ($pos > 0 && $session_max_rows != 'all') {
232 // loic1: patch #474210 from Gosha Sakovich - part 1
233 if ($GLOBALS['cfg']['NavigationBarIconic']) {
234 $caption1 = '&lt;&lt;';
235 $caption2 = ' &lt; ';
236 $title1 = ' title="' . $GLOBALS['strPos1'] . '"';
237 $title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
238 } else {
239 $caption1 = $GLOBALS['strPos1'] . ' &lt;&lt;';
240 $caption2 = $GLOBALS['strPrevious'] . ' &lt;';
241 $title1 = '';
242 $title2 = '';
243 } // end if... else...
244 ?>
245 <td>
246 <form action="sql.php" method="post">
247 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
248 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
249 <input type="hidden" name="pos" value="0" />
250 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
251 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
252 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
253 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
254 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
255 <input type="submit" name="navig" value="<?php echo $caption1; ?>"<?php echo $title1; ?> />
256 </form>
257 </td>
258 <td>
259 <form action="sql.php" method="post">
260 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
261 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
262 <input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
263 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
264 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
265 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
266 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
267 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
268 <input type="submit" name="navig" value="<?php echo $caption2; ?>"<?php echo $title2; ?> />
269 </form>
270 </td>
271 <?php
272 } // end move back
273 ?>
274 <td>
275 &nbsp;&nbsp;&nbsp;
276 </td>
277 <td align="center">
278 <form action="sql.php" method="post"
279 onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 1) &amp;&amp; checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 0, <?php echo $unlim_num_rows - 1; ?>))">
280 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
281 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
282 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
283 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
284 <input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
285 <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()" />
286 <?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
287 <input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
288 <br />
289 <?php
290 // Display mode (horizontal/vertical and repeat headers)
291 $param1 = ' <select name="disp_direction">' . "\n"
292 . ' <option value="horizontal"' . (($disp_direction == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
293 . ' <option value="horizontalflipped"' . (($disp_direction == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
294 . ' <option value="vertical"' . (($disp_direction == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
295 . ' </select>' . "\n"
296 . ' ';
297 $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" class="textfield" />' . "\n"
298 . ' ';
299 echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
300 ?>
301 </form>
302 </td>
303 <td>
304 &nbsp;&nbsp;&nbsp;
305 </td>
306 <?php
307 // Move to the next page or to the last one
308 if (($pos + $session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
309 && $session_max_rows != 'all') {
310 // loic1: patch #474210 from Gosha Sakovich - part 2
311 if ($GLOBALS['cfg']['NavigationBarIconic']) {
312 $caption3 = ' &gt; ';
313 $caption4 = '&gt;&gt;';
314 $title3 = ' title="' . $GLOBALS['strNext'] . '"';
315 $title4 = ' title="' . $GLOBALS['strEnd'] . '"';
316 } else {
317 $caption3 = '&gt; ' . $GLOBALS['strNext'];
318 $caption4 = '&gt;&gt; ' . $GLOBALS['strEnd'];
319 $title3 = '';
320 $title4 = '';
321 } // end if... else...
322 echo "\n";
323 ?>
324 <td>
325 <form action="sql.php" method="post">
326 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
327 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
328 <input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
329 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
330 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
331 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
332 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
333 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
334 <input type="submit" name="navig" value="<?php echo $caption3; ?>"<?php echo $title3; ?> />
335 </form>
336 </td>
337 <td>
338 <form action="sql.php" method="post"
339 onsubmit="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
340 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
341 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
342 <input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $session_max_rows)- 1) * $session_max_rows); ?>" />
343 <?php
344 if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
345 echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
346 // no backquote around this message
347 $onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], FALSE) . '\')"';
348 }
349 ?>
350 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
351 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
352 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
353 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
354 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
355 <input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> <?php echo (empty($onclick) ? '' : $onclick); ?>/>
356 </form>
357 </td>
358 <?php
359 } // end move toward
360  
361  
362 //page redirection
363 $pageNow = @floor($pos / $session_max_rows) + 1;
364 $nbTotalPage = @ceil($unlim_num_rows / $session_max_rows);
365  
366 if ($nbTotalPage > 1){ //if1
367 ?>
368 <td>
369 &nbsp;&nbsp;&nbsp;
370 </td>
371 <td>
372 <?php //<form> for keep the form alignment of button < and << ?>
373 <form action="none">
374 <?php echo PMA_pageselector(
375 'sql.php?sql_query=' . $encoded_query .
376 '&amp;session_max_rows=' . $session_max_rows .
377 '&amp;disp_direction=' . $disp_direction .
378 '&amp;repeat_cells=' . $repeat_cells .
379 '&amp;goto=' . $goto .
380 '&amp;dontlimitchars=' . $dontlimitchars .
381 '&amp;' . PMA_generate_common_url($db, $table) .
382 '&amp;',
383 $session_max_rows,
384 $pageNow,
385 $nbTotalPage
386 );
387 ?>
388 </form>
389 </td>
390 <?php
391 } //_if1
392  
393  
394 // Show all the records if allowed
395 if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
396 echo "\n";
397 ?>
398 <td>
399 &nbsp;&nbsp;&nbsp;
400 </td>
401 <td>
402 <form action="sql.php" method="post">
403 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
404 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
405 <input type="hidden" name="pos" value="0" />
406 <input type="hidden" name="session_max_rows" value="all" />
407 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
408 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
409 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
410 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
411 <input type="submit" name="navig" value="<?php echo $GLOBALS['strShowAll']; ?>" />
412 </form>
413 </td>
414 <?php
415 } // end show all
416 echo "\n";
417 ?>
418 </tr>
419 </table>
420  
421 <?php
422 } // end of the 'PMA_displayTableNavigation()' function
423  
424  
425 /**
426 * Displays the headers of the results table
427 *
428 * @param array which elements to display
429 * @param array the list of fields properties
430 * @param integer the total number of fields returned by the sql query
431 * @param array the analyzed query
432 *
433 * @return boolean always true
434 *
435 * @global string $db the database name
436 * @global string $table the table name
437 * @global string $goto the url to go back in case of errors
438 * @global boolean $dontlimitchars whether to limit the number of displayed
439 * characters of text type fields or not
440 * @global string $sql_query the sql query
441 * @global integer $num_rows the total number of rows returned by the
442 * sql query
443 * @global integer $pos the current position in results
444 * @global integer $session_max_rows the maximum number of rows per page
445 * @global array $vertical_display informations used with vertical display
446 * mode
447 * @global string $disp_direction the display mode
448 * (horizontal/vertical/horizontalflipped)
449 * @global integer $repeat_cellsthe number of row to display between two
450 * table headers
451 *
452 * @access private
453 *
454 * @see PMA_displayTable()
455 */
456 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
457 {
458 global $db, $table, $goto, $dontlimitchars;
459 global $sql_query, $num_rows, $pos, $session_max_rows;
460 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
461  
462 if ($analyzed_sql == '') {
463 $analyzed_sql = array();
464 }
465  
466 // can the result be sorted?
467 if ($is_display['sort_lnk'] == '1') {
468  
469 // Just as fallback
470 $unsorted_sql_query = $sql_query;
471 if (isset($analyzed_sql[0]['unsorted_query'])) {
472 $unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
473 }
474  
475 // we need $sort_expression and $sort_expression_nodir
476 // even if there are many table references
477  
478 $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
479  
480 // Get rid of ASC|DESC (TODO: analyzer)
481 preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
482 $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
483  
484 // sorting by indexes, only if it makes sense (only one table ref)
485 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
486 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
487 isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
488  
489 // grab indexes data:
490 PMA_DBI_select_db($db);
491 if (!defined('PMA_IDX_INCLUDED')) {
492 $ret_keys = PMA_get_indexes($table);
493 }
494  
495 $prev_index = '';
496 foreach ($ret_keys as $row) {
497  
498 if ($row['Key_name'] != $prev_index ){
499 $indexes[] = $row['Key_name'];
500 $prev_index = $row['Key_name'];
501 }
502 $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
503 $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
504 if (isset($row['Cardinality'])) {
505 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
506 }
507 // I don't know what does the following column mean....
508 // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
509 $indexes_info[$row['Key_name']]['Comment'] = (isset($row['Comment']))
510 ? $row['Comment']
511 : '';
512 $indexes_info[$row['Key_name']]['Index_type'] = (isset($row['Index_type']))
513 ? $row['Index_type']
514 : '';
515  
516 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
517 if (isset($row['Sub_part'])) {
518 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
519 }
520 } // end while
521  
522 // do we have any index?
523 if (isset($indexes_data)) {
524  
525 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
526 $span = $fields_cnt;
527 if ($is_display['edit_lnk'] != 'nn') {
528 $span++;
529 }
530 if ($is_display['del_lnk'] != 'nn') {
531 $span++;
532 }
533 if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
534 $span++;
535 }
536 } else {
537 $span = $num_rows + floor($num_rows/$repeat_cells) + 1;
538 }
539  
540 echo '<form action="sql.php" method="post">' . "\n";
541 echo PMA_generate_common_hidden_inputs($db, $table, 5);
542 echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
543 echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
544 echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
545 echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
546 echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
547 echo $GLOBALS['strSortByKey'] . ': <select name="sql_query">' . "\n";
548 $used_index = false;
549 $local_order = (isset($sort_expression) ? $sort_expression : '');
550 foreach ($indexes_data AS $key => $val) {
551 $asc_sort = '';
552 $desc_sort = '';
553 foreach ($val AS $key2 => $val2) {
554 $asc_sort .= PMA_backquote($val2['Column_name']) . ' ASC , ';
555 $desc_sort .= PMA_backquote($val2['Column_name']) . ' DESC , ';
556 }
557 $asc_sort = substr($asc_sort, 0, -3);
558 $desc_sort = substr($desc_sort, 0, -3);
559 $used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
560 echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strAscending'] . ')</option>';
561 echo "\n";
562 echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>';
563 echo "\n";
564 }
565 echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"' ) . '>' . $GLOBALS['strNone'] . '</option>';
566 echo "\n";
567 echo '</select>' . "\n";
568 echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
569 echo "\n";
570 echo '</form>' . "\n";
571 }
572 }
573 }
574  
575  
576 $vertical_display['emptypre'] = 0;
577 $vertical_display['emptyafter'] = 0;
578 $vertical_display['textbtn'] = '';
579  
580  
581 // Start of form for multi-rows delete
582  
583 if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp' ) {
584 echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
585 echo PMA_generate_common_hidden_inputs($db, $table, 1);
586 echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
587 echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
588 echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
589 echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
590 echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
591 echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
592 }
593  
594 echo '<table id="table_results" class="data">' . "\n";
595 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
596 echo '<thead><tr>' . "\n";
597 }
598  
599 // 1. Displays the full/partial text button (part 1)...
600 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
601 $colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
602 ? ' colspan="3"'
603 : '';
604 } else {
605 $rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
606 ? ' rowspan="3"'
607 : '';
608 }
609 $text_url = 'sql.php?'
610 . PMA_generate_common_url($db, $table)
611 . '&amp;sql_query=' . urlencode($sql_query)
612 . '&amp;session_max_rows=' . $session_max_rows
613 . '&amp;pos=' . $pos
614 . '&amp;disp_direction=' . $disp_direction
615 . '&amp;repeat_cells=' . $repeat_cells
616 . '&amp;goto=' . $goto
617 . '&amp;dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
618 $text_message = '<img class="fulltext" src="' . $GLOBALS['pmaThemeImage'] . 's_'.($dontlimitchars ? 'partialtext' : 'fulltext') . '.png" width="50" height="20" alt="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" />';
619 $text_link = PMA_linkOrButton( $text_url, $text_message, array(), false );
620  
621 // ... before the result table
622 if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
623 && $is_display['text_btn'] == '1') {
624 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
625 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
626 ?>
627 <th colspan="<?php echo $fields_cnt; ?>"><?php echo $text_link; ?></th>
628 </tr>
629 <tr>
630 <?php
631 } // end horizontal/horizontalflipped mode
632 else {
633 ?>
634 <tr>
635 <th colspan="<?php echo $num_rows + floor($num_rows/$repeat_cells) + 1; ?>">
636 <?php echo $text_link; ?></th>
637 </tr>
638 <?php
639 } // end vertical mode
640 }
641  
642 // ... at the left column of the result table header if possible
643 // and required
644 elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
645 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
646 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
647 ?>
648 <th <?php echo $colspan; ?>><?php echo $text_link; ?></th>
649 <?php
650 } // end horizontal/horizontalflipped mode
651 else {
652 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
653 . ' ' . $text_link . "\n"
654 . ' </th>' . "\n";
655 } // end vertical mode
656 }
657  
658 // ... elseif no button, displays empty(ies) col(s) if required
659 elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft']
660 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
661 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
662 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
663 ?>
664 <td<?php echo $colspan; ?>></td>
665 <?php
666 } // end horizontal/horizontalfipped mode
667 else {
668 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
669 } // end vertical mode
670 }
671  
672 // 2. Displays the fields' name
673 // 2.0 If sorting links should be used, checks if the query is a "JOIN"
674 // statement (see 2.1.3)
675  
676 // 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
677 // Do not show comments, if using horizontalflipped mode, because of space usage
678 if ($GLOBALS['cfg']['ShowBrowseComments'] && ($GLOBALS['cfgRelation']['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) && $disp_direction != 'horizontalflipped') {
679 $comments_map = array();
680 if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
681 foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
682 $tb = $tbl['table_true_name'];
683 $comments_map[$tb] = PMA_getComments($db, $tb);
684 unset($tb);
685 }
686 }
687 }
688  
689 if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
690 require_once('./libraries/transformations.lib.php');
691 $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
692 }
693  
694 if ($is_display['sort_lnk'] == '1') {
695 //$is_join = preg_match('@(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN@im', $sql_query, $select_stt);
696 $is_join = (isset($analyzed_sql[0]['queryflags']['join']) ?TRUE:FALSE);
697 $select_expr = $analyzed_sql[0]['select_expr_clause'];
698 } else {
699 $is_join = FALSE;
700 }
701  
702 // garvin: See if we have to highlight any header fields of a WHERE query.
703 // Uses SQL-Parser results.
704 $highlight_columns = array();
705 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
706 isset($analyzed_sql[0]['where_clause_identifiers'])) {
707  
708 $wi = 0;
709 if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
710 foreach ($analyzed_sql[0]['where_clause_identifiers'] AS $wci_nr => $wci) {
711 $highlight_columns[$wci] = 'true';
712 }
713 }
714 }
715  
716 for ($i = 0; $i < $fields_cnt; $i++) {
717 // garvin: See if this column should get highlight because it's used in the
718 // where-query.
719 if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
720 $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
721 } else {
722 $column_style = '';
723 }
724  
725 // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
726 if (isset($comments_map) &&
727 isset($comments_map[$fields_meta[$i]->table]) &&
728 isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
729 $comments = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) . '</span>';
730 } else {
731 $comments = '';
732 }
733  
734 // 2.1 Results can be sorted
735 if ($is_display['sort_lnk'] == '1') {
736  
737 // 2.1.1 Checks if the table name is required; it's the case
738 // for a query with a "JOIN" statement and if the column
739 // isn't aliased, or in queries like
740 // SELECT `1`.`master_field` , `2`.`master_field`
741 // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
742  
743 if (($is_join
744 && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts))
745 || ( isset($analyzed_sql[0]['select_expr'][$i]['expr'])
746 && isset($analyzed_sql[0]['select_expr'][$i]['column'])
747 && $analyzed_sql[0]['select_expr'][$i]['expr'] !=
748 $analyzed_sql[0]['select_expr'][$i]['column']
749 && isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) ) {
750 $sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . ';
751 } else {
752 $sort_tbl = '';
753 }
754 // 2.1.2 Checks if the current column is used to sort the
755 // results
756 if (empty($sort_expression)) {
757 $is_in_sort = FALSE;
758 } else {
759 // field name may be preceded by a space, or any number
760 // of characters followed by a dot (tablename.fieldname)
761 // so do a direct comparison
762 // for the sort expression (avoids problems with queries
763 // like "SELECT id, count(id)..." and clicking to sort
764 // on id or on count(id) )
765 $is_in_sort = ($sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? TRUE : FALSE);
766 }
767 // 2.1.3 Check the field name for backquotes.
768 // If it contains some, it's probably a function column
769 // like 'COUNT(`field`)'
770 if (strpos(' ' . $fields_meta[$i]->name, '`') > 0) {
771 $sort_order = ' ORDER BY \'' . $fields_meta[$i]->name . '\' ';
772 } else {
773 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name) . ' ';
774 }
775  
776 // 2.1.4 Do define the sorting url
777 if (!$is_in_sort) {
778 // loic1: patch #455484 ("Smart" order)
779 $GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']);
780 if ($GLOBALS['cfg']['Order'] == 'SMART') {
781 $GLOBALS['cfg']['Order'] = (preg_match('@time|date@i', $fields_meta[$i]->type)) ? 'DESC' : 'ASC';
782 }
783 $sort_order .= $GLOBALS['cfg']['Order'];
784 $order_img = '';
785 } elseif (preg_match('@[[:space:]]ASC$@i', $sort_expression)) {
786 $sort_order .= ' DESC';
787 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
788 } elseif (preg_match('@[[:space:]]DESC$@i', $sort_expression)) {
789 $sort_order .= ' ASC';
790 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" id="soimg' . $i . '" />';
791 } else {
792 $sort_order .= ' DESC';
793 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
794 }
795  
796 if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
797 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
798 } else {
799 $sorted_sql_query = $unsorted_sql_query . $sort_order;
800 }
801 $url_query = PMA_generate_common_url($db, $table)
802 . '&amp;pos=' . $pos
803 . '&amp;session_max_rows=' . $session_max_rows
804 . '&amp;disp_direction=' . $disp_direction
805 . '&amp;repeat_cells=' . $repeat_cells
806 . '&amp;dontlimitchars=' . $dontlimitchars
807 . '&amp;sql_query=' . urlencode($sorted_sql_query);
808 $order_url = 'sql.php?' . $url_query;
809  
810 // 2.1.5 Displays the sorting url
811 // added 20004-06-09: Michael Keck <mail@michaelkeck.de>
812 // enable sord order swapping for image
813 $order_link_params = array();
814 if (isset($order_img) && $order_img!='') {
815 if (strstr($order_img, 'asc')) {
816 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
817 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
818 } elseif (strstr($order_img, 'desc')) {
819 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
820 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
821 }
822 }
823 if ( $disp_direction == 'horizontalflipped'
824 && $GLOBALS['cfg']['HeaderFlipType'] == 'css' ) {
825 $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
826 }
827 $order_link_params['title'] = $GLOBALS['strSort'];
828 $order_link_content = ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
829 $order_link = PMA_linkOrButton( $order_url, $order_link_content . $order_img, $order_link_params, false, true );
830  
831 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
832 ?>
833 <th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') { echo 'valign="bottom"'; } ?>>
834 <?php echo $order_link; ?>
835 <?php echo $comments; ?>
836 </th>
837 <?php
838 }
839 $vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
840 . $order_link
841 . $comments
842 . ' </th>' . "\n";
843 } // end if (2.1)
844  
845 // 2.2 Results can't be sorted
846 else {
847 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
848 ?>
849 <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;"' : ''); ?>>
850 <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake'? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name)) . "\n"; ?>
851 <?php echo $comments; ?>
852 </th>
853 <?php
854 }
855 $vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
856 . ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
857 . $comments
858 . ' </th>';
859 } // end else (2.2)
860 } // end for
861  
862 // 3. Displays the full/partial text button (part 2) at the right
863 // column of the result table header if possible and required...
864 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
865 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
866 && $is_display['text_btn'] == '1') {
867 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
868 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
869 echo "\n";
870 ?>
871 <th <?php echo $colspan; ?>>
872 <?php echo $text_link; ?>
873 </th>
874 <?php
875 } // end horizontal/horizontalflipped mode
876 else {
877 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
878 . ' ' . $text_link . "\n"
879 . ' </th>' . "\n";
880 } // end vertical mode
881 }
882  
883 // ... elseif no button, displays empty cols if required
884 // (unless coming from Browse mode print view)
885 elseif ($GLOBALS['cfg']['ModifyDeleteAtRight']
886 && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
887 && (!$GLOBALS['is_header_sent'])) {
888 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
889 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
890 echo "\n";
891 ?>
892 <td<?php echo $colspan; ?>></td>
893 <?php
894 } // end horizontal/horizontalflipped mode
895 else {
896 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
897 } // end vertical mode
898 }
899  
900 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
901 ?>
902 </tr>
903 </thead>
904 <?php
905 }
906  
907 return TRUE;
908 } // end of the 'PMA_displayTableHeaders()' function
909  
910  
911  
912 /**
913 * Displays the body of the results table
914 *
915 * @param integer the link id associated to the query which results have
916 * to be displayed
917 * @param array which elements to display
918 * @param array the list of relations
919 * @param array the analyzed query
920 *
921 * @return boolean always true
922 *
923 * @global string $db the database name
924 * @global string $table the table name
925 * @global string $goto the url to go back in case of errors
926 * @global boolean $dontlimitchars whether to limit the number of displayed
927 * characters of text type fields or not
928 * @global string $sql_query the sql query
929 * @global integer $pos the current position in results
930 * @global integer $session_max_rows the maximum number of rows per page
931 * @global array $fields_meta the list of fields properties
932 * @global integer $fields_cnt the total number of fields returned by
933 * the sql query
934 * @global array $vertical_display informations used with vertical display
935 * mode
936 * @global string $disp_direction the display mode
937 * (horizontal/vertical/horizontalflipped)
938 * @global integer $repeat_cells the number of row to display between two
939 * table headers
940 * @global array $highlight_columns collumn names to highlight
941 * @gloabl array $row current row data
942 *
943 * @access private
944 *
945 * @see PMA_displayTable()
946 */
947 function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
948 global $db, $table, $goto, $dontlimitchars;
949 global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
950 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
951 global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
952  
953 $url_sql_query = $sql_query;
954  
955 // query without conditions to shorten urls when needed, 200 is just
956 // guess, it should depend on remaining url length
957  
958 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
959 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
960 strlen($sql_query) > 200) {
961  
962 $url_sql_query = 'SELECT ';
963 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
964 $url_sql_query .= ' DISTINCT ';
965 }
966 $url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
967 if (!empty($analyzed_sql[0]['from_clause'])) {
968 $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
969 }
970 }
971  
972 if (!is_array($map)) {
973 $map = array();
974 }
975 $row_no = 0;
976 $vertical_display['edit'] = array();
977 $vertical_display['delete'] = array();
978 $vertical_display['data'] = array();
979 $vertical_display['row_delete'] = array();
980  
981 // Correction uva 19991216 in the while below
982 // Previous code assumed that all tables have keys, specifically that
983 // the phpMyAdmin GUI should support row delete/edit only for such
984 // tables.
985 // Although always using keys is arguably the prescribed way of
986 // defining a relational table, it is not required. This will in
987 // particular be violated by the novice.
988 // We want to encourage phpMyAdmin usage by such novices. So the code
989 // below has been changed to conditionally work as before when the
990 // table being displayed has one or more keys; but to display
991 // delete/edit options correctly for tables without keys.
992  
993 // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
994 // to get the NULL values
995  
996 // rabus: This function needs a little rework.
997 // Using MYSQL_BOTH just pollutes the memory!
998  
999 // ne0x: Use function PMA_DBI_fetch_array() due to mysqli
1000 // compatibility. Now this function is wrapped.
1001  
1002 $odd_row = true;
1003 while ($row = PMA_DBI_fetch_row($dt_result)) {
1004 // lem9: "vertical display" mode stuff
1005 if ( $row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells)
1006 && ( $disp_direction == 'horizontal'
1007 || $disp_direction == 'horizontalflipped') )
1008 {
1009 echo '<tr>' . "\n";
1010 if ( $vertical_display['emptypre'] > 0 ) {
1011 echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n"
1012 .' &nbsp;</th>' . "\n";
1013 }
1014  
1015 foreach ( $vertical_display['desc'] as $val ) {
1016 echo $val;
1017 }
1018  
1019 if ( $vertical_display['emptyafter'] > 0 ) {
1020 echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n"
1021 .' &nbsp;</th>' . "\n";
1022 }
1023 echo '</tr>' . "\n";
1024 } // end if
1025  
1026 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1027 // loic1: pointer code part
1028 echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
1029 $odd_row = ! $odd_row;
1030 $bgcolor = '';
1031 } elseif (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
1032 $bgcolor = ' bgcolor="#ffffff" ';
1033 } else {
1034 $bgcolor = ' bgcolor="' . ($row_no % 2 ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'] ) . '" ';
1035 }
1036  
1037  
1038 // 1. Prepares the row (gets primary keys to use)
1039 // 1.1 Results from a "SELECT" statement -> builds the
1040 // "primary" key to use in links
1041 $uva_condition = urlencode(PMA_getUvaCondition($dt_result, $fields_cnt, $fields_meta, $row));
1042  
1043 // 1.2 Defines the urls for the modify/delete link(s)
1044 $url_query = PMA_generate_common_url($db, $table)
1045 . '&amp;pos=' . $pos
1046 . '&amp;session_max_rows=' . $session_max_rows
1047 . '&amp;disp_direction=' . $disp_direction
1048 . '&amp;repeat_cells=' . $repeat_cells
1049 . '&amp;dontlimitchars=' . $dontlimitchars;
1050  
1051 if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
1052 // We need to copy the value or else the == 'both' check will always return true
1053  
1054 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1055 $iconic_spacer = '<div class="nowrap">';
1056 } else {
1057 $iconic_spacer = '';
1058 }
1059  
1060 // 1.2.1 Modify link(s)
1061 if ($is_display['edit_lnk'] == 'ur') { // update row case
1062 $lnk_goto = 'sql.php';
1063  
1064 $edit_url = 'tbl_change.php'
1065 . '?' . $url_query
1066 . '&amp;primary_key=' . $uva_condition
1067 . '&amp;sql_query=' . urlencode($url_sql_query)
1068 . '&amp;goto=' . urlencode($lnk_goto);
1069 if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
1070 $edit_str = $GLOBALS['strEdit'];
1071 } else {
1072 $edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />';
1073 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1074 $edit_str .= ' ' . $GLOBALS['strEdit'] . '</div>';
1075 }
1076 }
1077 } // end if (1.2.1)
1078  
1079 if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db'] && isset($row[1]) && isset($row[0])) {
1080 $bookmark_go = '<a href="import.php?'
1081 . PMA_generate_common_url($row[1], '')
1082 . '&amp;id_bookmark=' . $row[0]
1083 . '&amp;action_bookmark=0'
1084 . '&amp;action_bookmark_all=1'
1085 . '&amp;SQL=' . $GLOBALS['strExecuteBookmarked']
1086 .' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
1087  
1088 if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
1089 $bookmark_go .= $GLOBALS['strExecuteBookmarked'];
1090 } else {
1091 $bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />';
1092 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1093 $bookmark_go .= ' ' . $GLOBALS['strExecuteBookmarked'] . '</div>';
1094 }
1095 }
1096  
1097 $bookmark_go .= '</a>';
1098 } else {
1099 $bookmark_go = '';
1100 }
1101  
1102 // 1.2.2 Delete/Kill link(s)
1103 if ($is_display['del_lnk'] == 'dr') { // delete row case
1104 $lnk_goto = 'sql.php'
1105 . '?' . str_replace('&amp;', '&', $url_query)
1106 . '&sql_query=' . urlencode($url_sql_query)
1107 . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1108 . '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto);
1109 $del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . '+LIMIT+1';
1110 $del_url = 'sql.php'
1111 . '?' . $url_query
1112 . '&amp;sql_query=' . $del_query
1113 . '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1114 . '&amp;goto=' . urlencode($lnk_goto);
1115 $js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
1116 . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE))
1117 . ' LIMIT 1';
1118 if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
1119 $del_str = $GLOBALS['strDelete'];
1120 } else {
1121 $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />';
1122 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1123 $del_str .= ' ' . $GLOBALS['strDelete'] . '</div>';
1124 }
1125 }
1126 } elseif ($is_display['del_lnk'] == 'kp') { // kill process case
1127 $lnk_goto = 'sql.php'
1128 . '?' . str_replace('&amp;', '&', $url_query)
1129 . '&sql_query=' . urlencode($url_sql_query)
1130 . '&goto=main.php';
1131 $del_url = 'sql.php?'
1132 . PMA_generate_common_url('mysql')
1133 . '&amp;sql_query=' . urlencode('KILL ' . $row[0])
1134 . '&amp;goto=' . urlencode($lnk_goto);
1135 $del_query = urlencode('KILL ' . $row[0]);
1136 $js_conf = 'KILL ' . $row[0];
1137 if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
1138 $del_str = $GLOBALS['strKill'];
1139 } else {
1140 $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />';
1141 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1142 $del_str .= ' ' . $GLOBALS['strKill'] . '</div>';
1143 }
1144 }
1145 } // end if (1.2.2)
1146  
1147 // 1.3 Displays the links at left if required
1148 if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
1149 && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
1150 $doWriteModifyAt = 'left';
1151 require('./libraries/display_tbl_links.lib.php');
1152 } // end if (1.3)
1153 } // end if (1)
1154  
1155 // 2. Displays the rows' values
1156 for ($i = 0; $i < $fields_cnt; ++$i) {
1157 $meta = $fields_meta[$i];
1158 // loic1: To fix bug #474943 under php4, the row pointer will
1159 // depend on whether the "is_null" php4 function is
1160 // available or not
1161 $pointer = (function_exists('is_null') ? $i : $meta->name);
1162 // garvin: See if this column should get highlight because it's used in the
1163 // where-query.
1164 if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) {
1165 $column_style = ' style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '" ';
1166 } else {
1167 $column_style = '';
1168 }
1169  
1170 if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
1171 if ($GLOBALS['cfg']['BrowsePointerColor'] == TRUE) {
1172 $column_style .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
1173 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');" ';
1174 }
1175 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
1176 $column_style .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1177 } else {
1178 $column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1179 }
1180 }// end if
1181  
1182 // garvin: Wrap MIME-transformations. [MIME]
1183 $default_function = 'default_function'; // default_function
1184 $transform_function = $default_function;
1185 $transform_options = array();
1186  
1187 if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
1188  
1189 if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) {
1190 $include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']);
1191  
1192 if (file_exists('./libraries/transformations/' . $include_file)) {
1193 $transformfunction_name = preg_replace('@(\.inc\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
1194  
1195 require_once('./libraries/transformations/' . $include_file);
1196  
1197 if (function_exists('PMA_transformation_' . $transformfunction_name)) {
1198 $transform_function = 'PMA_transformation_' . $transformfunction_name;
1199 $transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''));
1200 $meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
1201 }
1202 } // end if file_exists
1203 } // end if transformation is set
1204 } // end if mime/transformation works.
1205  
1206 $transform_options['wrapper_link'] = '?'
1207 . (isset($url_query) ? $url_query : '')
1208 . '&amp;primary_key=' . (isset($uva_condition) ? $uva_condition : '')
1209 . '&amp;sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '')
1210 . '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
1211 . '&amp;transform_key=' . urlencode($meta->name);
1212  
1213  
1214 // n u m e r i c
1215 if ($meta->numeric == 1) {
1216  
1217  
1218 // lem9: if two fields have the same name (this is possible
1219 // with self-join queries, for example), using $meta->name
1220 // will show both fields NULL even if only one is NULL,
1221 // so use the $pointer
1222 // (works only if function_exists('is_null')
1223 // PS: why not always work with the number ($i), since
1224 // the default second parameter of
1225 // mysql_fetch_array() is MYSQL_BOTH, so we always get
1226 // associative and numeric indices?
1227  
1228 //if (!isset($row[$meta->name])
1229 if (!isset($row[$i]) || is_null($row[$i])) {
1230 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
1231 } elseif ($row[$i] != '') {
1232 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . ' class="nowrap">';
1233  
1234 if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
1235 foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
1236 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1237 if (isset($alias) && strlen($alias)) {
1238 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1239 if ($alias == $meta->name) {
1240 $meta->name = $true_column;
1241 } // end if
1242 } // end if
1243 } // end while
1244 }
1245  
1246 if (isset($map[$meta->name])) {
1247 // Field to display from the foreign table?
1248 if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
1249 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1250 . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1251 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
1252 . ' = ' . $row[$i];
1253 $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
1254 if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
1255 list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
1256 } else {
1257 $dispval = $GLOBALS['strLinkNotFound'];
1258 }
1259 @PMA_DBI_free_result($dispresult);
1260 } else {
1261 $dispval = '';
1262 } // end if... else...
1263  
1264 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
1265 $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[-&gt;' . $dispval . ']</code>';
1266 } else {
1267 $title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1268  
1269 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
1270 . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1271 . '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
1272 . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>'
1273 . ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>';
1274 }
1275 } else {
1276 $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta));
1277 }
1278 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1279 } else {
1280 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . ' class="nowrap">&nbsp;</td>' . "\n";
1281 }
1282  
1283 // b l o b
1284  
1285 } elseif ($GLOBALS['cfg']['ShowBlob'] == FALSE && stristr($meta->type, 'BLOB')) {
1286 // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
1287 // TEXT fields type, however TEXT fields must be displayed
1288 // even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type
1289 // of the fields.
1290 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1291 if (stristr($field_flags, 'BINARY')) {
1292 $blobtext = '[BLOB';
1293 if (!isset($row[$i]) || is_null($row[$i])) {
1294 $blobtext .= ' - NULL';
1295 $blob_size = 0;
1296 } elseif (isset($row[$i])) {
1297 $blob_size = strlen($row[$i]);
1298 $display_blob_size = PMA_formatByteDown($blob_size, 3, 1);
1299 $blobtext .= ' - '. $display_blob_size[0] . ' ' . $display_blob_size[1];
1300 unset($display_blob_size);
1301 }
1302  
1303 $blobtext .= ']';
1304 if (strpos($transform_function, 'octetstream')) {
1305 $blobtext = $row[$i];
1306 }
1307 if ($blob_size > 0) {
1308 $blobtext = ($default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta));
1309 }
1310 unset($blob_size);
1311  
1312 $vertical_display['data'][$row_no][$i] = ' <td align="left"' . $column_style . $bgcolor . '>' . $blobtext . '</td>';
1313 } else {
1314 if (!isset($row[$i]) || is_null($row[$i])) {
1315 $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
1316 } elseif ($row[$i] != '') {
1317 // garvin: if a transform function for blob is set, none of these replacements will be made
1318 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
1319 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1320 }
1321 // loic1: displays all space characters, 4 space
1322 // characters for tabulations and <cr>/<lf>
1323 $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1324  
1325 $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '>' . $row[$i] . '</td>' . "\n";
1326 } else {
1327 $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '>&nbsp;</td>' . "\n";
1328 }
1329 }
1330 } else {
1331 if (!isset($row[$i]) || is_null($row[$i])) {
1332 $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
1333 } elseif ($row[$i] != '') {
1334 // loic1: support blanks in the key
1335 $relation_id = $row[$i];
1336  
1337 // nijel: Cut all fields to $GLOBALS['cfg']['LimitChars']
1338 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
1339 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1340 }
1341  
1342 // loic1: displays special characters from binaries
1343 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1344 if (stristr($field_flags, 'BINARY')) {
1345 $row[$i] = str_replace("\x00", '\0', $row[$i]);
1346 $row[$i] = str_replace("\x08", '\b', $row[$i]);
1347 $row[$i] = str_replace("\x0a", '\n', $row[$i]);
1348 $row[$i] = str_replace("\x0d", '\r', $row[$i]);
1349 $row[$i] = str_replace("\x1a", '\Z', $row[$i]);
1350 $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1351 }
1352 // loic1: displays all space characters, 4 space
1353 // characters for tabulations and <cr>/<lf>
1354 else {
1355 $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1356 }
1357  
1358 // garvin: transform functions may enable nowrapping:
1359 $function_nowrap = $transform_function . '_nowrap';
1360 $bool_nowrap = (($default_function != $transform_function && function_exists($function_nowrap)) ? $function_nowrap($transform_options) : false);
1361  
1362 // loic1: do not wrap if date field type
1363 $nowrap = ((preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap) ? ' nowrap="nowrap"' : '');
1364 $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . $nowrap . '>';
1365  
1366 if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
1367 foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
1368 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1369 if (isset($alias) && strlen($alias)) {
1370 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1371 if ($alias == $meta->name) {
1372 $meta->name = $true_column;
1373 } // end if
1374 } // end if
1375 } // end while
1376 }
1377  
1378 if (isset($map[$meta->name])) {
1379 // Field to display from the foreign table?
1380 if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
1381 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1382 . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1383 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
1384 . ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
1385 $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
1386 if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
1387 list($dispval) = PMA_DBI_fetch_row($dispresult);
1388 @PMA_DBI_free_result($dispresult);
1389 } else {
1390 $dispval = $GLOBALS['strLinkNotFound'];
1391 }
1392 } else {
1393 $dispval = '';
1394 }
1395 $title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1396  
1397 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
1398 . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1399 . '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
1400 . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
1401 . $row[$i] . '</a>';
1402 } else {
1403 $vertical_display['data'][$row_no][$i] .= $row[$i];
1404 }
1405 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1406 } else {
1407 $vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '>&nbsp;</td>' . "\n";
1408 }
1409 }
1410  
1411 // lem9: output stored cell
1412 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1413 echo $vertical_display['data'][$row_no][$i];
1414 }
1415  
1416 if (isset($vertical_display['rowdata'][$i][$row_no])) {
1417 $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
1418 } else {
1419 $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
1420 }
1421 } // end for (2)
1422  
1423 // 3. Displays the modify/delete links on the right if required
1424 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
1425 && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
1426 $doWriteModifyAt = 'right';
1427 require('./libraries/display_tbl_links.lib.php');
1428 } // end if (3)
1429  
1430 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1431 ?>
1432 </tr>
1433 <?php
1434 } // end if
1435  
1436 // 4. Gather links of del_urls and edit_urls in an array for later
1437 // output
1438 if (!isset($vertical_display['edit'][$row_no])) {
1439 $vertical_display['edit'][$row_no] = '';
1440 $vertical_display['delete'][$row_no] = '';
1441 $vertical_display['row_delete'][$row_no] = '';
1442 }
1443  
1444 $column_style_vertical = '';
1445 if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) {
1446 $column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
1447 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
1448 }
1449 $column_marker_vertical = '';
1450 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
1451 $column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');';
1452 }
1453  
1454 if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
1455 $vertical_display['row_delete'][$row_no] .= ' <td align="center" ' . $bgcolor . $column_style_vertical . '>' . "\n"
1456 . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $uva_condition . ']"'
1457 . ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"'
1458 . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
1459 . ' </td>' . "\n";
1460 } else {
1461 unset($vertical_display['row_delete'][$row_no]);
1462 }
1463  
1464 if (isset($edit_url)) {
1465 $vertical_display['edit'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n"
1466 . PMA_linkOrButton($edit_url, $edit_str, array(), FALSE)
1467 . $bookmark_go
1468 . ' </td>' . "\n";
1469 } else {
1470 unset($vertical_display['edit'][$row_no]);
1471 }
1472  
1473 if (isset($del_url)) {
1474 $vertical_display['delete'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n"
1475 . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)
1476 . ' </td>' . "\n";
1477 } else {
1478 unset($vertical_display['delete'][$row_no]);
1479 }
1480  
1481 echo (($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') ? "\n" : '');
1482 $row_no++;
1483 } // end while
1484  
1485 if (isset($url_query)) {
1486 $GLOBALS['url_query'] = $url_query;
1487 }
1488  
1489 return TRUE;
1490 } // end of the 'PMA_displayTableBody()' function
1491  
1492  
1493 /**
1494 * Do display the result table with the vertical direction mode.
1495 * Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
1496 *
1497 * @return boolean always true
1498 *
1499 * @global array $vertical_display the information to display
1500 * @global integer $repeat_cells the number of row to display between two
1501 * table headers
1502 *
1503 * @access private
1504 *
1505 * @see PMA_displayTable()
1506 */
1507 function PMA_displayVerticalTable()
1508 {
1509 global $vertical_display, $repeat_cells;
1510  
1511 // Displays "multi row delete" link at top if required
1512 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1513 echo '<tr>' . "\n";
1514 echo $vertical_display['textbtn'];
1515 $foo_counter = 0;
1516 foreach ($vertical_display['row_delete'] as $val) {
1517 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1518 echo '<th>&nbsp;</th>' . "\n";
1519 }
1520  
1521 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '', $val);
1522 $foo_counter++;
1523 } // end while
1524 echo '</tr>' . "\n";
1525 } // end if
1526  
1527 // Displays "edit" link at top if required
1528 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1529 echo '<tr>' . "\n";
1530 if (!is_array($vertical_display['row_delete'])) {
1531 echo $vertical_display['textbtn'];
1532 }
1533 $foo_counter = 0;
1534 foreach ($vertical_display['edit'] as $val) {
1535 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1536 echo ' <th>&nbsp;</th>' . "\n";
1537 }
1538  
1539 echo $val;
1540 $foo_counter++;
1541 } // end while
1542 echo '</tr>' . "\n";
1543 } // end if
1544  
1545 // Displays "delete" link at top if required
1546 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1547 echo '<tr>' . "\n";
1548 if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1549 echo $vertical_display['textbtn'];
1550 }
1551 $foo_counter = 0;
1552 foreach ($vertical_display['delete'] as $val) {
1553 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1554 echo '<th>&nbsp;</th>' . "\n";
1555 }
1556  
1557 echo $val;
1558 $foo_counter++;
1559 } // end while
1560 echo '</tr>' . "\n";
1561 } // end if
1562  
1563 // Displays data
1564 foreach ($vertical_display['desc'] AS $key => $val) {
1565  
1566 echo '<tr>' . "\n";
1567 echo $val;
1568  
1569 $foo_counter = 0;
1570 foreach ($vertical_display['rowdata'][$key] as $subval) {
1571 if (($foo_counter != 0) && ($repeat_cells != 0) and !($foo_counter % $repeat_cells)) {
1572 echo $val;
1573 }
1574  
1575 echo $subval;
1576 $foo_counter++;
1577 } // end while
1578  
1579 echo '</tr>' . "\n";
1580 } // end while
1581  
1582 // Displays "multi row delete" link at bottom if required
1583 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1584 echo '<tr>' . "\n";
1585 echo $vertical_display['textbtn'];
1586 $foo_counter = 0;
1587 foreach ($vertical_display['row_delete'] as $val) {
1588 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1589 echo '<th>&nbsp;</th>' . "\n";
1590 }
1591  
1592 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', 'r', $val);
1593 $foo_counter++;
1594 } // end while
1595 echo '</tr>' . "\n";
1596 } // end if
1597  
1598 // Displays "edit" link at bottom if required
1599 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1600 echo '<tr>' . "\n";
1601 if (!is_array($vertical_display['row_delete'])) {
1602 echo $vertical_display['textbtn'];
1603 }
1604 $foo_counter = 0;
1605 foreach ($vertical_display['edit'] as $val) {
1606 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1607 echo '<th>&nbsp;</th>' . "\n";
1608 }
1609  
1610 echo $val;
1611 $foo_counter++;
1612 } // end while
1613 echo '</tr>' . "\n";
1614 } // end if
1615  
1616 // Displays "delete" link at bottom if required
1617 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1618 echo '<tr>' . "\n";
1619 if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1620 echo $vertical_display['textbtn'];
1621 }
1622 $foo_counter = 0;
1623 foreach ($vertical_display['delete'] as $val) {
1624 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1625 echo '<th>&nbsp;</th>' . "\n";
1626 }
1627  
1628 echo $val;
1629 $foo_counter++;
1630 } // end while
1631 echo '</tr>' . "\n";
1632 }
1633  
1634 return TRUE;
1635 } // end of the 'PMA_displayVerticalTable' function
1636  
1637  
1638 /**
1639 * Displays a table of results returned by a sql query.
1640 * This function is called by the "sql.php" script.
1641 *
1642 * @param integer the link id associated to the query which results have
1643 * to be displayed
1644 * @param array the display mode
1645 * @param array the analyzed query
1646 *
1647 * @global string $db the database name
1648 * @global string $table the table name
1649 * @global string $goto the url to go back in case of errors
1650 * @global boolean $dontlimitchars whether to limit the number of displayed
1651 * characters of text type fields or not
1652 * @global string $sql_query the current sql query
1653 * @global integer $num_rows the total number of rows returned by the
1654 * sql query
1655 * @global integer $unlim_num_rows the total number of rows returned by the
1656 * sql query without any programmatically
1657 * appended "LIMIT" clause
1658 * @global integer $pos the current postion of the first record
1659 * to be displayed
1660 * @global array $fields_meta the list of fields properties
1661 * @global integer $fields_cnt the total number of fields returned by
1662 * the sql query
1663 * @global array $vertical_display informations used with vertical display
1664 * mode
1665 * @global string $disp_direction the display mode
1666 * (horizontal/vertical/horizontalflipped)
1667 * @global integer $repeat_cells the number of row to display between two
1668 * table headers
1669 * @global array $highlight_columns collumn names to highlight
1670 * @global array $cfgRelation the relation settings
1671 *
1672 * @access private
1673 *
1674 * @see PMA_showMessage(), PMA_setDisplayMode(),
1675 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1676 * PMA_displayTableBody()
1677 */
1678 function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
1679 {
1680 global $db, $table, $goto, $dontlimitchars;
1681 global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
1682 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
1683 global $cfgRelation;
1684  
1685 // 1. ----- Prepares the work -----
1686  
1687 // 1.1 Gets the informations about which functionnalities should be
1688 // displayed
1689 $total = '';
1690 $is_display = PMA_setDisplayMode($the_disp_mode, $total);
1691 if ($total == '') {
1692 unset($total);
1693 }
1694  
1695 // 1.2 Defines offsets for the next and previous pages
1696 if ($is_display['nav_bar'] == '1') {
1697 if (!isset($pos)) {
1698 $pos = 0;
1699 }
1700 if ($GLOBALS['session_max_rows'] == 'all') {
1701 $pos_next = 0;
1702 $pos_prev = 0;
1703 } else {
1704 $pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
1705 $pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
1706 if ($pos_prev < 0) {
1707 $pos_prev = 0;
1708 }
1709 }
1710 } // end if
1711  
1712 // 1.3 Urlencodes the query to use in input form fields
1713 $encoded_sql_query = urlencode($sql_query);
1714  
1715 // 2. ----- Displays the top of the page -----
1716  
1717 // 2.1 Displays a messages with position informations
1718 if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
1719 if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
1720 $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
1721 } else {
1722 $selectstring = '';
1723 }
1724 $last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total)
1725 ? $total - 1
1726 : $pos_next - 1;
1727 PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . PMA_formatNumber( $total, 0 ) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
1728 if (PMA_tableIsView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
1729 echo '<div class="notice">' . "\n";
1730 echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
1731 echo '</div>' . "\n";
1732 }
1733 } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1734 PMA_showMessage($GLOBALS['strSQLQuery']);
1735 }
1736  
1737 // 2.3 Displays the navigation bars
1738 if (!isset($table) || strlen(trim($table)) == 0) {
1739 if (isset($analyzed_sql[0]['query_type'])
1740 && $analyzed_sql[0]['query_type'] == 'SELECT') {
1741 // table does not always contain a real table name,
1742 // for example in MySQL 5.0.x, the query SHOW STATUS
1743 // returns STATUS as a table name
1744 $table = $fields_meta[0]->table;
1745 } else {
1746 $table = '';
1747 }
1748 }
1749 if ($is_display['nav_bar'] == '1') {
1750 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1751 echo "\n";
1752 } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1753 echo "\n" . '<br /><br />' . "\n";
1754 }
1755  
1756 // 2b ----- Get field references from Database -----
1757 // (see the 'relation' config variable)
1758 // loic1, 2002-03-02: extended to php3
1759  
1760 // init map
1761 $map = array();
1762  
1763 // find tables
1764 $target=array();
1765 if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
1766 foreach ($analyzed_sql[0]['table_ref'] AS $table_ref_position => $table_ref) {
1767 $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
1768 }
1769 }
1770 $tabs = '(\'' . join('\',\'', $target) . '\')';
1771  
1772 if ($cfgRelation['displaywork']) {
1773 if (! isset($table) || ! strlen($table)) {
1774 $exist_rel = FALSE;
1775 } else {
1776 $exist_rel = PMA_getForeigners($db, $table, '', 'both');
1777 if ($exist_rel) {
1778 foreach ($exist_rel AS $master_field => $rel) {
1779 $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
1780 $map[$master_field] = array($rel['foreign_table'],
1781 $rel['foreign_field'],
1782 $display_field,
1783 $rel['foreign_db']);
1784 } // end while
1785 } // end if
1786 } // end if
1787 } // end if
1788 // end 2b
1789  
1790 // 3. ----- Displays the results table -----
1791 PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
1792 $url_query='';
1793 echo '<tbody>' . "\n";
1794 PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
1795 echo '</tbody>' . "\n";
1796 // vertical output case
1797 if ($disp_direction == 'vertical') {
1798 PMA_displayVerticalTable();
1799 } // end if
1800 unset($vertical_display);
1801 ?>
1802 </table>
1803  
1804 <?php
1805 // 4. ----- Displays the link for multi-fields delete
1806  
1807 if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
1808  
1809 $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
1810  
1811 $uncheckall_url = 'sql.php?'
1812 . PMA_generate_common_url($db, $table)
1813 . '&amp;sql_query=' . urlencode($sql_query)
1814 . '&amp;pos=' . $pos
1815 . '&amp;session_max_rows=' . $GLOBALS['session_max_rows']
1816 . '&amp;pos=' . $pos
1817 . '&amp;disp_direction=' . $disp_direction
1818 . '&amp;repeat_cells=' . $repeat_cells
1819 . '&amp;goto=' . $goto
1820 . '&amp;dontlimitchars=' . $dontlimitchars;
1821 $checkall_url = $uncheckall_url . '&amp;checkall=1';
1822  
1823 if ( $disp_direction == 'vertical' ) {
1824 $checkall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', true) ) return false;';
1825 $uncheckall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', false) ) return false;';
1826 } else {
1827 $checkall_params['onclick'] = 'if ( markAllRows(\'rowsDeleteForm\') ) return false;';
1828 $uncheckall_params['onclick'] = 'if ( unMarkAllRows(\'rowsDeleteForm\') ) return false;';
1829 }
1830 $checkall_link = PMA_linkOrButton( $checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false );
1831 $uncheckall_link = PMA_linkOrButton( $uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false );
1832 if ( $disp_direction != 'vertical' ) {
1833 echo '<img class="selectallarrow" width="38" height="22"'
1834 .' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
1835 .' alt="' . $GLOBALS['strWithChecked'] . '" />';
1836 }
1837 echo $checkall_link . "\n"
1838 .' / ' . "\n"
1839 .$uncheckall_link . "\n"
1840 .'<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
1841  
1842 if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
1843 PMA_buttonOrImage('submit_mult', 'mult_submit',
1844 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
1845 PMA_buttonOrImage('submit_mult', 'mult_submit',
1846 'submit_mult_delete', $delete_text, 'b_drop.png');
1847 if ($analyzed_sql[0]['querytype'] == 'SELECT') {
1848 PMA_buttonOrImage('submit_mult', 'mult_submit',
1849 'submit_mult_export', $GLOBALS['strExport'],
1850 'b_tblexport.png');
1851 }
1852 echo "\n";
1853 } else {
1854 echo ' <input type="submit" name="submit_mult"'
1855 .' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"'
1856 .' title="' . $GLOBALS['strEdit'] . '" />' . "\n";
1857 echo ' <input type="submit" name="submit_mult"'
1858 .' value="' . htmlspecialchars($delete_text) . '"'
1859 .' title="' . $delete_text . '" />' . "\n";
1860 if ($analyzed_sql[0]['querytype'] == 'SELECT') {
1861 echo ' <input type="submit" name="submit_mult"'
1862 .' value="' . htmlspecialchars($GLOBALS['strExport']) . '"'
1863 .' title="' . $GLOBALS['strExport'] . '" />' . "\n";
1864 }
1865 }
1866 echo '<input type="hidden" name="sql_query"'
1867 .' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
1868 echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
1869 echo '<input type="hidden" name="url_query"'
1870 .' value="' . $GLOBALS['url_query'] . '" />' . "\n";
1871 echo '</form>' . "\n";
1872 }
1873  
1874 // 5. ----- Displays the navigation bar at the bottom if required -----
1875  
1876 if ($is_display['nav_bar'] == '1') {
1877 echo '<br />' . "\n";
1878 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1879 } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1880 echo "\n" . '<br /><br />' . "\n";
1881 }
1882 } // end of the 'PMA_displayTable()' function
1883  
1884 function default_function($buffer) {
1885 $buffer = htmlspecialchars($buffer);
1886 $buffer = str_replace("\011", ' &nbsp;&nbsp;&nbsp;',
1887 str_replace(' ', ' &nbsp;', $buffer));
1888 $buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />', $buffer);
1889  
1890 return $buffer;
1891 }
1892 ?>