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