2
/* $Id: display_tbl.lib.php 10235 2007-03-31 13:07:59Z lem9 $ */
3
// vim: expandtab sw=4 ts=4 sts=4:
5
require_once './libraries/Table.class.php';
8
* Set of functions used to display the records returned by a sql query
12
* Avoids undefined variables
17
/* We need this to be a integer */
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.
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
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
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
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
58
* @see PMA_displayTable()
60
function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
63
global $unlim_num_rows, $fields_meta;
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
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';
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']) {
112
* @todo defines edit/delete links depending on show statement
114
$tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which);
115
if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
116
$do_display['edit_lnk'] = 'nn'; // no edit link
117
$do_display['del_lnk'] = 'kp'; // "kill process" type edit link
119
// Default case -> no links
120
$do_display['edit_lnk'] = 'nn'; // no edit link
121
$do_display['del_lnk'] = 'nn'; // no delete link
123
// 2.2.2 Other settings
124
$do_display['sort_lnk'] = (string) '0';
125
$do_display['nav_bar'] = (string) '0';
126
$do_display['ins_row'] = (string) '0';
127
$do_display['bkm_form'] = (string) '1';
128
$do_display['text_btn'] = (string) '1';
129
$do_display['pview_lnk'] = (string) '1';
131
// 2.3 Other statements (ie "SELECT" ones) -> updates
132
// $do_display['edit_lnk'], $do_display['del_lnk'] and
133
// $do_display['text_btn'] (keeps other default values)
135
$prev_table = $fields_meta[0]->table;
136
$do_display['text_btn'] = (string) '1';
137
for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) {
138
$is_link = ($do_display['edit_lnk'] != 'nn'
139
|| $do_display['del_lnk'] != 'nn'
140
|| $do_display['sort_lnk'] != '0'
141
|| $do_display['ins_row'] != '0');
142
// 2.3.2 Displays edit/delete/sort/insert links?
144
&& ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
145
$do_display['edit_lnk'] = 'nn'; // don't display links
146
$do_display['del_lnk'] = 'nn';
148
* @todo May be problematic with same fields names in two joined table.
150
// $do_display['sort_lnk'] = (string) '0';
151
$do_display['ins_row'] = (string) '0';
152
if ($do_display['text_btn'] == '1') {
156
// 2.3.3 Always display print view link
157
$do_display['pview_lnk'] = (string) '1';
158
$prev_table = $fields_meta[$i]->table;
160
} // end if..elseif...else (2.1 -> 2.3)
163
// 3. Gets the total number of rows if it is unknown
164
if (isset($unlim_num_rows) && $unlim_num_rows != '') {
165
$the_total = $unlim_num_rows;
166
} elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
167
&& (isset($db) && strlen($db) && !empty($table))) {
168
$the_total = PMA_Table::countRecords($db, $table, true);
171
// 4. If navigation bar or sorting fields names urls should be
172
// displayed but there is only one row, change these settings to
174
if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') {
176
if (isset($unlim_num_rows) && $unlim_num_rows < 2) {
177
// garvin: force display of navbar for vertical/horizontal display-choice.
178
// $do_display['nav_bar'] = (string) '0';
179
$do_display['sort_lnk'] = (string) '0';
184
// 5. Updates the synthetic var
185
$the_disp_mode = join('', $do_display);
188
} // end of the 'PMA_setDisplayMode()' function
192
* Displays a navigation bar to browse among the results of a sql query
194
* @param integer the offset for the "next" page
195
* @param integer the offset for the "previous" page
196
* @param string the url-encoded query
198
* @global string $db the database name
199
* @global string $table the table name
200
* @global string $goto the url to go back in case of errors
201
* @global boolean $dontlimitchars whether to limit the number of displayed
202
* characters of text type fields or not
203
* @global integer $num_rows the total number of rows returned by the
205
* @global integer $unlim_num_rows the total number of rows returned by the
206
* sql any programmatically appended "LIMIT" clause
207
* @global integer $pos the current position in results
208
* @global mixed $session_max_rows the maximum number of rows per page
210
* @global string $disp_direction the display mode
211
* (horizontal / vertical / horizontalflipped)
212
* @global integer $repeat_cells the number of row to display between two
214
* @global boolean $is_innodb whether its InnoDB or not
215
* @global array $showtable table definitions
219
* @see PMA_displayTable()
221
function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
223
global $db, $table, $goto, $dontlimitchars;
224
global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
225
global $disp_direction, $repeat_cells;
230
* @todo move this to a central place
231
* @todo for other future table types
233
$is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
237
<!-- Navigation bar -->
238
<table border="0" cellpadding="2" cellspacing="0">
241
// Move to the beginning or to the previous page
242
if ($pos > 0 && $session_max_rows != 'all') {
243
// loic1: patch #474210 from Gosha Sakovich - part 1
244
if ($GLOBALS['cfg']['NavigationBarIconic']) {
245
$caption1 = '<<';
246
$caption2 = ' < ';
247
$title1 = ' title="' . $GLOBALS['strPos1'] . '"';
248
$title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
250
$caption1 = $GLOBALS['strPos1'] . ' <<';
251
$caption2 = $GLOBALS['strPrevious'] . ' <';
254
} // end if... else...
257
<form action="sql.php" method="post">
258
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
259
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
260
<input type="hidden" name="pos" value="0" />
261
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
262
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
263
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
264
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
265
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
266
<input type="submit" name="navig" value="<?php echo $caption1; ?>"<?php echo $title1; ?> />
270
<form action="sql.php" method="post">
271
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
272
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
273
<input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
274
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
275
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
276
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
277
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
278
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
279
<input type="submit" name="navig" value="<?php echo $caption2; ?>"<?php echo $title2; ?> />
289
<form action="sql.php" method="post"
290
onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 1) && checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 0, <?php echo $unlim_num_rows - 1; ?>))">
291
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
292
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
293
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
294
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
295
<input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
296
<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()" />
297
<?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
298
<input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
301
// Display mode (horizontal/vertical and repeat headers)
302
$param1 = ' <select name="disp_direction">' . "\n"
303
. ' <option value="horizontal"' . (($disp_direction == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
304
. ' <option value="horizontalflipped"' . (($disp_direction == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
305
. ' <option value="vertical"' . (($disp_direction == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
306
. ' </select>' . "\n"
308
$param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" class="textfield" />' . "\n"
310
echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
318
// Move to the next page or to the last one
319
if (($pos + $session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
320
&& $session_max_rows != 'all') {
321
// loic1: patch #474210 from Gosha Sakovich - part 2
322
if ($GLOBALS['cfg']['NavigationBarIconic']) {
323
$caption3 = ' > ';
324
$caption4 = '>>';
325
$title3 = ' title="' . $GLOBALS['strNext'] . '"';
326
$title4 = ' title="' . $GLOBALS['strEnd'] . '"';
328
$caption3 = '> ' . $GLOBALS['strNext'];
329
$caption4 = '>> ' . $GLOBALS['strEnd'];
332
} // end if... else...
336
<form action="sql.php" method="post">
337
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
338
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
339
<input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
340
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
341
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
342
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
343
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
344
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
345
<input type="submit" name="navig" value="<?php echo $caption3; ?>"<?php echo $title3; ?> />
349
<form action="sql.php" method="post"
350
onsubmit="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
351
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
352
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
353
<input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $session_max_rows)- 1) * $session_max_rows); ?>" />
355
if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
356
echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
357
// no backquote around this message
358
$onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], false) . '\')"';
361
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
362
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
363
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
364
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
365
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
366
<input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> <?php echo (empty($onclick) ? '' : $onclick); ?>/>
374
$pageNow = @floor($pos / $session_max_rows) + 1;
375
$nbTotalPage = @ceil($unlim_num_rows / $session_max_rows);
377
if ($nbTotalPage > 1){ //if1
383
<?php //<form> for keep the form alignment of button < and << ?>
385
<?php echo PMA_pageselector(
386
'sql.php?sql_query=' . $encoded_query .
387
'&session_max_rows=' . $session_max_rows .
388
'&disp_direction=' . $disp_direction .
389
'&repeat_cells=' . $repeat_cells .
390
'&goto=' . $goto .
391
'&dontlimitchars=' . $dontlimitchars .
392
'&' . PMA_generate_common_url($db, $table) .
405
// Show all the records if allowed
406
if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
413
<form action="sql.php" method="post">
414
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
415
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
416
<input type="hidden" name="pos" value="0" />
417
<input type="hidden" name="session_max_rows" value="all" />
418
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
419
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
420
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
421
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
422
<input type="submit" name="navig" value="<?php echo $GLOBALS['strShowAll']; ?>" />
433
} // end of the 'PMA_displayTableNavigation()' function
437
* Displays the headers of the results table
439
* @param array which elements to display
440
* @param array the list of fields properties
441
* @param integer the total number of fields returned by the sql query
442
* @param array the analyzed query
444
* @return boolean always true
446
* @global string $db the database name
447
* @global string $table the table name
448
* @global string $goto the url to go back in case of errors
449
* @global boolean $dontlimitchars whether to limit the number of displayed
450
* characters of text type fields or not
451
* @global string $sql_query the sql query
452
* @global integer $num_rows the total number of rows returned by the
454
* @global integer $pos the current position in results
455
* @global integer $session_max_rows the maximum number of rows per page
456
* @global array $vertical_display informations used with vertical display
458
* @global string $disp_direction the display mode
459
* (horizontal/vertical/horizontalflipped)
460
* @global integer $repeat_cellsthe number of row to display between two
465
* @see PMA_displayTable()
467
function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
469
global $db, $table, $goto, $dontlimitchars;
470
global $sql_query, $num_rows, $pos, $session_max_rows;
471
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
473
if ($analyzed_sql == '') {
474
$analyzed_sql = array();
477
// can the result be sorted?
478
if ($is_display['sort_lnk'] == '1') {
481
$unsorted_sql_query = $sql_query;
482
if (isset($analyzed_sql[0]['unsorted_query'])) {
483
$unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
486
// we need $sort_expression and $sort_expression_nodir
487
// even if there are many table references
489
$sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
492
* Get rid of ASC|DESC
495
preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
496
$sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
498
// sorting by indexes, only if it makes sense (only one table ref)
499
if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
500
isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
501
isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
503
// grab indexes data:
504
PMA_DBI_select_db($db);
505
if (!defined('PMA_IDX_INCLUDED')) {
506
$ret_keys = PMA_get_indexes($table);
510
foreach ($ret_keys as $row) {
512
if ($row['Key_name'] != $prev_index){
513
$indexes[] = $row['Key_name'];
514
$prev_index = $row['Key_name'];
516
$indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
517
$indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
518
if (isset($row['Cardinality'])) {
519
$indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
521
// I don't know what does the following column mean....
522
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
523
$indexes_info[$row['Key_name']]['Comment'] = (isset($row['Comment']))
526
$indexes_info[$row['Key_name']]['Index_type'] = (isset($row['Index_type']))
530
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
531
if (isset($row['Sub_part'])) {
532
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
536
// do we have any index?
537
if (isset($indexes_data)) {
539
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
541
if ($is_display['edit_lnk'] != 'nn') {
544
if ($is_display['del_lnk'] != 'nn') {
547
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
551
$span = $num_rows + floor($num_rows/$repeat_cells) + 1;
554
echo '<form action="sql.php" method="post">' . "\n";
555
echo PMA_generate_common_hidden_inputs($db, $table, 5);
556
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
557
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
558
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
559
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
560
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
561
echo $GLOBALS['strSortByKey'] . ': <select name="sql_query">' . "\n";
563
$local_order = (isset($sort_expression) ? $sort_expression : '');
564
foreach ($indexes_data AS $key => $val) {
567
foreach ($val AS $key2 => $val2) {
568
$asc_sort .= PMA_backquote($val2['Column_name']) . ' ASC , ';
569
$desc_sort .= PMA_backquote($val2['Column_name']) . ' DESC , ';
571
$asc_sort = substr($asc_sort, 0, -3);
572
$desc_sort = substr($desc_sort, 0, -3);
573
$used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
574
echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strAscending'] . ')</option>';
576
echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>';
579
echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"') . '>' . $GLOBALS['strNone'] . '</option>';
581
echo '</select>' . "\n";
582
echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
584
echo '</form>' . "\n";
590
$vertical_display['emptypre'] = 0;
591
$vertical_display['emptyafter'] = 0;
592
$vertical_display['textbtn'] = '';
595
// Start of form for multi-rows delete
597
if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') {
598
echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
599
echo PMA_generate_common_hidden_inputs($db, $table, 1);
600
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
601
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
602
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
603
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
604
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
605
echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
608
echo '<table id="table_results" class="data">' . "\n";
609
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
610
echo '<thead><tr>' . "\n";
613
// 1. Displays the full/partial text button (part 1)...
614
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
615
$colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
619
$rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
623
$text_url = 'sql.php?'
624
. PMA_generate_common_url($db, $table)
625
. '&sql_query=' . urlencode($sql_query)
626
. '&session_max_rows=' . $session_max_rows
628
. '&disp_direction=' . $disp_direction
629
. '&repeat_cells=' . $repeat_cells
630
. '&goto=' . $goto
631
. '&dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
632
$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']) . '" />';
633
$text_link = PMA_linkOrButton($text_url, $text_message, array(), false);
635
// ... before the result table
636
if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
637
&& $is_display['text_btn'] == '1') {
638
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
639
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
641
<th colspan="<?php echo $fields_cnt; ?>"><?php echo $text_link; ?></th>
645
} // end horizontal/horizontalflipped mode
649
<th colspan="<?php echo $num_rows + floor($num_rows/$repeat_cells) + 1; ?>">
650
<?php echo $text_link; ?></th>
653
} // end vertical mode
656
// ... at the left column of the result table header if possible
658
elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
659
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
660
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
662
<th <?php echo $colspan; ?>><?php echo $text_link; ?></th>
664
} // end horizontal/horizontalflipped mode
666
$vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
667
. ' ' . $text_link . "\n"
669
} // end vertical mode
672
// ... elseif no button, displays empty(ies) col(s) if required
673
elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft']
674
&& ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
675
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
676
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
678
<td<?php echo $colspan; ?>></td>
680
} // end horizontal/horizontalfipped mode
682
$vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
683
} // end vertical mode
686
// 2. Displays the fields' name
687
// 2.0 If sorting links should be used, checks if the query is a "JOIN"
688
// statement (see 2.1.3)
690
// 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
691
// Do not show comments, if using horizontalflipped mode, because of space usage
692
if ($GLOBALS['cfg']['ShowBrowseComments'] && ($GLOBALS['cfgRelation']['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) && $disp_direction != 'horizontalflipped') {
693
$comments_map = array();
694
if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
695
foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
696
$tb = $tbl['table_true_name'];
697
$comments_map[$tb] = PMA_getComments($db, $tb);
703
if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
704
require_once './libraries/transformations.lib.php';
705
$GLOBALS['mime_map'] = PMA_getMIME($db, $table);
708
if ($is_display['sort_lnk'] == '1') {
709
//$is_join = preg_match('@(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN@im', $sql_query, $select_stt);
710
$is_join = (isset($analyzed_sql[0]['queryflags']['join']) ? true : false);
711
$select_expr = $analyzed_sql[0]['select_expr_clause'];
716
// garvin: See if we have to highlight any header fields of a WHERE query.
717
// Uses SQL-Parser results.
718
$highlight_columns = array();
719
if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
720
isset($analyzed_sql[0]['where_clause_identifiers'])) {
723
if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
724
foreach ($analyzed_sql[0]['where_clause_identifiers'] AS $wci_nr => $wci) {
725
$highlight_columns[$wci] = 'true';
730
for ($i = 0; $i < $fields_cnt; $i++) {
731
// garvin: See if this column should get highlight because it's used in the
733
if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
734
$condition_field = true;
736
$condition_field = false;
739
// 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
740
if (isset($comments_map) &&
741
isset($comments_map[$fields_meta[$i]->table]) &&
742
isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
743
$comments = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) . '</span>';
748
// 2.1 Results can be sorted
749
if ($is_display['sort_lnk'] == '1') {
751
// 2.1.1 Checks if the table name is required; it's the case
752
// for a query with a "JOIN" statement and if the column
753
// isn't aliased, or in queries like
754
// SELECT `1`.`master_field` , `2`.`master_field`
755
// FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
757
* we prefer always using table if existing
758
* and second this code does not correctly check $fields_meta[$i]->table
760
&& !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts))
761
|| (isset($analyzed_sql[0]['select_expr'][$i]['expr'])
762
&& isset($analyzed_sql[0]['select_expr'][$i]['column'])
763
&& $analyzed_sql[0]['select_expr'][$i]['expr'] !=
764
$analyzed_sql[0]['select_expr'][$i]['column']
765
&& isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table))) {
767
if (isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) {
768
$sort_tbl = PMA_backquote($fields_meta[$i]->table) . '.';
773
// 2.1.2 Checks if the current column is used to sort the
775
if (empty($sort_expression)) {
778
// field name may be preceded by a space, or any number
779
// of characters followed by a dot (tablename.fieldname)
780
// so do a direct comparison
781
// for the sort expression (avoids problems with queries
782
// like "SELECT id, count(id)..." and clicking to sort
783
// on id or on count(id))
784
$is_in_sort = ($sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? true : false);
786
// 2.1.3 Check the field name for backquotes.
787
// If it contains some, it's probably a function column
788
// like 'COUNT(`field`)'
789
if (strpos($fields_meta[$i]->name, '`') !== false) {
790
$sort_order = ' ORDER BY ' . PMA_backquote($fields_meta[$i]->name) . ' ';
792
$sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name) . ' ';
795
// 2.1.4 Do define the sorting url
797
// loic1: patch #455484 ("Smart" order)
798
$GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']);
799
if ($GLOBALS['cfg']['Order'] === 'SMART') {
800
$sort_order .= (preg_match('@time|date@i', $fields_meta[$i]->type)) ? 'DESC' : 'ASC';
802
$sort_order .= $GLOBALS['cfg']['Order'];
805
} elseif (preg_match('@[[:space:]]DESC$@i', $sort_expression)) {
806
$sort_order .= ' ASC';
807
$order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" id="soimg' . $i . '" />';
809
$sort_order .= ' DESC';
810
$order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
813
if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
814
$sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
816
$sorted_sql_query = $unsorted_sql_query . $sort_order;
818
$url_query = PMA_generate_common_url($db, $table)
820
. '&session_max_rows=' . $session_max_rows
821
. '&disp_direction=' . $disp_direction
822
. '&repeat_cells=' . $repeat_cells
823
. '&dontlimitchars=' . $dontlimitchars
824
. '&sql_query=' . urlencode($sorted_sql_query);
825
$order_url = 'sql.php?' . $url_query;
827
// 2.1.5 Displays the sorting url
828
// added 20004-06-09: Michael Keck <mail@michaelkeck.de>
829
// enable sord order swapping for image
830
$order_link_params = array();
831
if (isset($order_img) && $order_img!='') {
832
if (strstr($order_img, 'asc')) {
833
$order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
834
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
835
} elseif (strstr($order_img, 'desc')) {
836
$order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
837
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
840
if ($disp_direction == 'horizontalflipped'
841
&& $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
842
$order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
844
$order_link_params['title'] = $GLOBALS['strSort'];
845
$order_link_content = ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
846
$order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true);
848
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
850
if ($condition_field) {
851
echo ' class="condition"';
853
if ($disp_direction == 'horizontalflipped') {
854
echo ' valign="bottom"';
856
echo '>' . $order_link . $comments . '</th>';
858
$vertical_display['desc'][] = ' <th '
859
. ($condition_field ? ' class="condition"' : '') . '>' . "\n"
860
. $order_link . $comments . ' </th>' . "\n";
863
// 2.2 Results can't be sorted
865
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
867
if ($condition_field) {
868
echo ' class="condition"';
870
if ($disp_direction == 'horizontalflipped') {
871
echo ' valign="bottom"';
873
if ($disp_direction == 'horizontalflipped'
874
&& $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
875
echo ' style="direction: ltr; writing-mode: tb-rl;"';
878
if ($disp_direction == 'horizontalflipped'
879
&& $GLOBALS['cfg']['HeaderFlipType'] == 'fake') {
880
echo PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), '<br />');
882
echo htmlspecialchars($fields_meta[$i]->name);
884
echo "\n" . $comments . '</th>';
886
$vertical_display['desc'][] = ' <th '
887
. ($condition_field ? ' class="condition"' : '') . '>' . "\n"
888
. ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
889
. $comments . ' </th>';
893
// 3. Displays the full/partial text button (part 2) at the right
894
// column of the result table header if possible and required...
895
if ($GLOBALS['cfg']['ModifyDeleteAtRight']
896
&& ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
897
&& $is_display['text_btn'] == '1') {
898
$vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
899
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
902
<th <?php echo $colspan; ?>>
903
<?php echo $text_link; ?>
906
} // end horizontal/horizontalflipped mode
908
$vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
909
. ' ' . $text_link . "\n"
911
} // end vertical mode
914
// ... elseif no button, displays empty cols if required
915
// (unless coming from Browse mode print view)
916
elseif ($GLOBALS['cfg']['ModifyDeleteAtRight']
917
&& ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
918
&& (!$GLOBALS['is_header_sent'])) {
919
$vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
920
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
923
<td<?php echo $colspan; ?>></td>
925
} // end horizontal/horizontalflipped mode
927
$vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
928
} // end vertical mode
931
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
939
} // end of the 'PMA_displayTableHeaders()' function
944
* Displays the body of the results table
946
* @param integer the link id associated to the query which results have
948
* @param array which elements to display
949
* @param array the list of relations
950
* @param array the analyzed query
952
* @return boolean always true
954
* @global string $db the database name
955
* @global string $table the table name
956
* @global string $goto the url to go back in case of errors
957
* @global boolean $dontlimitchars whether to limit the number of displayed
958
* characters of text type fields or not
959
* @global string $sql_query the sql query
960
* @global integer $pos the current position in results
961
* @global integer $session_max_rows the maximum number of rows per page
962
* @global array $fields_meta the list of fields properties
963
* @global integer $fields_cnt the total number of fields returned by
965
* @global array $vertical_display informations used with vertical display
967
* @global string $disp_direction the display mode
968
* (horizontal/vertical/horizontalflipped)
969
* @global integer $repeat_cells the number of row to display between two
971
* @global array $highlight_columns collumn names to highlight
972
* @gloabl array $row current row data
976
* @see PMA_displayTable()
978
function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
979
global $db, $table, $goto, $dontlimitchars;
980
global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
981
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
982
global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
984
$url_sql_query = $sql_query;
986
// query without conditions to shorten urls when needed, 200 is just
987
// guess, it should depend on remaining url length
989
if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
990
isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
991
strlen($sql_query) > 200) {
993
$url_sql_query = 'SELECT ';
994
if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
995
$url_sql_query .= ' DISTINCT ';
997
$url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
998
if (!empty($analyzed_sql[0]['from_clause'])) {
999
$url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
1003
if (!is_array($map)) {
1007
$vertical_display['edit'] = array();
1008
$vertical_display['delete'] = array();
1009
$vertical_display['data'] = array();
1010
$vertical_display['row_delete'] = array();
1012
// Correction University of Virginia 19991216 in the while below
1013
// Previous code assumed that all tables have keys, specifically that
1014
// the phpMyAdmin GUI should support row delete/edit only for such
1016
// Although always using keys is arguably the prescribed way of
1017
// defining a relational table, it is not required. This will in
1018
// particular be violated by the novice.
1019
// We want to encourage phpMyAdmin usage by such novices. So the code
1020
// below has been changed to conditionally work as before when the
1021
// table being displayed has one or more keys; but to display
1022
// delete/edit options correctly for tables without keys.
1024
// loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
1025
// to get the NULL values
1027
// rabus: This function needs a little rework.
1028
// Using MYSQL_BOTH just pollutes the memory!
1030
// ne0x: Use function PMA_DBI_fetch_array() due to mysqli
1031
// compatibility. Now this function is wrapped.
1034
while ($row = PMA_DBI_fetch_row($dt_result)) {
1035
// lem9: "vertical display" mode stuff
1036
if ($row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells)
1037
&& ($disp_direction == 'horizontal'
1038
|| $disp_direction == 'horizontalflipped'))
1041
if ($vertical_display['emptypre'] > 0) {
1042
echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n"
1043
.' </th>' . "\n";
1046
foreach ($vertical_display['desc'] as $val) {
1050
if ($vertical_display['emptyafter'] > 0) {
1051
echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n"
1052
.' </th>' . "\n";
1054
echo '</tr>' . "\n";
1057
$class = $odd_row ? 'odd' : 'even';
1058
$odd_row = ! $odd_row;
1059
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1060
// loic1: pointer code part
1061
echo ' <tr class="' . $class . '">' . "\n";
1066
// 1. Prepares the row (gets primary keys to use)
1067
// 1.1 Results from a "SELECT" statement -> builds the
1068
// "primary" key to use in links
1070
* @todo $unique_condition could be empty, for example a table
1071
* with only one field and it's a BLOB; in this case,
1072
* avoid to display the delete and edit links
1075
$unique_condition = urlencode(PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row));
1077
// 1.2 Defines the urls for the modify/delete link(s)
1078
$url_query = PMA_generate_common_url($db, $table)
1079
. '&pos=' . $pos
1080
. '&session_max_rows=' . $session_max_rows
1081
. '&disp_direction=' . $disp_direction
1082
. '&repeat_cells=' . $repeat_cells
1083
. '&dontlimitchars=' . $dontlimitchars;
1085
if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
1086
// We need to copy the value or else the == 'both' check will always return true
1088
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1089
$iconic_spacer = '<div class="nowrap">';
1091
$iconic_spacer = '';
1094
// 1.2.1 Modify link(s)
1095
if ($is_display['edit_lnk'] == 'ur') { // update row case
1096
$lnk_goto = 'sql.php';
1098
$edit_url = 'tbl_change.php'
1100
. '&primary_key=' . $unique_condition
1101
. '&sql_query=' . urlencode($url_sql_query)
1102
. '&goto=' . urlencode($lnk_goto);
1103
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1104
$edit_str = $GLOBALS['strEdit'];
1106
$edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />';
1107
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1108
$edit_str .= ' ' . $GLOBALS['strEdit'] . '</div>';
1113
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])) {
1114
$bookmark_go = '<a href="import.php?'
1115
. PMA_generate_common_url($row[1], '')
1116
. '&id_bookmark=' . $row[0]
1117
. '&action_bookmark=0'
1118
. '&action_bookmark_all=1'
1119
. '&SQL=' . $GLOBALS['strExecuteBookmarked']
1120
.' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
1122
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1123
$bookmark_go .= $GLOBALS['strExecuteBookmarked'];
1125
$bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />';
1126
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1127
$bookmark_go .= ' ' . $GLOBALS['strExecuteBookmarked'] . '</div>';
1131
$bookmark_go .= '</a>';
1136
// 1.2.2 Delete/Kill link(s)
1137
if ($is_display['del_lnk'] == 'dr') { // delete row case
1138
$lnk_goto = 'sql.php'
1139
. '?' . str_replace('&', '&', $url_query)
1140
. '&sql_query=' . urlencode($url_sql_query)
1141
. '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1142
. '&goto=' . (empty($goto) ? 'tbl_sql.php' : $goto);
1143
$del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $unique_condition . '+LIMIT+1';
1144
$del_url = 'sql.php'
1146
. '&sql_query=' . $del_query
1147
. '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1148
. '&goto=' . urlencode($lnk_goto);
1149
$js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
1150
. ' WHERE ' . trim(PMA_jsFormat(urldecode($unique_condition), false))
1152
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1153
$del_str = $GLOBALS['strDelete'];
1155
$del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />';
1156
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1157
$del_str .= ' ' . $GLOBALS['strDelete'] . '</div>';
1160
} elseif ($is_display['del_lnk'] == 'kp') { // kill process case
1161
$lnk_goto = 'sql.php'
1162
. '?' . str_replace('&', '&', $url_query)
1163
. '&sql_query=' . urlencode($url_sql_query)
1165
$del_url = 'sql.php?'
1166
. PMA_generate_common_url('mysql')
1167
. '&sql_query=' . urlencode('KILL ' . $row[0])
1168
. '&goto=' . urlencode($lnk_goto);
1169
$del_query = urlencode('KILL ' . $row[0]);
1170
$js_conf = 'KILL ' . $row[0];
1171
if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1172
$del_str = $GLOBALS['strKill'];
1174
$del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />';
1175
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1176
$del_str .= ' ' . $GLOBALS['strKill'] . '</div>';
1181
// 1.3 Displays the links at left if required
1182
if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
1183
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
1184
$doWriteModifyAt = 'left';
1185
require './libraries/display_tbl_links.lib.php';
1189
// 2. Displays the rows' values
1190
for ($i = 0; $i < $fields_cnt; ++$i) {
1191
$meta = $fields_meta[$i];
1192
// loic1: To fix bug #474943 under php4, the row pointer will
1193
// depend on whether the "is_null" php4 function is
1195
$pointer = (function_exists('is_null') ? $i : $meta->name);
1196
// garvin: See if this column should get highlight because it's used in the
1198
if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) {
1199
$condition_field = true;
1201
$condition_field = false;
1205
if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
1206
if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1207
$mouse_events .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"'
1208
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');" ';
1210
if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1211
$mouse_events .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1213
$mouse_events .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1217
// garvin: Wrap MIME-transformations. [MIME]
1218
$default_function = 'default_function'; // default_function
1219
$transform_function = $default_function;
1220
$transform_options = array();
1222
if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
1224
if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) {
1225
$include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']);
1227
if (file_exists('./libraries/transformations/' . $include_file)) {
1228
$transformfunction_name = preg_replace('@(\.inc\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
1230
require_once './libraries/transformations/' . $include_file;
1232
if (function_exists('PMA_transformation_' . $transformfunction_name)) {
1233
$transform_function = 'PMA_transformation_' . $transformfunction_name;
1234
$transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''));
1235
$meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
1237
} // end if file_exists
1238
} // end if transformation is set
1239
} // end if mime/transformation works.
1241
$transform_options['wrapper_link'] = '?'
1242
. (isset($url_query) ? $url_query : '')
1243
. '&primary_key=' . (isset($unique_condition) ? $unique_condition : '')
1244
. '&sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '')
1245
. '&goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
1246
. '&transform_key=' . urlencode($meta->name);
1250
if ($meta->numeric == 1) {
1253
// lem9: if two fields have the same name (this is possible
1254
// with self-join queries, for example), using $meta->name
1255
// will show both fields NULL even if only one is NULL,
1256
// so use the $pointer
1257
// (works only if function_exists('is_null')
1258
// PS: why not always work with the number ($i), since
1259
// the default second parameter of
1260
// mysql_fetch_array() is MYSQL_BOTH, so we always get
1261
// associative and numeric indices?
1263
//if (!isset($row[$meta->name])
1264
if (!isset($row[$i]) || is_null($row[$i])) {
1265
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
1266
} elseif ($row[$i] != '') {
1267
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . ' nowrap">';
1269
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
1270
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
1271
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1272
if (isset($alias) && strlen($alias)) {
1273
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1274
if ($alias == $meta->name) {
1275
$meta->name = $true_column;
1281
if (isset($map[$meta->name])) {
1282
// Field to display from the foreign table?
1283
if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
1284
$dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1285
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1286
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
1288
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
1289
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
1290
list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
1292
$dispval = $GLOBALS['strLinkNotFound'];
1294
@PMA_DBI_free_result($dispresult);
1297
} // end if... else...
1299
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
1300
$vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[->' . $dispval . ']</code>';
1302
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1304
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
1305
. PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1306
. '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars
1307
. '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>'
1308
. ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>';
1311
$vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta));
1313
$vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1315
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ' nowrap' . ($condition_field ? ' condition' : '') . '"> </td>' . "\n";
1320
} elseif ($GLOBALS['cfg']['ShowBlob'] == false && stristr($meta->type, 'BLOB')) {
1321
// loic1 : PMA_mysql_fetch_fields returns BLOB in place of
1322
// TEXT fields type, however TEXT fields must be displayed
1323
// even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type
1325
$field_flags = PMA_DBI_field_flags($dt_result, $i);
1326
if (stristr($field_flags, 'BINARY')) {
1327
$blobtext = '[BLOB';
1328
if (!isset($row[$i]) || is_null($row[$i])) {
1329
$blobtext .= ' - NULL';
1331
} elseif (isset($row[$i])) {
1332
$blob_size = strlen($row[$i]);
1333
$display_blob_size = PMA_formatByteDown($blob_size, 3, 1);
1334
$blobtext .= ' - '. $display_blob_size[0] . ' ' . $display_blob_size[1];
1335
unset($display_blob_size);
1339
if (strpos($transform_function, 'octetstream')) {
1340
$blobtext = $row[$i];
1342
if ($blob_size > 0) {
1343
$blobtext = ($default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta));
1347
$vertical_display['data'][$row_no][$i] = ' <td align="left"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $blobtext . '</td>';
1349
if (!isset($row[$i]) || is_null($row[$i])) {
1350
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
1351
} elseif ($row[$i] != '') {
1352
// garvin: if a transform function for blob is set, none of these replacements will be made
1353
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
1354
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1356
// loic1: displays all space characters, 4 space
1357
// characters for tabulations and <cr>/<lf>
1358
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1360
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $row[$i] . '</td>' . "\n";
1362
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"> </td>' . "\n";
1366
if (!isset($row[$i]) || is_null($row[$i])) {
1367
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
1368
} elseif ($row[$i] != '') {
1369
// loic1: support blanks in the key
1370
$relation_id = $row[$i];
1372
// nijel: Cut all fields to $GLOBALS['cfg']['LimitChars']
1373
// lem9: (unless it's a link-type transformation)
1374
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1) && !strpos($transform_function, 'link') === true) {
1375
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1378
// loic1: displays special characters from binaries
1379
$field_flags = PMA_DBI_field_flags($dt_result, $i);
1380
if (stristr($field_flags, 'BINARY')) {
1381
$row[$i] = str_replace("\x00", '\0', $row[$i]);
1382
$row[$i] = str_replace("\x08", '\b', $row[$i]);
1383
$row[$i] = str_replace("\x0a", '\n', $row[$i]);
1384
$row[$i] = str_replace("\x0d", '\r', $row[$i]);
1385
$row[$i] = str_replace("\x1a", '\Z', $row[$i]);
1386
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1388
// loic1: displays all space characters, 4 space
1389
// characters for tabulations and <cr>/<lf>
1391
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1394
// garvin: transform functions may enable nowrapping:
1395
$function_nowrap = $transform_function . '_nowrap';
1396
$bool_nowrap = (($default_function != $transform_function && function_exists($function_nowrap)) ? $function_nowrap($transform_options) : false);
1398
// loic1: do not wrap if date field type
1399
$nowrap = ((preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap) ? ' nowrap' : '');
1400
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . $nowrap . ($condition_field ? ' condition' : '') . '">';
1402
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
1403
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
1404
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1405
if (isset($alias) && strlen($alias)) {
1406
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1407
if ($alias == $meta->name) {
1408
$meta->name = $true_column;
1414
if (isset($map[$meta->name])) {
1415
// Field to display from the foreign table?
1416
if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
1417
$dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1418
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1419
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
1420
. ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
1421
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
1422
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
1423
list($dispval) = PMA_DBI_fetch_row($dispresult);
1424
@PMA_DBI_free_result($dispresult);
1426
$dispval = $GLOBALS['strLinkNotFound'];
1431
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1433
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
1434
. PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1435
. '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars
1436
. '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
1437
. $row[$i] . '</a>';
1439
$vertical_display['data'][$row_no][$i] .= $row[$i];
1441
$vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1443
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"> </td>' . "\n";
1447
// lem9: output stored cell
1448
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1449
echo $vertical_display['data'][$row_no][$i];
1452
if (isset($vertical_display['rowdata'][$i][$row_no])) {
1453
$vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
1455
$vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
1459
// 3. Displays the modify/delete links on the right if required
1460
if ($GLOBALS['cfg']['ModifyDeleteAtRight']
1461
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
1462
$doWriteModifyAt = 'right';
1463
require './libraries/display_tbl_links.lib.php';
1466
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
1472
// 4. Gather links of del_urls and edit_urls in an array for later
1474
if (!isset($vertical_display['edit'][$row_no])) {
1475
$vertical_display['edit'][$row_no] = '';
1476
$vertical_display['delete'][$row_no] = '';
1477
$vertical_display['row_delete'][$row_no] = '';
1480
$column_style_vertical = '';
1481
if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1482
$column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"'
1483
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');"';
1485
$column_marker_vertical = '';
1486
if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1487
$column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\');';
1490
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
1491
$vertical_display['row_delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1492
. ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $unique_condition . ']"'
1493
. ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"'
1494
. ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
1497
unset($vertical_display['row_delete'][$row_no]);
1500
if (isset($edit_url)) {
1501
$vertical_display['edit'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1502
. PMA_linkOrButton($edit_url, $edit_str, array(), false)
1506
unset($vertical_display['edit'][$row_no]);
1509
if (isset($del_url)) {
1510
$vertical_display['delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1511
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), false)
1514
unset($vertical_display['delete'][$row_no]);
1517
echo (($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') ? "\n" : '');
1521
if (isset($url_query)) {
1522
$GLOBALS['url_query'] = $url_query;
1526
} // end of the 'PMA_displayTableBody()' function
1530
* Do display the result table with the vertical direction mode.
1531
* Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
1533
* @return boolean always true
1535
* @global array $vertical_display the information to display
1536
* @global integer $repeat_cells the number of row to display between two
1541
* @see PMA_displayTable()
1543
function PMA_displayVerticalTable()
1545
global $vertical_display, $repeat_cells;
1547
// Displays "multi row delete" link at top if required
1548
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1550
echo $vertical_display['textbtn'];
1552
foreach ($vertical_display['row_delete'] as $val) {
1553
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1554
echo '<th> </th>' . "\n";
1557
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '', $val);
1560
echo '</tr>' . "\n";
1563
// Displays "edit" link at top if required
1564
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1566
if (!is_array($vertical_display['row_delete'])) {
1567
echo $vertical_display['textbtn'];
1570
foreach ($vertical_display['edit'] as $val) {
1571
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1572
echo ' <th> </th>' . "\n";
1578
echo '</tr>' . "\n";
1581
// Displays "delete" link at top if required
1582
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1584
if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1585
echo $vertical_display['textbtn'];
1588
foreach ($vertical_display['delete'] as $val) {
1589
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1590
echo '<th> </th>' . "\n";
1596
echo '</tr>' . "\n";
1600
foreach ($vertical_display['desc'] AS $key => $val) {
1606
foreach ($vertical_display['rowdata'][$key] as $subval) {
1607
if (($foo_counter != 0) && ($repeat_cells != 0) and !($foo_counter % $repeat_cells)) {
1615
echo '</tr>' . "\n";
1618
// Displays "multi row delete" link at bottom if required
1619
if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1621
echo $vertical_display['textbtn'];
1623
foreach ($vertical_display['row_delete'] as $val) {
1624
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1625
echo '<th> </th>' . "\n";
1628
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', 'r', $val);
1631
echo '</tr>' . "\n";
1634
// Displays "edit" link at bottom if required
1635
if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1637
if (!is_array($vertical_display['row_delete'])) {
1638
echo $vertical_display['textbtn'];
1641
foreach ($vertical_display['edit'] as $val) {
1642
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1643
echo '<th> </th>' . "\n";
1649
echo '</tr>' . "\n";
1652
// Displays "delete" link at bottom if required
1653
if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1655
if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1656
echo $vertical_display['textbtn'];
1659
foreach ($vertical_display['delete'] as $val) {
1660
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
1661
echo '<th> </th>' . "\n";
1667
echo '</tr>' . "\n";
1671
} // end of the 'PMA_displayVerticalTable' function
1675
* Displays a table of results returned by a sql query.
1676
* This function is called by the "sql.php" script.
1678
* @param integer the link id associated to the query which results have
1680
* @param array the display mode
1681
* @param array the analyzed query
1683
* @global string $db the database name
1684
* @global string $table the table name
1685
* @global string $goto the url to go back in case of errors
1686
* @global boolean $dontlimitchars whether to limit the number of displayed
1687
* characters of text type fields or not
1688
* @global string $sql_query the current sql query
1689
* @global integer $num_rows the total number of rows returned by the
1691
* @global integer $unlim_num_rows the total number of rows returned by the
1692
* sql query without any programmatically
1693
* appended "LIMIT" clause
1694
* @global integer $pos the current postion of the first record
1696
* @global array $fields_meta the list of fields properties
1697
* @global integer $fields_cnt the total number of fields returned by
1699
* @global array $vertical_display informations used with vertical display
1701
* @global string $disp_direction the display mode
1702
* (horizontal/vertical/horizontalflipped)
1703
* @global integer $repeat_cells the number of row to display between two
1705
* @global array $highlight_columns collumn names to highlight
1706
* @global array $cfgRelation the relation settings
1710
* @see PMA_showMessage(), PMA_setDisplayMode(),
1711
* PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1712
* PMA_displayTableBody(), PMA_displayResultsOperations()
1714
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
1716
global $db, $table, $goto, $dontlimitchars;
1717
global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
1718
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
1719
global $cfgRelation;
1721
// 1. ----- Prepares the work -----
1723
// 1.1 Gets the informations about which functionnalities should be
1726
$is_display = PMA_setDisplayMode($the_disp_mode, $total);
1731
// 1.2 Defines offsets for the next and previous pages
1732
if ($is_display['nav_bar'] == '1') {
1736
if ($GLOBALS['session_max_rows'] == 'all') {
1740
$pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
1741
$pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
1742
if ($pos_prev < 0) {
1748
// 1.3 Urlencodes the query to use in input form fields
1749
$encoded_sql_query = urlencode($sql_query);
1751
// 2. ----- Displays the top of the page -----
1753
// 2.1 Displays a messages with position informations
1754
if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
1755
if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
1756
$selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
1760
$last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total)
1763
PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . PMA_formatNumber($total, 0) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
1764
if (isset($table) && PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
1765
echo '<div class="notice">' . "\n";
1766
echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
1767
echo '</div>' . "\n";
1770
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1771
PMA_showMessage($GLOBALS['strSQLQuery']);
1774
// 2.3 Displays the navigation bars
1775
if (!isset($table) || strlen(trim($table)) == 0) {
1776
if (isset($analyzed_sql[0]['query_type'])
1777
&& $analyzed_sql[0]['query_type'] == 'SELECT') {
1778
// table does not always contain a real table name,
1779
// for example in MySQL 5.0.x, the query SHOW STATUS
1780
// returns STATUS as a table name
1781
$table = $fields_meta[0]->table;
1786
if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1787
PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
1789
if ($is_display['nav_bar'] == '1') {
1790
PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1792
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1793
echo "\n" . '<br /><br />' . "\n";
1796
// 2b ----- Get field references from Database -----
1797
// (see the 'relation' config variable)
1798
// loic1, 2002-03-02: extended to php3
1805
if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
1806
foreach ($analyzed_sql[0]['table_ref'] AS $table_ref_position => $table_ref) {
1807
$target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
1810
$tabs = '(\'' . join('\',\'', $target) . '\')';
1812
if ($cfgRelation['displaywork']) {
1813
if (! isset($table) || ! strlen($table)) {
1816
$exist_rel = PMA_getForeigners($db, $table, '', 'both');
1818
foreach ($exist_rel AS $master_field => $rel) {
1819
$display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
1820
$map[$master_field] = array($rel['foreign_table'],
1821
$rel['foreign_field'],
1823
$rel['foreign_db']);
1830
// 3. ----- Displays the results table -----
1831
PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
1833
echo '<tbody>' . "\n";
1834
PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
1835
echo '</tbody>' . "\n";
1836
// vertical output case
1837
if ($disp_direction == 'vertical') {
1838
PMA_displayVerticalTable();
1840
unset($vertical_display);
1845
// 4. ----- Displays the link for multi-fields delete
1847
if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
1849
$delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
1851
$uncheckall_url = 'sql.php?'
1852
. PMA_generate_common_url($db, $table)
1853
. '&sql_query=' . urlencode($sql_query)
1854
. '&pos=' . $pos
1855
. '&session_max_rows=' . $GLOBALS['session_max_rows']
1856
. '&pos=' . $pos
1857
. '&disp_direction=' . $disp_direction
1858
. '&repeat_cells=' . $repeat_cells
1859
. '&goto=' . $goto
1860
. '&dontlimitchars=' . $dontlimitchars;
1861
$checkall_url = $uncheckall_url . '&checkall=1';
1863
if ($disp_direction == 'vertical') {
1864
$checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
1865
$uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
1867
$checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
1868
$uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
1870
$checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
1871
$uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
1872
if ($disp_direction != 'vertical') {
1873
echo '<img class="selectallarrow" width="38" height="22"'
1874
.' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
1875
.' alt="' . $GLOBALS['strWithChecked'] . '" />';
1877
echo $checkall_link . "\n"
1879
.$uncheckall_link . "\n"
1880
.'<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
1882
if ($GLOBALS['cfg']['PropertiesIconic']) {
1883
PMA_buttonOrImage('submit_mult', 'mult_submit',
1884
'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
1885
PMA_buttonOrImage('submit_mult', 'mult_submit',
1886
'submit_mult_delete', $delete_text, 'b_drop.png');
1887
if ($analyzed_sql[0]['querytype'] == 'SELECT') {
1888
PMA_buttonOrImage('submit_mult', 'mult_submit',
1889
'submit_mult_export', $GLOBALS['strExport'],
1894
echo ' <input type="submit" name="submit_mult"'
1895
.' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"'
1896
.' title="' . $GLOBALS['strEdit'] . '" />' . "\n";
1897
echo ' <input type="submit" name="submit_mult"'
1898
.' value="' . htmlspecialchars($delete_text) . '"'
1899
.' title="' . $delete_text . '" />' . "\n";
1900
if ($analyzed_sql[0]['querytype'] == 'SELECT') {
1901
echo ' <input type="submit" name="submit_mult"'
1902
.' value="' . htmlspecialchars($GLOBALS['strExport']) . '"'
1903
.' title="' . $GLOBALS['strExport'] . '" />' . "\n";
1906
echo '<input type="hidden" name="sql_query"'
1907
.' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
1908
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
1909
echo '<input type="hidden" name="url_query"'
1910
.' value="' . $GLOBALS['url_query'] . '" />' . "\n";
1911
echo '</form>' . "\n";
1914
// 5. ----- Displays the navigation bar at the bottom if required -----
1916
if ($is_display['nav_bar'] == '1') {
1917
echo '<br />' . "\n";
1918
PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1919
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1920
echo "\n" . '<br /><br />' . "\n";
1922
} // end of the 'PMA_displayTable()' function
1924
function default_function($buffer) {
1925
$buffer = htmlspecialchars($buffer);
1926
$buffer = str_replace("\011", ' ',
1927
str_replace(' ', ' ', $buffer));
1928
$buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />', $buffer);
1934
* Displays operations that are available on results.
1936
* @param array the display mode
1937
* @param array the analyzed query
1939
* @global string $db the database name
1940
* @global string $table the table name
1941
* @global boolean $dontlimitchars whether to limit the number of displayed
1942
* characters of text type fields or not
1943
* @global integer $pos the current postion of the first record
1945
* @global string $sql_query the current sql query
1946
* @global integer $unlim_num_rows the total number of rows returned by the
1947
* sql query without any programmatically
1948
* appended "LIMIT" clause
1949
* @global string $disp_direction the display mode
1950
* (horizontal/vertical/horizontalflipped)
1951
* @global integer $repeat_cells the number of row to display between two
1956
* @see PMA_showMessage(), PMA_setDisplayMode(),
1957
* PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1958
* PMA_displayTableBody(), PMA_displayResultsOperations()
1960
function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
1961
global $db, $table, $dontlimitchars, $pos, $sql_query, $unlim_num_rows, $disp_direction, $repeat_cells;
1963
$header_shown = FALSE;
1964
$header = '<fieldset><legend>' . $GLOBALS['strQueryResultsOperations'] . '</legend>';
1966
if ($the_disp_mode[6] == '1' || $the_disp_mode[9] == '1') {
1967
// Displays "printable view" link if required
1968
if ($the_disp_mode[9] == '1') {
1970
if (!$header_shown) {
1972
$header_shown = TRUE;
1976
. PMA_generate_common_url($db, $table)
1977
. '&pos=' . $pos
1978
. '&session_max_rows=' . $GLOBALS['session_max_rows']
1979
. '&disp_direction=' . $disp_direction
1980
. '&repeat_cells=' . $repeat_cells
1981
. '&printview=1'
1982
. '&sql_query=' . urlencode($sql_query);
1983
echo ' <!-- Print view -->' . "\n";
1984
echo PMA_linkOrButton(
1985
'sql.php' . $url_query . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&dontlimitchars=1' : ''),
1986
($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintView'] . '"/>' : '') . $GLOBALS['strPrintView'],
1987
'', true, true, 'print_view') . "\n";
1989
if (!$dontlimitchars) {
1990
echo ' ' . "\n";
1991
echo PMA_linkOrButton(
1992
'sql.php' . $url_query . '&dontlimitchars=1',
1993
($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintViewFull'] . '"/>' : '') . $GLOBALS['strPrintViewFull'],
1994
'', true, true, 'print_view') . "\n";
1996
} // end displays "printable view"
2002
// (the url_query has extra parameters that won't be used to export)
2003
// (the single_table parameter is used in display_export.lib.php
2004
// to hide the SQL and the structure export dialogs)
2005
if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview)) {
2006
if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
2007
$single_table = '&single_table=true';
2011
if (!$header_shown) {
2013
$header_shown = TRUE;
2015
echo ' <!-- Export -->' . "\n";
2016
echo ' ' . "\n";
2017
echo PMA_linkOrButton(
2018
'tbl_export.php' . $url_query . '&unlim_num_rows=' . $unlim_num_rows . $single_table,
2019
($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_tblexport.png" height="16" width="16" alt="' . $GLOBALS['strExport'] . '" />' : '') . $GLOBALS['strExport'],
2020
'', true, true, '') . "\n";
2022
if ($header_shown) {
2023
echo '</fieldset><br />';