Fix not displaying content of TEXT fields (was treated like BLOB).
[phpmyadmin/crack.git] / libraries / display_tbl.lib.php3
blob757fbc7273c04d240473158af8d9113477643af4
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Set of functions used to display the records returned by a sql query
7 */
9 if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
10 define('PMA_DISPLAY_TBL_LIB_INCLUDED', 1);
12 /**
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.
16 * In this string:
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
19 * edit link...);
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
22 * no delete link...);
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
37 * elements
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
45 * statement
47 * @access private
49 * @see PMA_displayTable()
51 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
53 global $db, $table;
54 global $unlim_num_rows, $fields_meta;
55 global $err_url;
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
69 // display mode
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
103 else {
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)
119 else {
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';
129 if (!$is_link) {
130 break;
132 } // end if (2.3.1)
133 // 2.3.2 Displays edit/delete/sort/insert links?
134 if ($is_link
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
139 // two joined table.
140 // $do_display['sort_lnk'] = (string) '0';
141 $do_display['ins_row'] = (string) '0';
142 if ($do_display['text_btn'] == '1') {
143 break;
145 } // end if (2.3.2)
146 // 2.3.3 Always display print view link
147 $do_display['pview_lnk'] = (string) '1';
148 $prev_table = $fields_meta[$i]->table;
149 } // end for
150 } // end if..elseif...else (2.1 -> 2.3)
151 } // end if (2)
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 $the_total = PMA_countRecords($db, $table, TRUE);
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') {
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';
173 } // end if (3)
175 // 5. Updates the synthetic var
176 $the_disp_mode = join('', $do_display);
178 return $do_display;
179 } // end of the 'PMA_setDisplayMode()' function
183 * Displays a navigation bar to browse among the results of a sql query
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
189 * @global string the current language
190 * @global string the currect charset for MySQL
191 * @global integer the server to use (refers to the number in the
192 * configuration file)
193 * @global string the database name
194 * @global string the table name
195 * @global string the url to go back in case of errors
196 * @global integer the total number of rows returned by the sql query
197 * @global integer the total number of rows returned by the sql query
198 * without any programmatically appended "LIMIT" clause
199 * @global integer the current position in results
200 * @global mixed the maximum number of rows per page ('all' = no limit)
201 * @global string the display mode (horizontal/vertical/horizontalflipped)
202 * @global integer the number of row to display between two table headers
203 * @global boolean whether to limit the number of displayed characters of
204 * text type fields or not
206 * @access private
208 * @see PMA_displayTable()
210 function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
212 global $lang, $convcharset, $server, $db, $table;
213 global $goto;
214 global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
215 global $disp_direction, $repeat_cells;
216 global $dontlimitchars;
219 <!-- Navigation bar -->
220 <table border="0">
221 <tr>
222 <?php
223 // Move to the beginning or to the previous page
224 if ($pos > 0 && $session_max_rows != 'all') {
225 // loic1: patch #474210 from Gosha Sakovich - part 1
226 if ($GLOBALS['cfg']['NavigationBarIconic']) {
227 $caption1 = '&lt;&lt;';
228 $caption2 = '&nbsp;&lt;&nbsp;';
229 $title1 = ' title="' . $GLOBALS['strPos1'] . '"';
230 $title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
231 } else {
232 $caption1 = $GLOBALS['strPos1'] . ' &lt;&lt;';
233 $caption2 = $GLOBALS['strPrevious'] . ' &lt;';
234 $title1 = '';
235 $title2 = '';
236 } // end if... else...
238 <td>
239 <form action="sql.php3" method="post">
240 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
241 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
242 <input type="hidden" name="pos" value="0" />
243 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
244 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
245 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
246 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
247 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
248 <input type="submit" name="navig" value="<?php echo $caption1; ?>"<?php echo $title1; ?> />
249 </form>
250 </td>
251 <td>
252 <form action="sql.php3" method="post">
253 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
254 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
255 <input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
256 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
257 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
258 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
259 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
260 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
261 <input type="submit" name="navig" value="<?php echo $caption2; ?>"<?php echo $title2; ?> />
262 </form>
263 </td>
264 <?php
265 } // end move back
266 echo "\n";
268 <td>
269 &nbsp;&nbsp;&nbsp;
270 </td>
271 <td align="center">
272 <form action="sql.php3" method="post"
273 onsubmit="return (checkFormElementInRange(this, 'session_max_rows', 1) && checkFormElementInRange(this, 'pos', 0, <?php echo $unlim_num_rows - 1; ?>))">
274 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
275 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
276 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
277 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
278 <input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
279 <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()" />
280 <?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
281 <input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
282 <br />
283 <?php
284 // Display mode (horizontal/vertical and repeat headers)
285 $param1 = ' <select name="disp_direction">' . "\n"
286 . ' <option value="horizontal"' . (($disp_direction == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
287 . ' <option value="horizontalflipped"' . (($disp_direction == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
288 . ' <option value="vertical"' . (($disp_direction == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
289 . ' </select>' . "\n"
290 . ' ';
291 $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" class="textfield" />' . "\n"
292 . ' ';
293 echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
295 </form>
296 </td>
297 <td>
298 &nbsp;&nbsp;&nbsp;
299 </td>
300 <?php
301 // Move to the next page or to the last one
302 if (($pos + $session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
303 && $session_max_rows != 'all') {
304 // loic1: patch #474210 from Gosha Sakovich - part 2
305 if ($GLOBALS['cfg']['NavigationBarIconic']) {
306 $caption3 = '&nbsp;&gt;&nbsp;';
307 $caption4 = '&gt;&gt;';
308 $title3 = ' title="' . $GLOBALS['strNext'] . '"';
309 $title4 = ' title="' . $GLOBALS['strEnd'] . '"';
310 } else {
311 $caption3 = '&gt; ' . $GLOBALS['strNext'];
312 $caption4 = '&gt;&gt; ' . $GLOBALS['strEnd'];
313 $title3 = '';
314 $title4 = '';
315 } // end if... else...
316 echo "\n";
318 <td>
319 <form action="sql.php3" method="post">
320 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
321 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
322 <input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
323 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
324 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
325 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
326 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
327 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
328 <input type="submit" name="navig" value="<?php echo $caption3; ?>"<?php echo $title3; ?> />
329 </form>
330 </td>
331 <td>
332 <form action="sql.php3" method="post"
333 onsubmit="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
334 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
335 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
336 <input type="hidden" name="pos" value="<?php echo $unlim_num_rows - $session_max_rows; ?>" />
337 <input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
338 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
339 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
340 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
341 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
342 <input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> />
343 </form>
344 </td>
345 <?php
346 } // end move toward
349 //page redirection
350 $pageNow = @floor($pos / $session_max_rows) + 1;
351 $nbTotalPage = @ceil($unlim_num_rows / $session_max_rows);
353 if ($nbTotalPage > 1){ //if1
355 <td>
356 &nbsp;&nbsp;&nbsp;
357 </td>
358 <td>
359 <?php //<form> for keep the form alignment of button < and << ?>
360 <form>
361 <?php echo $GLOBALS['strPageNumber']; ?>
362 <select name="goToPage" onChange="goToUrl(this, '<?php echo "sql.php3?sql_query=".$encoded_query."&amp;session_max_rows=".$session_max_rows."&amp;disp_direction=".$disp_direction."&amp;repeat_cells=".$repeat_cells."&amp;goto=".$goto."&amp;dontlimitchars=".$dontlimitchars."&amp;".PMA_generate_common_url($db, $table)."&amp;"; ?>')">
364 <?php
365 if ($nbTotalPage < 200) {
366 $firstPage = 1;
367 $lastPage = $nbTotalPage;
368 } else {
369 $range = 20;
370 $firstPage = ($pageNow - $range < 1 ? 1 : $pageNow - $range);
371 $lastPage = ($pageNow + $range > $nbTotalPage ? $nbTotalPage : $pageNow + $range);
373 for ($i=$firstPage; $i<=$lastPage; $i++){
374 if ($i == $pageNow) {
375 $selected = 'selected="selected"';
376 } else {
377 $selected = "";
379 echo " <option ".$selected." value=\"".(($i - 1) * $session_max_rows)."\">".$i."</option>\n";
383 </select>
384 </form>
385 </td>
386 <?php
387 } //_if1
390 // Show all the records if allowed
391 if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
392 echo "\n";
394 <td>
395 &nbsp;&nbsp;&nbsp;
396 </td>
397 <td>
398 <form action="sql.php3" method="post">
399 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
400 <input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
401 <input type="hidden" name="pos" value="0" />
402 <input type="hidden" name="session_max_rows" value="all" />
403 <input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
404 <input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
405 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
406 <input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
407 <input type="submit" name="navig" value="<?php echo $GLOBALS['strShowAll']; ?>" />
408 </form>
409 </td>
410 <?php
411 } // end show all
412 echo "\n";
414 </tr>
415 </table>
417 <?php
418 } // end of the 'PMA_displayTableNavigation()' function
422 * Displays the headers of the results table
424 * @param array which elements to display
425 * @param array the list of fields properties
426 * @param integer the total number of fields returned by the sql query
427 * @param array the analyzed query
429 * @return boolean always true
431 * @global string the current language
432 * @global string the current charset for MySQL
433 * @global integer the server to use (refers to the number in the
434 * configuration file)
435 * @global string the database name
436 * @global string the table name
437 * @global string the sql query
438 * @global string the url to go back in case of errors
439 * @global integer the total number of rows returned by the sql query
440 * @global integer the current position in results
441 * @global integer the maximum number of rows per page
442 * @global array informations used with vertical display mode
443 * @global string the display mode (horizontal/vertical/horizontalflipped)
444 * @global integer the number of row to display between two table headers
445 * @global boolean whether to limit the number of displayed characters of
446 * text type fields or not
448 * @access private
450 * @see PMA_displayTable()
452 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
454 global $lang, $convcharset, $server, $db, $table;
455 global $goto;
456 global $sql_query, $num_rows, $pos, $session_max_rows;
457 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
458 global $dontlimitchars;
460 if ($analyzed_sql == '') {
461 $analyzed_sql = array();
464 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
466 <!-- Results table headers -->
467 <tr>
468 <?php
469 echo "\n";
472 $vertical_display['emptypre'] = 0;
473 $vertical_display['emptyafter'] = 0;
474 $vertical_display['textbtn'] = '';
476 // 1. Displays the full/partial text button (part 1)...
477 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
478 $colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
479 ? ' colspan="2"'
480 : '';
481 } else {
482 $rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
483 ? ' rowspan="2"'
484 : '';
486 $text_url = 'sql.php3?'
487 . PMA_generate_common_url($db, $table)
488 . '&amp;sql_query=' . urlencode($sql_query)
489 . '&amp;pos=' . $pos
490 . '&amp;session_max_rows=' . $session_max_rows
491 . '&amp;pos=' . $pos
492 . '&amp;disp_direction=' . $disp_direction
493 . '&amp;repeat_cells=' . $repeat_cells
494 . '&amp;goto=' . $goto
495 . '&amp;dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
497 // ... before the result table
498 if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
499 && $is_display['text_btn'] == '1') {
500 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 2 : 0;
501 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
503 <td colspan="<?php echo $fields_cnt; ?>" align="center">
504 <a href="<?php echo $text_url; ?>">
505 <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>
506 </td>
507 </tr>
509 <tr>
510 <?php
511 } // end horizontal/horizontalflipped mode
512 else {
513 echo "\n";
515 <tr>
516 <td colspan="<?php echo $num_rows + floor($num_rows/$repeat_cells) + 1; ?>" align="center">
517 <a href="<?php echo $text_url; ?>">
518 <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>
519 </td>
520 </tr>
521 <?php
522 } // end vertical mode
525 // ... at the left column of the result table header if possible
526 // and required
527 else if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
528 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 2 : 0;
529 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
530 echo "\n";
532 <td<?php echo $colspan; ?> align="center">
533 <a href="<?php echo $text_url; ?>">
534 <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>
535 </td>
536 <?php
537 } // end horizontal/horizontalflipped mode
538 else {
539 $vertical_display['textbtn'] = ' <td' . $rowspan . ' align="center" valign="middle">' . "\n"
540 . ' <a href="' . $text_url . '">' . "\n"
541 . ' <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"
542 . ' </td>' . "\n";
543 } // end vertical mode
546 // ... else if no button, displays empty(ies) col(s) if required
547 else if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
548 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
549 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 2 : 0;
550 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
551 echo "\n";
553 <td<?php echo $colspan; ?>></td>
554 <?php
555 echo "\n";
556 } // end horizontal/horizontalfipped mode
557 else {
558 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
559 } // end vertical mode
562 // 2. Displays the fields' name
563 // 2.0 If sorting links should be used, checks if the query is a "JOIN"
564 // statement (see 2.1.3)
566 // 2.0.1 Prepare Display column comments if enabled ($cfg['ShowBrowseComments']).
567 // Do not show comments, if using horizontalflipped mode, because of space usage
568 if ($GLOBALS['cfg']['ShowBrowseComments'] && $GLOBALS['cfgRelation']['commwork'] && $disp_direction != 'horizontalflipped') {
569 $comments_map = PMA_getComments($db, $table);
570 } else {
571 $comments_map = array();
574 if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
575 require('./libraries/transformations.lib.php3');
576 $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
580 if ($is_display['sort_lnk'] == '1') {
581 $is_join = eregi('(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN', $sql_query, $select_stt);
582 } else {
583 $is_join = FALSE;
586 // garvin: See if we have to highlight any header fields of a WHERE query.
587 // Uses SQL-Parser results.
588 $highlight_columns = array();
589 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
590 isset($analyzed_sql[0]['where_clause_identifiers'])) {
592 $wi = 0;
593 @reset($analyzed_sql[0]['where_clause_identifiers']);
594 while(list($wci_nr, $wci) = each($analyzed_sql[0]['where_clause_identifiers'])) {
595 $highlight_columns[$wci] = 'true';
599 for ($i = 0; $i < $fields_cnt; $i++) {
600 // garvin: See if this column should get highlight because it's used in the
601 // where-query.
602 if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
603 $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
604 } else {
605 $column_style = '';
608 // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
609 if (isset($comments_map[$fields_meta[$i]->name])) {
610 $comments_table_wrap_pre = '<table border="0" cellpadding="0" cellspacing="0"><tr><th>';
611 $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>';
612 } else {
613 $comments_table_wrap_pre = '';
614 $comments_table_wrap_post = '';
617 // 2.1 Results can be sorted
618 if ($is_display['sort_lnk'] == '1') {
619 // Defines the url used to append/modify a sorting order
620 // 2.1.1 Checks if an hard coded 'order by' clause exists
621 if (eregi('(.*)([[:space:]]ORDER[[:space:]]*BY[[:space:]](.*))', $sql_query, $regs1)) {
622 if (eregi('((.*)([[:space:]]ASC|[[:space:]]DESC)([[:space:]]|$))(.*)', $regs1[2], $regs2)) {
623 $unsorted_sql_query = trim($regs1[1] . ' ' . $regs2[5]);
624 $sql_order = trim($regs2[1]);
625 eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order);
626 $sort_expression = trim($after_order[2]);
628 else if (eregi('((.*))[[:space:]]+(LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE)', $regs1[2], $regs3)) {
629 $unsorted_sql_query = trim($regs1[1] . ' ' . $regs3[3]);
630 $sql_order = trim($regs3[1]) . ' ASC';
631 eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order);
632 $sort_expression = trim($after_order[2]);
633 } else {
634 $unsorted_sql_query = trim($regs1[1]);
635 $sql_order = trim($regs1[2]) . ' ASC';
636 eregi('(ORDER[[:space:]]*BY[[:space:]]*)(.*)([[:space:]]*ASC|[[:space:]]*DESC)',$sql_order,$after_order);
637 $sort_expression = trim($after_order[2]);
639 } else {
640 $unsorted_sql_query = $sql_query;
643 // 2.1.2 Checks if the current column is used to sort the
644 // results
645 if (empty($sql_order)) {
646 $is_in_sort = FALSE;
647 } else {
648 // $pattern = str_replace('\\', '\\\\', $fields_meta[$i]->name);
649 // $pattern = str_replace('(','\(', $pattern);
650 // $pattern = str_replace(')','\)', $pattern);
651 // $pattern = str_replace('*','\*', $pattern);
653 // field name may be preceded by a space, or any number
654 // of characters followed by a dot (tablename.fieldname)
655 // $is_in_sort = eregi('([[:space:]]|(.*\.))(`?)' . $pattern . '(`?)[ ,$]', $sql_order);
656 // instead of using eregi(), now do a direct comparison
657 // for the sort expression (avoids problems with queries
658 // like "SELECT id, count(id)..." and clicking to sort
659 // on id or on count(id) )
660 $is_in_sort = (PMA_backquote($fields_meta[$i]->name) == $sort_expression ? TRUE : FALSE);
662 // 2.1.3 Checks if the table name is required (it's the case
663 // for a query with a "JOIN" statement and if the column
664 // isn't aliased)
665 if ($is_join
666 && !eregi('([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name, $select_stt[1], $parts)) {
667 $sort_tbl = PMA_backquote($fields_meta[$i]->table) . '.';
668 } else {
669 $sort_tbl = '';
671 // 2.1.4 Check the field name for backquotes.
672 // If it contains some, it's probably a function column
673 // like 'COUNT(`field`)'
674 if (strpos(' ' . $fields_meta[$i]->name, '`') > 0) {
675 $sort_order = ' ORDER BY \'' . $fields_meta[$i]->name . '\' ';
676 } else {
677 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name) . ' ';
679 // 2.1.5 Do define the sorting url
680 if (!$is_in_sort) {
681 // loic1: patch #455484 ("Smart" order)
682 $cfg['Order'] = strtoupper($GLOBALS['cfg']['Order']);
683 if ($cfg['Order'] == 'SMART') {
684 $cfg['Order'] = (eregi('time|date', $fields_meta[$i]->type)) ? 'DESC' : 'ASC';
686 $sort_order .= $cfg['Order'];
687 $order_img = '';
689 else if (eregi('[[:space:]]ASC$', $sql_order)) {
690 $sort_order .= ' DESC';
691 $order_img = '&nbsp;<img src="./images/asc_order.png" border="0" width="7" height="7" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" />';
693 else if (eregi('[[:space:]]DESC$', $sql_order)) {
694 $sort_order .= ' ASC';
695 $order_img = '&nbsp;<img src="./images/desc_order.png" border="0" width="7" height="7" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" />';
697 if (eregi('(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))', $unsorted_sql_query, $regs3)) {
698 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
699 } else {
700 $sorted_sql_query = $unsorted_sql_query . $sort_order;
702 $url_query = PMA_generate_common_url($db, $table)
703 . '&amp;pos=' . $pos
704 . '&amp;session_max_rows=' . $session_max_rows
705 . '&amp;disp_direction=' . $disp_direction
706 . '&amp;repeat_cells=' . $repeat_cells
707 . '&amp;dontlimitchars=' . $dontlimitchars
708 . '&amp;sql_query=' . urlencode($sorted_sql_query);
710 // 2.1.5 Displays the sorting url
711 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
712 echo "\n";
714 <th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') echo 'valign="bottom"'; ?>>
715 <?php echo $comments_table_wrap_pre; ?>
716 <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;"' : ''); ?>>
717 <?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"; ?>
718 <?php echo $comments_table_wrap_post; ?>
719 </th>
720 <?php
722 $vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
723 . $comments_table_wrap_pre
724 . ' <a href="sql.php3?' . $url_query . '">' . "\n"
725 . ' ' . htmlspecialchars($fields_meta[$i]->name) . '</a>' . $order_img . "\n"
726 . $comments_table_wrap_post
727 . ' </th>' . "\n";
728 } // end if (2.1)
730 // 2.2 Results can't be sorted
731 else {
732 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
733 echo "\n";
735 <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;"' : ''); ?>>
736 <?php echo $comments_table_wrap_pre; ?>
737 <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake'? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name)) . "\n"; ?>
738 <?php echo $comments_table_wrap_post; ?>
739 </th>
740 <?php
742 $vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
743 . $comments_table_wrap_pre
744 . ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
745 . $comments_table_wrap_post
746 . ' </th>';
747 } // end else (2.2)
748 } // end for
750 // 3. Displays the full/partial text button (part 2) at the right
751 // column of the result table header if possible and required...
752 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
753 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
754 && $is_display['text_btn'] == '1') {
755 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 2 : 1;
756 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
757 echo "\n";
759 <td<?php echo $colspan; ?> align="center">
760 <a href="<?php echo $text_url; ?>">
761 <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>
762 </td>
763 <?php
764 } // end horizontal/horizontalflipped mode
765 else {
766 $vertical_display['textbtn'] = ' <td' . $rowspan . ' align="center" valign="middle">' . "\n"
767 . ' <a href="' . $text_url . '">' . "\n"
768 . ' <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"
769 . ' </td>' . "\n";
770 } // end vertical mode
773 // ... else if no button, displays empty cols if required
774 // (unless coming from Browse mode print view)
775 else if ($GLOBALS['cfg']['ModifyDeleteAtRight']
776 && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
777 && (!$GLOBALS['is_header_sent'])) {
778 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 2 : 1;
779 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
780 echo "\n";
782 <td<?php echo $colspan; ?>></td>
783 <?php
784 } // end horizontal/horizontalflipped mode
785 else {
786 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
787 } // end vertical mode
790 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
791 echo "\n";
793 </tr>
794 <?php
796 echo "\n";
798 return TRUE;
799 } // end of the 'PMA_displayTableHeaders()' function
804 * Displays the body of the results table
806 * @param integer the link id associated to the query which results have
807 * to be displayed
808 * @param array which elements to display
809 * @param array the list of relations
810 * @param array the analyzed query
812 * @return boolean always true
814 * @global string the current language
815 * @global string the current charset for MySQL
816 * @global integer the server to use (refers to the number in the
817 * configuration file)
818 * @global string the database name
819 * @global string the table name
820 * @global string the sql query
821 * @global string the url to go back in case of errors
822 * @global integer the current position in results
823 * @global integer the maximum number of rows per page
824 * @global array the list of fields properties
825 * @global integer the total number of fields returned by the sql query
826 * @global array informations used with vertical display mode
827 * @global string the display mode (horizontal/vertical/horizontalflipped)
828 * @global integer the number of row to display between two table headers
829 * @global boolean whether to limit the number of displayed characters of
830 * text type fields or not
832 * @access private
834 * @see PMA_displayTable()
836 function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
838 global $lang, $convcharset, $server, $db, $table;
839 global $goto;
840 global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
841 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
842 global $dontlimitchars;
844 if (!is_array($map)) {
845 $map = array();
848 <!-- Results table body -->
849 <?php
850 echo "\n";
852 $row_no = 0;
853 $vertical_display['edit'] = array();
854 $vertical_display['delete'] = array();
855 $vertical_display['data'] = array();
857 // Correction uva 19991216 in the while below
858 // Previous code assumed that all tables have keys, specifically that
859 // the phpMyAdmin GUI should support row delete/edit only for such
860 // tables.
861 // Although always using keys is arguably the prescribed way of
862 // defining a relational table, it is not required. This will in
863 // particular be violated by the novice.
864 // We want to encourage phpMyAdmin usage by such novices. So the code
865 // below has been changed to conditionally work as before when the
866 // table being displayed has one or more keys; but to display
867 // delete/edit options correctly for tables without keys.
869 // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
870 // to get the NULL values
872 while ($row = PMA_mysql_fetch_array($dt_result)) {
874 // lem9: "vertical display" mode stuff
875 if (($row_no != 0) && ($repeat_cells != 0) && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
876 echo '<tr>' . "\n";
878 for ($foo_i = 0; $foo_i < $vertical_display['emptypre']; $foo_i++) {
879 echo ' <td>&nbsp;</td>' . "\n";
882 reset($vertical_display['desc']);
883 while (list($key, $val) = each($vertical_display['desc'])) {
884 echo $val;
887 for ($foo_i = 0; $foo_i < $vertical_display['emptyafter']; $foo_i++) {
888 echo ' <td>&nbsp;</td>' . "\n";
891 echo '</tr>' . "\n";
892 } // end if
894 if (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
895 $bgcolor = '#ffffff';
896 } else {
897 $bgcolor = ($row_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
900 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
901 // loic1: pointer code part
902 $on_mouse = '';
903 if (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) {
904 if ($GLOBALS['cfg']['BrowsePointerColor'] != '') {
905 $on_mouse = ' onmouseover="setPointer(this, ' . $row_no . ', \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
906 . ' onmouseout="setPointer(this, ' . $row_no . ', \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
908 if ($GLOBALS['cfg']['BrowseMarkerColor'] != '') {
909 $on_mouse .= ' onmousedown="setPointer(this, ' . $row_no . ', \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
911 } // end if
913 <tr<?php echo $on_mouse; ?>>
914 <?php
915 echo "\n";
918 // 1. Prepares the row (gets primary keys to use)
919 if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
920 $primary_key = '';
921 $unique_key = '';
922 $uva_nonprimary_condition = '';
924 // 1.1 Results from a "SELECT" statement -> builds the
925 // "primary" key to use in links
926 if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) {
927 for ($i = 0; $i < $fields_cnt; ++$i) {
928 $field_flags = PMA_mysql_field_flags($dt_result, $i);
929 $meta = $fields_meta[$i];
931 // do not use an alias in a condition
932 $column_for_condition = $meta->name;
933 reset($analyzed_sql[0]['select_expr']);
934 while (list ($select_expr_position, $select_expr) = each ($analyzed_sql[0]['select_expr'])) {
935 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
936 if (!empty($alias)) {
937 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
938 if ($alias == $meta->name) {
939 $column_for_condition = $true_column;
940 } // end if
941 } // end if
942 } // end while
944 // to fix the bug where float fields (primary or not)
945 // can't be matched because of the imprecision of
946 // floating comparison, use CONCAT
947 // (also, the syntax "CONCAT(field) IS NULL"
948 // that we need on the next "if" will work)
949 if ($meta->type == 'real') {
950 $condition = ' CONCAT(' . PMA_backquote($column_for_condition) . ') ';
951 } else {
952 $condition = ' ' . PMA_backquote($column_for_condition) . ' ';
953 } // end if... else...
955 // loic1: To fix bug #474943 under php4, the row
956 // pointer will depend on whether the "is_null"
957 // php4 function is available or not
958 $pointer = (function_exists('is_null') ? $i : $meta->name);
959 if (!isset($row[$meta->name])
960 || (function_exists('is_null') && is_null($row[$pointer]))) {
961 $condition .= 'IS NULL AND';
962 } else {
963 if ($meta->type == 'blob'
964 // hexify only if this is a true BLOB
965 && eregi('BINARY', $field_flags)) {
966 $condition .= 'LIKE 0x' . bin2hex($row[$pointer]). ' AND';
967 } else {
968 $condition .= '= \'' . PMA_sqlAddslashes($row[$pointer], FALSE, TRUE) . '\' AND';
971 if ($meta->primary_key > 0) {
972 $primary_key .= $condition;
973 } else if ($meta->unique_key > 0) {
974 $unique_key .= $condition;
976 $uva_nonprimary_condition .= $condition;
977 } // end for
979 // Correction uva 19991216: prefer primary or unique keys
980 // for condition, but use conjunction of all values if no
981 // primary key
982 if ($primary_key) {
983 $uva_condition = $primary_key;
984 } else if ($unique_key) {
985 $uva_condition = $unique_key;
986 } else {
987 $uva_condition = $uva_nonprimary_condition;
990 $uva_condition = urlencode(ereg_replace('[[:space:]]?AND$', '', $uva_condition));
991 } // end if (1.1)
993 // 1.2 Defines the urls for the modify/delete link(s)
994 $url_query = PMA_generate_common_url($db, $table)
995 . '&amp;pos=' . $pos
996 . '&amp;session_max_rows=' . $session_max_rows
997 . '&amp;disp_direction=' . $disp_direction
998 . '&amp;repeat_cells=' . $repeat_cells
999 . '&amp;dontlimitchars=' . $dontlimitchars;
1001 // 1.2.1 Modify link(s)
1002 if ($is_display['edit_lnk'] == 'ur') { // update row case
1003 // $lnk_goto = 'sql.php3'
1004 // . '?' . str_replace('&amp;', '&', $url_query)
1005 // . '&sql_query=' . urlencode($sql_query)
1006 // . '&goto=' . (empty($goto) ? 'tbl_properties.php3' : $goto);
1007 // to reduce the length of the URL, because of some browsers limitations:
1008 $lnk_goto = 'sql.php3';
1010 $edit_url = 'tbl_change.php3'
1011 . '?' . $url_query
1012 . '&amp;primary_key=' . $uva_condition
1013 . '&amp;sql_query=' . urlencode($sql_query)
1014 . '&amp;goto=' . urlencode($lnk_goto);
1015 $edit_str = $GLOBALS['strEdit'];
1016 } // end if (1.2.1)
1018 if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db']) {
1019 $bookmark_go = '<form method="post" action="read_dump.php3">'
1020 . PMA_generate_common_hidden_inputs($row['dbase'], '')
1021 . '<input type="hidden" name="id_bookmark" value="' . $row['id'] . '" />'
1022 . '<input type="hidden" name="action_bookmark" value="0" />'
1023 . '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />'
1024 . '</form>';
1025 } else {
1026 $bookmark_go = '';
1029 // 1.2.2 Delete/Kill link(s)
1030 if ($is_display['del_lnk'] == 'dr') { // delete row case
1031 $lnk_goto = 'sql.php3'
1032 . '?' . str_replace('&amp;', '&', $url_query)
1033 . '&sql_query=' . urlencode($sql_query)
1034 . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1035 . '&goto=' . (empty($goto) ? 'tbl_properties.php3' : $goto);
1036 $del_url = 'sql.php3'
1037 . '?' . $url_query
1038 . '&amp;sql_query=' . urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . ((PMA_MYSQL_INT_VERSION >= 32207) ? urlencode(' LIMIT 1') : '')
1039 . '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1040 . '&amp;goto=' . urlencode($lnk_goto);
1041 $js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
1042 . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE))
1043 . ((PMA_MYSQL_INT_VERSION >= 32207) ? ' LIMIT 1' : '');
1044 $del_str = $GLOBALS['strDelete'];
1045 } else if ($is_display['del_lnk'] == 'kp') { // kill process case
1046 $lnk_goto = 'sql.php3'
1047 . '?' . str_replace('&amp;', '&', $url_query)
1048 . '&sql_query=' . urlencode($sql_query)
1049 . '&goto=main.php3';
1050 $del_url = 'sql.php3?'
1051 . PMA_generate_common_url('mysql')
1052 . '&amp;sql_query=' . urlencode('KILL ' . $row['Id'])
1053 . '&amp;goto=' . urlencode($lnk_goto);
1054 $js_conf = 'KILL ' . $row['Id'];
1055 $del_str = $GLOBALS['strKill'];
1056 } // end if (1.2.2)
1058 // 1.3 Displays the links at left if required
1059 if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
1060 && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
1061 if (!empty($edit_url)) {
1062 echo ' <td valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
1063 echo PMA_linkOrButton($edit_url, $edit_str, '');
1064 echo $bookmark_go;
1065 echo ' </td>' . "\n";
1067 if (!empty($del_url)) {
1068 echo ' <td valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
1069 echo PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''));
1070 echo ' </td>' . "\n";
1072 } // end if (1.3)
1073 echo (($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') ? "\n" : '');
1074 } // end if (1)
1076 // 2. Displays the rows' values
1077 for ($i = 0; $i < $fields_cnt; ++$i) {
1078 $meta = $fields_meta[$i];
1079 // loic1: To fix bug #474943 under php4, the row pointer will
1080 // depend on whether the "is_null" php4 function is
1081 // available or not
1082 $pointer = (function_exists('is_null') ? $i : $meta->name);
1084 // garvin: See if this column should get highlight because it's used in the
1085 // where-query.
1086 if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) {
1087 $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
1088 } else {
1089 $column_style = '';
1092 // garvin: Wrap MIME-transformations. [MIME]
1093 $default_function = 'htmlspecialchars'; // default_function
1094 $transform_function = $default_function;
1095 $transform_options = array();
1097 if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
1099 if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) {
1100 // garvin: for security, never allow to break out from transformations directory
1101 $include_file = eregi_replace('\.\.*', '.', $GLOBALS['mime_map'][$meta->name]['transformation']);
1103 if (file_exists('./libraries/transformations/' . $include_file)) {
1104 $transformfunction_name = str_replace('.inc.php3', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
1106 include('./libraries/transformations/' . $include_file);
1108 if (defined('PMA_TRANSFORMATION_' . strtoupper($transformfunction_name)) && function_exists('PMA_transformation_' . $transformfunction_name)) {
1109 $transform_function = 'PMA_transformation_' . $transformfunction_name;
1110 $transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''));
1112 } // end if file_exists
1113 } // end if transformation is set
1114 } // end if mime/transformation works.
1116 $transform_options['wrapper_link'] = '?'
1117 . (isset($url_query) ? $url_query : '')
1118 . '&amp;primary_key=' . (isset($uva_condition) ? $uva_condition : '')
1119 . '&amp;sql_query=' . (isset($sql_query) ? urlencode($sql_query) : '')
1120 . '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
1121 . '&amp;transform_key=' . urlencode($meta->name);
1124 // n u m e r i c
1125 if ($meta->numeric == 1) {
1128 // lem9: if two fields have the same name (this is possible
1129 // with self-join queries, for example), using $meta->name
1130 // will show both fields NULL even if only one is NULL,
1131 // so use the $pointer
1132 // (works only if function_exists('is_null')
1133 // PS: why not always work with the number ($i), since
1134 // the default second parameter of
1135 // mysql_fetch_array() is MYSQL_BOTH, so we always get
1136 // associative and numeric indices?
1138 //if (!isset($row[$meta->name])
1139 if (!isset($row[$pointer])
1140 || (function_exists('is_null') && is_null($row[$pointer]))) {
1141 $vertical_display['data'][$row_no][$i] = ' <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
1142 } else if ($row[$pointer] != '') {
1143 $vertical_display['data'][$row_no][$i] = ' <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '" nowrap="nowrap">';
1145 reset($analyzed_sql[0]['select_expr']);
1146 while (list ($select_expr_position, $select_expr) = each ($analyzed_sql[0]['select_expr'])) {
1147 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1148 if (!empty($alias)) {
1149 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1150 if ($alias == $meta->name) {
1151 $meta->name = $true_column;
1152 } // end if
1153 } // end if
1154 } // end while
1156 if (isset($map[$meta->name])) {
1157 // Field to display from the foreign table?
1158 if (!empty($map[$meta->name][2])) {
1159 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1160 . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1161 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
1162 . ' = ' . $row[$pointer];
1163 $dispresult = PMA_mysql_query($dispsql);
1164 if ($dispresult && mysql_num_rows($dispresult) > 0) {
1165 $dispval = PMA_mysql_result($dispresult, 0);
1167 else {
1168 $dispval = $GLOBALS['strLinkNotFound'];
1171 else {
1172 $dispval = '';
1173 } // end if... else...
1174 $title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1176 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php3?'
1177 . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1178 . '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
1179 . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$pointer]) . '"' . $title . '>'
1180 . ($transform_function != $default_function ? $transform_function($row[$pointer], $transform_options) : $transform_function($row[$pointer])) . '</a>';
1181 } else {
1182 $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$pointer], $transform_options) : $transform_function($row[$pointer]));
1184 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1185 } else {
1186 $vertical_display['data'][$row_no][$i] = ' <td align="right" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '" nowrap="nowrap">&nbsp;</td>' . "\n";
1189 // b l o b
1191 } else if ($GLOBALS['cfg']['ShowBlob'] == FALSE && eregi('BLOB', $meta->type)) {
1192 // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
1193 // TEXT fields type, however TEXT fields must be displayed
1194 // even if $cfg['ShowBlob'] is false -> get the true type
1195 // of the fields.
1196 $field_flags = PMA_mysql_field_flags($dt_result, $i);
1197 if (eregi('BINARY', $field_flags)) {
1198 $blobtext = '[BLOB';
1199 if (isset($row[$pointer])) {
1200 $blob_size = PMA_formatByteDown(strlen($row[$pointer]), 3, 1);
1201 $blobtext .= ' - '. $blob_size [0] . ' ' . $blob_size[1];
1202 unset($blob_size);
1205 $blobtext .= ']';
1206 $blobtext = ($default_function != $transform_function ? $transform_function($blobtext, $transform_options) : $default_function($blobtext));
1208 $vertical_display['data'][$row_no][$i] = ' <td align="center" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '">' . $blobtext . '</td>';
1209 } else {
1210 //if (!isset($row[$meta->name])
1211 if (!isset($row[$pointer])
1212 || (function_exists('is_null') && is_null($row[$pointer]))) {
1213 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
1214 } else if ($row[$pointer] != '') {
1215 // garvin: if a transform function for blob is set, none of these replacements will be made
1216 if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
1217 $row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1219 // loic1: displays all space characters, 4 space
1220 // characters for tabulations and <cr>/<lf>
1221 $row[$pointer] = ($default_function != $transform_function ? $transform_function($row[$pointer], $transform_options) : $default_function($row[$pointer]));
1222 $row[$pointer] = str_replace("\011", ' &nbsp;&nbsp;&nbsp;', str_replace(' ', ' &nbsp;', $row[$pointer]));
1223 $row[$pointer] = ereg_replace("((\015\012)|(\015)|(\012))", '<br />', $row[$pointer]);
1225 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">' . $row[$pointer] . '</td>' . "\n";
1226 } else {
1227 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">&nbsp;</td>' . "\n";
1230 } else {
1231 //if (!isset($row[$meta->name])
1232 if (!isset($row[$pointer])
1233 || (function_exists('is_null') && is_null($row[$pointer]))) {
1234 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
1235 } else if ($row[$pointer] != '') {
1236 // loic1: support blanks in the key
1237 $relation_id = $row[$pointer];
1239 // loic1: Cut text/blob fields even if $cfg['ShowBlob'] is true
1240 if (eregi('BLOB', $meta->type)) {
1241 if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
1242 $row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1245 // loic1: displays special characters from binaries
1246 $field_flags = PMA_mysql_field_flags($dt_result, $i);
1247 if (eregi('BINARY', $field_flags)) {
1248 $row[$pointer] = str_replace("\x00", '\0', $row[$pointer]);
1249 $row[$pointer] = str_replace("\x08", '\b', $row[$pointer]);
1250 $row[$pointer] = str_replace("\x0a", '\n', $row[$pointer]);
1251 $row[$pointer] = str_replace("\x0d", '\r', $row[$pointer]);
1252 $row[$pointer] = str_replace("\x1a", '\Z', $row[$pointer]);
1253 $row[$pointer] = ($default_function != $transform_function ? $transform_function('BLOB', $transform_options) : $default_function($row[$pointer]));
1255 // loic1: displays all space characters, 4 space
1256 // characters for tabulations and <cr>/<lf>
1257 else {
1258 $row[$pointer] = ($default_function != $transform_function ? $transform_function($row[$pointer], $transform_options) : $default_function($row[$pointer]));
1259 $row[$pointer] = str_replace("\011", ' &nbsp;&nbsp;&nbsp;', str_replace(' ', ' &nbsp;', $row[$pointer]));
1260 $row[$pointer] = ereg_replace("((\015\012)|(\015)|(\012))", '<br />', $row[$pointer]);
1263 // garvin: transform functions may enable nowrapping:
1264 $function_nowrap = $transform_function . '_nowrap';
1265 $bool_nowrap = (($default_function != $transform_function && function_exists($function_nowrap)) ? $function_nowrap($transform_options) : false);
1267 // loic1: do not wrap if date field type
1268 $nowrap = ((eregi('DATE|TIME', $meta->type) || $bool_nowrap) ? ' nowrap="nowrap"' : '');
1269 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"' . $nowrap . '>';
1271 reset($analyzed_sql[0]['select_expr']);
1272 while (list ($select_expr_position, $select_expr) = each ($analyzed_sql[0]['select_expr'])) {
1273 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1274 if (!empty($alias)) {
1275 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1276 if ($alias == $meta->name) {
1277 $meta->name = $true_column;
1278 } // end if
1279 } // end if
1280 } // end while
1282 if (isset($map[$meta->name])) {
1283 // Field to display from the foreign table?
1284 if (!empty($map[$meta->name][2])) {
1285 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1286 . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1287 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
1288 . ' = \'' . PMA_sqlAddslashes($row[$pointer]) . '\'';
1289 $dispresult = @PMA_mysql_query($dispsql);
1290 if ($dispresult && mysql_num_rows($dispresult) > 0) {
1291 $dispval = PMA_mysql_result($dispresult, 0);
1293 else {
1294 $dispval = $GLOBALS['strLinkNotFound'];
1297 else {
1298 $dispval = '';
1300 $title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1302 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php3?'
1303 . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1304 . '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
1305 . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
1306 . $row[$pointer] . '</a>';
1307 } else {
1308 $vertical_display['data'][$row_no][$i] .= $row[$pointer];
1310 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1311 } else {
1312 $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">&nbsp;</td>' . "\n";
1316 // lem9: output stored cell
1317 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1318 echo $vertical_display['data'][$row_no][$i];
1321 if (isset($vertical_display['rowdata'][$i][$row_no])) {
1322 $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
1323 } else {
1324 $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
1326 } // end for (2)
1328 // 3. Displays the modify/delete links on the right if required
1329 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
1330 && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
1331 if (!empty($edit_url)) {
1332 echo ' <td valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
1333 echo PMA_linkOrButton($edit_url, $edit_str, '');
1334 echo $bookmark_go;
1335 echo ' </td>' . "\n";
1337 if (!empty($del_url)) {
1338 echo ' <td valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n";
1339 echo PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''));
1340 echo ' </td>' . "\n";
1342 } // end if (3)
1344 if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1345 echo "\n";
1347 </tr>
1348 <?php
1349 } // end if
1351 // 4. Gather links of del_urls and edit_urls in an array for later
1352 // output
1353 if (!isset($vertical_display['edit'][$row_no])) {
1354 $vertical_display['edit'][$row_no] = '';
1355 $vertical_display['delete'][$row_no] = '';
1358 if (isset($edit_url)) {
1359 $vertical_display['edit'][$row_no] .= ' <td valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
1360 . PMA_linkOrButton($edit_url, $edit_str, '')
1361 . $bookmark_go
1362 . ' </td>' . "\n";
1365 if (isset($del_url)) {
1366 $vertical_display['delete'][$row_no] .= ' <td valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n"
1367 . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''))
1368 . ' </td>' . "\n";
1371 echo (($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') ? "\n" : '');
1372 $row_no++;
1373 } // end while
1375 return TRUE;
1376 } // end of the 'PMA_displayTableBody()' function
1380 * Do display the result table with the vertical direction mode.
1381 * Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
1383 * @return boolean always true
1385 * @global array the information to display
1386 * @global integer the number of row to display between two table headers
1388 * @access private
1390 * @see PMA_displayTable()
1392 function PMA_displayVerticalTable()
1394 global $vertical_display, $repeat_cells;
1396 reset($vertical_display);
1398 // Displays "edit" link at top if required
1399 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['edit'])) {
1400 echo '<tr>' . "\n";
1401 echo $vertical_display['textbtn'];
1402 reset($vertical_display['edit']);
1403 $foo_counter = 0;
1404 while (list($key, $val) = each($vertical_display['edit'])) {
1405 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1406 echo ' <td>&nbsp;</td>' . "\n";
1409 echo $val;
1410 $foo_counter++;
1411 } // end while
1412 echo '</tr>' . "\n";
1413 } // end if
1415 // Displays "delete" link at top if required
1416 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['delete'])) {
1417 echo '<tr>' . "\n";
1418 if (!is_array($vertical_display['edit'])) {
1419 echo $vertical_display['textbtn'];
1421 reset($vertical_display['delete']);
1422 $foo_counter = 0;
1423 while (list($key, $val) = each($vertical_display['delete'])) {
1424 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1425 echo '<td>&nbsp;</td>' . "\n";
1428 echo $val;
1429 $foo_counter++;
1430 } // end while
1431 echo '</tr>' . "\n";
1432 } // end if
1434 // Displays data
1435 reset($vertical_display['desc']);
1436 $row_no = 0;
1437 while (list($key, $val) = each($vertical_display['desc'])) {
1438 $row_no++;
1440 if (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
1441 $bgcolor = '#ffffff';
1442 } else {
1443 $bgcolor = ($row_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
1446 $on_mouse = '';
1447 if (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) {
1448 if ($GLOBALS['cfg']['BrowsePointerColor'] != '') {
1449 $on_mouse = ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
1450 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
1452 if ($GLOBALS['cfg']['BrowseMarkerColor'] != '') {
1453 $on_mouse .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
1455 } // end if
1457 echo '<tr ' . $on_mouse . '>' . "\n";
1458 echo $val;
1460 $foo_counter = 0;
1461 while (list($subkey, $subval) = each($vertical_display['rowdata'][$key])) {
1462 if (($foo_counter != 0) && ($repeat_cells != 0) and !($foo_counter % $repeat_cells)) {
1463 echo $val;
1466 echo $subval;
1467 $foo_counter++;
1468 } // end while
1470 echo '</tr>' . "\n";
1471 } // end while
1473 // Displays "edit" link at bottom if required
1474 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['edit'])) {
1475 echo '<tr>' . "\n";
1476 echo $vertical_display['textbtn'];
1477 reset($vertical_display['edit']);
1478 $foo_counter = 0;
1479 while (list($key, $val) = each($vertical_display['edit'])) {
1480 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1481 echo '<td>&nbsp;</td>' . "\n";
1484 echo $val;
1485 $foo_counter++;
1486 } // end while
1487 echo '</tr>' . "\n";
1488 } // end if
1490 // Displays "delete" link at bottom if required
1491 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['delete'])) {
1492 echo '<tr>' . "\n";
1493 if (!is_array($vertical_display['edit'])) {
1494 echo $vertical_display['textbtn'];
1496 reset($vertical_display['delete']);
1497 $foo_counter = 0;
1498 while (list($key, $val) = each($vertical_display['delete'])) {
1499 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1500 echo '<td>&nbsp;</td>' . "\n";
1503 echo $val;
1504 $foo_counter++;
1505 } // end while
1506 echo '</tr>' . "\n";
1509 return TRUE;
1510 } // end of the 'PMA_displayVerticalTable' function
1514 * Displays a table of results returned by a sql query.
1515 * This function is called by the "sql.php3" script.
1517 * @param integer the link id associated to the query which results have
1518 * to be displayed
1519 * @param array the display mode
1520 * @param array the analyzed query
1522 * @global string the current language
1523 * @global integer the server to use (refers to the number in the
1524 * configuration file)
1525 * @global array the current server config
1526 * @global string the database name
1527 * @global string the table name
1528 * @global string the url to go back in case of errors
1529 * @global string the current sql query
1530 * @global integer the total number of rows returned by the sql query
1531 * @global integer the total number of rows returned by the sql query
1532 * without any programmatically appended "LIMIT" clause
1533 * @global integer the current postion of the first record to be
1534 * displayed
1535 * @global array the list of fields properties
1536 * @global integer the total number of fields returned by the sql query
1537 * @global array informations used with vertical display mode
1538 * @global string the display mode (horizontal/vertical/horizontalflipped)
1539 * @global integer the number of row to display between two table headers
1540 * @global boolean whether to limit the number of displayed characters of
1541 * text type fields or not
1542 * @global array the relation settings
1544 * @access private
1546 * @see PMA_showMessage(), PMA_setDisplayMode(),
1547 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1548 * PMA_displayTableBody()
1550 function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
1552 global $lang, $server, $cfg, $db, $table;
1553 global $goto;
1554 global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
1555 global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
1556 global $dontlimitchars;
1557 global $cfgRelation;
1559 // 1. ----- Prepares the work -----
1561 // 1.1 Gets the informations about which functionnalities should be
1562 // displayed
1563 $total = '';
1564 $is_display = PMA_setDisplayMode($the_disp_mode, $total);
1565 if ($total == '') {
1566 unset($total);
1569 // 1.2 Defines offsets for the next and previous pages
1570 if ($is_display['nav_bar'] == '1') {
1571 if (!isset($pos)) {
1572 $pos = 0;
1574 if ($GLOBALS['session_max_rows'] == 'all') {
1575 $pos_next = 0;
1576 $pos_prev = 0;
1577 } else {
1578 $pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
1579 $pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
1580 if ($pos_prev < 0) {
1581 $pos_prev = 0;
1584 } // end if
1586 // 1.3 Urlencodes the query to use in input form fields
1587 $encoded_sql_query = urlencode($sql_query);
1589 // 2. ----- Displays the top of the page -----
1591 // 2.1 Displays a messages with position informations
1592 if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
1593 if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
1594 $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
1595 } else {
1596 $selectstring = '';
1598 $last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total)
1599 ? $total - 1
1600 : $pos_next - 1;
1601 PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
1602 } else if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1603 PMA_showMessage($GLOBALS['strSQLQuery']);
1606 // 2.3 Displays the navigation bars
1607 if (!isset($table) || strlen(trim($table)) == 0) {
1608 $table = $fields_meta[0]->table;
1610 if ($is_display['nav_bar'] == '1') {
1611 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1612 echo "\n";
1613 } else if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1614 echo "\n" . '<br /><br />' . "\n";
1617 // 2b ----- Get field references from Database -----
1618 // (see the 'relation' config variable)
1619 // loic1, 2002-03-02: extended to php3
1621 // init map
1622 $map = array();
1624 if ($cfgRelation['relwork']) {
1625 // find tables
1626 //$pattern = '`?[[:space:]]+(((ON|on)[[:space:]]+[^,]+)?,|((NATURAL|natural)[[:space:]]+)?(INNER|inner|LEFT|left|RIGHT|right)([[:space:]]+(OUTER|outer))?[[:space:]]+(JOIN|join))[[:space:]]*`?';
1627 //$target = eregi_replace('^.*[[:space:]]+FROM[[:space:]]+`?|`?[[:space:]]*(ON[[:space:]]+[^,]+)?(WHERE[[:space:]]+.*)?$', '', $sql_query);
1628 //$target = eregi_replace('`?[[:space:]]ORDER BY[[:space:]](.*)','',$target);
1629 //$tabs = '(\'' . join('\',\'', split($pattern, $target)) . '\')';
1630 $target=array();
1631 reset($analyzed_sql[0]['table_ref']);
1632 while (list ($table_ref_position, $table_ref) = each ($analyzed_sql[0]['table_ref'])) {
1633 $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
1635 $tabs = '(\'' . join('\',\'', $target) . '\')';
1637 $local_query = 'SELECT master_field, foreign_db, foreign_table, foreign_field'
1638 . ' FROM ' . PMA_backquote($cfgRelation['relation'])
1639 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
1640 . ' AND master_table IN ' . $tabs;
1641 $result = @PMA_query_as_cu($local_query, FALSE);
1642 if ($result) {
1643 while ($rel = PMA_mysql_fetch_row($result)) {
1644 // check for display field?
1645 if ($cfgRelation['displaywork']) {
1646 $display_field = PMA_getDisplayField($rel[1], $rel[2]);
1647 $map[$rel[0]] = array($rel[2], $rel[3], $display_field, $rel[1]);
1648 } // end if
1649 } // end while
1650 } // end if
1651 } // end 2b
1653 // 3. ----- Displays the results table -----
1654 echo '<!-- Results table -->' . "\n"
1655 . '<table ';
1656 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
1657 echo 'border="1" cellpadding="2" cellspacing="0"';
1658 } else {
1659 echo 'border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="5"';
1661 echo '>' . "\n";
1662 PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
1663 PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
1664 // lem9: vertical output case
1665 if ($disp_direction == 'vertical') {
1666 PMA_displayVerticalTable();
1667 } // end if
1668 unset($vertical_display);
1670 </table>
1671 <?php
1673 echo "\n";
1675 // 4. ----- Displays the navigation bar at the bottom if required -----
1677 if ($is_display['nav_bar'] == '1') {
1678 echo '<br />' . "\n";
1679 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1680 } else if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1681 echo "\n" . '<br /><br />' . "\n";
1683 } // end of the 'PMA_displayTable()' function
1685 } // $__PMA_DISPLAY_TBL_LIB__