3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Set of functions used to display the records returned by a sql query
9 if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
10 define('PMA_DISPLAY_TBL_LIB_INCLUDED', 1);
13 * Defines the display mode to use for the results of a sql query
15 * It uses a synthetic string that contains all the required informations.
17 * - the first two characters stand for the action to do while
18 * clicking on the "edit" link (eg 'ur' for update a row, 'nn' for no
20 * - the next two characters stand for the action to do while
21 * clicking on the "delete" link (eg 'kp' for kill a process, 'nn' for
23 * - the next characters are boolean values (1/0) and respectively stand
24 * for sorting links, navigation bar, "insert a new row" link, the
25 * bookmark feature, the expand/collapse text/blob fields button and
26 * the "display printable view" option.
27 * Of course '0'/'1' means the feature won't/will be enabled.
29 * @param string the synthetic value for display_mode (see ยง1 a few
30 * lines above for explanations)
31 * @param integer the total number of rows returned by the sql query
32 * without any programmatically appended "LIMIT" clause
33 * (just a copy of $unlim_num_rows if it exists, else
34 * computed inside this function)
36 * @return array an array with explicit indexes for all the display
39 * @global string the database name
40 * @global string the table name
41 * @global integer the total number of rows returned by the sql query
42 * without any programmatically appended "LIMIT" clause
43 * @global array the properties of the fields returned by the query
44 * @global string the url to return to in case of error in a sql
49 * @see PMA_displayTable()
51 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
54 global $unlim_num_rows, $fields_meta;
57 // 1. Initializes the $do_display array
58 $do_display = array();
59 $do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
60 $do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3];
61 $do_display['sort_lnk'] = (string) $the_disp_mode[4];
62 $do_display['nav_bar'] = (string) $the_disp_mode[5];
63 $do_display['ins_row'] = (string) $the_disp_mode[6];
64 $do_display['bkm_form'] = (string) $the_disp_mode[7];
65 $do_display['text_btn'] = (string) $the_disp_mode[8];
66 $do_display['pview_lnk'] = (string) $the_disp_mode[9];
68 // 2. Display mode is not "false for all elements" -> updates the
70 if ($the_disp_mode != 'nnnn000000') {
71 // 2.0 Print view -> set all elements to FALSE!
72 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
73 $do_display['edit_lnk'] = 'nn'; // no edit link
74 $do_display['del_lnk'] = 'nn'; // no delete link
75 $do_display['sort_lnk'] = (string) '0';
76 $do_display['nav_bar'] = (string) '0';
77 $do_display['ins_row'] = (string) '0';
78 $do_display['bkm_form'] = (string) '0';
79 $do_display['text_btn'] = (string) '0';
80 $do_display['pview_lnk'] = (string) '0';
82 // 2.1 Statement is a "SELECT COUNT", a
83 // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
84 // contains a "PROC ANALYSE" part
85 else if ($GLOBALS['is_count'] ||
$GLOBALS['is_analyse'] ||
$GLOBALS['is_maint'] ||
$GLOBALS['is_explain']) {
86 $do_display['edit_lnk'] = 'nn'; // no edit link
87 $do_display['del_lnk'] = 'nn'; // no delete link
88 $do_display['sort_lnk'] = (string) '0';
89 $do_display['nav_bar'] = (string) '0';
90 $do_display['ins_row'] = (string) '0';
91 $do_display['bkm_form'] = (string) '1';
92 $do_display['text_btn'] = (string) '0';
93 $do_display['pview_lnk'] = (string) '1';
95 // 2.2 Statement is a "SHOW..."
96 else if ($GLOBALS['is_show']) {
97 // 2.2.1 TODO : defines edit/delete links depending on show statement
98 $tmp = eregi('^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS)', $GLOBALS['sql_query'], $which);
99 if (strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
100 $do_display['edit_lnk'] = 'nn'; // no edit link
101 $do_display['del_lnk'] = 'kp'; // "kill process" type edit link
104 // Default case -> no links
105 $do_display['edit_lnk'] = 'nn'; // no edit link
106 $do_display['del_lnk'] = 'nn'; // no delete link
108 // 2.2.2 Other settings
109 $do_display['sort_lnk'] = (string) '0';
110 $do_display['nav_bar'] = (string) '0';
111 $do_display['ins_row'] = (string) '0';
112 $do_display['bkm_form'] = (string) '1';
113 $do_display['text_btn'] = (string) '0';
114 $do_display['pview_lnk'] = (string) '1';
116 // 2.3 Other statements (ie "SELECT" ones) -> updates
117 // $do_display['edit_lnk'], $do_display['del_lnk'] and
118 // $do_display['text_btn'] (keeps other default values)
120 $prev_table = $fields_meta[0]->table
;
121 for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++
) {
122 $is_link = ($do_display['edit_lnk'] != 'nn'
123 ||
$do_display['del_lnk'] != 'nn'
124 ||
$do_display['sort_lnk'] != '0'
125 ||
$do_display['ins_row'] != '0');
126 // 2.3.1 Displays text cut/expand button?
127 if ($do_display['text_btn'] == '0' && eregi('BLOB', $fields_meta[$i]->type
)) {
128 $do_display['text_btn'] = (string) '1';
133 // 2.3.2 Displays edit/delete/sort/insert links?
135 && ($fields_meta[$i]->table
== '' ||
$fields_meta[$i]->table
!= $prev_table)) {
136 $do_display['edit_lnk'] = 'nn'; // don't display links
137 $do_display['del_lnk'] = 'nn';
138 // TODO: May be problematic with same fields names in
140 // $do_display['sort_lnk'] = (string) '0';
141 $do_display['ins_row'] = (string) '0';
142 if ($do_display['text_btn'] == '1') {
146 // 2.3.3 Always display print view link
147 $do_display['pview_lnk'] = (string) '1';
148 $prev_table = $fields_meta[$i]->table
;
150 } // end if..elseif...else (2.1 -> 2.3)
153 // 3. Gets the total number of rows if it is unknown
154 if (isset($unlim_num_rows) && $unlim_num_rows != '') {
155 $the_total = $unlim_num_rows;
157 else if (($do_display['nav_bar'] == '1' ||
$do_display['sort_lnk'] == '1')
158 && (!empty($db) && !empty($table))) {
159 $local_query = 'SELECT COUNT(*) AS total FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
160 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
161 $the_total = PMA_mysql_result($result, 0, 'total');
162 mysql_free_result($result);
165 // 4. If navigation bar or sorting fields names urls should be
166 // displayed but there is only one row, change these settings to
168 if ($do_display['nav_bar'] == '1' ||
$do_display['sort_lnk'] == '1') {
170 if (isset($unlim_num_rows) && $unlim_num_rows < 2) {
171 // garvin: force display of navbar for vertical/horizontal display-choice.
172 // $do_display['nav_bar'] = (string) '0';
173 $do_display['sort_lnk'] = (string) '0';
178 // 5. Updates the synthetic var
179 $the_disp_mode = join('', $do_display);
182 } // end of the 'PMA_setDisplayMode()' function
186 * Displays a navigation bar to browse among the results of a sql query
188 * @param integer the offset for the "next" page
189 * @param integer the offset for the "previous" page
190 * @param string the url-encoded query
192 * @global string the current language
193 * @global string the currect charset for MySQL
194 * @global integer the server to use (refers to the number in the
195 * configuration file)
196 * @global string the database name
197 * @global string the table name
198 * @global string the url to go back in case of errors
199 * @global integer the total number of rows returned by the sql query
200 * @global integer the total number of rows returned by the sql query
201 * without any programmatically appended "LIMIT" clause
202 * @global integer the current position in results
203 * @global mixed the maximum number of rows per page ('all' = no limit)
204 * @global string the display mode (horizontal/vertical/horizontalflipped)
205 * @global integer the number of row to display between two table headers
206 * @global boolean whether to limit the number of displayed characters of
207 * text type fields or not
211 * @see PMA_displayTable()
213 function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
215 global $lang, $convcharset, $server, $db, $table;
217 global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
218 global $disp_direction, $repeat_cells;
219 global $dontlimitchars;
222 <!-- Navigation bar
-->
226 // Move to the beginning or to the previous page
227 if ($pos > 0 && $session_max_rows != 'all') {
228 // loic1: patch #474210 from Gosha Sakovich - part 1
229 if ($GLOBALS['cfg']['NavigationBarIconic']) {
230 $caption1 = '<<';
231 $caption2 = ' < ';
232 $title1 = ' title="' . $GLOBALS['strPos1'] . '"';
233 $title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
235 $caption1 = $GLOBALS['strPos1'] . ' <<';
236 $caption2 = $GLOBALS['strPrevious'] . ' <';
239 } // end if... else...
242 <form action
="sql.php3" method
="post">
243 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
244 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
245 <input type
="hidden" name
="pos" value
="0" />
246 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
247 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
248 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
249 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
250 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
251 <input type
="submit" name
="navig" value
="<?php echo $caption1; ?>"<?php
echo $title1; ?
> />
255 <form action
="sql.php3" method
="post">
256 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
257 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
258 <input type
="hidden" name
="pos" value
="<?php echo $pos_prev; ?>" />
259 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
260 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
261 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
262 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
263 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
264 <input type
="submit" name
="navig" value
="<?php echo $caption2; ?>"<?php
echo $title2; ?
> />
275 <form action
="sql.php3" method
="post"
276 onsubmit
="return (checkFormElementInRange(this, 'session_max_rows', 1) && checkFormElementInRange(this, 'pos', 0, <?php echo $unlim_num_rows - 1; ?>))">
277 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
278 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
279 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
280 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
281 <input type
="submit" name
="navig" value
="<?php echo $GLOBALS['strShow']; ?> :" />
282 <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()" />
283 <?php
echo $GLOBALS['strRowsFrom'] . "\n"; ?
>
284 <input type
="text" name
="pos" size
="6" value
="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus
="this.select()" />
287 // Display mode (horizontal/vertical and repeat headers)
288 $param1 = ' <select name="disp_direction">' . "\n"
289 . ' <option value="horizontal"' . (($disp_direction == 'horizontal') ?
' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
290 . ' <option value="horizontalflipped"' . (($disp_direction == 'horizontalflipped') ?
' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
291 . ' <option value="vertical"' . (($disp_direction == 'vertical') ?
' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
292 . ' </select>' . "\n"
294 $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" class="textfield" />' . "\n"
296 echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
304 // Move to the next page or to the last one
305 if (($pos +
$session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
306 && $session_max_rows != 'all') {
307 // loic1: patch #474210 from Gosha Sakovich - part 2
308 if ($GLOBALS['cfg']['NavigationBarIconic']) {
309 $caption3 = ' > ';
310 $caption4 = '>>';
311 $title3 = ' title="' . $GLOBALS['strNext'] . '"';
312 $title4 = ' title="' . $GLOBALS['strEnd'] . '"';
314 $caption3 = '> ' . $GLOBALS['strNext'];
315 $caption4 = '>> ' . $GLOBALS['strEnd'];
318 } // end if... else...
322 <form action
="sql.php3" method
="post">
323 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
324 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
325 <input type
="hidden" name
="pos" value
="<?php echo $pos_next; ?>" />
326 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
327 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
328 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
329 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
330 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
331 <input type
="submit" name
="navig" value
="<?php echo $caption3; ?>"<?php
echo $title3; ?
> />
335 <form action
="sql.php3" method
="post"
336 onsubmit
="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
337 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
338 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
339 <input type
="hidden" name
="pos" value
="<?php echo $unlim_num_rows - $session_max_rows; ?>" />
340 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
341 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
342 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
343 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
344 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
345 <input type
="submit" name
="navig" value
="<?php echo $caption4; ?>"<?php
echo $title4; ?
> />
353 $pageNow = @floor
($pos / $session_max_rows) +
1;
354 $nbTotalPage = @ceil
($unlim_num_rows / $session_max_rows);
356 if ($nbTotalPage > 1){ //if1
362 <?php
//<form> for keep the form alignment of button < and << ?>
364 <?php
echo $GLOBALS['strPageNumber']; ?
>
365 <select name
="goToPage" onChange
="goToUrl(this, '<?php echo "sql
.php3?sql_query
=".$encoded_query."&
;session_max_rows
=".$session_max_rows."&
;disp_direction
=".$disp_direction."&
;repeat_cells
=".$repeat_cells."&
;goto=".$goto."&
;dontlimitchars
=".$dontlimitchars."&
;".PMA_generate_common_url($db, $table)."&
;"; ?>')">
368 for ($i=1; $i<=$nbTotalPage; $i++
){
369 if ($i == $pageNow) {
370 $selected = 'selected="selected"';
374 echo " <option ".$selected." value=\"".(($i - 1) * $session_max_rows)."\">".$i."</option>\n";
385 // Show all the records if allowed
386 if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
393 <form action
="sql.php3" method
="post">
394 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
395 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
396 <input type
="hidden" name
="pos" value
="0" />
397 <input type
="hidden" name
="session_max_rows" value
="all" />
398 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
399 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
400 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
401 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
402 <input type
="submit" name
="navig" value
="<?php echo $GLOBALS['strShowAll']; ?>" />
413 } // end of the 'PMA_displayTableNavigation()' function
417 * Displays the headers of the results table
419 * @param array which elements to display
420 * @param array the list of fields properties
421 * @param integer the total number of fields returned by the sql query
422 * @param array the analyzed query
424 * @return boolean always true
426 * @global string the current language
427 * @global string the current charset for MySQL
428 * @global integer the server to use (refers to the number in the
429 * configuration file)
430 * @global string the database name
431 * @global string the table name
432 * @global string the sql query
433 * @global string the url to go back in case of errors
434 * @global integer the total number of rows returned by the sql query
435 * @global integer the current position in results
436 * @global integer the maximum number of rows per page
437 * @global array informations used with vertical display mode
438 * @global string the display mode (horizontal/vertical/horizontalflipped)
439 * @global integer the number of row to display between two table headers
440 * @global boolean whether to limit the number of displayed characters of
441 * text type fields or not
445 * @see PMA_displayTable()
447 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = array())
449 global $lang, $convcharset, $server, $db, $table;
451 global $sql_query, $num_rows, $pos, $session_max_rows;
452 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
453 global $dontlimitchars;
455 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
457 <!-- Results table headers
-->
463 $vertical_display['emptypre'] = 0;
464 $vertical_display['emptyafter'] = 0;
465 $vertical_display['textbtn'] = '';
467 // 1. Displays the full/partial text button (part 1)...
468 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
469 $colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
473 $rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
477 $text_url = 'sql.php3?'
478 . PMA_generate_common_url($db, $table)
479 . '&sql_query=' . urlencode($sql_query)
481 . '&session_max_rows=' . $session_max_rows
483 . '&disp_direction=' . $disp_direction
484 . '&repeat_cells=' . $repeat_cells
485 . '&goto=' . $goto
486 . '&dontlimitchars=' . (($dontlimitchars) ?
0 : 1);
488 // ... before the result table
489 if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
490 && $is_display['text_btn'] == '1') {
491 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
492 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
494 <td colspan
="<?php echo $fields_cnt; ?>" align
="center">
495 <a href
="<?php echo $text_url; ?>">
496 <img src
="./images/<?php echo (($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
>
502 } // end horizontal/horizontalflipped mode
507 <td colspan
="<?php echo $num_rows + floor($num_rows/$repeat_cells) + 1; ?>" align
="center">
508 <a href
="<?php echo $text_url; ?>">
509 <img src
="./images/<?php echo (($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
>
513 } // end vertical mode
516 // ... at the left column of the result table header if possible
518 else if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
519 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
520 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
523 <td
<?php
echo $colspan; ?
> align
="center">
524 <a href
="<?php echo $text_url; ?>">
525 <img src
="./images/<?php echo (($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
>
528 } // end horizontal/horizontalflipped mode
530 $vertical_display['textbtn'] = ' <td' . $rowspan . ' align="center" valign="middle">' . "\n"
531 . ' <a href="' . $text_url . '">' . "\n"
532 . ' <img src="./images/' . (($dontlimitchars) ?
'partialtext' : 'fulltext') . '.png" border="0" width="50" height="20" alt="' . (($dontlimitchars) ?
$GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . (($dontlimitchars) ?
$GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" /></a>' . "\n"
534 } // end vertical mode
537 // ... else if no button, displays empty(ies) col(s) if required
538 else if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
539 && ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn')) {
540 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
541 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
544 <td
<?php
echo $colspan; ?
>></td
>
547 } // end horizontal/horizontalfipped mode
549 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
550 } // end vertical mode
553 // 2. Displays the fields' name
554 // 2.0 If sorting links should be used, checks if the query is a "JOIN"
555 // statement (see 2.1.3)
557 // 2.0.1 Prepare Display column comments if enabled ($cfg['ShowBrowseComments']).
558 // Do not show comments, if using horizontalflipped mode, because of space usage
559 if ($GLOBALS['cfg']['ShowBrowseComments'] && $GLOBALS['cfgRelation']['commwork'] && $disp_direction != 'horizontalflipped') {
560 $comments_map = PMA_getComments($db, $table);
562 $comments_map = array();
565 if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
566 require('./libraries/transformations.lib.php3');
567 $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
571 if ($is_display['sort_lnk'] == '1') {
572 $is_join = eregi('(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN', $sql_query, $select_stt);
577 // garvin: See if we have to highlight any header fields of a WHERE query.
578 // Uses SQL-Parser results.
579 $highlight_columns = array();
580 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
581 isset($analyzed_sql[0]['where_clause_identifiers'])) {
584 @reset
($analyzed_sql[0]['where_clause_identifiers']);
585 while(list($wci_nr, $wci) = each($analyzed_sql[0]['where_clause_identifiers'])) {
586 $highlight_columns[$wci] = 'true';
590 for ($i = 0; $i < $fields_cnt; $i++
) {
591 // garvin: See if this column should get highlight because it's used in the
593 if (isset($highlight_columns[$fields_meta[$i]->name
]) ||
isset($highlight_columns[PMA_backquote($fields_meta[$i]->name
)])) {
594 $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
599 // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
600 if (isset($comments_map[$fields_meta[$i]->name
])) {
601 $comments_table_wrap_pre = '<table border="0" cellpadding="0" cellspacing="0"><tr><th>';
602 $comments_table_wrap_post = '</th></tr><tr><th style="font-size: 8pt; font-weight: normal">' . htmlspecialchars($comments_map[$fields_meta[$i]->name
]) . '</td></tr></table>';
604 $comments_table_wrap_pre = '';
605 $comments_table_wrap_post = '';
608 // 2.1 Results can be sorted
609 if ($is_display['sort_lnk'] == '1') {
610 // Defines the url used to append/modify a sorting order
611 // 2.1.1 Checks if an hard coded 'order by' clause exists
612 if (eregi('(.*)([[:space:]]ORDER[[:space:]]*BY[[:space:]](.*))', $sql_query, $regs1)) {
613 if (eregi('((.*)([[:space:]]ASC|[[:space:]]DESC)([[:space:]]|$))(.*)', $regs1[2], $regs2)) {
614 $unsorted_sql_query = trim($regs1[1] . ' ' . $regs2[5]);
615 $sql_order = trim($regs2[1]);
616 eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order);
617 $sort_expression = trim($after_order[2]);
619 else if (eregi('((.*))[[:space:]]+(LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE)', $regs1[2], $regs3)) {
620 $unsorted_sql_query = trim($regs1[1] . ' ' . $regs3[3]);
621 $sql_order = trim($regs3[1]) . ' ASC';
622 eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order);
623 $sort_expression = trim($after_order[2]);
625 $unsorted_sql_query = trim($regs1[1]);
626 $sql_order = trim($regs1[2]) . ' ASC';
627 eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order);
628 $sort_expression = trim($after_order[2]);
631 $unsorted_sql_query = $sql_query;
634 // 2.1.2 Checks if the current column is used to sort the
636 if (empty($sql_order)) {
639 // $pattern = str_replace('\\', '\\\\', $fields_meta[$i]->name);
640 // $pattern = str_replace('(','\(', $pattern);
641 // $pattern = str_replace(')','\)', $pattern);
642 // $pattern = str_replace('*','\*', $pattern);
644 // field name may be preceded by a space, or any number
645 // of characters followed by a dot (tablename.fieldname)
646 // $is_in_sort = eregi('([[:space:]]|(.*\.))(`?)' . $pattern . '(`?)[ ,$]', $sql_order);
647 // instead of using eregi(), now do a direct comparison
648 // for the sort expression (avoids problems with queries
649 // like "SELECT id, count(id)..." and clicking to sort
650 // on id or on count(id) )
651 $is_in_sort = (PMA_backquote($fields_meta[$i]->name
) == $sort_expression ?
TRUE : FALSE);
653 // 2.1.3 Checks if the table name is required (it's the case
654 // for a query with a "JOIN" statement and if the column
657 && !eregi('([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name
, $select_stt[1], $parts)) {
658 $sort_tbl = PMA_backquote($fields_meta[$i]->table
) . '.';
662 // 2.1.4 Check the field name for backquotes.
663 // If it contains some, it's probably a function column
664 // like 'COUNT(`field`)'
665 if (strpos(' ' . $fields_meta[$i]->name
, '`') > 0) {
666 $sort_order = ' ORDER BY \'' . $fields_meta[$i]->name
. '\' ';
668 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name
) . ' ';
670 // 2.1.5 Do define the sorting url
672 // loic1: patch #455484 ("Smart" order)
673 $cfg['Order'] = strtoupper($GLOBALS['cfg']['Order']);
674 if ($cfg['Order'] == 'SMART') {
675 $cfg['Order'] = (eregi('time|date', $fields_meta[$i]->type
)) ?
'DESC' : 'ASC';
677 $sort_order .= $cfg['Order'];
680 else if (eregi('[[:space:]]ASC$', $sql_order)) {
681 $sort_order .= ' DESC';
682 $order_img = ' <img src="./images/asc_order.png" border="0" width="7" height="7" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" />';
684 else if (eregi('[[:space:]]DESC$', $sql_order)) {
685 $sort_order .= ' ASC';
686 $order_img = ' <img src="./images/desc_order.png" border="0" width="7" height="7" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" />';
688 if (eregi('(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))', $unsorted_sql_query, $regs3)) {
689 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
691 $sorted_sql_query = $unsorted_sql_query . $sort_order;
693 $url_query = PMA_generate_common_url($db, $table)
695 . '&session_max_rows=' . $session_max_rows
696 . '&disp_direction=' . $disp_direction
697 . '&repeat_cells=' . $repeat_cells
698 . '&dontlimitchars=' . $dontlimitchars
699 . '&sql_query=' . urlencode($sorted_sql_query);
701 // 2.1.5 Displays the sorting url
702 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
705 <th
<?php
echo $column_style; ?
> <?php
if ($disp_direction == 'horizontalflipped') echo 'valign="bottom"'; ?
>>
706 <?php
echo $comments_table_wrap_pre; ?
>
707 <a href
="sql.php3?<?php echo $url_query; ?>" <?php
echo (($disp_direction == 'horizontalflipped' AND $GLOBALS['cfg']['HeaderFlipType'] == 'css') ?
'style="direction: ltr; writing-mode: tb-rl;"' : ''); ?
>>
708 <?php
echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ?
PMA_flipstring(htmlspecialchars($fields_meta[$i]->name
), "<br />\n") : htmlspecialchars($fields_meta[$i]->name
)); ?
></a
><?php
echo $order_img . "\n"; ?
>
709 <?php
echo $comments_table_wrap_post; ?
>
713 $vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
714 . $comments_table_wrap_pre
715 . ' <a href="sql.php3?' . $url_query . '">' . "\n"
716 . ' ' . htmlspecialchars($fields_meta[$i]->name
) . '</a>' . $order_img . "\n"
717 . $comments_table_wrap_post
721 // 2.2 Results can't be sorted
723 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
726 <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;"' : ''); ?
>>
727 <?php
echo $comments_table_wrap_pre; ?
>
728 <?php
echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake'?
PMA_flipstring(htmlspecialchars($fields_meta[$i]->name
), "<br />\n") : htmlspecialchars($fields_meta[$i]->name
)) . "\n"; ?
>
729 <?php
echo $comments_table_wrap_post; ?
>
733 $vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
734 . $comments_table_wrap_pre
735 . ' ' . htmlspecialchars($fields_meta[$i]->name
) . "\n"
736 . $comments_table_wrap_post
741 // 3. Displays the full/partial text button (part 2) at the right
742 // column of the result table header if possible and required...
743 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
744 && ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn')
745 && $is_display['text_btn'] == '1') {
746 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
747 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
750 <td
<?php
echo $colspan; ?
> align
="center">
751 <a href
="<?php echo $text_url; ?>">
752 <img src
="./images/<?php echo (($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
>
755 } // end horizontal/horizontalflipped mode
757 $vertical_display['textbtn'] = ' <td' . $rowspan . ' align="center" valign="middle">' . "\n"
758 . ' <a href="' . $text_url . '">' . "\n"
759 . ' <img src="./images/' . (($dontlimitchars) ?
'partialtext' : 'fulltext') . '.png" border="0" width="50" height="20" alt="' . (($dontlimitchars) ?
$GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . (($dontlimitchars) ?
$GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" /></a>' . "\n"
761 } // end vertical mode
764 // ... else if no button, displays empty cols if required
765 // (unless coming from Browse mode print view)
766 else if ($GLOBALS['cfg']['ModifyDeleteAtRight']
767 && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
768 && (!$GLOBALS['is_header_sent'])) {
769 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
770 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
773 <td
<?php
echo $colspan; ?
>></td
>
775 } // end horizontal/horizontalflipped mode
777 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
778 } // end vertical mode
781 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
790 } // end of the 'PMA_displayTableHeaders()' function
795 * Displays the body of the results table
797 * @param integer the link id associated to the query which results have
799 * @param array which elements to display
800 * @param array the list of relations
801 * @param array the analyzed query
803 * @return boolean always true
805 * @global string the current language
806 * @global string the current charset for MySQL
807 * @global integer the server to use (refers to the number in the
808 * configuration file)
809 * @global string the database name
810 * @global string the table name
811 * @global string the sql query
812 * @global string the url to go back in case of errors
813 * @global integer the current position in results
814 * @global integer the maximum number of rows per page
815 * @global array the list of fields properties
816 * @global integer the total number of fields returned by the sql query
817 * @global array informations used with vertical display mode
818 * @global string the display mode (horizontal/vertical/horizontalflipped)
819 * @global integer the number of row to display between two table headers
820 * @global boolean whether to limit the number of displayed characters of
821 * text type fields or not
825 * @see PMA_displayTable()
827 function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
829 global $lang, $convcharset, $server, $db, $table;
831 global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
832 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
833 global $dontlimitchars;
835 if (!is_array($map)) {
839 <!-- Results table body
-->
844 $vertical_display['edit'] = array();
845 $vertical_display['delete'] = array();
846 $vertical_display['data'] = array();
848 // Correction uva 19991216 in the while below
849 // Previous code assumed that all tables have keys, specifically that
850 // the phpMyAdmin GUI should support row delete/edit only for such
852 // Although always using keys is arguably the prescribed way of
853 // defining a relational table, it is not required. This will in
854 // particular be violated by the novice.
855 // We want to encourage phpMyAdmin usage by such novices. So the code
856 // below has been changed to conditionally work as before when the
857 // table being displayed has one or more keys; but to display
858 // delete/edit options correctly for tables without keys.
860 // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
861 // to get the NULL values
863 while ($row = PMA_mysql_fetch_array($dt_result)) {
865 // lem9: "vertical display" mode stuff
866 if (($row_no != 0) && ($repeat_cells != 0) && !($row_no %
$repeat_cells) && ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped')) {
869 for ($foo_i = 0; $foo_i < $vertical_display['emptypre']; $foo_i++
) {
870 echo ' <td> </td>' . "\n";
873 reset($vertical_display['desc']);
874 while (list($key, $val) = each($vertical_display['desc'])) {
878 for ($foo_i = 0; $foo_i < $vertical_display['emptyafter']; $foo_i++
) {
879 echo ' <td> </td>' . "\n";
885 if (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
886 $bgcolor = '#ffffff';
888 $bgcolor = ($row_no %
2) ?
$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
891 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
892 // loic1: pointer code part
894 if (!isset($GLOBALS['printview']) ||
($GLOBALS['printview'] != '1')) {
895 if ($GLOBALS['cfg']['BrowsePointerColor'] != '') {
896 $on_mouse = ' onmouseover="setPointer(this, ' . $row_no . ', \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
897 . ' onmouseout="setPointer(this, ' . $row_no . ', \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
899 if ($GLOBALS['cfg']['BrowseMarkerColor'] != '') {
900 $on_mouse .= ' onmousedown="setPointer(this, ' . $row_no . ', \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
904 <tr
<?php
echo $on_mouse; ?
>>
909 // 1. Prepares the row (gets primary keys to use)
910 if ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn') {
913 $uva_nonprimary_condition = '';
915 // 1.1 Results from a "SELECT" statement -> builds the
916 // "primary" key to use in links
917 if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) {
918 for ($i = 0; $i < $fields_cnt; ++
$i) {
919 $meta = $fields_meta[$i];
921 // do not use an alias in a condition
922 $column_for_condition = $meta->name
;
923 reset($analyzed_sql[0]['select_expr']);
924 while (list ($select_expr_position, $select_expr) = each ($analyzed_sql[0]['select_expr'])) {
925 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
926 if (!empty($alias)) {
927 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
928 if ($alias == $meta->name
) {
929 $column_for_condition = $true_column;
934 // to fix the bug where float fields (primary or not)
935 // can't be matched because of the imprecision of
936 // floating comparison, use CONCAT
937 // (also, the syntax "CONCAT(field) IS NULL"
938 // that we need on the next "if" will work)
939 if ($meta->type
== 'real') {
940 $condition = ' CONCAT(' . PMA_backquote($column_for_condition) . ') ';
942 $condition = ' ' . PMA_backquote($column_for_condition) . ' ';
943 } // end if... else...
945 // loic1: To fix bug #474943 under php4, the row
946 // pointer will depend on whether the "is_null"
947 // php4 function is available or not
948 $pointer = (function_exists('is_null') ?
$i : $meta->name
);
949 if (!isset($row[$meta->name
])
950 ||
(function_exists('is_null') && is_null($row[$pointer]))) {
951 $condition .= 'IS NULL AND';
953 $condition .= '= \'' . PMA_sqlAddslashes($row[$pointer], FALSE, TRUE) . '\' AND';
955 if ($meta->primary_key
> 0) {
956 $primary_key .= $condition;
957 } else if ($meta->unique_key
> 0) {
958 $unique_key .= $condition;
960 $uva_nonprimary_condition .= $condition;
963 // Correction uva 19991216: prefer primary or unique keys
964 // for condition, but use conjunction of all values if no
967 $uva_condition = $primary_key;
968 } else if ($unique_key) {
969 $uva_condition = $unique_key;
971 $uva_condition = $uva_nonprimary_condition;
974 $uva_condition = urlencode(ereg_replace('[[:space:]]?AND$', '', $uva_condition));
977 // 1.2 Defines the urls for the modify/delete link(s)
978 $url_query = PMA_generate_common_url($db, $table)
980 . '&session_max_rows=' . $session_max_rows
981 . '&disp_direction=' . $disp_direction
982 . '&repeat_cells=' . $repeat_cells
983 . '&dontlimitchars=' . $dontlimitchars;
985 // 1.2.1 Modify link(s)
986 if ($is_display['edit_lnk'] == 'ur') { // update row case
987 // $lnk_goto = 'sql.php3'
988 // . '?' . str_replace('&', '&', $url_query)
989 // . '&sql_query=' . urlencode($sql_query)
990 // . '&goto=' . (empty($goto) ? 'tbl_properties.php3' : $goto);
991 // to reduce the length of the URL, because of some browsers limitations:
992 $lnk_goto = 'sql.php3';
994 $edit_url = 'tbl_change.php3'
996 . '&primary_key=' . $uva_condition
997 . '&sql_query=' . urlencode($sql_query)
998 . '&goto=' . urlencode($lnk_goto);
999 $edit_str = $GLOBALS['strEdit'];
1002 if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db']) {
1003 $bookmark_go = '<form method="post" target="phpmain" action="read_dump.php3">'
1004 . PMA_generate_common_hidden_inputs($row['dbase'], '')
1005 . '<input type="hidden" name="id_bookmark" value="' . $row['id'] . '" />'
1006 . '<input type="hidden" name="action_bookmark" value="0" />'
1007 . '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />'
1013 // 1.2.2 Delete/Kill link(s)
1014 if ($is_display['del_lnk'] == 'dr') { // delete row case
1015 $lnk_goto = 'sql.php3'
1016 . '?' . str_replace('&', '&', $url_query)
1017 . '&sql_query=' . urlencode($sql_query)
1018 . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1019 . '&goto=' . (empty($goto) ?
'tbl_properties.php3' : $goto);
1020 $del_url = 'sql.php3'
1022 . '&sql_query=' . urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . ((PMA_MYSQL_INT_VERSION
>= 32207) ?
urlencode(' LIMIT 1') : '')
1023 . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1024 . '&goto=' . urlencode($lnk_goto);
1025 $js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
1026 . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE))
1027 . ((PMA_MYSQL_INT_VERSION
>= 32207) ?
' LIMIT 1' : '');
1028 $del_str = $GLOBALS['strDelete'];
1029 } else if ($is_display['del_lnk'] == 'kp') { // kill process case
1030 $lnk_goto = 'sql.php3'
1031 . '?' . str_replace('&', '&', $url_query)
1032 . '&sql_query=' . urlencode($sql_query)
1033 . '&goto=main.php3';
1034 $del_url = 'sql.php3?'
1035 . PMA_generate_common_url('mysql')
1036 . '&sql_query=' . urlencode('KILL ' . $row['Id'])
1037 . '&goto=' . urlencode($lnk_goto);
1038 $js_conf = 'KILL ' . $row['Id'];
1039 $del_str = $GLOBALS['strKill'];
1042 // 1.3 Displays the links at left if required
1043 if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
1044 && ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped')) {
1045 if (!empty($edit_url)) {
1046 echo ' <td valign="' . ($bookmark_go != '' ?
'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
1047 echo PMA_linkOrButton($edit_url, $edit_str, '');
1049 echo ' </td>' . "\n";
1051 if (!empty($del_url)) {
1052 echo ' <td valign="' . ($bookmark_go != '' ?
'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
1053 echo PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ?
$js_conf : ''));
1054 echo ' </td>' . "\n";
1057 echo (($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') ?
"\n" : '');
1060 // 2. Displays the rows' values
1061 for ($i = 0; $i < $fields_cnt; ++
$i) {
1062 $meta = $fields_meta[$i];
1063 // loic1: To fix bug #474943 under php4, the row pointer will
1064 // depend on whether the "is_null" php4 function is
1066 $pointer = (function_exists('is_null') ?
$i : $meta->name
);
1068 // garvin: See if this column should get highlight because it's used in the
1070 if (isset($highlight_columns) && (isset($highlight_columns[$meta->name
]) ||
isset($highlight_columns[PMA_backquote($meta->name
)]))) {
1071 $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
1076 // garvin: Wrap MIME-transformations. [MIME]
1077 $default_function = 'htmlspecialchars'; // default_function
1078 $transform_function = $default_function;
1079 $transform_options = array();
1081 if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
1083 if (isset($GLOBALS['mime_map'][$meta->name
]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name
]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name
]['transformation'])) {
1084 // garvin: for security, never allow to break out from transformations directory
1085 $include_file = eregi_replace('\.\.*', '.', $GLOBALS['mime_map'][$meta->name
]['transformation']);
1087 if (file_exists('./libraries/transformations/' . $include_file)) {
1088 $transformfunction_name = str_replace('.inc.php3', '', $GLOBALS['mime_map'][$meta->name
]['transformation']);
1090 @include
('./libraries/transformations/' . $include_file);
1092 if (defined('PMA_TRANSFORMATION_' . strtoupper($transformfunction_name)) && function_exists('PMA_transformation_' . $transformfunction_name)) {
1093 $transform_function = 'PMA_transformation_' . $transformfunction_name;
1094 $transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name
]['transformation_options']) ?
$GLOBALS['mime_map'][$meta->name
]['transformation_options'] : ''));
1096 } // end if file_exists
1097 } // end if transformation is set
1098 } // end if mime/transformation works.
1100 $transform_options['wrapper_link'] = '?'
1101 . (isset($url_query) ?
$url_query : '')
1102 . '&primary_key=' . (isset($uva_condition) ?
$uva_condition : '')
1103 . '&sql_query=' . (isset($sql_query) ?
urlencode($sql_query) : '')
1104 . '&goto=' . (isset($sql_goto) ?
urlencode($lnk_goto) : '')
1105 . '&transform_key=' . urlencode($meta->name
);
1109 if ($meta->numeric == 1) {
1111 // lem9: if two fields have the same name (this is possible
1112 // with self-join queries, for example), using $meta->name
1113 // will show both fields NULL even if only one is NULL,
1114 // so use the $pointer
1115 // (works only if function_exists('is_null')
1116 // PS: why not always work with the number ($i), since
1117 // the default second parameter of
1118 // mysql_fetch_array() is MYSQL_BOTH, so we always get
1119 // associative and numeric indices?
1121 //if (!isset($row[$meta->name])
1122 if (!isset($row[$pointer])
1123 ||
(function_exists('is_null') && is_null($row[$pointer]))) {
1124 $vertical_display['data'][$row_no][$i] = ' <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
1125 } else if ($row[$pointer] != '') {
1126 $vertical_display['data'][$row_no][$i] = ' <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">';
1128 reset($analyzed_sql[0]['select_expr']);
1129 while (list ($select_expr_position, $select_expr) = each ($analyzed_sql[0]['select_expr'])) {
1130 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1131 if (!empty($alias)) {
1132 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1133 if ($alias == $meta->name
) {
1134 $meta->name
= $true_column;
1139 if (isset($map[$meta->name
])) {
1140 // Field to display from the foreign table?
1141 if (!empty($map[$meta->name
][2])) {
1142 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name
][2])
1143 . ' FROM ' . PMA_backquote($map[$meta->name
][0])
1144 . ' WHERE ' . PMA_backquote($map[$meta->name
][1])
1145 . ' = ' . $row[$pointer];
1146 $dispresult = PMA_mysql_query($dispsql);
1147 if ($dispresult && mysql_num_rows($dispresult) > 0) {
1148 $dispval = PMA_mysql_result($dispresult, 0);
1151 $dispval = $GLOBALS['strLinkNotFound'];
1156 } // end if... else...
1157 $title = (!empty($dispval))?
' title="' . htmlspecialchars($dispval) . '"' : '';
1159 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php3?'
1160 . PMA_generate_common_url($db, $map[$meta->name
][0])
1161 . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars
1162 . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name
][0]) . ' WHERE ' . PMA_backquote($map[$meta->name
][1]) . ' = ' . $row[$pointer]) . '"' . $title . '>'
1163 . ($transform_function != $default_function ?
$transform_function($row[$pointer], $transform_options) : $transform_function($row[$pointer])) . '</a>';
1165 $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ?
$transform_function($row[$pointer], $transform_options) : $transform_function($row[$pointer]));
1167 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1169 $vertical_display['data'][$row_no][$i] = ' <td align="right" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '"> </td>' . "\n";
1174 } else if ($GLOBALS['cfg']['ShowBlob'] == FALSE && eregi('BLOB', $meta->type
)) {
1175 // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
1176 // TEXT fields type, however TEXT fields must be displayed
1177 // even if $cfg['ShowBlob'] is false -> get the true type
1179 $field_flags = PMA_mysql_field_flags($dt_result, $i);
1181 if (eregi('BINARY', $field_flags)) {
1182 $blobtext = '[BLOB';
1183 if (isset($row[$pointer])) {
1184 $blob_size = PMA_formatByteDown(strlen($row[$pointer]), 3, 1);
1185 $blobtext .= ' - '. $blob_size [0] . ' ' . $blob_size[1];
1190 $blobtext = ($default_function != $transform_function ?
$transform_function($blobtext, $transform_options) : $default_function($blobtext));
1192 $vertical_display['data'][$row_no][$i] = ' <td align="center" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '">' . $blobtext . '</td>';
1194 //if (!isset($row[$meta->name])
1195 if (!isset($row[$pointer])
1196 ||
(function_exists('is_null') && is_null($row[$pointer]))) {
1197 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
1198 } else if ($row[$pointer] != '') {
1199 // garvin: if a transform function for blob is set, none of these replacements will be made
1200 if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
1201 $row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1203 // loic1: displays all space characters, 4 space
1204 // characters for tabulations and <cr>/<lf>
1206 $row[$pointer] = ($default_function != $transform_function ?
$transform_function('BLOB', $transform_options) : $default_function($row[$pointer]));
1207 $row[$pointer] = str_replace("\011", ' ', str_replace(' ', ' ', $row[$pointer]));
1208 $row[$pointer] = ereg_replace("((\015\012)|(\015)|(\012))", '<br />', $row[$pointer]);
1210 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">' . $row[$pointer] . '</td>' . "\n";
1212 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"> </td>' . "\n";
1216 //if (!isset($row[$meta->name])
1217 if (!isset($row[$pointer])
1218 ||
(function_exists('is_null') && is_null($row[$pointer]))) {
1219 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
1220 } else if ($row[$pointer] != '') {
1221 // loic1: support blanks in the key
1222 $relation_id = $row[$pointer];
1224 // loic1: Cut text/blob fields even if $cfg['ShowBlob'] is true
1225 if (eregi('BLOB', $meta->type
)) {
1226 if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
1227 $row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1230 // loic1: displays special characters from binaries
1231 $field_flags = PMA_mysql_field_flags($dt_result, $i);
1232 if (eregi('BINARY', $field_flags)) {
1233 $row[$pointer] = str_replace("\x00", '\0', $row[$pointer]);
1234 $row[$pointer] = str_replace("\x08", '\b', $row[$pointer]);
1235 $row[$pointer] = str_replace("\x0a", '\n', $row[$pointer]);
1236 $row[$pointer] = str_replace("\x0d", '\r', $row[$pointer]);
1237 $row[$pointer] = str_replace("\x1a", '\Z', $row[$pointer]);
1238 $row[$pointer] = ($default_function != $transform_function ?
$transform_function('BLOB', $transform_options) : $default_function($row[$pointer]));
1240 // loic1: displays all space characters, 4 space
1241 // characters for tabulations and <cr>/<lf>
1243 $row[$pointer] = ($default_function != $transform_function ?
$transform_function('BLOB', $transform_options) : $default_function($row[$pointer]));
1244 $row[$pointer] = str_replace("\011", ' ', str_replace(' ', ' ', $row[$pointer]));
1245 $row[$pointer] = ereg_replace("((\015\012)|(\015)|(\012))", '<br />', $row[$pointer]);
1248 // loic1: do not wrap if date field type
1249 $nowrap = (eregi('DATE|TIME', $meta->type
) ?
' nowrap="nowrap"' : '');
1250 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"' . $nowrap . '>';
1252 reset($analyzed_sql[0]['select_expr']);
1253 while (list ($select_expr_position, $select_expr) = each ($analyzed_sql[0]['select_expr'])) {
1254 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1255 if (!empty($alias)) {
1256 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1257 if ($alias == $meta->name
) {
1258 $meta->name
= $true_column;
1263 if (isset($map[$meta->name
])) {
1264 // Field to display from the foreign table?
1265 if (!empty($map[$meta->name
][2])) {
1266 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name
][2])
1267 . ' FROM ' . PMA_backquote($map[$meta->name
][0])
1268 . ' WHERE ' . PMA_backquote($map[$meta->name
][1])
1269 . ' = \'' . PMA_sqlAddslashes($row[$pointer]) . '\'';
1270 $dispresult = @PMA_mysql_query
($dispsql);
1271 if ($dispresult && mysql_num_rows($dispresult) > 0) {
1272 $dispval = PMA_mysql_result($dispresult, 0);
1275 $dispval = $GLOBALS['strLinkNotFound'];
1281 $title = (!empty($dispval))?
' title="' . htmlspecialchars($dispval) . '"' : '';
1283 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php3?'
1284 . PMA_generate_common_url($db, $map[$meta->name
][0])
1285 . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars
1286 . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name
][0]) . ' WHERE ' . PMA_backquote($map[$meta->name
][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
1287 . $row[$pointer] . '</a>';
1289 $vertical_display['data'][$row_no][$i] .= $row[$pointer];
1291 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1293 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"> </td>' . "\n";
1297 // lem9: output stored cell
1298 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
1299 echo $vertical_display['data'][$row_no][$i];
1302 if (isset($vertical_display['rowdata'][$i][$row_no])) {
1303 $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
1305 $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
1309 // 3. Displays the modify/delete links on the right if required
1310 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
1311 && ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped')) {
1312 if (!empty($edit_url)) {
1313 echo ' <td valign="' . ($bookmark_go != '' ?
'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
1314 echo PMA_linkOrButton($edit_url, $edit_str, '');
1316 echo ' </td>' . "\n";
1318 if (!empty($del_url)) {
1319 echo ' <td valign="' . ($bookmark_go != '' ?
'top' : 'middle') . ' bgcolor="' . $bgcolor . '">' . "\n";
1320 echo PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ?
$js_conf : ''));
1321 echo ' </td>' . "\n";
1325 if ($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') {
1332 // 4. Gather links of del_urls and edit_urls in an array for later
1334 if (!isset($vertical_display['edit'][$row_no])) {
1335 $vertical_display['edit'][$row_no] = '';
1336 $vertical_display['delete'][$row_no] = '';
1339 if (isset($edit_url)) {
1340 $vertical_display['edit'][$row_no] .= ' <td valign="' . ($bookmark_go != '' ?
'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
1341 . PMA_linkOrButton($edit_url, $edit_str, '')
1346 if (isset($del_url)) {
1347 $vertical_display['delete'][$row_no] .= ' <td valign="' . ($bookmark_go != '' ?
'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
1348 . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ?
$js_conf : ''))
1352 echo (($disp_direction == 'horizontal' ||
$disp_direction == 'horizontalflipped') ?
"\n" : '');
1357 } // end of the 'PMA_displayTableBody()' function
1361 * Do display the result table with the vertical direction mode.
1362 * Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
1364 * @return boolean always true
1366 * @global array the information to display
1367 * @global integer the number of row to display between two table headers
1371 * @see PMA_displayTable()
1373 function PMA_displayVerticalTable()
1375 global $vertical_display, $repeat_cells;
1377 reset($vertical_display);
1379 // Displays "edit" link at top if required
1380 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['edit'])) {
1382 echo $vertical_display['textbtn'];
1383 reset($vertical_display['edit']);
1385 while (list($key, $val) = each($vertical_display['edit'])) {
1386 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1387 echo ' <td> </td>' . "\n";
1393 echo '</tr>' . "\n";
1396 // Displays "delete" link at top if required
1397 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['delete'])) {
1399 if (!is_array($vertical_display['edit'])) {
1400 echo $vertical_display['textbtn'];
1402 reset($vertical_display['delete']);
1404 while (list($key, $val) = each($vertical_display['delete'])) {
1405 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1406 echo '<td> </td>' . "\n";
1412 echo '</tr>' . "\n";
1416 reset($vertical_display['desc']);
1418 while (list($key, $val) = each($vertical_display['desc'])) {
1421 if (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
1422 $bgcolor = '#ffffff';
1424 $bgcolor = ($row_no %
2) ?
$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
1428 if (!isset($GLOBALS['printview']) ||
($GLOBALS['printview'] != '1')) {
1429 if ($GLOBALS['cfg']['BrowsePointerColor'] != '') {
1430 $on_mouse = ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
1431 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
1433 if ($GLOBALS['cfg']['BrowseMarkerColor'] != '') {
1434 $on_mouse .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
1438 echo '<tr ' . $on_mouse . '>' . "\n";
1442 while (list($subkey, $subval) = each($vertical_display['rowdata'][$key])) {
1443 if (($foo_counter != 0) && ($repeat_cells != 0) and !($foo_counter %
$repeat_cells)) {
1451 echo '</tr>' . "\n";
1454 // Displays "edit" link at bottom if required
1455 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['edit'])) {
1457 echo $vertical_display['textbtn'];
1458 reset($vertical_display['edit']);
1460 while (list($key, $val) = each($vertical_display['edit'])) {
1461 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1462 echo '<td> </td>' . "\n";
1468 echo '</tr>' . "\n";
1471 // Displays "delete" link at bottom if required
1472 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['delete'])) {
1474 if (!is_array($vertical_display['edit'])) {
1475 echo $vertical_display['textbtn'];
1477 reset($vertical_display['delete']);
1479 while (list($key, $val) = each($vertical_display['delete'])) {
1480 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1481 echo '<td> </td>' . "\n";
1487 echo '</tr>' . "\n";
1491 } // end of the 'PMA_displayVerticalTable' function
1495 * Displays a table of results returned by a sql query.
1496 * This function is called by the "sql.php3" script.
1498 * @param integer the link id associated to the query which results have
1500 * @param array the display mode
1501 * @param array the analyzed query
1503 * @global string the current language
1504 * @global integer the server to use (refers to the number in the
1505 * configuration file)
1506 * @global array the current server config
1507 * @global string the database name
1508 * @global string the table name
1509 * @global string the url to go back in case of errors
1510 * @global string the current sql query
1511 * @global integer the total number of rows returned by the sql query
1512 * @global integer the total number of rows returned by the sql query
1513 * without any programmatically appended "LIMIT" clause
1514 * @global integer the current postion of the first record to be
1516 * @global array the list of fields properties
1517 * @global integer the total number of fields returned by the sql query
1518 * @global array informations used with vertical display mode
1519 * @global string the display mode (horizontal/vertical/horizontalflipped)
1520 * @global integer the number of row to display between two table headers
1521 * @global boolean whether to limit the number of displayed characters of
1522 * text type fields or not
1523 * @global array the relation settings
1527 * @see PMA_showMessage(), PMA_setDisplayMode(),
1528 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1529 * PMA_displayTableBody()
1531 function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
1533 global $lang, $server, $cfg, $db, $table;
1535 global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
1536 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
1537 global $dontlimitchars;
1538 global $cfgRelation;
1540 // 1. ----- Prepares the work -----
1542 // 1.1 Gets the informations about which functionnalities should be
1545 $is_display = PMA_setDisplayMode($the_disp_mode, $total);
1550 // 1.2 Defines offsets for the next and previous pages
1551 if ($is_display['nav_bar'] == '1') {
1555 if ($GLOBALS['session_max_rows'] == 'all') {
1559 $pos_next = $pos +
$GLOBALS['cfg']['MaxRows'];
1560 $pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
1561 if ($pos_prev < 0) {
1567 // 1.3 Urlencodes the query to use in input form fields
1568 $encoded_sql_query = urlencode($sql_query);
1570 // 2. ----- Displays the top of the page -----
1572 // 2.1 Displays a messages with position informations
1573 if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
1574 if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
1575 $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
1579 $last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' ||
$pos_next > $total)
1582 PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
1583 } else if (!isset($GLOBALS['printview']) ||
$GLOBALS['printview'] != '1') {
1584 PMA_showMessage($GLOBALS['strSQLQuery']);
1587 // 2.3 Displays the navigation bars
1588 if (!isset($table) ||
strlen(trim($table)) == 0) {
1589 $table = $fields_meta[0]->table
;
1591 if ($is_display['nav_bar'] == '1') {
1592 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1594 } else if (!isset($GLOBALS['printview']) ||
$GLOBALS['printview'] != '1') {
1595 echo "\n" . '<br /><br />' . "\n";
1598 // 2b ----- Get field references from Database -----
1599 // (see the 'relation' config variable)
1600 // loic1, 2002-03-02: extended to php3
1605 if ($cfgRelation['relwork']) {
1607 //$pattern = '`?[[:space:]]+(((ON|on)[[:space:]]+[^,]+)?,|((NATURAL|natural)[[:space:]]+)?(INNER|inner|LEFT|left|RIGHT|right)([[:space:]]+(OUTER|outer))?[[:space:]]+(JOIN|join))[[:space:]]*`?';
1608 //$target = eregi_replace('^.*[[:space:]]+FROM[[:space:]]+`?|`?[[:space:]]*(ON[[:space:]]+[^,]+)?(WHERE[[:space:]]+.*)?$', '', $sql_query);
1609 //$target = eregi_replace('`?[[:space:]]ORDER BY[[:space:]](.*)','',$target);
1610 //$tabs = '(\'' . join('\',\'', split($pattern, $target)) . '\')';
1612 reset($analyzed_sql[0]['table_ref']);
1613 while (list ($table_ref_position, $table_ref) = each ($analyzed_sql[0]['table_ref'])) {
1614 $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
1616 $tabs = '(\'' . join('\',\'', $target) . '\')';
1618 $local_query = 'SELECT master_field, foreign_db, foreign_table, foreign_field'
1619 . ' FROM ' . PMA_backquote($cfgRelation['relation'])
1620 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
1621 . ' AND master_table IN ' . $tabs;
1622 $result = @PMA_query_as_cu
($local_query, FALSE);
1624 while ($rel = PMA_mysql_fetch_row($result)) {
1625 // check for display field?
1626 if ($cfgRelation['displaywork']) {
1627 $display_field = PMA_getDisplayField($db, $rel[2]);
1628 $map[$rel[0]] = array($rel[2], $rel[3], $display_field);
1634 // 3. ----- Displays the results table -----
1635 echo '<!-- Results table -->' . "\n"
1637 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
1638 echo 'border="1" cellpadding="2" cellspacing="0"';
1640 echo 'border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="5"';
1643 PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
1644 PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
1645 // lem9: vertical output case
1646 if ($disp_direction == 'vertical') {
1647 PMA_displayVerticalTable();
1649 unset($vertical_display);
1656 // 4. ----- Displays the navigation bar at the bottom if required -----
1658 if ($is_display['nav_bar'] == '1') {
1659 echo '<br />' . "\n";
1660 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1661 } else if (!isset($GLOBALS['printview']) ||
$GLOBALS['printview'] != '1') {
1662 echo "\n" . '<br /><br />' . "\n";
1664 } // end of the 'PMA_displayTable()' function
1666 } // $__PMA_DISPLAY_TBL_LIB__