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