Fixed bugs in show error message ine multi row change in table structure
[phpmyadmin/madhuracj.git] / libraries / display_tbl.lib.php
blob0b63a1edf3d9e166ae2ddaa7c529edf201ffac5d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * library for displaying table with results from all sort of select queries
6 * @package phpMyAdmin
7 */
9 /**
12 require_once './libraries/Index.class.php';
14 /**
15 * Defines the display mode to use for the results of a SQL query
17 * It uses a synthetic string that contains all the required informations.
18 * In this string:
19 * - the first two characters stand for the action to do while
20 * clicking on the "edit" link (e.g. 'ur' for update a row, 'nn' for no
21 * edit link...);
22 * - the next two characters stand for the action to do while
23 * clicking on the "delete" link (e.g. 'kp' for kill a process, 'nn' for
24 * no delete link...);
25 * - the next characters are boolean values (1/0) and respectively stand
26 * for sorting links, navigation bar, "insert a new row" link, the
27 * bookmark feature, the expand/collapse text/blob fields button and
28 * the "display printable view" option.
29 * Of course '0'/'1' means the feature won't/will be enabled.
31 * @param string the synthetic value for display_mode (see a few
32 * lines above for explanations)
33 * @param integer the total number of rows returned by the SQL query
34 * without any programmatically appended "LIMIT" clause
35 * (just a copy of $unlim_num_rows if it exists, else
36 * computed inside this function)
38 * @return array an array with explicit indexes for all the display
39 * elements
41 * @global string the database name
42 * @global string the table name
43 * @global integer the total number of rows returned by the SQL query
44 * without any programmatically appended "LIMIT" clause
45 * @global array the properties of the fields returned by the query
46 * @global string the URL to return to in case of error in a SQL
47 * statement
49 * @access private
51 * @see PMA_displayTable()
53 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
55 global $db, $table;
56 global $unlim_num_rows, $fields_meta;
57 global $err_url;
59 // 1. Initializes the $do_display array
60 $do_display = array();
61 $do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
62 $do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3];
63 $do_display['sort_lnk'] = (string) $the_disp_mode[4];
64 $do_display['nav_bar'] = (string) $the_disp_mode[5];
65 $do_display['ins_row'] = (string) $the_disp_mode[6];
66 $do_display['bkm_form'] = (string) $the_disp_mode[7];
67 $do_display['text_btn'] = (string) $the_disp_mode[8];
68 $do_display['pview_lnk'] = (string) $the_disp_mode[9];
70 // 2. Display mode is not "false for all elements" -> updates the
71 // display mode
72 if ($the_disp_mode != 'nnnn000000') {
73 // 2.0 Print view -> set all elements to false!
74 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
75 $do_display['edit_lnk'] = 'nn'; // no edit link
76 $do_display['del_lnk'] = 'nn'; // no delete link
77 $do_display['sort_lnk'] = (string) '0';
78 $do_display['nav_bar'] = (string) '0';
79 $do_display['ins_row'] = (string) '0';
80 $do_display['bkm_form'] = (string) '0';
81 $do_display['text_btn'] = (string) '0';
82 $do_display['pview_lnk'] = (string) '0';
84 // 2.1 Statement is a "SELECT COUNT", a
85 // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
86 // contains a "PROC ANALYSE" part
87 elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
88 $do_display['edit_lnk'] = 'nn'; // no edit link
89 $do_display['del_lnk'] = 'nn'; // no delete link
90 $do_display['sort_lnk'] = (string) '0';
91 $do_display['nav_bar'] = (string) '0';
92 $do_display['ins_row'] = (string) '0';
93 $do_display['bkm_form'] = (string) '1';
94 if ($GLOBALS['is_maint']) {
95 $do_display['text_btn'] = (string) '1';
96 } else {
97 $do_display['text_btn'] = (string) '0';
99 $do_display['pview_lnk'] = (string) '1';
101 // 2.2 Statement is a "SHOW..."
102 elseif ($GLOBALS['is_show']) {
104 * 2.2.1
105 * @todo defines edit/delete links depending on show statement
107 $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which);
108 if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
109 $do_display['edit_lnk'] = 'nn'; // no edit link
110 $do_display['del_lnk'] = 'kp'; // "kill process" type edit link
111 } else {
112 // Default case -> no links
113 $do_display['edit_lnk'] = 'nn'; // no edit link
114 $do_display['del_lnk'] = 'nn'; // no delete link
116 // 2.2.2 Other settings
117 $do_display['sort_lnk'] = (string) '0';
118 $do_display['nav_bar'] = (string) '0';
119 $do_display['ins_row'] = (string) '0';
120 $do_display['bkm_form'] = (string) '1';
121 $do_display['text_btn'] = (string) '1';
122 $do_display['pview_lnk'] = (string) '1';
124 // 2.3 Other statements (ie "SELECT" ones) -> updates
125 // $do_display['edit_lnk'], $do_display['del_lnk'] and
126 // $do_display['text_btn'] (keeps other default values)
127 else {
128 $prev_table = $fields_meta[0]->table;
129 $do_display['text_btn'] = (string) '1';
130 for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) {
131 $is_link = ($do_display['edit_lnk'] != 'nn'
132 || $do_display['del_lnk'] != 'nn'
133 || $do_display['sort_lnk'] != '0'
134 || $do_display['ins_row'] != '0');
135 // 2.3.2 Displays edit/delete/sort/insert links?
136 if ($is_link
137 && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
138 $do_display['edit_lnk'] = 'nn'; // don't display links
139 $do_display['del_lnk'] = 'nn';
141 * @todo May be problematic with same fields names in two joined table.
143 // $do_display['sort_lnk'] = (string) '0';
144 $do_display['ins_row'] = (string) '0';
145 if ($do_display['text_btn'] == '1') {
146 break;
148 } // end if (2.3.2)
149 // 2.3.3 Always display print view link
150 $do_display['pview_lnk'] = (string) '1';
151 $prev_table = $fields_meta[$i]->table;
152 } // end for
153 } // end if..elseif...else (2.1 -> 2.3)
154 } // end if (2)
156 // 3. Gets the total number of rows if it is unknown
157 if (isset($unlim_num_rows) && $unlim_num_rows != '') {
158 $the_total = $unlim_num_rows;
159 } elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
160 && (strlen($db) && !empty($table))) {
161 $the_total = PMA_Table::countRecords($db, $table);
164 // 4. If navigation bar or sorting fields names URLs should be
165 // displayed but there is only one row, change these settings to
166 // false
167 if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') {
169 // - Do not display sort links if less than 2 rows.
170 // - For a VIEW we (probably) did not count the number of rows
171 // so don't test this number here, it would remove the possibility
172 // of sorting VIEW results.
173 if (isset($unlim_num_rows) && $unlim_num_rows < 2 && ! PMA_Table::isView($db, $table)) {
174 // force display of navbar for vertical/horizontal display-choice.
175 // $do_display['nav_bar'] = (string) '0';
176 $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 * Return true if we are executing a query in the form of
189 * "SELECT * FROM <a table> ..."
191 * @return boolean
193 function PMA_isSelect()
195 // global variables set from sql.php
196 global $is_count, $is_export, $is_func, $is_analyse;
197 global $analyzed_sql;
199 return ! ($is_count || $is_export || $is_func || $is_analyse)
200 && count($analyzed_sql[0]['select_expr']) == 0
201 && isset($analyzed_sql[0]['queryflags']['select_from'])
202 && count($analyzed_sql[0]['table_ref']) == 1;
207 * Displays a navigation button
210 * @param string iconic caption for button
211 * @param string text for button
212 * @param integer position for next query
213 * @param string query ready for display
214 * @param string optional onsubmit clause
215 * @param string optional hidden field for special treatment
216 * @param string optional onclick clause
218 * @global string $db the database name
219 * @global string $table the table name
220 * @global string $goto the URL to go back in case of errors
222 * @access private
224 * @see PMA_displayTableNavigation()
226 function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_query, $onsubmit = '', $input_for_real_end = '', $onclick = '') {
228 global $db, $table, $goto;
230 $caption_output = '';
231 // for true or 'both'
232 if ($GLOBALS['cfg']['NavigationBarIconic']) {
233 $caption_output .= $caption;
235 // for false or 'both'
236 if (false === $GLOBALS['cfg']['NavigationBarIconic'] || 'both' === $GLOBALS['cfg']['NavigationBarIconic']) {
237 $caption_output .= '&nbsp;' . $title;
239 $title_output = ' title="' . $title . '"';
241 <td>
242 <form action="sql.php" method="post" <?php echo $onsubmit; ?>>
243 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
244 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
245 <input type="hidden" name="pos" value="<?php echo $pos; ?>" />
246 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
247 <?php echo $input_for_real_end; ?>
248 <input type="submit" name="navig" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax" ' : '' ); ?> value="<?php echo $caption_output; ?>"<?php echo $title_output . $onclick; ?> />
249 </form>
250 </td>
251 <?php
252 } // end function PMA_displayTableNavigationOneButton()
255 * Displays a navigation bar to browse among the results of a SQL query
257 * @param integer the offset for the "next" page
258 * @param integer the offset for the "previous" page
259 * @param string the URL-encoded query
260 * @param string the id for the direction dropdown
262 * @global string $db the database name
263 * @global string $table the table name
264 * @global string $goto the URL to go back in case of errors
265 * @global integer $num_rows the total number of rows returned by the
266 * SQL query
267 * @global integer $unlim_num_rows the total number of rows returned by the
268 * SQL any programmatically appended "LIMIT" clause
269 * @global boolean $is_innodb whether its InnoDB or not
270 * @global array $showtable table definitions
272 * @access private
274 * @see PMA_displayTable()
276 function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_direction_dropdown)
278 global $db, $table, $goto;
279 global $num_rows, $unlim_num_rows;
280 global $is_innodb;
281 global $showtable;
283 // here, using htmlentities() would cause problems if the query
284 // contains accented characters
285 $html_sql_query = htmlspecialchars($sql_query);
288 * @todo move this to a central place
289 * @todo for other future table types
291 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
295 <!-- Navigation bar -->
296 <table border="0" cellpadding="2" cellspacing="0" class="navigation">
297 <tr>
298 <?php
299 // Move to the beginning or to the previous page
300 if ($_SESSION['tmp_user_values']['pos'] && $_SESSION['tmp_user_values']['max_rows'] != 'all') {
301 PMA_displayTableNavigationOneButton('&lt;&lt;', __('Begin'), 0, $html_sql_query);
302 PMA_displayTableNavigationOneButton('&lt;', __('Previous'), $pos_prev, $html_sql_query);
304 } // end move back
306 //page redirection
307 // (unless we are showing all records)
308 if ('all' != $_SESSION['tmp_user_values']['max_rows']) { //if1
309 $pageNow = @floor($_SESSION['tmp_user_values']['pos'] / $_SESSION['tmp_user_values']['max_rows']) + 1;
310 $nbTotalPage = @ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']);
312 if ($nbTotalPage > 1){ //if2
314 <td>
315 <?php
316 $_url_params = array(
317 'db' => $db,
318 'table' => $table,
319 'sql_query' => $sql_query,
320 'goto' => $goto,
322 //<form> to keep the form alignment of button < and <<
323 // and also to know what to execute when the selector changes
324 echo '<form action="sql.php' . PMA_generate_common_url($_url_params). '" method="post">';
325 echo PMA_pageselector(
326 $_SESSION['tmp_user_values']['max_rows'],
327 $pageNow,
328 $nbTotalPage,
329 200,
334 __('Page number:')
337 </form>
338 </td>
339 <?php
340 } //_if2
341 } //_if1
343 // Display the "Show all" button if allowed
344 if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
345 echo "\n";
347 <td>
348 <form action="sql.php" method="post">
349 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
350 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
351 <input type="hidden" name="pos" value="0" />
352 <input type="hidden" name="session_max_rows" value="all" />
353 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
354 <input type="submit" name="navig" value="<?php echo __('Show all'); ?>" />
355 </form>
356 </td>
357 <?php
358 } // end show all
360 // Move to the next page or to the last one
361 if (($_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'] < $unlim_num_rows) && $num_rows >= $_SESSION['tmp_user_values']['max_rows']
362 && $_SESSION['tmp_user_values']['max_rows'] != 'all') {
364 // display the Next button
365 PMA_displayTableNavigationOneButton('&gt;',
366 __('Next'),
367 $pos_next,
368 $html_sql_query);
370 // prepare some options for the End button
371 if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
372 $input_for_real_end = '<input id="real_end_input" type="hidden" name="find_real_end" value="1" />';
373 // no backquote around this message
374 $onclick = '';
375 } else {
376 $input_for_real_end = $onclick = '';
379 // display the End button
380 PMA_displayTableNavigationOneButton('&gt;&gt;',
381 __('End'),
382 @((ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows'])- 1) * $_SESSION['tmp_user_values']['max_rows']),
383 $html_sql_query,
384 'onsubmit="return ' . (($_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'] < $unlim_num_rows && $num_rows >= $_SESSION['tmp_user_values']['max_rows']) ? 'true' : 'false') . '"',
385 $input_for_real_end,
386 $onclick
388 } // end move toward
390 <td>
391 <input class="restore_column hide" type="submit" value="<?php echo __('Restore column order'); ?>" />
392 <?php
393 if (PMA_isSelect()) {
394 // generate the column order, if it is set
395 $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
396 $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
397 if ($col_order) {
398 echo '<input id="col_order" type="hidden" value="' . implode(',', $col_order) . '" />';
400 // generate table create time
401 echo '<input id="table_create_time" type="hidden" value="' .
402 PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />';
404 // generate hints
405 echo '<input id="col_order_hint" type="hidden" value="' . __('Drag to reorder') . '" />';
406 echo '<input id="sort_hint" type="hidden" value="' . __('Click to sort') . '" />';
407 echo '<input id="col_mark_hint" type="hidden" value="' . __('Click to mark/unmark') . '" />';
409 </td>
410 </tr>
411 </table>
413 <?php // if displaying a VIEW, $unlim_num_rows could be zero because
414 // of $cfg['MaxExactCountViews']; in this case, avoid passing
415 // the 5th parameter to checkFormElementInRange()
416 // (this means we can't validate the upper limit ?>
417 <div>
418 <form action="sql.php" method="post"
419 onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', __('%d is not valid row number.')); ?>', 1) &amp;&amp; checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', __('%d is not valid row number.')); ?>', 0<?php echo $unlim_num_rows > 0 ? ',' . $unlim_num_rows - 1 : ''; ?>))">
420 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
421 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
422 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
423 <input type="submit" name="navig" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?> value="<?php echo __('Show'); ?> :" />
424 <input type="text" name="session_max_rows" size="3" value="<?php echo (($_SESSION['tmp_user_values']['max_rows'] != 'all') ? $_SESSION['tmp_user_values']['max_rows'] : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
425 <?php echo __('row(s) starting from row #') . "\n"; ?>
426 <input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
427 <?php
428 // Display mode (horizontal/vertical and repeat headers)
429 $choices = array(
430 'horizontal' => __('horizontal'),
431 'horizontalflipped' => __('horizontal (rotated headers)'),
432 'vertical' => __('vertical'));
433 $param1 = PMA_generate_html_dropdown('disp_direction', $choices, $_SESSION['tmp_user_values']['disp_direction'], $id_for_direction_dropdown);
434 unset($choices);
436 $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $_SESSION['tmp_user_values']['repeat_cells'] . '" class="textfield" />' . "\n"
437 . ' ';
438 echo ' ' . sprintf(__('in %s mode and repeat headers after %s cells'), "\n" . $param1, "\n" . $param2) . "\n";
440 </form>
441 </div>
442 <?php
443 } // end of the 'PMA_displayTableNavigation()' function
447 * Displays the headers of the results table
449 * @param array which elements to display
450 * @param array the list of fields properties
451 * @param integer the total number of fields returned by the SQL query
452 * @param array the analyzed query
454 * @return boolean $clause_is_unique
456 * @global string $db the database name
457 * @global string $table the table name
458 * @global string $goto the URL to go back in case of errors
459 * @global string $sql_query the SQL query
460 * @global integer $num_rows the total number of rows returned by the
461 * SQL query
462 * @global array $vertical_display informations used with vertical display
463 * mode
465 * @access private
467 * @see PMA_displayTable()
469 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '', $sort_expression, $sort_expression_nodirection, $sort_direction)
471 global $db, $table, $goto;
472 global $sql_query, $num_rows;
473 global $vertical_display, $highlight_columns;
475 // required to generate sort links that will remember whether the
476 // "Show all" button has been clicked
477 $sql_md5 = md5($GLOBALS['sql_query']);
478 $session_max_rows = $_SESSION['tmp_user_values']['query'][$sql_md5]['max_rows'];
480 if ($analyzed_sql == '') {
481 $analyzed_sql = array();
484 // can the result be sorted?
485 if ($is_display['sort_lnk'] == '1') {
487 // Just as fallback
488 $unsorted_sql_query = $sql_query;
489 if (isset($analyzed_sql[0]['unsorted_query'])) {
490 $unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
492 // Handles the case of multiple clicks on a column's header
493 // which would add many spaces before "ORDER BY" in the
494 // generated query.
495 $unsorted_sql_query = trim($unsorted_sql_query);
497 // sorting by indexes, only if it makes sense (only one table ref)
498 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
499 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
500 isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
502 // grab indexes data:
503 $indexes = PMA_Index::getFromTable($table, $db);
505 // do we have any index?
506 if ($indexes) {
508 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
509 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
510 $span = $fields_cnt;
511 if ($is_display['edit_lnk'] != 'nn') {
512 $span++;
514 if ($is_display['del_lnk'] != 'nn') {
515 $span++;
517 if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
518 $span++;
520 } else {
521 $span = $num_rows + floor($num_rows/$_SESSION['tmp_user_values']['repeat_cells']) + 1;
524 echo '<form action="sql.php" method="post">' . "\n";
525 echo PMA_generate_common_hidden_inputs($db, $table);
526 echo __('Sort by key') . ': <select name="sql_query" onchange="this.form.submit();">' . "\n";
527 $used_index = false;
528 $local_order = (isset($sort_expression) ? $sort_expression : '');
529 foreach ($indexes as $index) {
530 $asc_sort = '`' . implode('` ASC, `', array_keys($index->getColumns())) . '` ASC';
531 $desc_sort = '`' . implode('` DESC, `', array_keys($index->getColumns())) . '` DESC';
532 $used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
533 echo '<option value="'
534 . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort)
535 . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '')
536 . '>' . htmlspecialchars($index->getName()) . ' ('
537 . __('Ascending') . ')</option>';
538 echo '<option value="'
539 . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort)
540 . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '')
541 . '>' . htmlspecialchars($index->getName()) . ' ('
542 . __('Descending') . ')</option>';
544 echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"') . '>' . __('None') . '</option>';
545 echo '</select>' . "\n";
546 echo '<noscript><input type="submit" value="' . __('Go') . '" /></noscript>';
547 echo '</form>' . "\n";
553 $vertical_display['emptypre'] = 0;
554 $vertical_display['emptyafter'] = 0;
555 $vertical_display['textbtn'] = '';
557 // Display options (if we are not in print view)
558 if (! (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1')) {
559 echo '<form method="post" action="sql.php" name="displayOptionsForm" id="displayOptionsForm"';
560 if ($GLOBALS['cfg']['AjaxEnable']) {
561 echo ' class="ajax" ';
563 echo '>';
564 $url_params = array(
565 'db' => $db,
566 'table' => $table,
567 'sql_query' => $sql_query,
568 'goto' => $goto,
569 'display_options_form' => 1
571 echo PMA_generate_common_hidden_inputs($url_params);
572 echo '<br />';
573 PMA_generate_slider_effect('displayoptions',__('Options'));
574 echo '<fieldset>';
576 echo '<div class="formelement">';
577 $choices = array(
578 'P' => __('Partial texts'),
579 'F' => __('Full texts')
581 PMA_display_html_radio('display_text', $choices, $_SESSION['tmp_user_values']['display_text']);
582 echo '</div>';
584 // prepare full/partial text button or link
585 if ($_SESSION['tmp_user_values']['display_text']=='F') {
586 // currently in fulltext mode so show the opposite link
587 $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_partialtext.png';
588 $tmp_txt = __('Partial texts');
589 $url_params['display_text'] = 'P';
590 } else {
591 $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_fulltext.png';
592 $tmp_txt = __('Full texts');
593 $url_params['display_text'] = 'F';
596 $tmp_image = '<img class="fulltext" src="' . $tmp_image_file . '" alt="' . $tmp_txt . '" title="' . $tmp_txt . '" />';
597 $tmp_url = 'sql.php' . PMA_generate_common_url($url_params);
598 $full_or_partial_text_link = PMA_linkOrButton($tmp_url, $tmp_image, array(), false);
599 unset($tmp_image_file, $tmp_txt, $tmp_url, $tmp_image);
602 if ($GLOBALS['cfgRelation']['relwork'] && $GLOBALS['cfgRelation']['displaywork']) {
603 echo '<div class="formelement">';
604 $choices = array(
605 'K' => __('Relational key'),
606 'D' => __('Relational display column')
608 PMA_display_html_radio('relational_display', $choices, $_SESSION['tmp_user_values']['relational_display']);
609 echo '</div>';
612 echo '<div class="formelement">';
613 PMA_display_html_checkbox('display_binary', __('Show binary contents'), ! empty($_SESSION['tmp_user_values']['display_binary']), false);
614 echo '<br />';
615 PMA_display_html_checkbox('display_blob', __('Show BLOB contents'), ! empty($_SESSION['tmp_user_values']['display_blob']), false);
616 echo '<br />';
617 PMA_display_html_checkbox('display_binary_as_hex', __('Show binary contents as HEX'), ! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false);
618 echo '</div>';
620 // I would have preferred to name this "display_transformation".
621 // This is the only way I found to be able to keep this setting sticky
622 // per SQL query, and at the same time have a default that displays
623 // the transformations.
624 echo '<div class="formelement">';
625 PMA_display_html_checkbox('hide_transformation', __('Hide') . ' ' . __('Browser transformation'), ! empty($_SESSION['tmp_user_values']['hide_transformation']), false);
626 echo '</div>';
628 echo '<div class="formelement">';
629 $choices = array(
630 'GEOM' => __('Geometry'),
631 'WKT' => __('Well Known Text'),
632 'WKB' => __('Well Known Binary')
634 PMA_display_html_radio('geometry_display', $choices, $_SESSION['tmp_user_values']['geometry_display']);
635 echo '</div>';
637 echo '<div class="clearfloat"></div>';
638 echo '</fieldset>';
640 echo '<fieldset class="tblFooters">';
641 echo '<input type="submit" value="' . __('Go') . '" />';
642 echo '</fieldset>';
643 echo '</div>';
644 echo '</form>';
647 // Start of form for multi-rows edit/delete/export
649 if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') {
650 echo '<form method="post" action="tbl_row_action.php" name="resultsForm" id="resultsForm"';
651 if ($GLOBALS['cfg']['AjaxEnable']) {
652 echo ' class="ajax" ';
654 echo '>' . "\n";
655 echo PMA_generate_common_hidden_inputs($db, $table, 1);
656 echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
659 echo '<table id="table_results" class="data';
660 if ($GLOBALS['cfg']['AjaxEnable']) {
661 echo ' ajax';
663 echo '">' . "\n";
664 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
665 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
666 echo '<thead><tr>' . "\n";
669 // 1. Displays the full/partial text button (part 1)...
670 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
671 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
672 $colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
673 ? ' colspan="4"'
674 : '';
675 } else {
676 $rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
677 ? ' rowspan="4"'
678 : '';
681 // ... before the result table
682 if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
683 && $is_display['text_btn'] == '1') {
684 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 4 : 0;
685 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
686 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
688 <th colspan="<?php echo $fields_cnt; ?>"></th>
689 </tr>
690 <tr>
691 <?php
692 } // end horizontal/horizontalflipped mode
693 else {
695 <tr>
696 <th colspan="<?php echo $num_rows + floor($num_rows/$_SESSION['tmp_user_values']['repeat_cells']) + 1; ?>"></th>
697 </tr>
698 <?php
699 } // end vertical mode
702 // ... at the left column of the result table header if possible
703 // and required
704 elseif (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
705 && $is_display['text_btn'] == '1') {
706 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 4 : 0;
707 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
708 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
710 <th <?php echo $colspan; ?>><?php echo $full_or_partial_text_link;?></th>
711 <?php
712 } // end horizontal/horizontalflipped mode
713 else {
714 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
715 . ' ' . "\n"
716 . ' </th>' . "\n";
717 } // end vertical mode
720 // ... elseif no button, displays empty(ies) col(s) if required
721 elseif (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
722 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
723 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 4 : 0;
724 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
725 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
727 <td<?php echo $colspan; ?>></td>
728 <?php
729 } // end horizontal/horizontalfipped mode
730 else {
731 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
732 } // end vertical mode
735 // ... elseif display an empty column if the actions links are disabled to match the rest of the table
736 elseif ($GLOBALS['cfg']['RowActionLinks'] == 'none' && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
737 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped')) {
738 echo '<th></th>';
741 // 2. Displays the fields' name
742 // 2.0 If sorting links should be used, checks if the query is a "JOIN"
743 // statement (see 2.1.3)
745 // 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
746 // Do not show comments, if using horizontalflipped mode, because of space usage
747 if ($GLOBALS['cfg']['ShowBrowseComments']
748 && $_SESSION['tmp_user_values']['disp_direction'] != 'horizontalflipped') {
749 $comments_map = array();
750 if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
751 foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
752 $tb = $tbl['table_true_name'];
753 $comments_map[$tb] = PMA_getComments($db, $tb);
754 unset($tb);
759 if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME'] && ! $_SESSION['tmp_user_values']['hide_transformation']) {
760 require_once './libraries/transformations.lib.php';
761 $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
764 // See if we have to highlight any header fields of a WHERE query.
765 // Uses SQL-Parser results.
766 $highlight_columns = array();
767 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
768 isset($analyzed_sql[0]['where_clause_identifiers'])) {
770 $wi = 0;
771 if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
772 foreach ($analyzed_sql[0]['where_clause_identifiers'] AS $wci_nr => $wci) {
773 $highlight_columns[$wci] = 'true';
778 if (PMA_isSelect()) {
779 // prepare to get the column order, if available
780 $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
781 $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
782 } else {
783 $col_order = false;
786 for ($j = 0; $j < $fields_cnt; $j++) {
787 // assign $i with appropriate column order
788 $i = $col_order ? $col_order[$j] : $j;
789 // See if this column should get highlight because it's used in the
790 // where-query.
791 if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
792 $condition_field = true;
793 } else {
794 $condition_field = false;
797 // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
798 if (isset($comments_map) &&
799 isset($comments_map[$fields_meta[$i]->table]) &&
800 isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
801 $comments = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) . '</span>';
802 } else {
803 $comments = '';
806 // 2.1 Results can be sorted
807 if ($is_display['sort_lnk'] == '1') {
809 // 2.1.1 Checks if the table name is required; it's the case
810 // for a query with a "JOIN" statement and if the column
811 // isn't aliased, or in queries like
812 // SELECT `1`.`master_field` , `2`.`master_field`
813 // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
815 if (isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) {
816 $sort_tbl = PMA_backquote($fields_meta[$i]->table) . '.';
817 } else {
818 $sort_tbl = '';
821 // 2.1.2 Checks if the current column is used to sort the
822 // results
823 // the orgname member does not exist for all MySQL versions
824 // but if found, it's the one on which to sort
825 $name_to_use_in_sort = $fields_meta[$i]->name;
826 if (isset($fields_meta[$i]->orgname) && strlen($fields_meta[$i]->orgname)) {
827 $name_to_use_in_sort = $fields_meta[$i]->orgname;
829 // $name_to_use_in_sort might contain a space due to
830 // formatting of function expressions like "COUNT(name )"
831 // so we remove the space in this situation
832 $name_to_use_in_sort = str_replace(' )', ')', $name_to_use_in_sort);
834 if (empty($sort_expression)) {
835 $is_in_sort = false;
836 } else {
837 // Field name may be preceded by a space, or any number
838 // of characters followed by a dot (tablename.fieldname)
839 // so do a direct comparison for the sort expression;
840 // this avoids problems with queries like
841 // "SELECT id, count(id)..." and clicking to sort
842 // on id or on count(id).
843 // Another query to test this:
844 // SELECT p.*, FROM_UNIXTIME(p.temps) FROM mytable AS p
845 // (and try clicking on each column's header twice)
846 if (! empty($sort_tbl) && strpos($sort_expression_nodirection, $sort_tbl) === false && strpos($sort_expression_nodirection, '(') === false) {
847 $sort_expression_nodirection = $sort_tbl . $sort_expression_nodirection;
849 $is_in_sort = (str_replace('`', '', $sort_tbl) . $name_to_use_in_sort == str_replace('`', '', $sort_expression_nodirection) ? true : false);
851 // 2.1.3 Check the field name for a bracket.
852 // If it contains one, it's probably a function column
853 // like 'COUNT(`field`)'
854 if (strpos($name_to_use_in_sort, '(') !== false) {
855 $sort_order = ' ORDER BY ' . $name_to_use_in_sort . ' ';
856 } else {
857 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($name_to_use_in_sort) . ' ';
859 unset($name_to_use_in_sort);
861 // 2.1.4 Do define the sorting URL
862 if (! $is_in_sort) {
863 // patch #455484 ("Smart" order)
864 $GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']);
865 if ($GLOBALS['cfg']['Order'] === 'SMART') {
866 $sort_order .= (preg_match('@time|date@i', $fields_meta[$i]->type)) ? 'DESC' : 'ASC';
867 } else {
868 $sort_order .= $GLOBALS['cfg']['Order'];
870 $order_img = '';
871 } elseif ('DESC' == $sort_direction) {
872 $sort_order .= ' ASC';
873 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. __('Descending') . '" title="'. __('Descending') . '" id="soimg' . $i . '" />';
874 } else {
875 $sort_order .= ' DESC';
876 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. __('Ascending') . '" title="'. __('Ascending') . '" id="soimg' . $i . '" />';
879 if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
880 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
881 } else {
882 $sorted_sql_query = $unsorted_sql_query . $sort_order;
884 $_url_params = array(
885 'db' => $db,
886 'table' => $table,
887 'sql_query' => $sorted_sql_query,
888 'session_max_rows' => $session_max_rows
890 $order_url = 'sql.php' . PMA_generate_common_url($_url_params);
892 // 2.1.5 Displays the sorting URL
893 // enable sort order swapping for image
894 $order_link_params = array();
895 if (isset($order_img) && $order_img!='') {
896 if (strstr($order_img, 'asc')) {
897 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
898 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
899 } elseif (strstr($order_img, 'desc')) {
900 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
901 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
904 if ($GLOBALS['cfg']['HeaderFlipType'] == 'auto') {
905 if (PMA_USR_BROWSER_AGENT == 'IE') {
906 $GLOBALS['cfg']['HeaderFlipType'] = 'css';
907 } else {
908 $GLOBALS['cfg']['HeaderFlipType'] = 'fake';
911 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'
912 && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
913 $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
915 $order_link_params['title'] = __('Sort');
916 $order_link_content = ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
917 $order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true);
919 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
920 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
921 echo '<th';
922 $th_class = array();
923 $th_class[] = 'draggable';
924 if ($condition_field) {
925 $th_class[] = 'condition';
927 $th_class[] = 'column_heading';
928 if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
929 $th_class[] = 'pointer';
931 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
932 $th_class[] = 'marker';
934 echo ' class="' . implode(' ', $th_class) . '"';
936 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
937 echo ' valign="bottom"';
939 echo '>' . $order_link . $comments . '</th>';
941 $vertical_display['desc'][] = ' <th '
942 . 'class="draggable' . ($condition_field ? ' condition' : '') . '">' . "\n"
943 . $order_link . $comments . ' </th>' . "\n";
944 } // end if (2.1)
946 // 2.2 Results can't be sorted
947 else {
948 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
949 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
950 echo '<th';
951 $th_class = array();
952 $th_class[] = 'draggable';
953 if ($condition_field) {
954 $th_class[] = 'condition';
956 echo ' class="' . implode(' ', $th_class) . '"';
957 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
958 echo ' valign="bottom"';
960 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'
961 && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
962 echo ' style="direction: ltr; writing-mode: tb-rl;"';
964 echo '>';
965 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'
966 && $GLOBALS['cfg']['HeaderFlipType'] == 'fake') {
967 echo PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), '<br />');
968 } else {
969 echo htmlspecialchars($fields_meta[$i]->name);
971 echo "\n" . $comments . '</th>';
973 $vertical_display['desc'][] = ' <th '
974 . 'class="draggable' . ($condition_field ? ' condition"' : '') . '">' . "\n"
975 . ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
976 . $comments . ' </th>';
977 } // end else (2.2)
978 } // end for
980 // 3. Displays the needed checkboxes at the right
981 // column of the result table header if possible and required...
982 if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
983 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
984 && $is_display['text_btn'] == '1') {
985 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 4 : 1;
986 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
987 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
988 echo "\n";
990 <th <?php echo $colspan; ?>><?php echo $full_or_partial_text_link;?>
991 </th>
992 <?php
993 } // end horizontal/horizontalflipped mode
994 else {
995 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
996 . ' ' . "\n"
997 . ' </th>' . "\n";
998 } // end vertical mode
1001 // ... elseif no button, displays empty columns if required
1002 // (unless coming from Browse mode print view)
1003 elseif (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1004 && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
1005 && (!$GLOBALS['is_header_sent'])) {
1006 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 4 : 1;
1007 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1008 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1009 echo "\n";
1011 <td<?php echo $colspan; ?>></td>
1012 <?php
1013 } // end horizontal/horizontalflipped mode
1014 else {
1015 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
1016 } // end vertical mode
1019 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1020 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1022 </tr>
1023 </thead>
1024 <?php
1027 return true;
1028 } // end of the 'PMA_displayTableHeaders()' function
1032 * Prepares the display for a value
1034 * @param string $class
1035 * @param string $condition_field
1036 * @param string $value
1038 * @return string the td
1040 function PMA_buildValueDisplay($class, $condition_field, $value) {
1041 return '<td align="left"' . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $value . '</td>';
1045 * Prepares the display for a null value
1047 * @param string $class
1048 * @param string $condition_field
1050 * @return string the td
1052 function PMA_buildNullDisplay($class, $condition_field) {
1053 // the null class is needed for inline editing
1054 return '<td align="right"' . ' class="' . $class . ($condition_field ? ' condition' : '') . ' null"><i>NULL</i></td>';
1058 * Prepares the display for an empty value
1060 * @param string $class
1061 * @param string $condition_field
1062 * @param string $align
1064 * @return string the td
1066 function PMA_buildEmptyDisplay($class, $condition_field, $meta, $align = '') {
1067 $nowrap = ' nowrap';
1068 return '<td ' . $align . ' class="' . PMA_addClass($class, $condition_field, $meta, $nowrap) . '"></td>';
1072 * Adds the relavant classes.
1074 * @param string $class
1075 * @param string $condition_field
1076 * @param object $meta the meta-information about this field
1077 * @param string $nowrap
1078 * @param bool $is_field_truncated
1079 * @param string $transform_function
1080 * @param string $default_function
1082 * @return string the list of classes
1084 function PMA_addClass($class, $condition_field, $meta, $nowrap, $is_field_truncated = false, $transform_function = '', $default_function = '') {
1085 // Define classes to be added to this data field based on the type of data
1086 $enum_class = '';
1087 if(strpos($meta->flags, 'enum') !== false) {
1088 $enum_class = ' enum';
1091 $set_class = '';
1092 if(strpos($meta->flags, 'set') !== false) {
1093 $set_class = ' set';
1096 $bit_class = '';
1097 if(strpos($meta->type, 'bit') !== false) {
1098 $bit_class = ' bit';
1101 $mime_type_class = '';
1102 if(isset($meta->mimetype)) {
1103 $mime_type_class = ' ' . preg_replace('/\//', '_', $meta->mimetype);
1106 $result = $class . ($condition_field ? ' condition' : '') . $nowrap
1107 . ' ' . ($is_field_truncated ? ' truncated' : '')
1108 . ($transform_function != $default_function ? ' transformed' : '')
1109 . $enum_class . $set_class . $bit_class . $mime_type_class;
1111 return $result;
1114 * Displays the body of the results table
1116 * @param integer the link id associated to the query which results have
1117 * to be displayed
1118 * @param array which elements to display
1119 * @param array the list of relations
1120 * @param array the analyzed query
1122 * @return boolean always true
1124 * @global string $db the database name
1125 * @global string $table the table name
1126 * @global string $goto the URL to go back in case of errors
1127 * @global string $sql_query the SQL query
1128 * @global array $fields_meta the list of fields properties
1129 * @global integer $fields_cnt the total number of fields returned by
1130 * the SQL query
1131 * @global array $vertical_display informations used with vertical display
1132 * mode
1133 * @global array $highlight_columns column names to highlight
1134 * @global array $row current row data
1136 * @access private
1138 * @see PMA_displayTable()
1140 function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
1141 global $db, $table, $goto;
1142 global $sql_query, $fields_meta, $fields_cnt;
1143 global $vertical_display, $highlight_columns;
1144 global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
1146 $url_sql_query = $sql_query;
1148 // query without conditions to shorten URLs when needed, 200 is just
1149 // guess, it should depend on remaining URL length
1151 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
1152 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
1153 strlen($sql_query) > 200) {
1155 $url_sql_query = 'SELECT ';
1156 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
1157 $url_sql_query .= ' DISTINCT ';
1159 $url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
1160 if (!empty($analyzed_sql[0]['from_clause'])) {
1161 $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
1165 if (! is_array($map)) {
1166 $map = array();
1168 $row_no = 0;
1169 $vertical_display['edit'] = array();
1170 $vertical_display['copy'] = array();
1171 $vertical_display['delete'] = array();
1172 $vertical_display['data'] = array();
1173 $vertical_display['row_delete'] = array();
1174 // name of the class added to all inline editable elements
1175 $inline_edit_class = 'inline_edit';
1177 // prepare to get the column order, if available
1178 if (PMA_isSelect()) {
1179 $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
1180 $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
1181 } else {
1182 $col_order = false;
1185 // Correction University of Virginia 19991216 in the while below
1186 // Previous code assumed that all tables have keys, specifically that
1187 // the phpMyAdmin GUI should support row delete/edit only for such
1188 // tables.
1189 // Although always using keys is arguably the prescribed way of
1190 // defining a relational table, it is not required. This will in
1191 // particular be violated by the novice.
1192 // We want to encourage phpMyAdmin usage by such novices. So the code
1193 // below has been changed to conditionally work as before when the
1194 // table being displayed has one or more keys; but to display
1195 // delete/edit options correctly for tables without keys.
1197 $odd_row = true;
1198 while ($row = PMA_DBI_fetch_row($dt_result)) {
1199 // "vertical display" mode stuff
1200 if ($row_no != 0 && $_SESSION['tmp_user_values']['repeat_cells'] != 0 && !($row_no % $_SESSION['tmp_user_values']['repeat_cells'])
1201 && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1202 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'))
1204 echo '<tr>' . "\n";
1205 if ($vertical_display['emptypre'] > 0) {
1206 echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n"
1207 .' &nbsp;</th>' . "\n";
1208 } else if ($GLOBALS['cfg']['RowActionLinks'] == 'none') {
1209 echo ' <th></th>' . "\n";
1212 foreach ($vertical_display['desc'] as $val) {
1213 echo $val;
1216 if ($vertical_display['emptyafter'] > 0) {
1217 echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n"
1218 .' &nbsp;</th>' . "\n";
1220 echo '</tr>' . "\n";
1221 } // end if
1223 $alternating_color_class = ($odd_row ? 'odd' : 'even');
1224 $odd_row = ! $odd_row;
1226 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1227 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1228 // pointer code part
1229 echo '<tr class="' . $alternating_color_class . '">';
1233 // 1. Prepares the row
1234 // 1.1 Results from a "SELECT" statement -> builds the
1235 // WHERE clause to use in links (a unique key if possible)
1237 * @todo $where_clause could be empty, for example a table
1238 * with only one field and it's a BLOB; in this case,
1239 * avoid to display the delete and edit links
1241 list($where_clause, $clause_is_unique) = PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row);
1242 $where_clause_html = urlencode($where_clause);
1244 // 1.2 Defines the URLs for the modify/delete link(s)
1246 if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
1247 // We need to copy the value or else the == 'both' check will always return true
1249 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1250 $iconic_spacer = '<div class="nowrap">';
1251 } else {
1252 $iconic_spacer = '';
1255 // 1.2.1 Modify link(s)
1256 if ($is_display['edit_lnk'] == 'ur') { // update row case
1257 $_url_params = array(
1258 'db' => $db,
1259 'table' => $table,
1260 'where_clause' => $where_clause,
1261 'clause_is_unique' => $clause_is_unique,
1262 'sql_query' => $url_sql_query,
1263 'goto' => 'sql.php',
1265 $edit_url = 'tbl_change.php' . PMA_generate_common_url($_url_params + array('default_action' => 'update'));
1266 $copy_url = 'tbl_change.php' . PMA_generate_common_url($_url_params + array('default_action' => 'insert'));
1268 $edit_str = PMA_getIcon('b_edit.png', __('Edit'), true);
1269 $copy_str = PMA_getIcon('b_insrow.png', __('Copy'), true);
1271 // Class definitions required for inline editing jQuery scripts
1272 $edit_anchor_class = "edit_row_anchor";
1273 if( $clause_is_unique == 0) {
1274 $edit_anchor_class .= ' nonunique';
1276 } // end if (1.2.1)
1278 // 1.2.2 Delete/Kill link(s)
1279 if ($is_display['del_lnk'] == 'dr') { // delete row case
1280 $_url_params = array(
1281 'db' => $db,
1282 'table' => $table,
1283 'sql_query' => $url_sql_query,
1284 'message_to_show' => __('The row has been deleted'),
1285 'goto' => (empty($goto) ? 'tbl_sql.php' : $goto),
1287 $lnk_goto = 'sql.php' . PMA_generate_common_url($_url_params, 'text');
1289 $del_query = 'DELETE FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)
1290 . ' WHERE ' . $where_clause . ($clause_is_unique ? '' : ' LIMIT 1');
1292 $_url_params = array(
1293 'db' => $db,
1294 'table' => $table,
1295 'sql_query' => $del_query,
1296 'message_to_show' => __('The row has been deleted'),
1297 'goto' => $lnk_goto,
1299 $del_url = 'sql.php' . PMA_generate_common_url($_url_params);
1301 $js_conf = 'DELETE FROM ' . PMA_jsFormat($db) . '.' . PMA_jsFormat($table)
1302 . ' WHERE ' . PMA_jsFormat($where_clause, false)
1303 . ($clause_is_unique ? '' : ' LIMIT 1');
1304 $del_str = PMA_getIcon('b_drop.png', __('Delete'), true);
1305 } elseif ($is_display['del_lnk'] == 'kp') { // kill process case
1307 $_url_params = array(
1308 'db' => $db,
1309 'table' => $table,
1310 'sql_query' => $url_sql_query,
1311 'goto' => 'main.php',
1313 $lnk_goto = 'sql.php' . PMA_generate_common_url($_url_params, 'text');
1315 $_url_params = array(
1316 'db' => 'mysql',
1317 'sql_query' => 'KILL ' . $row[0],
1318 'goto' => $lnk_goto,
1320 $del_url = 'sql.php' . PMA_generate_common_url($_url_params);
1321 $del_query = 'KILL ' . $row[0];
1322 $js_conf = 'KILL ' . $row[0];
1323 $del_str = PMA_getIcon('b_drop.png', __('Kill'), true);
1324 } // end if (1.2.2)
1326 // 1.3 Displays the links at left if required
1327 if (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1328 && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1329 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped')) {
1330 if (! isset($js_conf)) {
1331 $js_conf = '';
1333 echo PMA_generateCheckboxAndLinks('left', $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, $edit_str, $copy_str, $del_str, $js_conf);
1334 } else if (($GLOBALS['cfg']['RowActionLinks'] == 'none')
1335 && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1336 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped')) {
1337 if (! isset($js_conf)) {
1338 $js_conf = '';
1340 echo PMA_generateCheckboxAndLinks('none', $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, 'l', $edit_url, $copy_url, $edit_anchor_class, $edit_str, $copy_str, $del_str, $js_conf);
1341 } // end if (1.3)
1342 } // end if (1)
1344 // 2. Displays the rows' values
1346 for ($j = 0; $j < $fields_cnt; ++$j) {
1347 // assign $i with appropriate column order
1348 $i = $col_order ? $col_order[$j] : $j;
1350 $meta = $fields_meta[$i];
1351 $not_null_class = $meta->not_null ? 'not_null' : '';
1352 $relation_class = isset($map[$meta->name]) ? 'relation' : '';
1353 $pointer = $i;
1354 $is_field_truncated = false;
1355 //If the previous column had blob data, we need to reset the class
1356 // to $inline_edit_class
1357 $class = 'data ' . $inline_edit_class . ' ' . $not_null_class . ' ' . $alternating_color_class . ' ' . $relation_class;
1359 // See if this column should get highlight because it's used in the
1360 // where-query.
1361 if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) {
1362 $condition_field = true;
1363 } else {
1364 $condition_field = false;
1367 if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical' && (! isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
1368 // the row number corresponds to a data row, not HTML table row
1369 $class .= ' row_' . $row_no;
1370 if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1371 $class .= ' vpointer';
1373 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1374 $class .= ' vmarker';
1376 }// end if
1378 // Wrap MIME-transformations. [MIME]
1379 $default_function = 'default_function'; // default_function
1380 $transform_function = $default_function;
1381 $transform_options = array();
1383 if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
1385 if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) {
1386 $include_file = $GLOBALS['mime_map'][$meta->name]['transformation'];
1388 if (file_exists('./libraries/transformations/' . $include_file)) {
1389 $transformfunction_name = str_replace('.inc.php', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
1391 require_once './libraries/transformations/' . $include_file;
1393 if (function_exists('PMA_transformation_' . $transformfunction_name)) {
1394 $transform_function = 'PMA_transformation_' . $transformfunction_name;
1395 $transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''));
1396 $meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
1398 } // end if file_exists
1399 } // end if transformation is set
1400 } // end if mime/transformation works.
1402 $_url_params = array(
1403 'db' => $db,
1404 'table' => $table,
1405 'where_clause' => $where_clause,
1406 'transform_key' => $meta->name,
1409 if (! empty($sql_query)) {
1410 $_url_params['sql_query'] = $url_sql_query;
1413 $transform_options['wrapper_link'] = PMA_generate_common_url($_url_params);
1415 // n u m e r i c
1416 if ($meta->numeric == 1) {
1418 // if two fields have the same name (this is possible
1419 // with self-join queries, for example), using $meta->name
1420 // will show both fields NULL even if only one is NULL,
1421 // so use the $pointer
1423 if (! isset($row[$i]) || is_null($row[$i])) {
1424 $vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
1425 } elseif ($row[$i] != '') {
1427 $nowrap = ' nowrap';
1428 $where_comparison = ' = ' . $row[$i];
1430 $vertical_display['data'][$row_no][$i] = '<td align="right"' . PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $map, $row[$i], $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated);
1431 } else {
1432 $vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta, 'align="right"');
1435 // b l o b
1437 } elseif (stristr($meta->type, 'BLOB')) {
1438 // PMA_mysql_fetch_fields returns BLOB in place of
1439 // TEXT fields type so we have to ensure it's really a BLOB
1440 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1442 // remove 'inline_edit' from $class as we can't edit binary data.
1443 $class = str_replace('inline_edit', '', $class);
1445 if (stristr($field_flags, 'BINARY')) {
1446 if (! isset($row[$i]) || is_null($row[$i])) {
1447 $vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
1448 } else {
1449 // for blobstreaming
1450 // if valid BS reference exists
1451 if (PMA_BS_IsPBMSReference($row[$i], $db)) {
1452 $blobtext = PMA_BS_CreateReferenceLink($row[$i], $db);
1453 } else {
1454 $blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ? $row[$i] : ''), $transform_function, $transform_options, $default_function, $meta, $_url_params);
1457 $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $blobtext);
1458 unset($blobtext);
1460 // not binary:
1461 } else {
1462 if (! isset($row[$i]) || is_null($row[$i])) {
1463 $vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
1464 } elseif ($row[$i] != '') {
1465 // if a transform function for blob is set, none of these replacements will be made
1466 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P') {
1467 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1468 $is_field_truncated = true;
1470 // displays all space characters, 4 space
1471 // characters for tabulations and <cr>/<lf>
1472 $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1474 $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $row[$i]);
1475 } else {
1476 $vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta);
1479 // g e o m e t r y
1480 } elseif ($meta->type == 'geometry') {
1482 // Remove 'inline_edit' from $class as we do not allow to inline-edit geometry data.
1483 $class = str_replace('inline_edit', '', $class);
1485 // Display as [GEOMETRY - (size)]
1486 if ('GEOM' == $_SESSION['tmp_user_values']['geometry_display']) {
1487 $geometry_text = PMA_handle_non_printable_contents(
1488 'GEOMETRY', (isset($row[$i]) ? $row[$i] : ''), $transform_function,
1489 $transform_options, $default_function, $meta
1491 $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay(
1492 $class, $condition_field, $geometry_text
1495 // Display in Well Known Text(WKT) format.
1496 } elseif ('WKT' == $_SESSION['tmp_user_values']['geometry_display']) {
1497 // Convert to WKT format
1498 $wktsql = "SELECT ASTEXT (GeomFromWKB(x'" . PMA_substr(bin2hex($row[$i]), 8) . "'))";
1499 $wktresult = PMA_DBI_try_query($wktsql, null, PMA_DBI_QUERY_STORE);
1500 $wktarr = PMA_DBI_fetch_row($wktresult, 0);
1501 $wktval = $wktarr[0];
1502 @PMA_DBI_free_result($wktresult);
1504 if (PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars']
1505 && $_SESSION['tmp_user_values']['display_text'] == 'P'
1507 $wktval = PMA_substr($wktval, 0, $GLOBALS['cfg']['LimitChars']) . '...';
1508 $is_field_truncated = true;
1511 $vertical_display['data'][$row_no][$i] = '<td ' . PMA_prepare_row_data(
1512 $class, $condition_field, $analyzed_sql, $meta, $map, $wktval, $transform_function,
1513 $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated
1516 // Display in Well Known Binary(WKB) format.
1517 } else {
1518 if ($_SESSION['tmp_user_values']['display_binary']) {
1519 if ($_SESSION['tmp_user_values']['display_binary_as_hex']
1520 && PMA_contains_nonprintable_ascii($row[$i])
1522 $wkbval = PMA_substr(bin2hex($row[$i]), 8);
1523 } else {
1524 $wkbval = htmlspecialchars(PMA_replace_binary_contents($row[$i]));
1527 if (PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']
1528 && $_SESSION['tmp_user_values']['display_text'] == 'P'
1530 $wkbval = PMA_substr($wkbval, 0, $GLOBALS['cfg']['LimitChars']) . '...';
1531 $is_field_truncated = true;
1534 $vertical_display['data'][$row_no][$i] = '<td ' . PMA_prepare_row_data(
1535 $class, $condition_field, $analyzed_sql, $meta, $map, $wkbval, $transform_function,
1536 $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated
1538 } else {
1539 $wkbval = PMA_handle_non_printable_contents(
1540 'BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta, $_url_params
1542 $vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $wkbval);
1546 // n o t n u m e r i c a n d n o t B L O B
1547 } else {
1548 if (! isset($row[$i]) || is_null($row[$i])) {
1549 $vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field);
1550 } elseif ($row[$i] != '') {
1551 // support blanks in the key
1552 $relation_id = $row[$i];
1554 // Cut all fields to $GLOBALS['cfg']['LimitChars']
1555 // (unless it's a link-type transformation)
1556 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P' && !strpos($transform_function, 'link') === true) {
1557 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1558 $is_field_truncated = true;
1561 // displays special characters from binaries
1562 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1563 if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
1564 $row[$i] = PMA_printable_bit_value($row[$i], $meta->length);
1565 // some results of PROCEDURE ANALYSE() are reported as
1566 // being BINARY but they are quite readable,
1567 // so don't treat them as BINARY
1568 } elseif (stristr($field_flags, 'BINARY') && $meta->type == 'string' && !(isset($GLOBALS['is_analyse']) && $GLOBALS['is_analyse'])) {
1569 if ($_SESSION['tmp_user_values']['display_binary']) {
1570 // user asked to see the real contents of BINARY
1571 // fields
1572 if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && PMA_contains_nonprintable_ascii($row[$i])) {
1573 $row[$i] = bin2hex($row[$i]);
1574 } else {
1575 $row[$i] = htmlspecialchars(PMA_replace_binary_contents($row[$i]));
1577 } else {
1578 // we show the BINARY message and field's size
1579 // (or maybe use a transformation)
1580 $row[$i] = PMA_handle_non_printable_contents('BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta, $_url_params);
1584 // transform functions may enable no-wrapping:
1585 $function_nowrap = $transform_function . '_nowrap';
1586 $bool_nowrap = (($default_function != $transform_function && function_exists($function_nowrap)) ? $function_nowrap($transform_options) : false);
1588 // do not wrap if date field type
1589 $nowrap = ((preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap) ? ' nowrap' : '');
1590 $where_comparison = ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
1591 $vertical_display['data'][$row_no][$i] = '<td ' . PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $map, $row[$i], $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated);
1593 } else {
1594 $vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta);
1598 // output stored cell
1599 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1600 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1601 echo $vertical_display['data'][$row_no][$i];
1604 if (isset($vertical_display['rowdata'][$i][$row_no])) {
1605 $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
1606 } else {
1607 $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
1609 } // end for (2)
1611 // 3. Displays the modify/delete links on the right if required
1612 if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1613 && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1614 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped')) {
1615 if (! isset($js_conf)) {
1616 $js_conf = '';
1618 echo PMA_generateCheckboxAndLinks('right', $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, 'r', $edit_url, $copy_url, $edit_anchor_class, $edit_str, $copy_str, $del_str, $js_conf);
1619 } // end if (3)
1621 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1622 || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1624 </tr>
1625 <?php
1626 } // end if
1628 // 4. Gather links of del_urls and edit_urls in an array for later
1629 // output
1630 if (! isset($vertical_display['edit'][$row_no])) {
1631 $vertical_display['edit'][$row_no] = '';
1632 $vertical_display['copy'][$row_no] = '';
1633 $vertical_display['delete'][$row_no] = '';
1634 $vertical_display['row_delete'][$row_no] = '';
1636 $vertical_class = ' row_' . $row_no;
1637 if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1638 $vertical_class .= ' vpointer';
1640 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1641 $vertical_class .= ' vmarker';
1644 if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
1645 $vertical_display['row_delete'][$row_no] .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, '[%_PMA_CHECKBOX_DIR_%]', $alternating_color_class . $vertical_class);
1646 } else {
1647 unset($vertical_display['row_delete'][$row_no]);
1650 if (isset($edit_url)) {
1651 $vertical_display['edit'][$row_no] .= PMA_generateEditLink($edit_url, $alternating_color_class . ' ' . $edit_anchor_class . $vertical_class, $edit_str, $where_clause, $where_clause_html);
1652 } else {
1653 unset($vertical_display['edit'][$row_no]);
1656 if (isset($copy_url)) {
1657 $vertical_display['copy'][$row_no] .= PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause_html, $alternating_color_class . $vertical_class);
1658 } else {
1659 unset($vertical_display['copy'][$row_no]);
1662 if (isset($del_url)) {
1663 if (! isset($js_conf)) {
1664 $js_conf = '';
1666 $vertical_display['delete'][$row_no] .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, $alternating_color_class . $vertical_class);
1667 } else {
1668 unset($vertical_display['delete'][$row_no]);
1671 echo (($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') ? "\n" : '');
1672 $row_no++;
1673 } // end while
1675 // this is needed by PMA_displayTable() to generate the proper param
1676 // in the multi-edit and multi-delete form
1677 return $clause_is_unique;
1678 } // end of the 'PMA_displayTableBody()' function
1682 * Do display the result table with the vertical direction mode.
1684 * @return boolean always true
1686 * @global array $vertical_display the information to display
1688 * @access private
1690 * @see PMA_displayTable()
1692 function PMA_displayVerticalTable()
1694 global $vertical_display;
1696 // Displays "multi row delete" link at top if required
1697 if (($GLOBALS['cfg']['RowActionLinks'] != 'right')
1698 && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1699 echo '<tr>' . "\n";
1700 if ($GLOBALS['cfg']['RowActionLinks'] == 'none') {
1701 // if we are not showing the RowActionLinks, then we need to show the Multi-Row-Action checkboxes
1702 echo '<th></th>' . "\n";
1704 echo $vertical_display['textbtn'];
1705 $foo_counter = 0;
1706 foreach ($vertical_display['row_delete'] as $val) {
1707 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1708 echo '<th></th>' . "\n";
1710 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_left', $val);
1711 $foo_counter++;
1712 } // end while
1713 echo '</tr>' . "\n";
1714 } // end if
1716 // Displays "edit" link at top if required
1717 if (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1718 && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1719 echo '<tr>' . "\n";
1720 if (! is_array($vertical_display['row_delete'])) {
1721 echo $vertical_display['textbtn'];
1723 $foo_counter = 0;
1724 foreach ($vertical_display['edit'] as $val) {
1725 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1726 echo ' <th></th>' . "\n";
1729 echo $val;
1730 $foo_counter++;
1731 } // end while
1732 echo '</tr>' . "\n";
1733 } // end if
1735 // Displays "copy" link at top if required
1736 if (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1737 && is_array($vertical_display['copy']) && (count($vertical_display['copy']) > 0 || !empty($vertical_display['textbtn']))) {
1738 echo '<tr>' . "\n";
1739 if (! is_array($vertical_display['row_delete'])) {
1740 echo $vertical_display['textbtn'];
1742 $foo_counter = 0;
1743 foreach ($vertical_display['copy'] as $val) {
1744 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1745 echo ' <th></th>' . "\n";
1748 echo $val;
1749 $foo_counter++;
1750 } // end while
1751 echo '</tr>' . "\n";
1752 } // end if
1754 // Displays "delete" link at top if required
1755 if (($GLOBALS['cfg']['RowActionLinks'] == 'left' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1756 && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1757 echo '<tr>' . "\n";
1758 if (! is_array($vertical_display['edit']) && ! is_array($vertical_display['row_delete'])) {
1759 echo $vertical_display['textbtn'];
1761 $foo_counter = 0;
1762 foreach ($vertical_display['delete'] as $val) {
1763 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1764 echo '<th></th>' . "\n";
1767 echo $val;
1768 $foo_counter++;
1769 } // end while
1770 echo '</tr>' . "\n";
1771 } // end if
1773 if (PMA_isSelect()) {
1774 // prepare to get the column order, if available
1775 $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
1776 $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
1777 } else {
1778 $col_order = false;
1781 // Displays data
1782 foreach ($vertical_display['desc'] AS $j => $val) {
1783 // assign appropriate key with current column order
1784 $key = $col_order ? $col_order[$j] : $j;
1786 echo '<tr>' . "\n";
1787 echo $val;
1789 $foo_counter = 0;
1790 foreach ($vertical_display['rowdata'][$key] as $subval) {
1791 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) and !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1792 echo $val;
1795 echo $subval;
1796 $foo_counter++;
1797 } // end while
1799 echo '</tr>' . "\n";
1800 } // end while
1802 // Displays "multi row delete" link at bottom if required
1803 if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1804 && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1805 echo '<tr>' . "\n";
1806 echo $vertical_display['textbtn'];
1807 $foo_counter = 0;
1808 foreach ($vertical_display['row_delete'] as $val) {
1809 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1810 echo '<th></th>' . "\n";
1813 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '_right', $val);
1814 $foo_counter++;
1815 } // end while
1816 echo '</tr>' . "\n";
1817 } // end if
1819 // Displays "edit" link at bottom if required
1820 if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1821 && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1822 echo '<tr>' . "\n";
1823 if (! is_array($vertical_display['row_delete'])) {
1824 echo $vertical_display['textbtn'];
1826 $foo_counter = 0;
1827 foreach ($vertical_display['edit'] as $val) {
1828 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1829 echo '<th></th>' . "\n";
1832 echo $val;
1833 $foo_counter++;
1834 } // end while
1835 echo '</tr>' . "\n";
1836 } // end if
1838 // Displays "copy" link at bottom if required
1839 if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1840 && is_array($vertical_display['copy']) && (count($vertical_display['copy']) > 0 || !empty($vertical_display['textbtn']))) {
1841 echo '<tr>' . "\n";
1842 if (! is_array($vertical_display['row_delete'])) {
1843 echo $vertical_display['textbtn'];
1845 $foo_counter = 0;
1846 foreach ($vertical_display['copy'] as $val) {
1847 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1848 echo '<th></th>' . "\n";
1851 echo $val;
1852 $foo_counter++;
1853 } // end while
1854 echo '</tr>' . "\n";
1855 } // end if
1857 // Displays "delete" link at bottom if required
1858 if (($GLOBALS['cfg']['RowActionLinks'] == 'right' || $GLOBALS['cfg']['RowActionLinks'] == 'both')
1859 && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1860 echo '<tr>' . "\n";
1861 if (! is_array($vertical_display['edit']) && ! is_array($vertical_display['row_delete'])) {
1862 echo $vertical_display['textbtn'];
1864 $foo_counter = 0;
1865 foreach ($vertical_display['delete'] as $val) {
1866 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['tmp_user_values']['repeat_cells'])) {
1867 echo '<th></th>' . "\n";
1870 echo $val;
1871 $foo_counter++;
1872 } // end while
1873 echo '</tr>' . "\n";
1876 return true;
1877 } // end of the 'PMA_displayVerticalTable' function
1881 * @todo make maximum remembered queries configurable
1882 * @todo move/split into SQL class!?
1883 * @todo currently this is called twice unnecessary
1884 * @todo ignore LIMIT and ORDER in query!?
1886 function PMA_displayTable_checkConfigParams()
1888 $sql_md5 = md5($GLOBALS['sql_query']);
1890 $_SESSION['tmp_user_values']['query'][$sql_md5]['sql'] = $GLOBALS['sql_query'];
1892 if (PMA_isValid($_REQUEST['disp_direction'], array('horizontal', 'vertical', 'horizontalflipped'))) {
1893 $_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'] = $_REQUEST['disp_direction'];
1894 unset($_REQUEST['disp_direction']);
1895 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'])) {
1896 $_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'] = $GLOBALS['cfg']['DefaultDisplay'];
1899 if (PMA_isValid($_REQUEST['repeat_cells'], 'numeric')) {
1900 $_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'] = $_REQUEST['repeat_cells'];
1901 unset($_REQUEST['repeat_cells']);
1902 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'])) {
1903 $_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'] = $GLOBALS['cfg']['RepeatCells'];
1906 // as this is a form value, the type is always string so we cannot
1907 // use PMA_isValid($_REQUEST['session_max_rows'], 'integer')
1908 if ((PMA_isValid($_REQUEST['session_max_rows'], 'numeric')
1909 && (int) $_REQUEST['session_max_rows'] == $_REQUEST['session_max_rows'])
1910 || $_REQUEST['session_max_rows'] == 'all') {
1911 $_SESSION['tmp_user_values']['query'][$sql_md5]['max_rows'] = $_REQUEST['session_max_rows'];
1912 unset($_REQUEST['session_max_rows']);
1913 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['max_rows'])) {
1914 $_SESSION['tmp_user_values']['query'][$sql_md5]['max_rows'] = $GLOBALS['cfg']['MaxRows'];
1917 if (PMA_isValid($_REQUEST['pos'], 'numeric')) {
1918 $_SESSION['tmp_user_values']['query'][$sql_md5]['pos'] = $_REQUEST['pos'];
1919 unset($_REQUEST['pos']);
1920 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['pos'])) {
1921 $_SESSION['tmp_user_values']['query'][$sql_md5]['pos'] = 0;
1924 if (PMA_isValid($_REQUEST['display_text'], array('P', 'F'))) {
1925 $_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'] = $_REQUEST['display_text'];
1926 unset($_REQUEST['display_text']);
1927 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'])) {
1928 $_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'] = 'P';
1931 if (PMA_isValid($_REQUEST['relational_display'], array('K', 'D'))) {
1932 $_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'] = $_REQUEST['relational_display'];
1933 unset($_REQUEST['relational_display']);
1934 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'])) {
1935 $_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'] = 'K';
1938 if (PMA_isValid($_REQUEST['geometry_display'], array('WKT', 'WKB', 'GEOM'))) {
1939 $_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'] = $_REQUEST['geometry_display'];
1940 unset($_REQUEST['geometry_display']);
1941 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'])) {
1942 $_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'] = 'GEOM';
1945 if (isset($_REQUEST['display_binary'])) {
1946 $_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary'] = true;
1947 unset($_REQUEST['display_binary']);
1948 } elseif (isset($_REQUEST['display_options_form'])) {
1949 // we know that the checkbox was unchecked
1950 unset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary']);
1951 } else {
1952 // selected by default because some operations like OPTIMIZE TABLE
1953 // and all queries involving functions return "binary" contents,
1954 // according to low-level field flags
1955 $_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary'] = true;
1958 if (isset($_REQUEST['display_binary_as_hex'])) {
1959 $_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex'] = true;
1960 unset($_REQUEST['display_binary_as_hex']);
1961 } elseif (isset($_REQUEST['display_options_form'])) {
1962 // we know that the checkbox was unchecked
1963 unset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex']);
1964 } else {
1965 // display_binary_as_hex config option
1966 if (isset($GLOBALS['cfg']['DisplayBinaryAsHex']) && true === $GLOBALS['cfg']['DisplayBinaryAsHex']) {
1967 $_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex'] = true;
1971 if (isset($_REQUEST['display_blob'])) {
1972 $_SESSION['tmp_user_values']['query'][$sql_md5]['display_blob'] = true;
1973 unset($_REQUEST['display_blob']);
1974 } elseif (isset($_REQUEST['display_options_form'])) {
1975 // we know that the checkbox was unchecked
1976 unset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_blob']);
1979 if (isset($_REQUEST['hide_transformation'])) {
1980 $_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation'] = true;
1981 unset($_REQUEST['hide_transformation']);
1982 } elseif (isset($_REQUEST['display_options_form'])) {
1983 // we know that the checkbox was unchecked
1984 unset($_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation']);
1987 // move current query to the last position, to be removed last
1988 // so only least executed query will be removed if maximum remembered queries
1989 // limit is reached
1990 $tmp = $_SESSION['tmp_user_values']['query'][$sql_md5];
1991 unset($_SESSION['tmp_user_values']['query'][$sql_md5]);
1992 $_SESSION['tmp_user_values']['query'][$sql_md5] = $tmp;
1994 // do not exceed a maximum number of queries to remember
1995 if (count($_SESSION['tmp_user_values']['query']) > 10) {
1996 array_shift($_SESSION['tmp_user_values']['query']);
1997 //echo 'deleting one element ...';
2000 // populate query configuration
2001 $_SESSION['tmp_user_values']['display_text'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['display_text'];
2002 $_SESSION['tmp_user_values']['relational_display'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['relational_display'];
2003 $_SESSION['tmp_user_values']['geometry_display'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['geometry_display'];
2004 $_SESSION['tmp_user_values']['display_binary'] = isset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary']) ? true : false;
2005 $_SESSION['tmp_user_values']['display_binary_as_hex'] = isset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_binary_as_hex']) ? true : false;
2006 $_SESSION['tmp_user_values']['display_blob'] = isset($_SESSION['tmp_user_values']['query'][$sql_md5]['display_blob']) ? true : false;
2007 $_SESSION['tmp_user_values']['hide_transformation'] = isset($_SESSION['tmp_user_values']['query'][$sql_md5]['hide_transformation']) ? true : false;
2008 $_SESSION['tmp_user_values']['pos'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['pos'];
2009 $_SESSION['tmp_user_values']['max_rows'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['max_rows'];
2010 $_SESSION['tmp_user_values']['repeat_cells'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['repeat_cells'];
2011 $_SESSION['tmp_user_values']['disp_direction'] = $_SESSION['tmp_user_values']['query'][$sql_md5]['disp_direction'];
2014 * debugging
2015 echo '<pre>';
2016 var_dump($_SESSION['tmp_user_values']);
2017 echo '</pre>';
2022 * Displays a table of results returned by a SQL query.
2023 * This function is called by the "sql.php" script.
2025 * @param integer the link id associated to the query which results have
2026 * to be displayed
2027 * @param array the display mode
2028 * @param array the analyzed query
2030 * @global string $db the database name
2031 * @global string $table the table name
2032 * @global string $goto the URL to go back in case of errors
2033 * @global string $sql_query the current SQL query
2034 * @global integer $num_rows the total number of rows returned by the
2035 * SQL query
2036 * @global integer $unlim_num_rows the total number of rows returned by the
2037 * SQL query without any programmatically
2038 * appended "LIMIT" clause
2039 * @global array $fields_meta the list of fields properties
2040 * @global integer $fields_cnt the total number of fields returned by
2041 * the SQL query
2042 * @global array $vertical_display informations used with vertical display
2043 * mode
2044 * @global array $highlight_columns column names to highlight
2045 * @global array $cfgRelation the relation settings
2047 * @access private
2049 * @see PMA_showMessage(), PMA_setDisplayMode(),
2050 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
2051 * PMA_displayTableBody(), PMA_displayResultsOperations()
2053 function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
2055 global $db, $table, $goto;
2056 global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt;
2057 global $vertical_display, $highlight_columns;
2058 global $cfgRelation;
2059 global $showtable;
2061 // why was this called here? (already called from sql.php)
2062 //PMA_displayTable_checkConfigParams();
2065 * @todo move this to a central place
2066 * @todo for other future table types
2068 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
2070 if ($is_innodb
2071 && ! isset($analyzed_sql[0]['queryflags']['union'])
2072 && ! isset($analyzed_sql[0]['table_ref'][1]['table_name'])
2073 && (empty($analyzed_sql[0]['where_clause'])
2074 || $analyzed_sql[0]['where_clause'] == '1 ')) {
2075 // "j u s t b r o w s i n g"
2076 $pre_count = '~';
2077 $after_count = PMA_showHint(PMA_sanitize(__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]')), true);
2078 } else {
2079 $pre_count = '';
2080 $after_count = '';
2083 // 1. ----- Prepares the work -----
2085 // 1.1 Gets the informations about which functionalities should be
2086 // displayed
2087 $total = '';
2088 $is_display = PMA_setDisplayMode($the_disp_mode, $total);
2090 // 1.2 Defines offsets for the next and previous pages
2091 if ($is_display['nav_bar'] == '1') {
2092 if ($_SESSION['tmp_user_values']['max_rows'] == 'all') {
2093 $pos_next = 0;
2094 $pos_prev = 0;
2095 } else {
2096 $pos_next = $_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'];
2097 $pos_prev = $_SESSION['tmp_user_values']['pos'] - $_SESSION['tmp_user_values']['max_rows'];
2098 if ($pos_prev < 0) {
2099 $pos_prev = 0;
2102 } // end if
2104 // 1.3 Find the sort expression
2106 // we need $sort_expression and $sort_expression_nodirection
2107 // even if there are many table references
2108 if (! empty($analyzed_sql[0]['order_by_clause'])) {
2109 $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
2111 * Get rid of ASC|DESC
2113 preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
2114 $sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
2115 $sort_direction = isset($matches[2]) ? trim($matches[2]) : '';
2116 unset($matches);
2117 } else {
2118 $sort_expression = $sort_expression_nodirection = $sort_direction = '';
2121 // 1.4 Prepares display of first and last value of the sorted column
2123 if (! empty($sort_expression_nodirection)) {
2124 if (strpos($sort_expression_nodirection, '.') === false) {
2125 $sort_table = $table;
2126 $sort_column = $sort_expression_nodirection;
2127 } else {
2128 list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
2130 $sort_table = PMA_unQuote($sort_table);
2131 $sort_column = PMA_unQuote($sort_column);
2132 // find the sorted column index in row result
2133 // (this might be a multi-table query)
2134 $sorted_column_index = false;
2135 foreach($fields_meta as $key => $meta) {
2136 if ($meta->table == $sort_table && $meta->name == $sort_column) {
2137 $sorted_column_index = $key;
2138 break;
2141 if ($sorted_column_index !== false) {
2142 // fetch first row of the result set
2143 $row = PMA_DBI_fetch_row($dt_result);
2144 // initializing default arguments
2145 $default_function = 'default_function';
2146 $transform_function = $default_function;
2147 $transform_options = array();
2148 // check for non printable sorted row data
2149 $meta = $fields_meta[$sorted_column_index];
2150 if (stristr($meta->type, 'BLOB') || $meta->type == 'geometry') {
2151 $column_for_first_row = PMA_handle_non_printable_contents($meta->type, $row[$sorted_column_index], $transform_function, $transform_options, $default_function, $meta, NULL);
2152 } else {
2153 $column_for_first_row = $row[$sorted_column_index];
2155 $column_for_first_row = strtoupper(substr($column_for_first_row, 0, $GLOBALS['cfg']['LimitChars']));
2156 // fetch last row of the result set
2157 PMA_DBI_data_seek($dt_result, $num_rows - 1);
2158 $row = PMA_DBI_fetch_row($dt_result);
2159 // check for non printable sorted row data
2160 $meta = $fields_meta[$sorted_column_index];
2161 if (stristr($meta->type, 'BLOB') || $meta->type == 'geometry') {
2162 $column_for_last_row = PMA_handle_non_printable_contents($meta->type, $row[$sorted_column_index], $transform_function, $transform_options, $default_function, $meta, NULL);
2163 } else {
2164 $column_for_last_row = $row[$sorted_column_index];
2166 $column_for_last_row = strtoupper(substr($column_for_last_row, 0, $GLOBALS['cfg']['LimitChars']));
2167 // reset to first row for the loop in PMA_displayTableBody()
2168 PMA_DBI_data_seek($dt_result, 0);
2169 // we could also use here $sort_expression_nodirection
2170 $sorted_column_message = ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
2171 unset($row, $column_for_first_row, $column_for_last_row, $meta, $default_function, $transform_function, $transform_options);
2173 unset($sorted_column_index, $sort_table, $sort_column);
2176 // 2. ----- Displays the top of the page -----
2178 // 2.1 Displays a messages with position informations
2179 if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
2180 if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
2181 $selectstring = ', ' . $unlim_num_rows . ' ' . __('in query');
2182 } else {
2183 $selectstring = '';
2185 $last_shown_rec = ($_SESSION['tmp_user_values']['max_rows'] == 'all' || $pos_next > $total)
2186 ? $total - 1
2187 : $pos_next - 1;
2189 if (PMA_Table::isView($db, $table)
2190 && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
2191 $message = PMA_Message::notice(__('This view has at least this number of rows. Please refer to %sdocumentation%s.'));
2192 $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
2193 $message->addParam('[/a]');
2194 $message_view_warning = PMA_showHint($message);
2195 } else {
2196 $message_view_warning = false;
2199 $message = PMA_Message::success(__('Showing rows'));
2200 $message->addMessage($_SESSION['tmp_user_values']['pos']);
2201 if ($message_view_warning) {
2202 $message->addMessage('...', ' - ');
2203 $message->addMessage($message_view_warning);
2204 $message->addMessage('(');
2205 } else {
2206 $message->addMessage($last_shown_rec, ' - ');
2207 $message->addMessage(' (');
2208 $message->addMessage($pre_count . PMA_formatNumber($total, 0));
2209 $message->addString(__('total'));
2210 if (!empty($after_count)) {
2211 $message->addMessage($after_count);
2213 $message->addMessage($selectstring, '');
2214 $message->addMessage(', ', '');
2217 $messagge_qt = PMA_Message::notice(__('Query took %01.4f sec'));
2218 $messagge_qt->addParam($GLOBALS['querytime']);
2220 $message->addMessage($messagge_qt, '');
2221 $message->addMessage(')', '');
2223 $message->addMessage(isset($sorted_column_message) ? $sorted_column_message : '', '');
2225 PMA_showMessage($message, $sql_query, 'success');
2227 } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
2228 PMA_showMessage(__('Your SQL query has been executed successfully'), $sql_query, 'success');
2231 // 2.3 Displays the navigation bars
2232 if (! strlen($table)) {
2233 if (isset($analyzed_sql[0]['query_type'])
2234 && $analyzed_sql[0]['query_type'] == 'SELECT') {
2235 // table does not always contain a real table name,
2236 // for example in MySQL 5.0.x, the query SHOW STATUS
2237 // returns STATUS as a table name
2238 $table = $fields_meta[0]->table;
2239 } else {
2240 $table = '';
2244 if ($is_display['nav_bar'] == '1') {
2245 PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'top_direction_dropdown');
2246 echo "\n";
2247 } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
2248 echo "\n" . '<br /><br />' . "\n";
2251 // 2b ----- Get field references from Database -----
2252 // (see the 'relation' configuration variable)
2254 // initialize map
2255 $map = array();
2257 // find tables
2258 $target=array();
2259 if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
2260 foreach ($analyzed_sql[0]['table_ref'] AS $table_ref_position => $table_ref) {
2261 $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
2264 $tabs = '(\'' . join('\',\'', $target) . '\')';
2266 if (! strlen($table)) {
2267 $exist_rel = false;
2268 } else {
2269 // To be able to later display a link to the related table,
2270 // we verify both types of relations: either those that are
2271 // native foreign keys or those defined in the phpMyAdmin
2272 // configuration storage. If no PMA storage, we won't be able
2273 // to use the "column to display" notion (for example show
2274 // the name related to a numeric id).
2275 $exist_rel = PMA_getForeigners($db, $table, '', 'both');
2276 if ($exist_rel) {
2277 foreach ($exist_rel AS $master_field => $rel) {
2278 $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
2279 $map[$master_field] = array($rel['foreign_table'],
2280 $rel['foreign_field'],
2281 $display_field,
2282 $rel['foreign_db']);
2283 } // end while
2284 } // end if
2285 } // end if
2286 // end 2b
2288 // 3. ----- Displays the results table -----
2289 PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction);
2290 $url_query = '';
2291 echo '<tbody>' . "\n";
2292 $clause_is_unique = PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
2293 // vertical output case
2294 if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
2295 PMA_displayVerticalTable();
2296 } // end if
2297 unset($vertical_display);
2298 echo '</tbody>' . "\n";
2300 </table>
2302 <?php
2303 // 4. ----- Displays the link for multi-fields edit and delete
2305 if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
2307 $delete_text = $is_display['del_lnk'] == 'dr' ? __('Delete') : __('Kill');
2309 $_url_params = array(
2310 'db' => $db,
2311 'table' => $table,
2312 'sql_query' => $sql_query,
2313 'goto' => $goto,
2315 $uncheckall_url = 'sql.php' . PMA_generate_common_url($_url_params);
2317 $_url_params['checkall'] = '1';
2318 $checkall_url = 'sql.php' . PMA_generate_common_url($_url_params);
2320 if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
2321 $checkall_params['onclick'] = 'if (setCheckboxes(\'resultsForm\', true)) return false;';
2322 $uncheckall_params['onclick'] = 'if (setCheckboxes(\'resultsForm\', false)) return false;';
2323 } else {
2324 $checkall_params['onclick'] = 'if (markAllRows(\'resultsForm\')) return false;';
2325 $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'resultsForm\')) return false;';
2327 $checkall_link = PMA_linkOrButton($checkall_url, __('Check All'), $checkall_params, false);
2328 $uncheckall_link = PMA_linkOrButton($uncheckall_url, __('Uncheck All'), $uncheckall_params, false);
2329 if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') {
2330 echo '<img class="selectallarrow" width="38" height="22"'
2331 .' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
2332 .' alt="' . __('With selected:') . '" />';
2334 echo $checkall_link . "\n"
2335 .' / ' . "\n"
2336 .$uncheckall_link . "\n"
2337 .'<i>' . __('With selected:') . '</i>' . "\n";
2339 PMA_buttonOrImage('submit_mult', 'mult_submit',
2340 'submit_mult_change', __('Change'), 'b_edit.png', 'edit');
2341 PMA_buttonOrImage('submit_mult', 'mult_submit',
2342 'submit_mult_delete', $delete_text, 'b_drop.png', 'delete');
2343 if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT') {
2344 PMA_buttonOrImage('submit_mult', 'mult_submit',
2345 'submit_mult_export', __('Export'),
2346 'b_tblexport.png', 'export');
2348 echo "\n";
2350 echo '<input type="hidden" name="sql_query"'
2351 .' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
2353 if (! empty($GLOBALS['url_query'])) {
2354 echo '<input type="hidden" name="url_query"'
2355 .' value="' . $GLOBALS['url_query'] . '" />' . "\n";
2358 echo '<input type="hidden" name="clause_is_unique"'
2359 .' value="' . $clause_is_unique . '" />' . "\n";
2361 echo '</form>' . "\n";
2364 // 5. ----- Displays the navigation bar at the bottom if required -----
2366 if ($is_display['nav_bar'] == '1') {
2367 echo '<br />' . "\n";
2368 PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown');
2369 } elseif (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
2370 echo "\n" . '<br /><br />' . "\n";
2373 // 6. ----- Displays "Query results operations"
2374 if (! isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
2375 PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
2377 } // end of the 'PMA_displayTable()' function
2379 function default_function($buffer) {
2380 $buffer = htmlspecialchars($buffer);
2381 $buffer = str_replace("\011", ' &nbsp;&nbsp;&nbsp;',
2382 str_replace(' ', ' &nbsp;', $buffer));
2383 $buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />', $buffer);
2385 return $buffer;
2389 * Displays operations that are available on results.
2391 * @param array the display mode
2392 * @param array the analyzed query
2394 * @global string $db the database name
2395 * @global string $table the table name
2396 * @global string $sql_query the current SQL query
2397 * @global integer $unlim_num_rows the total number of rows returned by the
2398 * SQL query without any programmatically
2399 * appended "LIMIT" clause
2401 * @access private
2403 * @see PMA_showMessage(), PMA_setDisplayMode(),
2404 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
2405 * PMA_displayTableBody(), PMA_displayResultsOperations()
2407 function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
2408 global $db, $table, $sql_query, $unlim_num_rows, $fields_meta;
2410 $header_shown = false;
2411 $header = '<fieldset><legend>' . __('Query results operations') . '</legend>';
2413 if ($the_disp_mode[6] == '1' || $the_disp_mode[9] == '1') {
2414 // Displays "printable view" link if required
2415 if ($the_disp_mode[9] == '1') {
2417 if (!$header_shown) {
2418 echo $header;
2419 $header_shown = true;
2422 $_url_params = array(
2423 'db' => $db,
2424 'table' => $table,
2425 'printview' => '1',
2426 'sql_query' => $sql_query,
2428 $url_query = PMA_generate_common_url($_url_params);
2430 echo PMA_linkOrButton(
2431 'sql.php' . $url_query,
2432 PMA_getIcon('b_print.png', __('Print view'), false, true),
2433 '', true, true, 'print_view') . "\n";
2435 if ($_SESSION['tmp_user_values']['display_text']) {
2436 $_url_params['display_text'] = 'F';
2437 echo PMA_linkOrButton(
2438 'sql.php' . PMA_generate_common_url($_url_params),
2439 PMA_getIcon('b_print.png', __('Print view (with full texts)'), false, true),
2440 '', true, true, 'print_view') . "\n";
2441 unset($_url_params['display_text']);
2443 } // end displays "printable view"
2446 // Export link
2447 // (the url_query has extra parameters that won't be used to export)
2448 // (the single_table parameter is used in display_export.lib.php
2449 // to hide the SQL and the structure export dialogs)
2450 // If the parser found a PROCEDURE clause
2451 // (most probably PROCEDURE ANALYSE()) it makes no sense to
2452 // display the Export link).
2453 if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && ! isset($printview) && ! isset($analyzed_sql[0]['queryflags']['procedure'])) {
2454 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && ! isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
2455 $_url_params['single_table'] = 'true';
2457 if (!$header_shown) {
2458 echo $header;
2459 $header_shown = true;
2461 $_url_params['unlim_num_rows'] = $unlim_num_rows;
2464 * At this point we don't know the table name; this can happen
2465 * for example with a query like
2466 * SELECT bike_code FROM (SELECT bike_code FROM bikes) tmp
2467 * As a workaround we set in the table parameter the name of the
2468 * first table of this database, so that tbl_export.php and
2469 * the script it calls do not fail
2471 if (empty($_url_params['table']) && !empty($_url_params['db'])) {
2472 $_url_params['table'] = PMA_DBI_fetch_value("SHOW TABLES");
2473 /* No result (probably no database selected) */
2474 if ($_url_params['table'] === FALSE) {
2475 unset($_url_params['table']);
2479 echo PMA_linkOrButton(
2480 'tbl_export.php' . PMA_generate_common_url($_url_params),
2481 PMA_getIcon('b_tblexport.png', __('Export'), false, true),
2482 '', true, true, '') . "\n";
2484 // show chart
2485 echo PMA_linkOrButton(
2486 'tbl_chart.php' . PMA_generate_common_url($_url_params),
2487 PMA_getIcon('b_chart.png', __('Display chart'), false, true),
2488 '', true, true, '') . "\n";
2490 // show GIS chart
2491 $geometry_found = false;
2492 // If atleast one geometry field is found
2493 foreach ($fields_meta as $meta) {
2494 if ($meta->type == 'geometry') {
2495 $geometry_found = true;
2496 break;
2499 if ($geometry_found) {
2500 echo PMA_linkOrButton(
2501 'tbl_gis_visualization.php' . PMA_generate_common_url($_url_params),
2502 PMA_getIcon('b_globe.gif', __('Visualize GIS data'), false, true),
2503 '', true, true, '') . "\n";
2507 // CREATE VIEW
2510 * @todo detect privileges to create a view
2511 * (but see 2006-01-19 note in display_create_table.lib.php,
2512 * I think we cannot detect db-specific privileges reliably)
2513 * Note: we don't display a Create view link if we found a PROCEDURE clause
2515 if (!$header_shown) {
2516 echo $header;
2517 $header_shown = true;
2519 if (! isset($analyzed_sql[0]['queryflags']['procedure'])) {
2520 echo PMA_linkOrButton(
2521 'view_create.php' . $url_query,
2522 PMA_getIcon('b_views.png', __('Create view'), false, true),
2523 '', true, true, '') . "\n";
2525 if ($header_shown) {
2526 echo '</fieldset><br />';
2531 * Verifies what to do with non-printable contents (binary or BLOB)
2532 * in Browse mode.
2534 * @param string $category BLOB|BINARY|GEOMETRY
2535 * @param string $content the binary content
2536 * @param string $transform_function
2537 * @param string $transform_options
2538 * @param string $default_function
2539 * @param object $meta the meta-information about this field
2540 * @return mixed string or float
2542 function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta, $url_params = array()) {
2543 $result = '[' . $category;
2544 if (is_null($content)) {
2545 $result .= ' - NULL';
2546 $size = 0;
2547 } elseif (isset($content)) {
2548 $size = strlen($content);
2549 $display_size = PMA_formatByteDown($size, 3, 1);
2550 $result .= ' - '. $display_size[0] . ' ' . $display_size[1];
2552 $result .= ']';
2554 if (strpos($transform_function, 'octetstream')) {
2555 $result = $content;
2557 if ($size > 0) {
2558 if ($default_function != $transform_function) {
2559 $result = $transform_function($result, $transform_options, $meta);
2560 } else {
2561 $result = $default_function($result, array(), $meta);
2562 if (stristr($meta->type, 'BLOB') && $_SESSION['tmp_user_values']['display_blob']) {
2563 // in this case, restart from the original $content
2564 $result = htmlspecialchars(PMA_replace_binary_contents($content));
2566 /* Create link to download */
2567 if (count($url_params) > 0) {
2568 $result = '<a href="tbl_get_field.php' . PMA_generate_common_url($url_params) . '">' . $result . '</a>';
2572 return($result);
2576 * Prepares the displayable content of a data cell in Browse mode,
2577 * taking into account foreign key description field and transformations
2579 * @param string $class
2580 * @param string $condition_field
2581 * @param string $analyzed_sql
2582 * @param object $meta the meta-information about this field
2583 * @param string $map
2584 * @param string $data
2585 * @param string $transform_function
2586 * @param string $default_function
2587 * @param string $nowrap
2588 * @param string $where_comparison
2589 * @param bool $is_field_truncated
2590 * @return string formatted data
2592 function PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated ) {
2594 $result = ' class="' . PMA_addClass($class, $condition_field, $meta, $nowrap, $is_field_truncated, $transform_function, $default_function) . '">';
2596 if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
2597 foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
2598 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
2599 if (isset($alias) && strlen($alias)) {
2600 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
2601 if ($alias == $meta->name) {
2602 // this change in the parameter does not matter
2603 // outside of the function
2604 $meta->name = $true_column;
2605 } // end if
2606 } // end if
2607 } // end foreach
2608 } // end if
2610 if (isset($map[$meta->name])) {
2611 // Field to display from the foreign table?
2612 if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
2613 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
2614 . ' FROM ' . PMA_backquote($map[$meta->name][3])
2615 . '.' . PMA_backquote($map[$meta->name][0])
2616 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
2617 . $where_comparison;
2618 $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
2619 if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
2620 list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
2621 } else {
2622 $dispval = __('Link not found');
2624 @PMA_DBI_free_result($dispresult);
2625 } else {
2626 $dispval = '';
2627 } // end if... else...
2629 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
2630 $result .= ($transform_function != $default_function ? $transform_function($data, $transform_options, $meta) : $transform_function($data, array(), $meta)) . ' <code>[-&gt;' . $dispval . ']</code>';
2631 } else {
2633 if ('K' == $_SESSION['tmp_user_values']['relational_display']) {
2634 // user chose "relational key" in the display options, so
2635 // the title contains the display field
2636 $title = (! empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
2637 } else {
2638 $title = ' title="' . htmlspecialchars($data) . '"';
2641 $_url_params = array(
2642 'db' => $map[$meta->name][3],
2643 'table' => $map[$meta->name][0],
2644 'pos' => '0',
2645 'sql_query' => 'SELECT * FROM '
2646 . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
2647 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
2648 . $where_comparison,
2650 $result .= '<a href="sql.php' . PMA_generate_common_url($_url_params)
2651 . '"' . $title . '>';
2653 if ($transform_function != $default_function) {
2654 // always apply a transformation on the real data,
2655 // not on the display field
2656 $result .= $transform_function($data, $transform_options, $meta);
2657 } else {
2658 if ('D' == $_SESSION['tmp_user_values']['relational_display']) {
2659 // user chose "relational display field" in the
2660 // display options, so show display field in the cell
2661 $result .= $transform_function($dispval, array(), $meta);
2662 } else {
2663 // otherwise display data in the cell
2664 $result .= $transform_function($data, array(), $meta);
2667 $result .= '</a>';
2669 } else {
2670 $result .= ($transform_function != $default_function ? $transform_function($data, $transform_options, $meta) : $transform_function($data, array(), $meta));
2672 $result .= '</td>' . "\n";
2674 return $result;
2678 * Generates a checkbox for multi-row submits
2680 * @param string $del_url
2681 * @param array $is_display
2682 * @param string $row_no
2683 * @param string $where_clause_html
2684 * @param string $del_query
2685 * @param string $id_suffix
2686 * @param string $class
2687 * @return string the generated HTML
2690 function PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix, $class) {
2691 $ret = '';
2692 if (! empty($del_url) && $is_display['del_lnk'] != 'kp') {
2693 $ret .= '<td ';
2694 if (! empty($class)) {
2695 $ret .= 'class="' . $class . '"';
2697 $ret .= ' align="center">'
2698 . '<input type="checkbox" id="id_rows_to_delete' . $row_no . $id_suffix . '" name="rows_to_delete[' . $where_clause_html . ']"'
2699 . ' class="multi_checkbox"'
2700 . ' value="' . htmlspecialchars($del_query) . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />'
2701 . ' </td>';
2703 return $ret;
2707 * Generates an Edit link
2709 * @param string $edit_url
2710 * @param string $class
2711 * @param string $edit_str
2712 * @param string $where_clause
2713 * @param string $where_clause_html
2714 * @return string the generated HTML
2716 function PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html) {
2717 $ret = '';
2718 if (! empty($edit_url)) {
2719 $ret .= '<td class="' . $class . '" align="center" ' . ' ><span class="nowrap">'
2720 . PMA_linkOrButton($edit_url, $edit_str, array(), false);
2722 * Where clause for selecting this row uniquely is provided as
2723 * a hidden input. Used by jQuery scripts for handling inline editing
2725 if(! empty($where_clause)) {
2726 $ret .= '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />';
2728 $ret .= '</span></td>';
2730 return $ret;
2734 * Generates an Copy link
2736 * @param string $copy_url
2737 * @param string $copy_str
2738 * @param string $where_clause
2739 * @param string $where_clause_html
2740 * @return string the generated HTML
2742 function PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause_html, $class) {
2743 $ret = '';
2744 if (! empty($copy_url)) {
2745 $ret .= '<td ';
2746 if (! empty($class)) {
2747 $ret .= 'class="' . $class . '" ';
2749 $ret .= 'align="center" ' . ' ><span class="nowrap">'
2750 . PMA_linkOrButton($copy_url, $copy_str, array(), false);
2752 * Where clause for selecting this row uniquely is provided as
2753 * a hidden input. Used by jQuery scripts for handling inline editing
2755 if(! empty($where_clause)) {
2756 $ret .= '<input type="hidden" class="where_clause" value ="' . $where_clause_html . '" />';
2758 $ret .= '</span></td>';
2760 return $ret;
2764 * Generates a Delete link
2766 * @param string $del_url
2767 * @param string $del_str
2768 * @param string $js_conf
2769 * @param string $class
2770 * @return string the generated HTML
2772 function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class) {
2773 $ret = '';
2774 if (! empty($del_url)) {
2775 $ret .= '<td ';
2776 if (! empty($class)) {
2777 $ret .= 'class="' . $class . '" ';
2779 $ret .= 'align="center" ' . ' >'
2780 . PMA_linkOrButton($del_url, $del_str, $js_conf, false)
2781 . '</td>';
2783 return $ret;
2787 * Generates checkbox and links at some position (left or right)
2788 * (only called for horizontal mode)
2790 * @param string $position
2791 * @param string $del_url
2792 * @param array $is_display
2793 * @param string $row_no
2794 * @param string $where_clause
2795 * @param string $where_clause_html
2796 * @param string $del_query
2797 * @param string $id_suffix
2798 * @param string $edit_url
2799 * @param string $copy_url
2800 * @param string $class
2801 * @param string $edit_str
2802 * @param string $del_str
2803 * @param string $js_conf
2804 * @return string the generated HTML
2806 function PMA_generateCheckboxAndLinks($position, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $del_query, $id_suffix, $edit_url, $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf) {
2807 $ret = '';
2809 if ($position == 'left') {
2810 $ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_left', '', '', '');
2812 $ret .= PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html, '');
2814 $ret .= PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause_html, '');
2816 $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', '');
2818 } elseif ($position == 'right') {
2819 $ret .= PMA_generateDeleteLink($del_url, $del_str, $js_conf, '', '');
2821 $ret .= PMA_generateCopyLink($copy_url, $copy_str, $where_clause, $where_clause_html, '');
2823 $ret .= PMA_generateEditLink($edit_url, $class, $edit_str, $where_clause, $where_clause_html, '');
2825 $ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_right', '', '', '');
2826 } else { // $position == 'none'
2827 $ret .= PMA_generateCheckboxForMulti($del_url, $is_display, $row_no, $where_clause_html, $del_query, $id_suffix='_left', '', '', '');
2829 return $ret;